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