Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/smesh.git] / src / SMESH_I / SMESH_Mesh_i.hxx
1 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
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_i.hxx
25 //  Author : Paul RASCLE, EDF
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef _SMESH_MESH_I_HXX_
30 #define _SMESH_MESH_I_HXX_
31
32 #include <SALOMEconfig.h>
33 #include CORBA_SERVER_HEADER(SMESH_Mesh)
34 #include CORBA_SERVER_HEADER(SMESH_Group)
35 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
36 #include CORBA_CLIENT_HEADER(GEOM_Gen)
37 #include CORBA_CLIENT_HEADER(MED)
38
39 #include "SMESH_Hypothesis.hxx"
40 #include "SMESH_Mesh.hxx"
41 #include "SMESH_subMesh_i.hxx"
42 #include "SMESH_subMesh.hxx"
43
44 #include "SALOME_GenericObj_i.hh"
45
46 class SMESH_Gen_i;
47 class SMESH_GroupBase_i;
48
49 #include <map>
50
51 class SMESH_Mesh_i:
52   public virtual POA_SMESH::SMESH_Mesh,
53   public virtual SALOME::GenericObj_i
54 {
55   SMESH_Mesh_i();
56   SMESH_Mesh_i(const SMESH_Mesh_i&);
57 public:
58   SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
59                 SMESH_Gen_i*            myGen_i,
60                 CORBA::Long             studyId );
61
62   virtual ~SMESH_Mesh_i();
63
64   // --- CORBA
65   void SetShape( GEOM::GEOM_Object_ptr theShapeObject )
66     throw (SALOME::SALOME_Exception);
67
68   GEOM::GEOM_Object_ptr GetShapeToMesh()
69     throw (SALOME::SALOME_Exception);
70
71   SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
72                                          SMESH::SMESH_Hypothesis_ptr anHyp)
73     throw (SALOME::SALOME_Exception);
74
75   SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
76                                             SMESH::SMESH_Hypothesis_ptr anHyp)
77     throw (SALOME::SALOME_Exception);
78
79   SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
80     throw (SALOME::SALOME_Exception);
81
82   SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName)
83     throw (SALOME::SALOME_Exception);
84
85   void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
86     throw (SALOME::SALOME_Exception);
87
88   SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
89     throw (SALOME::SALOME_Exception);
90   
91   SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType    theElemType,
92                                                    const char*           theName,
93                                                    GEOM::GEOM_Object_ptr theGeomObj )
94     throw (SALOME::SALOME_Exception);
95
96   void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
97     throw (SALOME::SALOME_Exception);
98   
99   void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
100     throw (SALOME::SALOME_Exception);
101   
102   SMESH::ListOfGroups* GetGroups()
103     throw (SALOME::SALOME_Exception);
104
105   SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1, 
106                                       SMESH::SMESH_GroupBase_ptr theGroup2, 
107                                       const char* theName )
108     throw (SALOME::SALOME_Exception);
109   
110   SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1, 
111                                           SMESH::SMESH_GroupBase_ptr theGroup2, 
112                                           const char* theName )
113     throw (SALOME::SALOME_Exception);
114   
115   SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1, 
116                                     SMESH::SMESH_GroupBase_ptr theGroup2, 
117                                    const char* theName )
118     throw (SALOME::SALOME_Exception);
119
120 //    SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
121 //      throw (SALOME::SALOME_Exception);
122
123   SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
124     throw (SALOME::SALOME_Exception);
125
126   SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
127
128   void ClearLog()
129     throw (SALOME::SALOME_Exception);
130
131   CORBA::Long GetId()
132     throw (SALOME::SALOME_Exception);
133
134   CORBA::Long GetStudyId()
135     throw (SALOME::SALOME_Exception);
136
137   // --- C++ interface
138   void SetImpl(::SMESH_Mesh* impl);
139   ::SMESH_Mesh& GetImpl();         // :: force no namespace here
140
141   SMESH_Gen_i* GetGen() { return _gen_i; }
142
143   int ImportUNVFile( const char* theFileName )
144     throw (SALOME::SALOME_Exception);
145
146   int ImportSTLFile( const char* theFileName )
147     throw (SALOME::SALOME_Exception);
148
149   /*!
150    * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
151    */
152   SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
153     throw (SALOME::SALOME_Exception);
154
155   /*! Check group names for duplications.
156    *  Consider maximum group name length stored in MED file.
157    */
158   CORBA::Boolean HasDuplicatedGroupNamesMED();
159
160   void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
161     throw (SALOME::SALOME_Exception);
162   void ExportMED( const char* file, CORBA::Boolean auto_groups )
163     throw (SALOME::SALOME_Exception);
164
165   void ExportDAT( const char* file )
166     throw (SALOME::SALOME_Exception);
167   void ExportUNV( const char* file )
168     throw (SALOME::SALOME_Exception);
169   void ExportSTL( const char* file, const bool isascii )
170     throw (SALOME::SALOME_Exception);
171
172   SALOME_MED::MESH_ptr GetMEDMesh()
173     throw (SALOME::SALOME_Exception);
174
175   CORBA::Long NbNodes()
176     throw (SALOME::SALOME_Exception);
177
178   CORBA::Long NbElements()
179     throw (SALOME::SALOME_Exception);
180
181   CORBA::Long NbEdges()
182     throw (SALOME::SALOME_Exception);
183
184   CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
185     throw (SALOME::SALOME_Exception);
186
187   CORBA::Long NbFaces()
188     throw (SALOME::SALOME_Exception);
189
190   CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
191     throw (SALOME::SALOME_Exception);
192
193   CORBA::Long NbTriangles()
194     throw (SALOME::SALOME_Exception);
195
196   CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
197     throw (SALOME::SALOME_Exception);
198
199   CORBA::Long NbQuadrangles()
200     throw (SALOME::SALOME_Exception);
201
202   CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
203     throw (SALOME::SALOME_Exception);
204
205   CORBA::Long NbPolygons()
206     throw (SALOME::SALOME_Exception);
207
208   CORBA::Long NbVolumes()
209     throw (SALOME::SALOME_Exception);
210
211   CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
212     throw (SALOME::SALOME_Exception);
213
214   CORBA::Long NbTetras()
215     throw (SALOME::SALOME_Exception);
216
217   CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
218     throw (SALOME::SALOME_Exception);
219
220   CORBA::Long NbHexas()
221     throw (SALOME::SALOME_Exception);
222
223   CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
224     throw (SALOME::SALOME_Exception);
225
226   CORBA::Long NbPyramids()
227     throw (SALOME::SALOME_Exception);
228
229   CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
230     throw (SALOME::SALOME_Exception);
231
232   CORBA::Long NbPrisms()
233     throw (SALOME::SALOME_Exception);
234
235   CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
236     throw (SALOME::SALOME_Exception);
237
238   CORBA::Long NbPolyhedrons()
239     throw (SALOME::SALOME_Exception);
240
241   CORBA::Long NbSubMesh()
242     throw (SALOME::SALOME_Exception);
243
244   SMESH::long_array* GetElementsId()
245     throw (SALOME::SALOME_Exception);
246
247   SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
248     throw (SALOME::SALOME_Exception);
249   
250   SMESH::long_array* GetNodesId()
251     throw (SALOME::SALOME_Exception);
252   
253   SMESH::ElementType GetElementType( const CORBA::Long id, const bool iselem )
254     throw (SALOME::SALOME_Exception);
255   
256   /*!
257    * Returns ID of elements for given submesh
258    */
259   SMESH::long_array* GetSubMeshElementsId(const CORBA::Long ShapeID)
260     throw (SALOME::SALOME_Exception);
261
262   /*!
263    * Returns ID of nodes for given submesh
264    * If param all==true - returns all nodes, else -
265    * returns only nodes on shapes.
266    */
267   SMESH::long_array* GetSubMeshNodesId(const CORBA::Long ShapeID, CORBA::Boolean all)
268     throw (SALOME::SALOME_Exception);
269   
270   /*!
271    * Returns type of elements for given submesh
272    */
273   SMESH::ElementType GetSubMeshElementType(const CORBA::Long ShapeID)
274     throw (SALOME::SALOME_Exception);
275   
276   char* Dump();
277   
278   // Internal methods not available through CORBA
279   // They are called by corresponding interface methods
280   SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
281                                                     SMESH::SMESH_Hypothesis_ptr anHyp);
282
283   SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
284                                                        SMESH::SMESH_Hypothesis_ptr anHyp);
285   
286   int importMEDFile( const char* theFileName, const char* theMeshName );
287
288   SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
289
290   void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
291                      GEOM::GEOM_Object_ptr theSubShapeObject );
292
293   SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType  theElemType,
294                                          const char*         theName,
295                                          const TopoDS_Shape& theShape = TopoDS_Shape());
296
297   void removeGroup( const int theId );
298
299   SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
300   // return an existing subMesh object for the shapeID. shapeID == submeshID.
301
302   const map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
303   // return an existing group object.
304
305   virtual SMESH::long_array* GetIDs();
306
307   CORBA::Long GetMeshPtr();
308
309
310   /*!
311    * Get XYZ coordinates of node as list of double
312    * If there is not node for given ID - returns empty list
313    */
314   SMESH::double_array* GetNodeXYZ(const CORBA::Long id);
315   
316   /*!
317    * For given node returns list of IDs of inverse elements
318    * If there is not node for given ID - returns empty list
319    */
320   SMESH::long_array* GetNodeInverseElements(const CORBA::Long id);
321
322   /*!
323    * If given element is node returns IDs of shape from position
324    * else - return ID of result shape after ::FindShape()
325    * from SMESH_MeshEditor
326    * If there is not element for given ID - returns -1
327    */
328   CORBA::Long GetShapeID(const CORBA::Long id);
329
330   /*!
331    * Returns number of nodes for given element
332    * If there is not element for given ID - returns -1
333    */
334   CORBA::Long GetElemNbNodes(const CORBA::Long id);
335
336   /*!
337    * Returns ID of node by given index for given element
338    * If there is not element for given ID - returns -1
339    * If there is not node for given index - returns -2
340    */
341   CORBA::Long GetElemNode(const CORBA::Long id, const CORBA::Long index);
342   
343   /*!
344    * Returns true if given node is medium node
345    * in given quadratic element
346    */
347   CORBA::Boolean IsMediumNode(const CORBA::Long ide, const CORBA::Long idn);
348   
349   /*!
350    * Returns true if given node is medium node
351    * in one of quadratic elements
352    */
353   CORBA::Boolean IsMediumNodeOfAnyElem(const CORBA::Long idn,
354                                        SMESH::ElementType theElemType);
355   
356   /*!
357    * Returns number of edges for given element
358    */
359   CORBA::Long ElemNbEdges(const CORBA::Long id);
360   
361   /*!
362    * Returns number of faces for given element
363    */
364   CORBA::Long ElemNbFaces(const CORBA::Long id);
365   
366   /*!
367    * Returns true if given element is polygon
368    */
369   CORBA::Boolean IsPoly(const CORBA::Long id);
370   
371   /*!
372    * Returns true if given element is quadratic
373    */
374   CORBA::Boolean IsQuadratic(const CORBA::Long id);
375   
376   /*!
377    * Returns bary center for given element
378    */
379   SMESH::double_array* BaryCenter(const CORBA::Long id);
380
381
382   map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
383   map<int, ::SMESH_subMesh*> _mapSubMesh;   //NRI
384
385 private:
386   void CreateGroupServants();
387
388   static int myIdGenerator;
389   ::SMESH_Mesh* _impl;  // :: force no namespace here
390   SMESH_Gen_i* _gen_i;
391   int _id;          // id given by creator (unique within the creator instance)
392   int _studyId;
393   map<int, SMESH::SMESH_subMesh_ptr>    _mapSubMeshIor;
394   map<int, SMESH::SMESH_GroupBase_ptr>  _mapGroups;
395   map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;
396 };
397
398 #endif
399