1 // Copyright (C) 2007-2008 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
22 //=============================================================================
23 // File : MEDMEM_Mesh_i.cxx
26 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Mesh_i.cxx
27 //=============================================================================
31 #include "utilities.h"
32 #include "Utils_CorbaException.hxx"
33 #include "Utils_ORB_INIT.hxx"
34 #include "Utils_SINGLETON.hxx"
36 #include "MEDMEM_convert.hxx"
37 #include "MEDMEM_Mesh_i.hxx"
38 #include "MEDMEM_Support_i.hxx"
39 #include "MEDMEM_Family_i.hxx"
40 #include "MEDMEM_Group_i.hxx"
41 #include "MEDMEM_FieldTemplate_i.hxx"
43 #include "MEDMEM_Mesh.hxx"
44 #include "MEDMEM_Family.hxx"
45 #include "MEDMEM_Group.hxx"
46 #include "MEDMEM_CellModel.hxx"
48 #include "SenderFactory.hxx"
49 #include "MultiCommException.hxx"
50 using namespace MEDMEM;
52 // Initialisation des variables statiques
53 map < int, ::MESH *> MESH_i::meshMap ;
54 int MESH_i::meshIndex = 0 ;
58 //=============================================================================
62 //=============================================================================
63 MESH_i::MESH_i(): _mesh(constructConstMesh()),
64 _corbaIndex(MESH_i::meshIndex++),
67 const char* LOC = "Default Constructor MESH_i";
69 MESH_i::meshMap[_corbaIndex]=_mesh;
72 //=============================================================================
76 //=============================================================================
80 //=============================================================================
84 //=============================================================================
85 MESH_i::MESH_i(::MESH * const m ) :_mesh(m),
86 _corbaIndex(MESH_i::meshIndex++),
89 const char* LOC = "Constructor MESH_i(::MESH * const m )";
91 MESH_i::meshMap[_corbaIndex]=_mesh;
96 //=============================================================================
100 //=============================================================================
101 //MESH_i::MESH_i(const MESH_i & m) :_mesh(m._mesh),
102 MESH_i::MESH_i( MESH_i & m) :_mesh(m._mesh),
103 _corbaIndex(MESH_i::meshIndex++),
106 const char* LOC = "Constructor MESH_i";
108 MESH_i::meshMap[_corbaIndex]=_mesh;
111 //=============================================================================
113 * Internal Method in order to have a const ptr
115 //=============================================================================
116 ::MESH * MESH_i::constructConstMesh() const
118 ::MESH * const ptrMesh =new ::MESH();
121 //=============================================================================
123 * CORBA: Accessor for Name
125 //=============================================================================
126 char * MESH_i::getName()
127 throw (SALOME::SALOME_Exception)
130 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
131 SALOME::INTERNAL_ERROR);
135 return CORBA::string_dup(_mesh->getName().c_str());
137 catch (MEDEXCEPTION &ex)
139 MESSAGE("Unable to acces the mesh name");
140 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
143 //=============================================================================
145 * CORBA: Accessor for corbaindex cuisine interne
147 //=============================================================================
148 CORBA::Long MESH_i::getCorbaIndex()
149 throw (SALOME::SALOME_Exception)
152 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
153 SALOME::INTERNAL_ERROR);
156 //=============================================================================
158 * CORBA: Accessor for Space Dimension
160 //=============================================================================
161 CORBA::Long MESH_i::getSpaceDimension()
162 throw (SALOME::SALOME_Exception)
165 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
166 SALOME::INTERNAL_ERROR);
169 return _mesh->getSpaceDimension();
171 catch (MEDEXCEPTION &ex)
173 MESSAGE("Unable to acces the space dimension ");
174 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
177 //=============================================================================
179 * CORBA: Accessor for Mesh Dimension
181 //=============================================================================
182 CORBA::Long MESH_i::getMeshDimension()
183 throw (SALOME::SALOME_Exception)
186 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
187 SALOME::INTERNAL_ERROR);
190 return _mesh->getMeshDimension();
192 catch (MEDEXCEPTION &ex)
194 MESSAGE("Unable to acces the mesh dimension ");
195 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
198 //=============================================================================
200 * CORBA: boolean indicating if mesh is a Grid
202 //=============================================================================
203 CORBA::Boolean MESH_i::getIsAGrid()
204 throw (SALOME::SALOME_Exception)
207 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
208 SALOME::INTERNAL_ERROR);
211 return _mesh->getIsAGrid();
213 catch (MEDEXCEPTION &ex)
215 MESSAGE("Unable to acces mesh flag isAGrid");
216 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
219 //=============================================================================
221 * CORBA: boolean indicating if connectivity exists
223 //=============================================================================
224 CORBA::Boolean MESH_i::existConnectivity
225 (SALOME_MED::medConnectivity connectivityType,
226 SALOME_MED::medEntityMesh entity)
227 throw (SALOME::SALOME_Exception)
230 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
231 SALOME::INTERNAL_ERROR);
234 return _mesh->existConnectivity(connectivityType,
235 convertIdlEntToMedEnt(entity)); }
236 catch (MEDEXCEPTION &ex)
238 MESSAGE("Unable to acces mesh flag existConnectivity");
239 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
243 //=============================================================================
245 * CORBA: Accessor for Coordinates System
247 //=============================================================================
248 char * MESH_i::getCoordinatesSystem()
249 throw (SALOME::SALOME_Exception)
252 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
253 SALOME::INTERNAL_ERROR);
257 return CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
259 catch (MEDEXCEPTION &ex)
261 MESSAGE("Unable to acces the type of CoordinatesSystem");
262 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
265 //=============================================================================
267 * CORBA: Accessor for a specific coordinate
269 //=============================================================================
270 CORBA::Double MESH_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis)
271 throw (SALOME::SALOME_Exception)
274 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
275 SALOME::INTERNAL_ERROR);
278 return _mesh->getCoordinate(Number,Axis);
280 catch (MEDEXCEPTION &ex)
282 MESSAGE("Unable to acces this coordinate");
283 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
286 //=============================================================================
288 * CORBA: Accessor for Coordinates
290 //=============================================================================
291 SALOME_MED::double_array * MESH_i::getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
292 throw (SALOME::SALOME_Exception)
295 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
296 SALOME::INTERNAL_ERROR);
297 SALOME_MED::double_array_var myseq = new SALOME_MED::double_array;
300 int spaceDimension=_mesh->getSpaceDimension();
301 int nbNodes=_mesh->getNumberOfNodes();
302 const double * coordinates =_mesh->getCoordinates(
303 convertIdlModeToMedMode(typeSwitch));
305 myseq->length(nbNodes*spaceDimension);
306 for (int i=0; i<nbNodes*spaceDimension; i++)
308 myseq[i]=coordinates[i];
311 catch (MEDEXCEPTION &ex)
313 MESSAGE("Unable to acces the coordinates");
314 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
316 return myseq._retn();
318 //=============================================================================
320 * CORBA: 2nd Accessor for Coordinates
322 //=============================================================================
323 SALOME::SenderDouble_ptr MESH_i::getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
324 throw (SALOME::SALOME_Exception)
327 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
328 SALOME::INTERNAL_ERROR);
329 SALOME::SenderDouble_ptr ret;
332 int spaceDimension=_mesh->getSpaceDimension();
333 int nbNodes=_mesh->getNumberOfNodes();
334 const double * coordinates =_mesh->getCoordinates(convertIdlModeToMedMode(typeSwitch));
335 ret=SenderFactory::buildSender(*this,coordinates,nbNodes*spaceDimension);
337 catch (MEDEXCEPTION &ex)
339 MESSAGE("Unable to acces the coordinates");
340 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
342 catch(MultiCommException &ex2)
343 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
346 //=============================================================================
348 * CORBA: Accessor for Coordinates Names
350 //=============================================================================
351 SALOME_MED::string_array * MESH_i::getCoordinatesNames()
352 throw (SALOME::SALOME_Exception)
355 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
356 SALOME::INTERNAL_ERROR);
357 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
360 int spaceDimension=_mesh->getSpaceDimension();
361 const string * coordinatesName =_mesh->getCoordinatesNames();
362 myseq->length(spaceDimension);
363 for (int i=0; i<spaceDimension; i++)
365 myseq[i]=CORBA::string_dup(coordinatesName[i].c_str());
368 catch (MEDEXCEPTION &ex)
370 MESSAGE("Unable to acces the coordinates names");
371 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
373 return myseq._retn();
376 //=============================================================================
378 * CORBA: Accessor for Coordinates Units
380 //=============================================================================
381 SALOME_MED::string_array * MESH_i::getCoordinatesUnits()
382 throw (SALOME::SALOME_Exception)
385 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
386 SALOME::INTERNAL_ERROR);
387 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
390 int spaceDimension=_mesh->getSpaceDimension();
391 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
392 myseq->length(spaceDimension);
393 for (int i=0; i<spaceDimension; i++)
395 myseq[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
398 catch (MEDEXCEPTION &ex)
400 MESSAGE("Unable to acces the coordinates units");
401 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
403 return myseq._retn();
405 //=============================================================================
407 * CORBA: Accessor for Number of Nodes
409 //=============================================================================
410 CORBA::Long MESH_i::getNumberOfNodes()
411 throw (SALOME::SALOME_Exception)
414 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
415 SALOME::INTERNAL_ERROR);
418 return _mesh->getNumberOfNodes();
420 catch (MEDEXCEPTION &ex)
422 MESSAGE("Unable to acces number of nodes");
423 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
426 //=============================================================================
428 * CORBA: Accessor for number of Types
430 //=============================================================================
431 CORBA::Long MESH_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
432 throw (SALOME::SALOME_Exception)
435 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
436 SALOME::INTERNAL_ERROR);
439 return _mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
441 catch (MEDEXCEPTION &ex)
443 MESSAGE("Unable to acces number of differents types");
444 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
447 //=============================================================================
449 * CORBA: Accessor for existing geometry element types
451 //=============================================================================
452 SALOME_MED::medGeometryElement MESH_i::getElementType (SALOME_MED::medEntityMesh entity,
454 throw (SALOME::SALOME_Exception)
457 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
458 SALOME::INTERNAL_ERROR);
461 return _mesh->getElementType(convertIdlEntToMedEnt(entity),number);
463 catch (MEDEXCEPTION &ex)
465 MESSAGE("Unable to acces number of differents element types");
466 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
470 //=============================================================================
472 * CORBA: Accessor for existing geometry element types
473 * Not implemented for MED_ALL_ENTITIES
475 //=============================================================================
476 SALOME_MED::medGeometryElement_array * MESH_i::getTypes (SALOME_MED::medEntityMesh entity)
477 throw (SALOME::SALOME_Exception)
480 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
481 SALOME::INTERNAL_ERROR);
482 if (entity ==SALOME_MED::MED_ALL_ENTITIES)
483 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\
485 SALOME_MED::medGeometryElement_array_var myseq =
486 new SALOME_MED::medGeometryElement_array;
489 int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
490 const medGeometryElement * elemts =_mesh->getTypes(
491 convertIdlEntToMedEnt(entity));
492 myseq->length(nbTypes);
493 for (int i=0; i<nbTypes; i++)
495 myseq[i]=convertMedEltToIdlElt(elemts[i]);
498 catch (MEDEXCEPTION &ex)
500 MESSAGE("Unable to acces coordinates");
501 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
503 return myseq._retn();
505 //=============================================================================
507 * CORBA: Returns number of elements of type medGeometryElement
508 * Not implemented for MED_ALL_ELEMENTS
509 * implemented for MED_ALL_ENTITIES
511 //=============================================================================
512 CORBA::Long MESH_i::getNumberOfElements(SALOME_MED::medEntityMesh entity,
513 SALOME_MED::medGeometryElement geomElement)
514 throw (SALOME::SALOME_Exception)
517 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
518 SALOME::INTERNAL_ERROR);
519 if (verifieParam(entity,geomElement)==false)
520 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
525 // if ( geomElement == SALOME_MED::MED_POLYGON ||
526 // geomElement == SALOME_MED::MED_POLYHEDRA )
527 // return _mesh->getNumberOfElementsWithPoly(convertIdlEntToMedEnt(entity),
528 // convertIdlEltToMedElt(geomElement));
530 return _mesh->getNumberOfElements(convertIdlEntToMedEnt(entity),
531 convertIdlEltToMedElt(geomElement));
533 catch (MEDEXCEPTION &ex)
535 MESSAGE("Unable to acces number of elements");
536 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
539 //=============================================================================
541 * CORBA: Accessor for connectivities
543 //=============================================================================
544 SALOME_MED::long_array * MESH_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
545 SALOME_MED::medConnectivity mode,
546 SALOME_MED::medEntityMesh entity,
547 SALOME_MED::medGeometryElement geomElement)
548 throw (SALOME::SALOME_Exception)
551 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
552 SALOME::INTERNAL_ERROR);
553 if (verifieParam(entity,geomElement)==false)
554 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
556 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
560 int elt1 = _mesh->getNumberOfElements(
561 convertIdlEntToMedEnt(entity),
562 convertIdlEltToMedElt(geomElement));
564 if ( mode == SALOME_MED::MED_DESCENDING)
566 MESSAGE("MED_DESCENDING");
567 int elt2 =(_mesh->getCellsTypes(MED_CELL))->getNumberOfConstituents(1);
568 //int elt2 =(_mesh->getTypes(convertIdlEltToMedElt(geomElement)))->getNumberOfConstituents(1);
569 nbelements= elt2 * elt1;
574 MESSAGE("MED_NODAL");
575 // const int * tab=_mesh->getConnectivityIndex(
576 // convertIdlConnToMedConn(mode),
577 // convertIdlEntToMedEnt(entity));
578 nbelements = _mesh->getConnectivityLength
579 (convertIdlModeToMedMode(typeSwitch),
580 convertIdlConnToMedConn(mode),
581 convertIdlEntToMedEnt(entity),
582 convertIdlEltToMedElt(geomElement));
583 //nbelements = elt1*(convertIdlEltToMedElt(geomElement)%100);
584 // nbelements = tab[elt1 ] - 1 ;
589 myseq->length(nbelements);
590 const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
591 convertIdlConnToMedConn(mode),
592 convertIdlEntToMedEnt(entity),
593 convertIdlEltToMedElt(geomElement));
594 for (int i=0;i<nbelements;i++)
599 catch (MEDEXCEPTION &ex)
601 MESSAGE("Unable to acces connectivities");
602 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
604 return myseq._retn();
606 //=============================================================================
608 * CORBA: 2nd Accessor for connectivities
610 //=============================================================================
611 SALOME::SenderInt_ptr MESH_i::getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
612 SALOME_MED::medConnectivity mode,
613 SALOME_MED::medEntityMesh entity,
614 SALOME_MED::medGeometryElement geomElement)
615 throw (SALOME::SALOME_Exception)
618 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
619 SALOME::INTERNAL_ERROR);
620 if (verifieParam(entity,geomElement)==false)
621 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
623 SALOME::SenderInt_ptr ret;
626 int nbelements=_mesh->getConnectivityLength(convertIdlModeToMedMode(typeSwitch),
627 convertIdlConnToMedConn(mode),
628 convertIdlEntToMedEnt(entity),
629 convertIdlEltToMedElt(geomElement));
630 const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
631 convertIdlConnToMedConn(mode),
632 convertIdlEntToMedEnt(entity),
633 convertIdlEltToMedElt(geomElement));
634 ret=SenderFactory::buildSender(*this,numbers,nbelements);
636 catch (MEDEXCEPTION &ex)
638 MESSAGE("Unable to acces connectivities");
639 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
641 catch(MultiCommException &ex2)
642 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
646 //=======================================================================
647 //function : getSenderForPolygonsConnectivity
649 //=======================================================================
651 SALOME::SenderInt_ptr MESH_i::getSenderForPolygonsConnectivity(SALOME_MED::medConnectivity mode,
652 SALOME_MED::medEntityMesh entity)
653 throw (SALOME::SALOME_Exception)
656 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
657 SALOME::INTERNAL_ERROR);
658 if (verifieParam(entity,SALOME_MED::MED_POLYGON)==false)
659 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
661 SALOME::SenderInt_ptr ret;
664 int nbelements = _mesh->getPolygonsConnectivityLength(convertIdlConnToMedConn(mode),
665 convertIdlEntToMedEnt(entity));
666 const int * numbers=_mesh->getPolygonsConnectivity (convertIdlConnToMedConn(mode),
667 convertIdlEntToMedEnt(entity));
668 ret=SenderFactory::buildSender(*this,numbers,nbelements);
670 catch (MEDEXCEPTION &ex)
672 MESSAGE("Unable to acces connectivities");
673 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
675 catch(MultiCommException &ex2)
676 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
680 //=======================================================================
681 //function : getSenderForPolygonsConnectivityIndex
683 //=======================================================================
685 SALOME::SenderInt_ptr MESH_i::getSenderForPolygonsConnectivityIndex(SALOME_MED::medConnectivity mode,
686 SALOME_MED::medEntityMesh entity)
687 throw (SALOME::SALOME_Exception)
690 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
691 SALOME::INTERNAL_ERROR);
692 if (verifieParam(entity,SALOME_MED::MED_POLYGON)==false)
693 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
695 SALOME::SenderInt_ptr ret;
698 int nbelements = _mesh->getNumberOfPolygons(entity) + 1;
699 const int * numbers=_mesh->getPolygonsConnectivityIndex (convertIdlConnToMedConn(mode),
700 convertIdlEntToMedEnt(entity));
701 ret=SenderFactory::buildSender(*this,numbers,nbelements);
703 catch (MEDEXCEPTION &ex)
705 MESSAGE("Unable to acces connectivities");
706 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
708 catch(MultiCommException &ex2)
709 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
713 //=======================================================================
714 //function : getSenderForPolyhedronConnectivity
716 //=======================================================================
718 SALOME::SenderInt_ptr MESH_i::getSenderForPolyhedronConnectivity(SALOME_MED::medConnectivity mode)
719 throw (SALOME::SALOME_Exception)
722 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
723 SALOME::INTERNAL_ERROR);
724 SALOME::SenderInt_ptr ret;
727 int nbelements = _mesh->getPolyhedronConnectivityLength(convertIdlConnToMedConn(mode));
728 const int * numbers=_mesh->getPolyhedronConnectivity( convertIdlConnToMedConn(mode) );
729 ret=SenderFactory::buildSender(*this,numbers,nbelements);
731 catch (MEDEXCEPTION &ex)
733 MESSAGE("Unable to acces connectivities");
734 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
736 catch(MultiCommException &ex2)
737 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
741 //=======================================================================
742 //function : getSenderForPolyhedronIndex
744 //=======================================================================
746 SALOME::SenderInt_ptr MESH_i::getSenderForPolyhedronIndex(SALOME_MED::medConnectivity mode)
747 throw (SALOME::SALOME_Exception)
750 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
751 SALOME::INTERNAL_ERROR);
752 SALOME::SenderInt_ptr ret;
755 int nbelements = _mesh->getNumberOfPolyhedron() + 1;
756 const int * numbers = _mesh->getPolyhedronIndex( convertIdlConnToMedConn( mode ) );
757 ret=SenderFactory::buildSender(*this,numbers,nbelements);
759 catch (MEDEXCEPTION &ex)
761 MESSAGE("Unable to acces connectivities");
762 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
764 catch(MultiCommException &ex2)
765 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
769 //=======================================================================
770 //function : getSenderForPolyhedronFacesIndex
772 //=======================================================================
774 SALOME::SenderInt_ptr MESH_i::getSenderForPolyhedronFacesIndex()
775 throw (SALOME::SALOME_Exception)
778 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
779 SALOME::INTERNAL_ERROR);
780 SALOME::SenderInt_ptr ret;
783 int nbelements = _mesh->getNumberOfPolyhedronFaces() + 1;
784 const int * numbers=_mesh->getPolyhedronFacesIndex();
785 ret=SenderFactory::buildSender(*this,numbers,nbelements);
787 catch (MEDEXCEPTION &ex)
789 MESSAGE("Unable to acces connectivities");
790 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
792 catch(MultiCommException &ex2)
793 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
797 //=============================================================================
799 * CORBA: Accessor for connectivities
801 //=============================================================================
802 SALOME_MED::long_array* MESH_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
803 SALOME_MED::medEntityMesh entity)
804 throw (SALOME::SALOME_Exception)
807 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
808 SALOME::INTERNAL_ERROR);
809 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
812 int nbelements = _mesh->getNumberOfElements(
813 convertIdlEntToMedEnt(entity),
814 MED_ALL_ELEMENTS) + 1;
815 myseq->length(nbelements);
816 const int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode),
817 convertIdlEntToMedEnt(entity));
818 for (int i=0;i<nbelements;i++)
823 catch (MEDEXCEPTION &ex)
825 MESSAGE("Unable to acces connectivities index");
826 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
828 return myseq._retn();
830 //=============================================================================
832 * CORBA: Accessor for connectivities
834 //=============================================================================
835 SALOME_MED::long_array* MESH_i::getGlobalNumberingIndex( SALOME_MED::medEntityMesh entity)
836 throw (SALOME::SALOME_Exception)
839 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
840 SALOME::INTERNAL_ERROR);
841 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
844 int nbelements = _mesh->getNumberOfTypes( convertIdlEntToMedEnt(entity)) + 1;
845 myseq->length(nbelements);
846 const int * numbers=_mesh->getGlobalNumberingIndex( convertIdlEntToMedEnt(entity));
847 for (int i=0;i<nbelements;i++)
852 catch (MEDEXCEPTION &ex)
854 MESSAGE("Unable to acces global index");
855 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
857 return myseq._retn();
860 //=============================================================================
862 * CORBA: get global element number in connectivity array
863 * not implemented for MED_NODE and MED_ALL_ENTITIES,
864 * MED_NONE and MED_ALL_ELEMENTS.
866 //=============================================================================
867 CORBA::Long MESH_i::getElementNumber(SALOME_MED::medConnectivity mode,
868 SALOME_MED::medEntityMesh entity,
869 SALOME_MED::medGeometryElement type,
870 const SALOME_MED::long_array& connectivity)
871 throw (SALOME::SALOME_Exception)
874 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR);
875 int numberOfValue = connectivity.length() ;
876 int * myConnectivity = new int[numberOfValue] ;
877 for (int i=0; i<numberOfValue; i++)
878 myConnectivity[i]=connectivity[i] ;
882 result = _mesh->getElementNumber(convertIdlConnToMedConn(mode),
883 convertIdlEntToMedEnt(entity),
884 convertIdlEltToMedElt(type),
887 catch (MEDEXCEPTION &ex) {
888 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
892 //=============================================================================
894 * CORBA: Accessor for Ascendant connectivities
895 * not implemented for MED_ALL_ENTITIES and MED_MAILLE
897 //=============================================================================
898 SALOME_MED::long_array* MESH_i::getReverseConnectivity(SALOME_MED::medConnectivity mode)
899 throw (SALOME::SALOME_Exception)
902 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
903 SALOME::INTERNAL_ERROR);
904 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
907 int nbelements=_mesh->getReverseConnectivityLength(convertIdlConnToMedConn(mode));
909 myseq->length(nbelements);
910 const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
911 for (int i=0;i<nbelements;i++)
916 catch (MEDEXCEPTION &ex)
918 MESSAGE("Unable to acces reverse connectivities");
919 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
921 return myseq._retn();
923 //=============================================================================
925 * CORBA: Accessor for connectivities
927 //=============================================================================
928 SALOME_MED::long_array* MESH_i::getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
929 throw (SALOME::SALOME_Exception)
932 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
933 SALOME::INTERNAL_ERROR);
934 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
937 int nbelements=_mesh->getReverseConnectivityIndexLength(convertIdlConnToMedConn(mode));
938 myseq->length(nbelements);
939 const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
940 for (int i=0;i<nbelements;i++)
945 catch (MEDEXCEPTION &ex)
947 MESSAGE("Unable to acces reverse connectivities index");
948 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
950 return myseq._retn();
952 //=============================================================================
954 * CORBA: Returns number of families within the mesh
956 //=============================================================================
957 CORBA::Long MESH_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
958 throw (SALOME::SALOME_Exception)
961 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
962 SALOME::INTERNAL_ERROR);
965 return _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
967 catch (MEDEXCEPTION &ex)
969 MESSAGE("Unable to acces number of families of the mesh");
970 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
973 //=============================================================================
975 * CORBA: Returns number of groups within the mesh
977 //=============================================================================
978 CORBA::Long MESH_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
979 throw (SALOME::SALOME_Exception)
982 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
983 SALOME::INTERNAL_ERROR);
986 return _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
988 catch (MEDEXCEPTION &ex)
990 MESSAGE("Unable to acces number of groups of the mesh");
991 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
994 //=============================================================================
996 * CORBA: Returns references for families within the mesh
998 //=============================================================================
999 SALOME_MED::Family_array * MESH_i::getFamilies(SALOME_MED::medEntityMesh entity)
1000 throw (SALOME::SALOME_Exception)
1003 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1004 SALOME::INTERNAL_ERROR);
1005 SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
1008 int nbfam= _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
1009 myseq->length(nbfam);
1010 vector<FAMILY*> fam(nbfam);
1011 fam = _mesh->getFamilies(convertIdlEntToMedEnt(entity));
1012 for (int i=0;i<nbfam;i++)
1014 FAMILY_i * f1=new FAMILY_i(fam[i]);
1015 myseq[i] = f1->_this();
1018 catch (MEDEXCEPTION &ex)
1020 MESSAGE("Unable to acces families of the mesh");
1021 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1023 return myseq._retn();
1025 //=============================================================================
1027 * CORBA: Returns Coordinates global informations
1029 //=============================================================================
1030 SALOME_MED::MESH::coordinateInfos * MESH_i::getCoordGlobal()
1031 throw (SALOME::SALOME_Exception)
1034 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1035 SALOME::INTERNAL_ERROR);
1036 SALOME_MED::MESH::coordinateInfos_var all = new SALOME_MED::MESH::coordinateInfos;
1039 all->coordSystem = CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
1041 int spaceDimension=_mesh->getSpaceDimension();
1042 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
1043 const string * coordinatesName =_mesh->getCoordinatesNames();
1045 all->coordUnits.length(spaceDimension);
1046 all->coordNames.length(spaceDimension);
1047 for (int i=0; i<spaceDimension; i++)
1049 all->coordUnits[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
1050 all->coordNames[i]=CORBA::string_dup(coordinatesName[i].c_str());
1053 catch (MEDEXCEPTION &ex)
1055 MESSAGE("Unable to acces coordinate information ");
1056 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1060 //=============================================================================
1062 * CORBA: Returns connectivity global informations
1064 //=============================================================================
1065 SALOME_MED::MESH::connectivityInfos * MESH_i::getConnectGlobal (SALOME_MED::medEntityMesh entity)
1066 throw (SALOME::SALOME_Exception)
1069 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1070 SALOME::INTERNAL_ERROR);
1071 SALOME_MED::MESH::connectivityInfos_var all=new SALOME_MED::MESH::connectivityInfos;
1074 MED_EN::medEntityMesh anEntity = convertIdlEntToMedEnt(entity);
1075 all->numberOfNodes = _mesh->getNumberOfNodes();
1077 int nbTypes=_mesh->getNumberOfTypesWithPoly(anEntity);
1078 medGeometryElement * types =_mesh->getTypesWithPoly(anEntity);
1079 all->meshTypes.length(nbTypes);
1080 all->numberOfElements.length(nbTypes);
1081 all->nodalConnectivityLength.length(nbTypes);
1082 all->entityDimension=_mesh->getConnectivityptr()->getEntityDimension();
1083 for (int i=0; i<nbTypes; i++)
1085 all->meshTypes[i]=convertMedEltToIdlElt(types[i]);
1086 all->numberOfElements[i]=_mesh->getNumberOfElementsWithPoly(anEntity,types[i]);
1089 case MED_EN::MED_POLYGON:
1090 all->nodalConnectivityLength[i]=
1091 _mesh->getPolygonsConnectivityLength(MED_EN::MED_NODAL,anEntity);
1093 case MED_EN::MED_POLYHEDRA:
1094 all->nodalConnectivityLength[i]=
1095 _mesh->getPolyhedronConnectivityLength(MED_EN::MED_NODAL);
1098 all->nodalConnectivityLength[i]=
1099 _mesh->getConnectivityLength(MED_EN::MED_FULL_INTERLACE,MED_EN::MED_NODAL,
1105 catch (MEDEXCEPTION &ex)
1107 MESSAGE("Unable to acces connectivities informations");
1108 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1113 //=============================================================================
1115 * CORBA: Returns references for family i within the mesh
1117 //=============================================================================
1118 SALOME_MED::FAMILY_ptr MESH_i::getFamily(SALOME_MED::medEntityMesh entity,
1120 throw (SALOME::SALOME_Exception)
1123 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1124 SALOME::INTERNAL_ERROR);
1127 const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
1128 FAMILY_i * f1=new FAMILY_i(fam);
1131 catch (MEDEXCEPTION &ex)
1133 MESSAGE("Unable to acces specified family of the mesh");
1134 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1138 //=============================================================================
1140 * CORBA: Returns Mesh global informations
1142 //=============================================================================
1143 SALOME_MED::MESH::meshInfos * MESH_i::getMeshGlobal()
1144 throw (SALOME::SALOME_Exception)
1147 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1148 SALOME::INTERNAL_ERROR);
1149 SALOME_MED::MESH::meshInfos_var all = new SALOME_MED::MESH::meshInfos;
1152 all->name = CORBA::string_dup(_mesh->getName().c_str());
1153 all->spaceDimension = _mesh->getSpaceDimension();
1154 all->meshDimension = _mesh->getMeshDimension();
1155 all->numberOfNodes = _mesh->getNumberOfNodes();
1156 all->isAGrid = _mesh->getIsAGrid();
1158 int nbFam= _mesh->getNumberOfFamilies(MED_NODE);
1159 all->famNode.length(nbFam);
1160 vector<FAMILY*> vNode (nbFam);
1161 vNode = _mesh->getFamilies(MED_NODE);
1162 for (int i=0;i<nbFam;i++)
1164 FAMILY_i * f1=new FAMILY_i(vNode[i]);
1165 all->famNode[i] = f1->_this();
1168 nbFam = _mesh->getNumberOfFamilies(MED_EDGE);
1169 all->famEdge.length(nbFam);
1170 vector<FAMILY*> vEdge (nbFam);
1171 vEdge = _mesh->getFamilies(MED_EDGE);
1172 for (int i=0;i<nbFam;i++)
1173 for (int i=0;i<nbFam;i++)
1175 FAMILY_i * f1=new FAMILY_i(vEdge[i]);
1176 all->famEdge[i] = f1->_this();
1179 nbFam = _mesh->getNumberOfFamilies(MED_FACE);
1180 all->famFace.length(nbFam);
1181 vector<FAMILY*> vFace (nbFam);
1182 vFace = _mesh->getFamilies(MED_FACE);
1183 for (int i=0;i<nbFam;i++)
1185 FAMILY_i * f1=new FAMILY_i(vFace[i]);
1186 all->famFace[i] = f1->_this();
1189 nbFam = _mesh->getNumberOfFamilies(MED_CELL);
1190 all->famCell.length(nbFam);
1191 vector<FAMILY*> vCell (nbFam);
1192 vCell = _mesh->getFamilies(MED_CELL);
1193 for (int i=0;i<nbFam;i++)
1195 FAMILY_i * f1=new FAMILY_i(vCell[i]);
1196 all->famCell[i] = f1->_this();
1199 int nbGroup = _mesh->getNumberOfGroups(MED_NODE);
1200 all->groupNode.length(nbGroup);
1201 vector<GROUP*> gNode (nbGroup);
1202 gNode = _mesh->getGroups(MED_NODE);
1203 for (int i=0;i<nbGroup;i++)
1205 GROUP_i * f1=new GROUP_i(gNode[i]);
1206 all->groupNode[i] = f1->_this();
1209 nbGroup = _mesh->getNumberOfGroups(MED_EDGE);
1210 all->groupEdge.length(nbGroup);
1211 vector<GROUP*> gEdge (nbGroup);
1212 gEdge = _mesh->getGroups(MED_EDGE);
1213 for (int i=0;i<nbGroup;i++)
1215 GROUP_i * f1=new GROUP_i(gEdge[i]);
1216 all->groupEdge[i] = f1->_this();
1218 nbGroup = _mesh->getNumberOfGroups(MED_FACE);
1219 all->groupFace.length(nbGroup);
1220 vector<GROUP*> gFace (nbGroup);
1221 gFace = _mesh->getGroups(MED_FACE);
1222 for (int i=0;i<nbGroup;i++)
1224 GROUP_i * f1=new GROUP_i(gFace[i]);
1225 all->groupFace[i] = f1->_this();
1228 nbGroup = _mesh->getNumberOfGroups(MED_CELL);
1229 all->groupCell.length(nbGroup);
1230 vector<GROUP*> gCell (nbGroup);
1231 gCell = _mesh->getGroups(MED_CELL);
1232 for (int i=0;i<nbGroup;i++)
1234 GROUP_i * f1=new GROUP_i(gCell[i]);
1235 all->groupCell[i] = f1->_this();
1239 catch (MEDEXCEPTION &ex)
1241 MESSAGE("Unable to acces mesh");
1242 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1246 //=============================================================================
1248 * CORBA: Returns references for groups within the mesh
1250 //=============================================================================
1251 SALOME_MED::Group_array * MESH_i::getGroups(SALOME_MED::medEntityMesh entity)
1252 throw (SALOME::SALOME_Exception)
1255 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1256 SALOME::INTERNAL_ERROR);
1257 SALOME_MED::Group_array_var myseq = new SALOME_MED::Group_array;
1260 int nbgroups = _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
1261 myseq->length(nbgroups);
1262 vector<GROUP*> groups(nbgroups);
1263 groups = _mesh->getGroups(convertIdlEntToMedEnt(entity));
1264 for (int i=0;i<nbgroups;i++)
1266 GROUP_i * f1=new GROUP_i(groups[i]);
1267 myseq[i] = f1->_this();
1270 catch (MEDEXCEPTION &ex)
1272 MESSAGE("Unable to acces number of groups of the mesh");
1273 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1275 return myseq._retn();
1277 //=============================================================================
1279 * CORBA: Returns references for group i within the mesh
1281 //=============================================================================
1282 SALOME_MED::GROUP_ptr MESH_i::getGroup(SALOME_MED::medEntityMesh entity,
1284 throw (SALOME::SALOME_Exception)
1287 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1288 SALOME::INTERNAL_ERROR);
1291 const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
1292 GROUP_i * f1=new GROUP_i(grou);
1295 catch (MEDEXCEPTION &ex)
1297 MESSAGE("Unable to acces specified group of the mesh");
1298 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1301 //=============================================================================
1305 //=============================================================================
1306 SALOME_MED::SUPPORT_ptr MESH_i::getBoundaryElements(SALOME_MED::medEntityMesh entity)
1307 throw (SALOME::SALOME_Exception)
1310 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1311 SALOME::INTERNAL_ERROR);
1314 SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity));
1315 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1316 return mySupportI->_this();
1318 catch (MEDEXCEPTION &ex)
1320 MESSAGE("Unable to get the volume ");
1321 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1325 //=============================================================================
1329 //=============================================================================
1330 SALOME_MED::SUPPORT_ptr MESH_i::getSupportOnAll(SALOME_MED::medEntityMesh entity)
1331 throw (SALOME::SALOME_Exception)
1334 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1335 SALOME::INTERNAL_ERROR);
1338 SUPPORT * myNewSupport = _mesh->getSupportOnAll(convertIdlEntToMedEnt(entity));
1339 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1340 return mySupportI->_this();
1342 catch (MEDEXCEPTION &ex)
1344 MESSAGE("Unable to get the support ");
1345 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1348 //=============================================================================
1352 //=============================================================================
1353 SALOME_MED::FIELD_ptr MESH_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
1354 throw (SALOME::SALOME_Exception)
1357 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1358 SALOME::INTERNAL_ERROR); try
1360 int sup = mySupport->getCorbaIndex();
1361 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1362 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1363 ::FIELD<double>*f=_mesh->getVolume( myCppSupport);
1364 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
1365 return medf->_this();
1367 catch (MEDEXCEPTION &ex)
1369 MESSAGE("Unable to get the volume ");
1370 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1373 //=============================================================================
1377 //=============================================================================
1378 SALOME_MED::SUPPORT_ptr MESH_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D)
1379 throw (SALOME::SALOME_Exception)
1382 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1383 SALOME::INTERNAL_ERROR);
1386 int sup = mySupport3D->getCorbaIndex();
1387 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1388 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1389 SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport);
1390 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1391 return mySupportI->_this() ;
1393 catch (MEDEXCEPTION &ex)
1395 MESSAGE("Unable to get the volume ");
1396 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1399 //=============================================================================
1403 //=============================================================================
1404 SALOME_MED::FIELD_ptr MESH_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
1405 throw (SALOME::SALOME_Exception)
1408 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1409 SALOME::INTERNAL_ERROR);
1412 int sup = mySupport->getCorbaIndex();
1413 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1414 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1415 ::FIELD<double>*f=_mesh->getArea( myCppSupport);
1416 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
1417 return medf->_this();
1419 catch (MEDEXCEPTION &ex)
1421 MESSAGE("Unable to get the area ");
1422 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1425 //=============================================================================
1429 //=============================================================================
1430 SALOME_MED::FIELD_ptr MESH_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
1431 throw (SALOME::SALOME_Exception)
1434 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1435 SALOME::INTERNAL_ERROR);
1438 int sup = mySupport->getCorbaIndex();
1439 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1440 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1441 ::FIELD<double>*f=_mesh->getLength( myCppSupport);
1442 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
1443 return medf->_this();
1445 catch (MEDEXCEPTION &ex)
1447 MESSAGE("Unable to get the length ");
1448 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1451 //=============================================================================
1455 //=============================================================================
1456 SALOME_MED::FIELD_ptr MESH_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
1457 throw (SALOME::SALOME_Exception)
1460 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1461 SALOME::INTERNAL_ERROR);
1464 int sup = mySupport->getCorbaIndex();
1465 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1466 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1467 ::FIELD<double>*f=_mesh->getNormal( myCppSupport);
1468 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
1469 return medf->_this();
1471 catch (MEDEXCEPTION &ex)
1473 MESSAGE("Unable to get the normal ");
1474 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1477 //=============================================================================
1481 //=============================================================================
1482 SALOME_MED::FIELD_ptr MESH_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
1483 throw (SALOME::SALOME_Exception)
1486 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1487 SALOME::INTERNAL_ERROR);
1490 int sup = mySupport->getCorbaIndex();
1491 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1492 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1493 ::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
1494 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
1495 return medf->_this();
1497 catch (MEDEXCEPTION &ex)
1499 MESSAGE("Unable to get the barycenter ");
1500 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1503 //=============================================================================
1507 //=============================================================================
1508 SALOME_MED::FIELD_ptr MESH_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
1509 throw (SALOME::SALOME_Exception)
1512 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1513 SALOME::INTERNAL_ERROR);
1514 MESSAGE("Not Implemented");
1515 return SALOME_MED::FIELD::_nil();
1517 //=============================================================================
1519 * CORBA: add the Mesh in the StudyManager
1521 //=============================================================================
1522 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor )
1523 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1525 const char* LOC = "MED_Mesh_i::addInStudy";
1527 if ( _meshId != "" )
1529 MESSAGE("Mesh already in Study");
1530 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1534 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1535 SALOMEDS::GenericAttribute_var anAttr;
1536 SALOMEDS::AttributeName_var aName;
1537 SALOMEDS::AttributeIOR_var aIOR;
1539 // Find SComponent labelled 'MED'
1540 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1541 myBuilder->NewCommand();
1542 if ( CORBA::is_nil(medfather) )
1543 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1545 // Create SObject labelled 'MESH' if it doesn't already exit
1546 // SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1547 // if ( CORBA::is_nil(medmeshfather) )
1549 // MESSAGE("Add Object MEDMESH");
1550 // medmeshfather = myBuilder->NewObject(medfather);
1551 // //medmeshfather.Name = "MEDMESH" ;
1552 // anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1553 // aName = SALOMEDS::AttributeName::_narrow(anAttr);
1554 // aName->SetValue("MEDMESH");
1558 string aPath = "/Med/MEDMESH";
1559 SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath( aPath.c_str() );
1560 if ( CORBA::is_nil(medmeshfather) )
1562 MESSAGE("Add Object MEDMESH");
1564 myBuilder->AddDirectory( aPath.c_str() );
1565 medmeshfather = myStudy->FindObjectByPath( aPath.c_str() );
1568 aPath += "/" + _mesh->getName();
1569 SALOMEDS::SObject_var meshSO = myStudy->FindObjectByPath( aPath.c_str());
1570 bool alreadyPublished = ! CORBA::is_nil( meshSO );
1571 if ( !alreadyPublished ) {
1572 MESSAGE("Add a mesh Object under MED/MEDMESH");
1573 meshSO = myBuilder->NewObject(medmeshfather);
1575 anAttr = myBuilder->FindOrCreateAttribute(meshSO, "AttributeName");
1576 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1577 aName->SetValue(_mesh->getName().c_str());
1580 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1581 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1582 CORBA::ORB_var &orb = init(0,0);
1583 string iorStr = orb->object_to_string(myIor);
1584 anAttr = myBuilder->FindOrCreateAttribute(meshSO, "AttributeIOR");
1585 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1586 aIOR->SetValue(iorStr.c_str());
1587 _meshId = meshSO->GetID();
1588 myBuilder->CommitCommand();
1590 // register the Corba pointer: increase the referrence count
1591 MESSAGE("Registering of the Corba Mesh pointer");
1596 //=============================================================================
1598 * CORBA: add the Mesh in the StudyManager
1600 //=============================================================================
1601 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor,const string & fileName )
1602 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1604 const char* LOC = "MED_Mesh_i::addInStudy";
1606 if ( _meshId != "" )
1608 MESSAGE("Mesh already in Study");
1609 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1613 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1614 SALOMEDS::GenericAttribute_var anAttr;
1615 SALOMEDS::AttributeName_var aName;
1616 SALOMEDS::AttributeIOR_var aIOR;
1617 SALOMEDS::AttributeComment_var aComment;
1619 // Find SComponent labelled 'Med'
1620 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1621 if ( CORBA::is_nil(medfather) )
1622 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1624 // Create SObject labelled 'MESH' if it doesn't already exit
1625 SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1626 if ( CORBA::is_nil(medmeshfather) )
1628 MESSAGE("Add Object MEDMESH");
1629 medmeshfather = myBuilder->NewObject(medfather);
1630 //medmeshfather.Name = "MEDMESH" ;
1631 anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1632 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1633 aName->SetValue("MEDMESH");
1637 MESSAGE("Add a mesh Object under MED/MEDMESH");
1638 myBuilder->NewCommand();
1639 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
1641 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1642 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1643 CORBA::ORB_var &orb = init(0,0);
1644 CORBA::String_var iorStr = orb->object_to_string(myIor);
1645 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1646 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1647 aIOR->SetValue(iorStr.in());
1648 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1649 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1650 aName->SetValue(_mesh->getName().c_str());
1651 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
1652 aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1653 aComment->SetValue(fileName.c_str());
1654 _meshId = newObj->GetID();
1655 myBuilder->CommitCommand();
1657 // register the Corba pointer: increase the referrence count
1658 MESSAGE("Registering of the Corba Mesh pointer");
1663 //=============================================================================
1665 //=============================================================================
1667 * CORBA: write mesh in a med file
1669 //=============================================================================
1670 void MESH_i::write(CORBA::Long i, const char* driverMeshName)
1671 throw (SALOME::SALOME_Exception)
1674 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1675 SALOME::INTERNAL_ERROR);
1678 _mesh->write(i,driverMeshName);
1680 catch (MEDEXCEPTION &ex)
1682 MESSAGE("Unable to write the mesh ");
1683 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1686 //=============================================================================
1688 * CORBA: read mesh in a med file
1690 //=============================================================================
1691 void MESH_i::read(CORBA::Long i)
1692 throw (SALOME::SALOME_Exception)
1695 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1696 SALOME::INTERNAL_ERROR);
1701 catch (MEDEXCEPTION &ex)
1703 MESSAGE("Unable to read the mesh ");
1704 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1707 //=============================================================================
1709 * CORBA : release driver
1711 //=============================================================================
1712 void MESH_i::rmDriver(CORBA::Long i)
1713 throw (SALOME::SALOME_Exception)
1716 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1717 SALOME::INTERNAL_ERROR);
1722 catch (MEDEXCEPTION &ex)
1724 MESSAGE("Unable to unlink the mesh from the driver ");
1725 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1726 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
1727 ,SALOME::INTERNAL_ERROR);
1730 //=============================================================================
1732 * CORBA : attach driver
1734 //=============================================================================
1735 CORBA::Long MESH_i::addDriver(SALOME_MED::medDriverTypes driverType,
1736 const char* fileName, const char* meshName)
1737 throw (SALOME::SALOME_Exception)
1740 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1741 SALOME::INTERNAL_ERROR);
1744 int drivernum=_mesh->addDriver(
1745 convertIdlDriverToMedDriver(driverType),
1750 catch (MEDEXCEPTION &ex)
1752 MESSAGE("Unable to link the mesh to the driver ");
1753 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1757 //=============================================================================
1759 * CORBA : Test if this and other aggregate the same MESH using the MESH::operator==
1761 //=============================================================================
1762 CORBA::Boolean MESH_i::areEquals(SALOME_MED::MESH_ptr other)
1764 PortableServer::ServantBase *baseServ;
1766 baseServ=_default_POA()->reference_to_servant(other);
1773 baseServ->_remove_ref();
1774 MESH_i *otherServ=dynamic_cast<MESH_i *>(baseServ);
1775 return *_mesh==*otherServ->_mesh;