1 // SMESH SMESHDS : management of mesh data and SMESH document
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHDS_Mesh.hxx
27 #ifndef _SMESHDS_Mesh_HeaderFile
28 #define _SMESHDS_Mesh_HeaderFile
30 #include "SMESH_SMESHDS.hxx"
32 #include "SMDS_Mesh.hxx"
33 #include "SMDS_MeshNode.hxx"
34 #include "SMDS_MeshEdge.hxx"
35 #include "SMDS_MeshFace.hxx"
36 #include "SMDS_MeshVolume.hxx"
37 #include "SMESHDS_Hypothesis.hxx"
38 #include "SMESHDS_SubMesh.hxx"
39 #include "SMESHDS_Script.hxx"
41 #include <TopTools_IndexedMapOfShape.hxx>
42 #include <TopoDS_Shape.hxx>
43 #include <TopoDS_Solid.hxx>
44 #include <TopoDS_Shell.hxx>
45 #include <TopoDS_Face.hxx>
46 #include <TopoDS_Vertex.hxx>
47 #include <TopoDS_Edge.hxx>
49 #include <NCollection_DataMap.hxx>
52 * Using of native haah_map isn't portable and don't work on WIN32 platform.
53 * So this functionality implement on new NCollection_DataMap technology
55 #include "SMESHDS_DataMapOfShape.hxx"
57 class SMESHDS_GroupBase;
59 class SMESHDS_EXPORT SMESHDS_Mesh:public SMDS_Mesh{
61 SMESHDS_Mesh(int MeshID);
62 void ShapeToMesh(const TopoDS_Shape & S);
63 bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
64 bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);
66 virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID);
67 virtual SMDS_MeshNode * AddNode(double x, double y, double z);
69 virtual SMDS_MeshEdge* AddEdgeWithID(int n1, int n2, int ID);
70 virtual SMDS_MeshEdge* AddEdgeWithID(const SMDS_MeshNode * n1,
71 const SMDS_MeshNode * n2,
73 virtual SMDS_MeshEdge* AddEdge(const SMDS_MeshNode * n1,
74 const SMDS_MeshNode * n2);
76 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int ID);
77 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
78 const SMDS_MeshNode * n2,
79 const SMDS_MeshNode * n3,
81 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
82 const SMDS_MeshNode * n2,
83 const SMDS_MeshNode * n3);
85 virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4, int ID);
86 virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
87 const SMDS_MeshNode * n2,
88 const SMDS_MeshNode * n3,
89 const SMDS_MeshNode * n4,
91 virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
92 const SMDS_MeshNode * n2,
93 const SMDS_MeshNode * n3,
94 const SMDS_MeshNode * n4);
96 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int ID);
97 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
98 const SMDS_MeshNode * n2,
99 const SMDS_MeshNode * n3,
100 const SMDS_MeshNode * n4,
102 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
103 const SMDS_MeshNode * n2,
104 const SMDS_MeshNode * n3,
105 const SMDS_MeshNode * n4);
107 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int ID);
108 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
109 const SMDS_MeshNode * n2,
110 const SMDS_MeshNode * n3,
111 const SMDS_MeshNode * n4,
112 const SMDS_MeshNode * n5,
114 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
115 const SMDS_MeshNode * n2,
116 const SMDS_MeshNode * n3,
117 const SMDS_MeshNode * n4,
118 const SMDS_MeshNode * n5);
120 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int ID);
121 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
122 const SMDS_MeshNode * n2,
123 const SMDS_MeshNode * n3,
124 const SMDS_MeshNode * n4,
125 const SMDS_MeshNode * n5,
126 const SMDS_MeshNode * n6,
128 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
129 const SMDS_MeshNode * n2,
130 const SMDS_MeshNode * n3,
131 const SMDS_MeshNode * n4,
132 const SMDS_MeshNode * n5,
133 const SMDS_MeshNode * n6);
135 virtual SMDS_MeshVolume* AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int ID);
136 virtual SMDS_MeshVolume* AddVolumeWithID(const SMDS_MeshNode * n1,
137 const SMDS_MeshNode * n2,
138 const SMDS_MeshNode * n3,
139 const SMDS_MeshNode * n4,
140 const SMDS_MeshNode * n5,
141 const SMDS_MeshNode * n6,
142 const SMDS_MeshNode * n7,
143 const SMDS_MeshNode * n8,
145 virtual SMDS_MeshVolume* AddVolume(const SMDS_MeshNode * n1,
146 const SMDS_MeshNode * n2,
147 const SMDS_MeshNode * n3,
148 const SMDS_MeshNode * n4,
149 const SMDS_MeshNode * n5,
150 const SMDS_MeshNode * n6,
151 const SMDS_MeshNode * n7,
152 const SMDS_MeshNode * n8);
154 virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<int> nodes_ids,
157 virtual SMDS_MeshFace* AddPolygonalFaceWithID (std::vector<const SMDS_MeshNode*> nodes,
160 virtual SMDS_MeshFace* AddPolygonalFace (std::vector<const SMDS_MeshNode*> nodes);
162 virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
163 (std::vector<int> nodes_ids,
164 std::vector<int> quantities,
167 virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
168 (std::vector<const SMDS_MeshNode*> nodes,
169 std::vector<int> quantities,
172 virtual SMDS_MeshVolume* AddPolyhedralVolume
173 (std::vector<const SMDS_MeshNode*> nodes,
174 std::vector<int> quantities);
176 void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
177 virtual void RemoveNode(const SMDS_MeshNode *);
178 void RemoveElement(const SMDS_MeshElement *);
179 bool ChangeElementNodes(const SMDS_MeshElement * elem,
180 const SMDS_MeshNode * nodes[],
182 bool ChangePolygonNodes(const SMDS_MeshElement * elem,
183 std::vector<const SMDS_MeshNode*> nodes);
184 bool ChangePolyhedronNodes(const SMDS_MeshElement * elem,
185 std::vector<const SMDS_MeshNode*> nodes,
186 std::vector<int> quantities);
187 void Renumber (const bool isNodes, const int startID=1, const int deltaID=1);
189 void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
190 void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Solid & S);
191 void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S, double u=0., double v=0.);
192 void SetNodeOnEdge(SMDS_MeshNode * aNode, const TopoDS_Edge & S, double u=0.);
193 void SetNodeOnVertex(SMDS_MeshNode * aNode, const TopoDS_Vertex & S);
194 void UnSetNodeOnShape(const SMDS_MeshNode * aNode);
195 void SetMeshElementOnShape(const SMDS_MeshElement * anElt,
196 const TopoDS_Shape & S);
197 void UnSetMeshElementOnShape(const SMDS_MeshElement * anElt,
198 const TopoDS_Shape & S);
199 TopoDS_Shape ShapeToMesh() const;
200 bool HasMeshElements(const TopoDS_Shape & S);
201 SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S) const;
202 SMESHDS_SubMesh * MeshElements(const int Index);
203 std::list<int> SubMeshIndices();
204 const std::map<int,SMESHDS_SubMesh*>& SubMeshes()
205 { return myShapeIndexToSubMesh; }
207 bool HasHypothesis(const TopoDS_Shape & S);
208 const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
209 SMESHDS_Script * GetScript();
211 int ShapeToIndex(const TopoDS_Shape & aShape) const;
212 TopoDS_Shape IndexToShape(int ShapeIndex);
214 SMESHDS_SubMesh * NewSubMesh(int Index);
215 int AddCompoundSubmesh(const TopoDS_Shape& S, TopAbs_ShapeEnum type = TopAbs_SHAPE);
216 void SetNodeInVolume(const SMDS_MeshNode * aNode, int Index);
217 void SetNodeOnFace(SMDS_MeshNode * aNode, int Index , double u=0., double v=0.);
218 void SetNodeOnEdge(SMDS_MeshNode * aNode, int Index , double u=0.);
219 void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index);
220 void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index);
222 void AddGroup (SMESHDS_GroupBase* theGroup) { myGroups.insert(theGroup); }
223 void RemoveGroup (SMESHDS_GroupBase* theGroup) { myGroups.erase(theGroup); }
224 int GetNbGroups() const { return myGroups.size(); }
225 const std::set<SMESHDS_GroupBase*>& GetGroups() const { return myGroups; }
227 bool IsGroupOfSubShapes (const TopoDS_Shape& aSubShape) const;
232 void addNodeToSubmesh( const SMDS_MeshNode* aNode, int Index )
234 //Update or build submesh
235 map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.find( Index );
236 if ( it == myShapeIndexToSubMesh.end() )
237 it = myShapeIndexToSubMesh.insert( make_pair(Index, new SMESHDS_SubMesh() )).first;
238 it->second->AddNode( aNode ); // add aNode to submesh
241 /*int HashCode( const TopoDS_Shape& S, const Standard_Integer theUpper ) const
243 return S.HashCode(2147483647);
246 typedef std::list<const SMESHDS_Hypothesis*> THypList;
248 typedef NCollection_DataMap< TopoDS_Shape, THypList > ShapeToHypothesis;
250 ShapeToHypothesis myShapeToHypothesis;
253 TopoDS_Shape myShape;
255 typedef std::map<int,SMESHDS_SubMesh*> TShapeIndexToSubMesh;
256 TShapeIndexToSubMesh myShapeIndexToSubMesh;
258 TopTools_IndexedMapOfShape myIndexToShape;
260 typedef std::set<SMESHDS_GroupBase*> TGroups;
263 SMESHDS_Script* myScript;