1 // SMESH SMESH : implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESH_Mesh.hxx
25 // Author : Paul RASCLE, EDF
29 #ifndef _SMESH_MESH_HXX_
30 #define _SMESH_MESH_HXX_
32 #include "SMESH_SMESH.hxx"
34 #include "SMESH_Hypothesis.hxx"
35 //#include "SMESH_subMesh.hxx"
37 #include "SMESHDS_Document.hxx"
38 #include "SMESHDS_Mesh.hxx"
39 #include "SMESHDS_Command.hxx"
40 #include "SMDSAbs_ElementType.hxx"
42 //#include "NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx"
43 #include "SMESH_IndexedDataMapOfShapeIndexedMapOfShape.hxx"
45 #include "Utils_SALOME_Exception.hxx"
48 #include <TopExp_Explorer.hxx>
50 #include <TopoDS_Iterator.hxx>
51 #include <TopoDS_Compound.hxx>
52 #include <TopoDS_CompSolid.hxx>
53 #include <TopoDS_Solid.hxx>
54 #include <TopoDS_Shell.hxx>
55 #include <TopoDS_Face.hxx>
56 #include <TopoDS_Wire.hxx>
57 #include <TopoDS_Edge.hxx>
58 #include <TopoDS_Vertex.hxx>
59 #include <TopoDS_Shape.hxx>
60 #include <TopTools_IndexedMapOfShape.hxx>
61 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
72 class TopTools_ListOfShape;
74 class SMESH_HypoFilter;
76 //typedef NMTTools_IndexedDataMapOfShapeIndexedMapOfShape IndexedMapOfChain;
77 typedef SMESH_IndexedDataMapOfShapeIndexedMapOfShape IndexedMapOfChain;
79 class SMESH_EXPORT SMESH_Mesh
82 SMESH_Mesh(const SMESH_Mesh&);
84 SMESH_Mesh(int theLocalId,
87 bool theIsEmbeddedMode,
88 SMESHDS_Document* theDocument);
90 virtual ~SMESH_Mesh();
92 void ShapeToMesh(const TopoDS_Shape & aShape);
94 int UNVToMesh(const char* theFileName);
96 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
98 int MEDToMesh(const char* theFileName, const char* theMeshName);
100 int STLToMesh(const char* theFileName);
102 SMESH_Hypothesis::Hypothesis_Status
103 AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
104 throw(SALOME_Exception);
106 SMESH_Hypothesis::Hypothesis_Status
107 RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
108 throw(SALOME_Exception);
110 const list <const SMESHDS_Hypothesis * >&
111 GetHypothesisList(const TopoDS_Shape & aSubShape) const
112 throw(SALOME_Exception);
114 const SMESH_Hypothesis * GetHypothesis(const TopoDS_Shape & aSubShape,
115 const SMESH_HypoFilter& aFilter,
116 const bool andAncestors) const;
118 int GetHypotheses(const TopoDS_Shape & aSubShape,
119 const SMESH_HypoFilter& aFilter,
120 list <const SMESHDS_Hypothesis * >& aHypList,
121 const bool andAncestors) const;
123 const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
125 void ClearLog() throw(SALOME_Exception);
129 SMESHDS_Mesh * GetMeshDS();
133 SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
134 throw(SALOME_Exception);
136 SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape)
137 throw(SALOME_Exception);
139 SMESH_subMesh *GetSubMeshContaining(const int aShapeID)
140 throw(SALOME_Exception);
142 void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
143 // Say all submeshes that theChangedHyp has been modified
145 const list < SMESH_subMesh * >&
146 GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
147 throw(SALOME_Exception);
149 bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
150 const SMESH_subMesh * aSubMesh);
151 // Return True if anHyp is used to mesh aSubShape
153 bool IsNotConformAllowed() const;
154 // check if a hypothesis alowing notconform mesh is present
156 bool IsMainShape(const TopoDS_Shape& theShape) const;
158 const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape) const;
159 // return list of ancestors of theSubShape in the order
160 // that lower dimention shapes come first.
162 /*! Check group names for duplications.
163 * Consider maximum group name length stored in MED file.
165 bool HasDuplicatedGroupNamesMED();
167 void ExportMED(const char *file,
168 const char* theMeshName = NULL,
169 bool theAutoGroups = true,
171 throw(SALOME_Exception);
173 void ExportDAT(const char *file) throw(SALOME_Exception);
174 void ExportUNV(const char *file) throw(SALOME_Exception);
175 void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
177 int NbNodes() throw(SALOME_Exception);
180 * ElementOrder points out entities of what order are requested
183 ORDER_ANY, /*! entities of any order */
184 ORDER_LINEAR, /*! entities of 1st order */
185 ORDER_QUADRATIC /*! entities of 2nd order */
188 int NbEdges(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
190 int NbFaces(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
192 int NbTriangles(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
194 int NbQuadrangles(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
196 int NbPolygons() throw(SALOME_Exception);
198 int NbVolumes(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
200 int NbTetras(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
202 int NbHexas(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
204 int NbPyramids(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
206 int NbPrisms(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
208 int NbPolyhedrons() throw(SALOME_Exception);
210 int NbSubMesh() throw(SALOME_Exception);
212 int NbGroup() const { return _mapGroup.size(); }
214 SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
217 const TopoDS_Shape& theShape=TopoDS_Shape());
219 SMESH_Group* GetGroup (const int theGroupID);
221 list<int> GetGroupIds();
223 void RemoveGroup (const int theGroupID);
225 // Propagation hypothesis management
227 const SMESH_Hypothesis* IsLocal1DHypothesis (const TopoDS_Shape& theEdge);
228 // Returns a local 1D hypothesis used for theEdge.
230 bool IsPropagationHypothesis (const TopoDS_Shape& theEdge);
231 // Returns true, if a local Propagation hypothesis is set directly on <theEdge>
233 bool IsPropagatedHypothesis (const TopoDS_Shape& theEdge,
234 TopoDS_Shape& theMainEdge);
235 // Returns true, if a local 1D hypothesis is
236 // propagated on <theEdge> from some other edge.
237 // Returns through <theMainEdge> the edge, from
238 // which the 1D hypothesis is propagated on <theEdge>
240 bool IsReversedInChain (const TopoDS_Shape& theEdge,
241 const TopoDS_Shape& theMainEdge);
242 // Returns true if theEdge should be reversed to be
243 // co-directed with theMainEdge
245 bool RebuildPropagationChains();
246 bool RemovePropagationChain (const TopoDS_Shape& theMainEdge);
247 bool BuildPropagationChain (const TopoDS_Shape& theMainEdge);
249 SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
253 ostream& Dump(ostream & save);
256 // Propagation hypothesis management
257 void CleanMeshOnPropagationChain(const TopoDS_Shape& theMainEdge);
261 int _id; // id given by creator (unique within the creator instance)
263 int _idDoc; // id given by SMESHDS_Document
264 int _groupId; // id generator for group objects
265 bool _isShapeToMesh;// set to true when a shape is given (only once)
266 list <SMESH_subMesh *> _subMeshesUsingHypothesisList;
267 SMESHDS_Document * _myDocument;
268 SMESHDS_Mesh * _myMeshDS;
269 map <int, SMESH_subMesh *> _mapSubMesh;
270 map <int, SMESH_Group *> _mapGroup;
273 TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
275 IndexedMapOfChain _mapPropagationChains; // Propagation hypothesis management