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 CORBA::Long NbGroups()
112 throw (SALOME::SALOME_Exception);
114 SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
115 SMESH::SMESH_GroupBase_ptr theGroup2,
116 const char* theName )
117 throw (SALOME::SALOME_Exception);
119 SMESH::SMESH_Group_ptr IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
120 SMESH::SMESH_GroupBase_ptr theGroup2,
121 const char* theName )
122 throw (SALOME::SALOME_Exception);
124 SMESH::SMESH_Group_ptr CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1,
125 SMESH::SMESH_GroupBase_ptr theGroup2,
126 const char* theName )
127 throw (SALOME::SALOME_Exception);
129 // SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet)
130 // throw (SALOME::SALOME_Exception);
132 SMESH::log_array* GetLog(CORBA::Boolean clearAfterGet)
133 throw (SALOME::SALOME_Exception);
135 SMESH::SMESH_MeshEditor_ptr GetMeshEditor();
137 SMESH::SMESH_MeshEditor_ptr GetMeshEditPreviewer();
140 throw (SALOME::SALOME_Exception);
143 throw (SALOME::SALOME_Exception);
145 CORBA::Long GetStudyId()
146 throw (SALOME::SALOME_Exception);
149 void SetImpl(::SMESH_Mesh* impl);
150 ::SMESH_Mesh& GetImpl(); // :: force no namespace here
152 SMESH_Gen_i* GetGen() { return _gen_i; }
154 int ImportUNVFile( const char* theFileName )
155 throw (SALOME::SALOME_Exception);
157 int ImportSTLFile( const char* theFileName )
158 throw (SALOME::SALOME_Exception);
161 * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value
163 SMESH::DriverMED_ReadStatus ImportMEDFile( const char* theFileName, const char* theMeshName )
164 throw (SALOME::SALOME_Exception);
169 void SetAutoColor(CORBA::Boolean theAutoColor)
170 throw (SALOME::SALOME_Exception);
172 CORBA::Boolean GetAutoColor()
173 throw (SALOME::SALOME_Exception);
175 /*! Check group names for duplications.
176 * Consider maximum group name length stored in MED file.
178 CORBA::Boolean HasDuplicatedGroupNamesMED();
180 void ExportToMED( const char* file, CORBA::Boolean auto_groups, SMESH::MED_VERSION theVersion )
181 throw (SALOME::SALOME_Exception);
182 void ExportMED( const char* file, CORBA::Boolean auto_groups )
183 throw (SALOME::SALOME_Exception);
185 void ExportDAT( const char* file )
186 throw (SALOME::SALOME_Exception);
187 void ExportUNV( const char* file )
188 throw (SALOME::SALOME_Exception);
189 void ExportSTL( const char* file, bool isascii )
190 throw (SALOME::SALOME_Exception);
192 SALOME_MED::MESH_ptr GetMEDMesh()
193 throw (SALOME::SALOME_Exception);
195 CORBA::Long NbNodes()
196 throw (SALOME::SALOME_Exception);
198 CORBA::Long NbElements()
199 throw (SALOME::SALOME_Exception);
201 CORBA::Long NbEdges()
202 throw (SALOME::SALOME_Exception);
204 CORBA::Long NbEdgesOfOrder(SMESH::ElementOrder order)
205 throw (SALOME::SALOME_Exception);
207 CORBA::Long NbFaces()
208 throw (SALOME::SALOME_Exception);
210 CORBA::Long NbFacesOfOrder(SMESH::ElementOrder order)
211 throw (SALOME::SALOME_Exception);
213 CORBA::Long NbTriangles()
214 throw (SALOME::SALOME_Exception);
216 CORBA::Long NbTrianglesOfOrder(SMESH::ElementOrder order)
217 throw (SALOME::SALOME_Exception);
219 CORBA::Long NbQuadrangles()
220 throw (SALOME::SALOME_Exception);
222 CORBA::Long NbQuadranglesOfOrder(SMESH::ElementOrder order)
223 throw (SALOME::SALOME_Exception);
225 CORBA::Long NbPolygons()
226 throw (SALOME::SALOME_Exception);
228 CORBA::Long NbVolumes()
229 throw (SALOME::SALOME_Exception);
231 CORBA::Long NbVolumesOfOrder(SMESH::ElementOrder order)
232 throw (SALOME::SALOME_Exception);
234 CORBA::Long NbTetras()
235 throw (SALOME::SALOME_Exception);
237 CORBA::Long NbTetrasOfOrder(SMESH::ElementOrder order)
238 throw (SALOME::SALOME_Exception);
240 CORBA::Long NbHexas()
241 throw (SALOME::SALOME_Exception);
243 CORBA::Long NbHexasOfOrder(SMESH::ElementOrder order)
244 throw (SALOME::SALOME_Exception);
246 CORBA::Long NbPyramids()
247 throw (SALOME::SALOME_Exception);
249 CORBA::Long NbPyramidsOfOrder(SMESH::ElementOrder order)
250 throw (SALOME::SALOME_Exception);
252 CORBA::Long NbPrisms()
253 throw (SALOME::SALOME_Exception);
255 CORBA::Long NbPrismsOfOrder(SMESH::ElementOrder order)
256 throw (SALOME::SALOME_Exception);
258 CORBA::Long NbPolyhedrons()
259 throw (SALOME::SALOME_Exception);
261 CORBA::Long NbSubMesh()
262 throw (SALOME::SALOME_Exception);
264 SMESH::long_array* GetElementsId()
265 throw (SALOME::SALOME_Exception);
267 SMESH::long_array* GetElementsByType( SMESH::ElementType theElemType )
268 throw (SALOME::SALOME_Exception);
270 SMESH::long_array* GetNodesId()
271 throw (SALOME::SALOME_Exception);
273 SMESH::ElementType GetElementType( CORBA::Long id, bool iselem )
274 throw (SALOME::SALOME_Exception);
277 * Returns ID of elements for given submesh
279 SMESH::long_array* GetSubMeshElementsId(CORBA::Long ShapeID)
280 throw (SALOME::SALOME_Exception);
283 * Returns ID of nodes for given submesh
284 * If param all==true - returns all nodes, else -
285 * returns only nodes on shapes.
287 SMESH::long_array* GetSubMeshNodesId(CORBA::Long ShapeID, CORBA::Boolean all)
288 throw (SALOME::SALOME_Exception);
291 * Returns type of elements for given submesh
293 SMESH::ElementType GetSubMeshElementType(CORBA::Long ShapeID)
294 throw (SALOME::SALOME_Exception);
298 // Internal methods not available through CORBA
299 // They are called by corresponding interface methods
300 SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
301 SMESH::SMESH_Hypothesis_ptr anHyp);
303 SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
304 SMESH::SMESH_Hypothesis_ptr anHyp);
306 static SMESH::Hypothesis_Status
307 ConvertHypothesisStatus (SMESH_Hypothesis::Hypothesis_Status theStatus);
309 //int importMEDFile( const char* theFileName, const char* theMeshName );
311 SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject );
313 void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh,
314 GEOM::GEOM_Object_ptr theSubShapeObject );
316 SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType,
318 const TopoDS_Shape& theShape = TopoDS_Shape());
320 void removeGroup( const int theId );
322 SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID);
323 // return an existing subMesh object for the shapeID. shapeID == submeshID.
325 const map<int, SMESH::SMESH_GroupBase_ptr>& getGroups() { return _mapGroups; }
326 // return an existing group object.
329 * \brief Update hypotheses assigned to geom groups if the latter change
331 * NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
333 void CheckGeomGroupModif();
335 virtual SMESH::long_array* GetIDs();
337 CORBA::LongLong GetMeshPtr();
340 * \brief Assure that all groups are published
342 void CreateGroupServants();
345 * \brief Return groups cantained in _mapGroups by their IDs
347 SMESH::ListOfGroups* GetGroups(const std::list<int>& groupIDs) const;
350 * Get XYZ coordinates of node as list of double
351 * If there is not node for given ID - returns empty list
353 SMESH::double_array* GetNodeXYZ(CORBA::Long id);
356 * For given node returns list of IDs of inverse elements
357 * If there is not node for given ID - returns empty list
359 SMESH::long_array* GetNodeInverseElements(CORBA::Long id);
362 * \brief Return position of a node on shape
364 SMESH::NodePosition* GetNodePosition(CORBA::Long NodeID);
367 * If given element is node returns IDs of shape from position
368 * If there is not node for given ID - returns -1
370 CORBA::Long GetShapeID(CORBA::Long id);
373 * For given element returns ID of result shape after
374 * ::FindShape() from SMESH_MeshEditor
375 * If there is not element for given ID - returns -1
377 CORBA::Long GetShapeIDForElem(CORBA::Long id);
380 * Returns number of nodes for given element
381 * If there is not element for given ID - returns -1
383 CORBA::Long GetElemNbNodes(CORBA::Long id);
386 * Returns IDs of nodes of given element
388 SMESH::long_array* GetElemNodes(CORBA::Long id);
391 * Returns ID of node by given index for given element
392 * If there is not element for given ID - returns -1
393 * If there is not node for given index - returns -2
395 CORBA::Long GetElemNode(CORBA::Long id, CORBA::Long index);
398 * Returns true if given node is medium node
399 * in given quadratic element
401 CORBA::Boolean IsMediumNode(CORBA::Long ide, CORBA::Long idn);
404 * Returns true if given node is medium node
405 * in one of quadratic elements
407 CORBA::Boolean IsMediumNodeOfAnyElem(CORBA::Long idn,
408 SMESH::ElementType theElemType);
411 * Returns number of edges for given element
413 CORBA::Long ElemNbEdges(CORBA::Long id);
416 * Returns number of faces for given element
418 CORBA::Long ElemNbFaces(CORBA::Long id);
421 * Returns true if given element is polygon
423 CORBA::Boolean IsPoly(CORBA::Long id);
426 * Returns true if given element is quadratic
428 CORBA::Boolean IsQuadratic(CORBA::Long id);
431 * Returns bary center for given element
433 SMESH::double_array* BaryCenter(CORBA::Long id);
436 map<int, SMESH_subMesh_i*> _mapSubMesh_i; //NRI
437 map<int, ::SMESH_subMesh*> _mapSubMesh; //NRI
441 static int myIdGenerator;
442 ::SMESH_Mesh* _impl; // :: force no namespace here
444 int _id; // id given by creator (unique within the creator instance)
446 map<int, SMESH::SMESH_subMesh_ptr> _mapSubMeshIor;
447 map<int, SMESH::SMESH_GroupBase_ptr> _mapGroups;
448 map<int, SMESH::SMESH_Hypothesis_ptr> _mapHypo;