Salome HOME
Remove no longer needed files
[modules/smesh.git] / src / SMESHDS / SMESHDS_Mesh.hxx
1 //  SMESH SMESHDS : management of mesh data and SMESH document
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESHDS_Mesh.hxx
25 //  Module : SMESH
26
27 #ifndef _SMESHDS_Mesh_HeaderFile
28 #define _SMESHDS_Mesh_HeaderFile
29
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"
38
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;
48
49 using namespace std;
50
51 class SMESHDS_Mesh:public SMDS_Mesh
52 {
53
54   public:
55
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         virtual void RemoveNode(int ID);
62         void MoveNode(int ID, double x, double y, double z);
63         SMDS_MeshEdge* AddEdge(int idnode1, int idnode2);
64         SMDS_MeshFace* AddFace(int idnode1, int idnode2, int idnode3);
65         SMDS_MeshFace* AddFace(int idnode1, int idnode2, int idnode3, int idnode4);
66         SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4);
67         SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4,
68                 int idnode5);
69         SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4,
70                 int idnode5, int idnode6);
71         SMDS_MeshVolume* AddVolume(int idnode1, int idnode2, int idnode3, int idnode4,
72                 int idnode5, int idnode6, int idnode7, int idnode8);
73         virtual void RemoveElement(int IDelem);
74         void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S);
75         void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S);
76         void SetNodeOnEdge(SMDS_MeshNode * aNode, const TopoDS_Edge & S);
77         void SetNodeOnVertex(SMDS_MeshNode * aNode, const TopoDS_Vertex & S);
78         void UnSetNodeOnShape(const SMDS_MeshNode * aNode);
79         void SetMeshElementOnShape(const SMDS_MeshElement * anElt,
80                 const TopoDS_Shape & S);
81         void UnSetMeshElementOnShape(const SMDS_MeshElement * anElt,
82                 const TopoDS_Shape & S);
83         TopoDS_Shape ShapeToMesh() const;
84         bool HasMeshElements(const TopoDS_Shape & S);
85         SMESHDS_SubMesh * MeshElements(const TopoDS_Shape & S);
86         bool HasHypothesis(const TopoDS_Shape & S);
87         const list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
88         SMESHDS_Script * GetScript();
89         void ClearScript();
90         int ShapeToIndex(const TopoDS_Shape & aShape);
91         TopoDS_Shape IndexToShape(int ShapeIndex);
92         void NewSubMesh(int Index);
93         void SetNodeInVolume(const SMDS_MeshNode * aNode, int Index);
94         void SetNodeOnFace(SMDS_MeshNode * aNode, int Index);
95         void SetNodeOnEdge(SMDS_MeshNode * aNode, int Index);
96         void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index);
97         void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index);
98          ~SMESHDS_Mesh();
99
100   private:
101         struct HashTopoDS_Shape
102     {
103                 size_t operator()(const TopoDS_Shape& S) const {return S.HashCode(2147483647);}
104     };
105         typedef hash_map<TopoDS_Shape, list<const SMESHDS_Hypothesis*>,HashTopoDS_Shape > ShapeToHypothesis;
106         int myMeshID;
107         TopoDS_Shape myShape;
108         TopTools_IndexedMapOfShape myIndexToShape;
109         map<int,SMESHDS_SubMesh*> myShapeIndexToSubMesh;
110         ShapeToHypothesis myShapeToHypothesis;
111         SMESHDS_Script * myScript;
112 };
113 #endif