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;
53 class SMESH_I_EXPORT SMESH_Mesh_i:
54 public virtual POA_SMESH::SMESH_Mesh,
55 public virtual SALOME::GenericObj_i
58 SMESH_Mesh_i(const SMESH_Mesh_i&);
60 SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
62 CORBA::Long studyId );
64 virtual ~SMESH_Mesh_i();
67 void SetShape( GEOM::GEOM_Object_ptr theShapeObject )
68 throw (SALOME::SALOME_Exception);
70 CORBA::Boolean HasShapeToMesh()
71 throw (SALOME::SALOME_Exception);
73 GEOM::GEOM_Object_ptr GetShapeToMesh()
74 throw (SALOME::SALOME_Exception);
76 SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
77 SMESH::SMESH_Hypothesis_ptr anHyp)
78 throw (SALOME::SALOME_Exception);
80 SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
81 SMESH::SMESH_Hypothesis_ptr anHyp)
82 throw (SALOME::SALOME_Exception);
84 SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
85 throw (SALOME::SALOME_Exception);
87 SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName)
88 throw (SALOME::SALOME_Exception);
90 void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
91 throw (SALOME::SALOME_Exception);
93 SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
94 throw (SALOME::SALOME_Exception);
96 SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType theElemType,
98 GEOM::GEOM_Object_ptr theGeomObj )
99 throw (SALOME::SALOME_Exception);
101 void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
102 throw (SALOME::SALOME_Exception);
104 void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
105 throw (SALOME::SALOME_Exception);
107 SMESH::ListOfGroups* GetGroups()
108 throw (SALOME::SALOME_Exception);
110 SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
111 SMESH::SMESH_GroupBase_ptr theGroup2,
112 const char* theName )
113 throw (SALOME::SALOME_Exception);
115 SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
116 SMESH::SMESH_GroupBase_ptr theGroup2,
117 const char* theName )
118 throw (SALOME::SALOME_Exception);
120 SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
121 SMESH::SMESH_GroupBase_ptr theGroup2,
122 const char* theName )
123 throw (SALOME::SALOME_Exception);
125 // SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
126 // throw (SALOME::SALOME_Exception);
128 SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
129 throw (SALOME::SALOME_Exception);
131 SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
133 SMESH::SMESH_MeshEditor_ptr GetMeshEditPreviewer();
136 throw (SALOME::SALOME_Exception);
139 throw (SALOME::SALOME_Exception);
141 CORBA::Long GetStudyId()
142 throw (SALOME::SALOME_Exception);
145 void SetImpl(::SMESH_Mesh* impl);
146 ::SMESH_Mesh& GetImpl(); // :: force no namespace here
148 SMESH_Gen_i* GetGen() { return _gen_i; }
150 int ImportUNVFile( const char* theFileName )
151 throw (SALOME::SALOME_Exception);
153 int ImportSTLFile( const char* theFileName )
154 throw (SALOME::SALOME_Exception);
157 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
159 SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
160 throw (SALOME::SALOME_Exception);
162 /*! Check group names for duplications.
163 * Consider maximum group name length stored in MED file.
165 CORBA::Boolean HasDuplicatedGroupNamesMED();
167 void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
168 throw (SALOME::SALOME_Exception);
169 void ExportMED( const char* file, CORBA::Boolean auto_groups )
170 throw (SALOME::SALOME_Exception);
172 void ExportDAT( const char* file )
173 throw (SALOME::SALOME_Exception);
174 void ExportUNV( const char* file )
175 throw (SALOME::SALOME_Exception);
176 void ExportSTL( const char* file, bool isascii )
177 throw (SALOME::SALOME_Exception);
179 SALOME_MED::MESH_ptr GetMEDMesh()
180 throw (SALOME::SALOME_Exception);
182 CORBA::Long NbNodes()
183 throw (SALOME::SALOME_Exception);
185 CORBA::Long NbElements()
186 throw (SALOME::SALOME_Exception);
188 CORBA::Long NbEdges()
189 throw (SALOME::SALOME_Exception);
191 CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
192 throw (SALOME::SALOME_Exception);
194 CORBA::Long NbFaces()
195 throw (SALOME::SALOME_Exception);
197 CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
198 throw (SALOME::SALOME_Exception);
200 CORBA::Long NbTriangles()
201 throw (SALOME::SALOME_Exception);
203 CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
204 throw (SALOME::SALOME_Exception);
206 CORBA::Long NbQuadrangles()
207 throw (SALOME::SALOME_Exception);
209 CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
210 throw (SALOME::SALOME_Exception);
212 CORBA::Long NbPolygons()
213 throw (SALOME::SALOME_Exception);
215 CORBA::Long NbVolumes()
216 throw (SALOME::SALOME_Exception);
218 CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
219 throw (SALOME::SALOME_Exception);
221 CORBA::Long NbTetras()
222 throw (SALOME::SALOME_Exception);
224 CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
225 throw (SALOME::SALOME_Exception);
227 CORBA::Long NbHexas()
228 throw (SALOME::SALOME_Exception);
230 CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
231 throw (SALOME::SALOME_Exception);
233 CORBA::Long NbPyramids()
234 throw (SALOME::SALOME_Exception);
236 CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
237 throw (SALOME::SALOME_Exception);
239 CORBA::Long NbPrisms()
240 throw (SALOME::SALOME_Exception);
242 CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
243 throw (SALOME::SALOME_Exception);
245 CORBA::Long NbPolyhedrons()
246 throw (SALOME::SALOME_Exception);
248 CORBA::Long NbSubMesh()
249 throw (SALOME::SALOME_Exception);
251 SMESH::long_array* GetElementsId()
252 throw (SALOME::SALOME_Exception);
254 SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
255 throw (SALOME::SALOME_Exception);
257 SMESH::long_array* GetNodesId()
258 throw (SALOME::SALOME_Exception);
260 SMESH::ElementType GetElementType( CORBA::Long id, bool iselem )
261 throw (SALOME::SALOME_Exception);
264 * Returns ID of elements for given submesh
266 SMESH::long_array* GetSubMeshElementsId(CORBA::Long ShapeID)
267 throw (SALOME::SALOME_Exception);
270 * Returns ID of nodes for given submesh
271 * If param all==true - returns all nodes, else -
272 * returns only nodes on shapes.
274 SMESH::long_array* GetSubMeshNodesId(CORBA::Long ShapeID, CORBA::Boolean all)
275 throw (SALOME::SALOME_Exception);
278 * Returns type of elements for given submesh
280 SMESH::ElementType GetSubMeshElementType(CORBA::Long ShapeID)
281 throw (SALOME::SALOME_Exception);
285 // Internal methods not available through CORBA
286 // They are called by corresponding interface methods
287 SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
288 SMESH::SMESH_Hypothesis_ptr anHyp);
290 SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
291 SMESH::SMESH_Hypothesis_ptr anHyp);
293 static SMESH::Hypothesis_Status
294 ConvertHypothesisStatus (SMESH_Hypothesis::Hypothesis_Status theStatus);
296 int importMEDFile( const char* theFileName, const char* theMeshName );
298 SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
300 void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
301 GEOM::GEOM_Object_ptr theSubShapeObject );
303 SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
305 const TopoDS_Shape& theShape = TopoDS_Shape());
307 void removeGroup( const int theId );
309 SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
310 // return an existing subMesh object for the shapeID. shapeID == submeshID.
312 const map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
313 // return an existing group object.
315 virtual SMESH::long_array* GetIDs();
317 CORBA::LongLong GetMeshPtr();
321 * Get XYZ coordinates of node as list of double
322 * If there is not node for given ID - returns empty list
324 SMESH::double_array* GetNodeXYZ(CORBA::Long id);
327 * For given node returns list of IDs of inverse elements
328 * If there is not node for given ID - returns empty list
330 SMESH::long_array* GetNodeInverseElements(CORBA::Long id);
333 * If given element is node returns IDs of shape from position
334 * If there is not node for given ID - returns -1
336 CORBA::Long GetShapeID(CORBA::Long id);
339 * For given element returns ID of result shape after
340 * ::FindShape() from SMESH_MeshEditor
341 * If there is not element for given ID - returns -1
343 CORBA::Long GetShapeIDForElem(CORBA::Long id);
346 * Returns number of nodes for given element
347 * If there is not element for given ID - returns -1
349 CORBA::Long GetElemNbNodes(CORBA::Long id);
352 * Returns IDs of nodes of given element
354 SMESH::long_array* GetElemNodes(CORBA::Long id);
357 * Returns ID of node by given index for given element
358 * If there is not element for given ID - returns -1
359 * If there is not node for given index - returns -2
361 CORBA::Long GetElemNode(CORBA::Long id, CORBA::Long index);
364 * Returns true if given node is medium node
365 * in given quadratic element
367 CORBA::Boolean IsMediumNode(CORBA::Long ide, CORBA::Long idn);
370 * Returns true if given node is medium node
371 * in one of quadratic elements
373 CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
374 SMESH::ElementType theElemType);
377 * Returns number of edges for given element
379 CORBA::Long ElemNbEdges(CORBA::Long id);
382 * Returns number of faces for given element
384 CORBA::Long ElemNbFaces(CORBA::Long id);
387 * Returns true if given element is polygon
389 CORBA::Boolean IsPoly(CORBA::Long id);
392 * Returns true if given element is quadratic
394 CORBA::Boolean IsQuadratic(CORBA::Long id);
397 * Returns bary center for given element
399 SMESH::double_array* BaryCenter(CORBA::Long id);
402 map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
403 map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
406 void CreateGroupServants();
408 static int myIdGenerator;
409 ::SMESH_Mesh* _impl; // :: force no namespace here
411 int _id; // id given by creator (unique within the creator instance)
413 map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
414 map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
415 map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;