1 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SMESH_Mesh_i.hxx
25 // Author : Paul RASCLE, EDF
29 #ifndef _SMESH_MESH_I_HXX_
30 #define _SMESH_MESH_I_HXX_
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)
41 #include "SMESH_Hypothesis.hxx"
42 #include "SMESH_Mesh.hxx"
43 //#include "SMESH_subMesh_i.hxx"
44 #include "SMESH_subMesh.hxx"
46 #include "SALOME_GenericObj_i.hh"
49 class SMESH_GroupBase_i;
50 class SMESH_subMesh_i;
54 class SMESH_I_EXPORT SMESH_Mesh_i:
55 public virtual POA_SMESH::SMESH_Mesh,
56 public virtual SALOME::GenericObj_i
59 SMESH_Mesh_i(const SMESH_Mesh_i&);
61 SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
63 CORBA::Long studyId );
65 virtual ~SMESH_Mesh_i();
68 void SetShape( GEOM::GEOM_Object_ptr theShapeObject )
69 throw (SALOME::SALOME_Exception);
71 CORBA::Boolean HasShapeToMesh()
72 throw (SALOME::SALOME_Exception);
74 GEOM::GEOM_Object_ptr GetShapeToMesh()
75 throw (SALOME::SALOME_Exception);
78 throw (SALOME::SALOME_Exception);
80 void ClearSubMesh(CORBA::Long ShapeID)
81 throw (SALOME::SALOME_Exception);
83 SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
84 SMESH::SMESH_Hypothesis_ptr anHyp)
85 throw (SALOME::SALOME_Exception);
87 SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
88 SMESH::SMESH_Hypothesis_ptr anHyp)
89 throw (SALOME::SALOME_Exception);
91 SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
92 throw (SALOME::SALOME_Exception);
94 SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName)
95 throw (SALOME::SALOME_Exception);
97 void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
98 throw (SALOME::SALOME_Exception);
100 SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
101 throw (SALOME::SALOME_Exception);
103 SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType theElemType,
105 GEOM::GEOM_Object_ptr theGeomObj )
106 throw (SALOME::SALOME_Exception);
108 void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
109 throw (SALOME::SALOME_Exception);
111 void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
112 throw (SALOME::SALOME_Exception);
114 SMESH::ListOfGroups* GetGroups()
115 throw (SALOME::SALOME_Exception);
117 CORBA::Long NbGroups()
118 throw (SALOME::SALOME_Exception);
120 SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
121 SMESH::SMESH_GroupBase_ptr theGroup2,
122 const char* theName )
123 throw (SALOME::SALOME_Exception);
125 SMESH::SMESH_Group_ptr UnionListOfGroups( const SMESH::ListOfGroups& theGroups,
127 throw (SALOME::SALOME_Exception);
129 SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
130 SMESH::SMESH_GroupBase_ptr theGroup2,
131 const char* theName )
132 throw (SALOME::SALOME_Exception);
134 SMESH::SMESH_Group_ptr IntersectListOfGroups( const SMESH::ListOfGroups& theGroups,
135 const char* theName )
136 throw (SALOME::SALOME_Exception);
138 SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
139 SMESH::SMESH_GroupBase_ptr theGroup2,
140 const char* theName )
141 throw (SALOME::SALOME_Exception);
143 SMESH::SMESH_Group_ptr CutListOfGroups( const SMESH::ListOfGroups& theMainGroups,
144 const SMESH::ListOfGroups& theToolGroups,
145 const char* theName )
146 throw (SALOME::SALOME_Exception);
148 SMESH::SMESH_Group_ptr CreateDimGroup( const SMESH::ListOfGroups& theGroups,
149 SMESH::ElementType theElemType,
150 const char* theName )
151 throw (SALOME::SALOME_Exception);
154 // SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
155 // throw (SALOME::SALOME_Exception);
157 SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
158 throw (SALOME::SALOME_Exception);
160 SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
162 SMESH::SMESH_MeshEditor_ptr GetMeshEditPreviewer();
165 throw (SALOME::SALOME_Exception);
168 throw (SALOME::SALOME_Exception);
170 CORBA::Long GetStudyId()
171 throw (SALOME::SALOME_Exception);
174 void SetImpl(::SMESH_Mesh* impl);
175 ::SMESH_Mesh& GetImpl(); // :: force no namespace here
177 SMESH_Gen_i* GetGen() { return _gen_i; }
179 int ImportUNVFile( const char* theFileName )
180 throw (SALOME::SALOME_Exception);
182 int ImportSTLFile( const char* theFileName )
183 throw (SALOME::SALOME_Exception);
186 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
188 SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
189 throw (SALOME::SALOME_Exception);
194 void SetAutoColor(CORBA::Boolean theAutoColor)
195 throw (SALOME::SALOME_Exception);
197 CORBA::Boolean GetAutoColor()
198 throw (SALOME::SALOME_Exception);
200 /*! Check group names for duplications.
201 * Consider maximum group name length stored in MED file.
203 CORBA::Boolean HasDuplicatedGroupNamesMED();
205 * Return string representation of a MED file version comprising nbDigits
207 char* GetVersionString(SMESH::MED_VERSION version, CORBA::Short nbDigits);
209 void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
210 throw (SALOME::SALOME_Exception);
211 void ExportMED( const char* file, CORBA::Boolean auto_groups )
212 throw (SALOME::SALOME_Exception);
214 void ExportDAT( const char* file )
215 throw (SALOME::SALOME_Exception);
216 void ExportUNV( const char* file )
217 throw (SALOME::SALOME_Exception);
218 void ExportSTL( const char* file, bool isascii )
219 throw (SALOME::SALOME_Exception);
221 SALOME_MED::MESH_ptr GetMEDMesh()
222 throw (SALOME::SALOME_Exception);
224 CORBA::Long NbNodes()
225 throw (SALOME::SALOME_Exception);
227 CORBA::Long NbElements()
228 throw (SALOME::SALOME_Exception);
230 CORBA::Long NbEdges()
231 throw (SALOME::SALOME_Exception);
233 CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
234 throw (SALOME::SALOME_Exception);
236 CORBA::Long NbFaces()
237 throw (SALOME::SALOME_Exception);
239 CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
240 throw (SALOME::SALOME_Exception);
242 CORBA::Long NbTriangles()
243 throw (SALOME::SALOME_Exception);
245 CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
246 throw (SALOME::SALOME_Exception);
248 CORBA::Long NbQuadrangles()
249 throw (SALOME::SALOME_Exception);
251 CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
252 throw (SALOME::SALOME_Exception);
254 CORBA::Long NbPolygons()
255 throw (SALOME::SALOME_Exception);
257 CORBA::Long NbVolumes()
258 throw (SALOME::SALOME_Exception);
260 CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
261 throw (SALOME::SALOME_Exception);
263 CORBA::Long NbTetras()
264 throw (SALOME::SALOME_Exception);
266 CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
267 throw (SALOME::SALOME_Exception);
269 CORBA::Long NbHexas()
270 throw (SALOME::SALOME_Exception);
272 CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
273 throw (SALOME::SALOME_Exception);
275 CORBA::Long NbPyramids()
276 throw (SALOME::SALOME_Exception);
278 CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
279 throw (SALOME::SALOME_Exception);
281 CORBA::Long NbPrisms()
282 throw (SALOME::SALOME_Exception);
284 CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
285 throw (SALOME::SALOME_Exception);
287 CORBA::Long NbPolyhedrons()
288 throw (SALOME::SALOME_Exception);
290 CORBA::Long NbSubMesh()
291 throw (SALOME::SALOME_Exception);
293 SMESH::long_array* GetElementsId()
294 throw (SALOME::SALOME_Exception);
296 SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
297 throw (SALOME::SALOME_Exception);
299 SMESH::long_array* GetNodesId()
300 throw (SALOME::SALOME_Exception);
302 SMESH::ElementType GetElementType( CORBA::Long id, bool iselem )
303 throw (SALOME::SALOME_Exception);
306 * Returns ID of elements for given submesh
308 SMESH::long_array* GetSubMeshElementsId(CORBA::Long ShapeID)
309 throw (SALOME::SALOME_Exception);
312 * Returns ID of nodes for given submesh
313 * If param all==true - returns all nodes, else -
314 * returns only nodes on shapes.
316 SMESH::long_array* GetSubMeshNodesId(CORBA::Long ShapeID, CORBA::Boolean all)
317 throw (SALOME::SALOME_Exception);
320 * Returns type of elements for given submesh
322 SMESH::ElementType GetSubMeshElementType(CORBA::Long ShapeID)
323 throw (SALOME::SALOME_Exception);
327 // Internal methods not available through CORBA
328 // They are called by corresponding interface methods
329 SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
330 SMESH::SMESH_Hypothesis_ptr anHyp);
332 SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
333 SMESH::SMESH_Hypothesis_ptr anHyp);
335 static SMESH::Hypothesis_Status
336 ConvertHypothesisStatus (SMESH_Hypothesis::Hypothesis_Status theStatus);
338 static void PrepareForWriting (const char* file);
340 //int importMEDFile( const char* theFileName, const char* theMeshName );
342 SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
344 void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
345 GEOM::GEOM_Object_ptr theSubShapeObject );
347 SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
349 const TopoDS_Shape& theShape = TopoDS_Shape());
351 void removeGroup( const int theId );
353 SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
354 // return an existing subMesh object for the shapeID. shapeID == submeshID.
356 const std::map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
357 // return an existing group object.
360 * \brief Update hypotheses assigned to geom groups if the latter change
362 * NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
364 void CheckGeomGroupModif();
366 virtual SMESH::long_array* GetIDs();
368 CORBA::LongLong GetMeshPtr();
371 * \brief Assure that all groups are published
373 void CreateGroupServants();
376 * \brief Return groups cantained in _mapGroups by their IDs
378 SMESH::ListOfGroups* GetGroups(const std::list<int>& groupIDs) const;
381 * Get XYZ coordinates of node as list of double
382 * If there is not node for given ID - returns empty list
384 SMESH::double_array* GetNodeXYZ(CORBA::Long id);
387 * For given node returns list of IDs of inverse elements
388 * If there is not node for given ID - returns empty list
390 SMESH::long_array* GetNodeInverseElements(CORBA::Long id);
393 * \brief Return position of a node on shape
395 SMESH::NodePosition* GetNodePosition(CORBA::Long NodeID);
398 * If given element is node returns IDs of shape from position
399 * If there is not node for given ID - returns -1
401 CORBA::Long GetShapeID(CORBA::Long id);
404 * For given element returns ID of result shape after
405 * ::FindShape() from SMESH_MeshEditor
406 * If there is not element for given ID - returns -1
408 CORBA::Long GetShapeIDForElem(CORBA::Long id);
411 * Returns number of nodes for given element
412 * If there is not element for given ID - returns -1
414 CORBA::Long GetElemNbNodes(CORBA::Long id);
417 * Returns IDs of nodes of given element
419 SMESH::long_array* GetElemNodes(CORBA::Long id);
422 * Returns ID of node by given index for given element
423 * If there is not element for given ID - returns -1
424 * If there is not node for given index - returns -2
426 CORBA::Long GetElemNode(CORBA::Long id, CORBA::Long index);
429 * Returns true if given node is medium node
430 * in given quadratic element
432 CORBA::Boolean IsMediumNode(CORBA::Long ide, CORBA::Long idn);
435 * Returns true if given node is medium node
436 * in one of quadratic elements
438 CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
439 SMESH::ElementType theElemType);
442 * Returns number of edges for given element
444 CORBA::Long ElemNbEdges(CORBA::Long id);
447 * Returns number of faces for given element
449 CORBA::Long ElemNbFaces(CORBA::Long id);
452 * Returns true if given element is polygon
454 CORBA::Boolean IsPoly(CORBA::Long id);
457 * Returns true if given element is quadratic
459 CORBA::Boolean IsQuadratic(CORBA::Long id);
462 * Returns bary center for given element
464 SMESH::double_array* BaryCenter(CORBA::Long id);
467 * Returns information about imported MED file
469 virtual SALOME_MED::MedFileInfo* GetMEDFileInfo();
471 std::map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
472 std::map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
476 * Check and correct names of mesh groups
478 void checkGroupNames();
482 static int myIdGenerator;
483 ::SMESH_Mesh* _impl; // :: force no namespace here
485 int _id; // id given by creator (unique within the creator instance)
487 std::map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
488 std::map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
489 std::map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;
490 SALOME_MED::MedFileInfo_var myFileInfo;