1 // Copyright (C) 2007-2013 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 "SMESHDS_Mesh.hxx"
34 #include "SMESH_subMesh.hxx"
35 #include "SMESH_Mesh_i.hxx"
36 #include "SMESH_subMesh_i.hxx"
37 #include "SMESH_Gen_i.hxx"
39 #include <TopoDS_Iterator.hxx>
44 //=============================================================================
48 //=============================================================================
49 SMESH_MEDSupport_i::SMESH_MEDSupport_i()
51 BEGIN_OF("Default Constructor SMESH_MEDSupport_i");
52 END_OF("Default Constructor SMESH_MEDSupport_i");
55 //=============================================================================
59 //=============================================================================
60 SMESH_MEDSupport_i::SMESH_MEDSupport_i(SMESH_subMesh_i * sm, string name,
61 string description, SALOME_MED::medEntityMesh entity)
62 :_subMesh_i(sm), _name(name), _description(description), _entity(entity),
63 _seqNumber(false), _seqLength(0)
65 BEGIN_OF("Constructor SMESH_MEDSupport_i");
67 int subMeshId = sm->GetId();
69 MESSAGE(" subMeshId " << subMeshId);
71 SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( sm->GetMesh() );
72 _subMesh = mesh_i->GetImpl().GetSubMeshContaining( subMeshId );
74 if (_entity == SALOME_MED::MED_NODE)
76 _numberOfGeometricType = 1;
77 _geometricType = new SALOME_MED::medGeometryElement[1];
78 _geometricType[0] = SALOME_MED::MED_NONE;
82 MESSAGE("Pas implemente dans cette version");
83 THROW_SALOME_CORBA_EXCEPTION
84 ("Seules les familles de noeuds sont implementees ",
88 END_OF("Constructor SMESH_MEDSupport_i");
91 //=============================================================================
95 //=============================================================================
97 SMESH_MEDSupport_i(const SMESH_MEDSupport_i & s):_subMesh(s._subMesh),
98 _name(s._name), _description(s._description), _entity(s._entity),
99 _seqNumber(false), _seqLength(0)
101 BEGIN_OF("Constructor SMESH_MEDSupport_i");
103 END_OF("Constructor SMESH_MEDSupport_i");
106 //=============================================================================
110 //=============================================================================
112 SMESH_MEDSupport_i::~SMESH_MEDSupport_i()
116 //=============================================================================
118 * CORBA: Accessor for Corba Index
120 //=============================================================================
122 CORBA::Long SMESH_MEDSupport_i::getCorbaIndex()throw(SALOME::SALOME_Exception)
124 if (_subMesh == NULL)
125 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
126 SALOME::INTERNAL_ERROR);
127 MESSAGE("Not implemented for SMESH_i");
128 THROW_SALOME_CORBA_EXCEPTION("Not Implemented ", SALOME::BAD_PARAM);
132 //=============================================================================
134 * CORBA: Accessor for Name
136 //=============================================================================
138 char *SMESH_MEDSupport_i::getName() throw(SALOME::SALOME_Exception)
141 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
142 SALOME::INTERNAL_ERROR);
143 return CORBA::string_dup(_name.c_str());
147 //=============================================================================
149 * CORBA: Accessor for Description
151 //=============================================================================
153 char *SMESH_MEDSupport_i::getDescription() throw(SALOME::SALOME_Exception)
156 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
157 SALOME::INTERNAL_ERROR);
158 return CORBA::string_dup(_description.c_str());
161 //=============================================================================
163 * CORBA: Accessor for Mesh
165 //=============================================================================
167 SALOME_MED::GMESH_ptr SMESH_MEDSupport_i::getMesh()throw(SALOME::
171 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
172 SALOME::INTERNAL_ERROR);
174 return _subMesh_i->GetMesh()->GetMEDMesh();
177 //=============================================================================
179 * CORBA: boolean indicating if support concerns all elements
181 //=============================================================================
183 CORBA::Boolean SMESH_MEDSupport_i::isOnAllElements()throw(SALOME::
187 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
188 SALOME::INTERNAL_ERROR);
189 if (_seqNumber == false)
191 if (_entity != SALOME_MED::MED_NONE)
193 _seqLength = _subMesh_i->GetNumberOfNodes(/*all=*/false);
198 MESSAGE("Only Node Families are implemented ");
199 THROW_SALOME_CORBA_EXCEPTION("Not implemented Yet ",
205 _isOnAllElements = (_seqLength == _subMesh->GetFather()->NbNodes());
209 MESSAGE("unable to acces related Mesh");
210 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
211 SALOME::INTERNAL_ERROR);
213 return _isOnAllElements;
216 //=============================================================================
218 * CORBA: Accessor for type of support's entity
220 //=============================================================================
222 SALOME_MED::medEntityMesh SMESH_MEDSupport_i::getEntity()throw(SALOME::
226 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
227 SALOME::INTERNAL_ERROR);
231 //=============================================================================
233 * CORBA: Accessor for types of geometry elements
235 //=============================================================================
237 SALOME_MED::medGeometryElement_array *
238 SMESH_MEDSupport_i::getTypes()throw(SALOME::SALOME_Exception)
241 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
242 SALOME::INTERNAL_ERROR);
243 SALOME_MED::medGeometryElement_array_var myseq =
244 new SALOME_MED::medGeometryElement_array;
247 int mySeqLength = _numberOfGeometricType;
248 myseq->length(mySeqLength);
249 for (int i = 0; i < mySeqLength; i++)
251 myseq[i] = _geometricType[i];
256 MESSAGE("Exception lors de la recherche des differents types");
257 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support Types",
258 SALOME::INTERNAL_ERROR);
260 return myseq._retn();
263 //=============================================================================
265 * CORBA: Number of different types of geometry elements
266 * existing in the support
268 //=============================================================================
269 CORBA::Long SMESH_MEDSupport_i::getNumberOfElements(SALOME_MED::
270 medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
273 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
274 SALOME::INTERNAL_ERROR);
275 return _numberOfGeometricType;
279 //=============================================================================
283 //=============================================================================
285 SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumber(
286 SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
288 Unexpect aCatch(SALOME_SalomeException);
290 THROW_SALOME_CORBA_EXCEPTION("No associated Support",
291 SALOME::INTERNAL_ERROR);
293 // A changer s'il ne s agit plus seulement de famille de noeuds
294 if (geomElement != SALOME_MED::MED_NONE)
295 THROW_SALOME_CORBA_EXCEPTION("Not implemented", SALOME::BAD_PARAM);
297 SALOME_TYPES::ListOfLong_var myseq = new SALOME_TYPES::ListOfLong;
300 myseq->length(_subMesh_i->GetNumberOfNodes(/*all=*/false));
302 if ( _subMesh->GetSubMeshDS() )
304 SMDS_NodeIteratorPtr it = _subMesh->GetSubMeshDS()->GetNodes();
307 myseq[i] = it->next()->GetID();
312 SCRUTE(myseq->length());
313 MESSAGE("End of SMESH_MEDSupport_i::getNumber");
314 return myseq._retn();
318 //=============================================================================
320 * CORBA: get Nodes from file
322 //=============================================================================
324 SALOME_TYPES::ListOfLong * SMESH_MEDSupport_i::getNumberFromFile(
325 SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
327 return getNumber(geomElement);
330 //=============================================================================
332 * CORBA: Global Nodes Index (optionnaly designed by the user)
333 * CORBA: ??????????????????????????????
335 //=============================================================================
337 SALOME_TYPES::ListOfLong *
338 SMESH_MEDSupport_i::getNumberIndex()throw(SALOME::SALOME_Exception)
340 MESSAGE("Not implemented for SMESH_i");
341 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
344 //=============================================================================
346 * CORBA: Array containing indexes for elements included in the support
348 //=============================================================================
350 CORBA::Long SMESH_MEDSupport_i::getNumberOfGaussPoint(SALOME_MED::
351 medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
353 MESSAGE("Not implemented for SMESH_i");
356 //=============================================================================
358 * Gives the number of types of elements included in the support
360 //=============================================================================
361 CORBA::Long SMESH_MEDSupport_i::getNumberOfTypes()
362 throw (SALOME::SALOME_Exception)
364 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
365 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
368 //=============================================================================
370 * Gives CORBA: Array containing the numbers of Gauss point of elements
371 * included in the support
373 //=============================================================================
374 SALOME_TYPES::ListOfLong* SMESH_MEDSupport_i::getNumbersOfGaussPoint()
375 throw (SALOME::SALOME_Exception)
377 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
378 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
381 //=============================================================================
383 * build the object which will contain all the boundary elements of the mesh.
385 //=============================================================================
386 void SMESH_MEDSupport_i::getBoundaryElements()
387 throw (SALOME::SALOME_Exception)
389 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
390 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
392 //=============================================================================
394 * Gives information on the support
396 //=============================================================================
397 SALOME_MED::SUPPORT::supportInfos * SMESH_MEDSupport_i::getSupportGlobal()
398 throw (SALOME::SALOME_Exception)
400 MESSAGE("!!! NOT YET IMPLEMENTED !!!!");
401 THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);