Back to index

salome-med  6.5.0
MEDMEM_Support_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_Support_i.cxx
00025 // Project   : SALOME
00026 // Author    : EDF
00027 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Support_i.cxx
00028 //=============================================================================
00029 //
00030 #include "utilities.h"
00031 #include "Utils_CorbaException.hxx"
00032 #include "Utils_ORB_INIT.hxx"
00033 #include "Utils_SINGLETON.hxx"
00034 
00035 #include CORBA_SERVER_HEADER(MED)
00036 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
00037 
00038 
00039 #include "MEDMEM_define.hxx"
00040 #include "MEDMEM_Support.hxx"
00041 #include "MEDMEM_Mesh.hxx"
00042 
00043 #include "MEDMEM_Support_i.hxx"
00044 #include "MEDMEM_Mesh_i.hxx"
00045 #include "MEDMEM_convert.hxx"
00046 
00047 #include "SenderFactory.hxx"
00048 #include "MultiCommException.hxx"
00049 using namespace MEDMEM;
00050 
00051 // Initialisation des variables statiques
00052 map < int, ::SUPPORT *> SUPPORT_i::supportMap ;
00053 int SUPPORT_i::supportIndex = 0 ;
00054 
00055 
00056 //=============================================================================
00060 //=============================================================================
00061 SUPPORT_i::SUPPORT_i() :_support((::SUPPORT *)NULL),_corbaIndex(SUPPORT_i::supportIndex++)
00062 {
00063 }
00064 
00065 //=============================================================================
00069 //=============================================================================
00070 SUPPORT_i::SUPPORT_i(const ::SUPPORT * const s) :_support(s),
00071                                                  _corbaIndex(SUPPORT_i::supportIndex++)
00072 {
00073   if ( _support ) _support->addReference();
00074   SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support;
00075 }
00076 //=============================================================================
00080 //=============================================================================
00081 SUPPORT_i::SUPPORT_i(const SUPPORT_i &s) :_support(s._support),
00082                                           _corbaIndex(SUPPORT_i::supportIndex++)
00083 {
00084   if ( _support ) _support->addReference();
00085   SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support;
00086 }
00087 //=============================================================================
00091 //=============================================================================
00092 
00093 SUPPORT_i::~SUPPORT_i()
00094 {
00095   if ( SUPPORT_i::supportMap[_corbaIndex] )
00096     SUPPORT_i::supportMap[_corbaIndex]->removeReference();
00097 }
00098 //=============================================================================
00102 //=============================================================================
00103 
00104 CORBA::Long SUPPORT_i::getCorbaIndex()
00105   throw (SALOME::SALOME_Exception)
00106 {
00107   if (_support==NULL)
00108     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00109   return _corbaIndex;
00110 }
00111 
00112 //=============================================================================
00116 //=============================================================================
00117 
00118 char * SUPPORT_i::getName()     
00119   throw (SALOME::SALOME_Exception)
00120 {
00121   if (_support==NULL)
00122     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00123   try
00124   {
00125     return CORBA::string_dup(_support->getName().c_str());
00126   }
00127   catch (MEDEXCEPTION &ex)
00128   {
00129     MESSAGE("Unable to access the name of the support ");
00130     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00131   }
00132 }
00133 
00134 //=============================================================================
00138 //=============================================================================
00139 
00140 char*  SUPPORT_i::getDescription()
00141   throw (SALOME::SALOME_Exception)
00142 {
00143   if (_support==NULL)
00144     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00145   try
00146   {
00147     return CORBA::string_dup(_support->getDescription().c_str());
00148   }
00149   catch (MEDEXCEPTION &ex)
00150   {
00151     MESSAGE("Unable to access the description of the support ");
00152     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00153   }
00154 }
00155 
00156 //=============================================================================
00160 //=============================================================================
00161 
00162 SALOME_MED::SUPPORT::supportInfos * SUPPORT_i::getSupportGlobal()
00163   throw (SALOME::SALOME_Exception)
00164 {
00165   if (_support==NULL)
00166     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00167   SALOME_MED::SUPPORT::supportInfos_var all = new SALOME_MED::SUPPORT::supportInfos;
00168   try
00169   {
00170     all->name               = CORBA::string_dup(_support->getName().c_str());
00171     all->description        = CORBA::string_dup(_support->getDescription().c_str());
00172     const int numberOfTypes = _support->getNumberOfTypes();
00173     all->numberOfGeometricType = numberOfTypes;
00174     all->entity = _support->getEntity();
00175     all->isOnAllElements    = _support->isOnAllElements();
00176     all->types.length(numberOfTypes);
00177     all->nbEltTypes.length(numberOfTypes);
00178     all->nodalConnectivityLength.length(numberOfTypes);
00179     const medGeometryElement * types = _support->getTypes();
00180     const MESH* mesh = _support->getMesh()->convertInMESH();
00181     for (int i=0;i<numberOfTypes;i++)
00182     {
00183       int nbelements = _support->getNumberOfElements(types[i]);
00184       int connLength = 0;
00185       switch ( types[i] )
00186       {
00187       case MED_EN::MED_POLYGON: 
00188       case MED_EN::MED_POLYHEDRA: 
00189 {
00190         if (_support->isOnAllElements() ) 
00191 {
00192           connLength = mesh->getConnectivityLength(MED_EN::MED_NODAL,
00193                                                    _support->getEntity(),MED_EN::MED_ALL_ELEMENTS);
00194         }
00195         else 
00196 {
00197           const int * index = mesh->getConnectivityIndex(MED_EN::MED_NODAL,_support->getEntity());
00198           const int * numbers=_support->getNumber(types[i]);
00199           for (int j=0;j<nbelements;j++)
00200           {
00201             int elem = numbers[j] ;
00202             connLength += index[elem] - index[elem-1];
00203           }
00204         }
00205         break;
00206       }
00207       default:
00208         connLength = nbelements * ( types[i] % 100 );
00209       }
00210       all->types[i]                   = convertMedEltToIdlElt(types[i]);
00211       all->nbEltTypes[i]              = nbelements;
00212       all->nodalConnectivityLength[i] = connLength;
00213     }
00214     mesh->removeReference();
00215   }
00216   catch (MEDEXCEPTION &ex)
00217   {
00218     MESSAGE("Unable to access the description of the support ");
00219     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00220   }
00221   return all._retn();
00222 }
00223 
00224 
00225 //=============================================================================
00229 //=============================================================================
00230 
00231 SALOME_MED::GMESH_ptr SUPPORT_i::getMesh()
00232   throw (SALOME::SALOME_Exception)
00233 {
00234   if (_support==NULL)
00235     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00236   try
00237   {
00238     const GMESH * mesh = _support->getMesh();
00239 
00240     SCRUTE(mesh) ;
00241 
00242     GMESH_i * m1 = new GMESH_i(const_cast<GMESH*>( mesh ));
00243     SALOME_MED::GMESH_ptr m2 = m1->_this();
00244     MESSAGE("SALOME_MED::GMESH_ptr SUPPORT_i::getMesh() checking des pointeurs CORBA");
00245 
00246     SCRUTE(m1);
00247     SCRUTE(m2);
00248 
00249     return (m2);
00250   }
00251   catch (MEDEXCEPTION &ex)
00252   {
00253     MESSAGE("Unable to access the assoicated mesh");
00254     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00255   }
00256 }
00257 
00258 //=============================================================================
00262 //=============================================================================
00263 
00264 CORBA::Boolean SUPPORT_i::isOnAllElements()
00265   throw (SALOME::SALOME_Exception)
00266 {
00267   if (_support==NULL)
00268     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00269   try
00270   {
00271     return _support->isOnAllElements();
00272   }
00273   catch (MEDEXCEPTION &ex)
00274   {
00275     MESSAGE("Unable to access the type of the support");
00276     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00277   }
00278 }
00279 
00280 //=============================================================================
00284 //=============================================================================
00285 CORBA::Long SUPPORT_i::getNumberOfTypes()
00286   throw (SALOME::SALOME_Exception)
00287 {
00288   if (_support==NULL)
00289     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00290   try
00291   {
00292     return _support->getNumberOfTypes();
00293   }
00294   catch (MEDEXCEPTION &ex)
00295   {
00296     MESSAGE("Unable to access  number of support different types");
00297     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00298   }
00299 }
00300 
00301 
00302 //=============================================================================
00306 //=============================================================================
00307 
00308 SALOME_MED::medEntityMesh SUPPORT_i::getEntity() 
00309   throw (SALOME::SALOME_Exception)
00310 {
00311   if (_support==NULL)
00312     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00313   try
00314   {
00315     return convertMedEntToIdlEnt(_support->getEntity());
00316   }
00317   catch (MEDEXCEPTION &ex)
00318   {
00319     MESSAGE("Unable to access support s entity");
00320     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00321   }
00322 }
00323 
00324 //=============================================================================
00328 //=============================================================================
00329 
00330 SALOME_MED::medGeometryElement_array * SUPPORT_i::getTypes() 
00331   throw (SALOME::SALOME_Exception)
00332 {
00333   if (_support==NULL)
00334     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00335   SALOME_MED::medGeometryElement_array_var myseq = new SALOME_MED::medGeometryElement_array;
00336   try
00337   {
00338     int mySeqLength=_support->getNumberOfTypes();
00339     myseq->length(mySeqLength);
00340     const medGeometryElement * elemts = _support->getTypes();
00341     for (int i=0;i<mySeqLength;i++)
00342     {
00343       myseq[i]=convertMedEltToIdlElt(elemts[i]);
00344     }
00345   }
00346   catch (MEDEXCEPTION &ex)
00347   {
00348     MESSAGE("Unable to access support different types");
00349     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00350   }
00351   return myseq._retn();
00352 }
00353 
00354 //=============================================================================
00359 //=============================================================================
00360 CORBA::Long SUPPORT_i::getNumberOfElements(SALOME_MED::medGeometryElement geomElement) 
00361   throw (SALOME::SALOME_Exception)
00362 {
00363   SCRUTE(geomElement);
00364   SCRUTE(SALOME_MED::MED_ALL_ELEMENTS);
00365 
00366   if (_support==NULL)
00367     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00368   try
00369   {
00370     return _support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
00371   }
00372   catch (MEDEXCEPTION &ex)
00373   {
00374     MESSAGE("Unable to access the number of support different types");
00375     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00376   }
00377 }
00378 
00379 //=============================================================================
00383 //=============================================================================
00384 
00385 SALOME_TYPES::ListOfLong *  SUPPORT_i::getNumber(SALOME_MED::medGeometryElement geomElement) 
00386   throw (SALOME::SALOME_Exception)
00387 {
00388   SCRUTE(_support);
00389   SCRUTE(geomElement);
00390   SCRUTE(convertIdlEltToMedElt(geomElement));
00391 
00392   if (_support==NULL)
00393     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00394   SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong;
00395   try
00396   {
00397     int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
00398     myseq->length(nbelements);
00399     SCRUTE(_support->getName());
00400     SCRUTE(nbelements);
00401     SCRUTE(convertIdlEltToMedElt(geomElement));
00402     const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
00403     for (int i=0;i<nbelements;i++)
00404     {
00405       myseq[i]=numbers[i];
00406       SCRUTE(numbers[i]);
00407     }
00408   }
00409   catch (MEDEXCEPTION &ex)
00410   {
00411     MESSAGE("Unable to access the support optionnal index");
00412     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00413   }
00414   return myseq._retn();
00415 }
00416 
00417 //=============================================================================
00421 //=============================================================================
00422 SALOME_TYPES::ListOfLong *  SUPPORT_i::getNumberFromFile(SALOME_MED::medGeometryElement geomElement) 
00423   throw (SALOME::SALOME_Exception)
00424 {
00425   SCRUTE(_support);
00426   SCRUTE(geomElement);
00427   SCRUTE(convertIdlEltToMedElt(geomElement));
00428 
00429   if (_support==NULL)
00430     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00431   SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong;
00432   try
00433   {
00434     int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
00435     myseq->length(nbelements);
00436     SCRUTE(_support->getName());
00437     SCRUTE(nbelements);
00438     SCRUTE(convertIdlEltToMedElt(geomElement));
00439     const int * numbers=_support->getNumberFromFile(convertIdlEltToMedElt(geomElement));
00440     for (int i=0;i<nbelements;i++)
00441     {
00442       myseq[i]=numbers[i];
00443       SCRUTE(numbers[i]);
00444     }
00445   }
00446   catch (MEDEXCEPTION &ex)
00447   {
00448     MESSAGE("Unable to access the support optionnal index");
00449     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00450   }
00451   return myseq._retn();
00452 }
00453 
00454 //=============================================================================
00458 //=============================================================================
00459 SALOME::SenderInt_ptr SUPPORT_i::getSenderForNumber(SALOME_MED::medGeometryElement geomElement) 
00460   throw (SALOME::SALOME_Exception)
00461 {
00462   SCRUTE(_support);
00463   SCRUTE(geomElement);
00464   SCRUTE(convertIdlEltToMedElt(geomElement));
00465   if (_support==NULL)
00466     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00467   SALOME::SenderInt_ptr ret;
00468   try
00469   {
00470     int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
00471     const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
00472     ret=SenderFactory::buildSender(*this,numbers,nbelements);
00473   }
00474   catch (MEDEXCEPTION &ex)
00475   {
00476     MESSAGE("Unable to access the support optionnal index");
00477     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00478   }
00479   catch(MultiCommException &ex2)
00480     THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
00481   return ret;
00482 }
00483 //=============================================================================
00488 //=============================================================================
00489 
00490 SALOME_TYPES::ListOfLong *  SUPPORT_i::getNumberIndex()
00491   throw (SALOME::SALOME_Exception)
00492 {
00493   if (_support==NULL)
00494     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00495   SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong;
00496   try
00497   {
00498     MESSAGE ("Nombre d'elements  mis de façon stupide a MED_ALL_ELEMENTS");
00499     int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
00500     myseq->length(nbelements);
00501     const int * numbers=_support->getNumberIndex();
00502     for (int i=0;i<nbelements;i++)
00503     {
00504       myseq[i]=numbers[i];
00505     }
00506   }
00507   catch (MEDEXCEPTION &ex)
00508   {
00509     MESSAGE("Unable to access the support index");
00510     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00511   }
00512   return myseq._retn();
00513 }
00514 //=============================================================================
00518 //=============================================================================
00519 
00520 SALOME::SenderInt_ptr SUPPORT_i::getSenderForNumberIndex() 
00521   throw (SALOME::SALOME_Exception)
00522 {
00523   if (_support==NULL)
00524     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00525   SALOME::SenderInt_ptr ret;
00526   try
00527   {
00528     MESSAGE ("Nombre d'elements  mis de façon stupide a MED_ALL_ELEMENTS");
00529     int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
00530     const int * numbers=_support->getNumberIndex();
00531     ret=SenderFactory::buildSender(*this,numbers,nbelements);
00532   }
00533   catch (MEDEXCEPTION &ex)
00534   {
00535     MESSAGE("Unable to access the support index");
00536     THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
00537   }
00538   catch(MultiCommException &ex2)
00539     THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
00540   return ret;
00541 }
00542 //=============================================================================
00546 //=============================================================================
00547 
00548 void SUPPORT_i::getBoundaryElements()
00549   throw (SALOME::SALOME_Exception)
00550 {
00551   if (_support==NULL)
00552     THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR);
00553   try
00554   {
00555     (const_cast< ::SUPPORT *>(_support))->getBoundaryElements();
00556   }
00557   catch (MEDEXCEPTION &)
00558   {
00559     MESSAGE("Unable to access elements");
00560     THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object",
00561                                  SALOME::INTERNAL_ERROR);
00562   }
00563 }
00564 //=============================================================================
00568 //=============================================================================
00569 void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr myIor)
00570   throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
00571 {
00572   if ( _supportId != "" )
00573   {
00574     MESSAGE("Support already in Study");
00575     THROW_SALOME_CORBA_EXCEPTION("Support already in Study", SALOME::BAD_PARAM);
00576   };
00577 
00578   if ( CORBA::is_nil(myStudy) )
00579   {
00580     MESSAGE("Study not found");
00581     THROW_SALOME_CORBA_EXCEPTION("Study deleted !!!",
00582                                  SALOME::INTERNAL_ERROR);
00583   }
00584 
00585 
00586   SALOMEDS::StudyBuilder_var     myBuilder = myStudy->NewBuilder();
00587   SALOMEDS::GenericAttribute_var anAttr;
00588   SALOMEDS::AttributeName_var    aName;
00589   SALOMEDS::AttributeIOR_var     aIOR;
00590 
00591   // Find SComponent labelled 'Med'
00592   MESSAGE(" Find SComponent labelled 'MED'");
00593   SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
00594   if ( CORBA::is_nil(medfather) ) 
00595   {
00596     MESSAGE("MED not found");
00597     THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
00598   }
00599 
00600   // Find SObject MESH (represent mesh in support)
00601   SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
00602   if ( CORBA::is_nil(medmeshfather) )
00603   {
00604     MESSAGE(" No /Med/MEDMESH Found in study")
00605       THROW_SALOME_CORBA_EXCEPTION("SObject labelled 'MEDMESH' not Found",SALOME::INTERNAL_ERROR);
00606   }
00607   MESSAGE(" Find SObject MESH (represent mesh in support)");
00608 
00609   string meshName = _support->getMeshName() ;
00610   string meshNameStudy = meshName;
00611 
00612   for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
00613   {
00614     if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
00615   }
00616 
00617   // seulement sous Med : il peut y avoir le meme sous SMESH !!!
00618   SALOMEDS::SObject_var medsupportfather = myStudy->FindObject(meshName.c_str()); 
00619   if ( CORBA::is_nil(medsupportfather) ) 
00620     THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR);
00621   // perhaps add MESH automatically ?
00622 
00623   MESSAGE("Add a support Object under /Med/MESH/MESHNAME");
00624 
00625   char * medsupfatherName;
00626   int lenName = 15 + strlen(meshName.c_str()) + 1;
00627   medsupfatherName = new char[lenName];
00628   medsupfatherName = strcpy(medsupfatherName,"MEDSUPPORTS_OF_");
00629   medsupfatherName = strcat(medsupfatherName,meshNameStudy.c_str());
00630 
00631   SCRUTE(medsupfatherName);
00632 
00633   SALOMEDS::SObject_var medsupfather = myStudy->FindObject(medsupfatherName);
00634   if ( CORBA::is_nil(medsupfather) )
00635   {
00636     MESSAGE("Add Object MEDSUPPORT");
00637     medsupfather = myBuilder->NewObject(medmeshfather);
00638     anAttr = myBuilder->FindOrCreateAttribute(medsupfather, "AttributeName");
00639     aName = SALOMEDS::AttributeName::_narrow(anAttr);
00640     aName->SetValue(medsupfatherName);
00641 } ;
00642 
00643   //myBuilder->NewCommand();
00644 
00645   string supportEntryPath = getEntryPath( _support );
00646 
00647   SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
00648 
00649 
00650 
00651   if ( CORBA::is_nil(supportEntry) ) 
00652   {
00653     MESSAGE(" supportEntry is a nil corba object and is going to be created");
00654     // not already in study : we create it !
00655     SALOMEDS::SObject_var newObj = myBuilder->NewObject(medsupfather);
00656     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
00657     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
00658     CORBA::ORB_var &orb = init(0,0);
00659     CORBA::String_var iorStr = orb->object_to_string(myIor);
00660     anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
00661     aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00662     aIOR->SetValue(iorStr.in());
00663     anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
00664     aName = SALOMEDS::AttributeName::_narrow(anAttr);
00665     aName->SetValue(_support->getName().c_str());
00666     _supportId = newObj->GetID();
00667   }
00668   else
00669   {
00670     // already in study : put new AttributeIOR !
00671     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
00672     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
00673     CORBA::ORB_var &orb = init(0,0);
00674     CORBA::String_var iorStr = orb->object_to_string(myIor);
00675     anAttr = myBuilder->FindOrCreateAttribute(supportEntry, "AttributeIOR");
00676     aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
00677     aIOR->SetValue(iorStr.in());
00678   }
00679   myBuilder->CommitCommand();
00680 
00681   SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath.c_str());
00682 
00683   MESSAGE("Just for checking, reuse of the corba pointer");
00684 
00685   if ( CORBA::is_nil(supportEntry) ) 
00686   {
00687     MESSAGE("The reuse is OK");
00688   }
00689   else
00690   {
00691     MESSAGE("well !! the reuse is not OK and there was a problem in the storage in the study");
00692   }
00693 
00694   delete [] medsupfatherName;
00695 
00696 
00697   // register the Corba pointer: increase the referrence count
00698   MESSAGE("Registering of the Corba Support pointer");
00699   Register();
00700 }
00701 
00702 //=======================================================================
00703 //function : getEntryPath
00704 //purpose  : 
00705 //=======================================================================
00706 
00707 string SUPPORT_i::getEntryPath(const ::MEDMEM::SUPPORT * aSupport)
00708 {
00709   string meshNameStudy( aSupport->getMeshName() );
00710   for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
00711     if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
00712 
00713   string supportName = aSupport->getName();
00714   string supportNameStudy( supportName.c_str(), strlen( supportName.c_str() ));
00715   string supportEntryPath =
00716     "/Med/MEDMESH/MEDSUPPORTS_OF_" + meshNameStudy + "/" + supportNameStudy;
00717   SCRUTE( supportEntryPath );
00718 
00719   return supportEntryPath;
00720 }