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);
77 SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
78 SMESH::SMESH_Hypothesis_ptr anHyp)
79 throw (SALOME::SALOME_Exception);
81 SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
82 SMESH::SMESH_Hypothesis_ptr anHyp)
83 throw (SALOME::SALOME_Exception);
85 SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
86 throw (SALOME::SALOME_Exception);
88 SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName)
89 throw (SALOME::SALOME_Exception);
91 void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
92 throw (SALOME::SALOME_Exception);
94 SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
95 throw (SALOME::SALOME_Exception);
97 SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType theElemType,
99 GEOM::GEOM_Object_ptr theGeomObj )
100 throw (SALOME::SALOME_Exception);
102 void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
103 throw (SALOME::SALOME_Exception);
105 void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
106 throw (SALOME::SALOME_Exception);
108 SMESH::ListOfGroups* GetGroups()
109 throw (SALOME::SALOME_Exception);
111 SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
112 SMESH::SMESH_GroupBase_ptr theGroup2,
113 const char* theName )
114 throw (SALOME::SALOME_Exception);
116 SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
117 SMESH::SMESH_GroupBase_ptr theGroup2,
118 const char* theName )
119 throw (SALOME::SALOME_Exception);
121 SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
122 SMESH::SMESH_GroupBase_ptr theGroup2,
123 const char* theName )
124 throw (SALOME::SALOME_Exception);
126 // SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
127 // throw (SALOME::SALOME_Exception);
129 SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
130 throw (SALOME::SALOME_Exception);
132 SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
134 SMESH::SMESH_MeshEditor_ptr GetMeshEditPreviewer();
137 throw (SALOME::SALOME_Exception);
140 throw (SALOME::SALOME_Exception);
142 CORBA::Long GetStudyId()
143 throw (SALOME::SALOME_Exception);
146 void SetImpl(::SMESH_Mesh* impl);
147 ::SMESH_Mesh& GetImpl(); // :: force no namespace here
149 SMESH_Gen_i* GetGen() { return _gen_i; }
151 int ImportUNVFile( const char* theFileName )
152 throw (SALOME::SALOME_Exception);
154 int ImportSTLFile( const char* theFileName )
155 throw (SALOME::SALOME_Exception);
158 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
160 SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
161 throw (SALOME::SALOME_Exception);
166 void SetAutoColor(CORBA::Boolean theAutoColor)
167 throw (SALOME::SALOME_Exception);
169 CORBA::Boolean GetAutoColor()
170 throw (SALOME::SALOME_Exception);
172 /*! Check group names for duplications.
173 * Consider maximum group name length stored in MED file.
175 CORBA::Boolean HasDuplicatedGroupNamesMED();
177 void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
178 throw (SALOME::SALOME_Exception);
179 void ExportMED( const char* file, CORBA::Boolean auto_groups )
180 throw (SALOME::SALOME_Exception);
182 void ExportDAT( const char* file )
183 throw (SALOME::SALOME_Exception);
184 void ExportUNV( const char* file )
185 throw (SALOME::SALOME_Exception);
186 void ExportSTL( const char* file, bool isascii )
187 throw (SALOME::SALOME_Exception);
189 SALOME_MED::MESH_ptr GetMEDMesh()
190 throw (SALOME::SALOME_Exception);
192 CORBA::Long NbNodes()
193 throw (SALOME::SALOME_Exception);
195 CORBA::Long NbElements()
196 throw (SALOME::SALOME_Exception);
198 CORBA::Long NbEdges()
199 throw (SALOME::SALOME_Exception);
201 CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
202 throw (SALOME::SALOME_Exception);
204 CORBA::Long NbFaces()
205 throw (SALOME::SALOME_Exception);
207 CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
208 throw (SALOME::SALOME_Exception);
210 CORBA::Long NbTriangles()
211 throw (SALOME::SALOME_Exception);
213 CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
214 throw (SALOME::SALOME_Exception);
216 CORBA::Long NbQuadrangles()
217 throw (SALOME::SALOME_Exception);
219 CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
220 throw (SALOME::SALOME_Exception);
222 CORBA::Long NbPolygons()
223 throw (SALOME::SALOME_Exception);
225 CORBA::Long NbVolumes()
226 throw (SALOME::SALOME_Exception);
228 CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
229 throw (SALOME::SALOME_Exception);
231 CORBA::Long NbTetras()
232 throw (SALOME::SALOME_Exception);
234 CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
235 throw (SALOME::SALOME_Exception);
237 CORBA::Long NbHexas()
238 throw (SALOME::SALOME_Exception);
240 CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
241 throw (SALOME::SALOME_Exception);
243 CORBA::Long NbPyramids()
244 throw (SALOME::SALOME_Exception);
246 CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
247 throw (SALOME::SALOME_Exception);
249 CORBA::Long NbPrisms()
250 throw (SALOME::SALOME_Exception);
252 CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
253 throw (SALOME::SALOME_Exception);
255 CORBA::Long NbPolyhedrons()
256 throw (SALOME::SALOME_Exception);
258 CORBA::Long NbSubMesh()
259 throw (SALOME::SALOME_Exception);
261 SMESH::long_array* GetElementsId()
262 throw (SALOME::SALOME_Exception);
264 SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
265 throw (SALOME::SALOME_Exception);
267 SMESH::long_array* GetNodesId()
268 throw (SALOME::SALOME_Exception);
270 SMESH::ElementType GetElementType( CORBA::Long id, bool iselem )
271 throw (SALOME::SALOME_Exception);
274 * Returns ID of elements for given submesh
276 SMESH::long_array* GetSubMeshElementsId(CORBA::Long ShapeID)
277 throw (SALOME::SALOME_Exception);
280 * Returns ID of nodes for given submesh
281 * If param all==true - returns all nodes, else -
282 * returns only nodes on shapes.
284 SMESH::long_array* GetSubMeshNodesId(CORBA::Long ShapeID, CORBA::Boolean all)
285 throw (SALOME::SALOME_Exception);
288 * Returns type of elements for given submesh
290 SMESH::ElementType GetSubMeshElementType(CORBA::Long ShapeID)
291 throw (SALOME::SALOME_Exception);
295 // Internal methods not available through CORBA
296 // They are called by corresponding interface methods
297 SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
298 SMESH::SMESH_Hypothesis_ptr anHyp);
300 SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
301 SMESH::SMESH_Hypothesis_ptr anHyp);
303 static SMESH::Hypothesis_Status
304 ConvertHypothesisStatus (SMESH_Hypothesis::Hypothesis_Status theStatus);
306 int importMEDFile( const char* theFileName, const char* theMeshName );
308 SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
310 void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
311 GEOM::GEOM_Object_ptr theSubShapeObject );
313 SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
315 const TopoDS_Shape& theShape = TopoDS_Shape());
317 void removeGroup( const int theId );
319 SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
320 // return an existing subMesh object for the shapeID. shapeID == submeshID.
322 const map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
323 // return an existing group object.
326 * \brief Update hypotheses assigned to geom groups if the latter change
328 * NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
330 void CheckGeomGroupModif();
332 virtual SMESH::long_array* GetIDs();
334 CORBA::LongLong GetMeshPtr();
338 * Get XYZ coordinates of node as list of double
339 * If there is not node for given ID - returns empty list
341 SMESH::double_array* GetNodeXYZ(CORBA::Long id);
344 * For given node returns list of IDs of inverse elements
345 * If there is not node for given ID - returns empty list
347 SMESH::long_array* GetNodeInverseElements(CORBA::Long id);
350 * If given element is node returns IDs of shape from position
351 * If there is not node for given ID - returns -1
353 CORBA::Long GetShapeID(CORBA::Long id);
356 * For given element returns ID of result shape after
357 * ::FindShape() from SMESH_MeshEditor
358 * If there is not element for given ID - returns -1
360 CORBA::Long GetShapeIDForElem(CORBA::Long id);
363 * Returns number of nodes for given element
364 * If there is not element for given ID - returns -1
366 CORBA::Long GetElemNbNodes(CORBA::Long id);
369 * Returns IDs of nodes of given element
371 SMESH::long_array* GetElemNodes(CORBA::Long id);
374 * Returns ID of node by given index for given element
375 * If there is not element for given ID - returns -1
376 * If there is not node for given index - returns -2
378 CORBA::Long GetElemNode(CORBA::Long id, CORBA::Long index);
381 * Returns true if given node is medium node
382 * in given quadratic element
384 CORBA::Boolean IsMediumNode(CORBA::Long ide, CORBA::Long idn);
387 * Returns true if given node is medium node
388 * in one of quadratic elements
390 CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
391 SMESH::ElementType theElemType);
394 * Returns number of edges for given element
396 CORBA::Long ElemNbEdges(CORBA::Long id);
399 * Returns number of faces for given element
401 CORBA::Long ElemNbFaces(CORBA::Long id);
404 * Returns true if given element is polygon
406 CORBA::Boolean IsPoly(CORBA::Long id);
409 * Returns true if given element is quadratic
411 CORBA::Boolean IsQuadratic(CORBA::Long id);
414 * Returns bary center for given element
416 SMESH::double_array* BaryCenter(CORBA::Long id);
419 map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
420 map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
423 void CreateGroupServants();
425 static int myIdGenerator;
426 ::SMESH_Mesh* _impl; // :: force no namespace here
428 int _id; // id given by creator (unique within the creator instance)
430 map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
431 map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
432 map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;