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