2 //=============================================================================
3 // File : SMESH_MEDSupport_i.cxx
5 // Copyright : EDF 2002
6 //=============================================================================
8 #include "SMESH_MEDSupport_i.hxx"
10 #include "Utils_CorbaException.hxx"
12 #include <TopoDS_Iterator.hxx>
13 #include "SMESHDS_Mesh.hxx"
14 #include "SMDS_MapIteratorOfExtendedMap.hxx"
16 #include "SMESH_subMesh.hxx"
17 #include "SMESH_Mesh_i.hxx"
18 #include "SMESH_subMesh_i.hxx"
20 //=============================================================================
24 //=============================================================================
25 SMESH_MEDSupport_i::SMESH_MEDSupport_i()
27 BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
28 END_OF("Default Constructor SMESH_MEDSupport_i");
31 //=============================================================================
35 //=============================================================================
36 SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i* sm,
39 SALOME_MED::medEntityMesh entity) :
42 _description(description),
47 BEGIN_OF("Constructor SMESH_MEDSupport_i");
49 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
51 int subMeshId = _subMesh_i->GetId();
53 MESSAGE ( " subMeshId " << subMeshId )
54 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) != _subMesh_i->_mesh_i->_mapSubMesh.end()) {
55 ::SMESH_subMesh* subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
57 _subMeshDS = subMesh->GetSubMeshDS();
60 if ( _entity == SALOME_MED::MED_NODE)
62 _numberOfGeometricType = 1 ;
63 _geometricType = new SALOME_MED::medGeometryElement[1] ;
64 _geometricType[0] = SALOME_MED::MED_NONE ;
68 MESSAGE("Pas implemente dans cette version");
69 THROW_SALOME_CORBA_EXCEPTION("Seules les familles de noeuds sont implementees ", \
73 END_OF("Constructor SMESH_MEDSupport_i");
75 //=============================================================================
79 //=============================================================================
80 SMESH_MEDSupport_i::SMESH_MEDSupport_i(const SMESH_MEDSupport_i &s) :
81 _subMesh_i(s._subMesh_i),
83 _description(s._description),
88 BEGIN_OF("Constructor SMESH_MEDSupport_i");
90 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
92 int subMeshId = _subMesh_i->GetId();
93 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) != _subMesh_i->_mesh_i->_mapSubMesh.end()) {
94 ::SMESH_subMesh* subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
95 _subMeshDS = subMesh->GetSubMeshDS();
98 END_OF("Constructor SMESH_MEDSupport_i");
100 //=============================================================================
104 //=============================================================================
106 SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
109 //=============================================================================
111 * CORBA: Accessor for Corba Index
113 //=============================================================================
115 CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()
116 throw (SALOME::SALOME_Exception)
118 if (_subMeshDS==NULL)
119 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
120 SALOME::INTERNAL_ERROR);
121 MESSAGE("Not implemented for SMESH_i");
122 THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", \
127 //=============================================================================
129 * CORBA: Accessor for Name
131 //=============================================================================
133 char * SMESH_MEDSupport_i::getName()
134 throw (SALOME::SALOME_Exception)
136 if (_subMeshDS.IsNull())
137 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
138 SALOME::INTERNAL_ERROR);
139 return CORBA::string_dup(_name.c_str());
143 //=============================================================================
145 * CORBA: Accessor for Description
147 //=============================================================================
149 char* SMESH_MEDSupport_i::getDescription()
150 throw (SALOME::SALOME_Exception)
152 if (_subMeshDS.IsNull())
153 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
154 SALOME::INTERNAL_ERROR);
155 return CORBA::string_dup(_description.c_str());
158 //=============================================================================
160 * CORBA: Accessor for Mesh
162 //=============================================================================
164 SALOME_MED::MESH_ptr SMESH_MEDSupport_i::getMesh()
165 throw (SALOME::SALOME_Exception)
167 if (_subMeshDS.IsNull())
168 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
169 SALOME::INTERNAL_ERROR);
171 return _subMesh_i->_mesh_i->GetMEDMesh();
174 //=============================================================================
176 * CORBA: boolean indicating if support concerns all elements
178 //=============================================================================
180 CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()
181 throw (SALOME::SALOME_Exception)
183 if (_subMeshDS.IsNull())
184 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
185 SALOME::INTERNAL_ERROR);
186 if (_seqNumber == false)
188 if (_entity != SALOME_MED::MED_NONE)
191 const SMDS_MapOfMeshElement& myNodesMap = _subMeshDS->GetNodes();
192 for (SMDS_MapIteratorOfExtendedMap it(myNodesMap); it.More(); it.Next())
194 const Handle(SMDS_MeshElement)& elem = myNodesMap.FindID(it.Key()->GetID());
195 const Handle(SMDS_MeshNode)& node = _meshDS->GetNode(1,elem);
203 MESSAGE("Only Node Families are implemented ");
204 THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ", \
210 if (_seqLength == _meshDS->NbNodes())
211 _isOnAllElements=true;
213 _isOnAllElements=false;
217 MESSAGE("unable to acces related Mesh");
218 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
219 SALOME::INTERNAL_ERROR);
221 return _isOnAllElements;
224 //=============================================================================
226 * CORBA: Accessor for type of support's entity
228 //=============================================================================
230 SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()
231 throw (SALOME::SALOME_Exception)
233 if (_subMeshDS.IsNull())
234 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
235 SALOME::INTERNAL_ERROR);
239 //=============================================================================
241 * CORBA: Accessor for types of geometry elements
243 //=============================================================================
245 SALOME_MED::medGeometryElement_array * SMESH_MEDSupport_i::getTypes()
246 throw (SALOME::SALOME_Exception)
248 if (_subMeshDS.IsNull())
249 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
250 SALOME::INTERNAL_ERROR);
251 SALOME_MED::medGeometryElement_array_var myseq = new SALOME_MED::medGeometryElement_array;
254 int mySeqLength = _numberOfGeometricType;
255 myseq->length(mySeqLength);
256 for (int i=0;i<mySeqLength;i++)
258 myseq[i]=_geometricType[i];
263 MESSAGE("Exception lors de la recherche des differents types");
264 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types", \
265 SALOME::INTERNAL_ERROR);
267 return myseq._retn();
270 //=============================================================================
272 * CORBA: Number of different types of geometry elements
273 * existing in the support
275 //=============================================================================
276 CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::medGeometryElement geomElement)
277 throw (SALOME::SALOME_Exception)
279 if (_subMeshDS.IsNull())
280 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
281 SALOME::INTERNAL_ERROR);
282 return _numberOfGeometricType;
286 //=============================================================================
290 //=============================================================================
292 Engines::long_array * SMESH_MEDSupport_i::getNumber(SALOME_MED::medGeometryElement geomElement)
293 throw (SALOME::SALOME_Exception)
295 if (_subMeshDS.IsNull())
296 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
297 SALOME::INTERNAL_ERROR);
300 // A changer s'il ne s agit plus seulement de famille de noeuds
301 if (geomElement != SALOME_MED::MED_NONE)
302 THROW_SALOME_CORBA_EXCEPTION("Not implemented", \
305 Engines::long_array_var myseq= new Engines::long_array;
308 const SMDS_MapOfMeshElement& myNodesMap = _subMeshDS->GetNodes();
309 for (SMDS_MapIteratorOfExtendedMap it(myNodesMap); it.More(); it.Next())
311 const Handle(SMDS_MeshElement)& elem = myNodesMap.FindID(it.Key()->GetID());
312 const Handle(SMDS_MeshNode)& node = _meshDS->GetNode(1,elem);
314 myseq[i]=node->GetID();
315 SCRUTE(node->GetID());
320 SCRUTE(myseq->length());
322 return myseq._retn();
325 //=============================================================================
327 * CORBA: Global Nodes Index (optionnaly designed by the user)
328 * CORBA: ??????????????????????????????
330 //=============================================================================
332 Engines::long_array * SMESH_MEDSupport_i::getNumberIndex()
333 throw (SALOME::SALOME_Exception)
335 MESSAGE("Not implemented for SMESH_i");
336 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", \
341 //=============================================================================
343 * CORBA: Array containing indexes for elements included in the support
345 //=============================================================================
347 CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoints(SALOME_MED::medGeometryElement geomElement)
348 throw (SALOME::SALOME_Exception)
350 MESSAGE("Not implemented for SMESH_i");