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 "SMDS_Mesh.hxx"
31 #include "SMDS_MeshNode.hxx"
32 #include "SMDS_MeshEdge.hxx"
33 #include "SMDS_MeshFace.hxx"
34 #include "SMDS_MeshVolume.hxx"
35 #include "SMESHDS_Hypothesis.hxx"
36 #include "SMESHDS_SubMesh.hxx"
37 #include "SMESHDS_Script.hxx"
39 #include <TopTools_IndexedMapOfShape.hxx>
40 #include <TopoDS_Shape.hxx>
41 #include <TopoDS_Shell.hxx>
42 #include <TopoDS_Face.hxx>
43 #include <TopoDS_Vertex.hxx>
44 #include <TopoDS_Edge.hxx>
45 //Not portable see http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#5_4 to know more.
46 #include <ext/hash_map>
47 using namespace __gnu_cxx;
51 class SMESHDS_Mesh:public SMDS_Mesh
56 SMESHDS_Mesh(int MeshID);
57 void ShapeToMesh(const TopoDS_Shape & S);
58 bool AddHypothesis(const TopoDS_Shape & SS, const SMESHDS_Hypothesis * H);
59 bool RemoveHypothesis(const TopoDS_Shape & S, const SMESHDS_Hypothesis * H);
60 SMDS_MeshNode * AddNode(double x, double y, double z);
61 void RemoveNode(const SMDS_MeshNode *);
62 void MoveNode(const SMDS_MeshNode *, double x, double y, double z);
63 SMDS_MeshEdge* AddEdge(
64 const SMDS_MeshNode * n1,
65 const SMDS_MeshNode * n2);
66 SMDS_MeshFace* AddFace(
67 const SMDS_MeshNode * n1,
68 const SMDS_MeshNode * n2,
69 const SMDS_MeshNode * n3);
70 SMDS_MeshFace* AddFace(
71 const SMDS_MeshNode * n1,
72 const SMDS_MeshNode * n2,
73 const SMDS_MeshNode * n3,
74 const SMDS_MeshNode * n4);
75 SMDS_MeshVolume* AddVolume(
76 const SMDS_MeshNode * n1,
77 const SMDS_MeshNode * n2,
78 const SMDS_MeshNode * n3,
79 const SMDS_MeshNode * n4);
80 SMDS_MeshVolume* AddVolume(
81 const SMDS_MeshNode * n1,
82 const SMDS_MeshNode * n2,
83 const SMDS_MeshNode * n3,
84 const SMDS_MeshNode * n4,
85 const SMDS_MeshNode * n5);
86 SMDS_MeshVolume* AddVolume(
87 const SMDS_MeshNode * n1,
88 const SMDS_MeshNode * n2,
89 const SMDS_MeshNode * n3,
90 const SMDS_MeshNode * n4,
91 const SMDS_MeshNode * n5,
92 const SMDS_MeshNode * n6);
93 SMDS_MeshVolume* AddVolume(
94 const SMDS_MeshNode * n1,
95 const SMDS_MeshNode * n2,
96 const SMDS_MeshNode * n3,
97 const SMDS_MeshNode * n4,
98 const SMDS_MeshNode * n5,
99 const SMDS_MeshNode * n6,
100 const SMDS_MeshNode * n7,
101 const SMDS_MeshNode * n8);
103 void RemoveElement(const SMDS_MeshElement *);
104 void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
105 void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S);
106 void SetNodeOnEdge(SMDS_MeshNode * aNode, const TopoDS_Edge & S);
107 void SetNodeOnVertex(SMDS_MeshNode * aNode, const TopoDS_Vertex & S);
108 void UnSetNodeOnShape(const SMDS_MeshNode * aNode);
109 void SetMeshElementOnShape(const SMDS_MeshElement * anElt,
110 const TopoDS_Shape & S);
111 void UnSetMeshElementOnShape(const SMDS_MeshElement * anElt,
112 const TopoDS_Shape & S);
113 TopoDS_Shape ShapeToMesh() const;
114 bool HasMeshElements(const TopoDS_Shape & S);
115 SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S);
116 bool HasHypothesis(const TopoDS_Shape & S);
117 const list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
118 SMESHDS_Script * GetScript();
120 int ShapeToIndex(const TopoDS_Shape & aShape);
121 TopoDS_Shape IndexToShape(int ShapeIndex);
122 void NewSubMesh(int Index);
123 void SetNodeInVolume(const SMDS_MeshNode * aNode, int Index);
124 void SetNodeOnFace(SMDS_MeshNode * aNode, int Index);
125 void SetNodeOnEdge(SMDS_MeshNode * aNode, int Index);
126 void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index);
127 void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index);
131 struct HashTopoDS_Shape
133 size_t operator()(const TopoDS_Shape& S) const {return S.HashCode(2147483647);}
135 typedef hash_map<TopoDS_Shape, list<const SMESHDS_Hypothesis*>,HashTopoDS_Shape > ShapeToHypothesis;
137 TopoDS_Shape myShape;
138 TopTools_IndexedMapOfShape myIndexToShape;
139 map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
140 ShapeToHypothesis myShapeToHypothesis;
141 SMESHDS_Script * myScript;