1 // Copyright (C) 2011-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "HOMARD_Gen_i.hxx"
21 #include "HOMARD_Cas_i.hxx"
22 #include "HOMARD_Hypothesis_i.hxx"
23 #include "HOMARD_Iteration_i.hxx"
24 #include "HOMARD_Boundary_i.hxx"
25 #include "HOMARD_Zone_i.hxx"
26 #include "HomardDriver.hxx"
27 #include "HOMARD_DriverTools.hxx"
28 #include "HomardMedCommun.h"
30 #include "HOMARD_version.h"
32 #include "utilities.h"
33 #include "Utils_SINGLETON.hxx"
34 #include "Utils_CorbaException.hxx"
35 #include "SALOMEDS_Tool.hxx"
36 #include "SALOME_LifeCycleCORBA.hxx"
37 #include "SALOMEconfig.h"
38 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
39 #include CORBA_CLIENT_HEADER(SMESH_Gen)
56 //=============================================================================
58 //=============================================================================
59 std::string RemoveTabulation( std::string theScript )
61 std::string::size_type aPos = 0;
62 while( aPos < theScript.length() )
64 aPos = theScript.find( "\n\t", aPos );
65 if( aPos == std::string::npos )
67 theScript.replace( aPos, 2, "\n" );
72 //=============================================================================
74 * standard constructor
76 //=============================================================================
77 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
78 PortableServer::POA_ptr poa,
79 PortableServer::ObjectId * contId,
80 const char *instanceName,
81 const char *interfaceName) :
82 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
84 MESSAGE("constructor");
86 _id = _poa->activate_object(_thisObj);
88 myHomard = new ::HOMARD_Gen();
89 _NS = SINGLETON_<SALOME_NamingService>::Instance();
90 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
93 //=================================
97 //================================
98 HOMARD_Gen_i::~HOMARD_Gen_i()
101 //=============================================================================
102 //=============================================================================
103 // Utilitaires pour l'étude
104 //=============================================================================
105 //=============================================================================
106 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
108 ASSERT(!CORBA::is_nil(theStudy));
109 MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
110 SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
112 // Create SComponent labelled 'homard' if it doesn't already exit
113 SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
114 if (CORBA::is_nil(homardFather))
116 myBuilder->NewCommand();
117 MESSAGE("Add Component HOMARD");
119 bool aLocked = theStudy->GetProperties()->IsLocked();
120 if (aLocked) theStudy->GetProperties()->SetLocked(false);
122 homardFather = myBuilder->NewComponent(ComponentDataType());
123 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
124 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
125 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
126 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
127 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
128 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
129 if (!Comp->_is_nil())
131 aName->SetValue(ComponentDataType());
134 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
135 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
136 aPixmap->SetPixMap("HOMARD_2.png");
137 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
139 if (aLocked) theStudy->GetProperties()->SetLocked(true);
140 myBuilder->CommitCommand();
143 //=============================================================================
144 void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
146 MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID());
147 myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy);
148 this->addInStudy(myCurrentStudy);
150 //=============================================================================
151 SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
152 //=============================================================================
154 MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID());
155 return SALOMEDS::Study::_duplicate(myCurrentStudy);
157 //=============================================================================
158 CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
159 //=============================================================================
161 return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
163 //=============================================================================
164 //=============================================================================
166 //=============================================================================
167 //=============================================================================
168 // Utilitaires pour l'iteration
169 //=============================================================================
170 //=============================================================================
171 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
172 //=====================================================================================
174 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
175 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
176 if (CORBA::is_nil(myIteration))
178 SALOME::ExceptionStruct es;
179 es.type = SALOME::BAD_PARAM;
180 es.text = "Invalid iteration";
181 throw SALOME::SALOME_Exception(es);
185 myIteration->SetState(Etat);
187 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
188 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
192 icone = "iter0.png" ;
193 else if ( Etat == 2 )
194 icone = "iter_calculee.png" ;
196 icone = "iter_non_calculee.png" ;
197 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone, NULL) ;
199 aStudyBuilder->CommitCommand();
202 //=============================================================================
203 //=============================================================================
205 //=============================================================================
206 //=============================================================================
207 // Destruction des structures identifiees par leurs noms
208 //=============================================================================
209 //=============================================================================
210 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
212 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
213 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
214 if (CORBA::is_nil(myBoundary))
216 SALOME::ExceptionStruct es;
217 es.type = SALOME::BAD_PARAM;
218 es.text = "Invalid boundary";
219 throw SALOME::SALOME_Exception(es);
223 // On verifie que la frontiere n'est plus utilisee
224 HOMARD::listeCases* maListe = GetAllCasesName();
225 int numberOfCases = maListe->length();
226 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
227 std::string CaseName ;
228 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
230 HOMARD::HOMARD_Cas_var myCase ;
231 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
233 CaseName = std::string((*maListe)[NumeCas]);
234 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
235 myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
236 ASSERT(!CORBA::is_nil(myCase));
237 ListBoundaryGroupType = myCase->GetBoundaryGroup();
238 numberOfitems = ListBoundaryGroupType->length();
239 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
240 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
242 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
244 SALOME::ExceptionStruct es;
245 es.type = SALOME::BAD_PARAM;
246 es.text = "This boundary is used in a case and cannot be deleted.";
247 throw SALOME::SALOME_Exception(es);
253 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
254 myContextMap[GetCurrentStudyID()]._mesBoundarys.erase(BoundaryName);
255 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(BoundaryName, ComponentDataType());
256 SALOMEDS::SObject_var aSO =listSO[0];
257 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
258 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
262 //=============================================================================
263 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas)
265 // Pour detruire un cas
266 MESSAGE ( "DeleteCase : nomCas = " << nomCas );
267 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
268 if (CORBA::is_nil(myCase))
270 SALOME::ExceptionStruct es;
271 es.type = SALOME::BAD_PARAM;
272 es.text = "Invalid case context";
273 throw SALOME::SALOME_Exception(es);
276 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
277 CORBA::String_var nomIter = myCase->GetIter0Name();
278 CORBA::Long Option1 = 0 ;
279 CORBA::Long Option2 = 1 ;
280 if ( DeleteIterationOption(nomIter, Option1, Option2) != 0 )
285 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
286 myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas);
287 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType());
288 SALOMEDS::SObject_var aSO =listSO[0];
289 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
290 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
294 //=============================================================================
295 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
297 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
298 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
299 if (CORBA::is_nil(myHypo))
301 SALOME::ExceptionStruct es;
302 es.type = SALOME::BAD_PARAM;
303 es.text = "Invalid hypothesis";
304 throw SALOME::SALOME_Exception(es);
308 // On verifie que l'hypothese n'est plus utilisee
309 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
310 int numberOfIter = maListeIter->length();
311 if ( numberOfIter > 0 )
313 SALOME::ExceptionStruct es;
314 es.type = SALOME::BAD_PARAM;
315 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
316 throw SALOME::SALOME_Exception(es);
320 // suppression du lien avec les zones eventuelles
321 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
322 int numberOfZones = maListe->length();
323 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
324 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
326 std::string ZoneName = std::string((*maListe)[NumeZone]);
327 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
328 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
332 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
333 myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo);
334 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType());
335 SALOMEDS::SObject_var aSO =listSO[0];
336 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
337 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
341 //=============================================================================
342 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
344 // Option = 0 : On ne supprime pas le fichier du maillage associe
345 // Option = 1 : On supprime le fichier du maillage associe
346 // Option = 2 : On supprime le fichier du maillage associe, sauf si c'est la derniere iteration
347 // Pour detruire une iteration courante
348 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
349 CORBA::Long Option1 = 1 ;
350 return DeleteIterationOption(nomIter, Option1, Option);
352 //=============================================================================
353 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
355 // Option1 = 0 : On autorise la destruction de l'iteration 0
356 // Option1 = 1 : On interdit la destruction de l'iteration 0
358 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
359 // Option2 = 1 : On supprime le fichier du maillage associe
360 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
361 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
362 if (CORBA::is_nil(myIteration))
364 SALOME::ExceptionStruct es;
365 es.type = SALOME::BAD_PARAM;
366 es.text = "Invalid iteration";
367 throw SALOME::SALOME_Exception(es);
371 int numero = myIteration->GetNumber();
372 MESSAGE ( "DeleteIterationOption : numero = " << numero );
373 if ( numero == 0 and Option1 == 1 )
375 SALOME::ExceptionStruct es;
376 es.type = SALOME::BAD_PARAM;
377 es.text = "This iteration cannot be deleted.";
378 throw SALOME::SALOME_Exception(es);
382 // On detruit recursivement toutes les filles
383 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
384 int numberOfIter = maListe->length();
385 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
387 std::string nomIterFille = std::string((*maListe)[NumeIter]);
388 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
389 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
392 // On arrive ici pour une iteration sans fille
393 MESSAGE ( "Destruction effective de " << nomIter );
394 // On commence par invalider l'iteration pour faire le menage des dependances
395 // et eventeullement du maillage associe
396 InvalideIterOption(nomIter, Option2) ;
398 // Retrait dans la descendance de l'iteration parent
401 const char* nomIterationParent = myIteration->GetIterParentName();
402 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
403 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
404 if (CORBA::is_nil(myIterationParent))
406 SALOME::ExceptionStruct es;
407 es.type = SALOME::BAD_PARAM;
408 es.text = "Invalid iteration";
409 throw SALOME::SALOME_Exception(es);
412 myIterationParent->UnLinkNextIteration(nomIter);
415 // suppression du lien avec l'hypothese
418 const char* nomHypo = myIteration->GetHypoName();
419 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
420 ASSERT(!CORBA::is_nil(myHypo));
421 myHypo->UnLinkIteration(nomIter);
424 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
425 myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter);
426 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType());
427 SALOMEDS::SObject_var aSO =listSO[0];
428 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
429 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
430 // on peut aussi faire RemoveObject
431 // MESSAGE ( "Au final" );
432 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
433 // numberOfIter = Liste->length();
434 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
436 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
437 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
442 //=============================================================================
443 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
445 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
446 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone];
447 if (CORBA::is_nil(myZone))
449 SALOME::ExceptionStruct es;
450 es.type = SALOME::BAD_PARAM;
451 es.text = "Invalid zone";
452 throw SALOME::SALOME_Exception(es);
456 // On verifie que la zone n'est plus utilisee
457 HOMARD::listeHypo* maListe = myZone->GetHypo();
458 int numberOfHypo = maListe->length();
459 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
460 if ( numberOfHypo > 0 )
462 SALOME::ExceptionStruct es;
463 es.type = SALOME::BAD_PARAM;
464 es.text = "This zone is used in an hypothesis and cannot be deleted.";
465 throw SALOME::SALOME_Exception(es);
469 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
470 myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone);
471 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType());
472 SALOMEDS::SObject_var aSO =listSO[0];
473 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
474 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
478 //=============================================================================
479 //=============================================================================
481 //=============================================================================
482 //=============================================================================
483 // Invalidation des structures identifiees par leurs noms
484 //=============================================================================
485 //=============================================================================
486 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
488 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
489 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
490 if (CORBA::is_nil(myBoundary))
492 SALOME::ExceptionStruct es;
493 es.type = SALOME::BAD_PARAM;
494 es.text = "Invalid boundary";
495 throw SALOME::SALOME_Exception(es);
500 SALOME::ExceptionStruct es;
501 es.type = SALOME::BAD_PARAM;
502 es.text = "No change is allowed in a boundary. Ask for evolution.";
503 throw SALOME::SALOME_Exception(es);
507 //=============================================================================
508 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
510 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
511 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
512 if (CORBA::is_nil(myHypo))
514 SALOME::ExceptionStruct es;
515 es.type = SALOME::BAD_PARAM;
516 es.text = "Invalid hypothesis";
517 throw SALOME::SALOME_Exception(es);
521 HOMARD::listeIters* maListe = myHypo->GetIterations();
522 int numberOfIter = maListe->length();
523 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
525 std::string nomIter = std::string((*maListe)[NumeIter]);
526 MESSAGE( ".. nomIter = " << nomIter );
527 InvalideIter(nomIter.c_str());
530 //=============================================================================
531 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
533 MESSAGE("InvalideIter : nomIter = " << nomIter);
534 // Pour invalider totalement une iteration courante
535 CORBA::Long Option = 1 ;
536 return InvalideIterOption(nomIter, Option);
538 //=============================================================================
539 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
541 // Option = 0 : On ne supprime pas le fichier du maillage associe
542 // Option = 1 : On supprime le fichier du maillage associe
543 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
544 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
545 if (CORBA::is_nil(myIteration))
547 SALOME::ExceptionStruct es;
548 es.type = SALOME::BAD_PARAM;
549 es.text = "Invalid iteration";
550 throw SALOME::SALOME_Exception(es);
554 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
555 int numberOfIter = maListe->length();
556 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
558 std::string nomIterFille = std::string((*maListe)[NumeIter]);
559 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
560 InvalideIter(nomIterFille.c_str());
563 // On arrive ici pour une iteration sans fille
564 MESSAGE ( "Invalidation effective de " << nomIter );
565 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
566 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
567 for (; aIter->More(); aIter->Next())
569 SALOMEDS::SObject_var so = aIter->Value();
570 SALOMEDS::GenericAttribute_var anAttr;
571 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
572 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
573 std::string value (aCommentAttr->Value());
574 if(value == std::string("HypoHomard")) continue;
575 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
576 aStudyBuilder->RemoveObject(so);
579 int etat = myIteration->GetState();
582 SetEtatIter(nomIter,1);
583 const char * nomCas = myIteration->GetCaseName();
584 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
585 if (CORBA::is_nil(myCase))
587 SALOME::ExceptionStruct es;
588 es.type = SALOME::BAD_PARAM;
589 es.text = "Invalid case context";
590 throw SALOME::SALOME_Exception(es);
593 const char* dirCase = myCase->GetDirName();
594 const char* nomDir = myIteration->GetDirName();
595 const char* nomFichier = myIteration->GetMeshFile();
596 std::string commande= "rm -rf " + std::string(dirCase) + "/" + std::string(nomDir);
597 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
598 MESSAGE ( "commande = " << commande );
599 if ((system(commande.c_str())) != 0)
601 SALOME::ExceptionStruct es;
602 es.type = SALOME::BAD_PARAM;
603 es.text = "The directory for the calculation cannot be cleared." ;
604 throw SALOME::SALOME_Exception(es);
607 // Suppression du maillage publie dans SMESH
608 const char* MeshName = myIteration->GetMeshName() ;
609 DeleteResultInSmesh(nomFichier, MeshName) ;
613 //=============================================================================
614 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
616 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
617 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
618 if (CORBA::is_nil(myIteration))
620 SALOME::ExceptionStruct es;
621 es.type = SALOME::BAD_PARAM;
622 es.text = "Invalid iteration";
623 throw SALOME::SALOME_Exception(es);
627 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
628 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
629 for (; aIter->More(); aIter->Next())
631 SALOMEDS::SObject_var so = aIter->Value();
632 SALOMEDS::GenericAttribute_var anAttr;
633 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
634 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
635 std::string value (aCommentAttr->Value());
636 /* MESSAGE("... value = " << value);*/
637 if( (value == std::string("logInfo")) or ( value == std::string("SummaryInfo")) )
639 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
640 aStudyBuilder->RemoveObject(so);
644 const char * nomCas = myIteration->GetCaseName();
645 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
646 if (CORBA::is_nil(myCase))
648 SALOME::ExceptionStruct es;
649 es.type = SALOME::BAD_PARAM;
650 es.text = "Invalid case context";
651 throw SALOME::SALOME_Exception(es);
654 const char* dirCase = myCase->GetDirName();
655 const char* nomDir = myIteration->GetDirName();
656 std::string commande = "rm -f " + std::string(dirCase) + "/" + std::string(nomDir) + "/info* " ;
657 commande += std::string(dirCase) + "/" + std::string(nomDir) + "/Liste.*info" ;
658 /* MESSAGE ( "commande = " << commande );*/
659 if ((system(commande.c_str())) != 0)
661 SALOME::ExceptionStruct es;
662 es.type = SALOME::BAD_PARAM;
663 es.text = "The directory for the calculation cannot be cleared." ;
664 throw SALOME::SALOME_Exception(es);
668 //=============================================================================
669 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
671 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
672 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
673 if (CORBA::is_nil(myZone))
675 SALOME::ExceptionStruct es;
676 es.type = SALOME::BAD_PARAM;
677 es.text = "Invalid zone";
678 throw SALOME::SALOME_Exception(es);
681 HOMARD::listeHypo* maListe = myZone->GetHypo();
682 int numberOfHypo = maListe->length();
683 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
684 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
686 std::string nomHypo = std::string((*maListe)[NumeHypo]);
687 MESSAGE( ".. nomHypo = " << nomHypo );
688 InvalideHypo(nomHypo.c_str());
691 //=============================================================================
692 //=============================================================================
694 //=============================================================================
695 //=============================================================================
696 // Association de lien entre des structures identifiees par leurs noms
697 //=============================================================================
698 //=============================================================================
699 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
701 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
703 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
704 if (CORBA::is_nil(myCase))
706 SALOME::ExceptionStruct es;
707 es.type = SALOME::BAD_PARAM;
708 es.text = "Invalid case";
709 throw SALOME::SALOME_Exception(es);
713 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
714 if (CORBA::is_nil(myIteration))
716 SALOME::ExceptionStruct es;
717 es.type = SALOME::BAD_PARAM;
718 es.text = "Invalid iteration";
719 throw SALOME::SALOME_Exception(es);
723 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
724 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
725 if (CORBA::is_nil(aCasSO))
727 SALOME::ExceptionStruct es;
728 es.type = SALOME::BAD_PARAM;
729 es.text = "Invalid case";
730 throw SALOME::SALOME_Exception(es);
734 aStudyBuilder->NewCommand();
735 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
736 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
737 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
738 aStudyBuilder->CommitCommand();
740 myCase->AddIteration(nomIter);
741 myIteration->SetCaseName(nomCas);
743 //=====================================================================================
744 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
746 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
748 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
749 ASSERT(!CORBA::is_nil(myHypo));
750 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
751 ASSERT(!CORBA::is_nil(aHypoSO));
753 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
754 ASSERT(!CORBA::is_nil(myZone));
755 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
756 ASSERT(!CORBA::is_nil(aZoneSO));
758 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
760 aStudyBuilder->NewCommand();
762 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
763 aStudyBuilder->Addreference(aSubSO, aZoneSO);
765 aStudyBuilder->CommitCommand();
767 myZone->AddHypo(nomHypothesis);
768 myHypo->AddZone0(ZoneName, TypeUse);
770 //=============================================================================
771 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
773 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
775 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
776 ASSERT(!CORBA::is_nil(myHypo));
777 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
778 ASSERT(!CORBA::is_nil(aHypoSO));
780 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
781 ASSERT(!CORBA::is_nil(myIteration));
782 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
783 ASSERT(!CORBA::is_nil(aIterSO));
785 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
787 aStudyBuilder->NewCommand();
789 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
790 aStudyBuilder->Addreference(aSubSO, aHypoSO);
792 aStudyBuilder->CommitCommand();
794 myIteration->SetHypoName(nomHypo);
795 myHypo->LinkIteration(nomIter);
797 //=============================================================================
798 //=============================================================================
800 //=============================================================================
801 //=============================================================================
802 // Dissociation de lien entre des structures identifiees par leurs noms
803 //=============================================================================
804 //=============================================================================
805 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
807 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
809 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
810 ASSERT(!CORBA::is_nil(myHypo));
811 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
812 ASSERT(!CORBA::is_nil(aHypoSO));
814 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
815 ASSERT(!CORBA::is_nil(myZone));
816 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
817 ASSERT(!CORBA::is_nil(aZoneSO));
819 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
821 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
822 for (; it->More(); it->Next())
824 SALOMEDS::SObject_var aHypObj = it->Value();
825 SALOMEDS::SObject_var ptrObj;
826 if (aHypObj->ReferencedObject(ptrObj))
828 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
830 aStudyBuilder->NewCommand();
831 aStudyBuilder->RemoveObject(aHypObj);
832 aStudyBuilder->CommitCommand();
838 myZone->SupprHypo(nomHypothesis);
839 myHypo->SupprZone(ZoneName);
841 //=============================================================================
842 //=============================================================================
845 //=============================================================================
846 //=============================================================================
847 // Recuperation des listes
848 //=============================================================================
849 //=============================================================================
850 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
852 MESSAGE("GetAllCasesName");
855 HOMARD::listeCases_var ret = new HOMARD::listeCases;
856 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
857 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
859 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
860 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
862 ret[i++] = CORBA::string_dup((*it).first.c_str());
867 //=============================================================================
868 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
870 MESSAGE("GetAllHypothesesName");
873 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
874 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
875 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
877 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
878 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
880 ret[i++] = CORBA::string_dup((*it).first.c_str());
885 //=============================================================================
886 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
888 MESSAGE("GetAllZonesName");
891 HOMARD::listeZones_var ret = new HOMARD::listeZones;
892 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
893 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
895 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
896 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
898 ret[i++] = CORBA::string_dup((*it).first.c_str());
903 //=============================================================================
904 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
906 MESSAGE("GetAllIterationsName");
909 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
910 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
911 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
913 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
914 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
916 ret[i++] = CORBA::string_dup((*it).first.c_str());
921 //=============================================================================
922 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
924 MESSAGE("GetAllBoundarysName");
927 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
928 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
929 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
931 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
932 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
934 ret[i++] = CORBA::string_dup((*it).first.c_str());
939 //=============================================================================
940 //=============================================================================
942 //=============================================================================
943 //=============================================================================
944 // Recuperation des structures identifiees par leurs noms
945 //=============================================================================
946 //=============================================================================
947 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
949 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
950 ASSERT(!CORBA::is_nil(myCase));
951 return HOMARD::HOMARD_Cas::_duplicate(myCase);
953 //=============================================================================
954 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
956 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
957 ASSERT(!CORBA::is_nil(myZone));
958 return HOMARD::HOMARD_Zone::_duplicate(myZone);
960 //=============================================================================
961 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
963 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
964 ASSERT(!CORBA::is_nil(myHypothesis));
965 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
967 //=============================================================================
968 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
970 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
971 ASSERT(!CORBA::is_nil(myIteration));
972 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
974 //=============================================================================
975 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
977 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
978 ASSERT(!CORBA::is_nil(myBoundary));
979 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
981 //=============================================================================
982 //=============================================================================
984 //=============================================================================
985 //=============================================================================
987 //=============================================================================
988 //=============================================================================
989 void HOMARD_Gen_i::MeshInfo(const char* nomCas, const char* MeshName, const char* MeshFile, const char* DirName, CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
991 MESSAGE ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
992 MESSAGE ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
996 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, 1) ;
997 myCase->SetDirName(DirName) ;
999 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1003 //=============================================================================
1004 //=============================================================================
1006 //=============================================================================
1007 //=============================================================================
1008 // Recuperation des structures par le contexte
1009 //=============================================================================
1010 //=============================================================================
1011 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1013 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1014 ASSERT(!CORBA::is_nil(myCase));
1016 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1017 ASSERT(!CORBA::is_nil(myIteration));
1019 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1021 //=============================================================================
1022 //=============================================================================
1024 //=============================================================================
1025 //=============================================================================
1026 // Nouvelles structures
1027 //=============================================================================
1028 //=============================================================================
1029 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1031 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1032 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1033 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1034 return aCase._retn();
1036 //=============================================================================
1037 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1039 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1040 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1041 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1042 return aHypo._retn();
1044 //=============================================================================
1045 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1047 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1048 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1049 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1050 return aIter._retn();
1052 //=============================================================================
1053 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1055 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1056 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1057 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1058 return aBoundary._retn();
1060 //=============================================================================
1061 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1063 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1064 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1065 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1066 return aZone._retn();
1068 //=============================================================================
1069 //=============================================================================
1071 //=============================================================================
1072 //=============================================================================
1073 // Creation des structures identifiees par leurs noms
1074 //=============================================================================
1075 //=============================================================================
1076 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1078 // Creation d'un cas initial
1079 // nomCas : nom du cas a creer
1080 // MeshName, MeshFile : nom et fichier du maillage correspondant
1083 MESSAGE ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1085 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, 2) ;
1087 // Valeurs par defaut des filtrages
1088 myCase->SetPyram(0);
1090 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1092 //=============================================================================
1093 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1095 // nomCas : nom du cas a creer
1096 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1099 MESSAGE ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1100 char* nomDirWork = getenv("PWD") ;
1103 // A. Decodage du point de reprise
1104 // A.1. Controle du repertoire de depart de l'iteration
1105 codret = chdir(DirNameStart) ;
1108 SALOME::ExceptionStruct es;
1109 es.type = SALOME::BAD_PARAM;
1110 es.text = "The directory of the iteration does not exist.";
1111 throw SALOME::SALOME_Exception(es);
1114 // A.2. Reperage des fichiers du repertoire de reprise
1115 std::string file_configuration = "" ;
1116 std::string file_maillage_homard = "" ;
1119 struct dirent *dirp;
1120 dp = opendir(DirNameStart);
1121 while ( (dirp = readdir(dp)) != NULL )
1123 std::string file_name(dirp->d_name);
1124 // MESSAGE ( file_name );
1125 bilan = file_name.find("HOMARD.Configuration.") ;
1126 if ( bilan != string::npos ) { file_configuration = file_name ; }
1127 bilan = file_name.find("maill.") ;
1128 if ( bilan != string::npos )
1130 bilan = file_name.find(".hom.med") ;
1131 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1135 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1136 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1138 if ( ( file_configuration == "" ) or ( file_maillage_homard == "" ) )
1140 SALOME::ExceptionStruct es;
1141 es.type = SALOME::BAD_PARAM;
1143 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1144 else { text = "The HOMARD mesh file cannot be found." ; }
1145 es.text = CORBA::string_dup(text.c_str());
1146 throw SALOME::SALOME_Exception(es);
1149 // B. Lecture du fichier de configuration
1150 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1156 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1157 std::ifstream fichier( file_configuration.c_str() );
1158 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1160 std::string ligne; // variable contenant chaque ligne lue
1161 std::string mot_cle;
1162 std::string argument;
1164 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1165 while ( std::getline( fichier, ligne ) )
1167 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1168 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1169 ligne_bis >> mot_cle ;
1170 // B.2. Des valeurs entieres : le second bloc de la ligne
1171 if ( mot_cle == "NumeIter" )
1173 ligne_bis >> NumeIter ;
1176 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1177 else if ( ( mot_cle == "TypeConf" ) or ( mot_cle == "TypeElem" ) )
1179 ligne_bis >> argument ;
1181 if ( mot_cle == "TypeConf" )
1183 if ( argument == "conforme" ) { TypeConf = 1 ; }
1184 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1185 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1186 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1188 else if ( mot_cle == "TypeElem" )
1190 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1191 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1194 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1195 // il faut les supprimer
1196 else if ( ( mot_cle == "CCNoMNP1" ) or ( mot_cle == "CCMaiNP1" ) )
1198 ligne_bis >> argument ;
1199 if ( argument[0] == '"' ) { decalage = 1 ; }
1200 else { decalage = 0 ; }
1201 size_t size = argument.size() + 1 - 2*decalage ;
1203 if ( mot_cle == "CCNoMNP1" )
1205 MeshName = new char[ size ];
1206 strncpy( MeshName, argument.c_str()+decalage, size );
1207 MeshName[size-1] = '\0' ;
1209 else if ( mot_cle == "CCMaiNP1" )
1211 MeshFile = new char[ size ];
1212 strncpy( MeshFile, argument.c_str()+decalage, size );
1213 MeshFile[size-1] = '\0' ;
1217 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1218 MESSAGE ( "==> MeshName : " << MeshName ) ;
1219 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1220 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1221 MESSAGE ( "==> Pyram : " << Pyram ) ;
1225 SALOME::ExceptionStruct es;
1226 es.type = SALOME::BAD_PARAM;
1227 std::string text = "The configuration file cannot be read." ;
1228 es.text = CORBA::string_dup(text.c_str());
1229 throw SALOME::SALOME_Exception(es);
1232 // C. Creation effective du cas
1234 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, 2) ;
1236 // D. Parametrages lus dans le fichier de configuration
1238 myCase->SetConfType (TypeConf) ;
1239 myCase->SetPyram (Pyram) ;
1241 // E. Copie du fichier de maillage homard
1242 // E.1. Repertoire associe au cas
1243 char* nomDirCase = myCase->GetDirName() ;
1244 // E.2. Repertoire associe a l'iteration de ce cas
1246 IterName = myCase->GetIter0Name() ;
1247 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1248 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1249 Iter->SetDirName(nomDirIter);
1250 std::string nomDirIterTotal ;
1251 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1252 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1254 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1255 SALOME::ExceptionStruct es;
1256 es.type = SALOME::BAD_PARAM;
1257 std::string text = "The directory for the computation cannot be created." ;
1258 es.text = CORBA::string_dup(text.c_str());
1259 throw SALOME::SALOME_Exception(es);
1261 // E.3. Copie du maillage HOMARD au format MED
1262 codret = chdir(DirNameStart) ;
1263 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1264 MESSAGE ( "commande : " << commande ) ;
1265 codret = system(commande.c_str()) ;
1266 MESSAGE ( "codret : " << codret ) ;
1269 SALOME::ExceptionStruct es;
1270 es.type = SALOME::BAD_PARAM;
1271 es.text = "The starting point for the case cannot be copied into the working directory.";
1272 throw SALOME::SALOME_Exception(es);
1283 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1285 //=============================================================================
1286 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1288 // nomCas : nom du cas a creer
1289 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1292 MESSAGE ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1294 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1296 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1297 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1299 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1301 //=============================================================================
1302 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1304 // nomCas : nom du cas a creer
1305 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1306 // Number : numero de l'iteration de depart
1309 MESSAGE ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1312 SALOME::ExceptionStruct es;
1313 es.type = SALOME::BAD_PARAM;
1314 es.text = "The number of iteration must be positive.";
1315 throw SALOME::SALOME_Exception(es);
1319 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1321 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1322 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1324 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1326 //=============================================================================
1327 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1329 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1330 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1331 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1334 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1335 std::string nomDirWork = getenv("PWD") ;
1336 std::string DirNameStartIter ;
1338 int NumeIterMax = -1 ;
1340 // A.1. Controle du repertoire de depart du cas
1341 codret = chdir(DirNameStart) ;
1344 SALOME::ExceptionStruct es;
1345 es.type = SALOME::BAD_PARAM;
1346 es.text = "This directory of the case does not exist.";
1347 throw SALOME::SALOME_Exception(es);
1350 // A.2. Reperage des sous-repertoire du repertoire de reprise
1351 bool existe = false ;
1353 struct dirent *dirp;
1354 dp = opendir(DirNameStart);
1355 while ( (dirp = readdir(dp)) != NULL )
1357 std::string DirName_1(dirp->d_name);
1358 if ( ( DirName_1 != "." ) and ( DirName_1 != ".." ) )
1360 if ( chdir(DirName_1.c_str()) == 0 )
1362 // On cherche le fichier de configuration dans ce sous-repertoire
1363 codret = chdir(DirNameStart) ;
1365 struct dirent *dirp_1;
1366 dp_1 = opendir(DirName_1.c_str()) ;
1367 while ( (dirp_1 = readdir(dp_1)) != NULL )
1369 std::string file_name_1(dirp_1->d_name);
1370 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1371 if ( bilan != string::npos )
1373 // Decodage du fichier pour trouver le numero d'iteration
1374 chdir(DirName_1.c_str()) ;
1375 std::ifstream fichier( file_name_1.c_str() );
1376 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1379 std::string ligne; // variable contenant chaque ligne lue
1380 std::string mot_cle;
1381 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1382 while ( std::getline( fichier, ligne ) )
1384 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1385 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1386 ligne_bis >> mot_cle ;
1387 if ( mot_cle == "NumeIter" )
1389 ligne_bis >> NumeIter ;
1391 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1392 if ( Number == - 1 )
1394 if ( NumeIter >= NumeIterMax )
1396 NumeIterMax = NumeIter ;
1397 DirNameStartIter = DirName_1 ;
1402 if ( NumeIter == Number )
1404 DirNameStartIter = DirName_1 ;
1414 SALOME::ExceptionStruct es;
1415 es.type = SALOME::BAD_PARAM;
1416 std::string text = "The configuration file cannot be read." ;
1417 es.text = CORBA::string_dup(text.c_str());
1418 throw SALOME::SALOME_Exception(es);
1420 chdir(DirNameStart) ;
1422 if ( existe ) { break ; }
1425 if ( existe ) { break ; }
1431 chdir(nomDirWork.c_str());
1433 if ( ( Number >= 0 and ( not existe ) ) or ( Number < 0 and ( NumeIterMax == -1 ) ) )
1435 SALOME::ExceptionStruct es;
1436 es.type = SALOME::BAD_PARAM;
1437 es.text = "The directory of the iteration does not exist.";
1438 throw SALOME::SALOME_Exception(es);
1442 return DirNameStartIter ;
1444 //=============================================================================
1445 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* MeshName, const char* MeshFile, CORBA::Long MeshOption, CORBA::Long NumeIter, CORBA::Long Option)
1447 // nomCas : nom du cas a creer
1448 // MeshName, MeshFile : nom et fichier du maillage correspondant
1449 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1450 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1451 // -1 : le maillage n'est pas fourni
1452 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1453 // Option : multiple de nombres premiers
1454 // 1 : aucune option
1455 // x2 : publication du maillage dans SMESH
1457 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1458 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1459 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1465 // A.2. Controle du nom :
1466 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1468 SALOME::ExceptionStruct es;
1469 es.type = SALOME::BAD_PARAM;
1470 es.text = "This case has already been defined.";
1471 throw SALOME::SALOME_Exception(es);
1475 // A.3. Controle du fichier du maillage
1476 int existeMeshFile ;
1477 if ( MeshOption >= 0 )
1479 existeMeshFile = MEDFileExist ( MeshFile ) ;
1480 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1481 if ( ( existeMeshFile == 0 ) and ( MeshOption == 0 ) )
1483 SALOME::ExceptionStruct es;
1484 es.type = SALOME::BAD_PARAM;
1485 es.text = "The mesh file does not exist.";
1486 throw SALOME::SALOME_Exception(es);
1490 else { existeMeshFile = 0 ; }
1492 // B. Creation de l'objet cas et publication
1493 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1494 HOMARD::HOMARD_Cas_var myCase = newCase();
1495 myCase->SetName(nomCas);
1496 SALOMEDS::SObject_var aSO;
1497 PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1498 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1500 // C. Caracteristiques du maillage
1501 if ( existeMeshFile != 0 )
1503 // Les valeurs extremes des coordonnees
1504 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1505 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1506 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1507 if (LesExtremes.size()!=10) { return false; }
1509 for (int i =0 ; i< LesExtremes.size() ; i++)
1510 aSeq[i]=LesExtremes[i] ;
1511 myCase->SetBoundingBox(aSeq) ;
1513 // MESSAGE ( "CreateCase0 : Les groupes" );
1514 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1515 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1516 aSeqGroupe->length(LesGroupes.size());
1517 std::set<std::string>::const_iterator it ;
1519 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1520 aSeqGroupe[i++]=(*it).c_str() ;
1521 myCase->SetGroups(aSeqGroupe) ;
1524 // D. L'iteration initiale du cas
1525 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1526 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1527 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1529 std::string NomIteration = std::string(MeshName) ;
1530 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1532 std::ostringstream nom;
1533 nom << MeshName << monNum;
1534 NomIteration = nom.str();
1537 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1539 // D.2. Creation de l'iteration
1540 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1541 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1542 anIter->SetName(NomIteration.c_str());
1543 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1545 // D.4. Maillage correspondant
1546 if ( existeMeshFile != 0 )
1548 anIter->SetMeshFile(MeshFile);
1549 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1551 anIter->SetMeshName(MeshName);
1553 // D.5. Numero d'iteration
1554 anIter->SetNumber(NumeIter);
1557 SetEtatIter(NomIteration.c_str(), -NumeIter);
1560 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1562 //=============================================================================
1563 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1565 MESSAGE ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1568 // Controle du nom :
1569 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1571 SALOME::ExceptionStruct es;
1572 es.type = SALOME::BAD_PARAM;
1573 es.text = "This hypothesis has already been defined.";
1574 throw SALOME::SALOME_Exception(es);
1578 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1579 myHypothesis->SetName(nomHypothesis);
1580 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1581 SALOMEDS::SObject_var aSO;
1582 PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1584 // Valeurs par defaut des options avancees
1585 myHypothesis->SetNivMax(-1);
1586 myHypothesis->SetDiamMin(-1.0);
1587 myHypothesis->SetAdapInit(0);
1588 myHypothesis->SetLevelOutput(0);
1590 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1593 //=============================================================================
1594 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1595 //=============================================================================
1597 MESSAGE ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1600 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1601 if (CORBA::is_nil(myIterationParent))
1603 SALOME::ExceptionStruct es;
1604 es.type = SALOME::BAD_PARAM;
1605 es.text = "The parent iteration is not defined.";
1606 throw SALOME::SALOME_Exception(es);
1610 const char* nomCas = myIterationParent->GetCaseName();
1611 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1612 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1613 if (CORBA::is_nil(myCase))
1615 SALOME::ExceptionStruct es;
1616 es.type = SALOME::BAD_PARAM;
1617 es.text = "Invalid case context";
1618 throw SALOME::SALOME_Exception(es);
1621 const char* nomDirCase = myCase->GetDirName();
1623 // Controle du nom :
1624 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1626 SALOME::ExceptionStruct es;
1627 es.type = SALOME::BAD_PARAM;
1628 es.text = "This iteration has already been defined.";
1629 throw SALOME::SALOME_Exception(es);
1633 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1634 if (CORBA::is_nil(myIteration))
1636 SALOME::ExceptionStruct es;
1637 es.type = SALOME::BAD_PARAM;
1638 es.text = "Unable to create the iteration";
1639 throw SALOME::SALOME_Exception(es);
1642 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1643 // Nom de l'iteration et du maillage
1644 myIteration->SetName(NomIteration);
1645 myIteration->SetMeshName(NomIteration);
1646 myIteration->SetState(1);
1648 int numero = myIterationParent->GetNumber() + 1;
1649 myIteration->SetNumber(numero);
1651 // Nombre d'iterations deja connues pour le cas, permettant
1652 // la creation d'un sous-repertoire unique
1653 int nbitercase = myCase->GetNumberofIter();
1654 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1655 myIteration->SetDirName(nomDirIter);
1657 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1658 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1659 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1660 // situation la plus frequente.
1661 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1662 // le nombre d'iterations du cas permet d'eviter les collisions.
1664 if ( nbitercase < 100 ) { jaux = 2 ; }
1665 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1666 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1667 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1669 std::ostringstream iaux ;
1670 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1671 std::stringstream MeshFile;
1672 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1673 myIteration->SetMeshFile(MeshFile.str().c_str());
1675 // Association avec le cas
1676 std::string label = "IterationHomard_" + std::string(nomIterParent);
1677 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1678 // Lien avec l'iteration precedente
1679 myIterationParent->LinkNextIteration(NomIteration);
1680 myIteration->SetIterParentName(nomIterParent);
1682 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1684 //=============================================================================
1685 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1687 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1690 // Controle du nom :
1691 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1693 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1694 SALOME::ExceptionStruct es;
1695 es.type = SALOME::BAD_PARAM;
1696 es.text = "This boundary has already been defined";
1697 throw SALOME::SALOME_Exception(es);
1701 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1702 myBoundary->SetName(BoundaryName);
1703 myBoundary->SetType(BoundaryType);
1705 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1707 SALOMEDS::SObject_var aSO;
1708 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1710 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1712 //=============================================================================
1713 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1715 MESSAGE ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1716 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1717 myBoundary->SetMeshFile( MeshFile ) ;
1718 myBoundary->SetMeshName( MeshName ) ;
1720 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1722 //=============================================================================
1723 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1724 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1725 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1726 CORBA::Double Rayon)
1728 MESSAGE ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1730 SALOME::ExceptionStruct es;
1733 { es.text = "The radius must be positive." ;
1735 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1736 if ( daux < 0.0000001 )
1737 { es.text = "The axis must be a non 0 vector." ;
1741 es.type = SALOME::BAD_PARAM;
1742 throw SALOME::SALOME_Exception(es);
1746 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1747 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1749 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1751 //=============================================================================
1752 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1753 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1754 CORBA::Double Rayon)
1756 MESSAGE ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1758 SALOME::ExceptionStruct es;
1761 { es.text = "The radius must be positive." ;
1765 es.type = SALOME::BAD_PARAM;
1766 throw SALOME::SALOME_Exception(es);
1770 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1771 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1773 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1775 //=============================================================================
1776 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1777 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1778 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1780 MESSAGE ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1782 SALOME::ExceptionStruct es;
1784 if ( Angle <= 0.0 or Angle >= 90.0 )
1785 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1787 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1788 if ( daux < 0.0000001 )
1789 { es.text = "The axis must be a non 0 vector." ;
1793 es.type = SALOME::BAD_PARAM;
1794 throw SALOME::SALOME_Exception(es);
1798 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
1799 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
1801 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1803 //=============================================================================
1804 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
1805 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
1806 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
1808 MESSAGE ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
1810 SALOME::ExceptionStruct es;
1812 if ( Rayon1 < 0.0 or Rayon2 < 0.0 )
1813 { es.text = "The radius must be positive." ;
1815 double daux = fabs(Rayon2-Rayon1) ;
1816 if ( daux < 0.0000001 )
1817 { es.text = "The radius must be different." ;
1819 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
1820 if ( daux < 0.0000001 )
1821 { es.text = "The centers must be different." ;
1825 es.type = SALOME::BAD_PARAM;
1826 throw SALOME::SALOME_Exception(es);
1830 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
1831 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
1833 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1835 //=============================================================================
1836 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
1838 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
1841 // Controle du nom :
1842 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
1844 SALOME::ExceptionStruct es;
1845 es.type = SALOME::BAD_PARAM;
1846 es.text = "This zone has already been defined";
1847 throw SALOME::SALOME_Exception(es);
1851 HOMARD::HOMARD_Zone_var myZone = newZone();
1852 myZone->SetName(ZoneName);
1853 myZone->SetType(ZoneType);
1855 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
1857 SALOMEDS::SObject_var aSO;
1858 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
1860 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1862 //=============================================================================
1863 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
1864 CORBA::Double Xmini, CORBA::Double Xmaxi,
1865 CORBA::Double Ymini, CORBA::Double Ymaxi,
1866 CORBA::Double Zmini, CORBA::Double Zmaxi)
1868 MESSAGE ("CreateZoneBox : ZoneName = " << ZoneName ) ;
1870 SALOME::ExceptionStruct es;
1872 if ( Xmini > Xmaxi )
1873 { es.text = "The X coordinates are not coherent." ;
1875 if ( Ymini > Ymaxi )
1876 { es.text = "The Y coordinates are not coherent." ;
1878 if ( Zmini > Zmaxi )
1879 { es.text = "The Z coordinates are not coherent." ;
1883 es.type = SALOME::BAD_PARAM;
1884 throw SALOME::SALOME_Exception(es);
1888 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
1889 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
1891 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1893 //=============================================================================
1894 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
1895 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
1897 MESSAGE ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
1899 SALOME::ExceptionStruct es;
1902 { es.text = "The radius must be positive." ;
1906 es.type = SALOME::BAD_PARAM;
1907 throw SALOME::SALOME_Exception(es);
1911 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
1912 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1914 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1916 //=============================================================================
1917 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
1918 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1919 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1920 CORBA::Double Rayon, CORBA::Double Haut)
1922 MESSAGE ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
1924 SALOME::ExceptionStruct es;
1927 { es.text = "The radius must be positive." ;
1929 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1930 if ( daux < 0.0000001 )
1931 { es.text = "The axis must be a non 0 vector." ;
1934 { es.text = "The height must be positive." ;
1938 es.type = SALOME::BAD_PARAM;
1939 throw SALOME::SALOME_Exception(es);
1943 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
1944 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
1946 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1948 //=============================================================================
1949 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
1950 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1951 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1952 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
1954 MESSAGE ("CreateZonePipe : ZoneName = " << ZoneName ) ;
1956 SALOME::ExceptionStruct es;
1958 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
1959 { es.text = "The radius must be positive." ;
1961 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1962 if ( daux < 0.0000001 )
1963 { es.text = "The axis must be a non 0 vector." ;
1966 { es.text = "The height must be positive." ;
1968 if ( Rayon <= Rayonint )
1969 { es.text = "The external radius must be higher than the internal radius." ;
1973 es.type = SALOME::BAD_PARAM;
1974 throw SALOME::SALOME_Exception(es);
1978 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
1979 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
1981 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1983 //=============================================================================
1984 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
1985 CORBA::Double Umini, CORBA::Double Umaxi,
1986 CORBA::Double Vmini, CORBA::Double Vmaxi,
1989 MESSAGE ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
1990 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
1991 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
1992 // MESSAGE ("Orient = " << Orient ) ;
1994 SALOME::ExceptionStruct es;
1996 if ( Umini > Umaxi )
1997 { es.text = "The first coordinates are not coherent." ;
1999 if ( Vmini > Vmaxi )
2000 { es.text = "The second coordinates are not coherent." ;
2002 if ( Orient < 1 or Orient > 3 )
2003 { es.text = "The orientation must be 1, 2 or 3." ;
2007 es.type = SALOME::BAD_PARAM;
2008 throw SALOME::SALOME_Exception(es);
2012 double Xmini, Xmaxi ;
2013 double Ymini, Ymaxi ;
2014 double Zmini, Zmaxi ;
2022 else if ( Orient == 2 )
2029 else if ( Orient == 3 )
2036 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2038 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2039 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2041 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2043 //=============================================================================
2044 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2045 CORBA::Double Ucentre, CORBA::Double Vcentre,
2046 CORBA::Double Rayon,
2049 MESSAGE ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2051 SALOME::ExceptionStruct es;
2054 { es.text = "The radius must be positive." ;
2056 if ( Orient < 1 or Orient > 3 )
2057 { es.text = "The orientation must be 1, 2 or 3." ;
2061 es.type = SALOME::BAD_PARAM;
2062 throw SALOME::SALOME_Exception(es);
2070 { Xcentre = Ucentre ;
2073 else if ( Orient == 2 )
2076 Zcentre = Vcentre ; }
2077 else if ( Orient == 3 )
2078 { Xcentre = Vcentre ;
2080 Zcentre = Ucentre ; }
2081 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2083 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2084 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2086 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2088 //=============================================================================
2089 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2090 CORBA::Double Ucentre, CORBA::Double Vcentre,
2091 CORBA::Double Rayon, CORBA::Double Rayonint,
2094 MESSAGE ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2096 SALOME::ExceptionStruct es;
2098 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
2099 { es.text = "The radius must be positive." ;
2101 if ( Orient < 1 or Orient > 3 )
2102 { es.text = "The orientation must be 1, 2 or 3." ;
2104 if ( Rayon <= Rayonint )
2105 { es.text = "The external radius must be higher than the internal radius." ;
2109 es.type = SALOME::BAD_PARAM;
2110 throw SALOME::SALOME_Exception(es);
2118 { Xcentre = Ucentre ;
2121 else if ( Orient == 2 )
2124 Zcentre = Vcentre ; }
2125 else if ( Orient == 3 )
2126 { Xcentre = Vcentre ;
2128 Zcentre = Ucentre ; }
2129 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2131 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2132 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2134 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2136 //=============================================================================
2137 //=============================================================================
2142 //=============================================================================
2143 //=============================================================================
2144 // Traitement d'une iteration
2145 // etatMenage = 1 : destruction du repertoire d'execution
2146 // modeHOMARD = 1 : adaptation
2147 // != 1 : information avec les options modeHOMARD
2148 // Option1 >0 : appel depuis python
2149 // <0 : appel depuis GUI
2150 // Option2 : multiple de nombres premiers
2151 // 1 : aucune option
2152 // x2 : publication du maillage dans SMESH
2153 //=============================================================================
2154 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2156 MESSAGE ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", avec Option1 = " << Option1 << ", avec Option2 = " << Option2 );
2161 // A.1. L'objet iteration
2162 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2163 ASSERT(!CORBA::is_nil(myIteration));
2165 // A.2. Numero de l'iteration
2166 // siterp1 : numero de l'iteration a traiter
2168 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2169 // Ou si information :
2171 int NumeIter = myIteration->GetNumber();
2172 std::string siterp1 ;
2173 std::stringstream saux1 ;
2175 siterp1 = saux1.str() ;
2176 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2179 if ( modeHOMARD==1 )
2181 std::stringstream saux0 ;
2182 int iaux = max(0, NumeIter-1) ;
2184 siter = saux0.str() ;
2185 if (NumeIter < 11) { siter = "0" + siter ; }
2188 { siter = siterp1 ; }
2191 const char* nomCas = myIteration->GetCaseName();
2192 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2193 ASSERT(!CORBA::is_nil(myCase));
2195 // B. Les repertoires
2196 // B.1. Le repertoire courant
2197 char* nomDirWork = getenv("PWD") ;
2198 // B.2. Le sous-repertoire de l'iteration a traiter
2199 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2200 MESSAGE( ". DirCompute = " << DirCompute );
2202 // C. Le fichier des messages
2203 // C.1. Le deroulement de l'execution de HOMARD
2204 std::string LogFile = DirCompute ;
2205 LogFile += "/Liste" ;
2206 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2208 MESSAGE (". LogFile = " << LogFile);
2209 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2210 // C.2. Le bilan de l'analyse du maillage
2211 std::string FileInfo = DirCompute ;
2213 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2215 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2216 else { FileInfo += "info_ap" ; }
2218 FileInfo += "." + siterp1 + ".bilan" ;
2219 myIteration->SetFileInfo(FileInfo.c_str());
2221 // D. On passe dans le repertoire de l'iteration a calculer
2222 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2225 // E. Les donnees de l'execution HOMARD
2226 // E.1. L'objet du texte du fichier de configuration
2227 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2228 std::string Langue = "Francais" ;
2229 myDriver->TexteInit(DirCompute, LogFile, Langue);
2231 // E.2. Le maillage associe a l'iteration
2232 const char* NomMesh = myIteration->GetMeshName();
2233 MESSAGE ( ". NomMesh = " << NomMesh );
2234 const char* MeshFile = myIteration->GetMeshFile();
2235 MESSAGE ( ". MeshFile = " << MeshFile );
2237 // E.3. Les donnees du traitement HOMARD
2239 if ( modeHOMARD == 1 )
2242 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2243 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2244 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2248 InvalideIterInfo(NomIteration);
2249 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2251 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2252 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2253 myDriver->CreeFichierDonn();
2256 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2257 DriverTexteBoundary(myCase, myDriver) ;
2259 // E.5. Ecriture du texte dans le fichier
2261 { myDriver->CreeFichier(); }
2265 int codretexec = 12 ;
2268 codretexec = myDriver->ExecuteHomard(Option1);
2270 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2271 if ( modeHOMARD == 1 )
2273 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2274 else { SetEtatIter(NomIteration,1); }
2275 // GERALD -- QMESSAGE BOX
2279 // H. Gestion des resultats
2282 std::string Commentaire ;
2283 // H.1. Le fichier des messages, dans tous les cas
2284 Commentaire = "log" ;
2285 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2286 else { Commentaire += "Info" ; }
2287 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2289 // H.2. Si tout s'est bien passe :
2290 if (codretexec == 0)
2292 // H.2.1. Le fichier de bilan
2293 Commentaire = "Summary" ;
2294 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2295 else { Commentaire += "Info" ; }
2296 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2297 // H.2.2. Le fichier de maillage obtenu
2298 if ( modeHOMARD == 1 )
2300 std::stringstream saux0 ;
2301 Commentaire = "Iteration" ;
2302 Commentaire += " " + siter ;
2303 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2304 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2307 // H.3 Message d'erreur en cas de probleme
2310 SALOME::ExceptionStruct es;
2311 es.type = SALOME::BAD_PARAM;
2312 std::string text = "Error during the adaptation.\n" ;
2315 ifstream fichier(LogFile.c_str(), ios::in);
2317 while(getline(fichier, ligne) and (ligne != "===== HOMARD ===== STOP ====="));
2318 while (getline(fichier, ligne)) { text += ligne+ "\n";};
2321 text += "no log file ....";
2323 es.text = CORBA::string_dup(text.c_str());
2324 throw SALOME::SALOME_Exception(es);
2328 // I. Menage et retour dans le repertoire du cas
2332 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2338 //=============================================================================
2339 // Calcul d'une iteration : partie specifique a l'adaptation
2340 //=============================================================================
2341 CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option1, CORBA::Long Option2)
2343 MESSAGE ( "ComputeAdap" );
2348 // Etat de l'iteration
2349 int etat = myIteration->GetState();
2350 // Numero de l'iteration
2351 int NumeIter = myIteration->GetNumber();
2352 std::stringstream saux0 ;
2353 saux0 << NumeIter-1 ;
2354 std::string siter = saux0.str() ;
2355 if (NumeIter < 11) { siter = "0" + siter ; }
2357 // A.2. On ne calcule pas l iteration initiale
2360 MESSAGE ( "etat = "<<etat );
2361 SALOME::ExceptionStruct es;
2362 es.type = SALOME::BAD_PARAM;
2363 es.text = "This iteration is the first of the case and cannot be computed.";
2364 throw SALOME::SALOME_Exception(es);
2368 // A.3. On verifie qu il y a une hypothese (erreur improbable);
2369 const char* nomHypo = myIteration->GetHypoName();
2370 if (std::string(nomHypo) == std::string(""))
2372 SALOME::ExceptionStruct es;
2373 es.type = SALOME::BAD_PARAM;
2374 es.text = "This iteration does not have any associated hypothesis.";
2375 throw SALOME::SALOME_Exception(es);
2378 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2379 ASSERT(!CORBA::is_nil(myHypo));
2381 // B. L'iteration parent
2382 const char* nomIterationParent = myIteration->GetIterParentName();
2383 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2384 ASSERT(!CORBA::is_nil(myIterationParent));
2385 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2386 if ( myIterationParent->GetState() == 1 )
2389 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2392 // GERALD -- QMESSAGE BOX
2393 ASSERT("Pb au calcul de l'iteration precedente" == 0);
2397 // C. Le sous-repertoire de l'iteration precedente
2398 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2399 MESSAGE( ". DirComputePa = " << DirComputePa );
2401 // D. Les donnees de l'adaptation HOMARD
2402 // D.1. Le type de conformite
2403 int ConfType = myCase->GetConfType();
2404 MESSAGE ( ". ConfType = " << ConfType );
2406 // D.2. Le maillage de depart
2407 const char* NomMeshParent = myIterationParent->GetMeshName();
2408 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2409 const char* MeshFileParent = myIterationParent->GetMeshFile();
2410 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2412 // D.3. Le maillage associe a l'iteration
2413 const char* MeshFile = myIteration->GetMeshFile();
2414 MESSAGE ( ". MeshFile = " << MeshFile );
2415 FILE *file = fopen(MeshFile,"r");
2419 if (etatMenage == 0)
2421 SALOME::ExceptionStruct es;
2422 es.type = SALOME::BAD_PARAM;
2423 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2424 es.text = CORBA::string_dup(text.c_str());
2425 throw SALOME::SALOME_Exception(es);
2430 std::string commande = "rm -f " + std::string(MeshFile);
2431 codret = system(commande.c_str());
2434 SALOME::ExceptionStruct es;
2435 es.type = SALOME::BAD_PARAM;
2436 es.text = "The mesh file cannot be deleted.";
2437 throw SALOME::SALOME_Exception(es);
2443 // D.4. Les types de raffinement et de deraffinement
2444 // Les appels corba sont lourds, il vaut mieux les grouper
2445 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2446 ASSERT(ListTypes->length() == 3);
2447 int TypeAdap = (*ListTypes)[0];
2448 int TypeRaff = (*ListTypes)[1];
2449 int TypeDera = (*ListTypes)[2];
2451 // E. Texte du fichier de configuration
2452 // E.1. Incontournables du texte
2453 myDriver->TexteAdap();
2455 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2456 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2457 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2459 // E.2. Ajout des informations liees aux zones eventuelles
2460 if ( TypeAdap == 0 )
2461 { DriverTexteZone(myHypo, myDriver) ; }
2463 // E.3. Ajout des informations liees aux champs eventuels
2464 if ( TypeAdap == 1 )
2465 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2467 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2468 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2469 int numberOfGroups = listeGroupes->length();
2470 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2471 if (numberOfGroups > 0)
2473 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2475 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2476 MESSAGE( "... GroupName = " << GroupName );
2477 myDriver->TexteGroup(GroupName);
2481 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2482 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2484 // E.6. Ajout des options avancees
2485 int Pyram = myCase->GetPyram();
2486 MESSAGE ( ". Pyram = " << Pyram );
2487 int NivMax = myHypo->GetNivMax();
2488 MESSAGE ( ". NivMax = " << NivMax );
2489 double DiamMin = myHypo->GetDiamMin() ;
2490 MESSAGE ( ". DiamMin = " << DiamMin );
2491 int AdapInit = myHypo->GetAdapInit();
2492 MESSAGE ( ". AdapInit = " << AdapInit );
2493 int LevelOutput = myHypo->GetLevelOutput();
2494 MESSAGE ( ". LevelOutput = " << LevelOutput );
2495 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2499 //=============================================================================
2500 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire
2501 // nomrep : nom du repertoire parent
2502 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2503 //=============================================================================
2504 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2506 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2507 char* nomDirActuel = getenv("PWD") ;
2508 std::string DirName ;
2509 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2510 bool a_chercher = true ;
2511 while ( a_chercher )
2513 // On passe dans le repertoire parent
2515 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2517 if ( num < 100 ) { jaux = 2 ; }
2518 else if ( num < 1000 ) { jaux = 3 ; }
2519 else if ( num < 10000 ) { jaux = 4 ; }
2520 else if ( num < 100000 ) { jaux = 5 ; }
2522 std::ostringstream iaux ;
2523 iaux << std::setw(jaux) << std::setfill('0') << num ;
2524 std::ostringstream DirNameA ;
2525 DirNameA << "I" << iaux.str();
2526 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2527 // que c'est bien un probleme d'absence
2528 if ( chdir(DirNameA.str().c_str()) != 0 )
2530 bool existe = false ;
2532 struct dirent *dirp;
2533 dp = opendir(nomrep);
2534 while ( (dirp = readdir(dp)) != NULL )
2536 std::string file_name(dirp->d_name);
2537 if ( file_name == DirNameA.str() ) { existe = true ; }
2542 DirName = DirNameA.str() ;
2543 a_chercher = false ;
2550 MESSAGE ( "==> DirName = " << DirName);
2551 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2552 chdir(nomDirActuel);
2554 return CORBA::string_dup( DirName.c_str() );
2556 //=============================================================================
2557 // Calcul d'une iteration : gestion du repertoire de calcul
2558 // Si le sous-repertoire existe :
2559 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2560 // etatMenage = 1 : on fait le menage du repertoire
2561 // etatMenage = -1 : on ne fait rien
2562 //=============================================================================
2563 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2565 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2566 // B.2. Le repertoire du cas
2567 const char* nomDirCase = myCase->GetDirName();
2568 MESSAGE ( ". nomDirCase = " << nomDirCase );
2570 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2571 // B.3.1. Le nom du sous-repertoire
2572 const char* nomDirIt = myIteration->GetDirName();
2574 // B.3.2. Le nom complet du sous-repertoire
2575 std::stringstream DirCompute ;
2576 DirCompute << nomDirCase << "/" << nomDirIt;
2577 MESSAGE (". DirCompute = " << DirCompute.str() );
2579 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2580 if (chdir(DirCompute.str().c_str()) != 0)
2582 // Creation du repertoire car il n'existe pas :
2583 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2585 // GERALD -- QMESSAGE BOX
2586 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2587 ASSERT("Pb a la creation du repertoire" == 0);
2592 // Le repertoire existe
2593 // On demande de faire le menage de son contenu :
2594 if (etatMenage == 1)
2596 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2597 std::string commande= "rm -rf " + DirCompute.str()+"/*" ;
2598 int codret = system(commande.c_str());
2601 // GERALD -- QMESSAGE BOX
2602 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2603 ASSERT("Pb au menage du repertoire de calcul" == 0);
2606 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2609 if (etatMenage == 0)
2612 struct dirent *dirp;
2613 dp = opendir(DirCompute.str().c_str());
2615 while ((dirp = readdir(dp)) != NULL && result )
2617 std::string file_name(dirp->d_name);
2618 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2621 if ( result == false)
2623 SALOME::ExceptionStruct es;
2624 es.type = SALOME::BAD_PARAM;
2625 std::string text = "Directory : " + DirCompute.str() + "is not empty";
2626 es.text = CORBA::string_dup(text.c_str());
2627 throw SALOME::SALOME_Exception(es);
2628 ASSERT("Directory is not empty" == 0);
2634 return CORBA::string_dup( DirCompute.str().c_str() );
2636 //=============================================================================
2637 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2638 //=============================================================================
2639 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2641 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2642 // Le repertoire du cas
2643 const char* nomDirCase = myCase->GetDirName();
2644 MESSAGE ( ". nomDirCase = " << nomDirCase );
2646 // Le sous-repertoire de l'iteration precedente
2648 const char* nomIterationParent = myIteration->GetIterParentName();
2649 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2650 const char* nomDirItPa = myIterationParent->GetDirName();
2651 std::stringstream DirComputePa ;
2652 DirComputePa << nomDirCase << "/" << nomDirItPa;
2653 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2654 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2656 return CORBA::string_dup( DirComputePa.str().c_str() );
2658 //=============================================================================
2659 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2660 //=============================================================================
2661 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2663 MESSAGE ( "... DriverTexteZone" );
2664 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2665 int numberOfZonesx2 = ListZone->length();
2668 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2670 std::string ZoneName = std::string((*ListZone)[iaux]);
2671 MESSAGE ( "... ZoneName = " << ZoneName);
2672 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
2673 ASSERT(!CORBA::is_nil(myZone));
2675 int ZoneType = myZone->GetType();
2676 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
2677 int TypeUse = atoi( TypeUsestr.c_str() );
2678 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
2679 NumZone = iaux/2 + 1 ;
2680 HOMARD::double_array* zone = myZone->GetCoords();
2681 if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
2683 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.);
2685 else if ( ZoneType == 4 ) // Cas d une sphere
2687 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.);
2689 else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
2691 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.);
2693 else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
2695 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]);
2697 else { ASSERT("ZoneType est incorrect." == 0) ; }
2702 //=============================================================================
2703 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
2704 //=============================================================================
2705 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2707 MESSAGE ( "... DriverTexteField" );
2708 // Le fichier du champ
2709 char* FieldFile = myIteration->GetFieldFile();
2710 MESSAGE ( ". FieldFile = " << FieldFile );
2711 if (strlen(FieldFile) == 0)
2713 // GERALD -- QMESSAGE BOX
2714 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2715 ASSERT("The file for the field is not given." == 0);
2717 // Les caracteristiques d'instants
2718 int TimeStep = myIteration->GetTimeStep();
2719 MESSAGE( ". TimeStep = " << TimeStep );
2720 int Rank = myIteration->GetRank();
2721 MESSAGE( ". Rank = " << Rank );
2722 // Les informations sur les champ
2723 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
2725 const char* FieldName = aInfosHypo->FieldName;
2727 int TypeThR = aInfosHypo->TypeThR;
2728 double ThreshR = aInfosHypo->ThreshR;
2729 int TypeThC = aInfosHypo->TypeThC;
2730 double ThreshC = aInfosHypo->ThreshC;
2731 // Saut entre mailles ou non ?
2732 int UsField = aInfosHypo->UsField;
2733 MESSAGE( ". UsField = " << UsField );
2734 // L'usage des composantes
2735 int UsCmpI = aInfosHypo->UsCmpI;
2736 MESSAGE( ". UsCmpI = " << UsCmpI );
2738 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
2741 HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp();
2742 int numberOfCompos = mescompo->length();
2743 MESSAGE( ". numberOfCompos = " << numberOfCompos );
2744 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
2746 std::string nomCompo = std::string((*mescompo)[NumeComp]);
2747 MESSAGE( "... nomCompo = " << nomCompo );
2748 myDriver->TexteCompo(NumeComp, nomCompo);
2752 //=============================================================================
2753 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
2754 //=============================================================================
2755 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
2757 MESSAGE ( "... DriverTexteBoundary" );
2758 // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
2759 std::list<std::string> ListeBoundaryTraitees ;
2760 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
2761 int numberOfitems = ListBoundaryGroupType->length();
2762 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
2763 int BoundaryOption = 1 ;
2764 int NumBoundaryAnalytical = 0 ;
2765 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2767 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2768 MESSAGE ( "... BoundaryName = " << BoundaryName);
2770 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
2771 while (it != ListeBoundaryTraitees.end())
2773 MESSAGE ( "... BoundaryNameTraitee = " << *it);
2774 if ( BoundaryName == *it ) { A_faire = 0 ; }
2779 // Caracteristiques de la frontiere
2780 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2781 ASSERT(!CORBA::is_nil(myBoundary));
2782 int BoundaryType = myBoundary->GetType();
2783 MESSAGE ( "... BoundaryType = " << BoundaryType );
2784 // Ecriture selon le type
2785 if (BoundaryType == 0) // Cas d une frontiere discrete
2787 const char* MeshName = myBoundary->GetMeshName() ;
2788 const char* MeshFile = myBoundary->GetMeshFile() ;
2789 myDriver->TexteBoundaryDi( MeshName, MeshFile);
2790 BoundaryOption = BoundaryOption*2 ;
2792 else // Cas d une frontiere analytique
2794 NumBoundaryAnalytical++ ;
2795 HOMARD::double_array* coor = myBoundary->GetCoords();
2796 if (BoundaryType == 1) // Cas d un cylindre
2798 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2799 BoundaryOption = BoundaryOption*3 ;
2801 else if (BoundaryType == 2) // Cas d une sphere
2803 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
2804 BoundaryOption = BoundaryOption*3 ;
2806 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
2808 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2809 BoundaryOption = BoundaryOption*3 ;
2811 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
2813 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
2814 BoundaryOption = BoundaryOption*3 ;
2817 // Memorisation du traitement
2818 ListeBoundaryTraitees.push_back( BoundaryName );
2821 NumBoundaryAnalytical = 0 ;
2822 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2824 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2825 MESSAGE ( "... BoundaryName = " << BoundaryName);
2826 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2827 ASSERT(!CORBA::is_nil(myBoundary));
2828 int BoundaryType = myBoundary->GetType();
2829 MESSAGE ( "... BoundaryType = " << BoundaryType );
2830 // Recuperation du nom du groupe
2831 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
2832 MESSAGE ( "... GroupName = " << GroupName);
2833 if (BoundaryType == 0) // Cas d une frontiere discrete
2835 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
2837 else // Cas d une frontiere analytique
2839 NumBoundaryAnalytical++ ;
2840 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
2843 myDriver->TexteBoundaryOption(BoundaryOption);
2846 //=============================================================================
2847 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
2848 //=============================================================================
2849 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2851 MESSAGE ( "... DriverTexteFieldInterp" );
2852 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
2853 if (TypeFieldInterp != 0)
2855 // Le fichier des champs
2856 char* FieldFile = myIteration->GetFieldFile();
2857 MESSAGE ( ". FieldFile = " << FieldFile );
2858 if (strlen(FieldFile) == 0)
2860 // GERALD -- QMESSAGE BOX
2861 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2862 ASSERT("The file for the field is not given." == 0);
2864 // Les caracteristiques d'instants
2865 int TimeStep = myIteration->GetTimeStep();
2866 MESSAGE( ". TimeStep = " << TimeStep );
2867 int Rank = myIteration->GetRank();
2868 MESSAGE( ". Rank = " << Rank );
2870 const char* MeshFile = myIteration->GetMeshFile();
2871 myDriver->TexteFieldInterp(TypeFieldInterp, FieldFile, MeshFile, TimeStep, Rank);
2873 if (TypeFieldInterp == 2)
2875 HOMARD::listFieldInterpHypo* meschamps = myHypo->GetListFieldInterp();
2876 int numberOfFields = meschamps->length();
2877 MESSAGE( ". numberOfFields = " << numberOfFields );
2878 for (int NumeChamp = 0; NumeChamp< numberOfFields; NumeChamp++)
2880 std::string nomChamp = std::string((*meschamps)[NumeChamp]);
2881 MESSAGE( "... nomChamp = " << nomChamp );
2882 myDriver->TexteFieldInterpName(NumeChamp, nomChamp);
2888 //===========================================================================
2889 //===========================================================================
2892 //===========================================================================
2893 //===========================================================================
2895 //===========================================================================
2896 //===========================================================================
2897 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
2898 SALOMEDS::SObject_ptr theSObject,
2899 CORBA::Object_ptr theObject,
2900 const char* theName)
2902 MESSAGE("PublishInStudy pour " << theName);
2903 SALOMEDS::SObject_var aResultSO;
2904 if (CORBA::is_nil(theStudy))
2906 SALOME::ExceptionStruct es;
2907 es.type = SALOME::BAD_PARAM;
2908 es.text = "Invalid study context";
2909 throw SALOME::SALOME_Exception(es);
2913 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
2914 // Rq : Iteration est publiee ailleurs
2915 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
2916 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
2917 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
2918 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
2920 addInStudy(theStudy);
2922 // Controle de la non publication d'un objet de meme nom
2923 if ((!aHypo->_is_nil()) or (!aZone->_is_nil()) or (!aBoundary->_is_nil()))
2925 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
2926 if (listSO->length() >= 1)
2928 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
2929 std::cerr <<"This name "<<theName<<" is already used "<<listSO->length()<<" time(s)" << std::endl;
2930 aResultSO = listSO[0];
2931 return aResultSO._retn();
2935 // Caracteristiques de l'etude
2936 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
2937 aStudyBuilder->NewCommand();
2938 if(!aCase->_is_nil())
2939 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
2940 else if(!aHypo->_is_nil())
2941 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
2942 else if(!aZone->_is_nil())
2943 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
2944 else if(!aBoundary->_is_nil())
2945 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
2947 aStudyBuilder->CommitCommand();
2948 return aResultSO._retn();
2950 //=============================================================================
2951 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
2952 SALOMEDS::StudyBuilder_var aStudyBuilder,
2953 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
2955 MESSAGE("PublishCaseInStudy pour "<<theName);
2956 SALOMEDS::SObject_var aResultSO;
2957 SALOMEDS::GenericAttribute_var anAttr;
2959 if (CORBA::is_nil(theObject)) {
2960 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
2961 return aResultSO._retn();
2963 if (theStudy->_is_nil()) {
2964 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
2965 return aResultSO._retn();
2968 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
2969 if (theFatherHomard->_is_nil())
2971 MESSAGE("theFatherHomard->_is_nil()");
2972 return aResultSO._retn();
2975 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
2976 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
2977 _orb->object_to_string(theObject) ) ;
2978 return aResultSO._retn();
2981 //=============================================================================
2982 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
2983 SALOMEDS::StudyBuilder_var aStudyBuilder,
2984 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
2986 MESSAGE("PublishZoneStudy pour "<<theName);
2987 SALOMEDS::SObject_var aResultSO;
2988 SALOMEDS::GenericAttribute_var anAttr;
2990 if (CORBA::is_nil(theObject))
2992 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
2993 return aResultSO._retn();
2995 if (theStudy->_is_nil())
2997 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
2998 return aResultSO._retn();
3000 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3001 if (theFatherHomard->_is_nil())
3003 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3004 return aResultSO._retn();
3007 // Caracteristique de la zone
3008 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3009 CORBA::Long ZoneType = myZone->GetType();
3011 // On ajoute la categorie des zones dans l etude si necessaire
3012 SALOMEDS::SObject_var aSOZone;
3013 if (!theFatherHomard->FindSubObject(100, aSOZone))
3015 MESSAGE("Ajout de la categorie des zones");
3016 aSOZone = aStudyBuilder->NewObjectToTag(theFatherHomard, 100);
3017 PublishInStudyAttr(aStudyBuilder, aSOZone, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3019 else { MESSAGE("La categorie des zones existe deja."); }
3021 aResultSO = aStudyBuilder->NewObject(aSOZone);
3030 { icone = "boxdxy_2.png" ;
3034 { icone = "boxdxyz_2.png" ;
3042 { icone = "disk_2.png" ;
3046 { icone = "spherepoint_2.png" ;
3050 { icone = "cylinderpointvector_2.png" ;
3058 { icone = "diskwithhole_2.png" ;
3062 { icone = "pipe_2.png" ;
3066 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone, _orb->object_to_string(theObject) ) ;
3068 return aResultSO._retn();
3070 //=============================================================================
3071 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3072 SALOMEDS::StudyBuilder_var aStudyBuilder,
3073 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3075 MESSAGE("PublishBoundaryStudy pour "<<theName);
3076 SALOMEDS::SObject_var aResultSO;
3077 SALOMEDS::GenericAttribute_var anAttr;
3079 // Caracteristique de la Boundary
3080 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3082 // On recupere le module pere dans l etude
3083 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3084 if (theFatherHomard->_is_nil())
3086 MESSAGE("theFatherHomard->_is_nil()");
3087 return aResultSO._retn();
3090 // On ajoute la categorie des boundarys dans l etude si necessaire
3091 SALOMEDS::SObject_var aSOBoundary;
3092 if (!theFatherHomard->FindSubObject(101, aSOBoundary))
3094 MESSAGE("Ajout de la categorie des boundarys");
3095 aSOBoundary = aStudyBuilder->NewObjectToTag(theFatherHomard, 101);
3096 PublishInStudyAttr(aStudyBuilder, aSOBoundary, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3098 else { MESSAGE("La categorie des boundarys existe deja."); }
3100 aResultSO = aStudyBuilder->NewObject(aSOBoundary);
3101 CORBA::Long BoundaryType = myBoundary->GetType();
3102 // MESSAGE("BoundaryType : "<<BoundaryType);
3105 switch (BoundaryType)
3108 { value = "BoundaryDiHomard" ;
3109 icone = "mesh_tree_mesh.png" ;
3113 { value = "BoundaryAnHomard" ;
3114 icone = "cylinderpointvector_2.png" ;
3118 { value = "BoundaryAnHomard" ;
3119 icone = "spherepoint_2.png" ;
3123 { value = "BoundaryAnHomard" ;
3124 icone = "conepointvector.png" ;
3128 { value = "BoundaryAnHomard" ;
3129 icone = "conedxyz.png" ;
3133 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value, icone, _orb->object_to_string(theObject));
3134 return aResultSO._retn();
3137 //=============================================================================
3138 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3139 SALOMEDS::StudyBuilder_var aStudyBuilder,
3140 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3142 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3143 SALOMEDS::SObject_var aResultSO;
3144 SALOMEDS::GenericAttribute_var anAttr;
3146 // On recupere le module pere dans l etude
3147 // On ajoute la categorie des hypotheses dans l etude si necessaire
3148 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3149 if (theFatherHomard->_is_nil())
3151 MESSAGE("theFatherHomard->_is_nil()");
3152 return aResultSO._retn();
3154 SALOMEDS::SObject_var aSOHypothese;
3155 if (!theFatherHomard->FindSubObject(0, aSOHypothese))
3157 MESSAGE("Ajout de la categorie des hypotheses");
3158 aSOHypothese = aStudyBuilder->NewObjectToTag(theFatherHomard, 0);
3159 PublishInStudyAttr(aStudyBuilder, aSOHypothese, "Hypothesis", "HypoList","hypotheses.png", NULL);
3161 else { MESSAGE("La categorie des hypotheses existe deja."); }
3163 // Creation du resultat dans l'etude
3164 aResultSO = aStudyBuilder->NewObject(aSOHypothese);
3165 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3167 return aResultSO._retn();
3169 //===========================================================================
3170 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3171 SALOMEDS::SObject_var aResultSO,
3172 const char* name, const char* value, const char* icone, const char* ior)
3174 SALOMEDS::GenericAttribute_var anAttr ;
3178 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3179 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3180 aNameAttrib->SetValue(name);
3183 // Ajout du commentaire
3184 if ( value != NULL )
3186 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3187 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3188 aCommentAttrib->SetValue(value);
3192 if ( icone != NULL )
3194 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO,"AttributePixMap");
3195 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3196 aPixmap->SetPixMap(icone);
3202 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3203 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3204 anIOR->SetValue(ior);
3208 //=====================================================================================
3209 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3211 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3213 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3214 ASSERT(!CORBA::is_nil(myCase));
3215 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3216 ASSERT(!CORBA::is_nil(aCaseSO));
3218 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3219 ASSERT(!CORBA::is_nil(myBoundary));
3220 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3221 ASSERT(!CORBA::is_nil(aBoundarySO));
3223 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3225 aStudyBuilder->NewCommand();
3227 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3228 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3230 aStudyBuilder->CommitCommand();
3233 //=============================================================================
3234 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3235 // Option = 0 : fichier issu d'une importation
3236 // Option = 1 : fichier issu d'une execution HOMARD
3238 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3239 if (CORBA::is_nil(myCurrentStudy))
3241 SALOME::ExceptionStruct es;
3242 es.type = SALOME::BAD_PARAM;
3243 es.text = "Invalid study context";
3244 throw SALOME::SALOME_Exception(es);
3248 // Le module SMESH est-il actif ?
3249 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3251 if (!CORBA::is_nil(aSmeshSO))
3253 // On verifie que le fichier n est pas deja publie
3254 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3255 for (; aIter->More(); aIter->Next())
3257 SALOMEDS::SObject_var aSO = aIter->Value();
3258 SALOMEDS::GenericAttribute_var aGAttr;
3259 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3261 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3262 CORBA::String_var value=anAttr->Value();
3263 if (strcmp((const char*)value,NomFich) == 0)
3265 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3266 // Pour un fichier importe, on ne republie pas
3271 // Pour un fichier calcule, on commence par faire la depublication
3274 MESSAGE ( "PublishResultInSmesh : depublication" );
3275 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3276 CORBA::String_var value2=anAttr2->Value();
3277 const char* MeshName = value2 ;
3278 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3279 DeleteResultInSmesh(NomFich, MeshName) ;
3286 // On enregistre le fichier
3287 MESSAGE( "Enregistrement du fichier");
3288 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3289 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3290 ASSERT(!CORBA::is_nil(aSmeshEngine));
3291 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3292 SMESH::DriverMED_ReadStatus theStatus;
3293 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3295 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3296 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3297 for (int i = 0; i < mesMaillages->length(); i++)
3299 MESSAGE( ". Mise a jour des attributs du maillage");
3300 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3301 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3302 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3303 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3304 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3305 anAttr->SetValue(NomFich);
3306 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3307 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3309 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3310 else { icone = "mesh_tree_mesh.png" ; }
3311 anAttr2->SetPixMap( icone );
3315 //=============================================================================
3316 void HOMARD_Gen_i::DeleteResultInSmesh(const char* NomFich, const char* MeshName)
3318 MESSAGE (" DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3319 if (CORBA::is_nil(myCurrentStudy))
3321 SALOME::ExceptionStruct es;
3322 es.type = SALOME::BAD_PARAM;
3323 es.text = "Invalid study context";
3324 throw SALOME::SALOME_Exception(es);
3328 // Le module SMESH est-il actif ?
3329 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3331 if (CORBA::is_nil(aSmeshSO))
3335 // On verifie que le fichier est deja publie
3336 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3337 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3338 for (; aIter->More(); aIter->Next())
3340 SALOMEDS::SObject_var aSO = aIter->Value();
3341 SALOMEDS::GenericAttribute_var aGAttr;
3342 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3344 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3345 CORBA::String_var value=anAttr->Value();
3346 if (strcmp((const char*)value,NomFich) == 0)
3348 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3350 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3351 CORBA::String_var value2=anAttr2->Value();
3352 if (strcmp((const char*)value2,MeshName) == 0)
3354 myBuilder->RemoveObjectWithChildren( aSO ) ;
3362 //=============================================================================
3363 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3365 // MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3366 if (CORBA::is_nil(myCurrentStudy))
3368 SALOME::ExceptionStruct es;
3369 es.type = SALOME::BAD_PARAM;
3370 es.text = "Invalid study context";
3371 throw SALOME::SALOME_Exception(es);
3375 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3376 if (CORBA::is_nil(myIteration))
3378 SALOME::ExceptionStruct es;
3379 es.type = SALOME::BAD_PARAM;
3380 es.text = "Invalid iteration";
3381 throw SALOME::SALOME_Exception(es);
3384 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3385 if (CORBA::is_nil(myIteration))
3387 SALOME::ExceptionStruct es;
3388 es.type = SALOME::BAD_PARAM;
3389 es.text = "Invalid iterationStudy Object";
3390 throw SALOME::SALOME_Exception(es);
3394 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3396 aStudyBuilder->NewCommand();
3398 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3399 // Pour les fichiers med, on affiche une icone de maillage
3400 // Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte'
3401 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3403 const char* ior = " " ;
3404 if ( Commentaire[0] == 'I' )
3405 { icone = "med.png" ; }
3407 { icone = "texte_2.png" ; }
3408 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone, ior ) ;
3410 aStudyBuilder->CommitCommand();
3412 //=============================================================================
3413 //=============================================================================
3415 //=============================================================================
3416 //=============================================================================
3417 // Next functions are inherited from SALOMEDS::Driver interface
3418 //=============================================================================
3419 //=============================================================================
3420 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
3422 CORBA::Boolean isMultiFile)
3424 MESSAGE (" Save for theURL = "<< theURL);
3425 SALOMEDS::TMPFile_var aStreamFile;
3427 // get temporary directory name
3428 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3430 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3431 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3433 // HOMARD data file name
3434 std::string aFileName = "";
3436 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3437 aFileName += "_HOMARD.dat";
3439 // initialize sequence of file names
3440 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
3441 aFileSeq->length(1);
3442 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
3444 // get full path to the data file
3445 aFileName = tmpDir + aFileName;
3449 std::ofstream f(aFileName.c_str());
3451 // clear temporary id map
3452 context._idmap.clear();
3457 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
3458 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
3459 HOMARD::HOMARD_Cas_var aCas = it_case->second;
3460 PortableServer::ServantBase_var aServant = GetServant(aCas);
3461 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3463 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
3464 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
3468 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3469 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
3470 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
3471 PortableServer::ServantBase_var aServant = GetServant(aZone);
3472 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3474 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
3475 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3478 // -> save hypotheses
3479 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3480 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
3481 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
3482 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3483 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3485 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
3486 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3489 // -> save iterations
3490 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3491 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
3492 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
3493 PortableServer::ServantBase_var aServant = GetServant(aIter);
3494 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3496 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
3497 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3500 // -> save boundaries
3501 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3502 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
3503 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
3504 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3505 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3506 if (aBoundaryServant) {
3507 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
3508 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3512 MESSAGE ("close file");
3515 // put temporary files to the stream
3516 MESSAGE ("put temporary files to the stream");
3517 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
3519 // remove temporary files
3520 MESSAGE ("remove temporary files");
3521 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3523 // return data stream
3524 MESSAGE ("return data stream");
3525 return aStreamFile._retn();
3528 //===========================================================================
3529 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
3531 CORBA::Boolean isMultiFile)
3533 // No specific ASCII persistence
3534 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
3535 return aStreamFile._retn();
3538 //===========================================================================
3539 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
3540 const SALOMEDS::TMPFile& theStream,
3542 CORBA::Boolean isMultiFile)
3544 MESSAGE (" Load pour theURL = "<< theURL);
3545 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3547 // set current study
3548 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
3549 SetCurrentStudy(aStudy);
3551 // get temporary directory name
3552 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3554 // Convert the stream into sequence of files to process
3555 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
3558 // HOMARD data file name
3559 std::string aFileName = "";
3561 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3562 aFileName = tmpDir + aFileName + "_HOMARD.dat";
3564 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3568 std::ifstream f(aFileName.c_str());
3571 context._mesCas.clear();
3572 context._mesHypotheses.clear();
3573 context._mesIterations.clear();
3574 context._mesZones.clear();
3575 context._mesBoundarys.clear();
3576 context._idmap.clear();
3582 std::getline(f, line);
3583 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
3584 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
3585 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
3586 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
3587 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
3588 if (line.substr(0, caseSignature.size()) == caseSignature) {
3590 MESSAGE (" Recreation du cas" );
3591 HOMARD::HOMARD_Cas_var aCase = newCase();
3592 PortableServer::ServantBase_var aServant = GetServant(aCase);
3593 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3594 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
3595 context._mesCas[aCase->GetName()] = aCase;
3596 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
3599 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
3600 MESSAGE (" Recreation de la zone" );
3602 HOMARD::HOMARD_Zone_var aZone = newZone();
3603 PortableServer::ServantBase_var aServant = GetServant(aZone);
3604 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3605 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
3606 context._mesZones[aZone->GetName()] = aZone;
3607 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3610 else if (line.substr(0, iterSignature.size()) == iterSignature) {
3611 // re-create iteration
3612 MESSAGE (" Recreation de l iteration" );
3613 HOMARD::HOMARD_Iteration_var aIter = newIteration();
3614 PortableServer::ServantBase_var aServant = GetServant(aIter);
3615 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3616 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
3617 context._mesIterations[aIter->GetName()] = aIter;
3618 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3621 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
3622 // re-create hypothesis
3623 MESSAGE (" Recreation de l hypothese" );
3624 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
3625 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3626 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3627 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
3628 context._mesHypotheses[aHypo->GetName()] = aHypo;
3629 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3632 else if (line.substr(0, bounSignature.size()) == bounSignature) {
3633 // re-create boundary
3634 MESSAGE (" Recreation de la frontiere" );
3635 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
3636 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3637 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3638 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
3639 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
3640 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3649 // Remove temporary files created from the stream
3651 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3656 //===========================================================================
3657 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
3658 const SALOMEDS::TMPFile& theStream,
3660 CORBA::Boolean isMultiFile)
3662 // No specific ASCII persistence
3663 return Load(theComponent, theStream, theURL, isMultiFile);
3666 //===========================================================================
3667 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
3669 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
3670 // clearing study context should be done here:
3671 // - destroy all servants and related CORBA objects
3673 // - remove context from myContextMap
3674 myContextMap.erase(theComponent->GetStudy()->StudyId());
3675 // - nullify myCurrentStudy
3676 myCurrentStudy = SALOMEDS::Study::_nil();
3680 //===========================================================================
3681 char* HOMARD_Gen_i::ComponentDataType()
3683 return CORBA::string_dup("HOMARD");
3686 //===========================================================================
3687 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
3688 const char* IORString,
3689 CORBA::Boolean isMultiFile,
3690 CORBA::Boolean isASCII)
3692 CORBA::String_var aString("");
3693 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
3694 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3695 CORBA::Object_var anObj = _orb->string_to_object(IORString);
3696 if (!CORBA::is_nil(anObj)) {
3697 PortableServer::ServantBase_var aServant = GetServant(anObj);
3698 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
3700 std::map<int, PortableServer::ServantBase*>::const_iterator it;
3701 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
3702 if (it->second == aStorable) {
3703 std::stringstream os;
3705 aString = CORBA::string_dup(os.str().c_str());
3711 return aString._retn();
3714 //===========================================================================
3715 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
3716 const char* aLocalPersistentID,
3717 CORBA::Boolean isMultiFile,
3718 CORBA::Boolean isASCII)
3720 CORBA::String_var aString("");
3721 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
3722 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3723 int id = atoi(aLocalPersistentID);
3724 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
3725 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
3726 if (!CORBA::is_nil(object)) {
3727 aString = _orb->object_to_string(object);
3731 return aString._retn();
3734 //===========================================================================
3735 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
3737 if(CORBA::is_nil(myCurrentStudy))
3740 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
3741 if(!aCas->_is_nil())
3744 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
3745 if(!aHypo->_is_nil())
3748 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
3749 if(!aZone->_is_nil())
3752 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
3753 if(!aBoundary->_is_nil())
3756 /* Iteration is not published directly
3757 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
3758 if(!aIter->_is_nil())
3764 //===========================================================================
3765 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
3767 // No Copy/Paste support
3771 //===========================================================================
3772 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
3773 CORBA::Long& theObjectID)
3775 // No Copy/Paste support
3776 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
3777 return aStreamFile._retn();
3780 //===========================================================================
3781 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
3782 CORBA::Long theObjectID)
3784 // No Copy/Paste support
3788 //===========================================================================
3789 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
3790 CORBA::Long theObjectID,
3791 SALOMEDS::SObject_ptr theSObject)
3793 // No Copy/Paste support
3794 SALOMEDS::SObject_var aResultSO;
3795 return aResultSO._retn();
3798 //===========================================================================
3799 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
3801 PortableServer::Servant aServant = 0;
3802 if (!CORBA::is_nil(theObject)) {
3804 aServant = _poa->reference_to_servant(theObject);
3812 //==========================================================================
3813 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
3814 CORBA::Boolean isPublished,
3815 CORBA::Boolean isMultiFile,
3816 CORBA::Boolean& isValidScript)
3818 MESSAGE ("Entree dans DumpPython");
3820 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
3821 if(CORBA::is_nil(aStudy))
3822 return new Engines::TMPFile(0);
3824 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
3825 if(CORBA::is_nil(aSO))
3826 return new Engines::TMPFile(0);
3828 std::string aScript = "\"\"\"\n";
3829 aScript += "Python script for HOMARD\n";
3830 aScript += "Copyright EDF-R&D 2013\n";
3831 aScript += "\"\"\"\n";
3832 aScript += "__revision__ = \"V1.2\"\n";
3833 aScript += "import HOMARD\n";
3835 aScript += "import salome\n";
3836 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
3838 aScript += "def RebuildData(theStudy):\n";
3839 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
3842 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
3843 MESSAGE (". Au depart \n"<<aScript);
3846 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
3848 MESSAGE (". Ecritures des frontieres");
3849 aScript += "#\n# Creation of the boundaries";
3850 aScript += "\n# ==========================";
3852 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3853 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
3854 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
3856 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
3857 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
3858 std::string dumpBoundary = dumpCorbaBoundary.in();
3859 MESSAGE (dumpBoundary<<"\n");
3860 aScript += dumpBoundary;
3864 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
3866 MESSAGE (". Ecritures des zones");
3867 aScript += "#\n# Creation of the zones";
3868 aScript += "\n# =====================";
3870 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3871 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
3872 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
3874 HOMARD::HOMARD_Zone_var maZone = (*it_zone).second;
3875 CORBA::String_var dumpCorbaZone = maZone->GetDumpPython();
3876 std::string dumpZone = dumpCorbaZone.in();
3877 MESSAGE (dumpZone<<"\n");
3878 aScript += dumpZone;
3882 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
3884 MESSAGE (". Ecritures des hypotheses");
3885 aScript += "#\n# Creation of the hypotheses";
3886 aScript += "\n# ==========================";
3888 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3889 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
3890 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
3892 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
3893 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
3894 std::string dumpHypo = dumpCorbaHypo.in();
3895 MESSAGE (dumpHypo<<"\n");
3896 aScript += dumpHypo;
3900 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
3902 MESSAGE (". Ecritures des cas");
3903 aScript += "#\n# Creation of the cases";
3904 aScript += "\n# =====================";
3906 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
3907 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
3908 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
3910 std::string nomCas = (*it_cas).first;
3911 std::string dumpCas = std::string("\n# Creation of the case ") ;
3912 dumpCas += nomCas + std::string("\n");
3913 dumpCas += std::string("\t") + nomCas;
3914 dumpCas += std::string(" = homard.CreateCase('") + nomCas + std::string("', '");
3916 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
3917 CORBA::String_var cIter0= myCase->GetIter0Name();
3918 std::string iter0 = cIter0.in();
3920 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
3921 CORBA::String_var cMesh0= myIteration->GetMeshFile();
3922 std::string mesh0 = cMesh0.in();
3923 CORBA::String_var cMeshName0= myIteration->GetMeshName();
3924 std::string meshName0 = cMeshName0.in();
3925 dumpCas += meshName0 + std::string("', '")+ mesh0 + std::string("')\n");
3926 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
3927 std::string dumpCas2= dumpCorbaCase.in();
3929 MESSAGE (dumpCas<<dumpCas2<<"\n");
3930 aScript += dumpCas + dumpCas2;
3934 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
3936 MESSAGE (". Ecritures des iterations");
3937 aScript += "#\n# Creation of the iterations" ;
3938 aScript += "\n# ==========================";
3940 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3941 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
3942 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
3944 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
3945 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
3946 std::string dumpIter = dumpCorbaIter.in();
3947 MESSAGE (dumpIter<<"\n");
3948 aScript += dumpIter;
3951 MESSAGE (". Ecritures finales");
3953 aScript += "\n\tpass";
3956 if( !isMultiFile ) // remove unnecessary tabulation
3957 aScript = RemoveTabulation( aScript );
3959 // MESSAGE ("A ecrire \n"<<aScript);
3960 const size_t aLen = strlen(aScript.c_str());
3961 char* aBuffer = new char[aLen+1];
3962 strcpy(aBuffer, aScript.c_str());
3964 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
3965 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
3967 MESSAGE ("Sortie de DumpPython");
3968 return aStreamFile._retn();
3972 //=============================================================================
3973 //=============================================================================
3975 //=============================================================================
3976 //=============================================================================
3977 void HOMARD_Gen_i::IsValidStudy( )
3979 // MESSAGE( "IsValidStudy" );
3980 if (CORBA::is_nil(myCurrentStudy))
3982 SALOME::ExceptionStruct es;
3983 es.type = SALOME::BAD_PARAM;
3984 es.text = "Invalid study context";
3985 throw SALOME::SALOME_Exception(es);
3990 //=============================================================================
3991 CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir)
3993 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
3994 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
3995 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
3997 if (std::string(nomDir) == std::string(it->second->GetDirName())) return false;
4001 /*//=============================================================================
4002 void SALOMEException( std::string message )
4004 SALOME::ExceptionStruct es;
4005 es.type = SALOME::BAD_PARAM;
4007 throw SALOME::SALOME_Exception(es);
4010 //=============================================================================
4011 char* HOMARD_Gen_i::getVersion()
4013 #if HOMARD_DEVELOPMENT
4014 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4016 return CORBA::string_dup(HOMARD_VERSION_STR);
4020 //=============================================================================
4023 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
4024 PortableServer::POA_ptr poa,
4025 PortableServer::ObjectId* contId,
4026 const char* instanceName,
4027 const char* interfaceName)
4029 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
4030 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
4031 return myHOMARD_Gen->getId();