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_
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)
39 #include "SMESH_Hypothesis.hxx"
40 #include "SMESH_Mesh.hxx"
41 #include "SMESH_subMesh_i.hxx"
42 #include "SMESH_subMesh.hxx"
44 #include "SALOME_GenericObj_i.hh"
47 class SMESH_GroupBase_i;
52 public virtual POA_SMESH::SMESH_Mesh,
53 public virtual SALOME::GenericObj_i
56 SMESH_Mesh_i(const SMESH_Mesh_i&);
58 SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
60 CORBA::Long studyId );
62 virtual ~SMESH_Mesh_i();
65 void SetShape( GEOM::GEOM_Object_ptr theShapeObject )
66 throw (SALOME::SALOME_Exception);
68 CORBA::Boolean HasShapeToMesh()
69 throw (SALOME::SALOME_Exception);
71 GEOM::GEOM_Object_ptr GetShapeToMesh()
72 throw (SALOME::SALOME_Exception);
74 SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
75 SMESH::SMESH_Hypothesis_ptr anHyp)
76 throw (SALOME::SALOME_Exception);
78 SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
79 SMESH::SMESH_Hypothesis_ptr anHyp)
80 throw (SALOME::SALOME_Exception);
82 SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
83 throw (SALOME::SALOME_Exception);
85 SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName)
86 throw (SALOME::SALOME_Exception);
88 void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
89 throw (SALOME::SALOME_Exception);
91 SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
92 throw (SALOME::SALOME_Exception);
94 SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType theElemType,
96 GEOM::GEOM_Object_ptr theGeomObj )
97 throw (SALOME::SALOME_Exception);
99 void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
100 throw (SALOME::SALOME_Exception);
102 void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
103 throw (SALOME::SALOME_Exception);
105 SMESH::ListOfGroups* GetGroups()
106 throw (SALOME::SALOME_Exception);
108 SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
109 SMESH::SMESH_GroupBase_ptr theGroup2,
110 const char* theName )
111 throw (SALOME::SALOME_Exception);
113 SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
114 SMESH::SMESH_GroupBase_ptr theGroup2,
115 const char* theName )
116 throw (SALOME::SALOME_Exception);
118 SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
119 SMESH::SMESH_GroupBase_ptr theGroup2,
120 const char* theName )
121 throw (SALOME::SALOME_Exception);
123 // SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
124 // throw (SALOME::SALOME_Exception);
126 SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
127 throw (SALOME::SALOME_Exception);
129 SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
132 throw (SALOME::SALOME_Exception);
135 throw (SALOME::SALOME_Exception);
137 CORBA::Long GetStudyId()
138 throw (SALOME::SALOME_Exception);
141 void SetImpl(::SMESH_Mesh* impl);
142 ::SMESH_Mesh& GetImpl(); // :: force no namespace here
144 SMESH_Gen_i* GetGen() { return _gen_i; }
146 int ImportUNVFile( const char* theFileName )
147 throw (SALOME::SALOME_Exception);
149 int ImportSTLFile( const char* theFileName )
150 throw (SALOME::SALOME_Exception);
153 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
155 SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
156 throw (SALOME::SALOME_Exception);
158 /*! Check group names for duplications.
159 * Consider maximum group name length stored in MED file.
161 CORBA::Boolean HasDuplicatedGroupNamesMED();
163 void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
164 throw (SALOME::SALOME_Exception);
165 void ExportMED( const char* file, CORBA::Boolean auto_groups )
166 throw (SALOME::SALOME_Exception);
168 void ExportDAT( const char* file )
169 throw (SALOME::SALOME_Exception);
170 void ExportUNV( const char* file )
171 throw (SALOME::SALOME_Exception);
172 void ExportSTL( const char* file, const bool isascii )
173 throw (SALOME::SALOME_Exception);
175 SALOME_MED::MESH_ptr GetMEDMesh()
176 throw (SALOME::SALOME_Exception);
178 CORBA::Long NbNodes()
179 throw (SALOME::SALOME_Exception);
181 CORBA::Long NbElements()
182 throw (SALOME::SALOME_Exception);
184 CORBA::Long NbEdges()
185 throw (SALOME::SALOME_Exception);
187 CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
188 throw (SALOME::SALOME_Exception);
190 CORBA::Long NbFaces()
191 throw (SALOME::SALOME_Exception);
193 CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
194 throw (SALOME::SALOME_Exception);
196 CORBA::Long NbTriangles()
197 throw (SALOME::SALOME_Exception);
199 CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
200 throw (SALOME::SALOME_Exception);
202 CORBA::Long NbQuadrangles()
203 throw (SALOME::SALOME_Exception);
205 CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
206 throw (SALOME::SALOME_Exception);
208 CORBA::Long NbPolygons()
209 throw (SALOME::SALOME_Exception);
211 CORBA::Long NbVolumes()
212 throw (SALOME::SALOME_Exception);
214 CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
215 throw (SALOME::SALOME_Exception);
217 CORBA::Long NbTetras()
218 throw (SALOME::SALOME_Exception);
220 CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
221 throw (SALOME::SALOME_Exception);
223 CORBA::Long NbHexas()
224 throw (SALOME::SALOME_Exception);
226 CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
227 throw (SALOME::SALOME_Exception);
229 CORBA::Long NbPyramids()
230 throw (SALOME::SALOME_Exception);
232 CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
233 throw (SALOME::SALOME_Exception);
235 CORBA::Long NbPrisms()
236 throw (SALOME::SALOME_Exception);
238 CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
239 throw (SALOME::SALOME_Exception);
241 CORBA::Long NbPolyhedrons()
242 throw (SALOME::SALOME_Exception);
244 CORBA::Long NbSubMesh()
245 throw (SALOME::SALOME_Exception);
247 SMESH::long_array* GetElementsId()
248 throw (SALOME::SALOME_Exception);
250 SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
251 throw (SALOME::SALOME_Exception);
253 SMESH::long_array* GetNodesId()
254 throw (SALOME::SALOME_Exception);
256 SMESH::ElementType GetElementType( const CORBA::Long id, const bool iselem )
257 throw (SALOME::SALOME_Exception);
260 * Returns ID of elements for given submesh
262 SMESH::long_array* GetSubMeshElementsId(const CORBA::Long ShapeID)
263 throw (SALOME::SALOME_Exception);
266 * Returns ID of nodes for given submesh
267 * If param all==true - returns all nodes, else -
268 * returns only nodes on shapes.
270 SMESH::long_array* GetSubMeshNodesId(const CORBA::Long ShapeID, CORBA::Boolean all)
271 throw (SALOME::SALOME_Exception);
274 * Returns type of elements for given submesh
276 SMESH::ElementType GetSubMeshElementType(const CORBA::Long ShapeID)
277 throw (SALOME::SALOME_Exception);
281 // Internal methods not available through CORBA
282 // They are called by corresponding interface methods
283 SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
284 SMESH::SMESH_Hypothesis_ptr anHyp);
286 SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
287 SMESH::SMESH_Hypothesis_ptr anHyp);
289 int importMEDFile( const char* theFileName, const char* theMeshName );
291 SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
293 void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
294 GEOM::GEOM_Object_ptr theSubShapeObject );
296 SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
298 const TopoDS_Shape& theShape = TopoDS_Shape());
300 void removeGroup( const int theId );
302 SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
303 // return an existing subMesh object for the shapeID. shapeID == submeshID.
305 const map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
306 // return an existing group object.
308 virtual SMESH::long_array* GetIDs();
310 CORBA::Long GetMeshPtr();
314 * Get XYZ coordinates of node as list of double
315 * If there is not node for given ID - returns empty list
317 SMESH::double_array* GetNodeXYZ(const CORBA::Long id);
320 * For given node returns list of IDs of inverse elements
321 * If there is not node for given ID - returns empty list
323 SMESH::long_array* GetNodeInverseElements(const CORBA::Long id);
326 * If given element is node returns IDs of shape from position
327 * If there is not node for given ID - returns -1
329 CORBA::Long GetShapeID(const CORBA::Long id);
332 * For given element returns ID of result shape after
333 * ::FindShape() from SMESH_MeshEditor
334 * If there is not element for given ID - returns -1
336 CORBA::Long GetShapeIDForElem(const CORBA::Long id);
339 * Returns number of nodes for given element
340 * If there is not element for given ID - returns -1
342 CORBA::Long GetElemNbNodes(const CORBA::Long id);
345 * Returns IDs of nodes of given element
347 SMESH::long_array* GetElemNodes(const CORBA::Long id);
350 * Returns ID of node by given index for given element
351 * If there is not element for given ID - returns -1
352 * If there is not node for given index - returns -2
354 CORBA::Long GetElemNode(const CORBA::Long id, const CORBA::Long index);
357 * Returns true if given node is medium node
358 * in given quadratic element
360 CORBA::Boolean IsMediumNode(const CORBA::Long ide, const CORBA::Long idn);
363 * Returns true if given node is medium node
364 * in one of quadratic elements
366 CORBA::Boolean IsMediumNodeOfAnyElem(const CORBA::Long idn,
367 SMESH::ElementType theElemType);
370 * Returns number of edges for given element
372 CORBA::Long ElemNbEdges(const CORBA::Long id);
375 * Returns number of faces for given element
377 CORBA::Long ElemNbFaces(const CORBA::Long id);
380 * Returns true if given element is polygon
382 CORBA::Boolean IsPoly(const CORBA::Long id);
385 * Returns true if given element is quadratic
387 CORBA::Boolean IsQuadratic(const CORBA::Long id);
390 * Returns bary center for given element
392 SMESH::double_array* BaryCenter(const CORBA::Long id);
395 map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
396 map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
399 void CreateGroupServants();
401 static int myIdGenerator;
402 ::SMESH_Mesh* _impl; // :: force no namespace here
404 int _id; // id given by creator (unique within the creator instance)
406 map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
407 map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
408 map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;