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_Hypothesis.hxx"
33 //#include "SMESH_subMesh.hxx"
35 #include "SMESHDS_Document.hxx"
36 #include "SMESHDS_Mesh.hxx"
37 #include "SMESHDS_Command.hxx"
38 #include "SMDSAbs_ElementType.hxx"
40 //#include "NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx"
41 #include "SMESH_IndexedDataMapOfShapeIndexedMapOfShape.hxx"
43 #include "Utils_SALOME_Exception.hxx"
46 #include <TopExp_Explorer.hxx>
48 #include <TopoDS_Iterator.hxx>
49 #include <TopoDS_Compound.hxx>
50 #include <TopoDS_CompSolid.hxx>
51 #include <TopoDS_Solid.hxx>
52 #include <TopoDS_Shell.hxx>
53 #include <TopoDS_Face.hxx>
54 #include <TopoDS_Wire.hxx>
55 #include <TopoDS_Edge.hxx>
56 #include <TopoDS_Vertex.hxx>
57 #include <TopoDS_Shape.hxx>
58 #include <TopTools_IndexedMapOfShape.hxx>
59 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
70 class TopTools_ListOfShape;
72 class SMESH_HypoFilter;
75 typedef SMESH_IndexedDataMapOfShapeIndexedMapOfShape IndexedMapOfChain;
80 SMESH_Mesh(int theLocalId,
83 bool theIsEmbeddedMode,
84 SMESHDS_Document* theDocument);
86 virtual ~SMESH_Mesh();
89 * \brief Set geometry to be meshed
91 void ShapeToMesh(const TopoDS_Shape & aShape);
93 * \brief Return geometry to be meshed. (It may be a PseudoShape()!)
95 TopoDS_Shape GetShapeToMesh() const;
97 * \brief Return true if there is a geometry to be meshed, not PseudoShape()
99 bool HasShapeToMesh() const { return _isShapeToMesh; }
101 * \brief Return a solid which is returned by GetShapeToMesh() if
102 * a real geometry to be meshed was not set
104 static const TopoDS_Solid& PseudoShape();
107 int UNVToMesh(const char* theFileName);
109 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
111 int MEDToMesh(const char* theFileName, const char* theMeshName);
113 int STLToMesh(const char* theFileName);
115 SMESH_Hypothesis::Hypothesis_Status
116 AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
117 throw(SALOME_Exception);
119 SMESH_Hypothesis::Hypothesis_Status
120 RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
121 throw(SALOME_Exception);
123 const list <const SMESHDS_Hypothesis * >&
124 GetHypothesisList(const TopoDS_Shape & aSubShape) const
125 throw(SALOME_Exception);
127 const SMESH_Hypothesis * GetHypothesis(const TopoDS_Shape & aSubShape,
128 const SMESH_HypoFilter& aFilter,
129 const bool andAncestors) const;
131 int GetHypotheses(const TopoDS_Shape & aSubShape,
132 const SMESH_HypoFilter& aFilter,
133 list <const SMESHDS_Hypothesis * >& aHypList,
134 const bool andAncestors) const;
136 const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
138 void ClearLog() throw(SALOME_Exception);
140 int GetId() { return _id; }
142 SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; }
144 SMESH_Gen *GetGen() { return _gen; }
146 SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
147 throw(SALOME_Exception);
149 SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape)
150 throw(SALOME_Exception);
152 SMESH_subMesh *GetSubMeshContaining(const int aShapeID)
153 throw(SALOME_Exception);
155 void NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* theChangedHyp);
156 // Say all submeshes that theChangedHyp has been modified
158 const list < SMESH_subMesh * >&
159 GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
160 throw(SALOME_Exception);
162 bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
163 const SMESH_subMesh * aSubMesh);
164 // Return True if anHyp is used to mesh aSubShape
166 bool IsNotConformAllowed() const;
167 // check if a hypothesis alowing notconform mesh is present
169 bool IsMainShape(const TopoDS_Shape& theShape) const;
171 const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape) const;
172 // return list of ancestors of theSubShape in the order
173 // that lower dimention shapes come first.
175 /*! Check group names for duplications.
176 * Consider maximum group name length stored in MED file.
178 bool HasDuplicatedGroupNamesMED();
180 void ExportMED(const char *file,
181 const char* theMeshName = NULL,
182 bool theAutoGroups = true,
184 throw(SALOME_Exception);
186 void ExportDAT(const char *file) throw(SALOME_Exception);
187 void ExportUNV(const char *file) throw(SALOME_Exception);
188 void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception);
190 int NbNodes() throw(SALOME_Exception);
193 * ElementOrder points out entities of what order are requested
196 ORDER_ANY, /*! entities of any order */
197 ORDER_LINEAR, /*! entities of 1st order */
198 ORDER_QUADRATIC /*! entities of 2nd order */
201 int NbEdges(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
203 int NbFaces(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
205 int NbTriangles(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
207 int NbQuadrangles(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
209 int NbPolygons() throw(SALOME_Exception);
211 int NbVolumes(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
213 int NbTetras(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
215 int NbHexas(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
217 int NbPyramids(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
219 int NbPrisms(ElementOrder order = ORDER_ANY) throw(SALOME_Exception);
221 int NbPolyhedrons() throw(SALOME_Exception);
223 int NbSubMesh() throw(SALOME_Exception);
225 int NbGroup() const { return _mapGroup.size(); }
227 SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
230 const TopoDS_Shape& theShape=TopoDS_Shape());
232 SMESH_Group* GetGroup (const int theGroupID);
234 list<int> GetGroupIds();
236 void RemoveGroup (const int theGroupID);
238 // Propagation hypothesis management
240 const SMESH_Hypothesis* IsLocal1DHypothesis (const TopoDS_Shape& theEdge);
241 // Returns a local 1D hypothesis used for theEdge.
243 bool IsPropagationHypothesis (const TopoDS_Shape& theEdge);
244 // Returns true, if a local Propagation hypothesis is set directly on <theEdge>
246 bool IsPropagatedHypothesis (const TopoDS_Shape& theEdge,
247 TopoDS_Shape& theMainEdge);
248 // Returns true, if a local 1D hypothesis is
249 // propagated on <theEdge> from some other edge.
250 // Returns through <theMainEdge> the edge, from
251 // which the 1D hypothesis is propagated on <theEdge>
253 bool IsReversedInChain (const TopoDS_Shape& theEdge,
254 const TopoDS_Shape& theMainEdge);
255 // Returns true if theEdge should be reversed to be
256 // co-directed with theMainEdge
258 bool RebuildPropagationChains();
259 bool RemovePropagationChain (const TopoDS_Shape& theMainEdge);
260 bool BuildPropagationChain (const TopoDS_Shape& theMainEdge);
262 SMDSAbs_ElementType GetElementType( const int id, const bool iselem );
266 ostream& Dump(ostream & save);
269 // Propagation hypothesis management
270 void CleanMeshOnPropagationChain(const TopoDS_Shape& theMainEdge);
274 int _id; // id given by creator (unique within the creator instance)
276 int _idDoc; // id given by SMESHDS_Document
277 int _groupId; // id generator for group objects
278 bool _isShapeToMesh;// set to true when a shape is given (only once)
279 list <SMESH_subMesh *> _subMeshesUsingHypothesisList;
280 SMESHDS_Document * _myDocument;
281 SMESHDS_Mesh * _myMeshDS;
282 map <int, SMESH_subMesh *> _mapSubMesh;
283 map <int, SMESH_Group *> _mapGroup;
286 TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
288 IndexedMapOfChain _mapPropagationChains; // Propagation hypothesis management
292 SMESH_Mesh(const SMESH_Mesh&) {};