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);
160 
161  const std::list < SMESH_subMesh * >&
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 
183 
187  typedef TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap;
188  const TAncestorMap& GetAncestorMap() const { return _mapAncestors; }
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 
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;
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_Mesh::STLToMesh
int STLToMesh(const char *theFileName)
SMESH_Mesh::NotifySubMeshesHypothesisModification
void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis *theChangedHyp)
Say all submeshes that theChangedHyp has been modified.
SMESH_Mesh::MEDToMesh
int MEDToMesh(const char *theFileName, const char *theMeshName)
SMESH_Mesh::GetAutoColor
bool GetAutoColor()
SMESH_Mesh::_studyId
int _studyId
Definition: SMESH_Mesh.hxx:261
SMESH_Mesh::_isShapeToMesh
bool _isShapeToMesh
Definition: SMESH_Mesh.hxx:265
SMESH_Mesh::_gen
SMESH_Gen * _gen
Definition: SMESH_Mesh.hxx:271
SMESH_Mesh::IsMainShape
bool IsMainShape(const TopoDS_Shape &theShape) const
SMESH_Mesh::HasDuplicatedGroupNamesMED
bool HasDuplicatedGroupNamesMED()
Check group names for duplications. Consider maximum group name length stored in MED file.
SMESHDS_Command.hxx
SMESH_Mesh::GetLog
const std::list< SMESHDS_Command * > & GetLog()
SMESH_Mesh::SMESH_Mesh
SMESH_Mesh(int theLocalId, int theStudyId, SMESH_Gen *theGen, bool theIsEmbeddedMode, SMESHDS_Document *theDocument)
SMESH_Mesh::IsUsedHypothesis
bool IsUsedHypothesis(SMESHDS_Hypothesis *anHyp, const SMESH_subMesh *aSubMesh)
Return True if anHyp is used to mesh aSubShape.
SMESH_Mesh::_subMeshesUsingHypothesisList
std::list< SMESH_subMesh * > _subMeshesUsingHypothesisList
Definition: SMESH_Mesh.hxx:266
SMESH_Mesh::ShapeToMesh
void ShapeToMesh(const TopoDS_Shape &aShape)
Set geometry to be meshed.
SMESH_Mesh::GetSubMeshUsingHypothesis
const std::list< SMESH_subMesh * > & GetSubMeshUsingHypothesis(SMESHDS_Hypothesis *anHyp)
Utils_SALOME_Exception.hxx
SMESH_Mesh::_isAutoColor
bool _isAutoColor
Definition: SMESH_Mesh.hxx:273
SMDSAbs_ElementType.hxx
SMESH_Mesh::GetHypotheses
int GetHypotheses(const TopoDS_Shape &aSubShape, const SMESH_HypoFilter &aFilter, std::list< const SMESHDS_Hypothesis * > &aHypList, const bool andAncestors) const
SMDSAbs_ElementOrder
SMDSAbs_ElementOrder
Definition: SMDSAbs_ElementType.hxx:63
SMESH_Group
Definition: SMESH_Group.hxx:42
SMESH_Mesh::GetGroupSubMeshesContaining
std::list< SMESH_subMesh * > GetGroupSubMeshesContaining(const TopoDS_Shape &shape) const
Return submeshes of groups containing the given subshape.
SMESH_Hypothesis::Hypothesis_Status
Hypothesis_Status
Definition: SMESH_Hypothesis.hxx:51
SMESHDS_Hypothesis
Definition: SMESHDS_Hypothesis.hxx:37
SMESH_subMesh
Definition: SMESH_subMesh.hxx:60
SMESH_Mesh::ConvertToStandalone
SMESH_Group * ConvertToStandalone(int theGroupID)
ORDER_ANY
@ ORDER_ANY
Definition: SMDSAbs_ElementType.hxx:64
SMESH_Mesh::SMESH_Mesh
SMESH_Mesh(const SMESH_Mesh &)
Definition: SMESH_Mesh.hxx:281
SMESH_Mesh::RemoveHypothesis
SMESH_Hypothesis::Hypothesis_Status RemoveHypothesis(const TopoDS_Shape &aSubShape, int anHypId)
SMESH_HypoFilter
Definition: SMESH_HypoFilter.hxx:55
SMESHDS_Mesh
Definition: SMESHDS_Mesh.hxx:59
SALOME_Exception
#define SALOME_Exception
Definition: Utils_SALOME_Exception.hxx:5
SMESH_Mesh::SetAutoColor
void SetAutoColor(bool theAutoColor)
SMESH_Mesh::_myMeshDS
SMESHDS_Mesh * _myMeshDS
Definition: SMESH_Mesh.hxx:268
SMESH_Mesh::GetAncestors
const TopTools_ListOfShape & GetAncestors(const TopoDS_Shape &theSubShape) const
Return list of ancestors of theSubShape in the order that lower dimention shapes come first.
SMESH_Mesh::PseudoShape
static const TopoDS_Solid & PseudoShape()
Return a solid which is returned by GetShapeToMesh() if a real geometry to be meshed was not set.
SMESH_Mesh::RemoveGroup
void RemoveGroup(const int theGroupID)
SMESH_Gen
Definition: SMESH_Gen.hxx:63
SMESH_Mesh::GetMeshDS
SMESHDS_Mesh * GetMeshDS()
Definition: SMESH_Mesh.hxx:139
SMESH_Mesh::GetGroups
GroupIteratorPtr GetGroups() const
SMESH_Mesh::AddGroup
SMESH_Group * AddGroup(const SMDSAbs_ElementType theType, const char *theName, int &theId, const TopoDS_Shape &theShape=TopoDS_Shape())
SMESH_Mesh::_myDocument
SMESHDS_Document * _myDocument
Definition: SMESH_Mesh.hxx:267
SMESH_Hypothesis
Definition: SMESH_Hypothesis.hxx:48
SMESH_Mesh::DATToMesh
int DATToMesh(const char *theFileName)
SMESH_Mesh::GetHypothesisList
const std::list< const SMESHDS_Hypothesis * > & GetHypothesisList(const TopoDS_Shape &aSubShape) const
SMESH_Mesh::TAncestorMap
TopTools_IndexedDataMapOfShapeListOfShape TAncestorMap
Return data map of descendant to ancestor shapes.
Definition: SMESH_Mesh.hxx:187
SMESH_Mesh::GetSubMeshContaining
SMESH_subMesh * GetSubMeshContaining(const int aShapeID) const
SMESH_Mesh::GetGroup
SMESH_Group * GetGroup(const int theGroupID)
SMESH_Mesh::_mapGroup
std::map< int, SMESH_Group * > _mapGroup
Definition: SMESH_Mesh.hxx:270
SMESH_Mesh::_shapeDiagonal
double _shapeDiagonal
diagonal size of bounding box of shape to mesh
Definition: SMESH_Mesh.hxx:275
SMESH_Hypothesis.hxx
SMESH_Mesh::GetElementType
SMDSAbs_ElementType GetElementType(const int id, const bool iselem)
SMESH_SMESH.hxx
SMESH_Mesh::UNVToMesh
int UNVToMesh(const char *theFileName)
SMESHDS_Mesh.hxx
SMESH_Mesh::GetShapeDiagonalSize
double GetShapeDiagonalSize() const
Return diagonal size of bounding box of shape to mesh.
SMESH_Mesh::GetSubMeshContaining
SMESH_subMesh * GetSubMeshContaining(const TopoDS_Shape &aSubShape) const
SMESH_Mesh::IsNotConformAllowed
bool IsNotConformAllowed() const
check if a hypothesis alowing notconform mesh is present
SMESHDS_Document
Definition: SMESHDS_Document.hxx:37
SMESH_Mesh::_mapSubMesh
std::map< int, SMESH_subMesh * > _mapSubMesh
Definition: SMESH_Mesh.hxx:269
SMESH_Mesh
Definition: SMESH_Mesh.hxx:55
SMESH_Mesh::GetShapeDiagonalSize
static double GetShapeDiagonalSize(const TopoDS_Shape &aShape)
Return diagonal size of bounding box of a shape.
SMESH_Mesh::~SMESH_Mesh
virtual ~SMESH_Mesh()
SMESH_Mesh::ExportMED
void ExportMED(const char *file, const char *theMeshName=NULL, bool theAutoGroups=true, int theVersion=0)
SMESH_Mesh::_idDoc
int _idDoc
Definition: SMESH_Mesh.hxx:262
SMESH_Mesh::GroupIteratorPtr
boost::shared_ptr< SMDS_Iterator< SMESH_Group * > > GroupIteratorPtr
Definition: SMESH_Mesh.hxx:240
SMDSAbs_ElementType
SMDSAbs_ElementType
Type (node, edge, face or volume) of elements.
Definition: SMDSAbs_ElementType.hxx:33
SMESH_Mesh::GetShapeToMesh
TopoDS_Shape GetShapeToMesh() const
Return geometry to be meshed. (It may be a PseudoShape()!)
SMESH_Mesh::_id
int _id
Definition: SMESH_Mesh.hxx:260
SMESH_Mesh::SMESH_Mesh
SMESH_Mesh()
Definition: SMESH_Mesh.hxx:280
SMESH_Mesh::AddHypothesis
SMESH_Hypothesis::Hypothesis_Status AddHypothesis(const TopoDS_Shape &aSubShape, int anHypId)
SMESH_Mesh::_mapAncestors
TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors
Definition: SMESH_Mesh.hxx:277
SMESH_Mesh::GetHypothesis
const SMESH_Hypothesis * GetHypothesis(const TopoDS_Shape &aSubShape, const SMESH_HypoFilter &aFilter, const bool andAncestors, TopoDS_Shape *assignedTo=0) const
SMESH_Mesh::Dump
ostream & Dump(ostream &save)
SMESH_Mesh::_nbSubShapes
int _nbSubShapes
Definition: SMESH_Mesh.hxx:264
SMESH_Mesh::ClearSubMesh
void ClearSubMesh(const int theShapeId)
Remove all nodes and elements of indicated shape.
SMESH_Mesh::GetGroupIds
std::list< int > GetGroupIds() const
SMESH_Mesh::GetGen
SMESH_Gen * GetGen()
Definition: SMESH_Mesh.hxx:141
SMESH_Mesh::Clear
void Clear()
Remove all nodes and elements.
SMESH_Mesh::HasShapeToMesh
bool HasShapeToMesh() const
Return true if there is a geometry to be meshed, not PseudoShape()
Definition: SMESH_Mesh.hxx:76
SMESH_Mesh::_groupId
int _groupId
Definition: SMESH_Mesh.hxx:263
SMESH_Mesh::GetSubMesh
SMESH_subMesh * GetSubMesh(const TopoDS_Shape &aSubShape)
SMESH_EXPORT
#define SMESH_EXPORT
Definition: SMESH_SMESH.hxx:36