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"
35 #include "SMESH_subMesh.hxx"
36 #include "SMESH_Mesh_i.hxx"
37 #include "SMESH_subMesh_i.hxx"
39 //=============================================================================
43 //=============================================================================
44 SMESH_MEDSupport_i::SMESH_MEDSupport_i()
46 BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
47 END_OF("Default Constructor SMESH_MEDSupport_i");
50 //=============================================================================
54 //=============================================================================
55 SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i * sm, string name,
56 string description, SALOME_MED::medEntityMesh entity)
57 :_subMesh_i(sm), _name(name), _description(description), _entity(entity),
58 _seqNumber(false), _seqLength(0)
60 BEGIN_OF("Constructor SMESH_MEDSupport_i");
62 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
64 int subMeshId = _subMesh_i->GetId();
66 MESSAGE(" subMeshId " << subMeshId)
68 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) !=
69 _subMesh_i->_mesh_i->_mapSubMesh.end())
71 ::SMESH_subMesh * subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
72 _subMeshDS = subMesh->GetSubMeshDS();
75 if (_entity == SALOME_MED::MED_NODE)
77 _numberOfGeometricType = 1;
78 _geometricType = new SALOME_MED::medGeometryElement[1];
79 _geometricType[0] = SALOME_MED::MED_NONE;
83 MESSAGE("Pas implemente dans cette version");
84 THROW_SALOME_CORBA_EXCEPTION
85 ("Seules les familles de noeuds sont implementees ",
89 END_OF("Constructor SMESH_MEDSupport_i");
92 //=============================================================================
96 //=============================================================================
98 SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s):_subMesh_i(s._subMesh_i),
99 _name(s._name), _description(s._description), _entity(s._entity),
100 _seqNumber(false), _seqLength(0)
102 BEGIN_OF("Constructor SMESH_MEDSupport_i");
104 _meshDS = _subMesh_i->_mesh_i->GetImpl().GetMeshDS();
106 int subMeshId = _subMesh_i->GetId();
107 if (_subMesh_i->_mesh_i->_mapSubMesh.find(subMeshId) !=
108 _subMesh_i->_mesh_i->_mapSubMesh.end())
110 ::SMESH_subMesh * subMesh = _subMesh_i->_mesh_i->_mapSubMesh[subMeshId];
111 _subMeshDS = subMesh->GetSubMeshDS();
114 END_OF("Constructor SMESH_MEDSupport_i");
117 //=============================================================================
121 //=============================================================================
123 SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
127 //=============================================================================
129 * CORBA: Accessor for Corba Index
131 //=============================================================================
133 CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()throw(SALOME::SALOME_Exception)
135 if (_subMeshDS == NULL)
136 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
137 SALOME::INTERNAL_ERROR);
138 MESSAGE("Not implemented for SMESH_i");
139 THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", SALOME::BAD_PARAM);
143 //=============================================================================
145 * CORBA: Accessor for Name
147 //=============================================================================
149 char *SMESH_MEDSupport_i::getName() throw(SALOME::SALOME_Exception)
151 if (_subMeshDS==NULL)
152 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
153 SALOME::INTERNAL_ERROR);
154 return CORBA::string_dup(_name.c_str());
158 //=============================================================================
160 * CORBA: Accessor for Description
162 //=============================================================================
164 char *SMESH_MEDSupport_i::getDescription() throw(SALOME::SALOME_Exception)
166 if (_subMeshDS==NULL)
167 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
168 SALOME::INTERNAL_ERROR);
169 return CORBA::string_dup(_description.c_str());
172 //=============================================================================
174 * CORBA: Accessor for Mesh
176 //=============================================================================
178 SALOME_MED::MESH_ptr SMESH_MEDSupport_i::getMesh()throw(SALOME::
181 if (_subMeshDS==NULL)
182 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
183 SALOME::INTERNAL_ERROR);
185 return _subMesh_i->_mesh_i->GetMEDMesh();
188 //=============================================================================
190 * CORBA: boolean indicating if support concerns all elements
192 //=============================================================================
194 CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()throw(SALOME::
197 if (_subMeshDS==NULL)
198 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
199 SALOME::INTERNAL_ERROR);
200 if (_seqNumber == false)
202 if (_entity != SALOME_MED::MED_NONE)
204 _seqLength = _subMeshDS->NbNodes();
209 MESSAGE("Only Node Families are implemented ");
210 THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ",
216 _isOnAllElements = (_seqLength == _meshDS->NbNodes());
220 MESSAGE("unable to acces related Mesh");
221 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
222 SALOME::INTERNAL_ERROR);
224 return _isOnAllElements;
227 //=============================================================================
229 * CORBA: Accessor for type of support's entity
231 //=============================================================================
233 SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()throw(SALOME::
236 if (_subMeshDS==NULL)
237 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
238 SALOME::INTERNAL_ERROR);
242 //=============================================================================
244 * CORBA: Accessor for types of geometry elements
246 //=============================================================================
248 SALOME_MED::medGeometryElement_array *
249 SMESH_MEDSupport_i::getTypes()throw(SALOME::SALOME_Exception)
251 if (_subMeshDS==NULL)
252 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
253 SALOME::INTERNAL_ERROR);
254 SALOME_MED::medGeometryElement_array_var myseq =
255 new SALOME_MED::medGeometryElement_array;
258 int mySeqLength = _numberOfGeometricType;
259 myseq->length(mySeqLength);
260 for (int i = 0; i < mySeqLength; i++)
262 myseq[i] = _geometricType[i];
267 MESSAGE("Exception lors de la recherche des differents types");
268 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types",
269 SALOME::INTERNAL_ERROR);
271 return myseq._retn();
274 //=============================================================================
276 * CORBA: Number of different types of geometry elements
277 * existing in the support
279 //=============================================================================
280 CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::
281 medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
283 if (_subMeshDS==NULL)
284 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
285 SALOME::INTERNAL_ERROR);
286 return _numberOfGeometricType;
290 //=============================================================================
294 //=============================================================================
296 Engines::long_array * SMESH_MEDSupport_i::getNumber(
297 SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
299 if (_subMeshDS==NULL)
300 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
301 SALOME::INTERNAL_ERROR);
303 // A changer s'il ne s agit plus seulement de famille de noeuds
304 if (geomElement != SALOME_MED::MED_NONE)
305 THROW_SALOME_CORBA_EXCEPTION("Not implemented", SALOME::BAD_PARAM);
307 Engines::long_array_var myseq = new Engines::long_array;
310 myseq->length(_subMeshDS->NbNodes());
312 SMDS_Iterator<const SMDS_MeshNode*> * it = _subMeshDS->GetNodes();
315 myseq[i] = it->next()->GetID();
320 SCRUTE(myseq->length());
321 MESSAGE("End of SMESH_MEDSupport_i::getNumber");
322 return myseq._retn();
326 //=============================================================================
328 * CORBA: Global Nodes Index (optionnaly designed by the user)
329 * CORBA: ??????????????????????????????
331 //=============================================================================
333 Engines::long_array *
334 SMESH_MEDSupport_i::getNumberIndex()throw(SALOME::SALOME_Exception)
336 MESSAGE("Not implemented for SMESH_i");
337 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
341 //=============================================================================
343 * CORBA: Array containing indexes for elements included in the support
345 //=============================================================================
347 CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoints(SALOME_MED::
348 medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
350 MESSAGE("Not implemented for SMESH_i");