Back to index

salome-med  6.5.0
MEDMEM_GMesh_i.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //=============================================================================
00024 // File      : MEDMEM_Mesh_i.cxx
00025 // Project   : SALOME
00026 // Author    : EDF 
00027 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Mesh_i.cxx
00028 //=============================================================================
00029 //
00030 #include <vector>
00031 
00032 #include "utilities.h"
00033 #include "Utils_CorbaException.hxx"
00034 #include "Utils_ORB_INIT.hxx"
00035 #include "Utils_SINGLETON.hxx"
00036 
00037 #include "MEDMEM_convert.hxx"
00038 #include "MEDMEM_Mesh_i.hxx"
00039 #include "MEDMEM_Support_i.hxx"
00040 #include "MEDMEM_Family_i.hxx"
00041 #include "MEDMEM_Group_i.hxx"
00042 #include "MEDMEM_FieldTemplate_i.hxx"
00043 
00044 #include "MEDMEM_Mesh.hxx"
00045 #include "MEDMEM_Family.hxx"
00046 #include "MEDMEM_Group.hxx"
00047 #include "MEDMEM_CellModel.hxx"
00048 
00049 #include "SenderFactory.hxx"
00050 #include "MultiCommException.hxx"
00051 using namespace MEDMEM;
00052 
00053 // Initialisation des variables statiques
00054 map < int, ::GMESH *> GMESH_i::meshMap ;
00055 int GMESH_i::meshIndex = 0 ;
00056 
00057 
00058 
00059 //=============================================================================
00063 //=============================================================================
00064 GMESH_i::GMESH_i():
00065   SALOMEMultiComm(),
00066   SALOME::GenericObj_i(),
00067   _mesh(constructConstMesh()),
00068   _corbaIndex(MESH_i::meshIndex++),
00069   _meshId("") 
00070 {
00071   MESH_i::meshMap[_corbaIndex]=_mesh;
00072 }
00073 //=============================================================================
00077 //=============================================================================
00078 GMESH_i::~GMESH_i()
00079 {
00080   if ( _mesh )
00081     _mesh->removeReference();
00082 }
00083 //=============================================================================
00087 //=============================================================================
00088 GMESH_i::GMESH_i(::GMESH * const m ) :
00089   SALOMEMultiComm(),
00090   SALOME::GenericObj_i(),
00091   _mesh(m),
00092   _corbaIndex(MESH_i::meshIndex++),
00093   _meshId("") 
00094 {
00095   if ( _mesh ) _mesh->addReference();
00096   GMESH_i::meshMap[_corbaIndex]=_mesh;
00097 }
00098 //=============================================================================
00102 //=============================================================================
00103 //MESH_i::MESH_i(const MESH_i & m) :_mesh(m._mesh),
00104 GMESH_i::GMESH_i( GMESH_i & m) :
00105   SALOMEMultiComm(),
00106   SALOME::GenericObj_i(),
00107   _mesh(m._mesh),
00108   _corbaIndex(MESH_i::meshIndex++),
00109   _meshId("") 
00110 {
00111   if ( _mesh ) _mesh->addReference();
00112   GMESH_i::meshMap[_corbaIndex]=_mesh;
00113 }
00114 //=============================================================================
00118 //=============================================================================
00119 ::GMESH * GMESH_i::constructConstMesh() const
00120 {
00121         ::MESH * const ptrMesh =new ::MESH();
00122         return ptrMesh;
00123 }
00124 //=============================================================================
00128 //=============================================================================
00129 char * GMESH_i::getName()        
00130 throw (SALOME::SALOME_Exception)
00131 {
00132         if (_mesh==NULL)
00133                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00134                                              SALOME::INTERNAL_ERROR);
00135 
00136         try
00137         {
00138                 return CORBA::string_dup(_mesh->getName().c_str());
00139         }
00140         catch (MEDEXCEPTION &ex)
00141         {
00142                 MESSAGE("Unable to acces the mesh name");
00143                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00144         }
00145 }
00146 //=============================================================================
00150 //=============================================================================
00151 CORBA::Long GMESH_i::getCorbaIndex() 
00152 throw (SALOME::SALOME_Exception)
00153 {
00154         if (_mesh==NULL)
00155                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00156                                              SALOME::INTERNAL_ERROR);
00157         return _corbaIndex;
00158 }
00159 //=============================================================================
00163 //=============================================================================
00164 CORBA::Long GMESH_i::getSpaceDimension() 
00165 throw (SALOME::SALOME_Exception)
00166 {
00167         if (_mesh==NULL)
00168                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00169                                              SALOME::INTERNAL_ERROR);
00170         try
00171         {
00172                 return _mesh->getSpaceDimension();
00173         }
00174         catch (MEDEXCEPTION &ex)
00175         {
00176                 MESSAGE("Unable to acces the space dimension ");
00177                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00178         }
00179 }
00180 //=============================================================================
00184 //=============================================================================
00185 CORBA::Long GMESH_i::getMeshDimension()
00186 throw (SALOME::SALOME_Exception)
00187 {
00188         if (_mesh==NULL)
00189                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00190                                              SALOME::INTERNAL_ERROR);
00191         try
00192         {
00193                 return _mesh->getMeshDimension();
00194         }
00195         catch (MEDEXCEPTION &ex)
00196         {
00197                 MESSAGE("Unable to acces the mesh dimension ");
00198                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00199         }
00200 }
00201 //=============================================================================
00205 //=============================================================================
00206 CORBA::Boolean GMESH_i::getIsAGrid()
00207 throw (SALOME::SALOME_Exception)
00208 {
00209         if (_mesh==NULL)
00210                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00211                                              SALOME::INTERNAL_ERROR);
00212         try
00213         {
00214                 return _mesh->getIsAGrid();
00215         }
00216         catch (MEDEXCEPTION &ex)
00217         {
00218                 MESSAGE("Unable to acces mesh flag isAGrid");
00219                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00220         }
00221 }
00222 
00223 //=============================================================================
00227 //=============================================================================
00228 char * GMESH_i::getCoordinatesSystem()
00229 throw (SALOME::SALOME_Exception)
00230 {
00231         if (_mesh==NULL)
00232                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00233                                              SALOME::INTERNAL_ERROR);
00234 
00235         try
00236         {
00237                 return CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
00238         }
00239         catch (MEDEXCEPTION &ex)
00240         {
00241                 MESSAGE("Unable to acces the type of CoordinatesSystem");
00242                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00243         }
00244 }
00245 
00246 //=============================================================================
00250 //=============================================================================
00251 SALOME_TYPES::ListOfString  * GMESH_i::getCoordinatesNames() 
00252 throw (SALOME::SALOME_Exception)
00253 {
00254         if (_mesh==NULL)
00255                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00256                                              SALOME::INTERNAL_ERROR);
00257         SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString;
00258         try
00259         {
00260                 int spaceDimension=_mesh->getSpaceDimension();
00261                 const string * coordinatesName =_mesh->getCoordinatesNames();
00262                 myseq->length(spaceDimension);
00263                 for (int i=0; i<spaceDimension; i++)
00264                 {
00265                         myseq[i]=CORBA::string_dup(coordinatesName[i].c_str());
00266                 }
00267         }
00268         catch (MEDEXCEPTION &ex)
00269         {       
00270                 MESSAGE("Unable to acces the coordinates names");
00271                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00272         }
00273         return myseq._retn();
00274 
00275 }
00276 //=============================================================================
00280 //=============================================================================
00281 SALOME_TYPES::ListOfString *  GMESH_i::getCoordinatesUnits()
00282 throw (SALOME::SALOME_Exception)
00283 {
00284         if (_mesh==NULL)
00285                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00286                                              SALOME::INTERNAL_ERROR);
00287         SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString;
00288         try
00289         {
00290                 int spaceDimension=_mesh->getSpaceDimension();
00291                 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
00292                 myseq->length(spaceDimension);
00293                 for (int i=0; i<spaceDimension; i++)
00294                 {
00295                          myseq[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
00296                 };
00297         }
00298         catch (MEDEXCEPTION &ex)
00299         {       
00300                 MESSAGE("Unable to acces the coordinates units");
00301                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00302         }
00303         return myseq._retn();
00304 }
00305 //=============================================================================
00309 //=============================================================================
00310 CORBA::Long  GMESH_i::getNumberOfNodes() 
00311 throw (SALOME::SALOME_Exception)
00312 {
00313         if (_mesh==NULL)
00314                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00315                                              SALOME::INTERNAL_ERROR);
00316         try
00317         {
00318                 return _mesh->getNumberOfNodes();
00319         }
00320         catch (MEDEXCEPTION &ex)
00321         {       
00322                 MESSAGE("Unable to acces number of nodes");
00323                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00324         }
00325 }
00326 //=============================================================================
00330 //=============================================================================
00331 CORBA::Long GMESH_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity) 
00332 throw (SALOME::SALOME_Exception)
00333 {
00334         if (_mesh==NULL)
00335                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00336                                              SALOME::INTERNAL_ERROR);
00337         try
00338         {
00339                 return _mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
00340         }
00341         catch (MEDEXCEPTION &ex)
00342         {       
00343                 MESSAGE("Unable to acces number of differents types");
00344                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00345         }
00346 }
00347 //=============================================================================
00351 //=============================================================================
00352 SALOME_MED::medGeometryElement GMESH_i::getElementType (SALOME_MED::medEntityMesh entity,
00353                                                        CORBA::Long number)
00354 throw (SALOME::SALOME_Exception)
00355 {
00356         if (_mesh==NULL)
00357                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00358                                              SALOME::INTERNAL_ERROR);
00359         try
00360         {
00361                 return _mesh->getElementType(convertIdlEntToMedEnt(entity),number);
00362         }
00363         catch (MEDEXCEPTION &ex)
00364         {
00365                 MESSAGE("Unable to acces number of differents element types");
00366                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00367         }
00368 }
00369 
00370 //=============================================================================
00375 //=============================================================================
00376 SALOME_MED::medGeometryElement_array * GMESH_i::getTypes (SALOME_MED::medEntityMesh entity) 
00377 throw (SALOME::SALOME_Exception)
00378 {
00379         if (_mesh==NULL)
00380                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00381                                              SALOME::INTERNAL_ERROR);
00382         if (entity ==SALOME_MED::MED_ALL_ENTITIES)
00383                 THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\
00384                                              SALOME::BAD_PARAM);
00385         SALOME_MED::medGeometryElement_array_var myseq = 
00386                                         new SALOME_MED::medGeometryElement_array;
00387         try
00388         {
00389                 int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity));
00390                 const medGeometryElement * elemts  =_mesh->getTypes(
00391                                        convertIdlEntToMedEnt(entity));
00392                 myseq->length(nbTypes);
00393                 for (int i=0; i<nbTypes; i++)
00394                 {
00395                         myseq[i]=convertMedEltToIdlElt(elemts[i]);
00396                 };
00397         }
00398         catch (MEDEXCEPTION &ex)
00399         {       
00400                 MESSAGE("Unable to acces coordinates");
00401                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00402         }
00403         return myseq._retn();
00404 }
00405 //=============================================================================
00411 //=============================================================================
00412 CORBA::Long GMESH_i::getNumberOfElements(SALOME_MED::medEntityMesh entity, 
00413                                         SALOME_MED::medGeometryElement geomElement)
00414 throw (SALOME::SALOME_Exception)
00415 {
00416         if (_mesh==NULL)
00417                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00418                                              SALOME::INTERNAL_ERROR);
00419         if (verifieParam(entity,geomElement)==false)
00420                 THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\
00421                                              SALOME::BAD_PARAM);
00422         
00423         try
00424         {
00425 //           if ( geomElement == SALOME_MED::MED_POLYGON ||
00426 //                geomElement == SALOME_MED::MED_POLYHEDRA )
00427 //             return _mesh->getNumberOfElementsWithPoly(convertIdlEntToMedEnt(entity),
00428 //                                                       convertIdlEltToMedElt(geomElement));
00429 //           else
00430             return _mesh->getNumberOfElements(convertIdlEntToMedEnt(entity),
00431                                               convertIdlEltToMedElt(geomElement));
00432         }
00433         catch (MEDEXCEPTION &ex)
00434         {
00435                 MESSAGE("Unable to acces number of elements");
00436                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00437         }
00438 }
00439 
00440 //=============================================================================
00444 //=============================================================================
00445 CORBA::Long GMESH_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity)
00446 throw (SALOME::SALOME_Exception)
00447 {
00448         if (_mesh==NULL)
00449                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00450                                              SALOME::INTERNAL_ERROR);
00451         try
00452         {
00453                 return _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
00454         }
00455         catch (MEDEXCEPTION &ex)
00456         {
00457                 MESSAGE("Unable to acces number of families of the mesh");
00458                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00459         }
00460 }
00461 //=============================================================================
00465 //=============================================================================
00466 CORBA::Long GMESH_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity) 
00467 throw (SALOME::SALOME_Exception)
00468 {
00469         if (_mesh==NULL)
00470                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00471                                              SALOME::INTERNAL_ERROR);
00472         try
00473         {
00474                 return _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
00475         }
00476         catch (MEDEXCEPTION &ex)
00477         {
00478                 MESSAGE("Unable to acces number of groups of the mesh");
00479                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00480         }
00481 }
00482 //=============================================================================
00486 //=============================================================================
00487 SALOME_MED::Family_array * GMESH_i::getFamilies(SALOME_MED::medEntityMesh entity) 
00488 throw (SALOME::SALOME_Exception)
00489 {
00490         if (_mesh==NULL)
00491                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00492                                              SALOME::INTERNAL_ERROR);
00493         SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array;
00494         try
00495         {
00496                 int nbfam= _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity));
00497                 myseq->length(nbfam);
00498                 vector<FAMILY*> fam(nbfam);
00499                 fam = _mesh->getFamilies(convertIdlEntToMedEnt(entity));
00500                 for (int i=0;i<nbfam;i++)
00501                 {
00502                         FAMILY_i * f1=new FAMILY_i(fam[i]);
00503                         myseq[i] = f1->_this();
00504                 }
00505         }
00506         catch (MEDEXCEPTION &ex)
00507         {
00508                 MESSAGE("Unable to acces families of the mesh");
00509                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00510         }
00511         return myseq._retn();
00512 }
00513 //=============================================================================
00517 //=============================================================================
00518 SALOME_MED::GMESH::coordinateInfos *  GMESH_i::getCoordGlobal()
00519 throw (SALOME::SALOME_Exception)
00520 {
00521         if (_mesh==NULL)
00522                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00523                                              SALOME::INTERNAL_ERROR);
00524         SALOME_MED::GMESH::coordinateInfos_var all = new SALOME_MED::GMESH::coordinateInfos;
00525         try
00526         {
00527                 all->coordSystem = CORBA::string_dup(_mesh->getCoordinatesSystem().c_str());
00528 
00529                 int spaceDimension=_mesh->getSpaceDimension();
00530                 const string * coordinatesUnits =_mesh->getCoordinatesUnits();
00531                 const string * coordinatesName =_mesh->getCoordinatesNames();
00532 
00533                 all->coordUnits.length(spaceDimension);
00534                 all->coordNames.length(spaceDimension);
00535                 for (int i=0; i<spaceDimension; i++)
00536                 {
00537                          all->coordUnits[i]=CORBA::string_dup(coordinatesUnits[i].c_str());
00538                          all->coordNames[i]=CORBA::string_dup(coordinatesName[i].c_str());
00539                 }
00540         }
00541         catch (MEDEXCEPTION &ex)
00542         {
00543                 MESSAGE("Unable to acces coordinate information ");
00544                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00545         }
00546         return all._retn();
00547 }
00548 
00549 //=============================================================================
00553 //=============================================================================
00554 SALOME_MED::FAMILY_ptr GMESH_i::getFamily(SALOME_MED::medEntityMesh entity,
00555                                          CORBA::Long i) 
00556 throw (SALOME::SALOME_Exception)
00557 {
00558         if (_mesh==NULL)
00559                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00560                                              SALOME::INTERNAL_ERROR);
00561         try
00562         {
00563                 const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i);
00564                 FAMILY_i * f1=new FAMILY_i(fam);
00565                 return f1->_this();
00566         }
00567         catch (MEDEXCEPTION &ex)
00568         {
00569                 MESSAGE("Unable to acces specified family of the mesh");
00570                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00571         }
00572 
00573 }
00574 //=============================================================================
00575 /*
00576  * CORBA: Returns Mesh global informations
00577  */
00578 //=============================================================================
00579 SALOME_MED::GMESH::meshInfos *  GMESH_i::getMeshGlobal()
00580 throw (SALOME::SALOME_Exception)
00581 {
00582         if (_mesh==NULL)
00583                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00584                                              SALOME::INTERNAL_ERROR);
00585         SALOME_MED::GMESH::meshInfos_var all = new SALOME_MED::GMESH::meshInfos;
00586         try
00587         {
00588                 all->name = CORBA::string_dup(_mesh->getName().c_str());
00589                 all->spaceDimension = _mesh->getSpaceDimension();
00590                 all->meshDimension  = _mesh->getMeshDimension();
00591                 all->numberOfNodes  = _mesh->getNumberOfNodes();
00592                 all->isAGrid        = _mesh->getIsAGrid();
00593 
00594                 int nbFam= _mesh->getNumberOfFamilies(MED_NODE);
00595                 all->famNode.length(nbFam);
00596                 vector<FAMILY*> vNode (nbFam);
00597                 vNode = _mesh->getFamilies(MED_NODE);
00598                 for (int i=0;i<nbFam;i++)
00599                 {
00600                         FAMILY_i * f1=new FAMILY_i(vNode[i]);
00601                         all->famNode[i] = f1->_this();
00602                 }
00603 
00604                 nbFam = _mesh->getNumberOfFamilies(MED_EDGE);
00605                 all->famEdge.length(nbFam);
00606                 vector<FAMILY*> vEdge (nbFam);
00607                 vEdge = _mesh->getFamilies(MED_EDGE);
00608                 for (int i=0;i<nbFam;i++)
00609                 for (int i=0;i<nbFam;i++)
00610                 {
00611                         FAMILY_i * f1=new FAMILY_i(vEdge[i]);
00612                         all->famEdge[i] = f1->_this();
00613                 }
00614 
00615                 nbFam = _mesh->getNumberOfFamilies(MED_FACE);
00616                 all->famFace.length(nbFam);
00617                 vector<FAMILY*> vFace (nbFam);
00618                 vFace = _mesh->getFamilies(MED_FACE);
00619                 for (int i=0;i<nbFam;i++)
00620                 {
00621                         FAMILY_i * f1=new FAMILY_i(vFace[i]);
00622                         all->famFace[i] = f1->_this();
00623                 }
00624 
00625                 nbFam = _mesh->getNumberOfFamilies(MED_CELL);
00626                 all->famCell.length(nbFam);
00627                 vector<FAMILY*> vCell (nbFam);
00628                 vCell = _mesh->getFamilies(MED_CELL);
00629                 for (int i=0;i<nbFam;i++)
00630                 {
00631                         FAMILY_i * f1=new FAMILY_i(vCell[i]);
00632                         all->famCell[i] = f1->_this();
00633                 }
00634 
00635                 int nbGroup = _mesh->getNumberOfGroups(MED_NODE);
00636                 all->groupNode.length(nbGroup);
00637                 vector<GROUP*> gNode (nbGroup);
00638                 gNode = _mesh->getGroups(MED_NODE);
00639                 for (int i=0;i<nbGroup;i++)
00640                 {
00641                         GROUP_i * f1=new GROUP_i(gNode[i]);
00642                         all->groupNode[i] = f1->_this();
00643                 }
00644 
00645                 nbGroup = _mesh->getNumberOfGroups(MED_EDGE);
00646                 all->groupEdge.length(nbGroup);
00647                 vector<GROUP*> gEdge (nbGroup);
00648                 gEdge = _mesh->getGroups(MED_EDGE);
00649                 for (int i=0;i<nbGroup;i++)
00650                 {
00651                         GROUP_i * f1=new GROUP_i(gEdge[i]);
00652                         all->groupEdge[i] = f1->_this();
00653                 }
00654                 nbGroup = _mesh->getNumberOfGroups(MED_FACE);
00655                 all->groupFace.length(nbGroup);
00656                 vector<GROUP*> gFace (nbGroup);
00657                 gFace = _mesh->getGroups(MED_FACE);
00658                 for (int i=0;i<nbGroup;i++)
00659                 {
00660                         GROUP_i * f1=new GROUP_i(gFace[i]);
00661                         all->groupFace[i] = f1->_this();
00662                 }
00663 
00664                 nbGroup = _mesh->getNumberOfGroups(MED_CELL);
00665                 all->groupCell.length(nbGroup);
00666                 vector<GROUP*> gCell (nbGroup);
00667                 gCell = _mesh->getGroups(MED_CELL);
00668                 for (int i=0;i<nbGroup;i++)
00669                 {
00670                         GROUP_i * f1=new GROUP_i(gCell[i]);
00671                         all->groupCell[i] = f1->_this();
00672                 }
00673 
00674         }
00675         catch (MEDEXCEPTION &ex)
00676         {
00677                 MESSAGE("Unable to acces mesh");
00678                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00679         }
00680         return all._retn();
00681 }
00682 //=============================================================================
00683  /*
00684  * CORBA: Returns references for groups within the mesh
00685  */
00686 //=============================================================================
00687 SALOME_MED::Group_array *  GMESH_i::getGroups(SALOME_MED::medEntityMesh entity) 
00688 throw (SALOME::SALOME_Exception)
00689 {
00690         if (_mesh==NULL)
00691                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00692                                              SALOME::INTERNAL_ERROR);
00693         SALOME_MED::Group_array_var myseq = new SALOME_MED::Group_array;
00694         try
00695         {
00696                 int nbgroups = _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity));
00697                 myseq->length(nbgroups);
00698                 vector<GROUP*> groups(nbgroups);
00699                 groups = _mesh->getGroups(convertIdlEntToMedEnt(entity));
00700                 for (int i=0;i<nbgroups;i++)
00701                 {
00702                         GROUP_i * f1=new GROUP_i(groups[i]);
00703                         myseq[i] = f1->_this();
00704                 }
00705         }
00706         catch (MEDEXCEPTION &ex)
00707         {
00708                 MESSAGE("Unable to acces number of groups of the mesh");
00709                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00710         }
00711         return myseq._retn();
00712 }
00713 //=============================================================================
00717 //=============================================================================
00718 SALOME_MED::GROUP_ptr GMESH_i::getGroup(SALOME_MED::medEntityMesh entity,
00719                                        CORBA::Long i) 
00720 throw (SALOME::SALOME_Exception)
00721 {
00722         if (_mesh==NULL)
00723                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00724                                               SALOME::INTERNAL_ERROR);
00725         try
00726         {
00727                 const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i);
00728                 GROUP_i * f1=new GROUP_i(grou);
00729                 return f1->_this();
00730         }
00731         catch (MEDEXCEPTION &ex)
00732         {
00733                 MESSAGE("Unable to acces specified group of the mesh");
00734                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00735         }
00736 }
00737 //=============================================================================
00741 //=============================================================================
00742 SALOME_MED::SUPPORT_ptr GMESH_i::getBoundaryElements(SALOME_MED::medEntityMesh entity)
00743 throw (SALOME::SALOME_Exception)
00744 {
00745         if (_mesh==NULL)
00746                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00747                                               SALOME::INTERNAL_ERROR);
00748         try
00749         {
00750                 SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity));
00751                 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
00752                 return mySupportI->_this();
00753         }
00754         catch (MEDEXCEPTION &ex)
00755         {
00756                 MESSAGE("Unable to get the volume ");
00757                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00758         }
00759 }
00760 
00761 //=============================================================================
00765 //=============================================================================
00766 SALOME_MED::SUPPORT_ptr GMESH_i::getSupportOnAll(SALOME_MED::medEntityMesh entity)
00767 throw (SALOME::SALOME_Exception)
00768 {
00769         if (_mesh==NULL)
00770                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00771                                               SALOME::INTERNAL_ERROR);
00772         try
00773         {
00774           const SUPPORT * myNewSupport = _mesh->getSupportOnAll(convertIdlEntToMedEnt(entity));
00775           SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
00776           return mySupportI->_this();
00777         }
00778         catch (MEDEXCEPTION &ex)
00779         {
00780                 MESSAGE("Unable to get the support ");
00781                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00782         }
00783 }
00784 //=============================================================================
00788 //=============================================================================
00789 SALOME_MED::FIELD_ptr GMESH_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport)
00790 throw (SALOME::SALOME_Exception)
00791 {
00792         if (_mesh==NULL)
00793                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00794                                               SALOME::INTERNAL_ERROR); try
00795         {
00796                 int sup = mySupport->getCorbaIndex();
00797                 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
00798                 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
00799                 ::FIELD<double>*f=_mesh->getVolume( myCppSupport);
00800                 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
00801                 return medf->_this();
00802         }
00803         catch (MEDEXCEPTION &ex)
00804         {
00805                 MESSAGE("Unable to get the volume ");
00806                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00807         }
00808 }
00809 //=============================================================================
00813 //=============================================================================
00814 SALOME_MED::SUPPORT_ptr GMESH_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D)
00815 throw (SALOME::SALOME_Exception)
00816 {
00817         if (_mesh==NULL)
00818                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00819                                               SALOME::INTERNAL_ERROR);
00820         try
00821         {
00822                 int sup = mySupport3D->getCorbaIndex();
00823                 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
00824                 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
00825                 SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport);
00826                 SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport);
00827                 return mySupportI->_this() ;
00828         }
00829         catch (MEDEXCEPTION &ex)
00830         {
00831                 MESSAGE("Unable to get the volume ");
00832                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00833         }
00834 }
00835 //=============================================================================
00839 //=============================================================================
00840 SALOME_MED::FIELD_ptr GMESH_i::getArea(SALOME_MED::SUPPORT_ptr mySupport)
00841 throw (SALOME::SALOME_Exception)
00842 {
00843         if (_mesh==NULL)
00844                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00845                                               SALOME::INTERNAL_ERROR);
00846         try
00847         {
00848                 int sup = mySupport->getCorbaIndex();
00849                 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
00850                 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
00851                 ::FIELD<double>*f=_mesh->getArea( myCppSupport);
00852                 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
00853                 return medf->_this();
00854         }
00855         catch (MEDEXCEPTION &ex)
00856         {
00857                 MESSAGE("Unable to get the area ");
00858                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00859         }
00860 }
00861 //=============================================================================
00865 //=============================================================================
00866 SALOME_MED::FIELD_ptr GMESH_i::getLength(SALOME_MED::SUPPORT_ptr mySupport)
00867 throw (SALOME::SALOME_Exception)
00868 {
00869         if (_mesh==NULL)
00870                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00871                                               SALOME::INTERNAL_ERROR);
00872         try
00873         {
00874                 int sup = mySupport->getCorbaIndex();
00875                 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
00876                 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
00877                 ::FIELD<double>*f=_mesh->getLength( myCppSupport);
00878                 FIELDTEMPLATE_I<double>  *medf = new FIELDTEMPLATE_I<double>(f);
00879                 return medf->_this();
00880         }
00881         catch (MEDEXCEPTION &ex)
00882         {
00883                 MESSAGE("Unable to get the length ");
00884                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00885         }
00886 }
00887 //=============================================================================
00891 //=============================================================================
00892 SALOME_MED::FIELD_ptr GMESH_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport)
00893 throw (SALOME::SALOME_Exception)
00894 {
00895         if (_mesh==NULL)
00896                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00897                                               SALOME::INTERNAL_ERROR);
00898         try
00899         {
00900                 int sup = mySupport->getCorbaIndex();
00901                 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
00902                 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
00903                 ::FIELD<double>*f=_mesh->getNormal( myCppSupport);
00904                 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
00905                 return medf->_this();
00906         }
00907         catch (MEDEXCEPTION &ex)
00908         {
00909                 MESSAGE("Unable to get the normal ");
00910                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00911         }
00912 }
00913 //=============================================================================
00917 //=============================================================================
00918 SALOME_MED::FIELD_ptr GMESH_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport)
00919 throw (SALOME::SALOME_Exception)
00920 {
00921         if (_mesh==NULL)
00922                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00923                                               SALOME::INTERNAL_ERROR);
00924         try
00925         {
00926                 int sup = mySupport->getCorbaIndex();
00927                 ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end());
00928                 const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup];
00929                 ::FIELD<double>*f=_mesh->getBarycenter( myCppSupport);
00930                 FIELDTEMPLATE_I<double> *medf = new FIELDTEMPLATE_I<double>(f);
00931                 return medf->_this();
00932         }
00933         catch (MEDEXCEPTION &ex)
00934         {
00935                 MESSAGE("Unable to get the barycenter ");
00936                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00937         }
00938 }
00939 //=============================================================================
00943 //=============================================================================
00944 SALOME_MED::FIELD_ptr GMESH_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport)
00945 throw (SALOME::SALOME_Exception)
00946 {
00947         if (_mesh==NULL)
00948                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
00949                                               SALOME::INTERNAL_ERROR);
00950         MESSAGE("Not Implemented");
00951         return SALOME_MED::FIELD::_nil();
00952 }
00953 //=============================================================================
00957 //=============================================================================
00958 void GMESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::GMESH_ptr myIor )
00959 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
00960 {
00961         if ( _meshId != "" )
00962         {
00963                 MESSAGE("Mesh already in Study");
00964                     THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
00965                                  SALOME::BAD_PARAM);
00966         };
00967 
00968         SALOMEDS::StudyBuilder_var     myBuilder = myStudy->NewBuilder();
00969         SALOMEDS::GenericAttribute_var anAttr;
00970         SALOMEDS::AttributeName_var    aName;
00971         SALOMEDS::AttributeIOR_var     aIOR;
00972 
00973         // Find SComponent labelled 'MED'
00974         SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
00975         myBuilder->NewCommand();
00976         if ( CORBA::is_nil(medfather) ) 
00977           THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
00978 
00979         // Create SObject labelled 'MESH' if it doesn't already exit
00980 //      SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
00981 //      if ( CORBA::is_nil(medmeshfather) ) 
00982 //      {
00983 //              MESSAGE("Add Object MEDMESH");
00984 //              medmeshfather = myBuilder->NewObject(medfather);
00985 //              //medmeshfather.Name = "MEDMESH" ;
00986 //                 anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
00987 //                 aName = SALOMEDS::AttributeName::_narrow(anAttr);
00988 //                 aName->SetValue("MEDMESH");
00989 
00990 //      } ;
00991 
00992         string aPath = "/Med/MEDMESH";
00993         SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath( aPath.c_str() );
00994         if ( CORBA::is_nil(medmeshfather) ) 
00995           {
00996             MESSAGE("Add Object MEDMESH");
00997 
00998             myBuilder->AddDirectory( aPath.c_str() );
00999             medmeshfather = myStudy->FindObjectByPath( aPath.c_str() );
01000           } ;
01001 
01002         aPath += "/" + _mesh->getName();
01003         SALOMEDS::SObject_var meshSO = myStudy->FindObjectByPath( aPath.c_str());
01004         bool alreadyPublished = ! CORBA::is_nil( meshSO );
01005         if ( !alreadyPublished ) {
01006           MESSAGE("Add a mesh Object under MED/MEDMESH");
01007           meshSO = myBuilder->NewObject(medmeshfather);
01008 
01009           anAttr = myBuilder->FindOrCreateAttribute(meshSO, "AttributeName");
01010           aName = SALOMEDS::AttributeName::_narrow(anAttr);
01011           aName->SetValue(_mesh->getName().c_str());
01012         }
01013 
01014         ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
01015         ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
01016         CORBA::ORB_var &orb = init(0,0);
01017         string iorStr = orb->object_to_string(myIor);
01018         anAttr = myBuilder->FindOrCreateAttribute(meshSO, "AttributeIOR");
01019         aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
01020         aIOR->SetValue(iorStr.c_str());
01021         _meshId = meshSO->GetID();
01022         myBuilder->CommitCommand();
01023 
01024         // register the Corba pointer: increase the referrence count
01025         MESSAGE("Registering of the Corba Mesh pointer");
01026         Register();
01027 
01028 }
01029 //=============================================================================
01033 //=============================================================================
01034 void GMESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::GMESH_ptr myIor,const string & fileName )
01035 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
01036 {
01037         if ( _meshId != "" )
01038         {
01039                 MESSAGE("Mesh already in Study");
01040                     THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \
01041                                  SALOME::BAD_PARAM);
01042         };
01043 
01044         SALOMEDS::StudyBuilder_var     myBuilder = myStudy->NewBuilder();
01045         SALOMEDS::GenericAttribute_var anAttr;
01046         SALOMEDS::AttributeName_var    aName;
01047         SALOMEDS::AttributeIOR_var     aIOR;
01048         SALOMEDS::AttributeComment_var aComment;
01049 
01050         // Find SComponent labelled 'Med'
01051         SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
01052         if ( CORBA::is_nil(medfather) )
01053           THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
01054 
01055         // Create SObject labelled 'MESH' if it doesn't already exit
01056         SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH");
01057         if ( CORBA::is_nil(medmeshfather) )
01058         {
01059                 MESSAGE("Add Object MEDMESH");
01060                 medmeshfather = myBuilder->NewObject(medfather);
01061                 //medmeshfather.Name = "MEDMESH" ;
01062                 anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName");
01063                 aName = SALOMEDS::AttributeName::_narrow(anAttr);
01064                 aName->SetValue("MEDMESH");
01065 
01066         } ;
01067 
01068         MESSAGE("Add a mesh Object under MED/MEDMESH");
01069         myBuilder->NewCommand();
01070         SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather);
01071 
01072         ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
01073         ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
01074         CORBA::ORB_var &orb = init(0,0);
01075         CORBA::String_var iorStr = orb->object_to_string(myIor);
01076         anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
01077         aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
01078         aIOR->SetValue(iorStr.in());
01079         anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
01080         aName = SALOMEDS::AttributeName::_narrow(anAttr);
01081         aName->SetValue(_mesh->getName().c_str());
01082         anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeComment");
01083         aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
01084         aComment->SetValue(fileName.c_str());
01085         _meshId = newObj->GetID();
01086         myBuilder->CommitCommand();
01087 
01088         // register the Corba pointer: increase the referrence count
01089         MESSAGE("Registering of the Corba Mesh pointer");
01090         Register();
01091 
01092 }
01093 //=============================================================================
01094 
01095 //=============================================================================
01099 //=============================================================================
01100 void GMESH_i::write(CORBA::Long i, const char* driverMeshName)        
01101 throw (SALOME::SALOME_Exception)
01102 {
01103         if (_mesh==NULL)
01104                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
01105                                              SALOME::INTERNAL_ERROR);
01106         try
01107         {
01108                 _mesh->write(i);
01109         }
01110         catch (MEDEXCEPTION &ex)
01111         {
01112                 MESSAGE("Unable to write the mesh ");
01113                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
01114         }
01115 }
01116 //=============================================================================
01120 //=============================================================================
01121 void GMESH_i::read(CORBA::Long i)             
01122 throw (SALOME::SALOME_Exception)
01123 {
01124         if (_mesh==NULL)
01125                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
01126                                              SALOME::INTERNAL_ERROR);
01127         try
01128         {
01129                 _mesh->read(i);
01130         }
01131         catch (MEDEXCEPTION &ex)
01132         {
01133                 MESSAGE("Unable to read the mesh ");
01134                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
01135         }
01136 }
01137 //=============================================================================
01141 //=============================================================================
01142 void GMESH_i::rmDriver(CORBA::Long i)         
01143 throw (SALOME::SALOME_Exception)
01144 {
01145         if (_mesh==NULL)
01146                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
01147                                              SALOME::INTERNAL_ERROR);
01148         try
01149         {
01150                 _mesh->rmDriver();
01151         }
01152         catch (MEDEXCEPTION &ex)
01153         {
01154                 MESSAGE("Unable to unlink the mesh from the driver ");
01155                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
01156                 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
01157                                                 ,SALOME::INTERNAL_ERROR);
01158         }
01159 }
01160 //=============================================================================
01164 //=============================================================================
01165 CORBA::Long GMESH_i::addDriver(SALOME_MED::medDriverTypes driverType, 
01166                               const char* fileName, const char* meshName)
01167 throw (SALOME::SALOME_Exception)
01168 {
01169         if (_mesh==NULL)
01170                 THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \
01171                                              SALOME::INTERNAL_ERROR);
01172         try
01173         {
01174                 int drivernum=_mesh->addDriver(
01175                                         convertIdlDriverToMedDriver(driverType),
01176                                         fileName,
01177                                         meshName);
01178                 return drivernum;
01179         }
01180         catch (MEDEXCEPTION &ex)
01181         {
01182                 MESSAGE("Unable to link the mesh to the driver ");
01183                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
01184         }
01185 }
01186 
01187 //=============================================================================
01191 //=============================================================================
01192 CORBA::Boolean GMESH_i::areEquals(SALOME_MED::GMESH_ptr other)
01193 {
01194   PortableServer::ServantBase *baseServ;
01195   try {
01196     baseServ=_default_POA()->reference_to_servant(other);
01197   }
01198   catch(...){
01199     baseServ=0;
01200   }
01201   if(baseServ)
01202     {
01203      baseServ->_remove_ref();
01204      GMESH_i *otherServ=dynamic_cast<GMESH_i *>(baseServ);
01205      return *_mesh==*otherServ->_mesh;
01206     }
01207   return false;
01208 }
01209 
01210 //================================================================================
01214 //================================================================================
01215 
01216 SALOME_MED::MESH_ptr GMESH_i::convertInMESH() throw (SALOME::SALOME_Exception)
01217 {
01218   if (_mesh==NULL)
01219     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",SALOME::INTERNAL_ERROR);
01220 
01221   const MESH* mesh = _mesh->convertInMESH();
01222   MESH_i* mesh_i = new MESH_i( const_cast< MESH*> ( mesh ));
01223   return mesh_i->_this();
01224 }
01225