1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 //=============================================================================
21 // File : MEDMEM_Med_i.cxx
24 // Copyright : EDF 2002
25 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_i.cxx
26 //=============================================================================
30 //#include "MEDMEM_Field.hxx"
32 #include "MEDMEM_Med_i.hxx"
33 #include "MEDMEM_Mesh_i.hxx"
34 #include "MEDMEM_FieldDouble_i.hxx"
35 #include "MEDMEM_FieldInt_i.hxx"
36 #include "MEDMEM_Support_i.hxx"
37 #include "MEDMEM_Family_i.hxx"
38 #include "MEDMEM_Group_i.hxx"
39 #include "MEDMEM_convert.hxx"
40 #include "MEDMEM_Family.hxx"
41 #include "MEDMEM_Group.hxx"
43 #include "MEDMEM_DriversDef.hxx"
44 #include "utilities.h"
45 #include "Utils_CorbaException.hxx"
48 using namespace MEDMEM;
50 //=============================================================================
54 //=============================================================================
55 MED_i::MED_i():_med((::MED*)NULL)
57 BEGIN_OF("Default Constructor MED_i");
59 END_OF("Default Constructor MED_i");
61 //=============================================================================
65 //=============================================================================
66 void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const string & fileName)
68 const char * LOC = "MED_i::init(driverTypes, const string &)";
71 // we create all IOR from _med
74 _med = new ::MED(driverType,fileName);
77 deque<string> meshesNames = _med->getMeshNames();
78 int numberOfMeshes = meshesNames.size();
79 for (int i=0; i<numberOfMeshes; i++)
81 ::MESH * myMesh = _med->getMesh(meshesNames[i]);
83 MESH_i * myMeshI = new MESH_i(myMesh);
84 SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this();
85 _meshes[meshesNames[i]] = myMeshIOR;
86 // myMeshI->addInStudy(myStudy,myMeshIOR,fileName);
90 _med->updateSupport();
93 // we add all families
94 vector<FAMILY*> familyVector;
95 vector<FAMILY*>::iterator familyVectorIt;
98 vector<GROUP*> groupVector;
99 vector<GROUP*>::iterator groupVectorIt;
101 MED_EN::MESH_ENTITIES::const_iterator currentEntity;
102 for (int i=0; i<numberOfMeshes; i++)
104 ::MESH * ptrMesh = _med->getMesh(meshesNames[i]);
105 for (currentEntity = MED_EN::meshEntities.begin();
106 currentEntity != MED_EN::meshEntities.end();
109 // MESSAGE(LOC << ": for entity " << (*currentEntity).first);
111 familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first);
112 int nb = familyVector.size();
113 // MESSAGE(LOC << ": there is(are) " << nb << " family(ies)");
114 for (familyVectorIt = familyVector.begin();
115 familyVectorIt != familyVector.end();
118 FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
119 SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this();
120 // myFamilyI->addInStudy(myStudy,myFamilyIOR);
124 groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first);
125 nb = groupVector.size();
126 // MESSAGE(LOC << ": there is(are) " << nb << " group(s)");
127 for (groupVectorIt = groupVector.begin();
128 groupVectorIt != groupVector.end();
131 GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
132 SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this();
133 // myGroupI->addInStudy(myStudy,myGroupIOR);
138 for (int i=0; i<numberOfMeshes; i++)
140 map<MED_EN::medEntityMesh,::SUPPORT*> mySupports = _med->getSupports(meshesNames[i]);
141 map<MED_EN::medEntityMesh,::SUPPORT*>::const_iterator itSupport;
142 map<MED_EN::medEntityMesh, SALOME_MED::SUPPORT_ptr> & mySupportsIOR
143 = _supports[meshesNames[i]];
144 for ( itSupport = mySupports.begin(); itSupport != mySupports.end(); itSupport++ )
146 SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
147 SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this();
148 mySupportsIOR[(*itSupport).first] = mySupportIOR;
149 // mySupportI->addInStudy(myStudy,mySupportIOR);
154 deque<string> fieldsNames = _med->getFieldNames();
155 int numberOfFields = fieldsNames.size();
156 for (int i=0; i<numberOfFields; i++)
158 deque<DT_IT_> myIteration = _med->getFieldIteration (fieldsNames[i]);
159 int numberOfIteration = myIteration.size();
160 for (int j=0; j<numberOfIteration; j++)
162 ::FIELD_ * myField = _med->getField(fieldsNames[i], myIteration[j].dt, myIteration[j].it);
163 string meshName = myField->getSupport()->getMesh()->getName();
164 medEntityMesh myEntity = myField->getSupport()->getEntity();
165 map<string, map<MED_EN::medEntityMesh, SALOME_MED::SUPPORT_ptr> >::const_iterator
166 itSupportOnMesh = _supports.find(meshName);
167 if ( itSupportOnMesh == _supports.end() )
168 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
169 << "There is no support on mesh named |"
170 << meshName << "|" ));
171 const map<MED_EN::medEntityMesh, SALOME_MED::SUPPORT_ptr> & SupportOnMesh
172 = (*itSupportOnMesh).second;
173 map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr>::const_iterator itSupport
174 = SupportOnMesh.find(myEntity);
175 if (itSupport == SupportOnMesh.end())
176 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
177 << "There is no support on entity "
178 << entity << " in mesh named |"
179 << meshName << "|"));
180 SALOME_MED::SUPPORT_ptr mySupportIOR = (*itSupport).second;
181 med_type_champ type = myField->getValueType();
182 SALOME_MED::FIELD_ptr myFieldIOR;
185 case MED_EN::MED_INT32 :
187 ((FIELD<int>*)myField)->read();
188 FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
189 myFieldIOR = myFieldIntI->_this();
190 // myFieldIntI->addInStudy(myStudy,myFieldIOR);
194 case MED_EN::MED_REEL64:
196 ((FIELD<double>*)myField)->read();
197 FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
198 myFieldIOR = myFieldDoubleI->_this();
199 // myFieldDoubleI->addInStudy(myStudy,myFieldIOR);
204 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
205 <<" * Iteration "<<FieldIteration[j].dt
206 <<", order number "<<FieldIteration[j].it
207 <<" has wrong type : "<<type));
213 dtIt.dt = myIteration[j].dt;
214 dtIt.it = myIteration[j].it;
215 _fields[fieldsNames[i]][dtIt] = myFieldIOR;
222 //=============================================================================
226 //=============================================================================
227 void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const string & fileName)
229 const char * LOC = "MED_i::initWithFieldType(driverTypes, const string &)";
232 // we create all IOR from _med
239 _med = new ::MED(driverType,fileName);
241 int numberOfMeshes = _med->getNumberOfMeshes();
242 SCRUTE(numberOfMeshes);
244 deque<string> meshesNames = _med->getMeshNames();
245 string meshName0 = meshesNames[0];
249 for (int i=0; i<numberOfMeshes; i++)
251 string meshNamei = meshesNames[i];
254 ::MESH * myMesh = _med->getMesh(meshNamei);
256 MESH_i * myMeshI = new MESH_i(myMesh);
257 SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this();
258 _meshes[meshesNames[i]]=myMeshIOR;
259 myMeshI->addInStudy(myStudy,myMeshIOR);
263 _med->updateSupport();
266 // we add all families
267 vector<FAMILY*> familyVector;
268 vector<FAMILY*>::iterator familyVectorIt;
271 vector<GROUP*> groupVector;
272 vector<GROUP*>::iterator groupVectorIt;
274 SCRUTE(numberOfMeshes);
276 MED_EN::MESH_ENTITIES::const_iterator currentEntity;
277 for (int i=0; i<numberOfMeshes; i++)
279 ::MESH * ptrMesh = _med->getMesh(meshesNames[i]);
283 for (currentEntity = MED_EN::meshEntities.begin();
284 currentEntity != MED_EN::meshEntities.end();
287 MESSAGE(LOC << ": for entity " << (*currentEntity).first);
289 familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first);
290 int nb = familyVector.size();
291 MESSAGE(LOC << ": there is(are) " << nb << " family(ies)");
292 for (familyVectorIt = familyVector.begin();
293 familyVectorIt != familyVector.end();
296 FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
297 SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this();
298 myFamilyI->addInStudy(myStudy,myFamilyIOR);
302 groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first);
303 nb = groupVector.size();
304 MESSAGE(LOC << ": there is(are) " << nb << " group(s)");
305 for (groupVectorIt = groupVector.begin();
306 groupVectorIt != groupVector.end();
309 GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
310 SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this();
311 myGroupI->addInStudy(myStudy,myGroupIOR);
316 for (int i=0; i<numberOfMeshes; i++)
318 map<MED_EN::medEntityMesh,::SUPPORT*> mySupports = _med->getSupports(meshesNames[i]);
319 map<MED_EN::medEntityMesh,::SUPPORT*>::const_iterator itSupport;
320 map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr> &
321 mySupportsIOR = _supports[meshesNames[i]];
322 for (itSupport=mySupports.begin(); itSupport!=mySupports.end(); itSupport++ )
324 SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
325 SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this();
326 mySupportsIOR[(*itSupport).first]= mySupportIOR;
327 mySupportI->addInStudy(myStudy,mySupportIOR);
334 // for (int i=0; i<numberOfMeshes; i++)
336 // string meshName = meshesNames[i];
337 // char * supportEntryPath;
339 // string supportName;
340 // SALOMEDS::SObject_var supportEntry;
342 // supportName = "SupportOnAll_MED_MAILLE";
343 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
344 // supportEntryPath = new char[lenName];
345 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
346 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
347 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
348 // supportEntryPath = strcat(supportEntryPath,"/");
349 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
351 // SCRUTE(supportEntryPath);
353 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
355 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
357 // if ( CORBA::is_nil(supportEntry) )
358 // cout << "The reuse in Med is OK " << endl;
360 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
361 // delete [] supportEntryPath;
365 // supportName = "SupportOnAll_MED_FACE";
366 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
367 // supportEntryPath = new char[lenName];
368 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
369 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
370 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
371 // supportEntryPath = strcat(supportEntryPath,"/");
372 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
374 // SCRUTE(supportEntryPath);
376 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
378 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
380 // if ( CORBA::is_nil(supportEntry) )
381 // cout << "The reuse in Med is OK " << endl;
383 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
384 // delete [] supportEntryPath;
388 // supportName = "SupportOnAll_MED_ARETE";
389 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
390 // supportEntryPath = new char[lenName];
391 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
392 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
393 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
394 // supportEntryPath = strcat(supportEntryPath,"/");
395 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
397 // SCRUTE(supportEntryPath);
399 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
401 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
403 // if ( CORBA::is_nil(supportEntry) )
404 // cout << "The reuse in Med is OK " << endl;
406 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
407 // delete [] supportEntryPath;
412 // supportName = "SupportOnAll_MED_NOEUD";
413 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
414 // supportEntryPath = new char[lenName];
415 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
416 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
417 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
418 // supportEntryPath = strcat(supportEntryPath,"/");
419 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
421 // SCRUTE(supportEntryPath);
423 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
425 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
427 // if ( CORBA::is_nil(supportEntry) )
428 // cout << "The reuse in Med is OK " << endl;
430 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
431 // delete [] supportEntryPath;
445 deque<string> fieldsNames = _med->getFieldNames();
446 int numberOfFields = fieldsNames.size();
448 SCRUTE(numberOfFields);
450 for (int i=0; i<numberOfFields; i++)
452 MESSAGE("The name of the " << i << "^th fields is "<< fieldsNames[i]);
454 deque<DT_IT_> myIteration = _med->getFieldIteration (fieldsNames[i]);
455 int numberOfIteration = myIteration.size();
457 SCRUTE(numberOfIteration);
459 for (int j=0; j<numberOfIteration; j++)
461 MESSAGE("its " << i << "^th iteration is dt = " << myIteration[j].dt << " it = " << myIteration[j].it);
465 for (int i=0; i<numberOfFields; i++)
468 MESSAGE("dealing with the fields collection " << fieldsNames[i]);
470 deque<DT_IT_> myIteration = _med->getFieldIteration (fieldsNames[i]);
471 int numberOfIteration = myIteration.size();
473 SCRUTE(numberOfIteration);
475 for (int j=0; j<numberOfIteration; j++)
477 int dt = myIteration[j].dt;
478 int it = myIteration[j].it;
480 MESSAGE("Treatement of " << fieldsNames[i] << " dt = " << dt << " it = " << it);
482 ::FIELD_ * myField = _med->getField(fieldsNames[i],dt,it);
484 string meshName = myField->getSupport()->getMesh()->getName();
485 medEntityMesh myEntity = myField->getSupport()->getEntity();
486 map<string, map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr> >::const_iterator
487 itSupportOnMesh = _supports.find(meshName);
488 if (itSupportOnMesh == _supports.end() )
489 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
490 << "There is no support on mesh named |"
491 << meshName << "|"));
492 const map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr> & SupportOnMesh
493 = (*itSupportOnMesh).second;
494 map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr>::const_iterator itSupport
495 = SupportOnMesh.find(myEntity);
496 if (itSupport == SupportOnMesh.end() )
497 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
498 << "There is no support on entity "
499 << entity << " in mesh named |"
500 << meshName << "|"));
501 SALOME_MED::SUPPORT_ptr mySupportIOR = (*itSupport).second;
502 med_type_champ type = myField->getValueType();
510 case MED_EN::MED_INT32:
512 ((FIELD<int>*)myField)->read();
513 FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
514 SALOME_MED::FIELDINT_ptr myFieldIntIOR;
515 myFieldIntIOR = myFieldIntI->_this();
517 MESSAGE(LOC << " add in study of the field " << fieldsNames[i].c_str() << " dt = " << dtIt.dt << " it = " << dtIt.it);
519 myFieldIntI->addInStudy(myStudy,myFieldIntIOR);
520 _fields[fieldsNames[i]][dtIt] = myFieldIntIOR;
524 case MED_EN::MED_REEL64:
526 ((FIELD<double>*)myField)->read();
527 FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
528 SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR;
529 myFieldDoubleIOR = myFieldDoubleI->_this();
531 MESSAGE(LOC << " add in study of the field " << fieldsNames[i].c_str() << " dt = " << dtIt.dt << " it = " << dtIt.it);
533 myFieldDoubleI->addInStudy(myStudy,myFieldDoubleIOR);
534 _fields[fieldsNames[i]][dtIt] = myFieldDoubleIOR;
540 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
541 <<" * Iteration "<<FieldIteration[j].dt
542 <<", order number "<<FieldIteration[j].it
543 <<" has wrong type : "<<type));
549 MESSAGE("Here we are i="<< i);
566 // for (int i=0; i<numberOfMeshes; i++)
568 // string meshName = meshesNames[i];
569 // char * supportEntryPath;
571 // string supportName;
572 // SALOMEDS::SObject_var supportEntry;
574 // supportName = "SupportOnAll_MED_MAILLE";
575 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
576 // supportEntryPath = new char[lenName];
577 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
578 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
579 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
580 // supportEntryPath = strcat(supportEntryPath,"/");
581 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
583 // SCRUTE(supportEntryPath);
585 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
587 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
589 // if ( CORBA::is_nil(supportEntry) )
590 // cout << "The reuse in Med is OK " << endl;
592 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
593 // delete [] supportEntryPath;
597 // supportName = "SupportOnAll_MED_FACE";
598 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
599 // supportEntryPath = new char[lenName];
600 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
601 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
602 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
603 // supportEntryPath = strcat(supportEntryPath,"/");
604 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
606 // SCRUTE(supportEntryPath);
608 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
610 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
612 // if ( CORBA::is_nil(supportEntry) )
613 // cout << "The reuse in Med is OK " << endl;
615 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
616 // delete [] supportEntryPath;
620 // supportName = "SupportOnAll_MED_ARETE";
621 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
622 // supportEntryPath = new char[lenName];
623 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
624 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
625 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
626 // supportEntryPath = strcat(supportEntryPath,"/");
627 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
629 // SCRUTE(supportEntryPath);
631 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
633 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
635 // if ( CORBA::is_nil(supportEntry) )
636 // cout << "The reuse in Med is OK " << endl;
638 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
639 // delete [] supportEntryPath;
644 // supportName = "SupportOnAll_MED_NOEUD";
645 // lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str());
646 // supportEntryPath = new char[lenName];
647 // supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
648 // supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
649 // supportEntryPath = strcat(supportEntryPath,meshName.c_str());
650 // supportEntryPath = strcat(supportEntryPath,"/");
651 // supportEntryPath = strcat(supportEntryPath,supportName.c_str());
653 // SCRUTE(supportEntryPath);
655 // cout << "supportEntryPath in Med " << supportEntryPath << " length " << lenName << endl;
657 // supportEntry = myStudy->FindObjectByPath(supportEntryPath);
659 // if ( CORBA::is_nil(supportEntry) )
660 // cout << "The reuse in Med is OK " << endl;
662 // cout << "the reuse in Med is not OK and there was a problem in the storage in the study" << endl;
663 // delete [] supportEntryPath;
687 //=============================================================================
691 //=============================================================================
697 //=======================================================================
698 //function : updateSupportIORs
700 //=======================================================================
702 void MED_i::updateSupportIORs(SALOMEDS::Study_ptr myStudy, const char* meshName)
704 vector<FAMILY*> familyVector;
705 vector<FAMILY*>::iterator familyVectorIt;
706 vector<GROUP*> groupVector;
707 vector<GROUP*>::iterator groupVectorIt;
708 string supportEntryPath;
710 ::MESH * ptrMesh = _med->getMesh(meshName);
712 MED_EN::MESH_ENTITIES::const_iterator currentEntity;
714 for (currentEntity = MED_EN::meshEntities.begin();
715 currentEntity != MED_EN::meshEntities.end();
719 familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first);
720 int nb = familyVector.size();
721 for (familyVectorIt = familyVector.begin();
722 familyVectorIt != familyVector.end();
725 supportEntryPath = SUPPORT_i::getEntryPath( meshName, *familyVectorIt );
726 SALOMEDS::SObject_var familyEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
727 if ( !familyEntry->_is_nil() || CORBA::is_nil( familyEntry->GetObject() ))
729 FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt);
730 SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this();
731 myFamilyI->addInStudy(myStudy,myFamilyIOR);
736 groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first);
737 nb = groupVector.size();
738 for (groupVectorIt = groupVector.begin();
739 groupVectorIt != groupVector.end();
742 supportEntryPath = SUPPORT_i::getEntryPath( meshName, *groupVectorIt );
743 SALOMEDS::SObject_var groupEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
744 if ( !groupEntry->_is_nil() || CORBA::is_nil( groupEntry->GetObject() ))
746 GROUP_i * myGroupI = new GROUP_i(*groupVectorIt);
747 SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this();
748 myGroupI->addInStudy(myStudy,myGroupIOR);
753 _med->updateSupport();
756 map<MED_EN::medEntityMesh,::SUPPORT*> mySupports = _med->getSupports(meshName);
757 map<MED_EN::medEntityMesh,::SUPPORT*>::const_iterator itSupport;
758 map<MED_EN::medEntityMesh,SALOME_MED::SUPPORT_ptr> &
759 mySupportsIOR = _supports[meshName];
760 for (itSupport=mySupports.begin(); itSupport!=mySupports.end(); itSupport++ )
762 supportEntryPath = SUPPORT_i::getEntryPath( meshName, itSupport->second);
763 SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
764 if ( !supportEntry->_is_nil() || CORBA::is_nil( supportEntry->GetObject() ))
766 SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second);
767 SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this();
768 mySupportsIOR[(*itSupport).first]= mySupportIOR;
769 mySupportI->addInStudy(myStudy,mySupportIOR);
775 //=============================================================================
777 * CORBA: Accessor for Number of meshes
779 //=============================================================================
780 CORBA::Long MED_i::getNumberOfMeshes()
781 throw (SALOME::SALOME_Exception)
784 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
785 SALOME::INTERNAL_ERROR);
788 return _med->getNumberOfMeshes();
790 catch (MEDEXCEPTION &ex)
792 MESSAGE("Unable to get the number of meshes in Med Object");
793 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
796 //=============================================================================
798 * CORBA: Accessor for Number of fields
800 //=============================================================================
801 CORBA::Long MED_i::getNumberOfFields()
802 throw (SALOME::SALOME_Exception)
805 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
806 SALOME::INTERNAL_ERROR);
809 return _med->getNumberOfFields();
811 catch (MEDEXCEPTION &ex)
813 MESSAGE("Unable to get the number of fields in Med Object");
814 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
817 //=============================================================================
819 * CORBA: Accessor for meshes names
821 //=============================================================================
822 SALOME_MED::string_array * MED_i::getMeshNames()
823 throw (SALOME::SALOME_Exception)
826 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
827 SALOME::INTERNAL_ERROR);
828 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
831 int nbMeshes=_med->getNumberOfMeshes();
832 myseq->length(nbMeshes);
833 string * nameMeshes = new string[nbMeshes];
834 _med->getMeshNames(nameMeshes);
835 for (int i=0;i<nbMeshes;i++)
837 myseq[i]=CORBA::string_dup(nameMeshes[i].c_str());
839 delete [] nameMeshes;
842 catch (MEDEXCEPTION &ex)
844 MESSAGE("Unable to get the names of the meshes in Med Object");
845 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
847 return myseq._retn();
849 //=============================================================================
851 * CORBA: Accessor for fields names
853 //=============================================================================
854 SALOME_MED::string_array * MED_i::getFieldNames()
855 throw (SALOME::SALOME_Exception)
858 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
859 SALOME::INTERNAL_ERROR);
860 SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
863 deque<string> nameFields = _med->getFieldNames();
864 int nbFields = nameFields.size();
865 myseq->length(nbFields);
867 for (int i=0;i<nbFields;i++)
869 myseq[i]=CORBA::string_dup(nameFields[i].c_str());
872 catch (MEDEXCEPTION &ex)
874 MESSAGE("Unable to get the names of the fields in Med Object");
875 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
877 return myseq._retn();
879 //=============================================================================
881 * CORBA: Accessor for a specific mesh
883 //=============================================================================
884 SALOME_MED::MESH_ptr MED_i::getMeshByName(const char* meshName)
885 throw (SALOME::SALOME_Exception)
888 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
889 SALOME::INTERNAL_ERROR);
890 SALOME_MED::MESH_ptr meshIOR;
893 map<string,SALOME_MED::MESH_ptr>::const_iterator name_meshIOR =
894 _meshes.find( meshName );
895 if ( name_meshIOR == _meshes.end() ) {
896 MESH * mesh=_med->getMesh(meshName);
897 MESH_i * m1 = new MESH_i(mesh);
898 meshIOR = m1->POA_SALOME_MED::MESH::_this();
899 _meshes[ meshName ] = meshIOR;
902 meshIOR = name_meshIOR->second;
905 catch (MEDEXCEPTION &ex)
907 MESSAGE("Unable to get the specified mesh");
908 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
912 //=============================================================================
914 * CORBA: Accessor for a specific mesh
916 //=============================================================================
917 SALOME_MED::MESH_ptr MED_i::getMesh(SALOME_MED::FIELD_ptr fieldPtr)
918 throw (SALOME::SALOME_Exception)
921 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
922 SALOME::INTERNAL_ERROR);
923 int ind=fieldPtr->getCorbaIndex();
927 SALOME_MED::FIELDINT_var fieldint =SALOME_MED::FIELDINT::_narrow(fieldPtr);
928 if (CORBA::is_nil(fieldint))
931 SALOME_MED::FIELDDOUBLE_var fielddouble =
932 SALOME_MED::FIELDDOUBLE::_narrow(fieldPtr);
933 ASSERT(!CORBA::is_nil(fielddouble));
935 ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
937 ::FIELD<double> * fdouble = (::FIELD<double> *)FIELD_i::fieldMap[ind];
938 mesh=_med->getMesh(fdouble);
943 ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
945 ::FIELD<int> * fint = (::FIELD<int> *)FIELD_i::fieldMap[ind];
946 mesh=_med->getMesh(fint);
948 MESH_i * meshi = new MESH_i(mesh);
949 return meshi->POA_SALOME_MED::MESH::_this();
952 //=============================================================================
954 * CORBA: Accessor for Number of iteration of a given field by its name.
956 //=============================================================================
957 CORBA::Long MED_i::getFieldNumberOfIteration(const char* fieldName)
958 throw (SALOME::SALOME_Exception)
961 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
962 SALOME::INTERNAL_ERROR);
966 deque<DT_IT_> fieldIteration = _med->getFieldIteration(string(fieldName));
967 return fieldIteration.size();
969 catch (MEDEXCEPTION &ex)
971 MESSAGE("Unable to get the number of iteration of the field " << fieldName << " in Med Object");
972 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
975 //=============================================================================
977 * CORBA: Accessor for the Corba equivalent DT_IT_ (see MEDMEM direcrtory)
978 * of a given field by its name and its number (sequence of two long integers).
980 //=============================================================================
981 SALOME_MED::long_array * MED_i::getFieldIteration(const char* fieldName,CORBA::Long i)
982 throw (SALOME::SALOME_Exception)
985 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
986 SALOME::INTERNAL_ERROR);
988 SALOME_MED::long_array_var myseq = new SALOME_MED::long_array;
991 deque<DT_IT_> fieldIteration = _med->getFieldIteration(string(fieldName));
992 int numberOfIteration = fieldIteration.size();
994 if (i < 0 || i >=numberOfIteration)
995 THROW_SALOME_CORBA_EXCEPTION("The integer i should be geater or equal to 0 and lesser then numberOfIteration", \
996 SALOME::INTERNAL_ERROR);
999 myseq[0] = fieldIteration[i].dt;
1000 myseq[1] = fieldIteration[i].it;
1001 return myseq._retn();
1003 catch (MEDEXCEPTION &ex)
1005 MESSAGE("Unable to get the sequence of DT_IT of the given field");
1006 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1009 //=============================================================================
1011 * CORBA: Accessor for the list of Corba equivalent DT_IT_ (see MEDMEM direcrtory)
1012 * of a given field by its name (sequence of two by iteration number long integers).
1014 //=============================================================================
1015 SALOME_MED::long_array * MED_i::getFieldIterations(const char* fieldName)
1016 throw (SALOME::SALOME_Exception)
1019 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1020 SALOME::INTERNAL_ERROR);
1022 SALOME_MED::long_array_var myseq = new SALOME_MED::long_array;
1025 deque<DT_IT_> fieldIteration = _med->getFieldIteration(string(fieldName));
1026 int numberOfIteration = fieldIteration.size();
1027 int size = 2*numberOfIteration;
1029 myseq->length(size);
1031 for (int i=0; i<numberOfIteration; i++)
1034 myseq[index] = fieldIteration[i].dt;
1036 myseq[index] = fieldIteration[i].it;
1039 return myseq._retn();
1041 catch (MEDEXCEPTION &ex)
1043 MESSAGE("Unable to get the sequence of DT_IT of the given field");
1044 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1047 //=============================================================================
1049 * CORBA: Accessor for a specific field
1051 //=============================================================================
1052 SALOME_MED::FIELD_ptr MED_i::getField(const char* fieldName,
1053 CORBA::Long pasTemps,
1054 CORBA::Long numOrdre )
1055 throw (SALOME::SALOME_Exception)
1057 const char * LOC="MED_i::getField(const char*,CORBA::Long,CORBA::Long) ";
1060 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1061 SALOME::INTERNAL_ERROR);
1063 SALOME_MED::FIELD_ptr myFieldIOR = SALOME_MED::FIELD::_nil();
1067 dtIt.dt= (int)pasTemps;
1068 dtIt.it= (int)numOrdre;
1070 map<string,MAP_IOR_DT_IT_>::const_iterator itFields = _fields.find(fieldName);
1071 if ( itFields != _fields.end() )
1073 const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second;
1074 MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt);
1075 if ( itMap_dtIt != map_dtIt.end() )
1076 myFieldIOR = (*itMap_dtIt).second;
1079 if ( CORBA::is_nil( myFieldIOR ))
1083 ::FIELD_* myField = _med->getField( fieldName, pasTemps, numOrdre);
1085 switch ( myField->getValueType() ) {
1086 case MED_EN::MED_INT32 : {
1087 FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD<int>*)myField);
1088 myFieldIOR = myFieldIntI->_this();
1092 case MED_EN::MED_REEL64: {
1093 FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD<double>*)myField);
1094 myFieldIOR = myFieldDoubleI->_this();
1098 THROW_SALOME_CORBA_EXCEPTION ("Wrong field type", SALOME::INTERNAL_ERROR);
1101 catch (const std::exception & ex)
1103 MESSAGE("Exception Interceptee : ");
1105 THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR);
1107 _fields[fieldName][dtIt] = myFieldIOR;
1113 //=============================================================================
1115 * CORBA: Accessor for a specific field
1117 //=============================================================================
1118 CORBA::Long MED_i::addDriver(SALOME_MED::medDriverTypes driverType, const char* fileName)
1119 throw (SALOME::SALOME_Exception)
1122 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1123 SALOME::INTERNAL_ERROR);
1126 int driv=_med->addDriver(convertIdlDriverToMedDriver(driverType),
1130 catch (MEDEXCEPTION &ex)
1132 MESSAGE("Unable to add a driver to the med object");
1133 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1137 //=============================================================================
1139 * CORBA: relase the driver (mandatory)
1141 //=============================================================================
1142 void MED_i::rmDriver(CORBA::Long i)
1143 throw (SALOME::SALOME_Exception)
1146 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1147 SALOME::INTERNAL_ERROR);
1152 catch (MEDEXCEPTION &ex)
1154 MESSAGE("Unable to unlink the driver from the med object");
1155 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1158 //=============================================================================
1160 * CORBA: read med objects relations
1162 //=============================================================================
1163 void MED_i::readFileStruct(CORBA::Long i)
1164 throw (SALOME::SALOME_Exception)
1167 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1168 SALOME::INTERNAL_ERROR);
1171 _med->readFileStruct(i);
1173 catch (MEDEXCEPTION &ex)
1175 MESSAGE("Unable to read the structure of this file ");
1176 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1179 //=============================================================================
1181 * CORBA: write specifics objects f
1183 //=============================================================================
1184 void MED_i::writeFrom(CORBA::Long i)
1185 throw (SALOME::SALOME_Exception)
1188 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1189 SALOME::INTERNAL_ERROR);
1194 catch (MEDEXCEPTION &ex)
1196 MESSAGE("Unable to write this driver ");
1197 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1200 //=============================================================================
1202 * CORBA: write objects
1204 //=============================================================================
1205 void MED_i::write(CORBA::Long i)
1206 throw (SALOME::SALOME_Exception)
1209 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1210 SALOME::INTERNAL_ERROR);
1215 catch (MEDEXCEPTION &ex)
1217 MESSAGE("Unable to write this file ");
1218 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1221 //=============================================================================
1223 * CORBA: Add Mesh in Med objects
1225 //=============================================================================
1226 void MED_i::addMesh(SALOME_MED::MESH_ptr ptrMesh)
1227 throw (SALOME::SALOME_Exception)
1230 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1231 SALOME::INTERNAL_ERROR);
1234 int ind=ptrMesh->getCorbaIndex();
1236 ASSERT(MESH_i::meshMap.find(ind) !=MESH_i::meshMap.end());
1237 MESH * mesh= MESH_i::meshMap[ind];
1238 _med->addMesh(mesh);
1240 catch (MEDEXCEPTION &ex)
1242 MESSAGE("Unable to link this mesh to this med object");
1243 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
1246 //=============================================================================
1248 * CORBA: Add field in Med objects
1250 //=============================================================================
1251 void MED_i::addField(SALOME_MED::FIELD_ptr ptrField)
1252 throw (SALOME::SALOME_Exception)
1255 THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\
1256 SALOME::INTERNAL_ERROR);
1257 int ind=ptrField->getCorbaIndex();
1260 SALOME_MED::FIELDINT_var fieldint =SALOME_MED::FIELDINT::_narrow(ptrField);
1261 if (CORBA::is_nil(fieldint))
1264 SALOME_MED::FIELDDOUBLE_var fielddouble =
1265 SALOME_MED::FIELDDOUBLE::_narrow(ptrField);
1266 ASSERT(!CORBA::is_nil(fielddouble));
1268 ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
1270 ::FIELD<double> * fdouble = (::FIELD<double> *)FIELD_i::fieldMap[ind];
1272 //_med->addField(fdouble);
1277 ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end());
1278 ::FIELD<int> * fint = (::FIELD<int> *)FIELD_i::fieldMap[ind];
1279 //_med->addField(fint);
1282 //=============================================================================
1284 * CORBA: Add Med object in Study
1286 //=============================================================================
1287 void MED_i::addInStudy(SALOMEDS::Study_ptr myStudy, SALOME_MED::MED_ptr myIor)
1288 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1290 BEGIN_OF("MED_Mesh_i::addInStudy");
1293 MESSAGE("Med already in Study");
1294 THROW_SALOME_CORBA_EXCEPTION("Med already in Study", \
1298 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1299 myBuilder->NewCommand();
1300 SALOMEDS::GenericAttribute_var anAttr;
1301 SALOMEDS::AttributeName_var aName;
1302 SALOMEDS::AttributeIOR_var aIOR;
1304 // Create SComponent labelled 'MED' if it doesn't already exit
1305 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1306 if ( CORBA::is_nil(medfather) )
1308 THROW_SALOME_CORBA_EXCEPTION("Component Med not found",
1312 MESSAGE("Add a MED Object under Med");
1313 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather);
1315 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
1316 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
1317 CORBA::ORB_var &orb = init(0,0);
1318 string iorStr = orb->object_to_string(myIor);
1319 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1320 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1321 aIOR->SetValue(iorStr.c_str());
1322 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1323 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1324 aName->SetValue("Objet MED");
1325 _medId = newObj->GetID();
1326 myBuilder->CommitCommand();
1328 // register the Corba pointer: increase the referrence count
1329 MESSAGE("Registering of the Corba Med pointer");
1332 END_OF("Med_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
1335 //=============================================================================
1337 * CORBA: Add Med object in Study with a name medObjName
1339 //=============================================================================
1340 void MED_i::addInStudy(SALOMEDS::Study_ptr myStudy, SALOME_MED::MED_ptr myIor,
1341 const char * fileName)
1342 throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
1344 BEGIN_OF("MED_i::addInStudy(myStudy, myIor, fileName)");
1347 MESSAGE("Med already in Study");
1348 THROW_SALOME_CORBA_EXCEPTION("Med already in Study", \
1352 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
1353 myBuilder->NewCommand();
1354 SALOMEDS::GenericAttribute_var anAttr;
1355 SALOMEDS::AttributeName_var aName;
1356 SALOMEDS::AttributeIOR_var aIOR;
1358 // Create SComponent labelled 'MED' if it doesn't already exit
1359 SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
1360 if ( CORBA::is_nil(medfather) )
1362 THROW_SALOME_CORBA_EXCEPTION("Component Med not found",
1366 MESSAGE("Add a MED Object under Med");
1369 string::size_type pos1=string(fileName).rfind('/');
1370 string::size_type lenFileName = strlen(fileName);
1371 string fileNameShort = string(fileName,pos1+1,lenFileName-pos1-1);
1373 SCRUTE(fileNameShort);
1375 int lenName = 21 + strlen(fileNameShort.c_str()) + 1;
1376 medObjName = new char[lenName];
1377 medObjName = strcpy(medObjName,"MED_OBJECT_FROM_FILE_");
1378 medObjName = strcat(medObjName,fileNameShort.c_str());
1380 SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather);
1382 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
1383 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
1384 CORBA::ORB_var &orb = init(0,0);
1385 string iorStr = orb->object_to_string(myIor);
1386 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
1387 aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1388 aIOR->SetValue(iorStr.c_str());
1389 anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
1390 aName = SALOMEDS::AttributeName::_narrow(anAttr);
1391 aName->SetValue(medObjName);
1392 _medId = newObj->GetID();
1393 myBuilder->CommitCommand();
1395 delete [] medObjName;
1397 // char * medObjName1;
1398 // lenName = 26 + strlen(fileNameShort.c_str());
1399 // medObjName1 = new char[lenName];
1400 // medObjName1 = strcpy(medObjName1,"/MED/MED_OBJECT_FROM_FILE_");
1401 // medObjName1 = strcat(medObjName1,fileNameShort.c_str());
1403 // SALOMEDS::SObject_var medEntry = myStudy->FindObjectByPath(medObjName1);
1404 // if (!CORBA::is_nil(medEntry))
1406 // MESSAGE("MED_Mesh_i::addInStudy(myStudy, myIor, fileName) : The reuse in Med of Object MED from Study is OK");
1410 // MESSAGE("MED_Mesh_i::addInStudy(myStudy, myIor, fileName) : the reuse in Med of Object MED is not OK and there was a problem in the storage in the study");
1413 // delete [] medObjName1;
1415 // register the Corba pointer: increase the referrence count
1416 MESSAGE("Registering of the Corba Med pointer");
1419 END_OF("Med_i::addInStudy(myStudy, myIor, medObjName)");