SALOME - SMESH
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SMESH_Mesh.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : SMESH_Mesh.hxx
24 // Author : Paul RASCLE, EDF
25 // Module : SMESH
26 // $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESH/SMESH_Mesh.hxx,v 1.18.2.3 2008/11/27 12:25:15 abd Exp $
27 //
28 #ifndef _SMESH_MESH_HXX_
29 #define _SMESH_MESH_HXX_
30 
31 #include "SMESH_SMESH.hxx"
32 
33 #include "SMESH_Hypothesis.hxx"
34 
35 #include "SMESHDS_Mesh.hxx"
36 #include "SMESHDS_Command.hxx"
37 #include "SMDSAbs_ElementType.hxx"
38 
39 #include "SMESH_Exception.hxx"
40 
41 #include <TopoDS_Shape.hxx>
42 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
43 
44 #include <list>
45 #include <map>
46 
47 class SMESH_Gen;
48 class SMESHDS_Document;
49 class SMESH_Group;
50 class TopTools_ListOfShape;
51 class SMESH_subMesh;
52 class SMESH_HypoFilter;
53 class TopoDS_Solid;
54 
56 {
57 public:
58  SMESH_Mesh(int theLocalId,
59  int theStudyId,
60  SMESH_Gen* theGen,
61  bool theIsEmbeddedMode,
62  SMESHDS_Document* theDocument);
63 
64  virtual ~SMESH_Mesh();
65 
69  void ShapeToMesh(const TopoDS_Shape & aShape);
73  TopoDS_Shape GetShapeToMesh() const;
77  bool HasShapeToMesh() const { return _isShapeToMesh; }
81  double GetShapeDiagonalSize() const;
85  static double GetShapeDiagonalSize(const TopoDS_Shape & aShape);
90  static const TopoDS_Solid& PseudoShape();
91 
95  void Clear();
96 
100  void ClearSubMesh(const int theShapeId);
101 
102  int UNVToMesh(const char* theFileName);
106  int MEDToMesh(const char* theFileName, const char* theMeshName);
107 
108  int STLToMesh(const char* theFileName);
109 
110  int DATToMesh(const char* theFileName);
111 
113  AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
114  throw(SMESH_Exception);
115 
117  RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
118  throw(SMESH_Exception);
119 
120  const std::list <const SMESHDS_Hypothesis * >&
121  GetHypothesisList(const TopoDS_Shape & aSubShape) const
122  throw(SMESH_Exception);
123 
124  const SMESH_Hypothesis * GetHypothesis(const TopoDS_Shape & aSubShape,
125  const SMESH_HypoFilter& aFilter,
126  const bool andAncestors,
127  TopoDS_Shape* assignedTo=0) const;
128 
129  int GetHypotheses(const TopoDS_Shape & aSubShape,
130  const SMESH_HypoFilter& aFilter,
131  std::list <const SMESHDS_Hypothesis * >& aHypList,
132  const bool andAncestors) const;
133 
134  const std::list<SMESHDS_Command*> & GetLog() throw(SMESH_Exception);
135 
136  void ClearLog() throw(SMESH_Exception);
137 
138  int GetId() { return _id; }
139 
140  SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; }
141 
142  SMESH_Gen *GetGen() { return _gen; }
143 
144  SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
145  throw(SMESH_Exception);
146 
147  SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
148  throw(SMESH_Exception);
149 
150  SMESH_subMesh *GetSubMeshContaining(const int aShapeID) const
151  throw(SMESH_Exception);
155  std::list<SMESH_subMesh*> GetGroupSubMeshesContaining(const TopoDS_Shape & shape) const
156  throw(SMESH_Exception);
160  void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
161 
162  const std::list < SMESH_subMesh * >&
163  GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) throw(SMESH_Exception);
167  bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
168  const SMESH_subMesh * aSubMesh);
172  bool IsNotConformAllowed() const;
173 
174  bool IsMainShape(const TopoDS_Shape& theShape) const;
179  const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape) const;
180 
181  void SetAutoColor(bool theAutoColor) throw(SMESH_Exception);
182 
183  bool GetAutoColor() throw(SMESH_Exception);
184 
188  typedef TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap;
189  const TAncestorMap& GetAncestorMap() const { return _mapAncestors; }
194  bool HasDuplicatedGroupNamesMED();
195 
196  void ExportMED(const char *file,
197  const char* theMeshName = NULL,
198  bool theAutoGroups = true,
199  int theVersion = 0)
200  throw(SMESH_Exception);
201 
202  void ExportDAT(const char *file) throw(SMESH_Exception);
203  void ExportUNV(const char *file) throw(SMESH_Exception);
204  void ExportSTL(const char *file, const bool isascii) throw(SMESH_Exception);
205 
206  int NbNodes() throw(SMESH_Exception);
207 
208  int NbEdges(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
209 
210  int NbFaces(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
211 
212  int NbTriangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
213 
214  int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
215 
216  int NbPolygons() throw(SMESH_Exception);
217 
218  int NbVolumes(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
219 
220  int NbTetras(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
221 
222  int NbHexas(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
223 
224  int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
225 
226  int NbPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SMESH_Exception);
227 
228  int NbPolyhedrons() throw(SMESH_Exception);
229 
230  int NbSubMesh() throw(SMESH_Exception);
231 
232  int NbGroup() const { return _mapGroup.size(); }
233 
234  SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
235  const char* theName,
236  int& theId,
237  const TopoDS_Shape& theShape=TopoDS_Shape());
238 
239  typedef boost::shared_ptr< SMDS_Iterator<SMESH_Group*> > GroupIteratorPtr;
240  GroupIteratorPtr GetGroups() const;
241 
242  std::list<int> GetGroupIds() const;
243 
244  SMESH_Group* GetGroup (const int theGroupID);
245 
246  void RemoveGroup (const int theGroupID);
247 
248  SMESH_Group* ConvertToStandalone ( int theGroupID );
249 
250  SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
251 
252  //
253 
254  ostream& Dump(ostream & save);
255 
256 private:
257 
258 protected:
259  int _id; // id given by creator (unique within the creator instance)
260  int _studyId;
261  int _idDoc; // id given by SMESHDS_Document
262  int _groupId; // id generator for group objects
263  int _nbSubShapes; // initial nb of subshapes in the shape to mesh
264  bool _isShapeToMesh;// set to true when a shape is given (only once)
265  std::list <SMESH_subMesh*> _subMeshesUsingHypothesisList;
268  std::map <int, SMESH_subMesh*> _mapSubMesh;
269  std::map <int, SMESH_Group*> _mapGroup;
271 
273 
274  double _shapeDiagonal;
275 
276  TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
277 
278 protected:
280  SMESH_Mesh(const SMESH_Mesh&) {};
281 };
282 
283 #endif
SMESH_Gen * GetGen()
Definition: SMESH_Mesh.hxx:142
SMESH_Mesh(const SMESH_Mesh &)
Definition: SMESH_Mesh.hxx:280
bool _isAutoColor
Definition: SMESH_Mesh.hxx:272
bool _isShapeToMesh
Definition: SMESH_Mesh.hxx:264
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
SMDSAbs_ElementOrder
bool HasShapeToMesh() const
Return true if there is a geometry to be meshed, not PseudoShape()
Definition: SMESH_Mesh.hxx:77
SMESHDS_Mesh * _myMeshDS
Definition: SMESH_Mesh.hxx:267
SMESHDS_Document * _myDocument
Definition: SMESH_Mesh.hxx:266
SMESHDS_Mesh * GetMeshDS()
Definition: SMESH_Mesh.hxx:140
TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap
Return data map of descendant to ancestor shapes.
Definition: SMESH_Mesh.hxx:188
double _shapeDiagonal
diagonal size of bounding box of shape to mesh
Definition: SMESH_Mesh.hxx:274
TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors
Definition: SMESH_Mesh.hxx:276
std::map< int, SMESH_subMesh * > _mapSubMesh
Definition: SMESH_Mesh.hxx:268
std::map< int, SMESH_Group * > _mapGroup
Definition: SMESH_Mesh.hxx:269
boost::shared_ptr< SMDS_Iterator< SMESH_Group * > > GroupIteratorPtr
Definition: SMESH_Mesh.hxx:239
int _nbSubShapes
Definition: SMESH_Mesh.hxx:263
SMESH_Gen * _gen
Definition: SMESH_Mesh.hxx:270
std::list< SMESH_subMesh * > _subMeshesUsingHypothesisList
Definition: SMESH_Mesh.hxx:265
#define SMESH_EXPORT