SALOME - SMESH
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 //
27 #ifndef _SMESH_MESH_HXX_
28 #define _SMESH_MESH_HXX_
29 
30 #include "SMESH_SMESH.hxx"
31 
32 #include "SMESH_Hypothesis.hxx"
33 
34 #include "SMESHDS_Mesh.hxx"
35 #include "SMESHDS_Command.hxx"
36 #include "SMDSAbs_ElementType.hxx"
37 
39 
40 #include <TopoDS_Shape.hxx>
41 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
42 
43 #include <list>
44 #include <map>
45 
46 class SMESH_Gen;
47 class SMESHDS_Document;
48 class SMESH_Group;
49 class TopTools_ListOfShape;
50 class SMESH_subMesh;
51 class SMESH_HypoFilter;
52 class TopoDS_Solid;
53 
55 {
56 public:
57  SMESH_Mesh(int theLocalId,
58  int theStudyId,
59  SMESH_Gen* theGen,
60  bool theIsEmbeddedMode,
61  SMESHDS_Document* theDocument);
62 
63  virtual ~SMESH_Mesh();
64 
68  void ShapeToMesh(const TopoDS_Shape & aShape);
72  TopoDS_Shape GetShapeToMesh() const;
76  bool HasShapeToMesh() const { return _isShapeToMesh; }
80  double GetShapeDiagonalSize() const;
84  static double GetShapeDiagonalSize(const TopoDS_Shape & aShape);
89  static const TopoDS_Solid& PseudoShape();
90 
94  void Clear();
95 
99  void ClearSubMesh(const int theShapeId);
100 
101  int UNVToMesh(const char* theFileName);
105  int MEDToMesh(const char* theFileName, const char* theMeshName);
106 
107  int STLToMesh(const char* theFileName);
108 
109  int DATToMesh(const char* theFileName);
110 
112  AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
113  throw(SALOME_Exception);
114 
116  RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
117  throw(SALOME_Exception);
118 
119  const std::list <const SMESHDS_Hypothesis * >&
120  GetHypothesisList(const TopoDS_Shape & aSubShape) const
121  throw(SALOME_Exception);
122 
123  const SMESH_Hypothesis * GetHypothesis(const TopoDS_Shape & aSubShape,
124  const SMESH_HypoFilter& aFilter,
125  const bool andAncestors,
126  TopoDS_Shape* assignedTo=0) const;
127 
128  int GetHypotheses(const TopoDS_Shape & aSubShape,
129  const SMESH_HypoFilter& aFilter,
130  std::list <const SMESHDS_Hypothesis * >& aHypList,
131  const bool andAncestors) const;
132 
133  const std::list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
134 
135  void ClearLog() throw(SALOME_Exception);
136 
137  int GetId() { return _id; }
138 
139  SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; }
140 
141  SMESH_Gen *GetGen() { return _gen; }
142 
143  SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
144  throw(SALOME_Exception);
145 
146  SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
147  throw(SALOME_Exception);
148 
149  SMESH_subMesh *GetSubMeshContaining(const int aShapeID) const
150  throw(SALOME_Exception);
154  std::list<SMESH_subMesh*> GetGroupSubMeshesContaining(const TopoDS_Shape & shape) const
155  throw(SALOME_Exception);
159  void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
160 
161  const std::list < SMESH_subMesh * >&
162  GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) throw(SALOME_Exception);
166  bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
167  const SMESH_subMesh * aSubMesh);
171  bool IsNotConformAllowed() const;
172 
173  bool IsMainShape(const TopoDS_Shape& theShape) const;
178  const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape) const;
179 
180  void SetAutoColor(bool theAutoColor) throw(SALOME_Exception);
181 
182  bool GetAutoColor() throw(SALOME_Exception);
183 
187  typedef TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap;
188  const TAncestorMap& GetAncestorMap() const { return _mapAncestors; }
193  bool HasDuplicatedGroupNamesMED();
194 
195  void ExportMED(const char *file,
196  const char* theMeshName = NULL,
197  bool theAutoGroups = true,
198  int theVersion = 0)
199  throw(SALOME_Exception);
200 
201  void ExportDAT(const char *file) throw(SALOME_Exception);
202  void ExportUNV(const char *file) throw(SALOME_Exception);
203  void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
204 
205  int NbNodes() throw(SALOME_Exception);
206 
207  int Nb0DElements() throw(SALOME_Exception);
208 
209  int NbEdges(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
210 
211  int NbFaces(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
212 
213  int NbTriangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
214 
215  int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
216 
217  int NbPolygons() throw(SALOME_Exception);
218 
219  int NbVolumes(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
220 
221  int NbTetras(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
222 
223  int NbHexas(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
224 
225  int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
226 
227  int NbPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
228 
229  int NbPolyhedrons() throw(SALOME_Exception);
230 
231  int NbSubMesh() throw(SALOME_Exception);
232 
233  int NbGroup() const { return _mapGroup.size(); }
234 
235  SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
236  const char* theName,
237  int& theId,
238  const TopoDS_Shape& theShape=TopoDS_Shape());
239 
240  typedef boost::shared_ptr< SMDS_Iterator<SMESH_Group*> > GroupIteratorPtr;
241  GroupIteratorPtr GetGroups() const;
242 
243  std::list<int> GetGroupIds() const;
244 
245  SMESH_Group* GetGroup (const int theGroupID);
246 
247  void RemoveGroup (const int theGroupID);
248 
249  SMESH_Group* ConvertToStandalone ( int theGroupID );
250 
251  SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
252 
253  //
254 
255  ostream& Dump(ostream & save);
256 
257 private:
258 
259 protected:
260  int _id; // id given by creator (unique within the creator instance)
261  int _studyId;
262  int _idDoc; // id given by SMESHDS_Document
263  int _groupId; // id generator for group objects
264  int _nbSubShapes; // initial nb of subshapes in the shape to mesh
265  bool _isShapeToMesh;// set to true when a shape is given (only once)
266  std::list <SMESH_subMesh*> _subMeshesUsingHypothesisList;
269  std::map <int, SMESH_subMesh*> _mapSubMesh;
270  std::map <int, SMESH_Group*> _mapGroup;
272 
274 
275  double _shapeDiagonal;
276 
277  TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
278 
279 protected:
281  SMESH_Mesh(const SMESH_Mesh&) {};
282 };
283 
284 #endif
SMESH_Gen * GetGen()
Definition: SMESH_Mesh.hxx:141
SMESH_Mesh(const SMESH_Mesh &)
Definition: SMESH_Mesh.hxx:281
bool _isAutoColor
Definition: SMESH_Mesh.hxx:273
bool _isShapeToMesh
Definition: SMESH_Mesh.hxx:265
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
SMDSAbs_ElementOrder
SMESHDS_Mesh * _myMeshDS
Definition: SMESH_Mesh.hxx:268
SMESHDS_Document * _myDocument
Definition: SMESH_Mesh.hxx:267
SMESHDS_Mesh * GetMeshDS()
Definition: SMESH_Mesh.hxx:139
TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap
Return data map of descendant to ancestor shapes.
Definition: SMESH_Mesh.hxx:187
double _shapeDiagonal
diagonal size of bounding box of shape to mesh
Definition: SMESH_Mesh.hxx:275
const TAncestorMap & GetAncestorMap() const
Definition: SMESH_Mesh.hxx:188
TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors
Definition: SMESH_Mesh.hxx:277
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:36
std::map< int, SMESH_subMesh * > _mapSubMesh
Definition: SMESH_Mesh.hxx:269
std::map< int, SMESH_Group * > _mapGroup
Definition: SMESH_Mesh.hxx:270
bool HasShapeToMesh() const
Return true if there is a geometry to be meshed, not PseudoShape()
Definition: SMESH_Mesh.hxx:76
boost::shared_ptr< SMDS_Iterator< SMESH_Group * > > GroupIteratorPtr
Definition: SMESH_Mesh.hxx:240
int NbGroup() const
Definition: SMESH_Mesh.hxx:233
#define SALOME_Exception
int _nbSubShapes
Definition: SMESH_Mesh.hxx:264
SMESH_Gen * _gen
Definition: SMESH_Mesh.hxx:271
std::list< SMESH_subMesh * > _subMeshesUsingHypothesisList
Definition: SMESH_Mesh.hxx:266