1 //=============================================================================
2 // File : MEDMEM_Mesh_i.cxx
5 // Copyright : EDF 2002
6 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Mesh_i.cxx
7 //=============================================================================
11 #include "utilities.h"
12 #include "Utils_CorbaException.hxx"
13 #include "Utils_ORB_INIT.hxx"
14 #include "Utils_SINGLETON.hxx"
16 #include "MEDMEM_convert.hxx"
17 #include "MEDMEM_Mesh_i.hxx"
18 #include "MEDMEM_Support_i.hxx"
19 #include "MEDMEM_Family_i.hxx"
20 #include "MEDMEM_Group_i.hxx"
21 #include "MEDMEM_FieldDouble_i.hxx"
23 #include "MEDMEM_Mesh.hxx"
24 #include "MEDMEM_Family.hxx"
25 #include "MEDMEM_Group.hxx"
26 #include "MEDMEM_CellModel.hxx"
28 #include "SenderFactory.hxx"
29 #include "MultiCommException.hxx"
30 using namespace MEDMEM;
32 // Initialisation des variables statiques
33 map < int, ::MESH *> MESH_i::meshMap ;
34 int MESH_i::meshIndex = 0 ;
38 //=============================================================================
42 //=============================================================================
43 MESH_i::MESH_i(): _mesh(constructConstMesh()),
44 _corbaIndex(MESH_i::meshIndex++),
47 BEGIN_OF("Default Constructor MESH_i");
48 MESH_i::meshMap[_corbaIndex]=_mesh;
49 END_OF("Default Constructor MESH_i");
51 //=============================================================================
55 //=============================================================================
59 //=============================================================================
63 //=============================================================================
64 MESH_i::MESH_i(::MESH * const m ) :_mesh(m),
65 _corbaIndex(MESH_i::meshIndex++),
68 BEGIN_OF("Constructor MESH_i(::MESH * const m )");
69 MESH_i::meshMap[_corbaIndex]=_mesh;
72 END_OF("Constructor MESH_i(::MESH * const m )");
74 //=============================================================================
78 //=============================================================================
79 //MESH_i::MESH_i(const MESH_i & m) :_mesh(m._mesh),
80 MESH_i::MESH_i( MESH_i & m) :_mesh(m._mesh),
81 _corbaIndex(MESH_i::meshIndex++),
84 BEGIN_OF("Constructor MESH_i");
85 MESH_i::meshMap[_corbaIndex]=_mesh;
86 END_OF("Constructor MESH_i");
88 //=============================================================================
90 * Internal Method in order to have a const ptr
92 //=============================================================================
93 ::MESH * MESH_i::constructConstMesh() const
95 ::MESH * const ptrMesh =new ::MESH();
98 //=============================================================================
100 * CORBA: Accessor for Name
102 //=============================================================================
103 char * MESH_i::getName()
104 throw (SALOME::SALOME_Exception)
107 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
108 SALOME::INTERNAL_ERROR);
112 return CORBA::string_dup(_mesh->getName().c_str());
114 catch (MEDEXCEPTION &ex)
116 MESSAGE("Unable to acces the mesh name");
117 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
120 //=============================================================================
122 * CORBA: Accessor for corbaindex cuisine interne
124 //=============================================================================
125 CORBA::Long MESH_i::getCorbaIndex()
126 throw (SALOME::SALOME_Exception)
129 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
130 SALOME::INTERNAL_ERROR);
133 //=============================================================================
135 * CORBA: Accessor for Space Dimension
137 //=============================================================================
138 CORBA::Long MESH_i::getSpaceDimension()
139 throw (SALOME::SALOME_Exception)
142 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
143 SALOME::INTERNAL_ERROR);
146 return _mesh->getSpaceDimension();
148 catch (MEDEXCEPTION &ex)
150 MESSAGE("Unable to acces the space dimension ");
151 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
154 //=============================================================================
156 * CORBA: Accessor for Mesh Dimension
158 //=============================================================================
159 CORBA::Long MESH_i::getMeshDimension()
160 throw (SALOME::SALOME_Exception)
163 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
164 SALOME::INTERNAL_ERROR);
167 return _mesh->getMeshDimension();
169 catch (MEDEXCEPTION &ex)
171 MESSAGE("Unable to acces the mesh dimension ");
172 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
175 //=============================================================================
177 * CORBA: boolean indicating if mesh is a Grid
179 //=============================================================================
180 CORBA::Boolean MESH_i::getIsAGrid()
181 throw (SALOME::SALOME_Exception)
184 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
185 SALOME::INTERNAL_ERROR);
188 return _mesh->getIsAGrid();
190 catch (MEDEXCEPTION &ex)
192 MESSAGE("Unable to acces mesh flag isAGrid");
193 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
196 //=============================================================================
198 * CORBA: boolean indicating if connectivity exists
200 //=============================================================================
201 CORBA::Boolean MESH_i::existConnectivity
202 (SALOME_MED::medConnectivity connectivityType,
203 SALOME_MED::medEntityMesh entity)
204 throw (SALOME::SALOME_Exception)
207 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
208 SALOME::INTERNAL_ERROR);
211 return _mesh->existConnectivity(connectivityType,
212 convertIdlEntToMedEnt(entity)); }
213 catch (MEDEXCEPTION &ex)
215 MESSAGE("Unable to acces mesh flag existConnectivity");
216 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
220 //=============================================================================
222 * CORBA: Accessor for Coordinates System
224 //=============================================================================
225 char * MESH_i::getCoordinatesSystem()
226 throw (SALOME::SALOME_Exception)
229 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
230 SALOME::INTERNAL_ERROR);
234 return CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
236 catch (MEDEXCEPTION &ex)
238 MESSAGE("Unable to acces the type of CoordinatesSystem");
239 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
242 //=============================================================================
244 * CORBA: Accessor for a specific coordinate
246 //=============================================================================
247 CORBA::Double MESH_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis)
248 throw (SALOME::SALOME_Exception)
251 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
252 SALOME::INTERNAL_ERROR);
255 return _mesh->getCoordinate(Number,Axis);
257 catch (MEDEXCEPTION &ex)
259 MESSAGE("Unable to acces this coordinate");
260 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
263 //=============================================================================
265 * CORBA: Accessor for Coordinates
267 //=============================================================================
268 SALOME_MED::double_array * MESH_i::getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
269 throw (SALOME::SALOME_Exception)
272 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
273 SALOME::INTERNAL_ERROR);
274 SALOME_MED::double_array_var myseq = new SALOME_MED::double_array;
277 int spaceDimension=_mesh->getSpaceDimension();
278 int nbNodes=_mesh->getNumberOfNodes();
279 const double * coordinates =_mesh->getCoordinates(
280 convertIdlModeToMedMode(typeSwitch));
282 myseq->length(nbNodes*spaceDimension);
283 for (int i=0; i<nbNodes*spaceDimension; i++)
285 myseq[i]=coordinates[i];
288 catch (MEDEXCEPTION &ex)
290 MESSAGE("Unable to acces the coordinates");
291 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
293 return myseq._retn();
295 //=============================================================================
297 * CORBA: 2nd Accessor for Coordinates
299 //=============================================================================
300 SALOME::SenderDouble_ptr MESH_i::getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch)
301 throw (SALOME::SALOME_Exception)
304 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
305 SALOME::INTERNAL_ERROR);
306 SALOME::SenderDouble_ptr ret;
309 int spaceDimension=_mesh->getSpaceDimension();
310 int nbNodes=_mesh->getNumberOfNodes();
311 const double * coordinates =_mesh->getCoordinates(convertIdlModeToMedMode(typeSwitch));
312 ret=SenderFactory::buildSender(*this,coordinates,nbNodes*spaceDimension);
314 catch (MEDEXCEPTION &ex)
316 MESSAGE("Unable to acces the coordinates");
317 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
319 catch(MultiCommException &ex2)
320 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
323 //=============================================================================
325 * CORBA: Accessor for Coordinates Names
327 //=============================================================================
328 SALOME_MED::string_array * MESH_i::getCoordinatesNames()
329 throw (SALOME::SALOME_Exception)
332 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
333 SALOME::INTERNAL_ERROR);
334 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
337 int spaceDimension=_mesh->getSpaceDimension();
338 const string * coordinatesName =_mesh->getCoordinatesNames();
339 myseq->length(spaceDimension);
340 for (int i=0; i<spaceDimension; i++)
342 myseq[i]=CORBA::string_dup(coordinatesName[i].c_str());
345 catch (MEDEXCEPTION &ex)
347 MESSAGE("Unable to acces the coordinates names");
348 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
350 return myseq._retn();
353 //=============================================================================
355 * CORBA: Accessor for Coordinates Units
357 //=============================================================================
358 SALOME_MED::string_array * MESH_i::getCoordinatesUnits()
359 throw (SALOME::SALOME_Exception)
362 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
363 SALOME::INTERNAL_ERROR);
364 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
367 int spaceDimension=_mesh->getSpaceDimension();
368 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
369 myseq->length(spaceDimension);
370 for (int i=0; i<spaceDimension; i++)
372 myseq[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
375 catch (MEDEXCEPTION &ex)
377 MESSAGE("Unable to acces the coordinates units");
378 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
380 return myseq._retn();
382 //=============================================================================
384 * CORBA: Accessor for Number of Nodes
386 //=============================================================================
387 CORBA::Long MESH_i::getNumberOfNodes()
388 throw (SALOME::SALOME_Exception)
391 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
392 SALOME::INTERNAL_ERROR);
395 return _mesh->getNumberOfNodes();
397 catch (MEDEXCEPTION &ex)
399 MESSAGE("Unable to acces number of nodes");
400 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
403 //=============================================================================
405 * CORBA: Accessor for number of Types
407 //=============================================================================
408 CORBA::Long MESH_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
409 throw (SALOME::SALOME_Exception)
412 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
413 SALOME::INTERNAL_ERROR);
416 return _mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
418 catch (MEDEXCEPTION &ex)
420 MESSAGE("Unable to acces number of differents types");
421 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
424 //=============================================================================
426 * CORBA: Accessor for existing geometry element types
428 //=============================================================================
429 SALOME_MED::medGeometryElement MESH_i::getElementType (SALOME_MED::medEntityMesh entity,
431 throw (SALOME::SALOME_Exception)
434 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
435 SALOME::INTERNAL_ERROR);
438 return _mesh->getElementType(convertIdlEntToMedEnt(entity),number);
440 catch (MEDEXCEPTION &ex)
442 MESSAGE("Unable to acces number of differents element types");
443 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
447 //=============================================================================
449 * CORBA: Accessor for existing geometry element types
450 * Not implemented for MED_ALL_ENTITIES
452 //=============================================================================
453 SALOME_MED::medGeometryElement_array * MESH_i::getTypes (SALOME_MED::medEntityMesh entity)
454 throw (SALOME::SALOME_Exception)
457 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
458 SALOME::INTERNAL_ERROR);
459 if (entity ==SALOME_MED::MED_ALL_ENTITIES)
460 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\
462 SALOME_MED::medGeometryElement_array_var myseq =
463 new SALOME_MED::medGeometryElement_array;
466 int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
467 const medGeometryElement * elemts =_mesh->getTypes(
468 convertIdlEntToMedEnt(entity));
469 myseq->length(nbTypes);
470 for (int i=0; i<nbTypes; i++)
472 myseq[i]=convertMedEltToIdlElt(elemts[i]);
475 catch (MEDEXCEPTION &ex)
477 MESSAGE("Unable to acces coordinates");
478 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
480 return myseq._retn();
482 //=============================================================================
484 * CORBA: Returns number of elements of type medGeometryElement
485 * Not implemented for MED_ALL_ELEMENTS
486 * implemented for MED_ALL_ENTITIES
488 //=============================================================================
489 CORBA::Long MESH_i::getNumberOfElements(SALOME_MED::medEntityMesh entity,
490 SALOME_MED::medGeometryElement geomElement)
491 throw (SALOME::SALOME_Exception)
494 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
495 SALOME::INTERNAL_ERROR);
496 if (verifieParam(entity,geomElement)==false)
497 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
502 return _mesh->getNumberOfElements(convertIdlEntToMedEnt(entity),
503 convertIdlEltToMedElt(geomElement));
505 catch (MEDEXCEPTION &ex)
507 MESSAGE("Unable to acces number of elements");
508 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
511 //=============================================================================
513 * CORBA: Accessor for connectivities
515 //=============================================================================
516 SALOME_MED::long_array * MESH_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
517 SALOME_MED::medConnectivity mode,
518 SALOME_MED::medEntityMesh entity,
519 SALOME_MED::medGeometryElement geomElement)
520 throw (SALOME::SALOME_Exception)
523 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
524 SALOME::INTERNAL_ERROR);
525 if (verifieParam(entity,geomElement)==false)
526 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
528 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
532 int elt1 = _mesh->getNumberOfElements(
533 convertIdlEntToMedEnt(entity),
534 convertIdlEltToMedElt(geomElement));
536 if ( mode == SALOME_MED::MED_DESCENDING)
538 MESSAGE("MED_DESCENDING");
539 int elt2 =(_mesh->getCellsTypes(MED_CELL))->getNumberOfConstituents(1);
540 //int elt2 =(_mesh->getTypes(convertIdlEltToMedElt(geomElement)))->getNumberOfConstituents(1);
541 nbelements= elt2 * elt1;
546 MESSAGE("MED_NODAL");
547 const int * tab=_mesh->getConnectivityIndex(
548 convertIdlConnToMedConn(mode),
549 convertIdlEntToMedEnt(entity));
550 nbelements = elt1*(convertIdlEltToMedElt(geomElement)%100);
551 // nbelements = tab[elt1 ] - 1 ;
556 myseq->length(nbelements);
557 const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
558 convertIdlConnToMedConn(mode),
559 convertIdlEntToMedEnt(entity),
560 convertIdlEltToMedElt(geomElement));
561 for (int i=0;i<nbelements;i++)
566 catch (MEDEXCEPTION &ex)
568 MESSAGE("Unable to acces connectivities");
569 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
571 return myseq._retn();
573 //=============================================================================
575 * CORBA: 2nd Accessor for connectivities
577 //=============================================================================
578 SALOME::SenderInt_ptr MESH_i::getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch,
579 SALOME_MED::medConnectivity mode,
580 SALOME_MED::medEntityMesh entity,
581 SALOME_MED::medGeometryElement geomElement)
582 throw (SALOME::SALOME_Exception)
585 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
586 SALOME::INTERNAL_ERROR);
587 if (verifieParam(entity,geomElement)==false)
588 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
590 SALOME::SenderInt_ptr ret;
593 int nbelements=_mesh->getConnectivityLength(convertIdlModeToMedMode(typeSwitch),
594 convertIdlConnToMedConn(mode),
595 convertIdlEntToMedEnt(entity),
596 convertIdlEltToMedElt(geomElement));
597 const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
598 convertIdlConnToMedConn(mode),
599 convertIdlEntToMedEnt(entity),
600 convertIdlEltToMedElt(geomElement));
601 ret=SenderFactory::buildSender(*this,numbers,nbelements);
603 catch (MEDEXCEPTION &ex)
605 MESSAGE("Unable to acces connectivities");
606 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
608 catch(MultiCommException &ex2)
609 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
613 //=======================================================================
614 //function : getSenderForPolygonsConnectivity
616 //=======================================================================
618 SALOME::SenderInt_ptr MESH_i::getSenderForPolygonsConnectivity(SALOME_MED::medConnectivity mode,
619 SALOME_MED::medEntityMesh entity)
620 throw (SALOME::SALOME_Exception)
623 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
624 SALOME::INTERNAL_ERROR);
625 if (verifieParam(entity,SALOME_MED::MED_POLYGON)==false)
626 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
628 SALOME::SenderInt_ptr ret;
631 int nbelements = _mesh->getPolygonsConnectivityLength(convertIdlConnToMedConn(mode),
632 convertIdlEntToMedEnt(entity));
633 const int * numbers=_mesh->getPolygonsConnectivity (convertIdlConnToMedConn(mode),
634 convertIdlEntToMedEnt(entity));
635 ret=SenderFactory::buildSender(*this,numbers,nbelements);
637 catch (MEDEXCEPTION &ex)
639 MESSAGE("Unable to acces connectivities");
640 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
642 catch(MultiCommException &ex2)
643 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
647 //=======================================================================
648 //function : getSenderForPolygonsConnectivityIndex
650 //=======================================================================
652 SALOME::SenderInt_ptr MESH_i::getSenderForPolygonsConnectivityIndex(SALOME_MED::medConnectivity mode,
653 SALOME_MED::medEntityMesh entity)
654 throw (SALOME::SALOME_Exception)
657 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
658 SALOME::INTERNAL_ERROR);
659 if (verifieParam(entity,SALOME_MED::MED_POLYGON)==false)
660 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
662 SALOME::SenderInt_ptr ret;
665 int nbelements = _mesh->getNumberOfPolygons() + 1;
666 const int * numbers=_mesh->getPolygonsConnectivityIndex (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 : getSenderForPolyhedronConnectivity
683 //=======================================================================
685 SALOME::SenderInt_ptr MESH_i::getSenderForPolyhedronConnectivity(SALOME_MED::medConnectivity mode)
686 throw (SALOME::SALOME_Exception)
689 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
690 SALOME::INTERNAL_ERROR);
691 SALOME::SenderInt_ptr ret;
694 int nbelements = _mesh->getPolyhedronConnectivityLength(convertIdlConnToMedConn(mode));
695 const int * numbers=_mesh->getPolyhedronConnectivity( convertIdlConnToMedConn(mode) );
696 ret=SenderFactory::buildSender(*this,numbers,nbelements);
698 catch (MEDEXCEPTION &ex)
700 MESSAGE("Unable to acces connectivities");
701 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
703 catch(MultiCommException &ex2)
704 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
708 //=======================================================================
709 //function : getSenderForPolyhedronIndex
711 //=======================================================================
713 SALOME::SenderInt_ptr MESH_i::getSenderForPolyhedronIndex(SALOME_MED::medConnectivity mode)
714 throw (SALOME::SALOME_Exception)
717 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
718 SALOME::INTERNAL_ERROR);
719 SALOME::SenderInt_ptr ret;
722 int nbelements = _mesh->getNumberOfPolyhedron() + 1;
723 const int * numbers = _mesh->getPolyhedronIndex( convertIdlConnToMedConn( mode ) );
724 ret=SenderFactory::buildSender(*this,numbers,nbelements);
726 catch (MEDEXCEPTION &ex)
728 MESSAGE("Unable to acces connectivities");
729 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
731 catch(MultiCommException &ex2)
732 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
736 //=======================================================================
737 //function : getSenderForPolyhedronFacesIndex
739 //=======================================================================
741 SALOME::SenderInt_ptr MESH_i::getSenderForPolyhedronFacesIndex()
742 throw (SALOME::SALOME_Exception)
745 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
746 SALOME::INTERNAL_ERROR);
747 SALOME::SenderInt_ptr ret;
750 int nbelements = _mesh->getNumberOfPolyhedronFaces() + 1;
751 const int * numbers=_mesh->getPolyhedronFacesIndex();
752 ret=SenderFactory::buildSender(*this,numbers,nbelements);
754 catch (MEDEXCEPTION &ex)
756 MESSAGE("Unable to acces connectivities");
757 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
759 catch(MultiCommException &ex2)
760 THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
764 //=============================================================================
766 * CORBA: Accessor for connectivities
768 //=============================================================================
769 SALOME_MED::long_array* MESH_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
770 SALOME_MED::medEntityMesh entity)
771 throw (SALOME::SALOME_Exception)
774 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
775 SALOME::INTERNAL_ERROR);
776 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
779 int nbelements = _mesh->getNumberOfElements(
780 convertIdlEntToMedEnt(entity),
782 myseq->length(nbelements);
783 const int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode),
784 convertIdlEntToMedEnt(entity));
785 for (int i=0;i<nbelements;i++)
790 catch (MEDEXCEPTION &ex)
792 MESSAGE("Unable to acces connectivities index");
793 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
795 return myseq._retn();
797 //=============================================================================
799 * CORBA: Accessor for connectivities
801 //=============================================================================
802 SALOME_MED::long_array* MESH_i::getGlobalNumberingIndex( SALOME_MED::medEntityMesh entity)
803 throw (SALOME::SALOME_Exception)
806 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
807 SALOME::INTERNAL_ERROR);
808 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
811 int nbelements = _mesh->getNumberOfTypes( convertIdlEntToMedEnt(entity)) + 1;
812 myseq->length(nbelements);
813 const int * numbers=_mesh->getGlobalNumberingIndex( convertIdlEntToMedEnt(entity));
814 for (int i=0;i<nbelements;i++)
819 catch (MEDEXCEPTION &ex)
821 MESSAGE("Unable to acces global index");
822 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
824 return myseq._retn();
827 //=============================================================================
829 * CORBA: get global element number in connectivity array
830 * not implemented for MED_NODE and MED_ALL_ENTITIES,
831 * MED_NONE and MED_ALL_ELEMENTS.
833 //=============================================================================
834 CORBA::Long MESH_i::getElementNumber(SALOME_MED::medConnectivity mode,
835 SALOME_MED::medEntityMesh entity,
836 SALOME_MED::medGeometryElement type,
837 const SALOME_MED::long_array& connectivity)
838 throw (SALOME::SALOME_Exception)
841 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR);
842 int numberOfValue = connectivity.length() ;
843 int * myConnectivity = new int[numberOfValue] ;
844 for (int i=0; i<numberOfValue; i++)
845 myConnectivity[i]=connectivity[i] ;
849 result = _mesh->getElementNumber(convertIdlConnToMedConn(mode),
850 convertIdlEntToMedEnt(entity),
851 convertIdlEltToMedElt(type),
854 catch (MEDEXCEPTION &ex) {
855 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
859 //=============================================================================
861 * CORBA: Accessor for Ascendant connectivities
862 * not implemented for MED_ALL_ENTITIES and MED_MAILLE
864 //=============================================================================
865 SALOME_MED::long_array* MESH_i::getReverseConnectivity(SALOME_MED::medConnectivity mode)
866 throw (SALOME::SALOME_Exception)
869 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
870 SALOME::INTERNAL_ERROR);
871 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
874 int nbelements=_mesh->getReverseConnectivityLength(convertIdlConnToMedConn(mode));
876 myseq->length(nbelements);
877 const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
878 for (int i=0;i<nbelements;i++)
883 catch (MEDEXCEPTION &ex)
885 MESSAGE("Unable to acces reverse connectivities");
886 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
888 return myseq._retn();
890 //=============================================================================
892 * CORBA: Accessor for connectivities
894 //=============================================================================
895 SALOME_MED::long_array* MESH_i::getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
896 throw (SALOME::SALOME_Exception)
899 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
900 SALOME::INTERNAL_ERROR);
901 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
904 int nbelements=_mesh->getReverseConnectivityIndexLength(convertIdlConnToMedConn(mode));
905 myseq->length(nbelements);
906 const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
907 for (int i=0;i<nbelements;i++)
912 catch (MEDEXCEPTION &ex)
914 MESSAGE("Unable to acces reverse connectivities index");
915 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
917 return myseq._retn();
919 //=============================================================================
921 * CORBA: Returns number of families within the mesh
923 //=============================================================================
924 CORBA::Long MESH_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
925 throw (SALOME::SALOME_Exception)
928 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
929 SALOME::INTERNAL_ERROR);
932 return _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
934 catch (MEDEXCEPTION &ex)
936 MESSAGE("Unable to acces number of families of the mesh");
937 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
940 //=============================================================================
942 * CORBA: Returns number of groups within the mesh
944 //=============================================================================
945 CORBA::Long MESH_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
946 throw (SALOME::SALOME_Exception)
949 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
950 SALOME::INTERNAL_ERROR);
953 return _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
955 catch (MEDEXCEPTION &ex)
957 MESSAGE("Unable to acces number of groups of the mesh");
958 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
961 //=============================================================================
963 * CORBA: Returns references for families within the mesh
965 //=============================================================================
966 SALOME_MED::Family_array * MESH_i::getFamilies(SALOME_MED::medEntityMesh entity)
967 throw (SALOME::SALOME_Exception)
970 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
971 SALOME::INTERNAL_ERROR);
972 SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
975 int nbfam= _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
976 myseq->length(nbfam);
977 vector<FAMILY*> fam(nbfam);
978 fam = _mesh->getFamilies(convertIdlEntToMedEnt(entity));
979 for (int i=0;i<nbfam;i++)
981 FAMILY_i * f1=new FAMILY_i(fam[i]);
982 myseq[i] = f1->POA_SALOME_MED::FAMILY::_this();
985 catch (MEDEXCEPTION &ex)
987 MESSAGE("Unable to acces families of the mesh");
988 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
990 return myseq._retn();
992 //=============================================================================
994 * CORBA: Returns Coordinates global informations
996 //=============================================================================
997 SALOME_MED::MESH::coordinateInfos * MESH_i::getCoordGlobal()
998 throw (SALOME::SALOME_Exception)
1001 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1002 SALOME::INTERNAL_ERROR);
1003 SALOME_MED::MESH::coordinateInfos_var all = new SALOME_MED::MESH::coordinateInfos;
1006 all->coordSystem = CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
1008 int spaceDimension=_mesh->getSpaceDimension();
1009 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
1010 const string * coordinatesName =_mesh->getCoordinatesNames();
1012 all->coordUnits.length(spaceDimension);
1013 all->coordNames.length(spaceDimension);
1014 for (int i=0; i<spaceDimension; i++)
1016 all->coordUnits[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
1017 all->coordNames[i]=CORBA::string_dup(coordinatesName[i].c_str());
1020 catch (MEDEXCEPTION &ex)
1022 MESSAGE("Unable to acces coordinate information ");
1023 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1027 //=============================================================================
1029 * CORBA: Returns connectivity global informations
1031 //=============================================================================
1032 SALOME_MED::MESH::connectivityInfos * MESH_i::getConnectGlobal
1033 (SALOME_MED::medEntityMesh entity)
1034 throw (SALOME::SALOME_Exception)
1037 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1038 SALOME::INTERNAL_ERROR);
1039 SALOME_MED::MESH::connectivityInfos_var all=new SALOME_MED::MESH::connectivityInfos;
1042 all->numberOfNodes = _mesh->getNumberOfNodes();
1044 int nbTypes=_mesh->getNumberOfTypesWithPoly(convertIdlEntToMedEnt(entity));
1045 const medGeometryElement * elemts =_mesh->getTypesWithPoly(
1046 convertIdlEntToMedEnt(entity));
1047 all->meshTypes.length(nbTypes);
1048 all->numberOfElements.length(nbTypes);
1049 all->entityDimension=_mesh->getConnectivityptr()->getEntityDimension();
1050 for (int i=0; i<nbTypes; i++)
1052 all->meshTypes[i]=convertMedEltToIdlElt(elemts[i]);
1053 all->numberOfElements[i]=_mesh->getNumberOfElementsWithPoly(
1054 convertIdlEntToMedEnt(entity),elemts[i]);
1057 catch (MEDEXCEPTION &ex)
1059 MESSAGE("Unable to acces connectivities informations");
1060 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1065 //=============================================================================
1067 * CORBA: Returns references for family i within the mesh
1069 //=============================================================================
1070 SALOME_MED::FAMILY_ptr MESH_i::getFamily(SALOME_MED::medEntityMesh entity,
1072 throw (SALOME::SALOME_Exception)
1075 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1076 SALOME::INTERNAL_ERROR);
1079 const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
1080 FAMILY_i * f1=new FAMILY_i(fam);
1081 return f1->POA_SALOME_MED::FAMILY::_this();
1083 catch (MEDEXCEPTION &ex)
1085 MESSAGE("Unable to acces specified family of the mesh");
1086 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1090 //=============================================================================
1092 * CORBA: Returns Mesh global informations
1094 //=============================================================================
1095 SALOME_MED::MESH::meshInfos * MESH_i::getMeshGlobal()
1096 throw (SALOME::SALOME_Exception)
1099 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1100 SALOME::INTERNAL_ERROR);
1101 SALOME_MED::MESH::meshInfos_var all = new SALOME_MED::MESH::meshInfos;
1104 all->name = CORBA::string_dup(_mesh->getName().c_str());
1105 all->spaceDimension = _mesh->getSpaceDimension();
1106 all->meshDimension = _mesh->getMeshDimension();
1107 all->numberOfNodes = _mesh->getNumberOfNodes();
1108 all->isAGrid = _mesh->getIsAGrid();
1110 int nbFam= _mesh->getNumberOfFamilies(MED_NODE);
1111 all->famNode.length(nbFam);
1112 vector<FAMILY*> vNode (nbFam);
1113 vNode = _mesh->getFamilies(MED_NODE);
1114 for (int i=0;i<nbFam;i++)
1116 FAMILY_i * f1=new FAMILY_i(vNode[i]);
1117 all->famNode[i] = f1->POA_SALOME_MED::FAMILY::_this();
1120 nbFam = _mesh->getNumberOfFamilies(MED_EDGE);
1121 all->famEdge.length(nbFam);
1122 vector<FAMILY*> vEdge (nbFam);
1123 vEdge = _mesh->getFamilies(MED_EDGE);
1124 for (int i=0;i<nbFam;i++)
1125 for (int i=0;i<nbFam;i++)
1127 FAMILY_i * f1=new FAMILY_i(vEdge[i]);
1128 all->famEdge[i] = f1->POA_SALOME_MED::FAMILY::_this();
1131 nbFam = _mesh->getNumberOfFamilies(MED_FACE);
1132 all->famFace.length(nbFam);
1133 vector<FAMILY*> vFace (nbFam);
1134 vFace = _mesh->getFamilies(MED_FACE);
1135 for (int i=0;i<nbFam;i++)
1137 FAMILY_i * f1=new FAMILY_i(vFace[i]);
1138 all->famFace[i] = f1->POA_SALOME_MED::FAMILY::_this();
1141 nbFam = _mesh->getNumberOfFamilies(MED_CELL);
1142 all->famCell.length(nbFam);
1143 vector<FAMILY*> vCell (nbFam);
1144 vCell = _mesh->getFamilies(MED_CELL);
1145 for (int i=0;i<nbFam;i++)
1147 FAMILY_i * f1=new FAMILY_i(vCell[i]);
1148 all->famCell[i] = f1->POA_SALOME_MED::FAMILY::_this();
1151 int nbGroup = _mesh->getNumberOfGroups(MED_NODE);
1152 all->groupNode.length(nbGroup);
1153 vector<GROUP*> gNode (nbGroup);
1154 gNode = _mesh->getGroups(MED_NODE);
1155 for (int i=0;i<nbGroup;i++)
1157 GROUP_i * f1=new GROUP_i(gNode[i]);
1158 all->groupNode[i] = f1->POA_SALOME_MED::GROUP::_this();
1161 nbGroup = _mesh->getNumberOfGroups(MED_EDGE);
1162 all->groupEdge.length(nbGroup);
1163 vector<GROUP*> gEdge (nbGroup);
1164 gEdge = _mesh->getGroups(MED_EDGE);
1165 for (int i=0;i<nbGroup;i++)
1167 GROUP_i * f1=new GROUP_i(gEdge[i]);
1168 all->groupEdge[i] = f1->POA_SALOME_MED::GROUP::_this();
1170 nbGroup = _mesh->getNumberOfGroups(MED_FACE);
1171 all->groupFace.length(nbGroup);
1172 vector<GROUP*> gFace (nbGroup);
1173 gFace = _mesh->getGroups(MED_FACE);
1174 for (int i=0;i<nbGroup;i++)
1176 GROUP_i * f1=new GROUP_i(gFace[i]);
1177 all->groupFace[i] = f1->POA_SALOME_MED::GROUP::_this();
1180 nbGroup = _mesh->getNumberOfGroups(MED_CELL);
1181 all->groupCell.length(nbGroup);
1182 vector<GROUP*> gCell (nbGroup);
1183 gCell = _mesh->getGroups(MED_CELL);
1184 for (int i=0;i<nbGroup;i++)
1186 GROUP_i * f1=new GROUP_i(gCell[i]);
1187 all->groupCell[i] = f1->POA_SALOME_MED::GROUP::_this();
1191 catch (MEDEXCEPTION &ex)
1193 MESSAGE("Unable to acces mesh");
1194 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1198 //=============================================================================
1200 * CORBA: Returns references for groups within the mesh
1202 //=============================================================================
1203 SALOME_MED::Group_array * MESH_i::getGroups(SALOME_MED::medEntityMesh entity)
1204 throw (SALOME::SALOME_Exception)
1207 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1208 SALOME::INTERNAL_ERROR);
1209 SALOME_MED::Group_array_var myseq = new SALOME_MED::Group_array;
1212 int nbgroups = _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
1213 myseq->length(nbgroups);
1214 vector<GROUP*> groups(nbgroups);
1215 groups = _mesh->getGroups(convertIdlEntToMedEnt(entity));
1216 for (int i=0;i<nbgroups;i++)
1218 GROUP_i * f1=new GROUP_i(groups[i]);
1219 myseq[i] = f1->POA_SALOME_MED::GROUP::_this();
1222 catch (MEDEXCEPTION &ex)
1224 MESSAGE("Unable to acces number of groups of the mesh");
1225 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1227 return myseq._retn();
1229 //=============================================================================
1231 * CORBA: Returns references for group i within the mesh
1233 //=============================================================================
1234 SALOME_MED::GROUP_ptr MESH_i::getGroup(SALOME_MED::medEntityMesh entity,
1236 throw (SALOME::SALOME_Exception)
1239 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1240 SALOME::INTERNAL_ERROR);
1243 const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
1244 GROUP_i * f1=new GROUP_i(grou);
1245 return f1->POA_SALOME_MED::GROUP::_this();
1247 catch (MEDEXCEPTION &ex)
1249 MESSAGE("Unable to acces specified group of the mesh");
1250 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1253 //=============================================================================
1257 //=============================================================================
1258 SALOME_MED::SUPPORT_ptr MESH_i::getBoundaryElements(SALOME_MED::medEntityMesh entity)
1259 throw (SALOME::SALOME_Exception)
1262 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1263 SALOME::INTERNAL_ERROR);
1266 SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity));
1267 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1268 return mySupportI->_this();
1270 catch (MEDEXCEPTION &ex)
1272 MESSAGE("Unable to get the volume ");
1273 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1276 //=============================================================================
1280 //=============================================================================
1281 SALOME_MED::FIELD_ptr MESH_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
1282 throw (SALOME::SALOME_Exception)
1285 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1286 SALOME::INTERNAL_ERROR); try
1288 int sup = mySupport->getCorbaIndex();
1289 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1290 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1291 ::FIELD<double>*f=_mesh->getVolume( myCppSupport);
1292 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1293 return medf->_this();
1295 catch (MEDEXCEPTION &ex)
1297 MESSAGE("Unable to get the volume ");
1298 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1301 //=============================================================================
1305 //=============================================================================
1306 SALOME_MED::SUPPORT_ptr MESH_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D)
1307 throw (SALOME::SALOME_Exception)
1310 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1311 SALOME::INTERNAL_ERROR);
1314 int sup = mySupport3D->getCorbaIndex();
1315 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1316 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1317 SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport);
1318 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1319 return mySupportI->_this() ;
1321 catch (MEDEXCEPTION &ex)
1323 MESSAGE("Unable to get the volume ");
1324 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1327 //=============================================================================
1331 //=============================================================================
1332 SALOME_MED::FIELD_ptr MESH_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
1333 throw (SALOME::SALOME_Exception)
1336 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1337 SALOME::INTERNAL_ERROR);
1340 int sup = mySupport->getCorbaIndex();
1341 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1342 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1343 ::FIELD<double>*f=_mesh->getArea( myCppSupport);
1344 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1345 return medf->_this();
1347 catch (MEDEXCEPTION &ex)
1349 MESSAGE("Unable to get the area ");
1350 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1353 //=============================================================================
1357 //=============================================================================
1358 SALOME_MED::FIELD_ptr MESH_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
1359 throw (SALOME::SALOME_Exception)
1362 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1363 SALOME::INTERNAL_ERROR);
1366 int sup = mySupport->getCorbaIndex();
1367 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1368 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1369 ::FIELD<double>*f=_mesh->getLength( myCppSupport);
1370 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1371 return medf->_this();
1373 catch (MEDEXCEPTION &ex)
1375 MESSAGE("Unable to get the length ");
1376 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1379 //=============================================================================
1383 //=============================================================================
1384 SALOME_MED::FIELD_ptr MESH_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
1385 throw (SALOME::SALOME_Exception)
1388 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1389 SALOME::INTERNAL_ERROR);
1392 int sup = mySupport->getCorbaIndex();
1393 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1394 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1395 ::FIELD<double>*f=_mesh->getNormal( myCppSupport);
1396 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1397 return medf->_this();
1399 catch (MEDEXCEPTION &ex)
1401 MESSAGE("Unable to get the normal ");
1402 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1405 //=============================================================================
1409 //=============================================================================
1410 SALOME_MED::FIELD_ptr MESH_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
1411 throw (SALOME::SALOME_Exception)
1414 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1415 SALOME::INTERNAL_ERROR);
1418 int sup = mySupport->getCorbaIndex();
1419 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1420 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1421 ::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
1422 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1423 return medf->_this();
1425 catch (MEDEXCEPTION &ex)
1427 MESSAGE("Unable to get the barycenter ");
1428 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1431 //=============================================================================
1435 //=============================================================================
1436 SALOME_MED::FIELD_ptr MESH_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
1437 throw (SALOME::SALOME_Exception)
1440 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1441 SALOME::INTERNAL_ERROR);
1442 MESSAGE("Not Implemented");
1444 //=============================================================================
1446 * CORBA: add the Mesh in the StudyManager
1448 //=============================================================================
1449 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor )
1450 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1452 BEGIN_OF("MED_Mesh_i::addInStudy");
1453 if ( _meshId != "" )
1455 MESSAGE("Mesh already in Study");
1456 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1460 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1461 SALOMEDS::GenericAttribute_var anAttr;
1462 SALOMEDS::AttributeName_var aName;
1463 SALOMEDS::AttributeIOR_var aIOR;
1465 // Find SComponent labelled 'MED'
1466 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1467 myBuilder->NewCommand();
1468 if ( CORBA::is_nil(medfather) )
1469 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1471 // Create SObject labelled 'MESH' if it doesn't already exit
1472 // SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1473 // if ( CORBA::is_nil(medmeshfather) )
1475 // MESSAGE("Add Object MEDMESH");
1476 // medmeshfather = myBuilder->NewObject(medfather);
1477 // //medmeshfather.Name = "MEDMESH" ;
1478 // anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1479 // aName = SALOMEDS::AttributeName::_narrow(anAttr);
1480 // aName->SetValue("MEDMESH");
1484 SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
1485 if ( CORBA::is_nil(medmeshfather) )
1487 MESSAGE("Add Object MEDMESH");
1489 myBuilder->AddDirectory("/Med/MEDMESH");
1490 medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
1493 MESSAGE("Add a mesh Object under MED/MEDMESH");
1494 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
1496 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1497 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1498 CORBA::ORB_var &orb = init(0,0);
1499 string iorStr = orb->object_to_string(myIor);
1500 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1501 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1502 aIOR->SetValue(iorStr.c_str());
1503 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1504 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1505 aName->SetValue(_mesh->getName().c_str());
1506 _meshId = newObj->GetID();
1507 myBuilder->CommitCommand();
1509 // register the Corba pointer: increase the referrence count
1510 MESSAGE("Registering of the Corba Mesh pointer");
1513 END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
1515 //=============================================================================
1517 * CORBA: add the Mesh in the StudyManager
1519 //=============================================================================
1520 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor,const string & fileName )
1521 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1523 BEGIN_OF("MED_Mesh_i::addInStudy");
1524 if ( _meshId != "" )
1526 MESSAGE("Mesh already in Study");
1527 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1531 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1532 SALOMEDS::GenericAttribute_var anAttr;
1533 SALOMEDS::AttributeName_var aName;
1534 SALOMEDS::AttributeIOR_var aIOR;
1535 SALOMEDS::AttributeComment_var aComment;
1537 // Find SComponent labelled 'Med'
1538 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1539 if ( CORBA::is_nil(medfather) )
1540 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1542 // Create SObject labelled 'MESH' if it doesn't already exit
1543 SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1544 if ( CORBA::is_nil(medmeshfather) )
1546 MESSAGE("Add Object MEDMESH");
1547 medmeshfather = myBuilder->NewObject(medfather);
1548 //medmeshfather.Name = "MEDMESH" ;
1549 anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1550 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1551 aName->SetValue("MEDMESH");
1555 MESSAGE("Add a mesh Object under MED/MEDMESH");
1556 myBuilder->NewCommand();
1557 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
1559 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1560 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1561 CORBA::ORB_var &orb = init(0,0);
1562 string iorStr = orb->object_to_string(myIor);
1563 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1564 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1565 aIOR->SetValue(iorStr.c_str());
1566 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1567 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1568 aName->SetValue(_mesh->getName().c_str());
1569 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
1570 aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1571 aComment->SetValue(fileName.c_str());
1572 _meshId = newObj->GetID();
1573 myBuilder->CommitCommand();
1575 // register the Corba pointer: increase the referrence count
1576 MESSAGE("Registering of the Corba Mesh pointer");
1579 END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
1581 //=============================================================================
1583 //=============================================================================
1585 * CORBA: write mesh in a med file
1587 //=============================================================================
1588 void MESH_i::write(CORBA::Long i, const char* driverMeshName)
1589 throw (SALOME::SALOME_Exception)
1592 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1593 SALOME::INTERNAL_ERROR);
1596 _mesh->write(i,driverMeshName);
1598 catch (MEDEXCEPTION &ex)
1600 MESSAGE("Unable to write the mesh ");
1601 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1604 //=============================================================================
1606 * CORBA: read mesh in a med file
1608 //=============================================================================
1609 void MESH_i::read(CORBA::Long i)
1610 throw (SALOME::SALOME_Exception)
1613 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1614 SALOME::INTERNAL_ERROR);
1619 catch (MEDEXCEPTION &ex)
1621 MESSAGE("Unable to read the mesh ");
1622 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1625 //=============================================================================
1627 * CORBA : release driver
1629 //=============================================================================
1630 void MESH_i::rmDriver(CORBA::Long i)
1631 throw (SALOME::SALOME_Exception)
1634 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1635 SALOME::INTERNAL_ERROR);
1640 catch (MEDEXCEPTION &ex)
1642 MESSAGE("Unable to unlink the mesh from the driver ");
1643 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1644 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
1645 ,SALOME::INTERNAL_ERROR);
1648 //=============================================================================
1650 * CORBA : attach driver
1652 //=============================================================================
1653 CORBA::Long MESH_i::addDriver(SALOME_MED::medDriverTypes driverType,
1654 const char* fileName, const char* meshName)
1655 throw (SALOME::SALOME_Exception)
1658 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1659 SALOME::INTERNAL_ERROR);
1662 int drivernum=_mesh->addDriver(
1663 convertIdlDriverToMedDriver(driverType),
1668 catch (MEDEXCEPTION &ex)
1670 MESSAGE("Unable to link the mesh to the driver ");
1671 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1675 //=============================================================================
1677 * CORBA : Test if this and other aggregate the same MESH using the MESH::operator==
1679 //=============================================================================
1680 CORBA::Boolean MESH_i::areEquals(SALOME_MED::MESH_ptr other)
1682 PortableServer::ServantBase *baseServ;
1684 baseServ=_default_POA()->reference_to_servant(other);
1691 baseServ->_remove_ref();
1692 MESH_i *otherServ=dynamic_cast<MESH_i *>(baseServ);
1693 return *_mesh==*otherServ->_mesh;