Salome HOME
DCQ : Merge with Ecole_Ete_a6.
[modules/smesh.git] / src / SMESH / SMESH_Mesh.hxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
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   : SMESH_Mesh.hxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_MESH_HXX_
30 #define _SMESH_MESH_HXX_
31
32 #include "SMESHDS_Document.hxx"
33 #include "SMESHDS_Mesh.hxx"
34 #include "SMESHDS_Command.hxx"
35 #include "SMESH_Hypothesis.hxx"
36 #include "SMESH_subMesh.hxx"
37 #include <SMDSAbs_ElementType.hxx>
38 #include "Utils_SALOME_Exception.hxx"
39
40 #include <TopExp.hxx>
41 #include <TopExp_Explorer.hxx>
42 #include <TopoDS.hxx>
43 #include <TopoDS_Iterator.hxx>
44 #include <TopoDS_Compound.hxx>
45 #include <TopoDS_CompSolid.hxx>
46 #include <TopoDS_Solid.hxx>
47 #include <TopoDS_Shell.hxx>
48 #include <TopoDS_Face.hxx>
49 #include <TopoDS_Wire.hxx>
50 #include <TopoDS_Edge.hxx>
51 #include <TopoDS_Vertex.hxx>
52 #include <TopoDS_Shape.hxx>
53 #include <TopTools_IndexedMapOfShape.hxx>
54 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
55
56 #include <vector>
57 #include <list>
58 #include <map>
59
60 #if (__GNUC__>2)
61 #include <string>
62 #include <istream>
63 #include <ostream>
64 #else 
65 #include <string>
66 #include <istream.h>
67 #include <ostream.h>
68 #endif
69
70 class SMESH_Gen;
71 class SMESH_Group;
72 class TopTools_ListOfShape;
73
74 class SMESH_Mesh
75 {
76   public:
77         SMESH_Mesh();
78         SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen,
79                 SMESHDS_Document * myDocument);
80
81         virtual ~SMESH_Mesh();
82
83         void ShapeToMesh(const TopoDS_Shape & aShape);
84         /*!
85          * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
86          */
87         int MEDToMesh(const char* theFileName, const char* theMeshName);
88
89         SMESH_Hypothesis::Hypothesis_Status
90                 AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
91                 throw(SALOME_Exception);
92
93         SMESH_Hypothesis::Hypothesis_Status
94                 RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId)
95                 throw(SALOME_Exception);
96
97         const list <const SMESHDS_Hypothesis * >&
98                 GetHypothesisList(const TopoDS_Shape & aSubShape) const
99                 throw(SALOME_Exception);
100
101         const list<SMESHDS_Command*> & GetLog() throw(SALOME_Exception);
102
103 //   const SMESHDS_ListOfAsciiString& GetLog()
104 //     throw (SALOME_Exception);
105
106         void ClearLog() throw(SALOME_Exception);
107
108         int GetId();
109
110         SMESHDS_Mesh * GetMeshDS();
111
112         SMESH_Gen *GetGen();
113
114         SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape)
115                 throw(SALOME_Exception);
116
117         SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape)
118                 throw(SALOME_Exception);
119
120         const list < SMESH_subMesh * >&
121                 GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
122                 throw(SALOME_Exception);
123
124         bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
125                               const TopoDS_Shape & aSubShape);
126         // Return True if anHyp is used to mesh aSubShape
127
128         bool IsNotConformAllowed() const;
129         // check if a hypothesis alowing notconform mesh is present
130
131         bool IsMainShape(const TopoDS_Shape& theShape) const;
132
133         const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape);
134         // return list of ancestors of theSubShape in the order
135         // that lower dimention shapes come first.
136         
137         void ExportDAT(const char *file) throw(SALOME_Exception);
138         void ExportMED(const char *file, const char* theMeshName = NULL, bool theAutoGroups = true) throw(SALOME_Exception);
139         void ExportUNV(const char *file) throw(SALOME_Exception);
140
141         int NbNodes() throw(SALOME_Exception);
142
143         int NbEdges() throw(SALOME_Exception);
144
145         int NbFaces() throw(SALOME_Exception);
146
147         int NbTriangles() throw(SALOME_Exception);
148
149         int NbQuadrangles() throw(SALOME_Exception);
150
151         int NbVolumes() throw(SALOME_Exception);
152
153         int NbTetras() throw(SALOME_Exception);
154
155         int NbHexas() throw(SALOME_Exception);
156
157         int NbPyramids() throw(SALOME_Exception);
158
159         int NbPrisms() throw(SALOME_Exception);
160
161         int NbSubMesh() throw(SALOME_Exception);
162
163         int NbGroup() const { return _mapGroup.size(); }
164   
165         SMESH_Group* AddGroup (const SMDSAbs_ElementType theType,
166                                const char*               theName,
167                                int&                      theId);
168   
169         SMESH_Group* GetGroup (const int theGroupID);
170
171         list<int> GetGroupIds();
172   
173         void RemoveGroup (const int theGroupID);
174
175         ostream& Dump(ostream & save);
176
177   private:
178
179         int _id;                                        // id given by creator (unique within the creator instance)
180         int _studyId;
181         int _idDoc;                                     // id given by SMESHDS_Document
182         int _groupId;                                   // id generator for group objects
183         bool _isShapeToMesh;                            // set to true when a shape is given (only once)
184         list<const SMESHDS_Hypothesis *> _subShapeHypothesisList;
185         list <SMESH_subMesh *> _subMeshesUsingHypothesisList;
186         SMESHDS_Document * _myDocument;
187         SMESHDS_Mesh * _myMeshDS;
188         TopTools_IndexedMapOfShape _subShapes;
189         map <int, SMESH_subMesh *> _mapSubMesh;
190         map <int, SMESH_Group *>   _mapGroup;
191         SMESH_Gen *_gen;
192
193         TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors;
194 };
195
196 #endif