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