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);
612 //=============================================================================
614 * CORBA: Accessor for connectivities
616 //=============================================================================
617 SALOME_MED::long_array* MESH_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
618 SALOME_MED::medEntityMesh entity)
619 throw (SALOME::SALOME_Exception)
622 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
623 SALOME::INTERNAL_ERROR);
624 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
627 int nbelements = _mesh->getNumberOfElements(
628 convertIdlEntToMedEnt(entity),
630 myseq->length(nbelements);
631 const int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode),
632 convertIdlEntToMedEnt(entity));
633 for (int i=0;i<nbelements;i++)
638 catch (MEDEXCEPTION &ex)
640 MESSAGE("Unable to acces connectivities index");
641 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
643 return myseq._retn();
645 //=============================================================================
647 * CORBA: Accessor for connectivities
649 //=============================================================================
650 SALOME_MED::long_array* MESH_i::getGlobalNumberingIndex( SALOME_MED::medEntityMesh entity)
651 throw (SALOME::SALOME_Exception)
654 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
655 SALOME::INTERNAL_ERROR);
656 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
659 int nbelements = _mesh->getNumberOfTypes( convertIdlEntToMedEnt(entity)) + 1;
660 myseq->length(nbelements);
661 const int * numbers=_mesh->getGlobalNumberingIndex( convertIdlEntToMedEnt(entity));
662 for (int i=0;i<nbelements;i++)
667 catch (MEDEXCEPTION &ex)
669 MESSAGE("Unable to acces global index");
670 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
672 return myseq._retn();
675 //=============================================================================
677 * CORBA: get global element number in connectivity array
678 * not implemented for MED_NODE and MED_ALL_ENTITIES,
679 * MED_NONE and MED_ALL_ELEMENTS.
681 //=============================================================================
682 CORBA::Long MESH_i::getElementNumber(SALOME_MED::medConnectivity mode,
683 SALOME_MED::medEntityMesh entity,
684 SALOME_MED::medGeometryElement type,
685 const SALOME_MED::long_array& connectivity)
686 throw (SALOME::SALOME_Exception)
689 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR);
690 int numberOfValue = connectivity.length() ;
691 int * myConnectivity = new int[numberOfValue] ;
692 for (int i=0; i<numberOfValue; i++)
693 myConnectivity[i]=connectivity[i] ;
697 result = _mesh->getElementNumber(convertIdlConnToMedConn(mode),
698 convertIdlEntToMedEnt(entity),
699 convertIdlEltToMedElt(type),
702 catch (MEDEXCEPTION &ex) {
703 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
707 //=============================================================================
709 * CORBA: Accessor for Ascendant connectivities
710 * not implemented for MED_ALL_ENTITIES and MED_MAILLE
712 //=============================================================================
713 SALOME_MED::long_array* MESH_i::getReverseConnectivity(SALOME_MED::medConnectivity mode)
714 throw (SALOME::SALOME_Exception)
717 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
718 SALOME::INTERNAL_ERROR);
719 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
722 int nbelements=_mesh->getReverseConnectivityLength(convertIdlConnToMedConn(mode));
724 myseq->length(nbelements);
725 const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
726 for (int i=0;i<nbelements;i++)
731 catch (MEDEXCEPTION &ex)
733 MESSAGE("Unable to acces reverse connectivities");
734 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
736 return myseq._retn();
738 //=============================================================================
740 * CORBA: Accessor for connectivities
742 //=============================================================================
743 SALOME_MED::long_array* MESH_i::getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
744 throw (SALOME::SALOME_Exception)
747 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
748 SALOME::INTERNAL_ERROR);
749 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
752 int nbelements=_mesh->getReverseConnectivityIndexLength(convertIdlConnToMedConn(mode));
753 myseq->length(nbelements);
754 const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
755 for (int i=0;i<nbelements;i++)
760 catch (MEDEXCEPTION &ex)
762 MESSAGE("Unable to acces reverse connectivities index");
763 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
765 return myseq._retn();
767 //=============================================================================
769 * CORBA: Returns number of families within the mesh
771 //=============================================================================
772 CORBA::Long MESH_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
773 throw (SALOME::SALOME_Exception)
776 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
777 SALOME::INTERNAL_ERROR);
780 return _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
782 catch (MEDEXCEPTION &ex)
784 MESSAGE("Unable to acces number of families of the mesh");
785 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
788 //=============================================================================
790 * CORBA: Returns number of groups within the mesh
792 //=============================================================================
793 CORBA::Long MESH_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
794 throw (SALOME::SALOME_Exception)
797 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
798 SALOME::INTERNAL_ERROR);
801 return _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
803 catch (MEDEXCEPTION &ex)
805 MESSAGE("Unable to acces number of groups of the mesh");
806 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
809 //=============================================================================
811 * CORBA: Returns references for families within the mesh
813 //=============================================================================
814 SALOME_MED::Family_array * MESH_i::getFamilies(SALOME_MED::medEntityMesh entity)
815 throw (SALOME::SALOME_Exception)
818 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
819 SALOME::INTERNAL_ERROR);
820 SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
823 int nbfam= _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
824 myseq->length(nbfam);
825 vector<FAMILY*> fam(nbfam);
826 fam = _mesh->getFamilies(convertIdlEntToMedEnt(entity));
827 for (int i=0;i<nbfam;i++)
829 FAMILY_i * f1=new FAMILY_i(fam[i]);
830 myseq[i] = f1->POA_SALOME_MED::FAMILY::_this();
833 catch (MEDEXCEPTION &ex)
835 MESSAGE("Unable to acces families of the mesh");
836 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
838 return myseq._retn();
840 //=============================================================================
842 * CORBA: Returns Coordinates global informations
844 //=============================================================================
845 SALOME_MED::MESH::coordinateInfos * MESH_i::getCoordGlobal()
846 throw (SALOME::SALOME_Exception)
849 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
850 SALOME::INTERNAL_ERROR);
851 SALOME_MED::MESH::coordinateInfos_var all = new SALOME_MED::MESH::coordinateInfos;
854 all->coordSystem = CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
856 int spaceDimension=_mesh->getSpaceDimension();
857 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
858 const string * coordinatesName =_mesh->getCoordinatesNames();
860 all->coordUnits.length(spaceDimension);
861 all->coordNames.length(spaceDimension);
862 for (int i=0; i<spaceDimension; i++)
864 all->coordUnits[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
865 all->coordNames[i]=CORBA::string_dup(coordinatesName[i].c_str());
868 catch (MEDEXCEPTION &ex)
870 MESSAGE("Unable to acces coordinate information ");
871 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
875 //=============================================================================
877 * CORBA: Returns connectivity global informations
879 //=============================================================================
880 SALOME_MED::MESH::connectivityInfos * MESH_i::getConnectGlobal
881 (SALOME_MED::medEntityMesh entity)
882 throw (SALOME::SALOME_Exception)
885 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
886 SALOME::INTERNAL_ERROR);
887 SALOME_MED::MESH::connectivityInfos_var all=new SALOME_MED::MESH::connectivityInfos;
890 all->numberOfNodes = _mesh->getNumberOfNodes();
892 int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
893 const medGeometryElement * elemts =_mesh->getTypes(
894 convertIdlEntToMedEnt(entity));
895 all->meshTypes.length(nbTypes);
896 all->numberOfElements.length(nbTypes);
897 all->entityDimension=_mesh->getConnectivityptr()->getEntityDimension();
898 for (int i=0; i<nbTypes; i++)
900 all->meshTypes[i]=convertMedEltToIdlElt(elemts[i]);
901 all->numberOfElements[i]=_mesh->getNumberOfElements(
902 convertIdlEntToMedEnt(entity),elemts[i]);
905 catch (MEDEXCEPTION &ex)
907 MESSAGE("Unable to acces connectivities informations");
908 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
913 //=============================================================================
915 * CORBA: Returns references for family i within the mesh
917 //=============================================================================
918 SALOME_MED::FAMILY_ptr MESH_i::getFamily(SALOME_MED::medEntityMesh entity,
920 throw (SALOME::SALOME_Exception)
923 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
924 SALOME::INTERNAL_ERROR);
927 const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
928 FAMILY_i * f1=new FAMILY_i(fam);
929 return f1->POA_SALOME_MED::FAMILY::_this();
931 catch (MEDEXCEPTION &ex)
933 MESSAGE("Unable to acces specified family of the mesh");
934 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
938 //=============================================================================
940 * CORBA: Returns Mesh global informations
942 //=============================================================================
943 SALOME_MED::MESH::meshInfos * MESH_i::getMeshGlobal()
944 throw (SALOME::SALOME_Exception)
947 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
948 SALOME::INTERNAL_ERROR);
949 SALOME_MED::MESH::meshInfos_var all = new SALOME_MED::MESH::meshInfos;
952 all->name = CORBA::string_dup(_mesh->getName().c_str());
953 all->spaceDimension = _mesh->getSpaceDimension();
954 all->meshDimension = _mesh->getMeshDimension();
955 all->numberOfNodes = _mesh->getNumberOfNodes();
956 all->isAGrid = _mesh->getIsAGrid();
958 int nbFam= _mesh->getNumberOfFamilies(MED_NODE);
959 all->famNode.length(nbFam);
960 vector<FAMILY*> vNode (nbFam);
961 vNode = _mesh->getFamilies(MED_NODE);
962 for (int i=0;i<nbFam;i++)
964 FAMILY_i * f1=new FAMILY_i(vNode[i]);
965 all->famNode[i] = f1->POA_SALOME_MED::FAMILY::_this();
968 nbFam = _mesh->getNumberOfFamilies(MED_EDGE);
969 all->famEdge.length(nbFam);
970 vector<FAMILY*> vEdge (nbFam);
971 vEdge = _mesh->getFamilies(MED_EDGE);
972 for (int i=0;i<nbFam;i++)
973 for (int i=0;i<nbFam;i++)
975 FAMILY_i * f1=new FAMILY_i(vEdge[i]);
976 all->famEdge[i] = f1->POA_SALOME_MED::FAMILY::_this();
979 nbFam = _mesh->getNumberOfFamilies(MED_FACE);
980 all->famFace.length(nbFam);
981 vector<FAMILY*> vFace (nbFam);
982 vFace = _mesh->getFamilies(MED_FACE);
983 for (int i=0;i<nbFam;i++)
985 FAMILY_i * f1=new FAMILY_i(vFace[i]);
986 all->famFace[i] = f1->POA_SALOME_MED::FAMILY::_this();
989 nbFam = _mesh->getNumberOfFamilies(MED_CELL);
990 all->famCell.length(nbFam);
991 vector<FAMILY*> vCell (nbFam);
992 vCell = _mesh->getFamilies(MED_CELL);
993 for (int i=0;i<nbFam;i++)
995 FAMILY_i * f1=new FAMILY_i(vCell[i]);
996 all->famCell[i] = f1->POA_SALOME_MED::FAMILY::_this();
999 int nbGroup = _mesh->getNumberOfGroups(MED_NODE);
1000 all->groupNode.length(nbGroup);
1001 vector<GROUP*> gNode (nbGroup);
1002 gNode = _mesh->getGroups(MED_NODE);
1003 for (int i=0;i<nbGroup;i++)
1005 GROUP_i * f1=new GROUP_i(gNode[i]);
1006 all->groupNode[i] = f1->POA_SALOME_MED::GROUP::_this();
1009 nbGroup = _mesh->getNumberOfGroups(MED_EDGE);
1010 all->groupEdge.length(nbGroup);
1011 vector<GROUP*> gEdge (nbGroup);
1012 gEdge = _mesh->getGroups(MED_EDGE);
1013 for (int i=0;i<nbGroup;i++)
1015 GROUP_i * f1=new GROUP_i(gEdge[i]);
1016 all->groupEdge[i] = f1->POA_SALOME_MED::GROUP::_this();
1018 nbGroup = _mesh->getNumberOfGroups(MED_FACE);
1019 all->groupFace.length(nbGroup);
1020 vector<GROUP*> gFace (nbGroup);
1021 gFace = _mesh->getGroups(MED_FACE);
1022 for (int i=0;i<nbGroup;i++)
1024 GROUP_i * f1=new GROUP_i(gFace[i]);
1025 all->groupFace[i] = f1->POA_SALOME_MED::GROUP::_this();
1028 nbGroup = _mesh->getNumberOfGroups(MED_CELL);
1029 all->groupCell.length(nbGroup);
1030 vector<GROUP*> gCell (nbGroup);
1031 gCell = _mesh->getGroups(MED_CELL);
1032 for (int i=0;i<nbGroup;i++)
1034 GROUP_i * f1=new GROUP_i(gCell[i]);
1035 all->groupCell[i] = f1->POA_SALOME_MED::GROUP::_this();
1039 catch (MEDEXCEPTION &ex)
1041 MESSAGE("Unable to acces mesh");
1042 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1046 //=============================================================================
1048 * CORBA: Returns references for groups within the mesh
1050 //=============================================================================
1051 SALOME_MED::Group_array * MESH_i::getGroups(SALOME_MED::medEntityMesh entity)
1052 throw (SALOME::SALOME_Exception)
1055 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1056 SALOME::INTERNAL_ERROR);
1057 SALOME_MED::Group_array_var myseq = new SALOME_MED::Group_array;
1060 int nbgroups = _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
1061 myseq->length(nbgroups);
1062 vector<GROUP*> groups(nbgroups);
1063 groups = _mesh->getGroups(convertIdlEntToMedEnt(entity));
1064 for (int i=0;i<nbgroups;i++)
1066 GROUP_i * f1=new GROUP_i(groups[i]);
1067 myseq[i] = f1->POA_SALOME_MED::GROUP::_this();
1070 catch (MEDEXCEPTION &ex)
1072 MESSAGE("Unable to acces number of groups of the mesh");
1073 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1075 return myseq._retn();
1077 //=============================================================================
1079 * CORBA: Returns references for group i within the mesh
1081 //=============================================================================
1082 SALOME_MED::GROUP_ptr MESH_i::getGroup(SALOME_MED::medEntityMesh entity,
1084 throw (SALOME::SALOME_Exception)
1087 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1088 SALOME::INTERNAL_ERROR);
1091 const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
1092 GROUP_i * f1=new GROUP_i(grou);
1093 return f1->POA_SALOME_MED::GROUP::_this();
1095 catch (MEDEXCEPTION &ex)
1097 MESSAGE("Unable to acces specified group of the mesh");
1098 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1101 //=============================================================================
1105 //=============================================================================
1106 SALOME_MED::SUPPORT_ptr MESH_i::getBoundaryElements(SALOME_MED::medEntityMesh entity)
1107 throw (SALOME::SALOME_Exception)
1110 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1111 SALOME::INTERNAL_ERROR);
1114 SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity));
1115 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1116 return mySupportI->_this();
1118 catch (MEDEXCEPTION &ex)
1120 MESSAGE("Unable to get the volume ");
1121 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1124 //=============================================================================
1128 //=============================================================================
1129 SALOME_MED::FIELD_ptr MESH_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
1130 throw (SALOME::SALOME_Exception)
1133 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1134 SALOME::INTERNAL_ERROR); try
1136 int sup = mySupport->getCorbaIndex();
1137 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1138 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1139 ::FIELD<double>*f=_mesh->getVolume( myCppSupport);
1140 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1141 return medf->_this();
1143 catch (MEDEXCEPTION &ex)
1145 MESSAGE("Unable to get the volume ");
1146 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1149 //=============================================================================
1153 //=============================================================================
1154 SALOME_MED::SUPPORT_ptr MESH_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D)
1155 throw (SALOME::SALOME_Exception)
1158 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1159 SALOME::INTERNAL_ERROR);
1162 int sup = mySupport3D->getCorbaIndex();
1163 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1164 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1165 SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport);
1166 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1167 return mySupportI->_this() ;
1169 catch (MEDEXCEPTION &ex)
1171 MESSAGE("Unable to get the volume ");
1172 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1175 //=============================================================================
1179 //=============================================================================
1180 SALOME_MED::FIELD_ptr MESH_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
1181 throw (SALOME::SALOME_Exception)
1184 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1185 SALOME::INTERNAL_ERROR);
1188 int sup = mySupport->getCorbaIndex();
1189 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1190 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1191 ::FIELD<double>*f=_mesh->getArea( myCppSupport);
1192 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1193 return medf->_this();
1195 catch (MEDEXCEPTION &ex)
1197 MESSAGE("Unable to get the area ");
1198 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1201 //=============================================================================
1205 //=============================================================================
1206 SALOME_MED::FIELD_ptr MESH_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
1207 throw (SALOME::SALOME_Exception)
1210 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1211 SALOME::INTERNAL_ERROR);
1214 int sup = mySupport->getCorbaIndex();
1215 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1216 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1217 ::FIELD<double>*f=_mesh->getLength( myCppSupport);
1218 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1219 return medf->_this();
1221 catch (MEDEXCEPTION &ex)
1223 MESSAGE("Unable to get the length ");
1224 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1227 //=============================================================================
1231 //=============================================================================
1232 SALOME_MED::FIELD_ptr MESH_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
1233 throw (SALOME::SALOME_Exception)
1236 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1237 SALOME::INTERNAL_ERROR);
1240 int sup = mySupport->getCorbaIndex();
1241 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1242 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1243 ::FIELD<double>*f=_mesh->getNormal( myCppSupport);
1244 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1245 return medf->_this();
1247 catch (MEDEXCEPTION &ex)
1249 MESSAGE("Unable to get the normal ");
1250 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1253 //=============================================================================
1257 //=============================================================================
1258 SALOME_MED::FIELD_ptr MESH_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
1259 throw (SALOME::SALOME_Exception)
1262 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1263 SALOME::INTERNAL_ERROR);
1266 int sup = mySupport->getCorbaIndex();
1267 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1268 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1269 ::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
1270 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f);
1271 return medf->_this();
1273 catch (MEDEXCEPTION &ex)
1275 MESSAGE("Unable to get the barycenter ");
1276 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1279 //=============================================================================
1283 //=============================================================================
1284 SALOME_MED::FIELD_ptr MESH_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
1285 throw (SALOME::SALOME_Exception)
1288 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1289 SALOME::INTERNAL_ERROR);
1290 MESSAGE("Not Implemented");
1292 //=============================================================================
1294 * CORBA: add the Mesh in the StudyManager
1296 //=============================================================================
1297 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor )
1298 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1300 BEGIN_OF("MED_Mesh_i::addInStudy");
1301 if ( _meshId != "" )
1303 MESSAGE("Mesh already in Study");
1304 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1308 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1309 SALOMEDS::GenericAttribute_var anAttr;
1310 SALOMEDS::AttributeName_var aName;
1311 SALOMEDS::AttributeIOR_var aIOR;
1313 // Find SComponent labelled 'MED'
1314 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1315 myBuilder->NewCommand();
1316 if ( CORBA::is_nil(medfather) )
1317 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1319 // Create SObject labelled 'MESH' if it doesn't already exit
1320 // SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1321 // if ( CORBA::is_nil(medmeshfather) )
1323 // MESSAGE("Add Object MEDMESH");
1324 // medmeshfather = myBuilder->NewObject(medfather);
1325 // //medmeshfather.Name = "MEDMESH" ;
1326 // anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1327 // aName = SALOMEDS::AttributeName::_narrow(anAttr);
1328 // aName->SetValue("MEDMESH");
1332 SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
1333 if ( CORBA::is_nil(medmeshfather) )
1335 MESSAGE("Add Object MEDMESH");
1337 myBuilder->AddDirectory("/Med/MEDMESH");
1338 medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
1341 MESSAGE("Add a mesh Object under MED/MEDMESH");
1342 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
1344 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1345 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1346 CORBA::ORB_var &orb = init(0,0);
1347 string iorStr = orb->object_to_string(myIor);
1348 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1349 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1350 aIOR->SetValue(iorStr.c_str());
1351 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1352 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1353 aName->SetValue(_mesh->getName().c_str());
1354 _meshId = newObj->GetID();
1355 myBuilder->CommitCommand();
1357 END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
1359 //=============================================================================
1361 * CORBA: add the Mesh in the StudyManager
1363 //=============================================================================
1364 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor,const string & fileName )
1365 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1367 BEGIN_OF("MED_Mesh_i::addInStudy");
1368 if ( _meshId != "" )
1370 MESSAGE("Mesh already in Study");
1371 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1375 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1376 SALOMEDS::GenericAttribute_var anAttr;
1377 SALOMEDS::AttributeName_var aName;
1378 SALOMEDS::AttributeIOR_var aIOR;
1379 SALOMEDS::AttributeComment_var aComment;
1381 // Find SComponent labelled 'Med'
1382 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1383 if ( CORBA::is_nil(medfather) )
1384 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1386 // Create SObject labelled 'MESH' if it doesn't already exit
1387 SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1388 if ( CORBA::is_nil(medmeshfather) )
1390 MESSAGE("Add Object MEDMESH");
1391 medmeshfather = myBuilder->NewObject(medfather);
1392 //medmeshfather.Name = "MEDMESH" ;
1393 anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1394 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1395 aName->SetValue("MEDMESH");
1399 MESSAGE("Add a mesh Object under MED/MEDMESH");
1400 myBuilder->NewCommand();
1401 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
1403 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1404 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1405 CORBA::ORB_var &orb = init(0,0);
1406 string iorStr = orb->object_to_string(myIor);
1407 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1408 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1409 aIOR->SetValue(iorStr.c_str());
1410 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1411 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1412 aName->SetValue(_mesh->getName().c_str());
1413 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
1414 aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1415 aComment->SetValue(fileName.c_str());
1416 _meshId = newObj->GetID();
1417 myBuilder->CommitCommand();
1419 END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
1421 //=============================================================================
1423 //=============================================================================
1425 * CORBA: write mesh in a med file
1427 //=============================================================================
1428 void MESH_i::write(CORBA::Long i, const char* driverMeshName)
1429 throw (SALOME::SALOME_Exception)
1432 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1433 SALOME::INTERNAL_ERROR);
1436 _mesh->write(i,driverMeshName);
1438 catch (MEDEXCEPTION &ex)
1440 MESSAGE("Unable to write the mesh ");
1441 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1444 //=============================================================================
1446 * CORBA: read mesh in a med file
1448 //=============================================================================
1449 void MESH_i::read(CORBA::Long i)
1450 throw (SALOME::SALOME_Exception)
1453 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1454 SALOME::INTERNAL_ERROR);
1459 catch (MEDEXCEPTION &ex)
1461 MESSAGE("Unable to read the mesh ");
1462 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1465 //=============================================================================
1467 * CORBA : release driver
1469 //=============================================================================
1470 void MESH_i::rmDriver(CORBA::Long i)
1471 throw (SALOME::SALOME_Exception)
1474 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1475 SALOME::INTERNAL_ERROR);
1480 catch (MEDEXCEPTION &ex)
1482 MESSAGE("Unable to unlink the mesh from the driver ");
1483 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1484 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
1485 ,SALOME::INTERNAL_ERROR);
1488 //=============================================================================
1490 * CORBA : attach driver
1492 //=============================================================================
1493 CORBA::Long MESH_i::addDriver(SALOME_MED::medDriverTypes driverType,
1494 const char* fileName, const char* meshName)
1495 throw (SALOME::SALOME_Exception)
1498 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1499 SALOME::INTERNAL_ERROR);
1502 int drivernum=_mesh->addDriver(
1503 convertIdlDriverToMedDriver(driverType),
1508 catch (MEDEXCEPTION &ex)
1510 MESSAGE("Unable to link the mesh to the driver ");
1511 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1515 //=============================================================================
1517 * CORBA : Test if this and other aggregate the same MESH using the virtual MESH::operator==
1519 //=============================================================================
1520 CORBA::Boolean MESH_i::areEquals(SALOME_MED::MESH_ptr other)
1522 PortableServer::ServantBase *baseServ;
1524 baseServ=_default_POA()->reference_to_servant(other);
1531 baseServ->_remove_ref();
1532 MESH_i *otherServ=dynamic_cast<MESH_i *>(baseServ);
1533 return *_mesh==*otherServ->_mesh;