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