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"
27 using namespace MEDMEM;
29 // Initialisation des variables statiques
30 map < int, ::MESH *> MESH_i::meshMap ;
31 int MESH_i::meshIndex = 0 ;
35 //=============================================================================
39 //=============================================================================
40 MESH_i::MESH_i(): _mesh(constructConstMesh()),
41 _corbaIndex(MESH_i::meshIndex++),
44 BEGIN_OF("Default Constructor MESH_i");
45 MESH_i::meshMap[_corbaIndex]=_mesh;
46 END_OF("Default Constructor MESH_i");
48 //=============================================================================
52 //=============================================================================
56 //=============================================================================
60 //=============================================================================
61 MESH_i::MESH_i(::MESH * const m ) :_mesh(m),
62 _corbaIndex(MESH_i::meshIndex++),
65 BEGIN_OF("Constructor MESH_i(::MESH * const m )");
66 MESH_i::meshMap[_corbaIndex]=_mesh;
69 END_OF("Constructor MESH_i(::MESH * const m )");
71 //=============================================================================
75 //=============================================================================
76 //MESH_i::MESH_i(const MESH_i & m) :_mesh(m._mesh),
77 MESH_i::MESH_i( MESH_i & m) :_mesh(m._mesh),
78 _corbaIndex(MESH_i::meshIndex++),
81 BEGIN_OF("Constructor MESH_i");
82 MESH_i::meshMap[_corbaIndex]=_mesh;
83 END_OF("Constructor MESH_i");
85 //=============================================================================
87 * Internal Method in order to have a const ptr
89 //=============================================================================
90 ::MESH * MESH_i::constructConstMesh() const
92 ::MESH * const ptrMesh =new ::MESH();
95 //=============================================================================
97 * CORBA: Accessor for Name
99 //=============================================================================
100 char * MESH_i::getName()
101 throw (SALOME::SALOME_Exception)
104 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
105 SALOME::INTERNAL_ERROR);
109 return CORBA::string_dup(_mesh->getName().c_str());
111 catch (MEDEXCEPTION &ex)
113 MESSAGE("Unable to acces the mesh name");
114 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
117 //=============================================================================
119 * CORBA: Accessor for corbaindex cuisine interne
121 //=============================================================================
122 CORBA::Long MESH_i::getCorbaIndex()
123 throw (SALOME::SALOME_Exception)
126 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
127 SALOME::INTERNAL_ERROR);
130 //=============================================================================
132 * CORBA: Accessor for Space Dimension
134 //=============================================================================
135 CORBA::Long MESH_i::getSpaceDimension()
136 throw (SALOME::SALOME_Exception)
139 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
140 SALOME::INTERNAL_ERROR);
143 return _mesh->getSpaceDimension();
145 catch (MEDEXCEPTION &ex)
147 MESSAGE("Unable to acces the space dimension ");
148 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
151 //=============================================================================
153 * CORBA: Accessor for Mesh Dimension
155 //=============================================================================
156 CORBA::Long MESH_i::getMeshDimension()
157 throw (SALOME::SALOME_Exception)
160 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
161 SALOME::INTERNAL_ERROR);
164 return _mesh->getMeshDimension();
166 catch (MEDEXCEPTION &ex)
168 MESSAGE("Unable to acces the mesh dimension ");
169 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
172 //=============================================================================
174 * CORBA: boolean indicating if mesh is a Grid
176 //=============================================================================
177 CORBA::Boolean MESH_i::getIsAGrid()
178 throw (SALOME::SALOME_Exception)
181 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
182 SALOME::INTERNAL_ERROR);
185 return _mesh->getIsAGrid();
187 catch (MEDEXCEPTION &ex)
189 MESSAGE("Unable to acces mesh flag isAGrid");
190 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
193 //=============================================================================
195 * CORBA: boolean indicating if connectivity exists
197 //=============================================================================
198 CORBA::Boolean MESH_i::existConnectivity
199 (SALOME_MED::medConnectivity connectivityType,
200 SALOME_MED::medEntityMesh entity)
201 throw (SALOME::SALOME_Exception)
204 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
205 SALOME::INTERNAL_ERROR);
208 return _mesh->existConnectivity(connectivityType,
209 convertIdlEntToMedEnt(entity)); }
210 catch (MEDEXCEPTION &ex)
212 MESSAGE("Unable to acces mesh flag existConnectivity");
213 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
217 //=============================================================================
219 * CORBA: Accessor for Coordinates System
221 //=============================================================================
222 char * MESH_i::getCoordinatesSystem()
223 throw (SALOME::SALOME_Exception)
226 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
227 SALOME::INTERNAL_ERROR);
231 return CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
233 catch (MEDEXCEPTION &ex)
235 MESSAGE("Unable to acces the type of CoordinatesSystem");
236 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
239 //=============================================================================
241 * CORBA: Accessor for a specific coordinate
243 //=============================================================================
244 CORBA::Double MESH_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis)
245 throw (SALOME::SALOME_Exception)
248 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
249 SALOME::INTERNAL_ERROR);
252 return _mesh->getCoordinate(Number,Axis);
254 catch (MEDEXCEPTION &ex)
256 MESSAGE("Unable to acces this coordinate");
257 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
260 //=============================================================================
262 * CORBA: Accessor for Coordinates
264 //=============================================================================
265 SALOME_MED::double_array * MESH_i::getCoordinates(SALOME_MED::medModeSwitch typeSwitch)
266 throw (SALOME::SALOME_Exception)
269 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
270 SALOME::INTERNAL_ERROR);
271 SALOME_MED::double_array_var myseq = new SALOME_MED::double_array;
274 int spaceDimension=_mesh->getSpaceDimension();
275 int nbNodes=_mesh->getNumberOfNodes();
276 const double * coordinates =_mesh->getCoordinates(
277 convertIdlModeToMedMode(typeSwitch));
279 myseq->length(nbNodes*spaceDimension);
280 for (int i=0; i<nbNodes*spaceDimension; i++)
282 myseq[i]=coordinates[i];
285 catch (MEDEXCEPTION &ex)
287 MESSAGE("Unable to acces the coordinates");
288 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
290 return myseq._retn();
292 //=============================================================================
294 * CORBA: Accessor for Coordinates Names
296 //=============================================================================
297 SALOME_MED::string_array * MESH_i::getCoordinatesNames()
298 throw (SALOME::SALOME_Exception)
301 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
302 SALOME::INTERNAL_ERROR);
303 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
306 int spaceDimension=_mesh->getSpaceDimension();
307 const string * coordinatesName =_mesh->getCoordinatesNames();
308 myseq->length(spaceDimension);
309 for (int i=0; i<spaceDimension; i++)
311 myseq[i]=CORBA::string_dup(coordinatesName[i].c_str());
314 catch (MEDEXCEPTION &ex)
316 MESSAGE("Unable to acces the coordinates names");
317 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
319 return myseq._retn();
322 //=============================================================================
324 * CORBA: Accessor for Coordinates Units
326 //=============================================================================
327 SALOME_MED::string_array * MESH_i::getCoordinatesUnits()
328 throw (SALOME::SALOME_Exception)
331 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
332 SALOME::INTERNAL_ERROR);
333 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
336 int spaceDimension=_mesh->getSpaceDimension();
337 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
338 myseq->length(spaceDimension);
339 for (int i=0; i<spaceDimension; i++)
341 myseq[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
344 catch (MEDEXCEPTION &ex)
346 MESSAGE("Unable to acces the coordinates units");
347 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
349 return myseq._retn();
351 //=============================================================================
353 * CORBA: Accessor for Number of Nodes
355 //=============================================================================
356 CORBA::Long MESH_i::getNumberOfNodes()
357 throw (SALOME::SALOME_Exception)
360 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
361 SALOME::INTERNAL_ERROR);
364 return _mesh->getNumberOfNodes();
366 catch (MEDEXCEPTION &ex)
368 MESSAGE("Unable to acces number of nodes");
369 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
372 //=============================================================================
374 * CORBA: Accessor for number of Types
376 //=============================================================================
377 CORBA::Long MESH_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity)
378 throw (SALOME::SALOME_Exception)
381 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
382 SALOME::INTERNAL_ERROR);
385 return _mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
387 catch (MEDEXCEPTION &ex)
389 MESSAGE("Unable to acces number of differents types");
390 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
393 //=============================================================================
395 * CORBA: Accessor for existing geometry element types
397 //=============================================================================
398 SALOME_MED::medGeometryElement MESH_i::getElementType (SALOME_MED::medEntityMesh entity,
400 throw (SALOME::SALOME_Exception)
403 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
404 SALOME::INTERNAL_ERROR);
407 return _mesh->getElementType(convertIdlEntToMedEnt(entity),number);
409 catch (MEDEXCEPTION &ex)
411 MESSAGE("Unable to acces number of differents element types");
412 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
416 //=============================================================================
418 * CORBA: Accessor for existing geometry element types
419 * Not implemented for MED_ALL_ENTITIES
421 //=============================================================================
422 SALOME_MED::medGeometryElement_array * MESH_i::getTypes (SALOME_MED::medEntityMesh entity)
423 throw (SALOME::SALOME_Exception)
426 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
427 SALOME::INTERNAL_ERROR);
428 if (entity ==SALOME_MED::MED_ALL_ENTITIES)
429 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\
431 SALOME_MED::medGeometryElement_array_var myseq =
432 new SALOME_MED::medGeometryElement_array;
435 int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
436 const medGeometryElement * elemts =_mesh->getTypes(
437 convertIdlEntToMedEnt(entity));
438 myseq->length(nbTypes);
439 for (int i=0; i<nbTypes; i++)
441 myseq[i]=convertMedEltToIdlElt(elemts[i]);
444 catch (MEDEXCEPTION &ex)
446 MESSAGE("Unable to acces coordinates");
447 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
449 return myseq._retn();
451 //=============================================================================
453 * CORBA: Returns number of elements of type medGeometryElement
454 * Not implemented for MED_ALL_ELEMENTS
455 * implemented for MED_ALL_ENTITIES
457 //=============================================================================
458 CORBA::Long MESH_i::getNumberOfElements(SALOME_MED::medEntityMesh entity,
459 SALOME_MED::medGeometryElement geomElement)
460 throw (SALOME::SALOME_Exception)
463 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
464 SALOME::INTERNAL_ERROR);
465 if (verifieParam(entity,geomElement)==false)
466 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
471 return _mesh->getNumberOfElements(convertIdlEntToMedEnt(entity),
472 convertIdlEltToMedElt(geomElement));
474 catch (MEDEXCEPTION &ex)
476 MESSAGE("Unable to acces number of elements");
477 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
480 //=============================================================================
482 * CORBA: Accessor for connectivities
484 //=============================================================================
485 SALOME_MED::long_array * MESH_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
486 SALOME_MED::medConnectivity mode,
487 SALOME_MED::medEntityMesh entity,
488 SALOME_MED::medGeometryElement geomElement)
489 throw (SALOME::SALOME_Exception)
492 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
493 SALOME::INTERNAL_ERROR);
494 if (verifieParam(entity,geomElement)==false)
495 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
497 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
501 int elt1 = _mesh->getNumberOfElements(
502 convertIdlEntToMedEnt(entity),
503 convertIdlEltToMedElt(geomElement));
505 if ( mode == SALOME_MED::MED_DESCENDING)
507 MESSAGE("MED_DESCENDING");
508 int elt2 =(_mesh->getCellsTypes(MED_CELL))->getNumberOfConstituents(1);
509 //int elt2 =(_mesh->getTypes(convertIdlEltToMedElt(geomElement)))->getNumberOfConstituents(1);
510 nbelements= elt2 * elt1;
515 MESSAGE("MED_NODAL");
516 const int * tab=_mesh->getConnectivityIndex(
517 convertIdlConnToMedConn(mode),
518 convertIdlEntToMedEnt(entity));
519 nbelements = elt1*(convertIdlEltToMedElt(geomElement)%100);
520 // nbelements = tab[elt1 ] - 1 ;
525 myseq->length(nbelements);
526 const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch),
527 convertIdlConnToMedConn(mode),
528 convertIdlEntToMedEnt(entity),
529 convertIdlEltToMedElt(geomElement));
530 for (int i=0;i<nbelements;i++)
535 catch (MEDEXCEPTION &ex)
537 MESSAGE("Unable to acces connectivities");
538 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
540 return myseq._retn();
542 //=============================================================================
544 * CORBA: Accessor for connectivities
546 //=============================================================================
547 SALOME_MED::long_array* MESH_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
548 SALOME_MED::medEntityMesh entity)
549 throw (SALOME::SALOME_Exception)
552 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
553 SALOME::INTERNAL_ERROR);
554 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
557 int nbelements = _mesh->getNumberOfElements(
558 convertIdlEntToMedEnt(entity),
560 myseq->length(nbelements);
561 const int * numbers=_mesh->getConnectivityIndex(convertIdlConnToMedConn(mode),
562 convertIdlEntToMedEnt(entity));
563 for (int i=0;i<nbelements;i++)
568 catch (MEDEXCEPTION &ex)
570 MESSAGE("Unable to acces connectivities index");
571 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
573 return myseq._retn();
575 //=============================================================================
577 * CORBA: Accessor for connectivities
579 //=============================================================================
580 SALOME_MED::long_array* MESH_i::getGlobalNumberingIndex( SALOME_MED::medEntityMesh entity)
581 throw (SALOME::SALOME_Exception)
584 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
585 SALOME::INTERNAL_ERROR);
586 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
589 int nbelements = _mesh->getNumberOfTypes( convertIdlEntToMedEnt(entity)) + 1;
590 myseq->length(nbelements);
591 const int * numbers=_mesh->getGlobalNumberingIndex( convertIdlEntToMedEnt(entity));
592 for (int i=0;i<nbelements;i++)
597 catch (MEDEXCEPTION &ex)
599 MESSAGE("Unable to acces global index");
600 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
602 return myseq._retn();
605 //=============================================================================
607 * CORBA: get global element number in connectivity array
608 * not implemented for MED_NODE and MED_ALL_ENTITIES,
609 * MED_NONE and MED_ALL_ELEMENTS.
611 //=============================================================================
612 CORBA::Long MESH_i::getElementNumber(SALOME_MED::medConnectivity mode,
613 SALOME_MED::medEntityMesh entity,
614 SALOME_MED::medGeometryElement type,
615 const SALOME_MED::long_array& connectivity)
616 throw (SALOME::SALOME_Exception)
619 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR);
620 int numberOfValue = connectivity.length() ;
621 int * myConnectivity = new int[numberOfValue] ;
622 for (int i=0; i<numberOfValue; i++)
623 myConnectivity[i]=connectivity[i] ;
627 result = _mesh->getElementNumber(convertIdlConnToMedConn(mode),
628 convertIdlEntToMedEnt(entity),
629 convertIdlEltToMedElt(type),
632 catch (MEDEXCEPTION &ex) {
633 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
637 //=============================================================================
639 * CORBA: Accessor for Ascendant connectivities
640 * not implemented for MED_ALL_ENTITIES and MED_MAILLE
642 //=============================================================================
643 SALOME_MED::long_array* MESH_i::getReverseConnectivity(SALOME_MED::medConnectivity mode)
644 throw (SALOME::SALOME_Exception)
647 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
648 SALOME::INTERNAL_ERROR);
649 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
653 if ( mode == SALOME_MED::MED_DESCENDING)
655 nbelements =(_mesh->getNumberOfNodes())+1;
659 nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
662 myseq->length(nbelements);
663 const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode));
664 for (int i=0;i<nbelements;i++)
669 catch (MEDEXCEPTION &ex)
671 MESSAGE("Unable to acces reverse connectivities");
672 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
674 return myseq._retn();
676 //=============================================================================
678 * CORBA: Accessor for connectivities
680 //=============================================================================
681 SALOME_MED::long_array* MESH_i::getReverseConnectivityIndex(SALOME_MED::medConnectivity mode)
682 throw (SALOME::SALOME_Exception)
685 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
686 SALOME::INTERNAL_ERROR);
687 SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
691 if ( mode == SALOME_MED::MED_DESCENDING)
693 nbelements =_mesh->getNumberOfNodes();
697 int dim=_mesh->getMeshDimension();
699 nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
702 nbelements = _mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS);
704 THROW_SALOME_CORBA_EXCEPTION("Pb ", \
705 SALOME::INTERNAL_ERROR);
708 myseq->length(nbelements);
709 const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode));
710 for (int i=0;i<nbelements;i++)
715 catch (MEDEXCEPTION &ex)
717 MESSAGE("Unable to acces reverse connectivities index");
718 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
720 return myseq._retn();
722 //=============================================================================
724 * CORBA: Returns number of families within the mesh
726 //=============================================================================
727 CORBA::Long MESH_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
728 throw (SALOME::SALOME_Exception)
731 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
732 SALOME::INTERNAL_ERROR);
735 return _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
737 catch (MEDEXCEPTION &ex)
739 MESSAGE("Unable to acces number of families of the mesh");
740 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
743 //=============================================================================
745 * CORBA: Returns number of groups within the mesh
747 //=============================================================================
748 CORBA::Long MESH_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity)
749 throw (SALOME::SALOME_Exception)
752 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
753 SALOME::INTERNAL_ERROR);
756 return _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
758 catch (MEDEXCEPTION &ex)
760 MESSAGE("Unable to acces number of groups of the mesh");
761 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
764 //=============================================================================
766 * CORBA: Returns references for families within the mesh
768 //=============================================================================
769 SALOME_MED::Family_array * MESH_i::getFamilies(SALOME_MED::medEntityMesh entity)
770 throw (SALOME::SALOME_Exception)
773 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
774 SALOME::INTERNAL_ERROR);
775 SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
778 int nbfam= _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
779 myseq->length(nbfam);
780 vector<FAMILY*> fam(nbfam);
781 fam = _mesh->getFamilies(convertIdlEntToMedEnt(entity));
782 for (int i=0;i<nbfam;i++)
784 FAMILY_i * f1=new FAMILY_i(fam[i]);
785 SALOME_MED::FAMILY_ptr f2 =
786 f1->POA_SALOME_MED::FAMILY::_this();
791 catch (MEDEXCEPTION &ex)
793 MESSAGE("Unable to acces families of the mesh");
794 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
796 return myseq._retn();
798 //=============================================================================
800 * CORBA: Returns Coordinates global informations
802 //=============================================================================
803 SALOME_MED::MESH::coordinateInfos * MESH_i::getCoordGlobal()
804 throw (SALOME::SALOME_Exception)
807 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
808 SALOME::INTERNAL_ERROR);
809 SALOME_MED::MESH::coordinateInfos_var all = new SALOME_MED::MESH::coordinateInfos;
812 all->coordSystem = CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
814 int spaceDimension=_mesh->getSpaceDimension();
815 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
816 const string * coordinatesName =_mesh->getCoordinatesNames();
818 all->coordUnits.length(spaceDimension);
819 all->coordNames.length(spaceDimension);
820 for (int i=0; i<spaceDimension; i++)
822 all->coordUnits[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
823 all->coordNames[i]=CORBA::string_dup(coordinatesName[i].c_str());
826 catch (MEDEXCEPTION &ex)
828 MESSAGE("Unable to acces coordinate information ");
829 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
833 //=============================================================================
835 * CORBA: Returns connectivity global informations
837 //=============================================================================
838 SALOME_MED::MESH::connectivityInfos * MESH_i::getConnectGlobal
839 (SALOME_MED::medEntityMesh entity)
840 throw (SALOME::SALOME_Exception)
843 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
844 SALOME::INTERNAL_ERROR);
845 SALOME_MED::MESH::connectivityInfos_var all=new SALOME_MED::MESH::connectivityInfos;
848 all->numberOfNodes = _mesh->getNumberOfNodes();
850 int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
851 const medGeometryElement * elemts =_mesh->getTypes(
852 convertIdlEntToMedEnt(entity));
853 all->meshTypes.length(nbTypes);
854 all->numberOfElements.length(nbTypes);
855 for (int i=0; i<nbTypes; i++)
857 all->meshTypes[i]=convertMedEltToIdlElt(elemts[i]);
858 all->numberOfElements[i]=_mesh->getNumberOfElements(
859 convertIdlEntToMedEnt(entity),elemts[i]);
862 catch (MEDEXCEPTION &ex)
864 MESSAGE("Unable to acces connectivities informations");
865 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
870 //=============================================================================
872 * CORBA: Returns references for family i within the mesh
874 //=============================================================================
875 SALOME_MED::FAMILY_ptr MESH_i::getFamily(SALOME_MED::medEntityMesh entity,
877 throw (SALOME::SALOME_Exception)
880 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
881 SALOME::INTERNAL_ERROR);
884 const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
885 FAMILY_i * f1=new FAMILY_i(fam);
886 SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
888 return (SALOME_MED::FAMILY::_duplicate(f2));
890 catch (MEDEXCEPTION &ex)
892 MESSAGE("Unable to acces specified family of the mesh");
893 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
897 //=============================================================================
899 * CORBA: Returns Mesh global informations
901 //=============================================================================
902 SALOME_MED::MESH::meshInfos * MESH_i::getMeshGlobal()
903 throw (SALOME::SALOME_Exception)
906 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
907 SALOME::INTERNAL_ERROR);
908 SALOME_MED::MESH::meshInfos_var all = new SALOME_MED::MESH::meshInfos;
911 all->name = CORBA::string_dup(_mesh->getName().c_str());
912 all->spaceDimension = _mesh->getSpaceDimension();
913 all->meshDimension = _mesh->getMeshDimension();
914 all->numberOfNodes = _mesh->getNumberOfNodes();
915 all->isAGrid = _mesh->getIsAGrid();
917 int nbFam= _mesh->getNumberOfFamilies(MED_NODE);
918 all->famNode.length(nbFam);
919 vector<FAMILY*> vNode (nbFam);
920 vNode = _mesh->getFamilies(MED_NODE);
921 for (int i=0;i<nbFam;i++)
923 FAMILY_i * f1=new FAMILY_i(vNode[i]);
924 SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
926 all->famNode[i] = f2;
929 nbFam = _mesh->getNumberOfFamilies(MED_EDGE);
930 all->famEdge.length(nbFam);
931 vector<FAMILY*> vEdge (nbFam);
932 vEdge = _mesh->getFamilies(MED_EDGE);
933 for (int i=0;i<nbFam;i++)
934 for (int i=0;i<nbFam;i++)
936 FAMILY_i * f1=new FAMILY_i(vEdge[i]);
937 SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
939 all->famEdge[i] = f2;
942 nbFam = _mesh->getNumberOfFamilies(MED_FACE);
943 all->famFace.length(nbFam);
944 vector<FAMILY*> vFace (nbFam);
945 vFace = _mesh->getFamilies(MED_FACE);
946 for (int i=0;i<nbFam;i++)
948 FAMILY_i * f1=new FAMILY_i(vFace[i]);
949 SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
951 all->famFace[i] = f2;
954 nbFam = _mesh->getNumberOfFamilies(MED_CELL);
955 all->famCell.length(nbFam);
956 vector<FAMILY*> vCell (nbFam);
957 vCell = _mesh->getFamilies(MED_CELL);
958 for (int i=0;i<nbFam;i++)
960 FAMILY_i * f1=new FAMILY_i(vCell[i]);
961 SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this();
963 all->famCell[i] = f2;
966 int nbGroup = _mesh->getNumberOfGroups(MED_NODE);
967 all->groupNode.length(nbGroup);
968 vector<GROUP*> gNode (nbGroup);
969 gNode = _mesh->getGroups(MED_NODE);
970 for (int i=0;i<nbGroup;i++)
972 GROUP_i * f1=new GROUP_i(gNode[i]);
973 SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
975 all->groupNode[i] = f2;
978 nbGroup = _mesh->getNumberOfGroups(MED_EDGE);
979 all->groupEdge.length(nbGroup);
980 vector<GROUP*> gEdge (nbGroup);
981 gEdge = _mesh->getGroups(MED_EDGE);
982 for (int i=0;i<nbGroup;i++)
984 GROUP_i * f1=new GROUP_i(gEdge[i]);
985 SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
987 all->groupEdge[i] = f2;
989 nbGroup = _mesh->getNumberOfGroups(MED_FACE);
990 all->groupFace.length(nbGroup);
991 vector<GROUP*> gFace (nbGroup);
992 gFace = _mesh->getGroups(MED_FACE);
993 for (int i=0;i<nbGroup;i++)
995 GROUP_i * f1=new GROUP_i(gFace[i]);
996 SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
998 all->groupFace[i] = f2;
1001 nbGroup = _mesh->getNumberOfGroups(MED_CELL);
1002 all->groupCell.length(nbGroup);
1003 vector<GROUP*> gCell (nbGroup);
1004 gCell = _mesh->getGroups(MED_CELL);
1005 for (int i=0;i<nbGroup;i++)
1007 GROUP_i * f1=new GROUP_i(gCell[i]);
1008 SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
1010 all->groupCell[i] = f2;
1014 catch (MEDEXCEPTION &ex)
1016 MESSAGE("Unable to acces mesh");
1017 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1021 //=============================================================================
1023 * CORBA: Returns references for groups within the mesh
1025 //=============================================================================
1026 SALOME_MED::Group_array * MESH_i::getGroups(SALOME_MED::medEntityMesh entity)
1027 throw (SALOME::SALOME_Exception)
1030 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1031 SALOME::INTERNAL_ERROR);
1032 SALOME_MED::Group_array_var myseq = new SALOME_MED::Group_array;
1035 int nbgroups = _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
1036 myseq->length(nbgroups);
1037 vector<GROUP*> groups(nbgroups);
1038 groups = _mesh->getGroups(convertIdlEntToMedEnt(entity));
1039 for (int i=0;i<nbgroups;i++)
1041 GROUP_i * f1=new GROUP_i(groups[i]);
1042 SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
1047 catch (MEDEXCEPTION &ex)
1049 MESSAGE("Unable to acces number of groups of the mesh");
1050 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1052 return myseq._retn();
1054 //=============================================================================
1056 * CORBA: Returns references for group i within the mesh
1058 //=============================================================================
1059 SALOME_MED::GROUP_ptr MESH_i::getGroup(SALOME_MED::medEntityMesh entity,
1061 throw (SALOME::SALOME_Exception)
1064 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1065 SALOME::INTERNAL_ERROR);
1068 const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
1069 GROUP_i * f1=new GROUP_i(grou);
1070 SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this();
1072 return (SALOME_MED::GROUP::_duplicate(f2));
1074 catch (MEDEXCEPTION &ex)
1076 MESSAGE("Unable to acces specified group of the mesh");
1077 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1080 //=============================================================================
1084 //=============================================================================
1085 SALOME_MED::SUPPORT_ptr MESH_i::getBoundaryElements(SALOME_MED::medEntityMesh entity)
1086 throw (SALOME::SALOME_Exception)
1089 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1090 SALOME::INTERNAL_ERROR);
1093 SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity));
1094 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1095 SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ;
1096 return (SALOME_MED::SUPPORT::_duplicate(mySupportIOR));
1098 catch (MEDEXCEPTION &ex)
1100 MESSAGE("Unable to get the volume ");
1101 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1104 //=============================================================================
1108 //=============================================================================
1109 SALOME_MED::FIELD_ptr MESH_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
1110 throw (SALOME::SALOME_Exception)
1113 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1114 SALOME::INTERNAL_ERROR); try
1116 int sup = mySupport->getCorbaIndex();
1117 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1118 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1119 ::FIELD<double>*f=_mesh->getVolume( myCppSupport);
1120 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
1121 POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
1122 new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
1123 SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
1125 return (SALOME_MED::FIELD::_duplicate(f2));
1127 catch (MEDEXCEPTION &ex)
1129 MESSAGE("Unable to get the volume ");
1130 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1133 //=============================================================================
1137 //=============================================================================
1138 SALOME_MED::SUPPORT_ptr MESH_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D)
1139 throw (SALOME::SALOME_Exception)
1142 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1143 SALOME::INTERNAL_ERROR);
1146 int sup = mySupport3D->getCorbaIndex();
1147 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1148 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1149 SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport);
1150 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
1151 SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ;
1152 return (SALOME_MED::SUPPORT::_duplicate(mySupportIOR));
1154 catch (MEDEXCEPTION &ex)
1156 MESSAGE("Unable to get the volume ");
1157 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1160 //=============================================================================
1164 //=============================================================================
1165 SALOME_MED::FIELD_ptr MESH_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
1166 throw (SALOME::SALOME_Exception)
1169 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1170 SALOME::INTERNAL_ERROR);
1173 int sup = mySupport->getCorbaIndex();
1174 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1175 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1176 ::FIELD<double>*f=_mesh->getArea( myCppSupport);
1177 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
1178 POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
1179 new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
1180 SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
1182 return (SALOME_MED::FIELD::_duplicate(f2));
1184 catch (MEDEXCEPTION &ex)
1186 MESSAGE("Unable to get the area ");
1187 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1190 //=============================================================================
1194 //=============================================================================
1195 SALOME_MED::FIELD_ptr MESH_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
1196 throw (SALOME::SALOME_Exception)
1199 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1200 SALOME::INTERNAL_ERROR);
1203 int sup = mySupport->getCorbaIndex();
1204 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1205 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1206 ::FIELD<double>*f=_mesh->getLength( myCppSupport);
1207 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
1208 POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
1209 new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
1210 SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
1212 return (SALOME_MED::FIELD::_duplicate(f2));
1214 catch (MEDEXCEPTION &ex)
1216 MESSAGE("Unable to get the length ");
1217 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1220 //=============================================================================
1224 //=============================================================================
1225 SALOME_MED::FIELD_ptr MESH_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
1226 throw (SALOME::SALOME_Exception)
1229 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1230 SALOME::INTERNAL_ERROR);
1233 int sup = mySupport->getCorbaIndex();
1234 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1235 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1236 ::FIELD<double>*f=_mesh->getNormal( myCppSupport);
1237 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
1238 POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
1239 new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
1240 SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
1242 return (SALOME_MED::FIELD::_duplicate(f2));
1244 catch (MEDEXCEPTION &ex)
1246 MESSAGE("Unable to get the normal ");
1247 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1250 //=============================================================================
1254 //=============================================================================
1255 SALOME_MED::FIELD_ptr MESH_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
1256 throw (SALOME::SALOME_Exception)
1259 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1260 SALOME::INTERNAL_ERROR);
1263 int sup = mySupport->getCorbaIndex();
1264 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
1265 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
1266 ::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
1267 FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(mySupport,f);
1268 POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i> * f1 =
1269 new POA_SALOME_MED::FIELDDOUBLE_tie<FIELDDOUBLE_i>(medf,true);
1270 SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this();
1272 return (SALOME_MED::FIELD::_duplicate(f2));
1274 catch (MEDEXCEPTION &ex)
1276 MESSAGE("Unable to get the barycenter ");
1277 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1280 //=============================================================================
1284 //=============================================================================
1285 SALOME_MED::FIELD_ptr MESH_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
1286 throw (SALOME::SALOME_Exception)
1289 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1290 SALOME::INTERNAL_ERROR);
1291 MESSAGE("Not Implemented");
1293 //=============================================================================
1295 * CORBA: add the Mesh in the StudyManager
1297 //=============================================================================
1298 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor )
1299 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1301 BEGIN_OF("MED_Mesh_i::addInStudy");
1302 if ( _meshId != "" )
1304 MESSAGE("Mesh already in Study");
1305 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1309 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1310 SALOMEDS::GenericAttribute_var anAttr;
1311 SALOMEDS::AttributeName_var aName;
1312 SALOMEDS::AttributeIOR_var aIOR;
1314 // Find SComponent labelled 'MED'
1315 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1316 myBuilder->NewCommand();
1317 if ( CORBA::is_nil(medfather) )
1318 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1320 // Create SObject labelled 'MESH' if it doesn't already exit
1321 // SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1322 // if ( CORBA::is_nil(medmeshfather) )
1324 // MESSAGE("Add Object MEDMESH");
1325 // medmeshfather = myBuilder->NewObject(medfather);
1326 // //medmeshfather.Name = "MEDMESH" ;
1327 // anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1328 // aName = SALOMEDS::AttributeName::_narrow(anAttr);
1329 // aName->SetValue("MEDMESH");
1333 SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
1334 if ( CORBA::is_nil(medmeshfather) )
1336 MESSAGE("Add Object MEDMESH");
1338 myBuilder->AddDirectory("/Med/MEDMESH");
1339 medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
1342 MESSAGE("Add a mesh Object under MED/MEDMESH");
1343 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
1345 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1346 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1347 CORBA::ORB_var &orb = init(0,0);
1348 string iorStr = orb->object_to_string(myIor);
1349 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1350 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1351 aIOR->SetValue(iorStr.c_str());
1352 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1353 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1354 aName->SetValue(_mesh->getName().c_str());
1355 _meshId = newObj->GetID();
1356 myBuilder->CommitCommand();
1358 END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
1360 //=============================================================================
1362 * CORBA: add the Mesh in the StudyManager
1364 //=============================================================================
1365 void MESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::MESH_ptr myIor,const string & fileName )
1366 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1368 BEGIN_OF("MED_Mesh_i::addInStudy");
1369 if ( _meshId != "" )
1371 MESSAGE("Mesh already in Study");
1372 THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
1376 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1377 SALOMEDS::GenericAttribute_var anAttr;
1378 SALOMEDS::AttributeName_var aName;
1379 SALOMEDS::AttributeIOR_var aIOR;
1380 SALOMEDS::AttributeComment_var aComment;
1382 // Find SComponent labelled 'Med'
1383 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1384 if ( CORBA::is_nil(medfather) )
1385 THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
1387 // Create SObject labelled 'MESH' if it doesn't already exit
1388 SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
1389 if ( CORBA::is_nil(medmeshfather) )
1391 MESSAGE("Add Object MEDMESH");
1392 medmeshfather = myBuilder->NewObject(medfather);
1393 //medmeshfather.Name = "MEDMESH" ;
1394 anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
1395 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1396 aName->SetValue("MEDMESH");
1400 MESSAGE("Add a mesh Object under MED/MEDMESH");
1401 myBuilder->NewCommand();
1402 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
1404 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
1405 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
1406 CORBA::ORB_var &orb = init(0,0);
1407 string iorStr = orb->object_to_string(myIor);
1408 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1409 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1410 aIOR->SetValue(iorStr.c_str());
1411 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1412 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1413 aName->SetValue(_mesh->getName().c_str());
1414 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
1415 aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1416 aComment->SetValue(fileName.c_str());
1417 _meshId = newObj->GetID();
1418 myBuilder->CommitCommand();
1420 END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
1422 //=============================================================================
1424 //=============================================================================
1426 * CORBA: write mesh in a med file
1428 //=============================================================================
1429 void MESH_i::write(CORBA::Long i, const char* driverMeshName)
1430 throw (SALOME::SALOME_Exception)
1433 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1434 SALOME::INTERNAL_ERROR);
1437 _mesh->write(i,driverMeshName);
1439 catch (MEDEXCEPTION &ex)
1441 MESSAGE("Unable to write the mesh ");
1442 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1445 //=============================================================================
1447 * CORBA: read mesh in a med file
1449 //=============================================================================
1450 void MESH_i::read(CORBA::Long i)
1451 throw (SALOME::SALOME_Exception)
1454 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1455 SALOME::INTERNAL_ERROR);
1460 catch (MEDEXCEPTION &ex)
1462 MESSAGE("Unable to read the mesh ");
1463 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1466 //=============================================================================
1468 * CORBA : release driver
1470 //=============================================================================
1471 void MESH_i::rmDriver(CORBA::Long i)
1472 throw (SALOME::SALOME_Exception)
1475 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1476 SALOME::INTERNAL_ERROR);
1481 catch (MEDEXCEPTION &ex)
1483 MESSAGE("Unable to unlink the mesh from the driver ");
1484 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1485 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
1486 ,SALOME::INTERNAL_ERROR);
1489 //=============================================================================
1491 * CORBA : attach driver
1493 //=============================================================================
1494 CORBA::Long MESH_i::addDriver(SALOME_MED::medDriverTypes driverType,
1495 const char* fileName, const char* meshName)
1496 throw (SALOME::SALOME_Exception)
1499 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
1500 SALOME::INTERNAL_ERROR);
1503 int drivernum=_mesh->addDriver(
1504 convertIdlDriverToMedDriver(driverType),
1509 catch (MEDEXCEPTION &ex)
1511 MESSAGE("Unable to link the mesh to the driver ");
1512 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);