1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
23 // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
24 // File : SMESH_MEDSupport_i.cxx
27 #include "SMESH_MEDSupport_i.hxx"
28 #include "utilities.h"
29 #include "Utils_CorbaException.hxx"
30 #include "Utils_ExceptHandlers.hxx"
32 #include <TopoDS_Iterator.hxx>
33 #include "SMESHDS_Mesh.hxx"
35 #include "SMESH_subMesh.hxx"
36 #include "SMESH_Mesh_i.hxx"
37 #include "SMESH_subMesh_i.hxx"
42 //=============================================================================
46 //=============================================================================
47 SMESH_MEDSupport_i::SMESH_MEDSupport_i()
49 BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
50 END_OF("Default Constructor SMESH_MEDSupport_i");
53 //=============================================================================
57 //=============================================================================
58 SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i * sm, string name,
59 string description, SALOME_MED::medEntityMesh entity)
60 :_subMesh_i(sm), _name(name), _description(description), _entity(entity),
61 _seqNumber(false), _seqLength(0)
63 BEGIN_OF("Constructor SMESH_MEDSupport_i");
65 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
67 int subMeshId = _subMesh_i->GetId();
69 MESSAGE(" subMeshId " << subMeshId)
71 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) !=
72 _subMesh_i->_mesh_i->_mapSubMesh.end())
74 ::SMESH_subMesh * subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
75 _subMeshDS = subMesh->GetSubMeshDS();
78 if (_entity == SALOME_MED::MED_NODE)
80 _numberOfGeometricType = 1;
81 _geometricType = new SALOME_MED::medGeometryElement[1];
82 _geometricType[0] = SALOME_MED::MED_NONE;
86 MESSAGE("Pas implemente dans cette version");
87 THROW_SALOME_CORBA_EXCEPTION
88 ("Seules les familles de noeuds sont implementees ",
92 END_OF("Constructor SMESH_MEDSupport_i");
95 //=============================================================================
99 //=============================================================================
101 SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s):_subMesh_i(s._subMesh_i),
102 _name(s._name), _description(s._description), _entity(s._entity),
103 _seqNumber(false), _seqLength(0)
105 BEGIN_OF("Constructor SMESH_MEDSupport_i");
107 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
109 int subMeshId = _subMesh_i->GetId();
110 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) !=
111 _subMesh_i->_mesh_i->_mapSubMesh.end())
113 ::SMESH_subMesh * subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
114 _subMeshDS = subMesh->GetSubMeshDS();
117 END_OF("Constructor SMESH_MEDSupport_i");
120 //=============================================================================
124 //=============================================================================
126 SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
130 //=============================================================================
132 * CORBA: Accessor for Corba Index
134 //=============================================================================
136 CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()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 ", SALOME::BAD_PARAM);
146 //=============================================================================
148 * CORBA: Accessor for Name
150 //=============================================================================
152 char *SMESH_MEDSupport_i::getName() throw(SALOME::SALOME_Exception)
154 if (_subMeshDS==NULL)
155 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
156 SALOME::INTERNAL_ERROR);
157 return CORBA::string_dup(_name.c_str());
161 //=============================================================================
163 * CORBA: Accessor for Description
165 //=============================================================================
167 char *SMESH_MEDSupport_i::getDescription() throw(SALOME::SALOME_Exception)
169 if (_subMeshDS==NULL)
170 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
171 SALOME::INTERNAL_ERROR);
172 return CORBA::string_dup(_description.c_str());
175 //=============================================================================
177 * CORBA: Accessor for Mesh
179 //=============================================================================
181 SALOME_MED::GMESH_ptr SMESH_MEDSupport_i::getMesh()throw(SALOME::
184 if (_subMeshDS==NULL)
185 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
186 SALOME::INTERNAL_ERROR);
188 return _subMesh_i->_mesh_i->GetMEDMesh();
191 //=============================================================================
193 * CORBA: boolean indicating if support concerns all elements
195 //=============================================================================
197 CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()throw(SALOME::
200 if (_subMeshDS==NULL)
201 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
202 SALOME::INTERNAL_ERROR);
203 if (_seqNumber == false)
205 if (_entity != SALOME_MED::MED_NONE)
207 _seqLength = _subMeshDS->NbNodes();
212 MESSAGE("Only Node Families are implemented ");
213 THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ",
219 _isOnAllElements = (_seqLength == _meshDS->NbNodes());
223 MESSAGE("unable to acces related Mesh");
224 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
225 SALOME::INTERNAL_ERROR);
227 return _isOnAllElements;
230 //=============================================================================
232 * CORBA: Accessor for type of support's entity
234 //=============================================================================
236 SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()throw(SALOME::
239 if (_subMeshDS==NULL)
240 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
241 SALOME::INTERNAL_ERROR);
245 //=============================================================================
247 * CORBA: Accessor for types of geometry elements
249 //=============================================================================
251 SALOME_MED::medGeometryElement_array *
252 SMESH_MEDSupport_i::getTypes()throw(SALOME::SALOME_Exception)
254 if (_subMeshDS==NULL)
255 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
256 SALOME::INTERNAL_ERROR);
257 SALOME_MED::medGeometryElement_array_var myseq =
258 new SALOME_MED::medGeometryElement_array;
261 int mySeqLength = _numberOfGeometricType;
262 myseq->length(mySeqLength);
263 for (int i = 0; i < mySeqLength; i++)
265 myseq[i] = _geometricType[i];
270 MESSAGE("Exception lors de la recherche des differents types");
271 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types",
272 SALOME::INTERNAL_ERROR);
274 return myseq._retn();
277 //=============================================================================
279 * CORBA: Number of different types of geometry elements
280 * existing in the support
282 //=============================================================================
283 CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::
284 medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
286 if (_subMeshDS==NULL)
287 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
288 SALOME::INTERNAL_ERROR);
289 return _numberOfGeometricType;
293 //=============================================================================
297 //=============================================================================
299 SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumber(
300 SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
302 Unexpect aCatch(SALOME_SalomeException);
303 if (_subMeshDS==NULL)
304 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
305 SALOME::INTERNAL_ERROR);
307 // A changer s'il ne s agit plus seulement de famille de noeuds
308 if (geomElement != SALOME_MED::MED_NONE)
309 THROW_SALOME_CORBA_EXCEPTION("Not implemented", SALOME::BAD_PARAM);
311 SALOME_TYPES::ListOfLong_var myseq = new SALOME_TYPES::ListOfLong;
314 myseq->length(_subMeshDS->NbNodes());
316 SMDS_NodeIteratorPtr it = _subMeshDS->GetNodes();
319 myseq[i] = it->next()->GetID();
323 SCRUTE(myseq->length());
324 MESSAGE("End of SMESH_MEDSupport_i::getNumber");
325 return myseq._retn();
329 //=============================================================================
331 * CORBA: get Nodes from file
333 //=============================================================================
335 SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumberFromFile(
336 SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
338 return getNumber(geomElement);
341 //=============================================================================
343 * CORBA: Global Nodes Index (optionnaly designed by the user)
344 * CORBA: ??????????????????????????????
346 //=============================================================================
348 SALOME_TYPES::ListOfLong *
349 SMESH_MEDSupport_i::getNumberIndex()throw(SALOME::SALOME_Exception)
351 MESSAGE("Not implemented for SMESH_i");
352 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
355 //=============================================================================
357 * CORBA: Array containing indexes for elements included in the support
359 //=============================================================================
361 CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoint(SALOME_MED::
362 medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
364 MESSAGE("Not implemented for SMESH_i");
367 //=============================================================================
369 * Gives the number of types of elements included in the support
371 //=============================================================================
372 CORBA::Long SMESH_MEDSupport_i::getNumberOfTypes()
373 throw (SALOME::SALOME_Exception)
375 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
376 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
379 //=============================================================================
381 * Gives CORBA: Array containing the numbers of Gauss point of elements
382 * included in the support
384 //=============================================================================
385 SALOME_TYPES::ListOfLong* SMESH_MEDSupport_i::getNumbersOfGaussPoint()
386 throw (SALOME::SALOME_Exception)
388 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
389 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
392 //=============================================================================
394 * build the object which will contain all the boundary elements of the mesh.
396 //=============================================================================
397 void SMESH_MEDSupport_i::getBoundaryElements()
398 throw (SALOME::SALOME_Exception)
400 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
401 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
403 //=============================================================================
405 * Gives information on the support
407 //=============================================================================
408 SALOME_MED::SUPPORT::supportInfos * SMESH_MEDSupport_i::getSupportGlobal()
409 throw (SALOME::SALOME_Exception)
411 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
412 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);