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.c_str(), 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, CORBA::Long Option)
265 // Pour detruire un cas
266 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
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 if ( DeleteIterationOption(nomIter, Option1, Option) != 0 )
284 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
285 myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas);
286 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType());
287 SALOMEDS::SObject_var aSO =listSO[0];
288 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
289 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
293 //=============================================================================
294 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
296 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
297 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
298 if (CORBA::is_nil(myHypo))
300 SALOME::ExceptionStruct es;
301 es.type = SALOME::BAD_PARAM;
302 es.text = "Invalid hypothesis";
303 throw SALOME::SALOME_Exception(es);
307 // On verifie que l'hypothese n'est plus utilisee
308 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
309 int numberOfIter = maListeIter->length();
310 if ( numberOfIter > 0 )
312 SALOME::ExceptionStruct es;
313 es.type = SALOME::BAD_PARAM;
314 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
315 throw SALOME::SALOME_Exception(es);
319 // suppression du lien avec les zones eventuelles
320 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
321 int numberOfZones = maListe->length();
322 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
323 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
325 std::string ZoneName = std::string((*maListe)[NumeZone]);
326 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
327 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
331 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
332 myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo);
333 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType());
334 SALOMEDS::SObject_var aSO =listSO[0];
335 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
336 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
340 //=============================================================================
341 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
343 // Option = 0 : On ne supprime pas le fichier du maillage associe
344 // Option = 1 : On supprime le fichier du maillage associe
345 // Pour detruire une iteration courante
346 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
347 CORBA::Long Option1 = 1 ;
348 return DeleteIterationOption(nomIter, Option1, Option);
350 //=============================================================================
351 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
353 // Option1 = 0 : On autorise la destruction de l'iteration 0
354 // Option1 = 1 : On interdit la destruction de l'iteration 0
356 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
357 // Option2 = 1 : On supprime le fichier du maillage associe
358 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
359 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
360 if (CORBA::is_nil(myIteration))
362 SALOME::ExceptionStruct es;
363 es.type = SALOME::BAD_PARAM;
364 es.text = "Invalid iteration";
365 throw SALOME::SALOME_Exception(es);
369 int numero = myIteration->GetNumber();
370 MESSAGE ( "DeleteIterationOption : numero = " << numero );
371 if ( numero == 0 and Option1 == 1 )
373 SALOME::ExceptionStruct es;
374 es.type = SALOME::BAD_PARAM;
375 es.text = "This iteration cannot be deleted.";
376 throw SALOME::SALOME_Exception(es);
380 // On detruit recursivement toutes les filles
381 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
382 int numberOfIter = maListe->length();
383 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
385 std::string nomIterFille = std::string((*maListe)[NumeIter]);
386 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
387 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
390 // On arrive ici pour une iteration sans fille
391 MESSAGE ( "Destruction effective de " << nomIter );
392 // On commence par invalider l'iteration pour faire le menage des dependances
393 // et eventuellement du maillage associe
395 if ( numero == 0 ) { option = 0 ; }
396 else { option = Option2 ; }
397 InvalideIterOption(nomIter, option) ;
399 // Retrait dans la descendance de l'iteration parent
402 const char* nomIterationParent = myIteration->GetIterParentName();
403 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
404 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
405 if (CORBA::is_nil(myIterationParent))
407 SALOME::ExceptionStruct es;
408 es.type = SALOME::BAD_PARAM;
409 es.text = "Invalid iteration";
410 throw SALOME::SALOME_Exception(es);
413 myIterationParent->UnLinkNextIteration(nomIter);
416 // suppression du lien avec l'hypothese
419 const char* nomHypo = myIteration->GetHypoName();
420 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
421 ASSERT(!CORBA::is_nil(myHypo));
422 myHypo->UnLinkIteration(nomIter);
425 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
426 myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter);
427 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType());
428 SALOMEDS::SObject_var aSO =listSO[0];
429 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
430 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
431 // on peut aussi faire RemoveObject
432 // MESSAGE ( "Au final" );
433 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
434 // numberOfIter = Liste->length();
435 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
437 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
438 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
443 //=============================================================================
444 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
446 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
447 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone];
448 if (CORBA::is_nil(myZone))
450 SALOME::ExceptionStruct es;
451 es.type = SALOME::BAD_PARAM;
452 es.text = "Invalid zone";
453 throw SALOME::SALOME_Exception(es);
457 // On verifie que la zone n'est plus utilisee
458 HOMARD::listeHypo* maListe = myZone->GetHypo();
459 int numberOfHypo = maListe->length();
460 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
461 if ( numberOfHypo > 0 )
463 SALOME::ExceptionStruct es;
464 es.type = SALOME::BAD_PARAM;
465 es.text = "This zone is used in an hypothesis and cannot be deleted.";
466 throw SALOME::SALOME_Exception(es);
470 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
471 myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone);
472 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType());
473 SALOMEDS::SObject_var aSO =listSO[0];
474 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
475 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
479 //=============================================================================
480 //=============================================================================
482 //=============================================================================
483 //=============================================================================
484 // Invalidation des structures identifiees par leurs noms
485 //=============================================================================
486 //=============================================================================
487 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
489 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
490 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
491 if (CORBA::is_nil(myBoundary))
493 SALOME::ExceptionStruct es;
494 es.type = SALOME::BAD_PARAM;
495 es.text = "Invalid boundary";
496 throw SALOME::SALOME_Exception(es);
501 SALOME::ExceptionStruct es;
502 es.type = SALOME::BAD_PARAM;
503 es.text = "No change is allowed in a boundary. Ask for evolution.";
504 throw SALOME::SALOME_Exception(es);
508 //=============================================================================
509 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
511 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
512 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
513 if (CORBA::is_nil(myHypo))
515 SALOME::ExceptionStruct es;
516 es.type = SALOME::BAD_PARAM;
517 es.text = "Invalid hypothesis";
518 throw SALOME::SALOME_Exception(es);
522 HOMARD::listeIters* maListe = myHypo->GetIterations();
523 int numberOfIter = maListe->length();
524 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
526 std::string nomIter = std::string((*maListe)[NumeIter]);
527 MESSAGE( ".. nomIter = " << nomIter );
528 InvalideIter(nomIter.c_str());
531 //=============================================================================
532 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
534 MESSAGE("InvalideIter : nomIter = " << nomIter);
535 // Pour invalider totalement une iteration courante
536 CORBA::Long Option = 1 ;
537 return InvalideIterOption(nomIter, Option);
539 //=============================================================================
540 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
542 // Option = 0 : On ne supprime pas le fichier du maillage associe
543 // Option = 1 : On supprime le fichier du maillage associe
544 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
545 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
546 if (CORBA::is_nil(myIteration))
548 SALOME::ExceptionStruct es;
549 es.type = SALOME::BAD_PARAM;
550 es.text = "Invalid iteration";
551 throw SALOME::SALOME_Exception(es);
555 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
556 int numberOfIter = maListe->length();
557 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
559 std::string nomIterFille = std::string((*maListe)[NumeIter]);
560 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
561 InvalideIter(nomIterFille.c_str());
564 // On arrive ici pour une iteration sans fille
565 MESSAGE ( "Invalidation effective de " << nomIter );
566 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
567 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
568 for (; aIter->More(); aIter->Next())
570 SALOMEDS::SObject_var so = aIter->Value();
571 SALOMEDS::GenericAttribute_var anAttr;
572 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
573 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
574 std::string value (aCommentAttr->Value());
575 if(value == std::string("HypoHomard")) continue;
576 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
577 aStudyBuilder->RemoveObject(so);
580 int etat = myIteration->GetState();
583 SetEtatIter(nomIter,1);
584 const char * nomCas = myIteration->GetCaseName();
585 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
586 if (CORBA::is_nil(myCase))
588 SALOME::ExceptionStruct es;
589 es.type = SALOME::BAD_PARAM;
590 es.text = "Invalid case context";
591 throw SALOME::SALOME_Exception(es);
594 const char* nomDir = myIteration->GetDirName();
595 const char* nomFichier = myIteration->GetMeshFile();
596 std::string commande= "rm -rf " + 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* nomDir = myIteration->GetDirName();
655 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
656 commande += std::string(nomDir) + "/Liste.*info" ;
657 /* MESSAGE ( "commande = " << commande );*/
658 if ((system(commande.c_str())) != 0)
660 SALOME::ExceptionStruct es;
661 es.type = SALOME::BAD_PARAM;
662 es.text = "The directory for the calculation cannot be cleared." ;
663 throw SALOME::SALOME_Exception(es);
667 //=============================================================================
668 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
670 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
671 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
672 if (CORBA::is_nil(myZone))
674 SALOME::ExceptionStruct es;
675 es.type = SALOME::BAD_PARAM;
676 es.text = "Invalid zone";
677 throw SALOME::SALOME_Exception(es);
680 HOMARD::listeHypo* maListe = myZone->GetHypo();
681 int numberOfHypo = maListe->length();
682 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
683 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
685 std::string nomHypo = std::string((*maListe)[NumeHypo]);
686 MESSAGE( ".. nomHypo = " << nomHypo );
687 InvalideHypo(nomHypo.c_str());
690 //=============================================================================
691 //=============================================================================
693 //=============================================================================
694 //=============================================================================
695 // Association de lien entre des structures identifiees par leurs noms
696 //=============================================================================
697 //=============================================================================
698 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
700 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
702 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
703 if (CORBA::is_nil(myCase))
705 SALOME::ExceptionStruct es;
706 es.type = SALOME::BAD_PARAM;
707 es.text = "Invalid case";
708 throw SALOME::SALOME_Exception(es);
712 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
713 if (CORBA::is_nil(myIteration))
715 SALOME::ExceptionStruct es;
716 es.type = SALOME::BAD_PARAM;
717 es.text = "Invalid iteration";
718 throw SALOME::SALOME_Exception(es);
722 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
723 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
724 if (CORBA::is_nil(aCasSO))
726 SALOME::ExceptionStruct es;
727 es.type = SALOME::BAD_PARAM;
728 es.text = "Invalid case";
729 throw SALOME::SALOME_Exception(es);
733 aStudyBuilder->NewCommand();
734 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
735 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
736 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
737 aStudyBuilder->CommitCommand();
739 myCase->AddIteration(nomIter);
740 myIteration->SetCaseName(nomCas);
742 //=====================================================================================
743 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
745 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
747 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
748 ASSERT(!CORBA::is_nil(myHypo));
749 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
750 ASSERT(!CORBA::is_nil(aHypoSO));
752 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
753 ASSERT(!CORBA::is_nil(myZone));
754 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
755 ASSERT(!CORBA::is_nil(aZoneSO));
757 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
759 aStudyBuilder->NewCommand();
761 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
762 aStudyBuilder->Addreference(aSubSO, aZoneSO);
764 aStudyBuilder->CommitCommand();
766 myZone->AddHypo(nomHypothesis);
767 myHypo->AddZone0(ZoneName, TypeUse);
769 //=============================================================================
770 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
772 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
774 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
775 ASSERT(!CORBA::is_nil(myHypo));
776 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
777 ASSERT(!CORBA::is_nil(aHypoSO));
779 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
780 ASSERT(!CORBA::is_nil(myIteration));
781 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
782 ASSERT(!CORBA::is_nil(aIterSO));
784 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
786 aStudyBuilder->NewCommand();
788 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
789 aStudyBuilder->Addreference(aSubSO, aHypoSO);
791 aStudyBuilder->CommitCommand();
793 myIteration->SetHypoName(nomHypo);
794 myHypo->LinkIteration(nomIter);
796 //=============================================================================
797 //=============================================================================
799 //=============================================================================
800 //=============================================================================
801 // Dissociation de lien entre des structures identifiees par leurs noms
802 //=============================================================================
803 //=============================================================================
804 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
806 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
808 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
809 ASSERT(!CORBA::is_nil(myHypo));
810 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
811 ASSERT(!CORBA::is_nil(aHypoSO));
813 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
814 ASSERT(!CORBA::is_nil(myZone));
815 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
816 ASSERT(!CORBA::is_nil(aZoneSO));
818 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
820 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
821 for (; it->More(); it->Next())
823 SALOMEDS::SObject_var aHypObj = it->Value();
824 SALOMEDS::SObject_var ptrObj;
825 if (aHypObj->ReferencedObject(ptrObj))
827 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
829 aStudyBuilder->NewCommand();
830 aStudyBuilder->RemoveObject(aHypObj);
831 aStudyBuilder->CommitCommand();
837 myZone->SupprHypo(nomHypothesis);
838 myHypo->SupprZone(ZoneName);
840 //=============================================================================
841 //=============================================================================
844 //=============================================================================
845 //=============================================================================
846 // Recuperation des listes
847 //=============================================================================
848 //=============================================================================
849 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
851 MESSAGE("GetAllCasesName");
854 HOMARD::listeCases_var ret = new HOMARD::listeCases;
855 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
856 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
858 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
859 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
861 ret[i++] = CORBA::string_dup((*it).first.c_str());
866 //=============================================================================
867 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
869 MESSAGE("GetAllHypothesesName");
872 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
873 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
874 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
876 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
877 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
879 ret[i++] = CORBA::string_dup((*it).first.c_str());
884 //=============================================================================
885 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
887 MESSAGE("GetAllZonesName");
890 HOMARD::listeZones_var ret = new HOMARD::listeZones;
891 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
892 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
894 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
895 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
897 ret[i++] = CORBA::string_dup((*it).first.c_str());
902 //=============================================================================
903 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
905 MESSAGE("GetAllIterationsName");
908 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
909 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
910 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
912 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
913 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
915 ret[i++] = CORBA::string_dup((*it).first.c_str());
920 //=============================================================================
921 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
923 MESSAGE("GetAllBoundarysName");
926 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
927 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
928 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
930 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
931 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
933 ret[i++] = CORBA::string_dup((*it).first.c_str());
938 //=============================================================================
939 //=============================================================================
941 //=============================================================================
942 //=============================================================================
943 // Recuperation des structures identifiees par leurs noms
944 //=============================================================================
945 //=============================================================================
946 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
948 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
949 ASSERT(!CORBA::is_nil(myCase));
950 return HOMARD::HOMARD_Cas::_duplicate(myCase);
952 //=============================================================================
953 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
955 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
956 ASSERT(!CORBA::is_nil(myZone));
957 return HOMARD::HOMARD_Zone::_duplicate(myZone);
959 //=============================================================================
960 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
962 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
963 ASSERT(!CORBA::is_nil(myHypothesis));
964 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
966 //=============================================================================
967 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
969 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
970 ASSERT(!CORBA::is_nil(myIteration));
971 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
973 //=============================================================================
974 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
976 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
977 ASSERT(!CORBA::is_nil(myBoundary));
978 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
980 //=============================================================================
981 //=============================================================================
983 //=============================================================================
984 //=============================================================================
986 //=============================================================================
987 //=============================================================================
988 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)
990 MESSAGE ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
991 MESSAGE ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
995 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, 1) ;
996 myCase->SetDirName(DirName) ;
998 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1002 //=============================================================================
1003 //=============================================================================
1005 //=============================================================================
1006 //=============================================================================
1007 // Recuperation des structures par le contexte
1008 //=============================================================================
1009 //=============================================================================
1010 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1012 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1013 ASSERT(!CORBA::is_nil(myCase));
1015 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1016 ASSERT(!CORBA::is_nil(myIteration));
1018 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1020 //=============================================================================
1021 //=============================================================================
1023 //=============================================================================
1024 //=============================================================================
1025 // Nouvelles structures
1026 //=============================================================================
1027 //=============================================================================
1028 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1030 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1031 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1032 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1033 return aCase._retn();
1035 //=============================================================================
1036 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1038 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1039 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1040 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1041 return aHypo._retn();
1043 //=============================================================================
1044 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1046 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1047 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1048 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1049 return aIter._retn();
1051 //=============================================================================
1052 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1054 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1055 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1056 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1057 return aBoundary._retn();
1059 //=============================================================================
1060 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1062 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1063 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1064 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1065 return aZone._retn();
1067 //=============================================================================
1068 //=============================================================================
1070 //=============================================================================
1071 //=============================================================================
1072 // Creation des structures identifiees par leurs noms
1073 //=============================================================================
1074 //=============================================================================
1075 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1077 // Creation d'un cas initial
1078 // nomCas : nom du cas a creer
1079 // MeshName, MeshFile : nom et fichier du maillage correspondant
1082 MESSAGE ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1084 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, 2) ;
1086 // Valeurs par defaut des filtrages
1087 myCase->SetPyram(0);
1089 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1091 //=============================================================================
1092 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1094 // nomCas : nom du cas a creer
1095 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1098 MESSAGE ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1099 std::string nomDirWork = getenv("PWD") ;
1102 // A. Decodage du point de reprise
1103 // A.1. Controle du repertoire de depart de l'iteration
1104 codret = chdir(DirNameStart) ;
1107 SALOME::ExceptionStruct es;
1108 es.type = SALOME::BAD_PARAM;
1109 es.text = "The directory of the iteration does not exist.";
1110 throw SALOME::SALOME_Exception(es);
1113 // A.2. Reperage des fichiers du repertoire de reprise
1114 std::string file_configuration = "" ;
1115 std::string file_maillage_homard = "" ;
1118 struct dirent *dirp;
1119 dp = opendir(DirNameStart);
1120 while ( (dirp = readdir(dp)) != NULL )
1122 std::string file_name(dirp->d_name);
1123 // MESSAGE ( file_name );
1124 bilan = file_name.find("HOMARD.Configuration.") ;
1125 if ( bilan != string::npos ) { file_configuration = file_name ; }
1126 bilan = file_name.find("maill.") ;
1127 if ( bilan != string::npos )
1129 bilan = file_name.find(".hom.med") ;
1130 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1134 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1135 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1137 if ( ( file_configuration == "" ) or ( file_maillage_homard == "" ) )
1139 SALOME::ExceptionStruct es;
1140 es.type = SALOME::BAD_PARAM;
1142 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1143 else { text = "The HOMARD mesh file cannot be found." ; }
1144 es.text = CORBA::string_dup(text.c_str());
1145 throw SALOME::SALOME_Exception(es);
1148 // B. Lecture du fichier de configuration
1149 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1155 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1156 std::ifstream fichier( file_configuration.c_str() );
1157 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1159 std::string ligne; // variable contenant chaque ligne lue
1160 std::string mot_cle;
1161 std::string argument;
1163 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1164 while ( std::getline( fichier, ligne ) )
1166 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1167 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1168 ligne_bis >> mot_cle ;
1169 // B.2. Des valeurs entieres : le second bloc de la ligne
1170 if ( mot_cle == "NumeIter" )
1172 ligne_bis >> NumeIter ;
1175 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1176 else if ( ( mot_cle == "TypeConf" ) or ( mot_cle == "TypeElem" ) )
1178 ligne_bis >> argument ;
1180 if ( mot_cle == "TypeConf" )
1182 if ( argument == "conforme" ) { TypeConf = 1 ; }
1183 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1184 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1185 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1187 else if ( mot_cle == "TypeElem" )
1189 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1190 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1193 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1194 // il faut les supprimer
1195 else if ( ( mot_cle == "CCNoMNP1" ) or ( mot_cle == "CCMaiNP1" ) )
1197 ligne_bis >> argument ;
1198 if ( argument[0] == '"' ) { decalage = 1 ; }
1199 else { decalage = 0 ; }
1200 size_t size = argument.size() + 1 - 2*decalage ;
1202 if ( mot_cle == "CCNoMNP1" )
1204 MeshName = new char[ size ];
1205 strncpy( MeshName, argument.c_str()+decalage, size );
1206 MeshName[size-1] = '\0' ;
1208 else if ( mot_cle == "CCMaiNP1" )
1210 MeshFile = new char[ size ];
1211 strncpy( MeshFile, argument.c_str()+decalage, size );
1212 MeshFile[size-1] = '\0' ;
1216 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1217 MESSAGE ( "==> MeshName : " << MeshName ) ;
1218 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1219 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1220 MESSAGE ( "==> Pyram : " << Pyram ) ;
1224 SALOME::ExceptionStruct es;
1225 es.type = SALOME::BAD_PARAM;
1226 std::string text = "The configuration file cannot be read." ;
1227 es.text = CORBA::string_dup(text.c_str());
1228 throw SALOME::SALOME_Exception(es);
1231 // C. Creation effective du cas
1233 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, 2) ;
1235 // D. Parametrages lus dans le fichier de configuration
1237 myCase->SetConfType (TypeConf) ;
1238 myCase->SetPyram (Pyram) ;
1240 // E. Copie du fichier de maillage homard
1241 // E.1. Repertoire associe au cas
1242 char* nomDirCase = myCase->GetDirName() ;
1243 // E.2. Repertoire associe a l'iteration de ce cas
1245 IterName = myCase->GetIter0Name() ;
1246 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1247 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1248 Iter->SetDirNameLoc(nomDirIter);
1249 std::string nomDirIterTotal ;
1250 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1251 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1253 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1254 SALOME::ExceptionStruct es;
1255 es.type = SALOME::BAD_PARAM;
1256 std::string text = "The directory for the computation cannot be created." ;
1257 es.text = CORBA::string_dup(text.c_str());
1258 throw SALOME::SALOME_Exception(es);
1260 // E.3. Copie du maillage HOMARD au format MED
1261 codret = chdir(DirNameStart) ;
1262 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1263 MESSAGE ( "commande : " << commande ) ;
1264 codret = system(commande.c_str()) ;
1265 MESSAGE ( "codret : " << codret ) ;
1268 SALOME::ExceptionStruct es;
1269 es.type = SALOME::BAD_PARAM;
1270 es.text = "The starting point for the case cannot be copied into the working directory.";
1271 throw SALOME::SALOME_Exception(es);
1280 chdir(nomDirWork.c_str());
1282 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1284 //=============================================================================
1285 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1287 // nomCas : nom du cas a creer
1288 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1291 MESSAGE ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1293 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1295 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1296 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1298 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1300 //=============================================================================
1301 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1303 // nomCas : nom du cas a creer
1304 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1305 // Number : numero de l'iteration de depart
1308 MESSAGE ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1311 SALOME::ExceptionStruct es;
1312 es.type = SALOME::BAD_PARAM;
1313 es.text = "The number of iteration must be positive.";
1314 throw SALOME::SALOME_Exception(es);
1318 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1320 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1321 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1323 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1325 //=============================================================================
1326 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1328 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1329 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1330 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1333 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1334 std::string nomDirWork = getenv("PWD") ;
1335 std::string DirNameStartIter ;
1337 int NumeIterMax = -1 ;
1339 // A.1. Controle du repertoire de depart du cas
1340 codret = chdir(DirNameStart) ;
1343 SALOME::ExceptionStruct es;
1344 es.type = SALOME::BAD_PARAM;
1345 es.text = "The directory of the case for the pursuit does not exist.";
1346 throw SALOME::SALOME_Exception(es);
1349 // A.2. Reperage des sous-repertoire du repertoire de reprise
1350 bool existe = false ;
1352 struct dirent *dirp;
1353 dp = opendir(DirNameStart);
1354 while ( (dirp = readdir(dp)) != NULL )
1356 std::string DirName_1(dirp->d_name);
1357 if ( ( DirName_1 != "." ) and ( DirName_1 != ".." ) )
1359 if ( chdir(DirName_1.c_str()) == 0 )
1361 // On cherche le fichier de configuration dans ce sous-repertoire
1362 codret = chdir(DirNameStart) ;
1364 struct dirent *dirp_1;
1365 dp_1 = opendir(DirName_1.c_str()) ;
1366 while ( (dirp_1 = readdir(dp_1)) != NULL )
1368 std::string file_name_1(dirp_1->d_name);
1369 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1370 if ( bilan != string::npos )
1372 // Decodage du fichier pour trouver le numero d'iteration
1373 chdir(DirName_1.c_str()) ;
1374 std::ifstream fichier( file_name_1.c_str() );
1375 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1378 std::string ligne; // variable contenant chaque ligne lue
1379 std::string mot_cle;
1380 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1381 while ( std::getline( fichier, ligne ) )
1383 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1384 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1385 ligne_bis >> mot_cle ;
1386 if ( mot_cle == "NumeIter" )
1388 ligne_bis >> NumeIter ;
1390 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1391 if ( Number == - 1 )
1393 if ( NumeIter >= NumeIterMax )
1395 NumeIterMax = NumeIter ;
1396 DirNameStartIter = DirName_1 ;
1401 if ( NumeIter == Number )
1403 DirNameStartIter = DirName_1 ;
1413 SALOME::ExceptionStruct es;
1414 es.type = SALOME::BAD_PARAM;
1415 std::string text = "The configuration file cannot be read." ;
1416 es.text = CORBA::string_dup(text.c_str());
1417 throw SALOME::SALOME_Exception(es);
1419 chdir(DirNameStart) ;
1421 if ( existe ) { break ; }
1424 if ( existe ) { break ; }
1430 chdir(nomDirWork.c_str());
1432 if ( ( Number >= 0 and ( not existe ) ) or ( Number < 0 and ( NumeIterMax == -1 ) ) )
1434 SALOME::ExceptionStruct es;
1435 es.type = SALOME::BAD_PARAM;
1436 es.text = "The directory of the iteration does not exist.";
1437 throw SALOME::SALOME_Exception(es);
1441 return DirNameStartIter ;
1443 //=============================================================================
1444 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)
1446 // nomCas : nom du cas a creer
1447 // MeshName, MeshFile : nom et fichier du maillage correspondant
1448 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1449 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1450 // -1 : le maillage n'est pas fourni
1451 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1452 // Option : multiple de nombres premiers
1453 // 1 : aucune option
1454 // x2 : publication du maillage dans SMESH
1456 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1457 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1458 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1464 // A.2. Controle du nom :
1465 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1467 SALOME::ExceptionStruct es;
1468 es.type = SALOME::BAD_PARAM;
1469 es.text = "This case has already been defined.";
1470 throw SALOME::SALOME_Exception(es);
1474 // A.3. Controle du fichier du maillage
1475 int existeMeshFile ;
1476 if ( MeshOption >= 0 )
1478 existeMeshFile = MEDFileExist ( MeshFile ) ;
1479 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1480 if ( ( existeMeshFile == 0 ) and ( MeshOption == 0 ) )
1482 SALOME::ExceptionStruct es;
1483 es.type = SALOME::BAD_PARAM;
1484 es.text = "The mesh file does not exist.";
1485 throw SALOME::SALOME_Exception(es);
1489 else { existeMeshFile = 0 ; }
1491 // B. Creation de l'objet cas et publication
1492 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1493 HOMARD::HOMARD_Cas_var myCase = newCase();
1494 myCase->SetName(nomCas);
1495 SALOMEDS::SObject_var aSO;
1496 PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1497 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1499 // C. Caracteristiques du maillage
1500 if ( existeMeshFile != 0 )
1502 // Les valeurs extremes des coordonnees
1503 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1504 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1505 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1506 if (LesExtremes.size()!=10) { return false; }
1508 for (int i =0 ; i< LesExtremes.size() ; i++)
1509 aSeq[i]=LesExtremes[i] ;
1510 myCase->SetBoundingBox(aSeq) ;
1512 // MESSAGE ( "CreateCase0 : Les groupes" );
1513 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1514 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1515 aSeqGroupe->length(LesGroupes.size());
1516 std::set<std::string>::const_iterator it ;
1518 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1519 aSeqGroupe[i++]=(*it).c_str() ;
1520 myCase->SetGroups(aSeqGroupe) ;
1523 // D. L'iteration initiale du cas
1524 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1525 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1526 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1528 std::string NomIteration = std::string(MeshName) ;
1529 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1531 std::ostringstream nom;
1532 nom << MeshName << monNum;
1533 NomIteration = nom.str();
1536 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1538 // D.2. Creation de l'iteration
1539 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1540 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1541 anIter->SetName(NomIteration.c_str());
1542 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1544 // D.4. Maillage correspondant
1545 if ( existeMeshFile != 0 )
1547 anIter->SetMeshFile(MeshFile);
1548 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1550 anIter->SetMeshName(MeshName);
1552 // D.5. Numero d'iteration
1553 anIter->SetNumber(NumeIter);
1556 SetEtatIter(NomIteration.c_str(), -NumeIter);
1559 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1561 //=============================================================================
1562 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1564 MESSAGE ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1567 // Controle du nom :
1568 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1570 SALOME::ExceptionStruct es;
1571 es.type = SALOME::BAD_PARAM;
1572 es.text = "This hypothesis has already been defined.";
1573 throw SALOME::SALOME_Exception(es);
1577 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1578 myHypothesis->SetName(nomHypothesis);
1579 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1580 SALOMEDS::SObject_var aSO;
1581 PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1583 // Valeurs par defaut des options avancees
1584 myHypothesis->SetNivMax(-1);
1585 myHypothesis->SetDiamMin(-1.0);
1586 myHypothesis->SetAdapInit(0);
1587 myHypothesis->SetLevelOutput(0);
1589 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1592 //=============================================================================
1593 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1594 //=============================================================================
1596 MESSAGE ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1599 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1600 if (CORBA::is_nil(myIterationParent))
1602 SALOME::ExceptionStruct es;
1603 es.type = SALOME::BAD_PARAM;
1604 es.text = "The parent iteration is not defined.";
1605 throw SALOME::SALOME_Exception(es);
1609 const char* nomCas = myIterationParent->GetCaseName();
1610 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1611 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1612 if (CORBA::is_nil(myCase))
1614 SALOME::ExceptionStruct es;
1615 es.type = SALOME::BAD_PARAM;
1616 es.text = "Invalid case context";
1617 throw SALOME::SALOME_Exception(es);
1620 const char* nomDirCase = myCase->GetDirName();
1622 // Controle du nom :
1623 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1625 SALOME::ExceptionStruct es;
1626 es.type = SALOME::BAD_PARAM;
1627 es.text = "This iteration has already been defined.";
1628 throw SALOME::SALOME_Exception(es);
1632 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1633 if (CORBA::is_nil(myIteration))
1635 SALOME::ExceptionStruct es;
1636 es.type = SALOME::BAD_PARAM;
1637 es.text = "Unable to create the iteration";
1638 throw SALOME::SALOME_Exception(es);
1641 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1642 // Nom de l'iteration et du maillage
1643 myIteration->SetName(NomIteration);
1644 myIteration->SetMeshName(NomIteration);
1645 myIteration->SetState(1);
1647 int numero = myIterationParent->GetNumber() + 1;
1648 myIteration->SetNumber(numero);
1650 // Nombre d'iterations deja connues pour le cas, permettant
1651 // la creation d'un sous-repertoire unique
1652 int nbitercase = myCase->GetNumberofIter();
1653 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1654 myIteration->SetDirNameLoc(nomDirIter);
1656 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1657 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1658 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1659 // situation la plus frequente.
1660 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1661 // le nombre d'iterations du cas permet d'eviter les collisions.
1663 if ( nbitercase < 100 ) { jaux = 2 ; }
1664 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1665 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1666 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1668 std::ostringstream iaux ;
1669 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1670 std::stringstream MeshFile;
1671 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1672 myIteration->SetMeshFile(MeshFile.str().c_str());
1674 // Association avec le cas
1675 std::string label = "IterationHomard_" + std::string(nomIterParent);
1676 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1677 // Lien avec l'iteration precedente
1678 myIterationParent->LinkNextIteration(NomIteration);
1679 myIteration->SetIterParentName(nomIterParent);
1681 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1683 //=============================================================================
1684 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1686 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1689 // Controle du nom :
1690 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1692 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1693 SALOME::ExceptionStruct es;
1694 es.type = SALOME::BAD_PARAM;
1695 es.text = "This boundary has already been defined";
1696 throw SALOME::SALOME_Exception(es);
1700 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1701 myBoundary->SetName(BoundaryName);
1702 myBoundary->SetType(BoundaryType);
1704 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1706 SALOMEDS::SObject_var aSO;
1707 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1709 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1711 //=============================================================================
1712 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1714 MESSAGE ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1715 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1716 myBoundary->SetMeshFile( MeshFile ) ;
1717 myBoundary->SetMeshName( MeshName ) ;
1719 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1721 //=============================================================================
1722 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1723 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1724 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1725 CORBA::Double Rayon)
1727 MESSAGE ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1729 SALOME::ExceptionStruct es;
1732 { es.text = "The radius must be positive." ;
1734 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1735 if ( daux < 0.0000001 )
1736 { es.text = "The axis must be a non 0 vector." ;
1740 es.type = SALOME::BAD_PARAM;
1741 throw SALOME::SALOME_Exception(es);
1745 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1746 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1748 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1750 //=============================================================================
1751 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1752 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1753 CORBA::Double Rayon)
1755 MESSAGE ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1757 SALOME::ExceptionStruct es;
1760 { es.text = "The radius must be positive." ;
1764 es.type = SALOME::BAD_PARAM;
1765 throw SALOME::SALOME_Exception(es);
1769 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1770 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1772 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1774 //=============================================================================
1775 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1776 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1777 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1779 MESSAGE ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1781 SALOME::ExceptionStruct es;
1783 if ( Angle <= 0.0 or Angle >= 90.0 )
1784 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1786 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1787 if ( daux < 0.0000001 )
1788 { es.text = "The axis must be a non 0 vector." ;
1792 es.type = SALOME::BAD_PARAM;
1793 throw SALOME::SALOME_Exception(es);
1797 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
1798 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
1800 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1802 //=============================================================================
1803 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
1804 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
1805 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
1807 MESSAGE ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
1809 SALOME::ExceptionStruct es;
1811 if ( Rayon1 < 0.0 or Rayon2 < 0.0 )
1812 { es.text = "The radius must be positive." ;
1814 double daux = fabs(Rayon2-Rayon1) ;
1815 if ( daux < 0.0000001 )
1816 { es.text = "The radius must be different." ;
1818 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
1819 if ( daux < 0.0000001 )
1820 { es.text = "The centers must be different." ;
1824 es.type = SALOME::BAD_PARAM;
1825 throw SALOME::SALOME_Exception(es);
1829 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
1830 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
1832 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1834 //=============================================================================
1835 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
1837 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
1840 // Controle du nom :
1841 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
1843 SALOME::ExceptionStruct es;
1844 es.type = SALOME::BAD_PARAM;
1845 es.text = "This zone has already been defined";
1846 throw SALOME::SALOME_Exception(es);
1850 HOMARD::HOMARD_Zone_var myZone = newZone();
1851 myZone->SetName(ZoneName);
1852 myZone->SetType(ZoneType);
1854 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
1856 SALOMEDS::SObject_var aSO;
1857 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
1859 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1861 //=============================================================================
1862 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
1863 CORBA::Double Xmini, CORBA::Double Xmaxi,
1864 CORBA::Double Ymini, CORBA::Double Ymaxi,
1865 CORBA::Double Zmini, CORBA::Double Zmaxi)
1867 MESSAGE ("CreateZoneBox : ZoneName = " << ZoneName ) ;
1869 SALOME::ExceptionStruct es;
1871 if ( Xmini > Xmaxi )
1872 { es.text = "The X coordinates are not coherent." ;
1874 if ( Ymini > Ymaxi )
1875 { es.text = "The Y coordinates are not coherent." ;
1877 if ( Zmini > Zmaxi )
1878 { es.text = "The Z coordinates are not coherent." ;
1882 es.type = SALOME::BAD_PARAM;
1883 throw SALOME::SALOME_Exception(es);
1887 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
1888 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
1890 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1892 //=============================================================================
1893 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
1894 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
1896 MESSAGE ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
1898 SALOME::ExceptionStruct es;
1901 { es.text = "The radius must be positive." ;
1905 es.type = SALOME::BAD_PARAM;
1906 throw SALOME::SALOME_Exception(es);
1910 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
1911 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1913 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1915 //=============================================================================
1916 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
1917 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1918 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1919 CORBA::Double Rayon, CORBA::Double Haut)
1921 MESSAGE ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
1923 SALOME::ExceptionStruct es;
1926 { es.text = "The radius must be positive." ;
1928 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1929 if ( daux < 0.0000001 )
1930 { es.text = "The axis must be a non 0 vector." ;
1933 { es.text = "The height must be positive." ;
1937 es.type = SALOME::BAD_PARAM;
1938 throw SALOME::SALOME_Exception(es);
1942 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
1943 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
1945 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1947 //=============================================================================
1948 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
1949 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1950 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1951 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
1953 MESSAGE ("CreateZonePipe : ZoneName = " << ZoneName ) ;
1955 SALOME::ExceptionStruct es;
1957 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
1958 { es.text = "The radius must be positive." ;
1960 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1961 if ( daux < 0.0000001 )
1962 { es.text = "The axis must be a non 0 vector." ;
1965 { es.text = "The height must be positive." ;
1967 if ( Rayon <= Rayonint )
1968 { es.text = "The external radius must be higher than the internal radius." ;
1972 es.type = SALOME::BAD_PARAM;
1973 throw SALOME::SALOME_Exception(es);
1977 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
1978 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
1980 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1982 //=============================================================================
1983 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
1984 CORBA::Double Umini, CORBA::Double Umaxi,
1985 CORBA::Double Vmini, CORBA::Double Vmaxi,
1988 MESSAGE ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
1989 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
1990 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
1991 // MESSAGE ("Orient = " << Orient ) ;
1993 SALOME::ExceptionStruct es;
1995 if ( Umini > Umaxi )
1996 { es.text = "The first coordinates are not coherent." ;
1998 if ( Vmini > Vmaxi )
1999 { es.text = "The second coordinates are not coherent." ;
2001 if ( Orient < 1 or Orient > 3 )
2002 { es.text = "The orientation must be 1, 2 or 3." ;
2006 es.type = SALOME::BAD_PARAM;
2007 throw SALOME::SALOME_Exception(es);
2011 double Xmini, Xmaxi ;
2012 double Ymini, Ymaxi ;
2013 double Zmini, Zmaxi ;
2021 else if ( Orient == 2 )
2028 else if ( Orient == 3 )
2035 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2037 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2038 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2040 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2042 //=============================================================================
2043 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2044 CORBA::Double Ucentre, CORBA::Double Vcentre,
2045 CORBA::Double Rayon,
2048 MESSAGE ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2050 SALOME::ExceptionStruct es;
2053 { es.text = "The radius must be positive." ;
2055 if ( Orient < 1 or Orient > 3 )
2056 { es.text = "The orientation must be 1, 2 or 3." ;
2060 es.type = SALOME::BAD_PARAM;
2061 throw SALOME::SALOME_Exception(es);
2069 { Xcentre = Ucentre ;
2072 else if ( Orient == 2 )
2075 Zcentre = Vcentre ; }
2076 else if ( Orient == 3 )
2077 { Xcentre = Vcentre ;
2079 Zcentre = Ucentre ; }
2080 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2082 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2083 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2085 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2087 //=============================================================================
2088 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2089 CORBA::Double Ucentre, CORBA::Double Vcentre,
2090 CORBA::Double Rayon, CORBA::Double Rayonint,
2093 MESSAGE ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2095 SALOME::ExceptionStruct es;
2097 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
2098 { es.text = "The radius must be positive." ;
2100 if ( Orient < 1 or Orient > 3 )
2101 { es.text = "The orientation must be 1, 2 or 3." ;
2103 if ( Rayon <= Rayonint )
2104 { es.text = "The external radius must be higher than the internal radius." ;
2108 es.type = SALOME::BAD_PARAM;
2109 throw SALOME::SALOME_Exception(es);
2117 { Xcentre = Ucentre ;
2120 else if ( Orient == 2 )
2123 Zcentre = Vcentre ; }
2124 else if ( Orient == 3 )
2125 { Xcentre = Vcentre ;
2127 Zcentre = Ucentre ; }
2128 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2130 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2131 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2133 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2135 //=============================================================================
2136 //=============================================================================
2141 //=============================================================================
2142 //=============================================================================
2143 // Traitement d'une iteration
2144 // etatMenage = 1 : destruction du repertoire d'execution
2145 // modeHOMARD = 1 : adaptation
2146 // != 1 : information avec les options modeHOMARD
2147 // Option1 >0 : appel depuis python
2148 // <0 : appel depuis GUI
2149 // Option2 : multiple de nombres premiers
2150 // 1 : aucune option
2151 // x2 : publication du maillage dans SMESH
2152 //=============================================================================
2153 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2155 MESSAGE ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", avec Option1 = " << Option1 << ", avec Option2 = " << Option2 );
2160 // A.1. L'objet iteration
2161 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2162 ASSERT(!CORBA::is_nil(myIteration));
2164 // A.2. Numero de l'iteration
2165 // siterp1 : numero de l'iteration a traiter
2167 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2168 // Ou si information :
2170 int NumeIter = myIteration->GetNumber();
2171 std::string siterp1 ;
2172 std::stringstream saux1 ;
2174 siterp1 = saux1.str() ;
2175 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2178 if ( modeHOMARD==1 )
2180 std::stringstream saux0 ;
2181 int iaux = max(0, NumeIter-1) ;
2183 siter = saux0.str() ;
2184 if (NumeIter < 11) { siter = "0" + siter ; }
2187 { siter = siterp1 ; }
2190 const char* nomCas = myIteration->GetCaseName();
2191 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2192 ASSERT(!CORBA::is_nil(myCase));
2194 // B. Les repertoires
2195 // B.1. Le repertoire courant
2196 std::string nomDirWork = getenv("PWD") ;
2197 // B.2. Le sous-repertoire de l'iteration a traiter
2198 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2199 MESSAGE( ". DirCompute = " << DirCompute );
2201 // C. Le fichier des messages
2202 // C.1. Le deroulement de l'execution de HOMARD
2203 std::string LogFile = DirCompute ;
2204 LogFile += "/Liste" ;
2205 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2207 MESSAGE (". LogFile = " << LogFile);
2208 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2209 // C.2. Le bilan de l'analyse du maillage
2210 std::string FileInfo = DirCompute ;
2212 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2214 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2215 else { FileInfo += "info_ap" ; }
2217 FileInfo += "." + siterp1 + ".bilan" ;
2218 myIteration->SetFileInfo(FileInfo.c_str());
2220 // D. On passe dans le repertoire de l'iteration a calculer
2221 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2224 // E. Les donnees de l'execution HOMARD
2225 // E.1. L'objet du texte du fichier de configuration
2226 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2227 std::string Langue = "Francais" ;
2228 myDriver->TexteInit(DirCompute, LogFile, Langue);
2230 // E.2. Le maillage associe a l'iteration
2231 const char* NomMesh = myIteration->GetMeshName();
2232 MESSAGE ( ". NomMesh = " << NomMesh );
2233 const char* MeshFile = myIteration->GetMeshFile();
2234 MESSAGE ( ". MeshFile = " << MeshFile );
2236 // E.3. Les donnees du traitement HOMARD
2238 if ( modeHOMARD == 1 )
2241 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2242 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2243 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2247 InvalideIterInfo(NomIteration);
2248 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2250 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2251 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2252 myDriver->CreeFichierDonn();
2255 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2256 DriverTexteBoundary(myCase, myDriver) ;
2258 // E.5. Ecriture du texte dans le fichier
2260 { myDriver->CreeFichier(); }
2264 int codretexec = 12 ;
2267 codretexec = myDriver->ExecuteHomard(Option1);
2269 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2270 if ( modeHOMARD == 1 )
2272 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2273 else { SetEtatIter(NomIteration,1); }
2274 // GERALD -- QMESSAGE BOX
2278 // H. Gestion des resultats
2281 std::string Commentaire ;
2282 // H.1. Le fichier des messages, dans tous les cas
2283 Commentaire = "log" ;
2284 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2285 else { Commentaire += "Info" ; }
2286 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2288 // H.2. Si tout s'est bien passe :
2289 if (codretexec == 0)
2291 // H.2.1. Le fichier de bilan
2292 Commentaire = "Summary" ;
2293 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2294 else { Commentaire += "Info" ; }
2295 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2296 // H.2.2. Le fichier de maillage obtenu
2297 if ( modeHOMARD == 1 )
2299 std::stringstream saux0 ;
2300 Commentaire = "Iteration" ;
2301 Commentaire += " " + siter ;
2302 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2303 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2306 // H.3 Message d'erreur en cas de probleme
2309 SALOME::ExceptionStruct es;
2310 es.type = SALOME::BAD_PARAM;
2311 std::string text = "Error during the adaptation.\n" ;
2314 ifstream fichier(LogFile.c_str(), ios::in);
2316 while(getline(fichier, ligne) and (ligne != "===== HOMARD ===== STOP ====="));
2317 while (getline(fichier, ligne)) { text += ligne+ "\n";};
2320 text += "no log file ....";
2322 es.text = CORBA::string_dup(text.c_str());
2323 throw SALOME::SALOME_Exception(es);
2327 // I. Menage et retour dans le repertoire du cas
2331 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2332 chdir(nomDirWork.c_str());
2337 //=============================================================================
2338 // Calcul d'une iteration : partie specifique a l'adaptation
2339 //=============================================================================
2340 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)
2342 MESSAGE ( "ComputeAdap" );
2347 // Etat de l'iteration
2348 int etat = myIteration->GetState();
2349 // Numero de l'iteration
2350 int NumeIter = myIteration->GetNumber();
2351 std::stringstream saux0 ;
2352 saux0 << NumeIter-1 ;
2353 std::string siter = saux0.str() ;
2354 if (NumeIter < 11) { siter = "0" + siter ; }
2356 // A.2. On ne calcule pas l iteration initiale
2359 MESSAGE ( "etat = "<<etat );
2360 SALOME::ExceptionStruct es;
2361 es.type = SALOME::BAD_PARAM;
2362 es.text = "This iteration is the first of the case and cannot be computed.";
2363 throw SALOME::SALOME_Exception(es);
2367 // A.3. On verifie qu il y a une hypothese (erreur improbable);
2368 const char* nomHypo = myIteration->GetHypoName();
2369 if (std::string(nomHypo) == std::string(""))
2371 SALOME::ExceptionStruct es;
2372 es.type = SALOME::BAD_PARAM;
2373 es.text = "This iteration does not have any associated hypothesis.";
2374 throw SALOME::SALOME_Exception(es);
2377 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2378 ASSERT(!CORBA::is_nil(myHypo));
2380 // B. L'iteration parent
2381 const char* nomIterationParent = myIteration->GetIterParentName();
2382 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2383 ASSERT(!CORBA::is_nil(myIterationParent));
2384 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2385 if ( myIterationParent->GetState() == 1 )
2388 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2391 // GERALD -- QMESSAGE BOX
2392 ASSERT("Pb au calcul de l'iteration precedente" == 0);
2396 // C. Le sous-repertoire de l'iteration precedente
2397 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2398 MESSAGE( ". DirComputePa = " << DirComputePa );
2400 // D. Les donnees de l'adaptation HOMARD
2401 // D.1. Le type de conformite
2402 int ConfType = myCase->GetConfType();
2403 MESSAGE ( ". ConfType = " << ConfType );
2405 // D.2. Le maillage de depart
2406 const char* NomMeshParent = myIterationParent->GetMeshName();
2407 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2408 const char* MeshFileParent = myIterationParent->GetMeshFile();
2409 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2411 // D.3. Le maillage associe a l'iteration
2412 const char* MeshFile = myIteration->GetMeshFile();
2413 MESSAGE ( ". MeshFile = " << MeshFile );
2414 FILE *file = fopen(MeshFile,"r");
2418 if (etatMenage == 0)
2420 SALOME::ExceptionStruct es;
2421 es.type = SALOME::BAD_PARAM;
2422 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2423 es.text = CORBA::string_dup(text.c_str());
2424 throw SALOME::SALOME_Exception(es);
2429 std::string commande = "rm -f " + std::string(MeshFile);
2430 codret = system(commande.c_str());
2433 SALOME::ExceptionStruct es;
2434 es.type = SALOME::BAD_PARAM;
2435 es.text = "The mesh file cannot be deleted.";
2436 throw SALOME::SALOME_Exception(es);
2442 // D.4. Les types de raffinement et de deraffinement
2443 // Les appels corba sont lourds, il vaut mieux les grouper
2444 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2445 ASSERT(ListTypes->length() == 3);
2446 int TypeAdap = (*ListTypes)[0];
2447 int TypeRaff = (*ListTypes)[1];
2448 int TypeDera = (*ListTypes)[2];
2450 // E. Texte du fichier de configuration
2451 // E.1. Incontournables du texte
2452 myDriver->TexteAdap();
2454 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2455 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2456 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2458 // E.2. Ajout des informations liees aux zones eventuelles
2459 if ( TypeAdap == 0 )
2460 { DriverTexteZone(myHypo, myDriver) ; }
2462 // E.3. Ajout des informations liees aux champs eventuels
2463 if ( TypeAdap == 1 )
2464 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2466 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2467 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2468 int numberOfGroups = listeGroupes->length();
2469 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2470 if (numberOfGroups > 0)
2472 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2474 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2475 MESSAGE( "... GroupName = " << GroupName );
2476 myDriver->TexteGroup(GroupName);
2480 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2481 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2483 // E.6. Ajout des options avancees
2484 int Pyram = myCase->GetPyram();
2485 MESSAGE ( ". Pyram = " << Pyram );
2486 int NivMax = myHypo->GetNivMax();
2487 MESSAGE ( ". NivMax = " << NivMax );
2488 double DiamMin = myHypo->GetDiamMin() ;
2489 MESSAGE ( ". DiamMin = " << DiamMin );
2490 int AdapInit = myHypo->GetAdapInit();
2491 MESSAGE ( ". AdapInit = " << AdapInit );
2492 int LevelOutput = myHypo->GetLevelOutput();
2493 MESSAGE ( ". LevelOutput = " << LevelOutput );
2494 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2496 // E.7. Ajout des informations sur le deroulement de l'execution
2497 int MessInfo = myIteration->GetInfoCompute();
2498 MESSAGE ( ". MessInfo = " << MessInfo );
2499 myDriver->TexteInfoCompute(MessInfo);
2503 //=============================================================================
2504 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2505 // nomrep : nom du repertoire parent
2506 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2507 //=============================================================================
2508 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2510 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2511 // On verifie que le repertoire parent existe
2512 int codret = chdir(nomrep) ;
2515 SALOME::ExceptionStruct es;
2516 es.type = SALOME::BAD_PARAM;
2517 es.text = "The directory of the case does not exist.";
2518 throw SALOME::SALOME_Exception(es);
2521 std::string nomDirActuel = getenv("PWD") ;
2522 std::string DirName ;
2523 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2524 bool a_chercher = true ;
2525 while ( a_chercher )
2527 // On passe dans le repertoire parent
2529 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2531 if ( num < 100 ) { jaux = 2 ; }
2532 else if ( num < 1000 ) { jaux = 3 ; }
2533 else if ( num < 10000 ) { jaux = 4 ; }
2534 else if ( num < 100000 ) { jaux = 5 ; }
2536 std::ostringstream iaux ;
2537 iaux << std::setw(jaux) << std::setfill('0') << num ;
2538 std::ostringstream DirNameA ;
2539 DirNameA << "I" << iaux.str();
2540 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2541 // que c'est bien un probleme d'absence
2542 if ( chdir(DirNameA.str().c_str()) != 0 )
2544 bool existe = false ;
2546 struct dirent *dirp;
2547 dp = opendir(nomrep);
2548 while ( (dirp = readdir(dp)) != NULL )
2550 std::string file_name(dirp->d_name);
2551 if ( file_name == DirNameA.str() ) { existe = true ; }
2556 DirName = DirNameA.str() ;
2557 a_chercher = false ;
2564 MESSAGE ( "==> DirName = " << DirName);
2565 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2566 chdir(nomDirActuel.c_str());
2568 return CORBA::string_dup( DirName.c_str() );
2570 //=============================================================================
2571 // Calcul d'une iteration : gestion du repertoire de calcul
2572 // Si le sous-repertoire existe :
2573 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2574 // etatMenage = 1 : on fait le menage du repertoire
2575 // etatMenage = -1 : on ne fait rien
2576 //=============================================================================
2577 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2579 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2580 // B.2. Le repertoire du cas
2581 const char* nomDirCase = myCase->GetDirName();
2582 MESSAGE ( ". nomDirCase = " << nomDirCase );
2584 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2585 // B.3.1. Le nom du sous-repertoire
2586 const char* nomDirIt = myIteration->GetDirNameLoc();
2588 // B.3.2. Le nom complet du sous-repertoire
2589 std::stringstream DirCompute ;
2590 DirCompute << nomDirCase << "/" << nomDirIt;
2591 MESSAGE (". DirCompute = " << DirCompute.str() );
2593 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2594 if (chdir(DirCompute.str().c_str()) != 0)
2596 // Creation du repertoire car il n'existe pas :
2597 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2599 // GERALD -- QMESSAGE BOX
2600 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2601 ASSERT("Pb a la creation du repertoire" == 0);
2606 // Le repertoire existe
2607 // On demande de faire le menage de son contenu :
2608 if (etatMenage == 1)
2610 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2611 std::string commande= "rm -rf " + DirCompute.str()+"/*" ;
2612 int codret = system(commande.c_str());
2615 // GERALD -- QMESSAGE BOX
2616 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2617 ASSERT("Pb au menage du repertoire de calcul" == 0);
2620 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2623 if (etatMenage == 0)
2626 struct dirent *dirp;
2627 dp = opendir(DirCompute.str().c_str());
2629 while ((dirp = readdir(dp)) != NULL && result )
2631 std::string file_name(dirp->d_name);
2632 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2635 if ( result == false)
2637 SALOME::ExceptionStruct es;
2638 es.type = SALOME::BAD_PARAM;
2639 std::string text = "Directory : " + DirCompute.str() + "is not empty";
2640 es.text = CORBA::string_dup(text.c_str());
2641 throw SALOME::SALOME_Exception(es);
2642 ASSERT("Directory is not empty" == 0);
2648 return CORBA::string_dup( DirCompute.str().c_str() );
2650 //=============================================================================
2651 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2652 //=============================================================================
2653 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2655 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2656 // Le repertoire du cas
2657 const char* nomDirCase = myCase->GetDirName();
2658 MESSAGE ( ". nomDirCase = " << nomDirCase );
2660 // Le sous-repertoire de l'iteration precedente
2662 const char* nomIterationParent = myIteration->GetIterParentName();
2663 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2664 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
2665 std::stringstream DirComputePa ;
2666 DirComputePa << nomDirCase << "/" << nomDirItPa;
2667 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2668 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2670 return CORBA::string_dup( DirComputePa.str().c_str() );
2672 //=============================================================================
2673 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2674 //=============================================================================
2675 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2677 MESSAGE ( "... DriverTexteZone" );
2678 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2679 int numberOfZonesx2 = ListZone->length();
2682 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2684 std::string ZoneName = std::string((*ListZone)[iaux]);
2685 MESSAGE ( "... ZoneName = " << ZoneName);
2686 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
2687 ASSERT(!CORBA::is_nil(myZone));
2689 int ZoneType = myZone->GetType();
2690 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
2691 int TypeUse = atoi( TypeUsestr.c_str() );
2692 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
2693 NumZone = iaux/2 + 1 ;
2694 HOMARD::double_array* zone = myZone->GetCoords();
2695 if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
2697 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.);
2699 else if ( ZoneType == 4 ) // Cas d une sphere
2701 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.);
2703 else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
2705 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.);
2707 else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
2709 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]);
2711 else { ASSERT("ZoneType est incorrect." == 0) ; }
2716 //=============================================================================
2717 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
2718 //=============================================================================
2719 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2721 MESSAGE ( "... DriverTexteField" );
2722 // Le fichier du champ
2723 char* FieldFile = myIteration->GetFieldFile();
2724 MESSAGE ( ". FieldFile = " << FieldFile );
2725 if (strlen(FieldFile) == 0)
2727 // GERALD -- QMESSAGE BOX
2728 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2729 ASSERT("The file for the field is not given." == 0);
2731 // Les caracteristiques d'instants
2732 int TimeStep = myIteration->GetTimeStep();
2733 MESSAGE( ". TimeStep = " << TimeStep );
2734 int Rank = myIteration->GetRank();
2735 MESSAGE( ". Rank = " << Rank );
2736 // Les informations sur les champ
2737 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
2739 const char* FieldName = aInfosHypo->FieldName;
2741 int TypeThR = aInfosHypo->TypeThR;
2742 double ThreshR = aInfosHypo->ThreshR;
2743 int TypeThC = aInfosHypo->TypeThC;
2744 double ThreshC = aInfosHypo->ThreshC;
2745 // Saut entre mailles ou non ?
2746 int UsField = aInfosHypo->UsField;
2747 MESSAGE( ". UsField = " << UsField );
2748 // L'usage des composantes
2749 int UsCmpI = aInfosHypo->UsCmpI;
2750 MESSAGE( ". UsCmpI = " << UsCmpI );
2752 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
2755 HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp();
2756 int numberOfCompos = mescompo->length();
2757 MESSAGE( ". numberOfCompos = " << numberOfCompos );
2758 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
2760 std::string nomCompo = std::string((*mescompo)[NumeComp]);
2761 MESSAGE( "... nomCompo = " << nomCompo );
2762 myDriver->TexteCompo(NumeComp, nomCompo);
2766 //=============================================================================
2767 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
2768 //=============================================================================
2769 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
2771 MESSAGE ( "... DriverTexteBoundary" );
2772 // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
2773 std::list<std::string> ListeBoundaryTraitees ;
2774 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
2775 int numberOfitems = ListBoundaryGroupType->length();
2776 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
2777 int BoundaryOption = 1 ;
2778 int NumBoundaryAnalytical = 0 ;
2779 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2781 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2782 MESSAGE ( "... BoundaryName = " << BoundaryName);
2784 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
2785 while (it != ListeBoundaryTraitees.end())
2787 MESSAGE ( "... BoundaryNameTraitee = " << *it);
2788 if ( BoundaryName == *it ) { A_faire = 0 ; }
2793 // Caracteristiques de la frontiere
2794 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2795 ASSERT(!CORBA::is_nil(myBoundary));
2796 int BoundaryType = myBoundary->GetType();
2797 MESSAGE ( "... BoundaryType = " << BoundaryType );
2798 // Ecriture selon le type
2799 if (BoundaryType == 0) // Cas d une frontiere discrete
2801 const char* MeshName = myBoundary->GetMeshName() ;
2802 const char* MeshFile = myBoundary->GetMeshFile() ;
2803 myDriver->TexteBoundaryDi( MeshName, MeshFile);
2804 BoundaryOption = BoundaryOption*2 ;
2806 else // Cas d une frontiere analytique
2808 NumBoundaryAnalytical++ ;
2809 HOMARD::double_array* coor = myBoundary->GetCoords();
2810 if (BoundaryType == 1) // Cas d un cylindre
2812 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2813 BoundaryOption = BoundaryOption*3 ;
2815 else if (BoundaryType == 2) // Cas d une sphere
2817 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
2818 BoundaryOption = BoundaryOption*3 ;
2820 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
2822 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2823 BoundaryOption = BoundaryOption*3 ;
2825 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
2827 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
2828 BoundaryOption = BoundaryOption*3 ;
2831 // Memorisation du traitement
2832 ListeBoundaryTraitees.push_back( BoundaryName );
2835 NumBoundaryAnalytical = 0 ;
2836 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2838 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2839 MESSAGE ( "... BoundaryName = " << BoundaryName);
2840 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2841 ASSERT(!CORBA::is_nil(myBoundary));
2842 int BoundaryType = myBoundary->GetType();
2843 MESSAGE ( "... BoundaryType = " << BoundaryType );
2844 // Recuperation du nom du groupe
2845 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
2846 MESSAGE ( "... GroupName = " << GroupName);
2847 if (BoundaryType == 0) // Cas d une frontiere discrete
2849 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
2851 else // Cas d une frontiere analytique
2853 NumBoundaryAnalytical++ ;
2854 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
2857 myDriver->TexteBoundaryOption(BoundaryOption);
2860 //=============================================================================
2861 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
2862 //=============================================================================
2863 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2865 MESSAGE ( "... DriverTexteFieldInterp" );
2866 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
2867 if (TypeFieldInterp != 0)
2869 // Le fichier des champs
2870 char* FieldFile = myIteration->GetFieldFile();
2871 MESSAGE ( ". FieldFile = " << FieldFile );
2872 if (strlen(FieldFile) == 0)
2874 // GERALD -- QMESSAGE BOX
2875 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2876 ASSERT("The file for the field is not given." == 0);
2878 // Les caracteristiques d'instants
2879 int TimeStep = myIteration->GetTimeStep();
2880 MESSAGE( ". TimeStep = " << TimeStep );
2881 int Rank = myIteration->GetRank();
2882 MESSAGE( ". Rank = " << Rank );
2884 const char* MeshFile = myIteration->GetMeshFile();
2885 myDriver->TexteFieldInterp(TypeFieldInterp, FieldFile, MeshFile, TimeStep, Rank);
2887 if (TypeFieldInterp == 2)
2889 HOMARD::listFieldInterpHypo* meschamps = myHypo->GetListFieldInterp();
2890 int numberOfFields = meschamps->length();
2891 MESSAGE( ". numberOfFields = " << numberOfFields );
2892 for (int NumeChamp = 0; NumeChamp< numberOfFields; NumeChamp++)
2894 std::string nomChamp = std::string((*meschamps)[NumeChamp]);
2895 MESSAGE( "... nomChamp = " << nomChamp );
2896 myDriver->TexteFieldInterpName(NumeChamp, nomChamp);
2902 //===========================================================================
2903 //===========================================================================
2906 //===========================================================================
2907 //===========================================================================
2909 //===========================================================================
2910 //===========================================================================
2911 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
2912 SALOMEDS::SObject_ptr theSObject,
2913 CORBA::Object_ptr theObject,
2914 const char* theName)
2916 MESSAGE("PublishInStudy pour " << theName);
2917 SALOMEDS::SObject_var aResultSO;
2918 if (CORBA::is_nil(theStudy))
2920 SALOME::ExceptionStruct es;
2921 es.type = SALOME::BAD_PARAM;
2922 es.text = "Invalid study context";
2923 throw SALOME::SALOME_Exception(es);
2927 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
2928 // Rq : Iteration est publiee ailleurs
2929 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
2930 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
2931 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
2932 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
2934 addInStudy(theStudy);
2936 // Controle de la non publication d'un objet de meme nom
2937 if ((!aHypo->_is_nil()) or (!aZone->_is_nil()) or (!aBoundary->_is_nil()))
2939 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
2940 if (listSO->length() >= 1)
2942 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
2943 std::cerr <<"This name "<<theName<<" is already used "<<listSO->length()<<" time(s)" << std::endl;
2944 aResultSO = listSO[0];
2945 return aResultSO._retn();
2949 // Caracteristiques de l'etude
2950 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
2951 aStudyBuilder->NewCommand();
2952 if(!aCase->_is_nil())
2953 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
2954 else if(!aHypo->_is_nil())
2955 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
2956 else if(!aZone->_is_nil())
2957 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
2958 else if(!aBoundary->_is_nil())
2959 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
2961 aStudyBuilder->CommitCommand();
2962 return aResultSO._retn();
2964 //=============================================================================
2965 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
2966 SALOMEDS::StudyBuilder_var aStudyBuilder,
2967 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
2969 MESSAGE("PublishCaseInStudy pour "<<theName);
2970 SALOMEDS::SObject_var aResultSO;
2971 SALOMEDS::GenericAttribute_var anAttr;
2973 if (CORBA::is_nil(theObject)) {
2974 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
2975 return aResultSO._retn();
2977 if (theStudy->_is_nil()) {
2978 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
2979 return aResultSO._retn();
2982 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
2983 if (theFatherHomard->_is_nil())
2985 MESSAGE("theFatherHomard->_is_nil()");
2986 return aResultSO._retn();
2989 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
2990 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
2991 _orb->object_to_string(theObject) ) ;
2992 return aResultSO._retn();
2995 //=============================================================================
2996 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
2997 SALOMEDS::StudyBuilder_var aStudyBuilder,
2998 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3000 MESSAGE("PublishZoneStudy pour "<<theName);
3001 SALOMEDS::SObject_var aResultSO;
3002 SALOMEDS::GenericAttribute_var anAttr;
3004 if (CORBA::is_nil(theObject))
3006 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3007 return aResultSO._retn();
3009 if (theStudy->_is_nil())
3011 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
3012 return aResultSO._retn();
3014 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3015 if (theFatherHomard->_is_nil())
3017 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3018 return aResultSO._retn();
3021 // Caracteristique de la zone
3022 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3023 CORBA::Long ZoneType = myZone->GetType();
3025 // On ajoute la categorie des zones dans l etude si necessaire
3026 SALOMEDS::SObject_var aSOZone;
3027 if (!theFatherHomard->FindSubObject(100, aSOZone))
3029 MESSAGE("Ajout de la categorie des zones");
3030 aSOZone = aStudyBuilder->NewObjectToTag(theFatherHomard, 100);
3031 PublishInStudyAttr(aStudyBuilder, aSOZone, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3033 else { MESSAGE("La categorie des zones existe deja."); }
3035 aResultSO = aStudyBuilder->NewObject(aSOZone);
3044 { icone = "boxdxy_2.png" ;
3048 { icone = "boxdxyz_2.png" ;
3056 { icone = "disk_2.png" ;
3060 { icone = "spherepoint_2.png" ;
3064 { icone = "cylinderpointvector_2.png" ;
3072 { icone = "diskwithhole_2.png" ;
3076 { icone = "pipe_2.png" ;
3080 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3082 return aResultSO._retn();
3084 //=============================================================================
3085 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3086 SALOMEDS::StudyBuilder_var aStudyBuilder,
3087 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3089 MESSAGE("PublishBoundaryStudy pour "<<theName);
3090 SALOMEDS::SObject_var aResultSO;
3091 SALOMEDS::GenericAttribute_var anAttr;
3093 // Caracteristique de la Boundary
3094 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3096 // On recupere le module pere dans l etude
3097 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3098 if (theFatherHomard->_is_nil())
3100 MESSAGE("theFatherHomard->_is_nil()");
3101 return aResultSO._retn();
3104 // On ajoute la categorie des boundarys dans l etude si necessaire
3105 SALOMEDS::SObject_var aSOBoundary;
3106 if (!theFatherHomard->FindSubObject(101, aSOBoundary))
3108 MESSAGE("Ajout de la categorie des boundarys");
3109 aSOBoundary = aStudyBuilder->NewObjectToTag(theFatherHomard, 101);
3110 PublishInStudyAttr(aStudyBuilder, aSOBoundary, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3112 else { MESSAGE("La categorie des boundarys existe deja."); }
3114 aResultSO = aStudyBuilder->NewObject(aSOBoundary);
3115 CORBA::Long BoundaryType = myBoundary->GetType();
3116 // MESSAGE("BoundaryType : "<<BoundaryType);
3119 switch (BoundaryType)
3122 { value = "BoundaryDiHomard" ;
3123 icone = "mesh_tree_mesh.png" ;
3127 { value = "BoundaryAnHomard" ;
3128 icone = "cylinderpointvector_2.png" ;
3132 { value = "BoundaryAnHomard" ;
3133 icone = "spherepoint_2.png" ;
3137 { value = "BoundaryAnHomard" ;
3138 icone = "conepointvector.png" ;
3142 { value = "BoundaryAnHomard" ;
3143 icone = "conedxyz.png" ;
3147 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3148 return aResultSO._retn();
3151 //=============================================================================
3152 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3153 SALOMEDS::StudyBuilder_var aStudyBuilder,
3154 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3156 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3157 SALOMEDS::SObject_var aResultSO;
3158 SALOMEDS::GenericAttribute_var anAttr;
3160 // On recupere le module pere dans l etude
3161 // On ajoute la categorie des hypotheses dans l etude si necessaire
3162 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3163 if (theFatherHomard->_is_nil())
3165 MESSAGE("theFatherHomard->_is_nil()");
3166 return aResultSO._retn();
3168 SALOMEDS::SObject_var aSOHypothese;
3169 if (!theFatherHomard->FindSubObject(0, aSOHypothese))
3171 MESSAGE("Ajout de la categorie des hypotheses");
3172 aSOHypothese = aStudyBuilder->NewObjectToTag(theFatherHomard, 0);
3173 PublishInStudyAttr(aStudyBuilder, aSOHypothese, "Hypothesis", "HypoList","hypotheses.png", NULL);
3175 else { MESSAGE("La categorie des hypotheses existe deja."); }
3177 // Creation du resultat dans l'etude
3178 aResultSO = aStudyBuilder->NewObject(aSOHypothese);
3179 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3181 return aResultSO._retn();
3183 //===========================================================================
3184 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3185 SALOMEDS::SObject_var aResultSO,
3186 const char* name, const char* value, const char* icone, const char* ior)
3188 SALOMEDS::GenericAttribute_var anAttr ;
3192 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3193 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3194 aNameAttrib->SetValue(name);
3197 // Ajout du commentaire
3198 if ( value != NULL )
3200 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3201 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3202 aCommentAttrib->SetValue(value);
3206 if ( icone != NULL )
3208 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO,"AttributePixMap");
3209 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3210 aPixmap->SetPixMap(icone);
3216 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3217 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3218 anIOR->SetValue(ior);
3222 //=====================================================================================
3223 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3225 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3227 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3228 ASSERT(!CORBA::is_nil(myCase));
3229 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3230 ASSERT(!CORBA::is_nil(aCaseSO));
3232 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3233 ASSERT(!CORBA::is_nil(myBoundary));
3234 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3235 ASSERT(!CORBA::is_nil(aBoundarySO));
3237 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3239 aStudyBuilder->NewCommand();
3241 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3242 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3244 aStudyBuilder->CommitCommand();
3247 //=============================================================================
3248 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3249 // Option = 0 : fichier issu d'une importation
3250 // Option = 1 : fichier issu d'une execution HOMARD
3252 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3253 if (CORBA::is_nil(myCurrentStudy))
3255 SALOME::ExceptionStruct es;
3256 es.type = SALOME::BAD_PARAM;
3257 es.text = "Invalid study context";
3258 throw SALOME::SALOME_Exception(es);
3262 // Le module SMESH est-il actif ?
3263 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3265 if (!CORBA::is_nil(aSmeshSO))
3267 // On verifie que le fichier n est pas deja publie
3268 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3269 for (; aIter->More(); aIter->Next())
3271 SALOMEDS::SObject_var aSO = aIter->Value();
3272 SALOMEDS::GenericAttribute_var aGAttr;
3273 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3275 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3276 CORBA::String_var value=anAttr->Value();
3277 if (strcmp((const char*)value,NomFich) == 0)
3279 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3280 // Pour un fichier importe, on ne republie pas
3285 // Pour un fichier calcule, on commence par faire la depublication
3288 MESSAGE ( "PublishResultInSmesh : depublication" );
3289 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3290 CORBA::String_var value2=anAttr2->Value();
3291 const char* MeshName = value2 ;
3292 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3293 DeleteResultInSmesh(NomFich, MeshName) ;
3300 // On enregistre le fichier
3301 MESSAGE( "Enregistrement du fichier");
3302 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3303 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3304 ASSERT(!CORBA::is_nil(aSmeshEngine));
3305 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3306 SMESH::DriverMED_ReadStatus theStatus;
3307 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3309 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3310 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3311 for (int i = 0; i < mesMaillages->length(); i++)
3313 MESSAGE( ". Mise a jour des attributs du maillage");
3314 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3315 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3316 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3317 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3318 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3319 anAttr->SetValue(NomFich);
3320 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3321 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3323 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3324 else { icone = "mesh_tree_mesh.png" ; }
3325 anAttr2->SetPixMap( icone );
3329 //=============================================================================
3330 void HOMARD_Gen_i::DeleteResultInSmesh(const char* NomFich, const char* MeshName)
3332 MESSAGE (" DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3333 if (CORBA::is_nil(myCurrentStudy))
3335 SALOME::ExceptionStruct es;
3336 es.type = SALOME::BAD_PARAM;
3337 es.text = "Invalid study context";
3338 throw SALOME::SALOME_Exception(es);
3342 // Le module SMESH est-il actif ?
3343 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3345 if (CORBA::is_nil(aSmeshSO))
3349 // On verifie que le fichier est deja publie
3350 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3351 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3352 for (; aIter->More(); aIter->Next())
3354 SALOMEDS::SObject_var aSO = aIter->Value();
3355 SALOMEDS::GenericAttribute_var aGAttr;
3356 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3358 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3359 CORBA::String_var value=anAttr->Value();
3360 if (strcmp((const char*)value,NomFich) == 0)
3362 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3364 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3365 CORBA::String_var value2=anAttr2->Value();
3366 if (strcmp((const char*)value2,MeshName) == 0)
3368 myBuilder->RemoveObjectWithChildren( aSO ) ;
3376 //=============================================================================
3377 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3379 // MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3380 if (CORBA::is_nil(myCurrentStudy))
3382 SALOME::ExceptionStruct es;
3383 es.type = SALOME::BAD_PARAM;
3384 es.text = "Invalid study context";
3385 throw SALOME::SALOME_Exception(es);
3389 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3390 if (CORBA::is_nil(myIteration))
3392 SALOME::ExceptionStruct es;
3393 es.type = SALOME::BAD_PARAM;
3394 es.text = "Invalid iteration";
3395 throw SALOME::SALOME_Exception(es);
3398 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3399 if (CORBA::is_nil(myIteration))
3401 SALOME::ExceptionStruct es;
3402 es.type = SALOME::BAD_PARAM;
3403 es.text = "Invalid iterationStudy Object";
3404 throw SALOME::SALOME_Exception(es);
3408 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3410 aStudyBuilder->NewCommand();
3412 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3413 // Pour les fichiers med, on affiche une icone de maillage
3414 // Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte'
3415 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3417 std::string ior = " " ;
3418 if ( Commentaire[0] == 'I' )
3419 { icone = "med.png" ; }
3421 { icone = "texte_2.png" ; }
3422 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3424 aStudyBuilder->CommitCommand();
3426 //=============================================================================
3427 //=============================================================================
3429 //=============================================================================
3430 //=============================================================================
3431 // Next functions are inherited from SALOMEDS::Driver interface
3432 //=============================================================================
3433 //=============================================================================
3434 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
3436 CORBA::Boolean isMultiFile)
3438 MESSAGE (" Save for theURL = "<< theURL);
3439 SALOMEDS::TMPFile_var aStreamFile;
3441 // get temporary directory name
3442 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3444 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3445 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3447 // HOMARD data file name
3448 std::string aFileName = "";
3450 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3451 aFileName += "_HOMARD.dat";
3453 // initialize sequence of file names
3454 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
3455 aFileSeq->length(1);
3456 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
3458 // get full path to the data file
3459 aFileName = tmpDir + aFileName;
3463 std::ofstream f(aFileName.c_str());
3465 // clear temporary id map
3466 context._idmap.clear();
3471 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
3472 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
3473 HOMARD::HOMARD_Cas_var aCas = it_case->second;
3474 PortableServer::ServantBase_var aServant = GetServant(aCas);
3475 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3477 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
3478 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
3482 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3483 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
3484 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
3485 PortableServer::ServantBase_var aServant = GetServant(aZone);
3486 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3488 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
3489 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3492 // -> save hypotheses
3493 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3494 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
3495 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
3496 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3497 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3499 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
3500 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3503 // -> save iterations
3504 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3505 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
3506 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
3507 PortableServer::ServantBase_var aServant = GetServant(aIter);
3508 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3510 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
3511 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3514 // -> save boundaries
3515 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3516 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
3517 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
3518 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3519 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3520 if (aBoundaryServant) {
3521 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
3522 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3526 MESSAGE ("close file");
3529 // put temporary files to the stream
3530 MESSAGE ("put temporary files to the stream");
3531 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
3533 // remove temporary files
3534 MESSAGE ("remove temporary files");
3535 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3537 // return data stream
3538 MESSAGE ("return data stream");
3539 return aStreamFile._retn();
3542 //===========================================================================
3543 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
3545 CORBA::Boolean isMultiFile)
3547 // No specific ASCII persistence
3548 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
3549 return aStreamFile._retn();
3552 //===========================================================================
3553 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
3554 const SALOMEDS::TMPFile& theStream,
3556 CORBA::Boolean isMultiFile)
3558 MESSAGE (" Load pour theURL = "<< theURL);
3559 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3561 // set current study
3562 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
3563 SetCurrentStudy(aStudy);
3565 // get temporary directory name
3566 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3568 // Convert the stream into sequence of files to process
3569 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
3572 // HOMARD data file name
3573 std::string aFileName = "";
3575 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3576 aFileName = tmpDir + aFileName + "_HOMARD.dat";
3578 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3582 std::ifstream f(aFileName.c_str());
3585 context._mesCas.clear();
3586 context._mesHypotheses.clear();
3587 context._mesIterations.clear();
3588 context._mesZones.clear();
3589 context._mesBoundarys.clear();
3590 context._idmap.clear();
3596 std::getline(f, line);
3597 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
3598 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
3599 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
3600 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
3601 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
3602 if (line.substr(0, caseSignature.size()) == caseSignature) {
3604 MESSAGE (" Recreation du cas" );
3605 HOMARD::HOMARD_Cas_var aCase = newCase();
3606 PortableServer::ServantBase_var aServant = GetServant(aCase);
3607 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3608 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
3609 context._mesCas[aCase->GetName()] = aCase;
3610 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
3613 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
3614 MESSAGE (" Recreation de la zone" );
3616 HOMARD::HOMARD_Zone_var aZone = newZone();
3617 PortableServer::ServantBase_var aServant = GetServant(aZone);
3618 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3619 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
3620 context._mesZones[aZone->GetName()] = aZone;
3621 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3624 else if (line.substr(0, iterSignature.size()) == iterSignature) {
3625 // re-create iteration
3626 MESSAGE (" Recreation de l iteration" );
3627 HOMARD::HOMARD_Iteration_var aIter = newIteration();
3628 PortableServer::ServantBase_var aServant = GetServant(aIter);
3629 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3630 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
3631 context._mesIterations[aIter->GetName()] = aIter;
3632 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3635 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
3636 // re-create hypothesis
3637 MESSAGE (" Recreation de l hypothese" );
3638 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
3639 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3640 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3641 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
3642 context._mesHypotheses[aHypo->GetName()] = aHypo;
3643 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3646 else if (line.substr(0, bounSignature.size()) == bounSignature) {
3647 // re-create boundary
3648 MESSAGE (" Recreation de la frontiere" );
3649 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
3650 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3651 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3652 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
3653 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
3654 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3663 // Remove temporary files created from the stream
3665 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3670 //===========================================================================
3671 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
3672 const SALOMEDS::TMPFile& theStream,
3674 CORBA::Boolean isMultiFile)
3676 // No specific ASCII persistence
3677 return Load(theComponent, theStream, theURL, isMultiFile);
3680 //===========================================================================
3681 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
3683 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
3684 // clearing study context should be done here:
3685 // - destroy all servants and related CORBA objects
3687 // - remove context from myContextMap
3688 myContextMap.erase(theComponent->GetStudy()->StudyId());
3689 // - nullify myCurrentStudy
3690 myCurrentStudy = SALOMEDS::Study::_nil();
3694 //===========================================================================
3695 char* HOMARD_Gen_i::ComponentDataType()
3697 return CORBA::string_dup("HOMARD");
3700 //===========================================================================
3701 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
3702 const char* IORString,
3703 CORBA::Boolean isMultiFile,
3704 CORBA::Boolean isASCII)
3706 CORBA::String_var aString("");
3707 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
3708 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3709 CORBA::Object_var anObj = _orb->string_to_object(IORString);
3710 if (!CORBA::is_nil(anObj)) {
3711 PortableServer::ServantBase_var aServant = GetServant(anObj);
3712 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
3714 std::map<int, PortableServer::ServantBase*>::const_iterator it;
3715 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
3716 if (it->second == aStorable) {
3717 std::stringstream os;
3719 aString = CORBA::string_dup(os.str().c_str());
3725 return aString._retn();
3728 //===========================================================================
3729 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
3730 const char* aLocalPersistentID,
3731 CORBA::Boolean isMultiFile,
3732 CORBA::Boolean isASCII)
3734 CORBA::String_var aString("");
3735 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
3736 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3737 int id = atoi(aLocalPersistentID);
3738 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
3739 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
3740 if (!CORBA::is_nil(object)) {
3741 aString = _orb->object_to_string(object);
3745 return aString._retn();
3748 //===========================================================================
3749 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
3751 if(CORBA::is_nil(myCurrentStudy))
3754 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
3755 if(!aCas->_is_nil())
3758 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
3759 if(!aHypo->_is_nil())
3762 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
3763 if(!aZone->_is_nil())
3766 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
3767 if(!aBoundary->_is_nil())
3770 /* Iteration is not published directly
3771 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
3772 if(!aIter->_is_nil())
3778 //===========================================================================
3779 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
3781 // No Copy/Paste support
3785 //===========================================================================
3786 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
3787 CORBA::Long& theObjectID)
3789 // No Copy/Paste support
3790 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
3791 return aStreamFile._retn();
3794 //===========================================================================
3795 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
3796 CORBA::Long theObjectID)
3798 // No Copy/Paste support
3802 //===========================================================================
3803 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
3804 CORBA::Long theObjectID,
3805 SALOMEDS::SObject_ptr theSObject)
3807 // No Copy/Paste support
3808 SALOMEDS::SObject_var aResultSO;
3809 return aResultSO._retn();
3812 //===========================================================================
3813 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
3815 PortableServer::Servant aServant = 0;
3816 if (!CORBA::is_nil(theObject)) {
3818 aServant = _poa->reference_to_servant(theObject);
3826 //==========================================================================
3827 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
3828 CORBA::Boolean isPublished,
3829 CORBA::Boolean isMultiFile,
3830 CORBA::Boolean& isValidScript)
3832 MESSAGE ("Entree dans DumpPython");
3834 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
3835 if(CORBA::is_nil(aStudy))
3836 return new Engines::TMPFile(0);
3838 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
3839 if(CORBA::is_nil(aSO))
3840 return new Engines::TMPFile(0);
3842 std::string aScript = "\"\"\"\n";
3843 aScript += "Python script for HOMARD\n";
3844 aScript += "Copyright EDF-R&D 2013\n";
3845 aScript += "\"\"\"\n";
3846 aScript += "__revision__ = \"V1.2\"\n";
3847 aScript += "import HOMARD\n";
3849 aScript += "import salome\n";
3850 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
3852 aScript += "def RebuildData(theStudy):\n";
3853 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
3856 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
3857 MESSAGE (". Au depart \n"<<aScript);
3860 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
3862 MESSAGE (". Ecritures des frontieres");
3863 aScript += "#\n# Creation of the boundaries";
3864 aScript += "\n# ==========================";
3866 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3867 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
3868 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
3870 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
3871 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
3872 std::string dumpBoundary = dumpCorbaBoundary.in();
3873 MESSAGE (dumpBoundary<<"\n");
3874 aScript += dumpBoundary;
3878 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
3880 MESSAGE (". Ecritures des zones");
3881 aScript += "#\n# Creation of the zones";
3882 aScript += "\n# =====================";
3884 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3885 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
3886 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
3888 HOMARD::HOMARD_Zone_var maZone = (*it_zone).second;
3889 CORBA::String_var dumpCorbaZone = maZone->GetDumpPython();
3890 std::string dumpZone = dumpCorbaZone.in();
3891 MESSAGE (dumpZone<<"\n");
3892 aScript += dumpZone;
3896 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
3898 MESSAGE (". Ecritures des hypotheses");
3899 aScript += "#\n# Creation of the hypotheses";
3900 aScript += "\n# ==========================";
3902 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3903 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
3904 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
3906 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
3907 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
3908 std::string dumpHypo = dumpCorbaHypo.in();
3909 MESSAGE (dumpHypo<<"\n");
3910 aScript += dumpHypo;
3914 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
3916 MESSAGE (". Ecritures des cas");
3917 aScript += "#\n# Creation of the cases";
3918 aScript += "\n# =====================";
3920 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
3921 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
3922 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
3924 std::string nomCas = (*it_cas).first;
3925 std::string dumpCas = std::string("\n# Creation of the case ") ;
3926 dumpCas += nomCas + std::string("\n");
3927 dumpCas += std::string("\t") + nomCas;
3928 dumpCas += std::string(" = homard.CreateCase('") + nomCas + std::string("', '");
3930 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
3931 CORBA::String_var cIter0= myCase->GetIter0Name();
3932 std::string iter0 = cIter0.in();
3934 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
3935 CORBA::String_var cMesh0= myIteration->GetMeshFile();
3936 std::string mesh0 = cMesh0.in();
3937 CORBA::String_var cMeshName0= myIteration->GetMeshName();
3938 std::string meshName0 = cMeshName0.in();
3939 dumpCas += meshName0 + std::string("', '")+ mesh0 + std::string("')\n");
3940 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
3941 std::string dumpCas2= dumpCorbaCase.in();
3943 MESSAGE (dumpCas<<dumpCas2<<"\n");
3944 aScript += dumpCas + dumpCas2;
3948 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
3950 MESSAGE (". Ecritures des iterations");
3951 aScript += "#\n# Creation of the iterations" ;
3952 aScript += "\n# ==========================";
3954 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3955 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
3956 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
3958 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
3959 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
3960 std::string dumpIter = dumpCorbaIter.in();
3961 MESSAGE (dumpIter<<"\n");
3962 aScript += dumpIter;
3965 MESSAGE (". Ecritures finales");
3967 aScript += "\n\tpass";
3970 if( !isMultiFile ) // remove unnecessary tabulation
3971 aScript = RemoveTabulation( aScript );
3973 // MESSAGE ("A ecrire \n"<<aScript);
3974 const size_t aLen = strlen(aScript.c_str());
3975 char* aBuffer = new char[aLen+1];
3976 strcpy(aBuffer, aScript.c_str());
3978 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
3979 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
3981 MESSAGE ("Sortie de DumpPython");
3982 return aStreamFile._retn();
3986 //=============================================================================
3987 //=============================================================================
3989 //=============================================================================
3990 //=============================================================================
3991 void HOMARD_Gen_i::IsValidStudy( )
3993 // MESSAGE( "IsValidStudy" );
3994 if (CORBA::is_nil(myCurrentStudy))
3996 SALOME::ExceptionStruct es;
3997 es.type = SALOME::BAD_PARAM;
3998 es.text = "Invalid study context";
3999 throw SALOME::SALOME_Exception(es);
4004 //=============================================================================
4005 CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir)
4007 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4008 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4009 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
4011 if (std::string(nomDir) == std::string(it->second->GetDirName())) return false;
4015 /*//=============================================================================
4016 void SALOMEException( std::string message )
4018 SALOME::ExceptionStruct es;
4019 es.type = SALOME::BAD_PARAM;
4021 throw SALOME::SALOME_Exception(es);
4024 //=============================================================================
4025 char* HOMARD_Gen_i::getVersion()
4027 #if HOMARD_DEVELOPMENT
4028 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4030 return CORBA::string_dup(HOMARD_VERSION_STR);
4034 //=============================================================================
4037 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
4038 PortableServer::POA_ptr poa,
4039 PortableServer::ObjectId* contId,
4040 const char* instanceName,
4041 const char* interfaceName)
4043 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
4044 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
4045 return myHOMARD_Gen->getId();