]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM_I/MEDMEM_Support_i.cxx
Salome HOME
update after merging trhe branches CEA_V3_0_x, OCC_V3_1_0_a1_x, and the main
[modules/med.git] / src / MEDMEM_I / MEDMEM_Support_i.cxx
1 //=============================================================================
2 // File      : MEDMEM_Support_i.cxx
3 // Project   : SALOME
4 // Author    : EDF
5 // Copyright : EDF 2002
6 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Support_i.cxx
7 //=============================================================================
8
9 #include "utilities.h"
10 #include "Utils_CorbaException.hxx"
11 #include "Utils_ORB_INIT.hxx"
12 #include "Utils_SINGLETON.hxx"
13
14 #include CORBA_SERVER_HEADER(MED)
15 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
16
17
18 #include "MEDMEM_define.hxx"
19 #include "MEDMEM_Support.hxx"
20
21 #include "MEDMEM_Support_i.hxx"
22 #include "MEDMEM_Mesh_i.hxx"
23 #include "MEDMEM_convert.hxx"
24
25 #include "SenderFactory.hxx"
26 #include "MultiCommException.hxx"
27 using namespace MEDMEM;
28
29 // Initialisation des variables statiques
30 map < int, ::SUPPORT *> SUPPORT_i::supportMap ;
31 int SUPPORT_i::supportIndex = 0 ;
32
33
34 //=============================================================================
35 /*!
36  * Default constructor
37  */
38 //=============================================================================
39 SUPPORT_i::SUPPORT_i() :_support((::SUPPORT *)NULL),_corbaIndex(SUPPORT_i::supportIndex++)
40 {
41         BEGIN_OF("Default Constructor SUPPORT_i");
42         END_OF("Default Constructor SUPPORT_i");
43 }
44
45 //=============================================================================
46 /*!
47  * Constructor
48  */
49 //=============================================================================
50 SUPPORT_i::SUPPORT_i(const ::SUPPORT * const s) :_support(s),
51                    _corbaIndex(SUPPORT_i::supportIndex++)
52 {
53         BEGIN_OF("Constructor SUPPORT_i");
54         SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support;
55         END_OF("Constructor SUPPORT_i");
56 }
57 //=============================================================================
58 /*!
59  * Constructor
60  */
61 //=============================================================================
62 SUPPORT_i::SUPPORT_i(const SUPPORT_i &s) :_support(s._support),
63                             _corbaIndex(SUPPORT_i::supportIndex++)
64 {
65         BEGIN_OF("Constructor SUPPORT_i");
66         SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support;
67         END_OF("Constructor SUPPORT_i");
68 }
69 //=============================================================================
70 /*!
71  * Destructor
72  */
73 //=============================================================================
74
75 SUPPORT_i::~SUPPORT_i()
76 {
77 }
78 //=============================================================================
79 /*!
80  * CORBA: Accessor for Corba Index 
81  */
82 //=============================================================================
83
84 CORBA::Long SUPPORT_i::getCorbaIndex()
85 throw (SALOME::SALOME_Exception)
86 {
87         if (_support==NULL)
88                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
89                                              SALOME::INTERNAL_ERROR);
90         return _corbaIndex;
91 }
92
93 //=============================================================================
94 /*!
95  * CORBA: Accessor for Name 
96  */
97 //=============================================================================
98
99 char * SUPPORT_i::getName()     
100 throw (SALOME::SALOME_Exception)
101 {
102         if (_support==NULL)
103                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
104                                              SALOME::INTERNAL_ERROR);
105         try
106         {
107                 return CORBA::string_dup(_support->getName().c_str());
108         }
109         catch (MEDEXCEPTION &ex)
110         {
111                 MESSAGE("Unable to access the name of the support ");
112                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
113         }
114
115 }
116
117 //=============================================================================
118 /*!
119  * CORBA: Accessor for Description 
120  */
121 //=============================================================================
122
123 char*  SUPPORT_i::getDescription()
124 throw (SALOME::SALOME_Exception)
125 {
126         if (_support==NULL)
127                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
128                                              SALOME::INTERNAL_ERROR);
129         try
130         {
131                 return CORBA::string_dup(_support->getDescription().c_str());
132         }
133         catch (MEDEXCEPTION &ex)
134         {
135                 MESSAGE("Unable to access the description of the support ");
136                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
137         }
138 }
139
140 //=============================================================================
141 /*!
142  * CORBA: Accessor for Description and Name
143  */
144 //=============================================================================
145
146 SALOME_MED::SUPPORT::supportInfos * SUPPORT_i::getSupportGlobal()
147 throw (SALOME::SALOME_Exception)
148 {
149         if (_support==NULL)
150                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
151                                              SALOME::INTERNAL_ERROR);
152         SALOME_MED::SUPPORT::supportInfos_var all = new SALOME_MED::SUPPORT::supportInfos;
153         try
154         {
155                 all->name               = CORBA::string_dup(_support->getName().c_str());
156                 all->description        = CORBA::string_dup(_support->getDescription().c_str());
157                 const int numberOfTypes = _support->getNumberOfTypes();
158                 all->numberOfGeometricType = numberOfTypes;
159                 all->entity = _support->getEntity();
160
161                 all->types.length(numberOfTypes);
162                 all->nbEltTypes.length(numberOfTypes);
163                 const medGeometryElement * elemts = _support->getTypes();
164                 for (int i=0;i<numberOfTypes;i++)
165                 {
166                         all->types[i]      = convertMedEltToIdlElt(elemts[i]);
167                         all->nbEltTypes[i] = _support->getNumberOfElements(elemts[i]);
168                 }
169         }
170         catch (MEDEXCEPTION &ex)
171         {
172                 MESSAGE("Unable to access the description of the support ");
173                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
174         }
175         return all._retn();
176
177 }
178
179
180 //=============================================================================
181 /*!
182  * CORBA: Accessor for Mesh 
183  */
184 //=============================================================================
185
186 SALOME_MED::MESH_ptr SUPPORT_i::getMesh()
187 throw (SALOME::SALOME_Exception)
188 {
189   BEGIN_OF("SALOME_MED::MESH_ptr SUPPORT_i::getMesh()");
190
191         if (_support==NULL)
192                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
193                                              SALOME::INTERNAL_ERROR);
194         try
195         {
196                 MESH * mesh = _support->getMesh();
197
198                 SCRUTE(mesh) ;
199
200                 MESH_i * m1 = new MESH_i(mesh);
201                 SALOME_MED::MESH_ptr m2 = m1->POA_SALOME_MED::MESH::_this();
202                 MESSAGE("SALOME_MED::MESH_ptr SUPPORT_i::getMesh() checking des pointeurs CORBA");
203
204                 SCRUTE(m1);
205                 SCRUTE(m2);
206
207                 END_OF("SALOME_MED::MESH_ptr SUPPORT_i::getMesh()");
208
209                 return (m2);
210         }
211         catch (MEDEXCEPTION &ex)
212         {
213                 MESSAGE("Unable to access the assoicated mesh");
214                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
215         }
216 }
217
218 //=============================================================================
219 /*!
220  * CORBA: boolean indicating if support concerns all elements 
221  */
222 //=============================================================================
223
224 CORBA::Boolean SUPPORT_i::isOnAllElements()
225 throw (SALOME::SALOME_Exception)
226 {
227         if (_support==NULL)
228                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
229                                              SALOME::INTERNAL_ERROR);
230         try
231         {
232                 return _support->isOnAllElements();
233         }
234         catch (MEDEXCEPTION &ex)
235         {
236                 MESSAGE("Unable to access the type of the support");
237                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
238         }
239 }
240
241 //=============================================================================
242 /*!
243  * CORBA:
244  */
245 //=============================================================================
246 CORBA::Long SUPPORT_i::getNumberOfTypes()
247 throw (SALOME::SALOME_Exception)
248 {
249         if (_support==NULL)
250                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
251                                              SALOME::INTERNAL_ERROR);
252         try
253         {
254                 return _support->getNumberOfTypes();
255         }
256         catch (MEDEXCEPTION &ex)
257         {
258                 MESSAGE("Unable to access  number of support different types");
259                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
260         }
261
262 }
263
264
265 //=============================================================================
266 /*!
267  * CORBA: Accessor for type of support's entity 
268  */
269 //=============================================================================
270
271 SALOME_MED::medEntityMesh SUPPORT_i::getEntity() 
272 throw (SALOME::SALOME_Exception)
273 {
274   BEGIN_OF("SALOME_MED::medEntityMesh SUPPORT_i::getEntity()");
275
276   if (_support==NULL)
277     THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
278                                              SALOME::INTERNAL_ERROR);
279   try
280     {
281       END_OF("SALOME_MED::medEntityMesh SUPPORT_i::getEntity()");
282       return convertMedEntToIdlEnt(_support->getEntity());
283     }
284   catch (MEDEXCEPTION &ex)
285     {
286       MESSAGE("Unable to access support s entity");
287                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
288     }
289 }
290
291 //=============================================================================
292 /*!
293  * CORBA: Accessor for types of geometry elements 
294  */
295 //=============================================================================
296
297 SALOME_MED::medGeometryElement_array * SUPPORT_i::getTypes() 
298 throw (SALOME::SALOME_Exception)
299 {
300         if (_support==NULL)
301                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
302                                              SALOME::INTERNAL_ERROR);
303         SALOME_MED::medGeometryElement_array_var myseq = new SALOME_MED::medGeometryElement_array;
304         try
305         {
306                 int mySeqLength=_support->getNumberOfTypes();
307                 myseq->length(mySeqLength);
308                 const medGeometryElement * elemts = _support->getTypes();
309                 for (int i=0;i<mySeqLength;i++)
310                 {
311                         myseq[i]=convertMedEltToIdlElt(elemts[i]);
312                 }
313         }
314         catch (MEDEXCEPTION &ex)
315         {
316                 MESSAGE("Unable to access support different types");
317                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
318         }
319         return myseq._retn();
320 }
321
322 //=============================================================================
323 /*!
324  * CORBA: Number of different types of geometry elements
325  *        existing in the support
326  */
327 //=============================================================================
328 CORBA::Long SUPPORT_i::getNumberOfElements(SALOME_MED::medGeometryElement geomElement) 
329 throw (SALOME::SALOME_Exception)
330 {
331
332   SCRUTE(geomElement);
333   SCRUTE(SALOME_MED::MED_ALL_ELEMENTS);
334
335         if (_support==NULL)
336                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
337                                              SALOME::INTERNAL_ERROR);
338         try
339         {
340                 return _support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
341         }
342         catch (MEDEXCEPTION &ex)
343         {
344                 MESSAGE("Unable to access the number of support different types");
345                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
346         }
347
348 }
349
350 //=============================================================================
351 /*!
352  * CORBA: get Nodes 
353  */
354 //=============================================================================
355
356 SALOME_MED::long_array *  SUPPORT_i::getNumber(SALOME_MED::medGeometryElement geomElement) 
357 throw (SALOME::SALOME_Exception)
358 {
359   SCRUTE(_support);
360   SCRUTE(geomElement);
361   SCRUTE(convertIdlEltToMedElt(geomElement));
362
363         if (_support==NULL)
364                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
365                                              SALOME::INTERNAL_ERROR);
366         SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
367         try
368         {
369                 int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
370                 myseq->length(nbelements);
371 SCRUTE(_support->getName());
372 SCRUTE(nbelements);
373 SCRUTE(convertIdlEltToMedElt(geomElement));
374                 const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
375                 for (int i=0;i<nbelements;i++)
376                 {
377                         myseq[i]=numbers[i];
378 SCRUTE(numbers[i]);
379                 }
380         }
381         catch (MEDEXCEPTION &ex)
382         {
383                 MESSAGE("Unable to access the support optionnal index");
384                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
385         }
386         return myseq._retn();
387         
388 }
389
390 //=============================================================================
391 /*!
392  * CORBA: 2nd get Nodes 
393  */
394 //=============================================================================
395 SALOME::SenderInt_ptr SUPPORT_i::getSenderForNumber(SALOME_MED::medGeometryElement geomElement) 
396                                            throw (SALOME::SALOME_Exception)
397 {
398   SCRUTE(_support);
399   SCRUTE(geomElement);
400   SCRUTE(convertIdlEltToMedElt(geomElement));
401   if (_support==NULL)
402     THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
403                                  SALOME::INTERNAL_ERROR);
404   SALOME::SenderInt_ptr ret;
405   try
406     {
407       int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
408       const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement));
409       ret=SenderFactory::buildSender(*this,numbers,nbelements);
410     }
411   catch (MEDEXCEPTION &ex)
412     {
413       MESSAGE("Unable to access the support optionnal index");
414       THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
415     }
416   catch(MultiCommException &ex2)
417           THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
418   return ret;
419 }
420 //=============================================================================
421 /*!
422  * CORBA: Global Nodes Index (optionnaly designed by the user)
423  * CORBA:  ??????????????????????????????
424  */
425 //=============================================================================
426
427 SALOME_MED::long_array *  SUPPORT_i::getNumberIndex()
428 throw (SALOME::SALOME_Exception)
429 {
430         if (_support==NULL)
431                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
432                                              SALOME::INTERNAL_ERROR);
433         SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
434         try
435         {
436                 MESSAGE ("Nombre d'elements  mis de façon stupide a MED_ALL_ELEMENTS");
437                 int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
438                 myseq->length(nbelements);
439                 const int * numbers=_support->getNumberIndex();
440                 for (int i=0;i<nbelements;i++)
441                 {
442                         myseq[i]=numbers[i];
443                 }
444         }
445         catch (MEDEXCEPTION &ex)
446         {
447                 MESSAGE("Unable to access the support index");
448                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
449         }
450         return myseq._retn();
451         
452 }
453 //=============================================================================
454 /*!
455  * CORBA: 2nd Global Nodes Index (optionnaly designed by the user)
456  */
457 //=============================================================================
458
459 SALOME::SenderInt_ptr SUPPORT_i::getSenderForNumberIndex() 
460   throw (SALOME::SALOME_Exception)
461 {
462   if (_support==NULL)
463     THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
464                                  SALOME::INTERNAL_ERROR);
465   SALOME::SenderInt_ptr ret;
466   try
467     {
468       MESSAGE ("Nombre d'elements  mis de façon stupide a MED_ALL_ELEMENTS");
469       int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS);
470       const int * numbers=_support->getNumberIndex();
471       ret=SenderFactory::buildSender(*this,numbers,nbelements);
472     }
473   catch (MEDEXCEPTION &ex)
474     {
475       MESSAGE("Unable to access the support index");
476       THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
477     }
478   catch(MultiCommException &ex2)
479           THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR);
480   return ret;
481 }
482 //=============================================================================
483 /*!
484  * CORBA:
485  */
486 //=============================================================================
487
488 void SUPPORT_i::getBoundaryElements()
489 throw (SALOME::SALOME_Exception)
490 {
491         if (_support==NULL)
492                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
493                                              SALOME::INTERNAL_ERROR);
494         try
495         {
496                 (const_cast< ::SUPPORT *>(_support))->getBoundaryElements();
497         }
498         catch (MEDEXCEPTION &ex)
499         {
500                 MESSAGE("Unable to access elements");
501                 THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
502                                                 ,SALOME::INTERNAL_ERROR);
503         }
504 }
505
506
507 //=============================================================================
508 /*!
509  * CORBA: Array containing indexes for elements included in the support  
510  */
511 //=============================================================================
512
513 CORBA::Long SUPPORT_i::getNumberOfGaussPoint(SALOME_MED::medGeometryElement geomElement)
514 throw (SALOME::SALOME_Exception)
515 {
516         if (_support==NULL)
517                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
518                                              SALOME::INTERNAL_ERROR);
519         try
520         {
521                 return _support->getNumberOfGaussPoint(convertIdlEltToMedElt(geomElement));
522         }
523         catch (MEDEXCEPTION &ex)
524         {
525                 MESSAGE("Unable to access number of Gauss points");
526                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
527         }
528 }
529 //=============================================================================
530 /*!
531  * CORBA: Global Nodes Index (optionnaly designed by the user)
532  */
533 //=============================================================================
534 SALOME_MED::long_array *  SUPPORT_i::getNumbersOfGaussPoint()
535 throw (SALOME::SALOME_Exception)
536 {
537         if (_support==NULL)
538                 THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
539                                              SALOME::INTERNAL_ERROR);
540         SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
541         try
542         {
543                 int mySeqLength=_support->getNumberOfTypes();
544                 myseq->length(mySeqLength);
545                 const medGeometryElement * elemts = _support->getTypes();
546                 for (int i=0;i<mySeqLength;i++)
547                 {
548                         myseq[i]= _support->getNumberOfGaussPoint(elemts[i]);
549                 }
550         }
551         catch (MEDEXCEPTION &ex)
552         {
553                 MESSAGE("Unable to access number of Gauss points");
554                 THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
555         }
556         return myseq._retn();
557 }
558 //=============================================================================
559 /*!
560  * CORBA: add the Support in the StudyManager 
561  */
562 //=============================================================================
563 void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr myIor)
564   throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection)
565 {
566   const char * LOC = "SUPPORT_i::addInStudy";
567   BEGIN_OF(LOC);
568
569   if ( _supportId != "" )
570   {
571       MESSAGE(LOC << "Support already in Study");
572       THROW_SALOME_CORBA_EXCEPTION("Support already in Study", \
573                                    SALOME::BAD_PARAM);
574   };
575
576   if ( CORBA::is_nil(myStudy) )
577   {
578       MESSAGE(LOC << "Study not found");
579       THROW_SALOME_CORBA_EXCEPTION("Study deleted !!!",
580                                     SALOME::INTERNAL_ERROR);
581   }
582
583   
584   SALOMEDS::StudyBuilder_var     myBuilder = myStudy->NewBuilder();
585   SALOMEDS::GenericAttribute_var anAttr;
586   SALOMEDS::AttributeName_var    aName;
587   SALOMEDS::AttributeIOR_var     aIOR;
588   
589   // Find SComponent labelled 'Med'
590   MESSAGE(LOC << " Find SComponent labelled 'MED'");
591   SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
592   if ( CORBA::is_nil(medfather) ) 
593   { 
594     MESSAGE(LOC << "MED not found");
595     THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR);
596   }
597
598   // Find SObject MESH (represent mesh in support)
599   SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH");
600   if ( CORBA::is_nil(medmeshfather) )
601   { 
602     MESSAGE(LOC << " No /Med/MEDMESH Found in study")
603     THROW_SALOME_CORBA_EXCEPTION("SObject labelled 'MEDMESH' not Found",SALOME::INTERNAL_ERROR);
604   }
605   MESSAGE(LOC << " Find SObject MESH (represent mesh in support)");
606
607   string meshName = getMesh()->getName() ;
608   string meshNameStudy = meshName;
609
610   for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
611     {
612       if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
613     }
614
615                 // seulement sous Med : il peut y avoir le meme sous SMESH !!!
616   SALOMEDS::SObject_var medsupportfather = myStudy->FindObject(meshName.c_str()); 
617   if ( CORBA::is_nil(medsupportfather) ) 
618     THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR);
619   // perhaps add MESH automatically ?
620   
621   MESSAGE("Add a support Object under /MED/MESH/MESHNAME");
622
623   char * medsupfatherName;
624   int lenName = 15 + strlen(meshName.c_str()) + 1;
625   medsupfatherName = new char[lenName];
626   medsupfatherName = strcpy(medsupfatherName,"MEDSUPPORTS_OF_");
627   medsupfatherName = strcat(medsupfatherName,meshNameStudy.c_str());
628
629   SCRUTE(medsupfatherName);
630
631   SALOMEDS::SObject_var medsupfather = myStudy->FindObject(medsupfatherName);
632   if ( CORBA::is_nil(medsupfather) )
633   {
634                 MESSAGE("Add Object MEDSUPPORT");
635                 medsupfather = myBuilder->NewObject(medmeshfather);
636                 anAttr = myBuilder->FindOrCreateAttribute(medsupfather, "AttributeName");
637                 aName = SALOMEDS::AttributeName::_narrow(anAttr);
638                 aName->SetValue(medsupfatherName);
639
640   } ;
641
642   //myBuilder->NewCommand();
643
644   string supportName = _support->getName();
645
646   SCRUTE(supportName);
647
648   SCRUTE(meshNameStudy);
649
650   char * supportEntryPath;
651   lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str())+1;
652   supportEntryPath = new char[lenName];
653   supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
654   supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
655   supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
656   supportEntryPath = strcat(supportEntryPath,"/");
657   supportEntryPath = strcat(supportEntryPath,supportName.c_str());
658
659   //SCRUTE(supportEntryPath);
660
661   MESSAGE("supportEntryPath in support " << supportEntryPath << " length " << lenName);
662
663 //   SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str());
664                          // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!!
665   SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath);
666
667   if ( CORBA::is_nil(supportEntry) ) 
668   {
669     MESSAGE(" supportEntry is a nil corba object and is going to be created");
670     // not already in study : we create it !
671     SALOMEDS::SObject_var newObj = myBuilder->NewObject(medsupfather);
672     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
673     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
674     CORBA::ORB_var &orb = init(0,0);
675     string iorStr = orb->object_to_string(myIor);
676     anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
677     aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
678     aIOR->SetValue(iorStr.c_str());
679     anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
680     aName = SALOMEDS::AttributeName::_narrow(anAttr);
681     aName->SetValue(_support->getName().c_str());
682     _supportId = newObj->GetID();
683   } 
684   else 
685   {
686     // already in study : put new AttributeIOR !
687     ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
688     ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
689     CORBA::ORB_var &orb = init(0,0);
690     string iorStr = orb->object_to_string(myIor);
691     anAttr = myBuilder->FindOrCreateAttribute(supportEntry, "AttributeIOR");
692     aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
693     aIOR->SetValue(iorStr.c_str());
694   }
695   myBuilder->CommitCommand();
696
697   SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath);
698
699   MESSAGE("Just for checking, reuse of the corba pointer");
700
701   if ( CORBA::is_nil(supportEntry) ) 
702     {
703       MESSAGE("The reuse is OK");
704     }
705   else 
706     {
707       MESSAGE("well !! the reuse is not OK and there was a problem in the storage in the study");
708     }
709
710   delete [] medsupfatherName;
711   delete [] supportEntryPath;
712
713   // register the Corba pointer: increase the referrence count
714   MESSAGE("Registering of the Corba Support pointer");
715   Register();
716
717   END_OF(LOC);
718 }