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 GEOM::GEOM_Object_ptr GetShapeToMesh()
71 throw (SALOME::SALOME_Exception);
73 SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
74 SMESH::SMESH_Hypothesis_ptr anHyp)
75 throw (SALOME::SALOME_Exception);
77 SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
78 SMESH::SMESH_Hypothesis_ptr anHyp)
79 throw (SALOME::SALOME_Exception);
81 SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject)
82 throw (SALOME::SALOME_Exception);
84 SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName)
85 throw (SALOME::SALOME_Exception);
87 void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
88 throw (SALOME::SALOME_Exception);
90 SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName )
91 throw (SALOME::SALOME_Exception);
93 SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType theElemType,
95 GEOM::GEOM_Object_ptr theGeomObj )
96 throw (SALOME::SALOME_Exception);
98 void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
99 throw (SALOME::SALOME_Exception);
101 void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
102 throw (SALOME::SALOME_Exception);
104 SMESH::ListOfGroups* GetGroups()
105 throw (SALOME::SALOME_Exception);
107 SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
108 SMESH::SMESH_GroupBase_ptr theGroup2,
109 const char* theName )
110 throw (SALOME::SALOME_Exception);
112 SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
113 SMESH::SMESH_GroupBase_ptr theGroup2,
114 const char* theName )
115 throw (SALOME::SALOME_Exception);
117 SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
118 SMESH::SMESH_GroupBase_ptr theGroup2,
119 const char* theName )
120 throw (SALOME::SALOME_Exception);
122 // SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
123 // throw (SALOME::SALOME_Exception);
125 SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
126 throw (SALOME::SALOME_Exception);
128 SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
131 throw (SALOME::SALOME_Exception);
134 throw (SALOME::SALOME_Exception);
136 CORBA::Long GetStudyId()
137 throw (SALOME::SALOME_Exception);
140 void SetImpl(::SMESH_Mesh* impl);
141 ::SMESH_Mesh& GetImpl(); // :: force no namespace here
143 SMESH_Gen_i* GetGen() { return _gen_i; }
145 int ImportUNVFile( const char* theFileName )
146 throw (SALOME::SALOME_Exception);
148 int ImportSTLFile( const char* theFileName )
149 throw (SALOME::SALOME_Exception);
152 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
154 SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
155 throw (SALOME::SALOME_Exception);
157 /*! Check group names for duplications.
158 * Consider maximum group name length stored in MED file.
160 CORBA::Boolean HasDuplicatedGroupNamesMED();
162 void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
163 throw (SALOME::SALOME_Exception);
164 void ExportMED( const char* file, CORBA::Boolean auto_groups )
165 throw (SALOME::SALOME_Exception);
167 void ExportDAT( const char* file )
168 throw (SALOME::SALOME_Exception);
169 void ExportUNV( const char* file )
170 throw (SALOME::SALOME_Exception);
171 void ExportSTL( const char* file, bool isascii )
172 throw (SALOME::SALOME_Exception);
174 SALOME_MED::MESH_ptr GetMEDMesh()
175 throw (SALOME::SALOME_Exception);
177 CORBA::Long NbNodes()
178 throw (SALOME::SALOME_Exception);
180 CORBA::Long NbElements()
181 throw (SALOME::SALOME_Exception);
183 CORBA::Long NbEdges()
184 throw (SALOME::SALOME_Exception);
186 CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
187 throw (SALOME::SALOME_Exception);
189 CORBA::Long NbFaces()
190 throw (SALOME::SALOME_Exception);
192 CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
193 throw (SALOME::SALOME_Exception);
195 CORBA::Long NbTriangles()
196 throw (SALOME::SALOME_Exception);
198 CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
199 throw (SALOME::SALOME_Exception);
201 CORBA::Long NbQuadrangles()
202 throw (SALOME::SALOME_Exception);
204 CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
205 throw (SALOME::SALOME_Exception);
207 CORBA::Long NbPolygons()
208 throw (SALOME::SALOME_Exception);
210 CORBA::Long NbVolumes()
211 throw (SALOME::SALOME_Exception);
213 CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
214 throw (SALOME::SALOME_Exception);
216 CORBA::Long NbTetras()
217 throw (SALOME::SALOME_Exception);
219 CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
220 throw (SALOME::SALOME_Exception);
222 CORBA::Long NbHexas()
223 throw (SALOME::SALOME_Exception);
225 CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
226 throw (SALOME::SALOME_Exception);
228 CORBA::Long NbPyramids()
229 throw (SALOME::SALOME_Exception);
231 CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
232 throw (SALOME::SALOME_Exception);
234 CORBA::Long NbPrisms()
235 throw (SALOME::SALOME_Exception);
237 CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
238 throw (SALOME::SALOME_Exception);
240 CORBA::Long NbPolyhedrons()
241 throw (SALOME::SALOME_Exception);
243 CORBA::Long NbSubMesh()
244 throw (SALOME::SALOME_Exception);
246 SMESH::long_array* GetElementsId()
247 throw (SALOME::SALOME_Exception);
249 SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
250 throw (SALOME::SALOME_Exception);
252 SMESH::long_array* GetNodesId()
253 throw (SALOME::SALOME_Exception);
255 SMESH::ElementType GetElementType( CORBA::Long id, bool iselem )
256 throw (SALOME::SALOME_Exception);
259 * Returns ID of elements for given submesh
261 SMESH::long_array* GetSubMeshElementsId( CORBA::Long ShapeID)
262 throw (SALOME::SALOME_Exception);
265 * Returns ID of nodes for given submesh
266 * If param all==true - returns all nodes, else -
267 * returns only nodes on shapes.
269 SMESH::long_array* GetSubMeshNodesId( CORBA::Long ShapeID, CORBA::Boolean all)
270 throw (SALOME::SALOME_Exception);
273 * Returns type of elements for given submesh
275 SMESH::ElementType GetSubMeshElementType( CORBA::Long ShapeID)
276 throw (SALOME::SALOME_Exception);
280 // Internal methods not available through CORBA
281 // They are called by corresponding interface methods
282 SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
283 SMESH::SMESH_Hypothesis_ptr anHyp);
285 SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
286 SMESH::SMESH_Hypothesis_ptr anHyp);
288 int importMEDFile( const char* theFileName, const char* theMeshName );
290 SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
292 void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
293 GEOM::GEOM_Object_ptr theSubShapeObject );
295 SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
297 const TopoDS_Shape& theShape = TopoDS_Shape());
299 void removeGroup( const int theId );
301 SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
302 // return an existing subMesh object for the shapeID. shapeID == submeshID.
304 const map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
305 // return an existing group object.
307 virtual SMESH::long_array* GetIDs();
309 CORBA::Long GetMeshPtr();
313 * Get XYZ coordinates of node as list of double
314 * If there is not node for given ID - returns empty list
316 SMESH::double_array* GetNodeXYZ( CORBA::Long id);
319 * For given node returns list of IDs of inverse elements
320 * If there is not node for given ID - returns empty list
322 SMESH::long_array* GetNodeInverseElements( CORBA::Long id);
325 * If given element is node returns IDs of shape from position
326 * else - return ID of result shape after ::FindShape()
327 * from SMESH_MeshEditor
328 * If there is not element for given ID - returns -1
330 CORBA::Long GetShapeID( CORBA::Long id);
333 * Returns number of nodes for given element
334 * If there is not element for given ID - returns -1
336 CORBA::Long GetElemNbNodes( CORBA::Long id);
339 * Returns ID of node by given index for given element
340 * If there is not element for given ID - returns -1
341 * If there is not node for given index - returns -2
343 CORBA::Long GetElemNode( CORBA::Long id, CORBA::Long index);
346 * Returns true if given node is medium node
347 * in given quadratic element
349 CORBA::Boolean IsMediumNode( CORBA::Long ide, CORBA::Long idn);
352 * Returns true if given node is medium node
353 * in one of quadratic elements
355 CORBA::Boolean IsMediumNodeOfAnyElem( CORBA::Long idn,
356 SMESH::ElementType theElemType);
359 * Returns number of edges for given element
361 CORBA::Long ElemNbEdges( CORBA::Long id);
364 * Returns number of faces for given element
366 CORBA::Long ElemNbFaces( CORBA::Long id);
369 * Returns true if given element is polygon
371 CORBA::Boolean IsPoly( CORBA::Long id);
374 * Returns true if given element is quadratic
376 CORBA::Boolean IsQuadratic( CORBA::Long id);
379 * Returns bary center for given element
381 SMESH::double_array* BaryCenter( CORBA::Long id);
384 map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
385 map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
388 void CreateGroupServants();
390 static int myIdGenerator;
391 ::SMESH_Mesh* _impl; // :: force no namespace here
393 int _id; // id given by creator (unique within the creator instance)
395 map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
396 map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
397 map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;