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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_MEDSupport_i.cxx
28 #include "SMESH_MEDSupport_i.hxx"
29 #include "utilities.h"
30 #include "Utils_CorbaException.hxx"
32 #include <TopoDS_Iterator.hxx>
33 #include "SMESHDS_Mesh.hxx"
34 #include "SMDS_MapIteratorOfExtendedMap.hxx"
36 #include "SMESH_subMesh.hxx"
37 #include "SMESH_Mesh_i.hxx"
38 #include "SMESH_subMesh_i.hxx"
40 //=============================================================================
44 //=============================================================================
45 SMESH_MEDSupport_i::SMESH_MEDSupport_i()
47 BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
48 END_OF("Default Constructor SMESH_MEDSupport_i");
51 //=============================================================================
55 //=============================================================================
56 SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i* sm,
59 SALOME_MED::medEntityMesh entity) :
62 _description(description),
67 BEGIN_OF("Constructor SMESH_MEDSupport_i");
69 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
71 int subMeshId = _subMesh_i->GetId();
73 MESSAGE ( " subMeshId " << subMeshId )
74 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) != _subMesh_i->_mesh_i->_mapSubMesh.end()) {
75 ::SMESH_subMesh* subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
77 _subMeshDS = subMesh->GetSubMeshDS();
80 if ( _entity == SALOME_MED::MED_NODE)
82 _numberOfGeometricType = 1 ;
83 _geometricType = new SALOME_MED::medGeometryElement[1] ;
84 _geometricType[0] = SALOME_MED::MED_NONE ;
88 MESSAGE("Pas implemente dans cette version");
89 THROW_SALOME_CORBA_EXCEPTION("Seules les familles de noeuds sont implementees ", \
93 END_OF("Constructor SMESH_MEDSupport_i");
95 //=============================================================================
99 //=============================================================================
100 SMESH_MEDSupport_i::SMESH_MEDSupport_i(const SMESH_MEDSupport_i &s) :
101 _subMesh_i(s._subMesh_i),
103 _description(s._description),
108 BEGIN_OF("Constructor SMESH_MEDSupport_i");
110 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
112 int subMeshId = _subMesh_i->GetId();
113 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) != _subMesh_i->_mesh_i->_mapSubMesh.end()) {
114 ::SMESH_subMesh* subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
115 _subMeshDS = subMesh->GetSubMeshDS();
118 END_OF("Constructor SMESH_MEDSupport_i");
120 //=============================================================================
124 //=============================================================================
126 SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
129 //=============================================================================
131 * CORBA: Accessor for Corba Index
133 //=============================================================================
135 CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()
136 throw (SALOME::SALOME_Exception)
138 if (_subMeshDS==NULL)
139 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
140 SALOME::INTERNAL_ERROR);
141 MESSAGE("Not implemented for SMESH_i");
142 THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", \
147 //=============================================================================
149 * CORBA: Accessor for Name
151 //=============================================================================
153 char * SMESH_MEDSupport_i::getName()
154 throw (SALOME::SALOME_Exception)
156 if (_subMeshDS.IsNull())
157 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
158 SALOME::INTERNAL_ERROR);
159 return CORBA::string_dup(_name.c_str());
163 //=============================================================================
165 * CORBA: Accessor for Description
167 //=============================================================================
169 char* SMESH_MEDSupport_i::getDescription()
170 throw (SALOME::SALOME_Exception)
172 if (_subMeshDS.IsNull())
173 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
174 SALOME::INTERNAL_ERROR);
175 return CORBA::string_dup(_description.c_str());
178 //=============================================================================
180 * CORBA: Accessor for Mesh
182 //=============================================================================
184 SALOME_MED::MESH_ptr SMESH_MEDSupport_i::getMesh()
185 throw (SALOME::SALOME_Exception)
187 if (_subMeshDS.IsNull())
188 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
189 SALOME::INTERNAL_ERROR);
191 return _subMesh_i->_mesh_i->GetMEDMesh();
194 //=============================================================================
196 * CORBA: boolean indicating if support concerns all elements
198 //=============================================================================
200 CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()
201 throw (SALOME::SALOME_Exception)
203 if (_subMeshDS.IsNull())
204 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
205 SALOME::INTERNAL_ERROR);
206 if (_seqNumber == false)
208 if (_entity != SALOME_MED::MED_NONE)
211 const SMDS_MapOfMeshElement& myNodesMap = _subMeshDS->GetNodes();
212 for (SMDS_MapIteratorOfExtendedMap it(myNodesMap); it.More(); it.Next())
214 const Handle(SMDS_MeshElement)& elem = myNodesMap.FindID(it.Key()->GetID());
215 const Handle(SMDS_MeshNode)& node = _meshDS->GetNode(1,elem);
223 MESSAGE("Only Node Families are implemented ");
224 THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ", \
230 if (_seqLength == _meshDS->NbNodes())
231 _isOnAllElements=true;
233 _isOnAllElements=false;
237 MESSAGE("unable to acces related Mesh");
238 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
239 SALOME::INTERNAL_ERROR);
241 return _isOnAllElements;
244 //=============================================================================
246 * CORBA: Accessor for type of support's entity
248 //=============================================================================
250 SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()
251 throw (SALOME::SALOME_Exception)
253 if (_subMeshDS.IsNull())
254 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
255 SALOME::INTERNAL_ERROR);
259 //=============================================================================
261 * CORBA: Accessor for types of geometry elements
263 //=============================================================================
265 SALOME_MED::medGeometryElement_array * SMESH_MEDSupport_i::getTypes()
266 throw (SALOME::SALOME_Exception)
268 if (_subMeshDS.IsNull())
269 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
270 SALOME::INTERNAL_ERROR);
271 SALOME_MED::medGeometryElement_array_var myseq = new SALOME_MED::medGeometryElement_array;
274 int mySeqLength = _numberOfGeometricType;
275 myseq->length(mySeqLength);
276 for (int i=0;i<mySeqLength;i++)
278 myseq[i]=_geometricType[i];
283 MESSAGE("Exception lors de la recherche des differents types");
284 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types", \
285 SALOME::INTERNAL_ERROR);
287 return myseq._retn();
290 //=============================================================================
292 * CORBA: Number of different types of geometry elements
293 * existing in the support
295 //=============================================================================
296 CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::medGeometryElement geomElement)
297 throw (SALOME::SALOME_Exception)
299 if (_subMeshDS.IsNull())
300 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
301 SALOME::INTERNAL_ERROR);
302 return _numberOfGeometricType;
306 //=============================================================================
310 //=============================================================================
312 Engines::long_array * SMESH_MEDSupport_i::getNumber(SALOME_MED::medGeometryElement geomElement)
313 throw (SALOME::SALOME_Exception)
315 if (_subMeshDS.IsNull())
316 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
317 SALOME::INTERNAL_ERROR);
320 // A changer s'il ne s agit plus seulement de famille de noeuds
321 if (geomElement != SALOME_MED::MED_NONE)
322 THROW_SALOME_CORBA_EXCEPTION("Not implemented", \
325 Engines::long_array_var myseq= new Engines::long_array;
328 const SMDS_MapOfMeshElement& myNodesMap = _subMeshDS->GetNodes();
329 for (SMDS_MapIteratorOfExtendedMap it(myNodesMap); it.More(); it.Next())
331 const Handle(SMDS_MeshElement)& elem = myNodesMap.FindID(it.Key()->GetID());
332 const Handle(SMDS_MeshNode)& node = _meshDS->GetNode(1,elem);
334 myseq[i]=node->GetID();
335 SCRUTE(node->GetID());
340 SCRUTE(myseq->length());
342 return myseq._retn();
345 //=============================================================================
347 * CORBA: Global Nodes Index (optionnaly designed by the user)
348 * CORBA: ??????????????????????????????
350 //=============================================================================
352 Engines::long_array * SMESH_MEDSupport_i::getNumberIndex()
353 throw (SALOME::SALOME_Exception)
355 MESSAGE("Not implemented for SMESH_i");
356 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", \
361 //=============================================================================
363 * CORBA: Array containing indexes for elements included in the support
365 //=============================================================================
367 CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoints(SALOME_MED::medGeometryElement geomElement)
368 throw (SALOME::SALOME_Exception)
370 MESSAGE("Not implemented for SMESH_i");