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 "HOMARD_YACS_i.hxx"
27 #include "HomardDriver.hxx"
28 #include "HOMARD_DriverTools.hxx"
29 #include "HomardMedCommun.h"
30 #include "YACSDriver.hxx"
32 #include "HOMARD_version.h"
34 #include "utilities.h"
35 #include "Utils_SINGLETON.hxx"
36 #include "Utils_CorbaException.hxx"
37 #include "SALOMEDS_Tool.hxx"
38 #include "SALOME_LifeCycleCORBA.hxx"
39 #include "SALOMEconfig.h"
40 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
41 #include CORBA_CLIENT_HEADER(SMESH_Gen)
58 //=============================================================================
60 //=============================================================================
61 std::string RemoveTabulation( std::string theScript )
63 std::string::size_type aPos = 0;
64 while( aPos < theScript.length() )
66 aPos = theScript.find( "\n\t", aPos );
67 if( aPos == std::string::npos )
69 theScript.replace( aPos, 2, "\n" );
74 //=============================================================================
76 * standard constructor
78 //=============================================================================
79 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
80 PortableServer::POA_ptr poa,
81 PortableServer::ObjectId * contId,
82 const char *instanceName,
83 const char *interfaceName) :
84 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
86 MESSAGE("constructor");
88 _id = _poa->activate_object(_thisObj);
90 myHomard = new ::HOMARD_Gen();
91 _NS = SINGLETON_<SALOME_NamingService>::Instance();
92 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
101 //=================================
103 * standard destructor
105 //================================
106 HOMARD_Gen_i::~HOMARD_Gen_i()
109 //=============================================================================
110 //=============================================================================
111 // Utilitaires pour l'étude
112 //=============================================================================
113 //=============================================================================
114 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
116 ASSERT(!CORBA::is_nil(theStudy));
117 MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
118 SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
120 // Create SComponent labelled 'homard' if it doesn't already exit
121 SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
122 if (CORBA::is_nil(homardFather))
124 myBuilder->NewCommand();
125 MESSAGE("Add Component HOMARD");
127 bool aLocked = theStudy->GetProperties()->IsLocked();
128 if (aLocked) theStudy->GetProperties()->SetLocked(false);
130 homardFather = myBuilder->NewComponent(ComponentDataType());
131 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
132 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
133 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
134 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
135 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
136 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
137 if (!Comp->_is_nil())
139 aName->SetValue(ComponentDataType());
142 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
143 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
144 aPixmap->SetPixMap("HOMARD_2.png");
145 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
147 if (aLocked) theStudy->GetProperties()->SetLocked(true);
148 myBuilder->CommitCommand();
151 //=============================================================================
152 void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
154 MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID());
155 myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy);
156 this->addInStudy(myCurrentStudy);
158 //=============================================================================
159 SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
160 //=============================================================================
162 MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID());
163 return SALOMEDS::Study::_duplicate(myCurrentStudy);
165 //=============================================================================
166 CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
167 //=============================================================================
169 return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
171 //=============================================================================
172 //=============================================================================
174 //=============================================================================
175 //=============================================================================
176 // Utilitaires pour l'iteration
177 //=============================================================================
178 //=============================================================================
179 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
180 //=====================================================================================
182 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
183 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
184 if (CORBA::is_nil(myIteration))
186 SALOME::ExceptionStruct es;
187 es.type = SALOME::BAD_PARAM;
188 es.text = "Invalid iteration";
189 throw SALOME::SALOME_Exception(es);
193 myIteration->SetState(Etat);
195 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
196 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
200 icone = "iter0.png" ;
201 else if ( Etat == 2 )
202 icone = "iter_calculee.png" ;
204 icone = "iter_non_calculee.png" ;
205 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ;
207 aStudyBuilder->CommitCommand();
210 //=============================================================================
211 //=============================================================================
213 //=============================================================================
214 //=============================================================================
215 // Destruction des structures identifiees par leurs noms
216 //=============================================================================
217 //=============================================================================
218 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
220 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
221 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
222 if (CORBA::is_nil(myBoundary))
224 SALOME::ExceptionStruct es;
225 es.type = SALOME::BAD_PARAM;
226 es.text = "Invalid boundary";
227 throw SALOME::SALOME_Exception(es);
231 // On verifie que la frontiere n'est plus utilisee
232 HOMARD::listeCases* maListe = GetAllCasesName();
233 int numberOfCases = maListe->length();
234 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
235 std::string CaseName ;
236 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
238 HOMARD::HOMARD_Cas_var myCase ;
239 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
241 CaseName = std::string((*maListe)[NumeCas]);
242 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
243 myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
244 ASSERT(!CORBA::is_nil(myCase));
245 ListBoundaryGroupType = myCase->GetBoundaryGroup();
246 numberOfitems = ListBoundaryGroupType->length();
247 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
248 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
250 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
252 SALOME::ExceptionStruct es;
253 es.type = SALOME::BAD_PARAM;
254 es.text = "This boundary is used in a case and cannot be deleted.";
255 throw SALOME::SALOME_Exception(es);
261 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
262 myContextMap[GetCurrentStudyID()]._mesBoundarys.erase(BoundaryName);
263 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(BoundaryName, ComponentDataType());
264 SALOMEDS::SObject_var aSO =listSO[0];
265 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
266 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
270 //=============================================================================
271 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option)
273 // Pour detruire un cas
274 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
275 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
276 if (CORBA::is_nil(myCase))
278 SALOME::ExceptionStruct es;
279 es.type = SALOME::BAD_PARAM;
280 es.text = "Invalid case context";
281 throw SALOME::SALOME_Exception(es);
284 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
285 CORBA::String_var nomIter = myCase->GetIter0Name();
286 CORBA::Long Option1 = 0 ;
287 if ( DeleteIterationOption(nomIter, Option1, Option) != 0 )
292 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
293 myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas);
294 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType());
295 SALOMEDS::SObject_var aSO =listSO[0];
296 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
297 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
301 //=============================================================================
302 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
304 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
305 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
306 if (CORBA::is_nil(myHypo))
308 SALOME::ExceptionStruct es;
309 es.type = SALOME::BAD_PARAM;
310 es.text = "Invalid hypothesis";
311 throw SALOME::SALOME_Exception(es);
315 // On verifie que l'hypothese n'est plus utilisee
316 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
317 int numberOfIter = maListeIter->length();
318 if ( numberOfIter > 0 )
320 SALOME::ExceptionStruct es;
321 es.type = SALOME::BAD_PARAM;
322 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
323 throw SALOME::SALOME_Exception(es);
327 // suppression du lien avec les zones eventuelles
328 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
329 int numberOfZones = maListe->length();
330 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
331 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
333 std::string ZoneName = std::string((*maListe)[NumeZone]);
334 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
335 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
339 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
340 myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo);
341 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType());
342 SALOMEDS::SObject_var aSO =listSO[0];
343 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
344 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
348 //=============================================================================
349 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
351 // Option = 0 : On ne supprime pas le fichier du maillage associe
352 // Option = 1 : On supprime le fichier du maillage associe
353 // Pour detruire une iteration courante
354 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
355 CORBA::Long Option1 = 1 ;
356 return DeleteIterationOption(nomIter, Option1, Option);
358 //=============================================================================
359 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
361 // Option1 = 0 : On autorise la destruction de l'iteration 0
362 // Option1 = 1 : On interdit la destruction de l'iteration 0
364 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
365 // Option2 = 1 : On supprime le fichier du maillage associe
366 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
367 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
368 if (CORBA::is_nil(myIteration))
370 SALOME::ExceptionStruct es;
371 es.type = SALOME::BAD_PARAM;
372 es.text = "Invalid iteration";
373 throw SALOME::SALOME_Exception(es);
377 int numero = myIteration->GetNumber();
378 MESSAGE ( "DeleteIterationOption : numero = " << numero );
379 if ( numero == 0 and Option1 == 1 )
381 SALOME::ExceptionStruct es;
382 es.type = SALOME::BAD_PARAM;
383 es.text = "This iteration cannot be deleted.";
384 throw SALOME::SALOME_Exception(es);
388 // On detruit recursivement toutes les filles
389 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
390 int numberOfIter = maListe->length();
391 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
393 std::string nomIterFille = std::string((*maListe)[NumeIter]);
394 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
395 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
398 // On arrive ici pour une iteration sans fille
399 MESSAGE ( "Destruction effective de " << nomIter );
400 // On commence par invalider l'iteration pour faire le menage des dependances
401 // et eventuellement du maillage associe
403 if ( numero == 0 ) { option = 0 ; }
404 else { option = Option2 ; }
405 InvalideIterOption(nomIter, option) ;
407 // Retrait dans la descendance de l'iteration parent
410 std::string nomIterationParent = myIteration->GetIterParentName();
411 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
412 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
413 if (CORBA::is_nil(myIterationParent))
415 SALOME::ExceptionStruct es;
416 es.type = SALOME::BAD_PARAM;
417 es.text = "Invalid iteration";
418 throw SALOME::SALOME_Exception(es);
421 myIterationParent->UnLinkNextIteration(nomIter);
424 // suppression du lien avec l'hypothese
427 std::string nomHypo = myIteration->GetHypoName();
428 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
429 ASSERT(!CORBA::is_nil(myHypo));
430 myHypo->UnLinkIteration(nomIter);
433 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
434 myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter);
435 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType());
436 SALOMEDS::SObject_var aSO =listSO[0];
437 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
438 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
439 // on peut aussi faire RemoveObject
440 // MESSAGE ( "Au final" );
441 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
442 // numberOfIter = Liste->length();
443 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
445 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
446 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
451 //=============================================================================
452 CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option)
454 // Option = 0 : On ne supprime pas le fichier du schema associe
455 // Option = 1 : On supprime le fichier du schema associe
456 // Pour detruire une iteration courante
457 MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option );
458 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
459 if (CORBA::is_nil(myYACS))
461 SALOME::ExceptionStruct es;
462 es.type = SALOME::BAD_PARAM;
463 es.text = "Invalid schema YACS";
464 throw SALOME::SALOME_Exception(es);
467 ASSERT("Programmer le menage du fichier"!=0);
468 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
469 myContextMap[GetCurrentStudyID()]._mesYACSs.erase(nomYACS);
470 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomYACS, ComponentDataType());
471 SALOMEDS::SObject_var aSO =listSO[0];
472 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
473 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
477 //=============================================================================
478 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
480 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
481 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone];
482 if (CORBA::is_nil(myZone))
484 SALOME::ExceptionStruct es;
485 es.type = SALOME::BAD_PARAM;
486 es.text = "Invalid zone";
487 throw SALOME::SALOME_Exception(es);
491 // On verifie que la zone n'est plus utilisee
492 HOMARD::listeHypo* maListe = myZone->GetHypo();
493 int numberOfHypo = maListe->length();
494 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
495 if ( numberOfHypo > 0 )
497 SALOME::ExceptionStruct es;
498 es.type = SALOME::BAD_PARAM;
499 es.text = "This zone is used in an hypothesis and cannot be deleted.";
500 throw SALOME::SALOME_Exception(es);
504 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
505 myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone);
506 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType());
507 SALOMEDS::SObject_var aSO =listSO[0];
508 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
509 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
513 //=============================================================================
514 //=============================================================================
516 //=============================================================================
517 //=============================================================================
518 // Invalidation des structures identifiees par leurs noms
519 //=============================================================================
520 //=============================================================================
521 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
523 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
524 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
525 if (CORBA::is_nil(myBoundary))
527 SALOME::ExceptionStruct es;
528 es.type = SALOME::BAD_PARAM;
529 es.text = "Invalid boundary";
530 throw SALOME::SALOME_Exception(es);
535 SALOME::ExceptionStruct es;
536 es.type = SALOME::BAD_PARAM;
537 es.text = "No change is allowed in a boundary. Ask for evolution.";
538 throw SALOME::SALOME_Exception(es);
542 //=============================================================================
543 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
545 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
546 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
547 if (CORBA::is_nil(myHypo))
549 SALOME::ExceptionStruct es;
550 es.type = SALOME::BAD_PARAM;
551 es.text = "Invalid hypothesis";
552 throw SALOME::SALOME_Exception(es);
556 HOMARD::listeIters* maListe = myHypo->GetIterations();
557 int numberOfIter = maListe->length();
558 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
560 std::string nomIter = std::string((*maListe)[NumeIter]);
561 MESSAGE( ".. nomIter = " << nomIter );
562 InvalideIter(nomIter.c_str());
565 //=============================================================================
566 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
568 MESSAGE("InvalideIter : nomIter = " << nomIter);
569 // Pour invalider totalement une iteration courante
570 CORBA::Long Option = 1 ;
571 return InvalideIterOption(nomIter, Option);
573 //=============================================================================
574 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
576 // Option = 0 : On ne supprime pas le fichier du maillage associe
577 // Option = 1 : On supprime le fichier du maillage associe
578 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
579 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
580 if (CORBA::is_nil(myIteration))
582 SALOME::ExceptionStruct es;
583 es.type = SALOME::BAD_PARAM;
584 es.text = "Invalid iteration";
585 throw SALOME::SALOME_Exception(es);
589 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
590 int numberOfIter = maListe->length();
591 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
593 std::string nomIterFille = std::string((*maListe)[NumeIter]);
594 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
595 InvalideIter(nomIterFille.c_str());
598 // On arrive ici pour une iteration sans fille
599 MESSAGE ( "Invalidation effective de " << nomIter );
600 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
601 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
602 for (; aIter->More(); aIter->Next())
604 SALOMEDS::SObject_var so = aIter->Value();
605 SALOMEDS::GenericAttribute_var anAttr;
606 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
607 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
608 std::string value (aCommentAttr->Value());
609 if(value == std::string("HypoHomard")) continue;
610 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
611 aStudyBuilder->RemoveObject(so);
614 int etat = myIteration->GetState();
617 SetEtatIter(nomIter,1);
618 const char * nomCas = myIteration->GetCaseName();
619 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
620 if (CORBA::is_nil(myCase))
622 SALOME::ExceptionStruct es;
623 es.type = SALOME::BAD_PARAM;
624 es.text = "Invalid case context";
625 throw SALOME::SALOME_Exception(es);
628 std::string nomDir = myIteration->GetDirName();
629 std::string nomFichier = myIteration->GetMeshFile();
630 std::string commande= "rm -rf " + std::string(nomDir);
631 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
632 MESSAGE ( "commande = " << commande );
633 if ((system(commande.c_str())) != 0)
635 SALOME::ExceptionStruct es;
636 es.type = SALOME::BAD_PARAM;
637 es.text = "The directory for the calculation cannot be cleared." ;
638 throw SALOME::SALOME_Exception(es);
641 // Suppression du maillage publie dans SMESH
642 std::string MeshName = myIteration->GetMeshName() ;
643 DeleteResultInSmesh(nomFichier, MeshName) ;
647 //=============================================================================
648 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
650 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
651 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
652 if (CORBA::is_nil(myIteration))
654 SALOME::ExceptionStruct es;
655 es.type = SALOME::BAD_PARAM;
656 es.text = "Invalid iteration";
657 throw SALOME::SALOME_Exception(es);
661 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
662 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
663 for (; aIter->More(); aIter->Next())
665 SALOMEDS::SObject_var so = aIter->Value();
666 SALOMEDS::GenericAttribute_var anAttr;
667 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
668 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
669 std::string value (aCommentAttr->Value());
670 /* MESSAGE("... value = " << value);*/
671 if( (value == std::string("logInfo")) or ( value == std::string("SummaryInfo")) )
673 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
674 aStudyBuilder->RemoveObject(so);
678 const char * nomCas = myIteration->GetCaseName();
679 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
680 if (CORBA::is_nil(myCase))
682 SALOME::ExceptionStruct es;
683 es.type = SALOME::BAD_PARAM;
684 es.text = "Invalid case context";
685 throw SALOME::SALOME_Exception(es);
688 const char* nomDir = myIteration->GetDirName();
689 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
690 commande += std::string(nomDir) + "/Liste.*info" ;
691 /* MESSAGE ( "commande = " << commande );*/
692 if ((system(commande.c_str())) != 0)
694 SALOME::ExceptionStruct es;
695 es.type = SALOME::BAD_PARAM;
696 es.text = "The directory for the calculation cannot be cleared." ;
697 throw SALOME::SALOME_Exception(es);
701 //=============================================================================
702 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
704 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
705 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
706 if (CORBA::is_nil(myZone))
708 SALOME::ExceptionStruct es;
709 es.type = SALOME::BAD_PARAM;
710 es.text = "Invalid zone";
711 throw SALOME::SALOME_Exception(es);
714 HOMARD::listeHypo* maListe = myZone->GetHypo();
715 int numberOfHypo = maListe->length();
716 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
717 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
719 std::string nomHypo = std::string((*maListe)[NumeHypo]);
720 MESSAGE( ".. nomHypo = " << nomHypo );
721 InvalideHypo(nomHypo.c_str());
724 //=============================================================================
725 //=============================================================================
727 //=============================================================================
728 //=============================================================================
729 // Association de lien entre des structures identifiees par leurs noms
730 //=============================================================================
731 //=============================================================================
732 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
734 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
736 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
737 if (CORBA::is_nil(myCase))
739 SALOME::ExceptionStruct es;
740 es.type = SALOME::BAD_PARAM;
741 es.text = "Invalid case";
742 throw SALOME::SALOME_Exception(es);
746 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
747 if (CORBA::is_nil(myIteration))
749 SALOME::ExceptionStruct es;
750 es.type = SALOME::BAD_PARAM;
751 es.text = "Invalid iteration";
752 throw SALOME::SALOME_Exception(es);
756 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
757 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
758 if (CORBA::is_nil(aCasSO))
760 SALOME::ExceptionStruct es;
761 es.type = SALOME::BAD_PARAM;
762 es.text = "Invalid case";
763 throw SALOME::SALOME_Exception(es);
767 aStudyBuilder->NewCommand();
768 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
769 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
770 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
771 aStudyBuilder->CommitCommand();
773 myCase->AddIteration(nomIter);
774 myIteration->SetCaseName(nomCas);
776 //=====================================================================================
777 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
779 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
781 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
782 ASSERT(!CORBA::is_nil(myHypo));
783 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
784 ASSERT(!CORBA::is_nil(aHypoSO));
786 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
787 ASSERT(!CORBA::is_nil(myZone));
788 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
789 ASSERT(!CORBA::is_nil(aZoneSO));
791 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
793 aStudyBuilder->NewCommand();
795 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
796 aStudyBuilder->Addreference(aSubSO, aZoneSO);
798 aStudyBuilder->CommitCommand();
800 myZone->AddHypo(nomHypothesis);
801 myHypo->AddZone0(ZoneName, TypeUse);
803 //=============================================================================
804 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
806 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
808 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
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_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
814 ASSERT(!CORBA::is_nil(myIteration));
815 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
816 ASSERT(!CORBA::is_nil(aIterSO));
818 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
820 aStudyBuilder->NewCommand();
822 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
823 aStudyBuilder->Addreference(aSubSO, aHypoSO);
825 aStudyBuilder->CommitCommand();
827 myIteration->SetHypoName(nomHypo);
828 myHypo->LinkIteration(nomIter);
830 //=============================================================================
831 //=============================================================================
833 //=============================================================================
834 //=============================================================================
835 // Dissociation de lien entre des structures identifiees par leurs noms
836 //=============================================================================
837 //=============================================================================
838 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
840 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
842 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
843 ASSERT(!CORBA::is_nil(myHypo));
844 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
845 ASSERT(!CORBA::is_nil(aHypoSO));
847 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
848 ASSERT(!CORBA::is_nil(myZone));
849 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
850 ASSERT(!CORBA::is_nil(aZoneSO));
852 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
854 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
855 for (; it->More(); it->Next())
857 SALOMEDS::SObject_var aHypObj = it->Value();
858 SALOMEDS::SObject_var ptrObj;
859 if (aHypObj->ReferencedObject(ptrObj))
861 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
863 aStudyBuilder->NewCommand();
864 aStudyBuilder->RemoveObject(aHypObj);
865 aStudyBuilder->CommitCommand();
871 myZone->SupprHypo(nomHypothesis);
872 myHypo->SupprZone(ZoneName);
874 //=============================================================================
875 //=============================================================================
878 //=============================================================================
879 //=============================================================================
880 // Recuperation des listes
881 //=============================================================================
882 //=============================================================================
883 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
885 MESSAGE("GetAllBoundarysName");
888 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
889 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
890 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
892 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
893 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
895 ret[i++] = CORBA::string_dup((*it).first.c_str());
900 //=============================================================================
901 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
903 MESSAGE("GetAllCasesName");
906 HOMARD::listeCases_var ret = new HOMARD::listeCases;
907 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
908 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
910 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
911 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
913 ret[i++] = CORBA::string_dup((*it).first.c_str());
918 //=============================================================================
919 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
921 MESSAGE("GetAllHypothesesName");
924 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
925 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
926 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
928 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
929 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
931 ret[i++] = CORBA::string_dup((*it).first.c_str());
936 //=============================================================================
937 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
939 MESSAGE("GetAllIterationsName");
942 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
943 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
944 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
946 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
947 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
949 ret[i++] = CORBA::string_dup((*it).first.c_str());
954 //=============================================================================
955 HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName()
957 MESSAGE("GetAllYACSsName");
960 HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs;
961 ret->length(myContextMap[GetCurrentStudyID()]._mesYACSs.size());
962 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it;
964 for (it = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
965 it != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); it++)
967 ret[i++] = CORBA::string_dup((*it).first.c_str());
972 //=============================================================================
973 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
975 MESSAGE("GetAllZonesName");
978 HOMARD::listeZones_var ret = new HOMARD::listeZones;
979 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
980 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
982 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
983 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
985 ret[i++] = CORBA::string_dup((*it).first.c_str());
990 //=============================================================================
991 //=============================================================================
993 //=============================================================================
994 //=============================================================================
995 // Recuperation des structures identifiees par leurs noms
996 //=============================================================================
997 //=============================================================================
998 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
1000 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
1001 ASSERT(!CORBA::is_nil(myBoundary));
1002 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1004 //=============================================================================
1005 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
1007 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1008 ASSERT(!CORBA::is_nil(myCase));
1009 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1011 //=============================================================================
1012 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
1014 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
1015 ASSERT(!CORBA::is_nil(myHypothesis));
1016 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1018 //=============================================================================
1019 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
1021 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
1022 ASSERT(!CORBA::is_nil(myIteration));
1023 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1025 //=============================================================================
1026 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* YACSName)
1028 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[YACSName];
1029 ASSERT(!CORBA::is_nil(myYACS));
1030 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
1032 //=============================================================================
1033 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
1035 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
1036 ASSERT(!CORBA::is_nil(myZone));
1037 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1039 //=============================================================================
1040 //=============================================================================
1042 //=============================================================================
1043 //=============================================================================
1045 //=============================================================================
1046 //=============================================================================
1047 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)
1049 INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1050 INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
1054 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, 1) ;
1055 myCase->SetDirName(DirName) ;
1057 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1061 //=============================================================================
1062 //=============================================================================
1064 //=============================================================================
1065 //=============================================================================
1066 // Recuperation des structures par le contexte
1067 //=============================================================================
1068 //=============================================================================
1069 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1071 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1072 ASSERT(!CORBA::is_nil(myCase));
1074 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1075 ASSERT(!CORBA::is_nil(myIteration));
1077 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1079 //=============================================================================
1080 //=============================================================================
1082 //=============================================================================
1083 //=============================================================================
1084 // Nouvelles structures
1085 //=============================================================================
1086 //=============================================================================
1087 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1089 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1090 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1091 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1092 return aCase._retn();
1094 //=============================================================================
1095 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1097 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1098 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1099 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1100 return aHypo._retn();
1102 //=============================================================================
1103 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1105 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1106 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1107 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1108 return aIter._retn();
1110 //=============================================================================
1111 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1113 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1114 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1115 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1116 return aBoundary._retn();
1118 //=============================================================================
1119 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1121 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1122 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1123 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1124 return aZone._retn();
1126 //=============================================================================
1127 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS()
1129 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1130 HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine);
1131 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this());
1132 return aYACS._retn();
1134 //=============================================================================
1135 //=============================================================================
1137 //=============================================================================
1138 //=============================================================================
1139 // Creation des structures identifiees par leurs noms
1140 //=============================================================================
1141 //=============================================================================
1142 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1144 // Creation d'un cas initial
1145 // nomCas : nom du cas a creer
1146 // MeshName, MeshFile : nom et fichier du maillage correspondant
1149 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1151 // Par defaut, on ne publie pas le maillage
1152 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, 1) ;
1154 // Valeurs par defaut des filtrages
1155 myCase->SetPyram(0);
1157 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1159 //=============================================================================
1160 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1162 // nomCas : nom du cas a creer
1163 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1166 INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1167 std::string nomDirWork = getenv("PWD") ;
1170 // A. Decodage du point de reprise
1171 // A.1. Controle du repertoire de depart de l'iteration
1172 codret = chdir(DirNameStart) ;
1175 SALOME::ExceptionStruct es;
1176 es.type = SALOME::BAD_PARAM;
1177 es.text = "The directory of the iteration does not exist.";
1178 throw SALOME::SALOME_Exception(es);
1181 // A.2. Reperage des fichiers du repertoire de reprise
1182 std::string file_configuration = "" ;
1183 std::string file_maillage_homard = "" ;
1186 struct dirent *dirp;
1187 dp = opendir(DirNameStart);
1188 while ( (dirp = readdir(dp)) != NULL )
1190 std::string file_name(dirp->d_name);
1191 // MESSAGE ( file_name );
1192 bilan = file_name.find("HOMARD.Configuration.") ;
1193 if ( bilan != string::npos ) { file_configuration = file_name ; }
1194 bilan = file_name.find("maill.") ;
1195 if ( bilan != string::npos )
1197 bilan = file_name.find(".hom.med") ;
1198 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1202 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1203 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1205 if ( ( file_configuration == "" ) or ( file_maillage_homard == "" ) )
1207 SALOME::ExceptionStruct es;
1208 es.type = SALOME::BAD_PARAM;
1210 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1211 else { text = "The HOMARD mesh file cannot be found." ; }
1212 es.text = CORBA::string_dup(text.c_str());
1213 throw SALOME::SALOME_Exception(es);
1216 // B. Lecture du fichier de configuration
1217 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1223 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1224 std::ifstream fichier( file_configuration.c_str() );
1225 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1227 std::string ligne; // variable contenant chaque ligne lue
1228 std::string mot_cle;
1229 std::string argument;
1231 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1232 while ( std::getline( fichier, ligne ) )
1234 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1235 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1236 ligne_bis >> mot_cle ;
1237 // B.2. Des valeurs entieres : le second bloc de la ligne
1238 if ( mot_cle == "NumeIter" )
1240 ligne_bis >> NumeIter ;
1243 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1244 else if ( ( mot_cle == "TypeConf" ) or ( mot_cle == "TypeElem" ) )
1246 ligne_bis >> argument ;
1248 if ( mot_cle == "TypeConf" )
1250 if ( argument == "conforme" ) { TypeConf = 1 ; }
1251 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1252 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1253 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1255 else if ( mot_cle == "TypeElem" )
1257 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1258 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1261 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1262 // il faut les supprimer
1263 else if ( ( mot_cle == "CCNoMNP1" ) or ( mot_cle == "CCMaiNP1" ) )
1265 ligne_bis >> argument ;
1266 if ( argument[0] == '"' ) { decalage = 1 ; }
1267 else { decalage = 0 ; }
1268 size_t size = argument.size() + 1 - 2*decalage ;
1270 if ( mot_cle == "CCNoMNP1" )
1272 MeshName = new char[ size ];
1273 strncpy( MeshName, argument.c_str()+decalage, size );
1274 MeshName[size-1] = '\0' ;
1276 else if ( mot_cle == "CCMaiNP1" )
1278 MeshFile = new char[ size ];
1279 strncpy( MeshFile, argument.c_str()+decalage, size );
1280 MeshFile[size-1] = '\0' ;
1284 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1285 MESSAGE ( "==> MeshName : " << MeshName ) ;
1286 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1287 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1288 MESSAGE ( "==> Pyram : " << Pyram ) ;
1292 SALOME::ExceptionStruct es;
1293 es.type = SALOME::BAD_PARAM;
1294 std::string text = "The configuration file cannot be read." ;
1295 es.text = CORBA::string_dup(text.c_str());
1296 throw SALOME::SALOME_Exception(es);
1299 // C. Creation effective du cas
1301 // Par defaut, on ne publie pas le maillage
1302 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, 1) ;
1304 // D. Parametrages lus dans le fichier de configuration
1306 myCase->SetConfType (TypeConf) ;
1307 myCase->SetPyram (Pyram) ;
1309 // E. Copie du fichier de maillage homard
1310 // E.1. Repertoire associe au cas
1311 char* nomDirCase = myCase->GetDirName() ;
1312 // E.2. Repertoire associe a l'iteration de ce cas
1314 IterName = myCase->GetIter0Name() ;
1315 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1316 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1317 Iter->SetDirNameLoc(nomDirIter);
1318 std::string nomDirIterTotal ;
1319 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1320 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1322 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1323 SALOME::ExceptionStruct es;
1324 es.type = SALOME::BAD_PARAM;
1325 std::string text = "The directory for the computation cannot be created." ;
1326 es.text = CORBA::string_dup(text.c_str());
1327 throw SALOME::SALOME_Exception(es);
1329 // E.3. Copie du maillage HOMARD au format MED
1330 codret = chdir(DirNameStart) ;
1331 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1332 MESSAGE ( "commande : " << commande ) ;
1333 codret = system(commande.c_str()) ;
1334 MESSAGE ( "codret : " << codret ) ;
1337 SALOME::ExceptionStruct es;
1338 es.type = SALOME::BAD_PARAM;
1339 es.text = "The starting point for the case cannot be copied into the working directory.";
1340 throw SALOME::SALOME_Exception(es);
1349 chdir(nomDirWork.c_str());
1351 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1353 //=============================================================================
1354 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1356 // nomCas : nom du cas a creer
1357 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1360 INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1362 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1364 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1365 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1367 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1369 //=============================================================================
1370 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1372 // nomCas : nom du cas a creer
1373 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1374 // Number : numero de l'iteration de depart
1377 INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1380 SALOME::ExceptionStruct es;
1381 es.type = SALOME::BAD_PARAM;
1382 es.text = "The number of iteration must be positive.";
1383 throw SALOME::SALOME_Exception(es);
1387 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1389 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1390 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1392 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1394 //=============================================================================
1395 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1397 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1398 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1399 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1402 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1403 std::string nomDirWork = getenv("PWD") ;
1404 std::string DirNameStartIter ;
1406 int NumeIterMax = -1 ;
1408 // A.1. Controle du repertoire de depart du cas
1409 codret = chdir(DirNameStart) ;
1412 SALOME::ExceptionStruct es;
1413 es.type = SALOME::BAD_PARAM;
1414 es.text = "The directory of the case for the pursuit does not exist.";
1415 throw SALOME::SALOME_Exception(es);
1418 // A.2. Reperage des sous-repertoire du repertoire de reprise
1419 bool existe = false ;
1421 struct dirent *dirp;
1422 dp = opendir(DirNameStart);
1423 while ( (dirp = readdir(dp)) != NULL )
1425 std::string DirName_1(dirp->d_name);
1426 if ( ( DirName_1 != "." ) and ( DirName_1 != ".." ) )
1428 if ( chdir(DirName_1.c_str()) == 0 )
1430 // On cherche le fichier de configuration dans ce sous-repertoire
1431 codret = chdir(DirNameStart) ;
1433 struct dirent *dirp_1;
1434 dp_1 = opendir(DirName_1.c_str()) ;
1435 while ( (dirp_1 = readdir(dp_1)) != NULL )
1437 std::string file_name_1(dirp_1->d_name);
1438 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1439 if ( bilan != string::npos )
1441 // Decodage du fichier pour trouver le numero d'iteration
1442 chdir(DirName_1.c_str()) ;
1443 std::ifstream fichier( file_name_1.c_str() );
1444 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1447 std::string ligne; // variable contenant chaque ligne lue
1448 std::string mot_cle;
1449 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1450 while ( std::getline( fichier, ligne ) )
1452 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1453 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1454 ligne_bis >> mot_cle ;
1455 if ( mot_cle == "NumeIter" )
1457 ligne_bis >> NumeIter ;
1459 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1460 if ( Number == - 1 )
1462 if ( NumeIter >= NumeIterMax )
1464 NumeIterMax = NumeIter ;
1465 DirNameStartIter = DirName_1 ;
1470 if ( NumeIter == Number )
1472 DirNameStartIter = DirName_1 ;
1482 SALOME::ExceptionStruct es;
1483 es.type = SALOME::BAD_PARAM;
1484 std::string text = "The configuration file cannot be read." ;
1485 es.text = CORBA::string_dup(text.c_str());
1486 throw SALOME::SALOME_Exception(es);
1488 chdir(DirNameStart) ;
1490 if ( existe ) { break ; }
1493 if ( existe ) { break ; }
1499 chdir(nomDirWork.c_str());
1501 if ( ( Number >= 0 and ( not existe ) ) or ( Number < 0 and ( NumeIterMax == -1 ) ) )
1503 SALOME::ExceptionStruct es;
1504 es.type = SALOME::BAD_PARAM;
1505 es.text = "The directory of the iteration does not exist.";
1506 throw SALOME::SALOME_Exception(es);
1510 return DirNameStartIter ;
1512 //=============================================================================
1513 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)
1515 // nomCas : nom du cas a creer
1516 // MeshName, MeshFile : nom et fichier du maillage correspondant
1517 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1518 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1519 // -1 : le maillage n'est pas fourni
1520 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1521 // Option : multiple de nombres premiers
1522 // 1 : aucune option
1523 // x2 : publication du maillage dans SMESH
1525 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1526 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1527 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1533 // A.2. Controle du nom :
1534 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1536 SALOME::ExceptionStruct es;
1537 es.type = SALOME::BAD_PARAM;
1538 es.text = "This case has already been defined.";
1539 throw SALOME::SALOME_Exception(es);
1543 // A.3. Controle du fichier du maillage
1544 int existeMeshFile ;
1545 if ( MeshOption >= 0 )
1547 existeMeshFile = MEDFileExist ( MeshFile ) ;
1548 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1549 if ( ( existeMeshFile == 0 ) and ( MeshOption == 0 ) )
1551 SALOME::ExceptionStruct es;
1552 es.type = SALOME::BAD_PARAM;
1553 es.text = "The mesh file does not exist.";
1554 throw SALOME::SALOME_Exception(es);
1558 else { existeMeshFile = 0 ; }
1560 // B. Creation de l'objet cas et publication
1561 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1562 HOMARD::HOMARD_Cas_var myCase = newCase();
1563 myCase->SetName(nomCas);
1564 SALOMEDS::SObject_var aSO;
1565 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1566 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1568 // C. Caracteristiques du maillage
1569 if ( existeMeshFile != 0 )
1571 // Les valeurs extremes des coordonnees
1572 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1573 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1574 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1575 if (LesExtremes.size()!=10) { return false; }
1577 for (int i =0 ; i< LesExtremes.size() ; i++)
1578 aSeq[i]=LesExtremes[i] ;
1579 myCase->SetBoundingBox(aSeq) ;
1581 // MESSAGE ( "CreateCase0 : Les groupes" );
1582 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1583 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1584 aSeqGroupe->length(LesGroupes.size());
1585 std::set<std::string>::const_iterator it ;
1587 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1588 aSeqGroupe[i++]=(*it).c_str() ;
1589 myCase->SetGroups(aSeqGroupe) ;
1592 // D. L'iteration initiale du cas
1593 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1594 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1595 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1597 std::string NomIteration = std::string(MeshName) ;
1598 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1600 std::ostringstream nom;
1601 nom << MeshName << monNum;
1602 NomIteration = nom.str();
1605 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1607 // D.2. Creation de l'iteration
1608 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1609 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1610 anIter->SetName(NomIteration.c_str());
1611 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1613 // D.4. Maillage correspondant
1614 if ( existeMeshFile != 0 )
1616 anIter->SetMeshFile(MeshFile);
1617 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1619 anIter->SetMeshName(MeshName);
1621 // D.5. Numero d'iteration
1622 anIter->SetNumber(NumeIter);
1625 SetEtatIter(NomIteration.c_str(), -NumeIter);
1628 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1630 //=============================================================================
1631 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1633 INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1636 // A. Controle du nom :
1637 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1639 SALOME::ExceptionStruct es;
1640 es.type = SALOME::BAD_PARAM;
1641 es.text = "This hypothesis has already been defined.";
1642 throw SALOME::SALOME_Exception(es);
1646 // B. Creation de l'objet
1647 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1648 if (CORBA::is_nil(myHypothesis))
1650 SALOME::ExceptionStruct es;
1651 es.type = SALOME::BAD_PARAM;
1652 es.text = "Unable to create the hypothesis";
1653 throw SALOME::SALOME_Exception(es);
1656 myHypothesis->SetName(nomHypothesis);
1658 // C. Enregistrement
1659 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1661 SALOMEDS::SObject_var aSO;
1662 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1664 // D. Valeurs par defaut des options avancees
1665 myHypothesis->SetNivMax(-1);
1666 myHypothesis->SetDiamMin(-1.0);
1667 myHypothesis->SetAdapInit(0);
1668 myHypothesis->SetLevelOutput(0);
1670 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1673 //=============================================================================
1674 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1675 //=============================================================================
1677 INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1680 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1681 if (CORBA::is_nil(myIterationParent))
1683 SALOME::ExceptionStruct es;
1684 es.type = SALOME::BAD_PARAM;
1685 es.text = "The parent iteration is not defined.";
1686 throw SALOME::SALOME_Exception(es);
1690 const char* nomCas = myIterationParent->GetCaseName();
1691 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1692 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1693 if (CORBA::is_nil(myCase))
1695 SALOME::ExceptionStruct es;
1696 es.type = SALOME::BAD_PARAM;
1697 es.text = "Invalid case context";
1698 throw SALOME::SALOME_Exception(es);
1701 const char* nomDirCase = myCase->GetDirName();
1703 // Controle du nom :
1704 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1706 SALOME::ExceptionStruct es;
1707 es.type = SALOME::BAD_PARAM;
1708 es.text = "This iteration has already been defined.";
1709 throw SALOME::SALOME_Exception(es);
1713 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1714 if (CORBA::is_nil(myIteration))
1716 SALOME::ExceptionStruct es;
1717 es.type = SALOME::BAD_PARAM;
1718 es.text = "Unable to create the iteration";
1719 throw SALOME::SALOME_Exception(es);
1722 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1723 // Nom de l'iteration et du maillage
1724 myIteration->SetName(NomIteration);
1725 myIteration->SetMeshName(NomIteration);
1726 myIteration->SetState(1);
1728 int numero = myIterationParent->GetNumber() + 1;
1729 myIteration->SetNumber(numero);
1731 // Nombre d'iterations deja connues pour le cas, permettant
1732 // la creation d'un sous-repertoire unique
1733 int nbitercase = myCase->GetNumberofIter();
1734 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1735 myIteration->SetDirNameLoc(nomDirIter);
1737 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1738 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1739 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1740 // situation la plus frequente.
1741 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1742 // le nombre d'iterations du cas permet d'eviter les collisions.
1744 if ( nbitercase < 100 ) { jaux = 2 ; }
1745 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1746 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1747 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1749 std::ostringstream iaux ;
1750 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1751 std::stringstream MeshFile;
1752 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1753 myIteration->SetMeshFile(MeshFile.str().c_str());
1755 // Association avec le cas
1756 std::string label = "IterationHomard_" + std::string(nomIterParent);
1757 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1758 // Lien avec l'iteration precedente
1759 myIterationParent->LinkNextIteration(NomIteration);
1760 myIteration->SetIterParentName(nomIterParent);
1762 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1764 //=============================================================================
1765 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1767 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1770 // Controle du nom :
1771 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1773 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1774 SALOME::ExceptionStruct es;
1775 es.type = SALOME::BAD_PARAM;
1776 es.text = "This boundary has already been defined";
1777 throw SALOME::SALOME_Exception(es);
1781 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1782 myBoundary->SetName(BoundaryName);
1783 myBoundary->SetType(BoundaryType);
1785 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1787 SALOMEDS::SObject_var aSO;
1788 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1790 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1792 //=============================================================================
1793 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1795 INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1796 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1797 myBoundary->SetMeshFile( MeshFile ) ;
1798 myBoundary->SetMeshName( MeshName ) ;
1800 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1802 //=============================================================================
1803 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1804 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1805 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1806 CORBA::Double Rayon)
1808 INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1810 SALOME::ExceptionStruct es;
1813 { es.text = "The radius must be positive." ;
1815 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1816 if ( daux < 0.0000001 )
1817 { es.text = "The axis must be a non 0 vector." ;
1821 es.type = SALOME::BAD_PARAM;
1822 throw SALOME::SALOME_Exception(es);
1826 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1827 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1829 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1831 //=============================================================================
1832 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1833 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1834 CORBA::Double Rayon)
1836 INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1838 SALOME::ExceptionStruct es;
1841 { es.text = "The radius must be positive." ;
1845 es.type = SALOME::BAD_PARAM;
1846 throw SALOME::SALOME_Exception(es);
1850 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1851 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1853 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1855 //=============================================================================
1856 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1857 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1858 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1860 INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1862 SALOME::ExceptionStruct es;
1864 if ( Angle <= 0.0 or Angle >= 90.0 )
1865 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1867 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1868 if ( daux < 0.0000001 )
1869 { es.text = "The axis must be a non 0 vector." ;
1873 es.type = SALOME::BAD_PARAM;
1874 throw SALOME::SALOME_Exception(es);
1878 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
1879 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
1881 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1883 //=============================================================================
1884 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
1885 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
1886 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
1888 INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
1890 SALOME::ExceptionStruct es;
1892 if ( Rayon1 < 0.0 or Rayon2 < 0.0 )
1893 { es.text = "The radius must be positive." ;
1895 double daux = fabs(Rayon2-Rayon1) ;
1896 if ( daux < 0.0000001 )
1897 { es.text = "The radius must be different." ;
1899 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
1900 if ( daux < 0.0000001 )
1901 { es.text = "The centers must be different." ;
1905 es.type = SALOME::BAD_PARAM;
1906 throw SALOME::SALOME_Exception(es);
1910 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
1911 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
1913 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1915 //=============================================================================
1916 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
1918 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
1921 // Controle du nom :
1922 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
1924 SALOME::ExceptionStruct es;
1925 es.type = SALOME::BAD_PARAM;
1926 es.text = "This zone has already been defined";
1927 throw SALOME::SALOME_Exception(es);
1931 HOMARD::HOMARD_Zone_var myZone = newZone();
1932 myZone->SetName(ZoneName);
1933 myZone->SetType(ZoneType);
1935 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
1937 SALOMEDS::SObject_var aSO;
1938 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
1940 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1942 //=============================================================================
1943 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
1944 CORBA::Double Xmini, CORBA::Double Xmaxi,
1945 CORBA::Double Ymini, CORBA::Double Ymaxi,
1946 CORBA::Double Zmini, CORBA::Double Zmaxi)
1948 INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ;
1950 SALOME::ExceptionStruct es;
1952 if ( Xmini > Xmaxi )
1953 { es.text = "The X coordinates are not coherent." ;
1955 if ( Ymini > Ymaxi )
1956 { es.text = "The Y coordinates are not coherent." ;
1958 if ( Zmini > Zmaxi )
1959 { es.text = "The Z coordinates are not coherent." ;
1963 es.type = SALOME::BAD_PARAM;
1964 throw SALOME::SALOME_Exception(es);
1968 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
1969 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
1971 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1973 //=============================================================================
1974 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
1975 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
1977 INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
1979 SALOME::ExceptionStruct es;
1982 { es.text = "The radius must be positive." ;
1986 es.type = SALOME::BAD_PARAM;
1987 throw SALOME::SALOME_Exception(es);
1991 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
1992 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1994 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1996 //=============================================================================
1997 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
1998 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1999 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2000 CORBA::Double Rayon, CORBA::Double Haut)
2002 INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
2004 SALOME::ExceptionStruct es;
2007 { es.text = "The radius must be positive." ;
2009 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2010 if ( daux < 0.0000001 )
2011 { es.text = "The axis must be a non 0 vector." ;
2014 { es.text = "The height must be positive." ;
2018 es.type = SALOME::BAD_PARAM;
2019 throw SALOME::SALOME_Exception(es);
2023 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
2024 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
2026 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2028 //=============================================================================
2029 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
2030 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2031 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2032 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
2034 INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ;
2036 SALOME::ExceptionStruct es;
2038 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
2039 { es.text = "The radius must be positive." ;
2041 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2042 if ( daux < 0.0000001 )
2043 { es.text = "The axis must be a non 0 vector." ;
2046 { es.text = "The height must be positive." ;
2048 if ( Rayon <= Rayonint )
2049 { es.text = "The external radius must be higher than the internal radius." ;
2053 es.type = SALOME::BAD_PARAM;
2054 throw SALOME::SALOME_Exception(es);
2058 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
2059 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
2061 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2063 //=============================================================================
2064 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
2065 CORBA::Double Umini, CORBA::Double Umaxi,
2066 CORBA::Double Vmini, CORBA::Double Vmaxi,
2069 INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
2070 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
2071 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
2072 // MESSAGE ("Orient = " << Orient ) ;
2074 SALOME::ExceptionStruct es;
2076 if ( Umini > Umaxi )
2077 { es.text = "The first coordinates are not coherent." ;
2079 if ( Vmini > Vmaxi )
2080 { es.text = "The second coordinates are not coherent." ;
2082 if ( Orient < 1 or Orient > 3 )
2083 { es.text = "The orientation must be 1, 2 or 3." ;
2087 es.type = SALOME::BAD_PARAM;
2088 throw SALOME::SALOME_Exception(es);
2092 double Xmini, Xmaxi ;
2093 double Ymini, Ymaxi ;
2094 double Zmini, Zmaxi ;
2102 else if ( Orient == 2 )
2109 else if ( Orient == 3 )
2116 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2118 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2119 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2121 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2123 //=============================================================================
2124 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2125 CORBA::Double Ucentre, CORBA::Double Vcentre,
2126 CORBA::Double Rayon,
2129 INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2131 SALOME::ExceptionStruct es;
2134 { es.text = "The radius must be positive." ;
2136 if ( Orient < 1 or Orient > 3 )
2137 { es.text = "The orientation must be 1, 2 or 3." ;
2141 es.type = SALOME::BAD_PARAM;
2142 throw SALOME::SALOME_Exception(es);
2150 { Xcentre = Ucentre ;
2153 else if ( Orient == 2 )
2156 Zcentre = Vcentre ; }
2157 else if ( Orient == 3 )
2158 { Xcentre = Vcentre ;
2160 Zcentre = Ucentre ; }
2161 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2163 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2164 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2166 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2168 //=============================================================================
2169 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2170 CORBA::Double Ucentre, CORBA::Double Vcentre,
2171 CORBA::Double Rayon, CORBA::Double Rayonint,
2174 INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2176 SALOME::ExceptionStruct es;
2178 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
2179 { es.text = "The radius must be positive." ;
2181 if ( Orient < 1 or Orient > 3 )
2182 { es.text = "The orientation must be 1, 2 or 3." ;
2184 if ( Rayon <= Rayonint )
2185 { es.text = "The external radius must be higher than the internal radius." ;
2189 es.type = SALOME::BAD_PARAM;
2190 throw SALOME::SALOME_Exception(es);
2198 { Xcentre = Ucentre ;
2201 else if ( Orient == 2 )
2204 Zcentre = Vcentre ; }
2205 else if ( Orient == 3 )
2206 { Xcentre = Vcentre ;
2208 Zcentre = Ucentre ; }
2209 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2211 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2212 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2214 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2216 //=============================================================================
2217 //=============================================================================
2222 //=============================================================================
2223 //=============================================================================
2224 // Traitement d'une iteration
2225 // etatMenage = 1 : destruction du repertoire d'execution
2226 // modeHOMARD = 1 : adaptation
2227 // != 1 : information avec les options modeHOMARD
2228 // Option1 >0 : appel depuis python
2229 // <0 : appel depuis GUI
2230 // Option2 : multiple de nombres premiers
2231 // 1 : aucune option
2232 // x2 : publication du maillage dans SMESH
2233 //=============================================================================
2234 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2236 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2241 // A.1. L'objet iteration
2242 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2243 ASSERT(!CORBA::is_nil(myIteration));
2245 // A.2. Numero de l'iteration
2246 // siterp1 : numero de l'iteration a traiter
2248 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2249 // Ou si information :
2251 int NumeIter = myIteration->GetNumber();
2252 std::string siterp1 ;
2253 std::stringstream saux1 ;
2255 siterp1 = saux1.str() ;
2256 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2259 if ( modeHOMARD==1 )
2261 std::stringstream saux0 ;
2262 int iaux = max(0, NumeIter-1) ;
2264 siter = saux0.str() ;
2265 if (NumeIter < 11) { siter = "0" + siter ; }
2268 { siter = siterp1 ; }
2271 const char* nomCas = myIteration->GetCaseName();
2272 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2273 ASSERT(!CORBA::is_nil(myCase));
2275 // B. Les repertoires
2276 // B.1. Le repertoire courant
2277 std::string nomDirWork = getenv("PWD") ;
2278 // B.2. Le sous-repertoire de l'iteration a traiter
2279 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2280 MESSAGE( ". DirCompute = " << DirCompute );
2282 // C. Le fichier des messages
2283 // C.1. Le deroulement de l'execution de HOMARD
2284 std::string LogFile = DirCompute ;
2285 LogFile += "/Liste" ;
2286 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2288 MESSAGE (". LogFile = " << LogFile);
2289 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2290 // C.2. Le bilan de l'analyse du maillage
2291 std::string FileInfo = DirCompute ;
2293 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2295 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2296 else { FileInfo += "info_ap" ; }
2298 FileInfo += "." + siterp1 + ".bilan" ;
2299 myIteration->SetFileInfo(FileInfo.c_str());
2301 // D. On passe dans le repertoire de l'iteration a calculer
2302 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2305 // E. Les donnees de l'execution HOMARD
2306 // E.1. L'objet du texte du fichier de configuration
2307 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2308 std::string Langue = "Francais" ;
2309 myDriver->TexteInit(DirCompute, LogFile, Langue);
2311 // E.2. Le maillage associe a l'iteration
2312 const char* NomMesh = myIteration->GetMeshName();
2313 MESSAGE ( ". NomMesh = " << NomMesh );
2314 const char* MeshFile = myIteration->GetMeshFile();
2315 MESSAGE ( ". MeshFile = " << MeshFile );
2317 // E.3. Les donnees du traitement HOMARD
2319 if ( modeHOMARD == 1 )
2322 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2323 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2324 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2328 InvalideIterInfo(NomIteration);
2329 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2331 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2332 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2333 myDriver->CreeFichierDonn();
2336 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2337 DriverTexteBoundary(myCase, myDriver) ;
2339 // E.5. Ecriture du texte dans le fichier
2341 { myDriver->CreeFichier(); }
2345 int codretexec = 12 ;
2348 codretexec = myDriver->ExecuteHomard(Option1);
2350 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2351 if ( modeHOMARD == 1 )
2353 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2354 else { SetEtatIter(NomIteration,1); }
2355 // GERALD -- QMESSAGE BOX
2359 // H. Gestion des resultats
2362 std::string Commentaire ;
2363 // H.1. Le fichier des messages, dans tous les cas
2364 Commentaire = "log" ;
2365 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2366 else { Commentaire += "Info" ; }
2367 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2369 // H.2. Si tout s'est bien passe :
2370 if (codretexec == 0)
2372 // H.2.1. Le fichier de bilan
2373 Commentaire = "Summary" ;
2374 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2375 else { Commentaire += "Info" ; }
2376 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2377 // H.2.2. Le fichier de maillage obtenu
2378 if ( modeHOMARD == 1 )
2380 std::stringstream saux0 ;
2381 Commentaire = "Iteration" ;
2382 Commentaire += " " + siter ;
2383 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2384 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2387 // H.3 Message d'erreur en cas de probleme
2390 SALOME::ExceptionStruct es;
2391 es.type = SALOME::BAD_PARAM;
2392 std::string text = "Error during the adaptation.\n" ;
2395 ifstream fichier(LogFile.c_str(), ios::in);
2397 while(getline(fichier, ligne) and (ligne != "===== HOMARD ===== STOP ====="));
2398 while (getline(fichier, ligne)) { text += ligne+ "\n";};
2401 text += "no log file ....";
2403 es.text = CORBA::string_dup(text.c_str());
2404 throw SALOME::SALOME_Exception(es);
2408 // I. Menage et retour dans le repertoire du cas
2412 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2413 chdir(nomDirWork.c_str());
2418 //=============================================================================
2419 // Calcul d'une iteration : partie specifique a l'adaptation
2420 //=============================================================================
2421 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)
2423 MESSAGE ( "ComputeAdap" );
2428 // Etat de l'iteration
2429 int etat = myIteration->GetState();
2430 // Numero de l'iteration
2431 int NumeIter = myIteration->GetNumber();
2432 std::stringstream saux0 ;
2433 saux0 << NumeIter-1 ;
2434 std::string siter = saux0.str() ;
2435 if (NumeIter < 11) { siter = "0" + siter ; }
2437 // A.2. On ne calcule pas l iteration initiale
2440 MESSAGE ( "etat = "<<etat );
2441 SALOME::ExceptionStruct es;
2442 es.type = SALOME::BAD_PARAM;
2443 es.text = "This iteration is the first of the case and cannot be computed.";
2444 throw SALOME::SALOME_Exception(es);
2448 // A.3. On verifie qu il y a une hypothese (erreur improbable);
2449 const char* nomHypo = myIteration->GetHypoName();
2450 if (std::string(nomHypo) == std::string(""))
2452 SALOME::ExceptionStruct es;
2453 es.type = SALOME::BAD_PARAM;
2454 es.text = "This iteration does not have any associated hypothesis.";
2455 throw SALOME::SALOME_Exception(es);
2458 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2459 ASSERT(!CORBA::is_nil(myHypo));
2461 // B. L'iteration parent
2462 const char* nomIterationParent = myIteration->GetIterParentName();
2463 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2464 ASSERT(!CORBA::is_nil(myIterationParent));
2465 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2466 if ( myIterationParent->GetState() == 1 )
2469 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2472 // GERALD -- QMESSAGE BOX
2473 ASSERT("Pb au calcul de l'iteration precedente" == 0);
2477 // C. Le sous-repertoire de l'iteration precedente
2478 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2479 MESSAGE( ". DirComputePa = " << DirComputePa );
2481 // D. Les donnees de l'adaptation HOMARD
2482 // D.1. Le type de conformite
2483 int ConfType = myCase->GetConfType();
2484 MESSAGE ( ". ConfType = " << ConfType );
2486 // D.2. Le maillage de depart
2487 const char* NomMeshParent = myIterationParent->GetMeshName();
2488 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2489 const char* MeshFileParent = myIterationParent->GetMeshFile();
2490 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2492 // D.3. Le maillage associe a l'iteration
2493 const char* MeshFile = myIteration->GetMeshFile();
2494 MESSAGE ( ". MeshFile = " << MeshFile );
2495 FILE *file = fopen(MeshFile,"r");
2499 if (etatMenage == 0)
2501 SALOME::ExceptionStruct es;
2502 es.type = SALOME::BAD_PARAM;
2503 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2504 es.text = CORBA::string_dup(text.c_str());
2505 throw SALOME::SALOME_Exception(es);
2510 std::string commande = "rm -f " + std::string(MeshFile);
2511 codret = system(commande.c_str());
2514 SALOME::ExceptionStruct es;
2515 es.type = SALOME::BAD_PARAM;
2516 es.text = "The mesh file cannot be deleted.";
2517 throw SALOME::SALOME_Exception(es);
2523 // D.4. Les types de raffinement et de deraffinement
2524 // Les appels corba sont lourds, il vaut mieux les grouper
2525 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2526 ASSERT(ListTypes->length() == 3);
2527 int TypeAdap = (*ListTypes)[0];
2528 int TypeRaff = (*ListTypes)[1];
2529 int TypeDera = (*ListTypes)[2];
2531 // E. Texte du fichier de configuration
2532 // E.1. Incontournables du texte
2533 myDriver->TexteAdap();
2535 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2536 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2537 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2539 // E.2. Ajout des informations liees aux zones eventuelles
2540 if ( TypeAdap == 0 )
2541 { DriverTexteZone(myHypo, myDriver) ; }
2543 // E.3. Ajout des informations liees aux champs eventuels
2544 if ( TypeAdap == 1 )
2545 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2547 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2548 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2549 int numberOfGroups = listeGroupes->length();
2550 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2551 if (numberOfGroups > 0)
2553 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2555 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2556 MESSAGE( "... GroupName = " << GroupName );
2557 myDriver->TexteGroup(GroupName);
2561 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2562 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2564 // E.6. Ajout des options avancees
2565 int Pyram = myCase->GetPyram();
2566 MESSAGE ( ". Pyram = " << Pyram );
2567 int NivMax = myHypo->GetNivMax();
2568 MESSAGE ( ". NivMax = " << NivMax );
2569 double DiamMin = myHypo->GetDiamMin() ;
2570 MESSAGE ( ". DiamMin = " << DiamMin );
2571 int AdapInit = myHypo->GetAdapInit();
2572 MESSAGE ( ". AdapInit = " << AdapInit );
2573 int LevelOutput = myHypo->GetLevelOutput();
2574 MESSAGE ( ". LevelOutput = " << LevelOutput );
2575 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2577 // E.7. Ajout des informations sur le deroulement de l'execution
2578 int MessInfo = myIteration->GetInfoCompute();
2579 MESSAGE ( ". MessInfo = " << MessInfo );
2580 myDriver->TexteInfoCompute(MessInfo);
2584 //=============================================================================
2585 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2586 // nomrep : nom du repertoire parent
2587 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2588 //=============================================================================
2589 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2591 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2592 // On verifie que le repertoire parent existe
2593 int codret = chdir(nomrep) ;
2596 SALOME::ExceptionStruct es;
2597 es.type = SALOME::BAD_PARAM;
2598 es.text = "The directory of the case does not exist.";
2599 throw SALOME::SALOME_Exception(es);
2602 std::string nomDirActuel = getenv("PWD") ;
2603 std::string DirName ;
2604 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2605 bool a_chercher = true ;
2606 while ( a_chercher )
2608 // On passe dans le repertoire parent
2610 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2612 if ( num < 100 ) { jaux = 2 ; }
2613 else if ( num < 1000 ) { jaux = 3 ; }
2614 else if ( num < 10000 ) { jaux = 4 ; }
2615 else if ( num < 100000 ) { jaux = 5 ; }
2617 std::ostringstream iaux ;
2618 iaux << std::setw(jaux) << std::setfill('0') << num ;
2619 std::ostringstream DirNameA ;
2620 DirNameA << "I" << iaux.str();
2621 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2622 // que c'est bien un probleme d'absence
2623 if ( chdir(DirNameA.str().c_str()) != 0 )
2625 bool existe = false ;
2627 struct dirent *dirp;
2628 dp = opendir(nomrep);
2629 while ( (dirp = readdir(dp)) != NULL )
2631 std::string file_name(dirp->d_name);
2632 if ( file_name == DirNameA.str() ) { existe = true ; }
2637 DirName = DirNameA.str() ;
2638 a_chercher = false ;
2645 MESSAGE ( "==> DirName = " << DirName);
2646 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2647 chdir(nomDirActuel.c_str());
2649 return CORBA::string_dup( DirName.c_str() );
2651 //=============================================================================
2652 // Calcul d'une iteration : gestion du repertoire de calcul
2653 // Si le sous-repertoire existe :
2654 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2655 // etatMenage = 1 : on fait le menage du repertoire
2656 // etatMenage = -1 : on ne fait rien
2657 //=============================================================================
2658 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2660 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2661 // B.2. Le repertoire du cas
2662 const char* nomDirCase = myCase->GetDirName();
2663 MESSAGE ( ". nomDirCase = " << nomDirCase );
2665 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2666 // B.3.1. Le nom du sous-repertoire
2667 const char* nomDirIt = myIteration->GetDirNameLoc();
2669 // B.3.2. Le nom complet du sous-repertoire
2670 std::stringstream DirCompute ;
2671 DirCompute << nomDirCase << "/" << nomDirIt;
2672 MESSAGE (". DirCompute = " << DirCompute.str() );
2674 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2675 if (chdir(DirCompute.str().c_str()) != 0)
2677 // Creation du repertoire car il n'existe pas :
2678 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2680 // GERALD -- QMESSAGE BOX
2681 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2682 ASSERT("Pb a la creation du repertoire" == 0);
2687 // Le repertoire existe
2688 // On demande de faire le menage de son contenu :
2689 if (etatMenage == 1)
2691 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2692 std::string commande= "rm -rf " + DirCompute.str()+"/*" ;
2693 int codret = system(commande.c_str());
2696 // GERALD -- QMESSAGE BOX
2697 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2698 ASSERT("Pb au menage du repertoire de calcul" == 0);
2701 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2704 if (etatMenage == 0)
2707 struct dirent *dirp;
2708 dp = opendir(DirCompute.str().c_str());
2710 while ((dirp = readdir(dp)) != NULL && result )
2712 std::string file_name(dirp->d_name);
2713 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2716 if ( result == false)
2718 SALOME::ExceptionStruct es;
2719 es.type = SALOME::BAD_PARAM;
2720 std::string text = "Directory : " + DirCompute.str() + "is not empty";
2721 es.text = CORBA::string_dup(text.c_str());
2722 throw SALOME::SALOME_Exception(es);
2723 ASSERT("Directory is not empty" == 0);
2729 return CORBA::string_dup( DirCompute.str().c_str() );
2731 //=============================================================================
2732 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2733 //=============================================================================
2734 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2736 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2737 // Le repertoire du cas
2738 const char* nomDirCase = myCase->GetDirName();
2739 MESSAGE ( ". nomDirCase = " << nomDirCase );
2741 // Le sous-repertoire de l'iteration precedente
2743 const char* nomIterationParent = myIteration->GetIterParentName();
2744 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2745 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
2746 std::stringstream DirComputePa ;
2747 DirComputePa << nomDirCase << "/" << nomDirItPa;
2748 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2749 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2751 return CORBA::string_dup( DirComputePa.str().c_str() );
2753 //=============================================================================
2754 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2755 //=============================================================================
2756 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2758 MESSAGE ( "... DriverTexteZone" );
2759 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2760 int numberOfZonesx2 = ListZone->length();
2763 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2765 std::string ZoneName = std::string((*ListZone)[iaux]);
2766 MESSAGE ( "... ZoneName = " << ZoneName);
2767 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
2768 ASSERT(!CORBA::is_nil(myZone));
2770 int ZoneType = myZone->GetType();
2771 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
2772 int TypeUse = atoi( TypeUsestr.c_str() );
2773 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
2774 NumZone = iaux/2 + 1 ;
2775 HOMARD::double_array* zone = myZone->GetCoords();
2776 if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
2777 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
2778 else if ( ZoneType == 4 ) // Cas d une sphere
2779 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
2780 else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
2781 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
2782 else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
2783 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
2784 else { ASSERT("ZoneType est incorrect." == 0) ; }
2789 //=============================================================================
2790 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
2791 //=============================================================================
2792 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2794 MESSAGE ( "... DriverTexteField" );
2795 // Le fichier du champ
2796 char* FieldFile = myIteration->GetFieldFile();
2797 MESSAGE ( ". FieldFile = " << FieldFile );
2798 if (strlen(FieldFile) == 0)
2800 // GERALD -- QMESSAGE BOX
2801 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2802 ASSERT("The file for the field is not given." == 0);
2804 // Les caracteristiques d'instants
2805 int TimeStep = myIteration->GetTimeStep();
2806 MESSAGE( ". TimeStep = " << TimeStep );
2807 int Rank = myIteration->GetRank();
2808 MESSAGE( ". Rank = " << Rank );
2809 // Les informations sur les champs
2810 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
2812 const char* FieldName = aInfosHypo->FieldName;
2814 int TypeThR = aInfosHypo->TypeThR;
2815 double ThreshR = aInfosHypo->ThreshR;
2816 int TypeThC = aInfosHypo->TypeThC;
2817 double ThreshC = aInfosHypo->ThreshC;
2818 // Saut entre mailles ou non ?
2819 int UsField = aInfosHypo->UsField;
2820 MESSAGE( ". UsField = " << UsField );
2821 // L'usage des composantes
2822 int UsCmpI = aInfosHypo->UsCmpI;
2823 MESSAGE( ". UsCmpI = " << UsCmpI );
2825 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
2828 HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp();
2829 int numberOfCompos = mescompo->length();
2830 MESSAGE( ". numberOfCompos = " << numberOfCompos );
2831 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
2833 std::string nomCompo = std::string((*mescompo)[NumeComp]);
2834 MESSAGE( "... nomCompo = " << nomCompo );
2835 myDriver->TexteCompo(NumeComp, nomCompo);
2839 //=============================================================================
2840 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
2841 //=============================================================================
2842 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
2844 MESSAGE ( "... DriverTexteBoundary" );
2845 // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
2846 std::list<std::string> ListeBoundaryTraitees ;
2847 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
2848 int numberOfitems = ListBoundaryGroupType->length();
2849 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
2850 int BoundaryOption = 1 ;
2851 int NumBoundaryAnalytical = 0 ;
2852 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2854 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2855 MESSAGE ( "... BoundaryName = " << BoundaryName);
2857 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
2858 while (it != ListeBoundaryTraitees.end())
2860 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
2861 if ( BoundaryName == *it ) { A_faire = 0 ; }
2866 // Caracteristiques de la frontiere
2867 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2868 ASSERT(!CORBA::is_nil(myBoundary));
2869 int BoundaryType = myBoundary->GetType();
2870 MESSAGE ( "... BoundaryType = " << BoundaryType );
2871 // Ecriture selon le type
2872 if (BoundaryType == 0) // Cas d une frontiere discrete
2874 const char* MeshName = myBoundary->GetMeshName() ;
2875 const char* MeshFile = myBoundary->GetMeshFile() ;
2876 myDriver->TexteBoundaryDi( MeshName, MeshFile);
2877 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; }
2879 else // Cas d une frontiere analytique
2881 NumBoundaryAnalytical++ ;
2882 HOMARD::double_array* coor = myBoundary->GetCoords();
2883 if (BoundaryType == 1) // Cas d un cylindre
2885 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2886 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2888 else if (BoundaryType == 2) // Cas d une sphere
2890 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
2891 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2893 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
2895 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2896 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2898 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
2900 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
2901 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2904 // Memorisation du traitement
2905 ListeBoundaryTraitees.push_back( BoundaryName );
2908 NumBoundaryAnalytical = 0 ;
2909 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2911 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2912 MESSAGE ( "... BoundaryName = " << BoundaryName);
2913 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2914 ASSERT(!CORBA::is_nil(myBoundary));
2915 int BoundaryType = myBoundary->GetType();
2916 MESSAGE ( "... BoundaryType = " << BoundaryType );
2917 // Recuperation du nom du groupe
2918 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
2919 MESSAGE ( "... GroupName = " << GroupName);
2920 if (BoundaryType == 0) // Cas d une frontiere discrete
2922 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
2924 else // Cas d une frontiere analytique
2926 NumBoundaryAnalytical++ ;
2927 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
2930 myDriver->TexteBoundaryOption(BoundaryOption);
2933 //=============================================================================
2934 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
2935 //=============================================================================
2936 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2938 MESSAGE ( "... DriverTexteFieldInterp" );
2939 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
2940 if (TypeFieldInterp != 0)
2942 // Le fichier des champs
2943 char* FieldFile = myIteration->GetFieldFile();
2944 MESSAGE ( ". FieldFile = " << FieldFile );
2945 if (strlen(FieldFile) == 0)
2947 // GERALD -- QMESSAGE BOX
2948 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2949 ASSERT("The file for the field is not given." == 0);
2951 // Les caracteristiques d'instants
2952 int TimeStep = myIteration->GetTimeStep();
2953 MESSAGE( ". TimeStep = " << TimeStep );
2954 int Rank = myIteration->GetRank();
2955 MESSAGE( ". Rank = " << Rank );
2957 const char* MeshFile = myIteration->GetMeshFile();
2958 myDriver->TexteFieldInterp(TypeFieldInterp, FieldFile, MeshFile, TimeStep, Rank);
2960 if (TypeFieldInterp == 2)
2962 HOMARD::listFieldInterpHypo* meschamps = myHypo->GetListFieldInterp();
2963 int numberOfFields = meschamps->length();
2964 MESSAGE( ". numberOfFields = " << numberOfFields );
2965 for (int NumeChamp = 0; NumeChamp< numberOfFields; NumeChamp++)
2967 std::string nomChamp = std::string((*meschamps)[NumeChamp]);
2968 MESSAGE( "... nomChamp = " << nomChamp );
2969 myDriver->TexteFieldInterpName(NumeChamp, nomChamp);
2975 //===========================================================================
2976 //===========================================================================
2979 //===========================================================================
2980 //===========================================================================
2982 //===========================================================================
2983 //===========================================================================
2984 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
2985 SALOMEDS::SObject_ptr theSObject,
2986 CORBA::Object_ptr theObject,
2987 const char* theName)
2989 MESSAGE("PublishInStudy pour " << theName);
2990 SALOMEDS::SObject_var aResultSO;
2991 if (CORBA::is_nil(theStudy))
2993 SALOME::ExceptionStruct es;
2994 es.type = SALOME::BAD_PARAM;
2995 es.text = "Invalid study context";
2996 throw SALOME::SALOME_Exception(es);
3000 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
3001 // Rq : Iteration est publiee ailleurs
3002 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
3003 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
3004 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
3005 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject);
3006 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
3008 addInStudy(theStudy);
3010 // Controle de la non publication d'un objet de meme nom
3011 if ( (!aBoundary->_is_nil()) or (!aHypo->_is_nil()) or (!aYACS->_is_nil()) or (!aZone->_is_nil()) )
3013 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
3014 if (listSO->length() >= 1)
3016 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
3017 aResultSO = listSO[0];
3018 return aResultSO._retn();
3022 // Caracteristiques de l'etude
3023 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
3024 aStudyBuilder->NewCommand();
3025 if(!aBoundary->_is_nil())
3026 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
3027 else if(!aCase->_is_nil())
3028 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
3029 else if(!aHypo->_is_nil())
3030 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
3031 else if(!aZone->_is_nil())
3032 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
3033 else if(!aYACS->_is_nil())
3034 aResultSO = PublishYACSInStudy(theStudy, aStudyBuilder, aYACS, theName);
3036 aStudyBuilder->CommitCommand();
3038 return aResultSO._retn();
3040 //=============================================================================
3041 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3042 SALOMEDS::StudyBuilder_var aStudyBuilder,
3043 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3045 MESSAGE("PublishBoundaryStudy pour "<<theName);
3046 SALOMEDS::SObject_var aResultSO;
3048 // Caracteristique de la Boundary
3049 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3051 // On recupere le module pere dans l etude
3052 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3053 if (theFatherHomard->_is_nil())
3055 MESSAGE("theFatherHomard->_is_nil()");
3056 return aResultSO._retn();
3059 // On ajoute la categorie des boundarys dans l etude si necessaire
3060 if ( _tag_boun == 0 )
3063 _tag_boun = _tag_gene ;
3065 MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun );
3066 SALOMEDS::SObject_var aSObject;
3067 if (!theFatherHomard->FindSubObject(_tag_boun, aSObject))
3069 MESSAGE("Ajout de la categorie des boundarys");
3070 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun);
3071 PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3073 else { MESSAGE("La categorie des boundarys existe deja."); }
3075 CORBA::Long BoundaryType = myBoundary->GetType();
3076 // MESSAGE("BoundaryType : "<<BoundaryType);
3079 switch (BoundaryType)
3082 { value = "BoundaryDiHomard" ;
3083 icone = "mesh_tree_mesh.png" ;
3087 { value = "BoundaryAnHomard" ;
3088 icone = "cylinderpointvector_2.png" ;
3092 { value = "BoundaryAnHomard" ;
3093 icone = "spherepoint_2.png" ;
3097 { value = "BoundaryAnHomard" ;
3098 icone = "conepointvector.png" ;
3102 { value = "BoundaryAnHomard" ;
3103 icone = "conedxyz.png" ;
3107 aResultSO = aStudyBuilder->NewObject(aSObject);
3108 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3109 return aResultSO._retn();
3111 //=============================================================================
3112 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
3113 SALOMEDS::StudyBuilder_var aStudyBuilder,
3114 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
3116 MESSAGE("PublishCaseInStudy pour "<<theName);
3117 SALOMEDS::SObject_var aResultSO;
3119 if (CORBA::is_nil(theObject)) {
3120 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
3121 return aResultSO._retn();
3123 if (theStudy->_is_nil()) {
3124 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
3125 return aResultSO._retn();
3128 // On recupere le module pere dans l etude
3129 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3130 if (theFatherHomard->_is_nil())
3132 MESSAGE("theFatherHomard->_is_nil()");
3133 return aResultSO._retn();
3137 MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene );
3138 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
3139 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
3140 _orb->object_to_string(theObject) ) ;
3142 return aResultSO._retn();
3144 //=============================================================================
3145 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3146 SALOMEDS::StudyBuilder_var aStudyBuilder,
3147 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3149 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3150 SALOMEDS::SObject_var aResultSO;
3152 // On recupere le module pere dans l etude
3153 // On ajoute la categorie des hypotheses dans l etude si necessaire
3154 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3155 if (theFatherHomard->_is_nil())
3157 MESSAGE("theFatherHomard->_is_nil()");
3158 return aResultSO._retn();
3161 // On ajoute la categorie des hypotheses dans l etude si necessaire
3162 SALOMEDS::SObject_var aSObject;
3163 if ( _tag_hypo == 0 )
3166 _tag_hypo = _tag_gene ;
3168 MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo );
3169 if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject))
3171 MESSAGE("Ajout de la categorie des hypotheses");
3172 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo);
3173 PublishInStudyAttr(aStudyBuilder, aSObject, "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(aSObject);
3179 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3181 return aResultSO._retn();
3183 //=============================================================================
3184 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theStudy,
3185 SALOMEDS::StudyBuilder_var aStudyBuilder,
3186 HOMARD::HOMARD_YACS_ptr theObject, const char* theName)
3188 MESSAGE("PublishYACSInStudy pour "<<theName);
3189 SALOMEDS::SObject_var aResultSO;
3191 // On recupere le module pere dans l etude
3192 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3193 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3194 if (theFatherHomard->_is_nil())
3196 MESSAGE("theFatherHomard->_is_nil()");
3197 return aResultSO._retn();
3199 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3200 if ( _tag_yacs == 0 )
3203 _tag_yacs = _tag_gene ;
3205 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs );
3206 SALOMEDS::SObject_var aSObject;
3207 if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject))
3209 MESSAGE("Ajout de la categorie des schemas YACS");
3210 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs);
3211 PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL);
3213 else { MESSAGE("La categorie des schemas YACS existe deja."); }
3215 // Creation du resultat dans l'etude
3216 aResultSO = aStudyBuilder->NewObject(aSObject);
3217 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ;
3219 return aResultSO._retn();
3222 //=============================================================================
3223 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
3224 SALOMEDS::StudyBuilder_var aStudyBuilder,
3225 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3227 MESSAGE("PublishZoneStudy pour "<<theName);
3228 SALOMEDS::SObject_var aResultSO;
3229 if (CORBA::is_nil(theObject))
3231 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3232 return aResultSO._retn();
3234 if (theStudy->_is_nil())
3236 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
3237 return aResultSO._retn();
3239 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3240 if (theFatherHomard->_is_nil())
3242 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3243 return aResultSO._retn();
3246 // Caracteristique de la zone
3247 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3248 CORBA::Long ZoneType = myZone->GetType();
3250 // On ajoute la categorie des zones dans l etude si necessaire
3251 if ( _tag_zone == 0 )
3254 _tag_zone = _tag_gene ;
3256 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone );
3257 SALOMEDS::SObject_var aSObject;
3258 if (!theFatherHomard->FindSubObject(_tag_zone, aSObject))
3260 MESSAGE("Ajout de la categorie des zones");
3261 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone);
3262 PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3264 else { MESSAGE("La categorie des zones existe deja."); }
3266 aResultSO = aStudyBuilder->NewObject(aSObject);
3275 { icone = "boxdxy_2.png" ;
3279 { icone = "boxdxyz_2.png" ;
3287 { icone = "disk_2.png" ;
3291 { icone = "spherepoint_2.png" ;
3295 { icone = "cylinderpointvector_2.png" ;
3303 { icone = "diskwithhole_2.png" ;
3307 { icone = "pipe_2.png" ;
3311 MESSAGE("Appel de PublishInStudyAttr pour name = "<<theName);
3312 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3314 return aResultSO._retn();
3316 //===========================================================================
3317 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3318 SALOMEDS::SObject_var aResultSO,
3319 const char* name, const char* value, const char* icone, const char* ior)
3321 MESSAGE("PublishInStudyAttr pour name = "<<name);
3322 MESSAGE("value = "<<value);
3323 // MESSAGE("icone = "<<icone);
3324 // MESSAGE("ior = "<<ior);
3325 SALOMEDS::GenericAttribute_var anAttr ;
3329 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3330 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3331 aNameAttrib->SetValue(name);
3334 // Ajout du commentaire
3335 if ( value != NULL )
3337 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3338 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3339 aCommentAttrib->SetValue(value);
3343 if ( icone != NULL )
3345 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
3346 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3347 aPixmap->SetPixMap(icone);
3353 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3354 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3355 anIOR->SetValue(ior);
3359 //=====================================================================================
3360 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3362 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3364 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3365 ASSERT(!CORBA::is_nil(myCase));
3366 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3367 ASSERT(!CORBA::is_nil(aCaseSO));
3369 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3370 ASSERT(!CORBA::is_nil(myBoundary));
3371 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3372 ASSERT(!CORBA::is_nil(aBoundarySO));
3374 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3376 aStudyBuilder->NewCommand();
3378 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3379 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3381 aStudyBuilder->CommitCommand();
3384 //=============================================================================
3385 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3386 // Option = 0 : fichier issu d'une importation
3387 // Option = 1 : fichier issu d'une execution HOMARD
3389 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3390 if (CORBA::is_nil(myCurrentStudy))
3392 SALOME::ExceptionStruct es;
3393 es.type = SALOME::BAD_PARAM;
3394 es.text = "Invalid study context";
3395 throw SALOME::SALOME_Exception(es);
3399 // Le module SMESH est-il actif ?
3400 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3402 if (!CORBA::is_nil(aSmeshSO))
3404 // On verifie que le fichier n est pas deja publie
3405 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3406 for (; aIter->More(); aIter->Next())
3408 SALOMEDS::SObject_var aSO = aIter->Value();
3409 SALOMEDS::GenericAttribute_var aGAttr;
3410 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3412 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3413 CORBA::String_var value=anAttr->Value();
3414 if (strcmp((const char*)value,NomFich) == 0)
3416 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3417 // Pour un fichier importe, on ne republie pas
3422 // Pour un fichier calcule, on commence par faire la depublication
3425 MESSAGE ( "PublishResultInSmesh : depublication" );
3426 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3427 CORBA::String_var value2=anAttr2->Value();
3428 std::string MeshName = string(value2) ;
3429 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3430 DeleteResultInSmesh(NomFich, MeshName) ;
3437 // On enregistre le fichier
3438 MESSAGE( "Enregistrement du fichier");
3439 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3440 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3441 ASSERT(!CORBA::is_nil(aSmeshEngine));
3442 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3443 SMESH::DriverMED_ReadStatus theStatus;
3444 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3446 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3447 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3448 for (int i = 0; i < mesMaillages->length(); i++)
3450 MESSAGE( ". Mise a jour des attributs du maillage");
3451 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3452 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3453 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3454 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3455 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3456 anAttr->SetValue(NomFich);
3457 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3458 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3460 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3461 else { icone = "mesh_tree_mesh.png" ; }
3462 anAttr2->SetPixMap( icone );
3466 //=============================================================================
3467 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
3469 MESSAGE (" DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3470 if (CORBA::is_nil(myCurrentStudy))
3472 SALOME::ExceptionStruct es;
3473 es.type = SALOME::BAD_PARAM;
3474 es.text = "Invalid study context";
3475 throw SALOME::SALOME_Exception(es);
3479 // Le module SMESH est-il actif ?
3480 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3482 if (CORBA::is_nil(aSmeshSO))
3486 // On verifie que le fichier est deja publie
3487 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3488 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3489 for (; aIter->More(); aIter->Next())
3491 SALOMEDS::SObject_var aSO = aIter->Value();
3492 SALOMEDS::GenericAttribute_var aGAttr;
3493 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3495 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3496 CORBA::String_var value=anAttr->Value();
3497 if (strcmp((const char*)value,NomFich.c_str()) == 0)
3499 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3501 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3502 CORBA::String_var value2=anAttr2->Value();
3503 if (strcmp((const char*)value2,MeshName.c_str()) == 0)
3505 myBuilder->RemoveObjectWithChildren( aSO ) ;
3513 //=============================================================================
3514 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3516 // MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3517 if (CORBA::is_nil(myCurrentStudy))
3519 SALOME::ExceptionStruct es;
3520 es.type = SALOME::BAD_PARAM;
3521 es.text = "Invalid study context";
3522 throw SALOME::SALOME_Exception(es);
3526 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3527 if (CORBA::is_nil(myIteration))
3529 SALOME::ExceptionStruct es;
3530 es.type = SALOME::BAD_PARAM;
3531 es.text = "Invalid iteration";
3532 throw SALOME::SALOME_Exception(es);
3535 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3536 if (CORBA::is_nil(myIteration))
3538 SALOME::ExceptionStruct es;
3539 es.type = SALOME::BAD_PARAM;
3540 es.text = "Invalid iterationStudy Object";
3541 throw SALOME::SALOME_Exception(es);
3545 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3547 aStudyBuilder->NewCommand();
3549 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3550 // Pour les fichiers med, on affiche une icone de maillage
3551 // Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte'
3552 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3554 std::string ior = " " ;
3555 if ( Commentaire[0] == 'I' )
3556 { icone = "med.png" ; }
3558 { icone = "texte_2.png" ; }
3559 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3561 aStudyBuilder->CommitCommand();
3564 //=============================================================================
3565 //=============================================================================
3567 //=============================================================================
3568 //=============================================================================
3569 //=============================================================================
3570 // Creation d'un schema YACS
3571 // nomCas : nom du cas a traiter
3572 // FileName : nom du fichier contenant le script de lancement du calcul
3573 // DirName : le repertoire de lancement des calculs du schéma
3574 //=============================================================================
3575 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* YACSName, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
3577 INFOS ( "CreateYACSSchema : Schema YACS " << YACSName );
3578 INFOS ( ". nomCas : " << nomCas);
3579 INFOS ( ". ScriptFile : " << ScriptFile);
3580 INFOS ( ". DirName : " << DirName);
3581 INFOS ( ". MeshFile : " << MeshFile);
3583 // A. Controle du nom :
3584 if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(YACSName) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end())
3586 SALOME::ExceptionStruct es;
3587 es.type = SALOME::BAD_PARAM;
3588 es.text = "This schema YACS has already been defined.";
3589 throw SALOME::SALOME_Exception(es);
3593 // B. Creation de l'objet
3594 HOMARD::HOMARD_YACS_var myYACS = newYACS();
3595 if (CORBA::is_nil(myYACS))
3597 SALOME::ExceptionStruct es;
3598 es.type = SALOME::BAD_PARAM;
3599 es.text = "Unable to create the schema YACS";
3600 throw SALOME::SALOME_Exception(es);
3603 myYACS->SetName( YACSName ) ;
3605 // C. Enregistrement
3606 myContextMap[GetCurrentStudyID()]._mesYACSs[YACSName] = myYACS;
3608 SALOMEDS::SObject_var aSO;
3609 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, YACSName);
3611 // D. Caracterisation
3612 myYACS->SetDirName( DirName ) ;
3613 myYACS->SetMeshFile( MeshFile ) ;
3614 myYACS->SetScriptFile( ScriptFile ) ;
3615 myYACS->SetCaseName( nomCas ) ;
3616 myYACS->SetType( 1 ) ;
3618 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
3620 //=============================================================================
3621 // Ecriture d'un schema YACS
3622 //=============================================================================
3623 CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* YACSFile)
3625 INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << YACSFile );
3632 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3633 ASSERT(!CORBA::is_nil(myYACS));
3634 // B.2. Les caracteristiques
3635 std::string DirName = myYACS->GetDirName() ;
3636 std::string MeshFile = myYACS->GetMeshFile() ;
3637 std::string ScriptFile = myYACS->GetScriptFile() ;
3641 const char* nomCas = myYACS->GetCaseName();
3642 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
3643 ASSERT(!CORBA::is_nil(myCase));
3644 // C.2. Les instructions python associees au cas
3645 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
3646 std::string pythonCas = dumpCorbaCase.in();
3647 MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
3649 // D. Les iterations
3650 // D.1. L'iteration initiale
3651 HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
3652 std::string Iter0Name = myCase->GetIter0Name() ;
3653 MESSAGE (". Iter0Name = " << Iter0Name);
3654 // D.2. L'iteration numero 1
3655 HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
3656 int numberOfIter = maListe->length();
3657 if ( numberOfIter > 1 )
3659 MESSAGE (". numberOfIter = " << numberOfIter);
3660 SALOME::ExceptionStruct es ;
3661 es.type = SALOME::BAD_PARAM;
3662 std::string text = "Une seule iteration est permise." ;
3663 es.text = CORBA::string_dup(text.c_str());
3664 throw SALOME::SALOME_Exception(es);
3667 std::string Iter1Name = std::string((*maListe)[0]);
3668 MESSAGE ("... Iter1Name = " << Iter1Name);
3669 HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
3670 MESSAGE (". Iter1 = " << Iter1);
3672 // E. L'hypothese pour passer de l'iteration initiale a la suivante
3673 // E.1. La structure
3674 std::string nomHypo = Iter1->GetHypoName();
3675 MESSAGE (". nomHypo = " << nomHypo);
3676 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
3677 ASSERT(!CORBA::is_nil(myHypo));
3678 // E.2. Les caracteristiques de l'adaptation
3679 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
3680 ASSERT(ListTypes->length() == 3);
3681 int TypeAdap = (*ListTypes)[0];
3682 // int TypeRaff = (*ListTypes)[1];
3683 // int TypeDera = (*ListTypes)[2];
3684 // E.3. Les instructions python associees a l'hypothese
3685 CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
3686 std::string pythonHypo = dumpCorbaHypo.in();
3687 MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
3689 // F. Le fichier du schema de reference
3690 // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD
3691 std::string YACSFile_base ;
3692 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { YACSFile_base = getenv("HOMARD_ROOT_DIR") ; }
3693 else { ASSERT("HOMARD_ROOT_DIR est inconnu." == 0) ; }
3694 YACSFile_base += "/share/salome/resources/homard/yacs_01.xml" ;
3695 MESSAGE("YACSFile_base ="<<YACSFile_base);
3697 // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
3698 YACSDriver* myDriver = new YACSDriver(YACSFile, DirName);
3699 std::ifstream fichier( YACSFile_base.c_str() );
3700 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
3702 // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
3703 std::string ligne; // variable contenant chaque ligne lue
3704 std::string mot_cle;
3705 while ( std::getline( fichier, ligne ) )
3707 // G.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
3708 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
3709 ligne_bis >> mot_cle ;
3710 // G.1.2. Le maillage initial
3711 if ( mot_cle == "DataInit_MeshFile" )
3713 myDriver->Texte_DataInit_MeshFile(MeshFile);
3715 // G.1.3. Le script de lancement
3716 else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
3718 myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile);
3720 // G.1.4. Les options du cas
3721 else if ( mot_cle == "HOMARD_Init_au_debut_Case_Options" )
3723 myDriver->Texte_HOMARD_Init_au_debut_Case_Options(pythonCas);
3725 // G.1.5. Execution de HOMARD : le repertoire du cas
3726 else if ( mot_cle == "HOMARD_Exec_DirName" )
3728 myDriver->Texte_HOMARD_Exec_DirName();
3730 // G.1.6. Execution de HOMARD : les options de l'hypothese
3731 else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
3733 myDriver->Texte_python( pythonHypo, 3, "Hypo" ) ;
3735 // G.1.7. Zones et frontieres : les creations
3736 else if ( mot_cle == "HOMARD_Init_au_debut" )
3738 std::string texte_control = myDriver->Texte_HOMARD_Init_au_debut_control() ;
3739 if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; }
3740 texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ;
3741 myDriver->TexteAdd(texte_control);
3743 // G.1.8. Zones : les parametres
3744 else if ( mot_cle == "PARAMETRES" )
3746 if ( TypeAdap == 0 )
3747 { myDriver->TexteAddParametres(); }
3749 // G.1.n. La ligne est recopiee telle quelle
3752 myDriver->TexteAdd(ligne);
3755 // G.2. Ecriture du texte dans le fichier
3757 { myDriver->CreeFichier(); }
3761 SALOME::ExceptionStruct es;
3762 es.type = SALOME::BAD_PARAM;
3763 std::string text = "The reference file for the YACS schema cannot be read." ;
3764 es.text = CORBA::string_dup(text.c_str());
3765 throw SALOME::SALOME_Exception(es);
3772 //=============================================================================
3773 // Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
3774 //=============================================================================
3775 std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
3777 MESSAGE ( "YACSDriverTexteZone" );
3778 // A. Les zones associees a cette hypothese
3779 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
3780 int numberOfZonesx2 = ListZone->length();
3782 // B. Parcours des zones
3783 std::string texte_control ;
3784 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
3786 // 1. Reperage de la zone
3787 std::string ZoneName = std::string((*ListZone)[iaux]);
3788 MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
3789 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
3790 ASSERT(!CORBA::is_nil(myZone));
3791 // 2. Les instructions python associees a la zone
3792 // La premiere ligne est un commentaire a eliminer
3793 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
3794 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
3795 std::string pythonStructure_0 = dumpCorbaZone.in();
3796 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
3797 std::istringstream tout (pythonStructure_0) ;
3799 std::string pythonStructure ;
3800 while ( std::getline( tout, ligne ) )
3801 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
3802 MESSAGE ("pythonStructure :\n"<<pythonStructure);
3803 // 3. Decodage du nom du service
3804 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
3805 MESSAGE ( "... methode = " << methode);
3806 // 4. Mise en place des instructions
3807 int ZoneType = myZone->GetType();
3808 MESSAGE ( "... ZoneType = " << ZoneType);
3809 std::string texte_control_0 ;
3810 texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Zone(ZoneType, pythonStructure, methode, ZoneName );
3811 texte_control += texte_control_0 ;
3816 return texte_control ;
3818 //=============================================================================
3819 // Ecriture d'un schema YACS : ecriture des frontieres associees au cas
3820 //=============================================================================
3821 std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver)
3823 MESSAGE ( "YACSDriverTexteBoundary" );
3824 // A. Les frontieres associees au cas
3825 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3826 int numberOfitems = ListBoundaryGroupType->length();
3828 // B. Parcours des frontieres
3829 std::string texte_control ;
3830 std::list<std::string> ListeBoundaryTraitees ;
3831 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3833 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3834 MESSAGE ( "... BoundaryName = " << BoundaryName);
3835 // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver
3836 // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees
3838 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3839 while (it != ListeBoundaryTraitees.end())
3841 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3842 if ( BoundaryName == *it ) { A_faire = 0 ; }
3847 // 1. Caracteristiques de la frontiere
3848 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3849 ASSERT(!CORBA::is_nil(myBoundary));
3850 // 2. Les instructions python associees a la frontiere
3851 // La premiere ligne est un commentaire a eliminer
3852 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
3853 CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython();
3854 std::string pythonStructure_0 = dumpCorbaBoundary.in();
3855 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
3856 std::istringstream tout (pythonStructure_0) ;
3858 std::string pythonStructure ;
3859 while ( std::getline( tout, ligne ) )
3860 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
3861 MESSAGE ("pythonStructure :\n"<<pythonStructure);
3862 // 3. Decodage du nom du service
3863 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
3864 MESSAGE ( "... methode = " << methode);
3865 // 4. Mise en place des instructions
3866 int BoundaryType = myBoundary->GetType();
3867 MESSAGE ( "... BoundaryType = " << BoundaryType);
3868 std::string texte_control_0 ;
3869 texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Boundary(BoundaryType, pythonStructure, methode, BoundaryName );
3870 texte_control += texte_control_0 ;
3871 // 5. Memorisation du traitement
3872 ListeBoundaryTraitees.push_back( BoundaryName );
3876 return texte_control ;
3879 //=============================================================================
3880 //=============================================================================
3881 // Next functions are inherited from SALOMEDS::Driver interface
3882 //=============================================================================
3883 //=============================================================================
3884 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
3886 CORBA::Boolean isMultiFile)
3888 MESSAGE (" Save for theURL = "<< theURL);
3889 SALOMEDS::TMPFile_var aStreamFile;
3891 // get temporary directory name
3892 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3894 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3895 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3897 // HOMARD data file name
3898 std::string aFileName = "";
3900 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3901 aFileName += "_HOMARD.dat";
3903 // initialize sequence of file names
3904 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
3905 aFileSeq->length(1);
3906 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
3908 // get full path to the data file
3909 aFileName = tmpDir + aFileName;
3913 std::ofstream f(aFileName.c_str());
3915 // clear temporary id map
3916 context._idmap.clear();
3921 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
3922 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
3923 HOMARD::HOMARD_Cas_var aCas = it_case->second;
3924 PortableServer::ServantBase_var aServant = GetServant(aCas);
3925 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3927 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
3928 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
3932 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3933 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
3934 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
3935 PortableServer::ServantBase_var aServant = GetServant(aZone);
3936 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3938 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
3939 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3942 // -> save hypotheses
3943 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3944 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
3945 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
3946 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3947 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3949 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
3950 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3953 // -> save iterations
3954 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3955 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
3956 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
3957 PortableServer::ServantBase_var aServant = GetServant(aIter);
3958 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3960 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
3961 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3964 // -> save boundaries
3965 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3966 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
3967 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
3968 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3969 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3970 if (aBoundaryServant) {
3971 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
3972 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3976 MESSAGE ("close file");
3979 // put temporary files to the stream
3980 MESSAGE ("put temporary files to the stream");
3981 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
3983 // remove temporary files
3984 MESSAGE ("remove temporary files");
3985 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3987 // return data stream
3988 MESSAGE ("return data stream");
3989 return aStreamFile._retn();
3992 //===========================================================================
3993 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
3995 CORBA::Boolean isMultiFile)
3997 // No specific ASCII persistence
3998 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
3999 return aStreamFile._retn();
4002 //===========================================================================
4003 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
4004 const SALOMEDS::TMPFile& theStream,
4006 CORBA::Boolean isMultiFile)
4008 MESSAGE (" Load pour theURL = "<< theURL);
4009 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
4011 // set current study
4012 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
4013 SetCurrentStudy(aStudy);
4015 // get temporary directory name
4016 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4018 // Convert the stream into sequence of files to process
4019 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
4022 // HOMARD data file name
4023 std::string aFileName = "";
4025 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
4026 aFileName = tmpDir + aFileName + "_HOMARD.dat";
4028 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4032 std::ifstream f(aFileName.c_str());
4035 context._mesCas.clear();
4036 context._mesHypotheses.clear();
4037 context._mesIterations.clear();
4038 context._mesZones.clear();
4039 context._mesBoundarys.clear();
4040 context._idmap.clear();
4046 std::getline(f, line);
4047 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
4048 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
4049 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
4050 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
4051 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
4052 std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS);
4053 if (line.substr(0, bounSignature.size()) == bounSignature) {
4054 // re-create boundary
4055 MESSAGE (" Recreation de la frontiere" );
4056 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
4057 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4058 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4059 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
4060 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
4061 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4064 else if (line.substr(0, caseSignature.size()) == caseSignature) {
4066 MESSAGE (" Recreation du cas" );
4067 HOMARD::HOMARD_Cas_var aCase = newCase();
4068 PortableServer::ServantBase_var aServant = GetServant(aCase);
4069 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4070 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
4071 context._mesCas[aCase->GetName()] = aCase;
4072 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
4075 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
4076 // re-create hypothesis
4077 MESSAGE (" Recreation de l hypothese" );
4078 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
4079 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4080 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4081 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
4082 context._mesHypotheses[aHypo->GetName()] = aHypo;
4083 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4086 else if (line.substr(0, iterSignature.size()) == iterSignature) {
4087 // re-create iteration
4088 MESSAGE (" Recreation de l iteration" );
4089 HOMARD::HOMARD_Iteration_var aIter = newIteration();
4090 PortableServer::ServantBase_var aServant = GetServant(aIter);
4091 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4092 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
4093 context._mesIterations[aIter->GetName()] = aIter;
4094 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4097 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
4098 MESSAGE (" Recreation de la zone" );
4100 HOMARD::HOMARD_Zone_var aZone = newZone();
4101 PortableServer::ServantBase_var aServant = GetServant(aZone);
4102 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4103 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
4104 context._mesZones[aZone->GetName()] = aZone;
4105 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4108 else if (line.substr(0, zoneSignature.size()) == yacsSignature) {
4109 MESSAGE (" Recreation du schema YACS" );
4111 HOMARD::HOMARD_YACS_var aYACS = newYACS();
4112 PortableServer::ServantBase_var aServant = GetServant(aYACS);
4113 HOMARD_YACS_i* aYACSServant = dynamic_cast<HOMARD_YACS_i*>(aServant.in());
4114 if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) {
4115 context._mesYACSs[aYACS->GetName()] = aYACS;
4116 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aYACSServant);
4125 // Remove temporary files created from the stream
4127 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4132 //===========================================================================
4133 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
4134 const SALOMEDS::TMPFile& theStream,
4136 CORBA::Boolean isMultiFile)
4138 // No specific ASCII persistence
4139 return Load(theComponent, theStream, theURL, isMultiFile);
4142 //===========================================================================
4143 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
4145 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
4146 // clearing study context should be done here:
4147 // - destroy all servants and related CORBA objects
4149 // - remove context from myContextMap
4150 myContextMap.erase(theComponent->GetStudy()->StudyId());
4151 // - nullify myCurrentStudy
4152 myCurrentStudy = SALOMEDS::Study::_nil();
4156 //===========================================================================
4157 char* HOMARD_Gen_i::ComponentDataType()
4159 return CORBA::string_dup("HOMARD");
4162 //===========================================================================
4163 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
4164 const char* IORString,
4165 CORBA::Boolean isMultiFile,
4166 CORBA::Boolean isASCII)
4168 CORBA::String_var aString("");
4169 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
4170 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4171 CORBA::Object_var anObj = _orb->string_to_object(IORString);
4172 if (!CORBA::is_nil(anObj)) {
4173 PortableServer::ServantBase_var aServant = GetServant(anObj);
4174 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
4176 std::map<int, PortableServer::ServantBase*>::const_iterator it;
4177 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
4178 if (it->second == aStorable) {
4179 std::stringstream os;
4181 aString = CORBA::string_dup(os.str().c_str());
4187 return aString._retn();
4190 //===========================================================================
4191 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
4192 const char* aLocalPersistentID,
4193 CORBA::Boolean isMultiFile,
4194 CORBA::Boolean isASCII)
4196 CORBA::String_var aString("");
4197 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
4198 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4199 int id = atoi(aLocalPersistentID);
4200 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
4201 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
4202 if (!CORBA::is_nil(object)) {
4203 aString = _orb->object_to_string(object);
4207 return aString._retn();
4210 //===========================================================================
4211 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
4213 if(CORBA::is_nil(myCurrentStudy))
4216 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
4217 if(!aCas->_is_nil())
4220 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
4221 if(!aHypo->_is_nil())
4224 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
4225 if(!aZone->_is_nil())
4228 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
4229 if(!aBoundary->_is_nil())
4232 /* Iteration is not published directly
4233 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
4234 if(!aIter->_is_nil())
4240 //===========================================================================
4241 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
4243 // No Copy/Paste support
4247 //===========================================================================
4248 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
4249 CORBA::Long& theObjectID)
4251 // No Copy/Paste support
4252 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
4253 return aStreamFile._retn();
4256 //===========================================================================
4257 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
4258 CORBA::Long theObjectID)
4260 // No Copy/Paste support
4264 //===========================================================================
4265 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
4266 CORBA::Long theObjectID,
4267 SALOMEDS::SObject_ptr theSObject)
4269 // No Copy/Paste support
4270 SALOMEDS::SObject_var aResultSO;
4271 return aResultSO._retn();
4274 //===========================================================================
4275 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
4277 PortableServer::Servant aServant = 0;
4278 if (!CORBA::is_nil(theObject)) {
4280 aServant = _poa->reference_to_servant(theObject);
4288 //==========================================================================
4289 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
4290 CORBA::Boolean isPublished,
4291 CORBA::Boolean isMultiFile,
4292 CORBA::Boolean& isValidScript)
4294 MESSAGE ("Entree dans DumpPython");
4296 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
4297 if(CORBA::is_nil(aStudy))
4298 return new Engines::TMPFile(0);
4300 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
4301 if(CORBA::is_nil(aSO))
4302 return new Engines::TMPFile(0);
4304 std::string aScript = "\"\"\"\n";
4305 aScript += "Python script for HOMARD\n";
4306 aScript += "Copyright EDF-R&D 2013\n";
4307 aScript += "\"\"\"\n";
4308 aScript += "__revision__ = \"V1.2\"\n";
4309 aScript += "import HOMARD\n";
4311 aScript += "import salome\n";
4312 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4314 aScript += "def RebuildData(theStudy):\n";
4315 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
4318 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
4319 MESSAGE (". Au depart \n"<<aScript);
4322 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
4324 MESSAGE (". Ecritures des frontieres");
4325 aScript += "#\n# Creation of the boundaries";
4326 aScript += "\n# ==========================";
4328 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4329 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
4330 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
4332 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4333 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4334 std::string dumpBoundary = dumpCorbaBoundary.in();
4335 MESSAGE (dumpBoundary<<"\n");
4336 aScript += dumpBoundary;
4340 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
4342 MESSAGE (". Ecritures des zones");
4343 aScript += "#\n# Creation of the zones";
4344 aScript += "\n# =====================";
4346 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4347 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
4348 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
4350 HOMARD::HOMARD_Zone_var maZone = (*it_zone).second;
4351 CORBA::String_var dumpCorbaZone = maZone->GetDumpPython();
4352 std::string dumpZone = dumpCorbaZone.in();
4353 MESSAGE (dumpZone<<"\n");
4354 aScript += dumpZone;
4358 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
4360 MESSAGE (". Ecritures des hypotheses");
4361 aScript += "#\n# Creation of the hypotheses";
4362 aScript += "\n# ==========================";
4364 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4365 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
4366 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
4368 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4369 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4370 std::string dumpHypo = dumpCorbaHypo.in();
4371 MESSAGE (dumpHypo<<"\n");
4372 aScript += dumpHypo;
4376 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
4378 MESSAGE (". Ecritures des cas");
4379 aScript += "#\n# Creation of the cases";
4380 aScript += "\n# =====================";
4382 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4383 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4384 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
4386 std::string nomCas = (*it_cas).first;
4387 std::string dumpCas = std::string("\n# Creation of the case ") ;
4388 dumpCas += nomCas + std::string("\n");
4389 dumpCas += std::string("\t") + nomCas;
4390 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4392 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4393 CORBA::String_var cIter0= myCase->GetIter0Name();
4394 std::string iter0 = cIter0.in();
4396 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
4397 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4398 std::string mesh0 = cMesh0.in();
4399 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4400 std::string meshName0 = cMeshName0.in();
4401 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4402 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4403 std::string dumpCas2= dumpCorbaCase.in();
4405 MESSAGE (dumpCas<<dumpCas2<<"\n");
4406 aScript += dumpCas + dumpCas2;
4410 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
4412 MESSAGE (". Ecritures des iterations");
4413 aScript += "#\n# Creation of the iterations" ;
4414 aScript += "\n# ==========================";
4416 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4417 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
4418 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
4420 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4421 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4422 std::string dumpIter = dumpCorbaIter.in();
4423 MESSAGE (dumpIter<<"\n");
4424 aScript += dumpIter;
4427 MESSAGE (". Ecritures finales");
4429 aScript += "\n\tpass";
4432 if( !isMultiFile ) // remove unnecessary tabulation
4433 aScript = RemoveTabulation( aScript );
4435 // MESSAGE ("A ecrire \n"<<aScript);
4436 const size_t aLen = strlen(aScript.c_str());
4437 char* aBuffer = new char[aLen+1];
4438 strcpy(aBuffer, aScript.c_str());
4440 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4441 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4443 MESSAGE ("Sortie de DumpPython");
4444 return aStreamFile._retn();
4448 //=============================================================================
4449 //=============================================================================
4451 //=============================================================================
4452 //=============================================================================
4453 void HOMARD_Gen_i::IsValidStudy( )
4455 // MESSAGE( "IsValidStudy" );
4456 if (CORBA::is_nil(myCurrentStudy))
4458 SALOME::ExceptionStruct es;
4459 es.type = SALOME::BAD_PARAM;
4460 es.text = "Invalid study context";
4461 throw SALOME::SALOME_Exception(es);
4466 //=============================================================================
4467 CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir)
4469 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4470 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4471 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
4473 if (std::string(nomDir) == std::string(it->second->GetDirName())) return false;
4477 /*//=============================================================================
4478 void SALOMEException( std::string message )
4480 SALOME::ExceptionStruct es;
4481 es.type = SALOME::BAD_PARAM;
4483 throw SALOME::SALOME_Exception(es);
4486 //=============================================================================
4487 char* HOMARD_Gen_i::getVersion()
4489 #if HOMARD_DEVELOPMENT
4490 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4492 return CORBA::string_dup(HOMARD_VERSION_STR);
4495 //===============================================================================
4496 // Recuperation de la chaine de caracteres par rapport l'apparition d'un texte
4497 // ligne : la ligne a manipuler
4498 // texte : le texte a reperer
4499 // option : 0 : la chaine avant le texte
4500 // 1 : la chaine apres le texte
4501 // Si le texte est absent, on retourne la chaine totale
4502 //===============================================================================
4503 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string texte, int option )
4505 // MESSAGE("GetStringInTexte, recherche de '"<<texte<<"' dans '"<<ligne<<"'"<<", option = "<<option);
4507 std::string chaine = ligne ;
4508 int position = ligne.find_first_of( texte ) ;
4511 if ( option == 0 ) { chaine = ligne.substr( 0, position ) ; }
4512 else { chaine = ligne.substr( position+1 ) ; }
4514 // Conversion de type
4519 //=============================================================================
4522 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
4523 PortableServer::POA_ptr poa,
4524 PortableServer::ObjectId* contId,
4525 const char* instanceName,
4526 const char* interfaceName)
4528 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
4529 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
4530 return myHOMARD_Gen->getId();