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