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"
33 #include "HOMARD_version.h"
35 #include "utilities.h"
36 #include "Utils_SINGLETON.hxx"
37 #include "Utils_CorbaException.hxx"
38 #include "SALOMEDS_Tool.hxx"
39 #include "SALOME_LifeCycleCORBA.hxx"
40 #include "SALOMEconfig.h"
41 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
42 #include CORBA_CLIENT_HEADER(SMESH_Gen)
65 //=============================================================================
67 //=============================================================================
68 std::string RemoveTabulation( std::string theScript )
70 std::string::size_type aPos = 0;
71 while( aPos < theScript.length() )
73 aPos = theScript.find( "\n\t", aPos );
74 if( aPos == std::string::npos )
76 theScript.replace( aPos, 2, "\n" );
81 //=============================================================================
83 * standard constructor
85 //=============================================================================
86 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
87 PortableServer::POA_ptr poa,
88 PortableServer::ObjectId * contId,
89 const char *instanceName,
90 const char *interfaceName) :
91 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
93 MESSAGE("constructor");
95 _id = _poa->activate_object(_thisObj);
97 myHomard = new ::HOMARD_Gen();
98 _NS = SINGLETON_<SALOME_NamingService>::Instance();
99 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
110 //=================================
112 * standard destructor
114 //================================
115 HOMARD_Gen_i::~HOMARD_Gen_i()
118 //=============================================================================
119 //=============================================================================
120 // Utilitaires pour l'étude
121 //=============================================================================
122 //=============================================================================
123 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
125 ASSERT(!CORBA::is_nil(theStudy));
126 MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
127 SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
129 // Create SComponent labelled 'homard' if it doesn't already exit
130 SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
131 if (CORBA::is_nil(homardFather))
133 myBuilder->NewCommand();
134 MESSAGE("Add Component HOMARD");
136 bool aLocked = theStudy->GetProperties()->IsLocked();
137 if (aLocked) theStudy->GetProperties()->SetLocked(false);
139 homardFather = myBuilder->NewComponent(ComponentDataType());
140 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
141 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
142 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
143 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
144 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
145 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
146 if (!Comp->_is_nil())
148 aName->SetValue(ComponentDataType());
151 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
152 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
153 aPixmap->SetPixMap("HOMARD_2.png");
154 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
156 if (aLocked) theStudy->GetProperties()->SetLocked(true);
157 myBuilder->CommitCommand();
160 //=============================================================================
161 void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
163 MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID());
164 myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy);
165 this->addInStudy(myCurrentStudy);
167 //=============================================================================
168 SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
169 //=============================================================================
171 MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID());
172 return SALOMEDS::Study::_duplicate(myCurrentStudy);
174 //=============================================================================
175 CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
176 //=============================================================================
178 return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
180 //=============================================================================
181 //=============================================================================
183 //=============================================================================
184 //=============================================================================
185 // Utilitaires pour l'iteration
186 //=============================================================================
187 //=============================================================================
188 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
189 //=====================================================================================
191 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
192 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
193 if (CORBA::is_nil(myIteration))
195 SALOME::ExceptionStruct es;
196 es.type = SALOME::BAD_PARAM;
197 es.text = "Invalid iteration";
198 throw SALOME::SALOME_Exception(es);
202 myIteration->SetState(Etat);
204 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
205 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
209 icone = "iter0.png" ;
210 else if ( Etat == 2 )
211 icone = "iter_calculee.png" ;
213 icone = "iter_non_calculee.png" ;
214 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ;
216 aStudyBuilder->CommitCommand();
219 //=============================================================================
220 //=============================================================================
222 //=============================================================================
223 //=============================================================================
224 // Destruction des structures identifiees par leurs noms
225 //=============================================================================
226 //=============================================================================
227 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
229 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
230 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
231 if (CORBA::is_nil(myBoundary))
233 SALOME::ExceptionStruct es;
234 es.type = SALOME::BAD_PARAM;
235 es.text = "Invalid boundary";
236 throw SALOME::SALOME_Exception(es);
240 // On verifie que la frontiere n'est plus utilisee
241 HOMARD::listeCases* maListe = GetAllCasesName();
242 int numberOfCases = maListe->length();
243 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
244 std::string CaseName ;
245 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
247 HOMARD::HOMARD_Cas_var myCase ;
248 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
250 CaseName = std::string((*maListe)[NumeCas]);
251 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
252 myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
253 ASSERT(!CORBA::is_nil(myCase));
254 ListBoundaryGroupType = myCase->GetBoundaryGroup();
255 numberOfitems = ListBoundaryGroupType->length();
256 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
257 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
259 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
261 SALOME::ExceptionStruct es;
262 es.type = SALOME::BAD_PARAM;
263 es.text = "This boundary is used in a case and cannot be deleted.";
264 throw SALOME::SALOME_Exception(es);
270 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
271 myContextMap[GetCurrentStudyID()]._mesBoundarys.erase(BoundaryName);
272 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(BoundaryName, ComponentDataType());
273 SALOMEDS::SObject_var aSO =listSO[0];
274 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
275 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
279 //=============================================================================
280 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option)
282 // Pour detruire un cas
283 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
284 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
285 if (CORBA::is_nil(myCase))
287 SALOME::ExceptionStruct es;
288 es.type = SALOME::BAD_PARAM;
289 es.text = "Invalid case context";
290 throw SALOME::SALOME_Exception(es);
293 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
294 CORBA::String_var nomIter = myCase->GetIter0Name();
295 CORBA::Long Option1 = 0 ;
296 if ( DeleteIterationOption(nomIter, Option1, Option) != 0 )
301 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
302 myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas);
303 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType());
304 SALOMEDS::SObject_var aSO =listSO[0];
305 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
306 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
310 //=============================================================================
311 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
313 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
314 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
315 if (CORBA::is_nil(myHypo))
317 SALOME::ExceptionStruct es;
318 es.type = SALOME::BAD_PARAM;
319 es.text = "Invalid hypothesis";
320 throw SALOME::SALOME_Exception(es);
324 // On verifie que l'hypothese n'est plus utilisee
325 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
326 int numberOfIter = maListeIter->length();
327 if ( numberOfIter > 0 )
329 SALOME::ExceptionStruct es;
330 es.type = SALOME::BAD_PARAM;
331 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
332 throw SALOME::SALOME_Exception(es);
336 // suppression du lien avec les zones eventuelles
337 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
338 int numberOfZones = maListe->length();
339 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
340 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
342 std::string ZoneName = std::string((*maListe)[NumeZone]);
343 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
344 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
348 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
349 myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo);
350 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType());
351 SALOMEDS::SObject_var aSO =listSO[0];
352 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
353 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
357 //=============================================================================
358 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
360 // Option = 0 : On ne supprime pas le fichier du maillage associe
361 // Option = 1 : On supprime le fichier du maillage associe
362 // Pour detruire une iteration courante
363 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
364 CORBA::Long Option1 = 1 ;
365 return DeleteIterationOption(nomIter, Option1, Option);
367 //=============================================================================
368 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
370 // Option1 = 0 : On autorise la destruction de l'iteration 0
371 // Option1 = 1 : On interdit la destruction de l'iteration 0
373 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
374 // Option2 = 1 : On supprime le fichier du maillage associe
375 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
376 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
377 if (CORBA::is_nil(myIteration))
379 SALOME::ExceptionStruct es;
380 es.type = SALOME::BAD_PARAM;
381 es.text = "Invalid iteration";
382 throw SALOME::SALOME_Exception(es);
386 int numero = myIteration->GetNumber();
387 MESSAGE ( "DeleteIterationOption : numero = " << numero );
388 if ( numero == 0 && Option1 == 1 )
390 SALOME::ExceptionStruct es;
391 es.type = SALOME::BAD_PARAM;
392 es.text = "This iteration cannot be deleted.";
393 throw SALOME::SALOME_Exception(es);
397 // On detruit recursivement toutes les filles
398 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
399 int numberOfIter = maListe->length();
400 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
402 std::string nomIterFille = std::string((*maListe)[NumeIter]);
403 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
404 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
407 // On arrive ici pour une iteration sans fille
408 MESSAGE ( "Destruction effective de " << nomIter );
409 // On commence par invalider l'iteration pour faire le menage des dependances
410 // et eventuellement du maillage associe
412 if ( numero == 0 ) { option = 0 ; }
413 else { option = Option2 ; }
414 InvalideIterOption(nomIter, option) ;
416 // Retrait dans la descendance de l'iteration parent
419 std::string nomIterationParent = myIteration->GetIterParentName();
420 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
421 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
422 if (CORBA::is_nil(myIterationParent))
424 SALOME::ExceptionStruct es;
425 es.type = SALOME::BAD_PARAM;
426 es.text = "Invalid iteration";
427 throw SALOME::SALOME_Exception(es);
430 myIterationParent->UnLinkNextIteration(nomIter);
433 // suppression du lien avec l'hypothese
436 std::string nomHypo = myIteration->GetHypoName();
437 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
438 ASSERT(!CORBA::is_nil(myHypo));
439 myHypo->UnLinkIteration(nomIter);
442 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
443 myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter);
444 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType());
445 SALOMEDS::SObject_var aSO =listSO[0];
446 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
447 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
448 // on peut aussi faire RemoveObject
449 // MESSAGE ( "Au final" );
450 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
451 // numberOfIter = Liste->length();
452 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
454 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
455 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
460 //=============================================================================
461 CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option)
463 // Option = 0 : On ne supprime pas le fichier du schema associe
464 // Option = 1 : On supprime le fichier du schema associe
465 MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option );
466 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
467 if (CORBA::is_nil(myYACS))
469 SALOME::ExceptionStruct es;
470 es.type = SALOME::BAD_PARAM;
471 es.text = "Invalid schema YACS";
472 throw SALOME::SALOME_Exception(es);
475 // Suppression eventuelle du fichier XML
478 std::string nomFichier = myYACS->GetXMLFile();
479 std::string commande = "rm -rf " + nomFichier ;
480 MESSAGE ( "commande = " << commande );
481 if ((system(commande.c_str())) != 0)
483 SALOME::ExceptionStruct es;
484 es.type = SALOME::BAD_PARAM;
485 es.text = "The xml file for the schema YACS cannot be removed." ;
486 throw SALOME::SALOME_Exception(es);
490 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
491 myContextMap[GetCurrentStudyID()]._mesYACSs.erase(nomYACS);
492 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomYACS, ComponentDataType());
493 SALOMEDS::SObject_var aSO =listSO[0];
494 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
495 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
499 //=============================================================================
500 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
502 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
503 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone];
504 if (CORBA::is_nil(myZone))
506 SALOME::ExceptionStruct es;
507 es.type = SALOME::BAD_PARAM;
508 es.text = "Invalid zone";
509 throw SALOME::SALOME_Exception(es);
513 // On verifie que la zone n'est plus utilisee
514 HOMARD::listeHypo* maListe = myZone->GetHypo();
515 int numberOfHypo = maListe->length();
516 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
517 if ( numberOfHypo > 0 )
519 SALOME::ExceptionStruct es;
520 es.type = SALOME::BAD_PARAM;
521 es.text = "This zone is used in an hypothesis and cannot be deleted.";
522 throw SALOME::SALOME_Exception(es);
526 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
527 myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone);
528 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType());
529 SALOMEDS::SObject_var aSO =listSO[0];
530 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
531 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
535 //=============================================================================
536 //=============================================================================
538 //=============================================================================
539 //=============================================================================
540 // Invalidation des structures identifiees par leurs noms
541 //=============================================================================
542 //=============================================================================
543 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
545 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
546 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
547 if (CORBA::is_nil(myBoundary))
549 SALOME::ExceptionStruct es;
550 es.type = SALOME::BAD_PARAM;
551 es.text = "Invalid boundary";
552 throw SALOME::SALOME_Exception(es);
557 SALOME::ExceptionStruct es;
558 es.type = SALOME::BAD_PARAM;
559 es.text = "No change is allowed in a boundary. Ask for evolution.";
560 throw SALOME::SALOME_Exception(es);
564 //=============================================================================
565 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
567 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
568 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
569 if (CORBA::is_nil(myHypo))
571 SALOME::ExceptionStruct es;
572 es.type = SALOME::BAD_PARAM;
573 es.text = "Invalid hypothesis";
574 throw SALOME::SALOME_Exception(es);
578 HOMARD::listeIters* maListe = myHypo->GetIterations();
579 int numberOfIter = maListe->length();
580 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
582 std::string nomIter = std::string((*maListe)[NumeIter]);
583 MESSAGE( ".. nomIter = " << nomIter );
584 InvalideIter(nomIter.c_str());
587 //=============================================================================
588 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
590 MESSAGE("InvalideIter : nomIter = " << nomIter);
591 // Pour invalider totalement une iteration courante
592 CORBA::Long Option = 1 ;
593 return InvalideIterOption(nomIter, Option);
595 //=============================================================================
596 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
598 // Option = 0 : On ne supprime pas le fichier du maillage associe
599 // Option = 1 : On supprime le fichier du maillage associe
600 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
601 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
602 if (CORBA::is_nil(myIteration))
604 SALOME::ExceptionStruct es;
605 es.type = SALOME::BAD_PARAM;
606 es.text = "Invalid iteration";
607 throw SALOME::SALOME_Exception(es);
611 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
612 int numberOfIter = maListe->length();
613 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
615 std::string nomIterFille = std::string((*maListe)[NumeIter]);
616 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
617 InvalideIter(nomIterFille.c_str());
620 // On arrive ici pour une iteration sans fille
621 MESSAGE ( "Invalidation effective de " << nomIter );
622 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
623 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
624 for (; aIter->More(); aIter->Next())
626 SALOMEDS::SObject_var so = aIter->Value();
627 SALOMEDS::GenericAttribute_var anAttr;
628 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
629 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
630 std::string value (aCommentAttr->Value());
631 if(value == std::string("HypoHomard")) continue;
632 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
633 aStudyBuilder->RemoveObject(so);
636 int etat = myIteration->GetState();
639 SetEtatIter(nomIter,1);
640 const char * nomCas = myIteration->GetCaseName();
641 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
642 if (CORBA::is_nil(myCase))
644 SALOME::ExceptionStruct es;
645 es.type = SALOME::BAD_PARAM;
646 es.text = "Invalid case context";
647 throw SALOME::SALOME_Exception(es);
650 std::string nomDir = myIteration->GetDirName();
651 std::string nomFichier = myIteration->GetMeshFile();
652 std::string commande = "rm -rf " + std::string(nomDir);
653 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
654 MESSAGE ( "commande = " << commande );
655 if ((system(commande.c_str())) != 0)
657 SALOME::ExceptionStruct es;
658 es.type = SALOME::BAD_PARAM;
659 es.text = "The directory for the calculation cannot be cleared." ;
660 throw SALOME::SALOME_Exception(es);
663 // Suppression du maillage publie dans SMESH
664 std::string MeshName = myIteration->GetMeshName() ;
665 DeleteResultInSmesh(nomFichier, MeshName) ;
669 //=============================================================================
670 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
672 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
673 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
674 if (CORBA::is_nil(myIteration))
676 SALOME::ExceptionStruct es;
677 es.type = SALOME::BAD_PARAM;
678 es.text = "Invalid iteration";
679 throw SALOME::SALOME_Exception(es);
683 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
684 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
685 for (; aIter->More(); aIter->Next())
687 SALOMEDS::SObject_var so = aIter->Value();
688 SALOMEDS::GenericAttribute_var anAttr;
689 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
690 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
691 std::string value (aCommentAttr->Value());
692 /* MESSAGE("... value = " << value);*/
693 if( (value == std::string("logInfo")) || ( value == std::string("SummaryInfo")) )
695 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
696 aStudyBuilder->RemoveObject(so);
700 const char * nomCas = myIteration->GetCaseName();
701 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
702 if (CORBA::is_nil(myCase))
704 SALOME::ExceptionStruct es;
705 es.type = SALOME::BAD_PARAM;
706 es.text = "Invalid case context";
707 throw SALOME::SALOME_Exception(es);
710 const char* nomDir = myIteration->GetDirName();
711 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
712 commande += std::string(nomDir) + "/Liste.*info" ;
713 /* MESSAGE ( "commande = " << commande );*/
714 if ((system(commande.c_str())) != 0)
716 SALOME::ExceptionStruct es;
717 es.type = SALOME::BAD_PARAM;
718 es.text = "The directory for the calculation cannot be cleared." ;
719 throw SALOME::SALOME_Exception(es);
723 //=============================================================================
724 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
726 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
727 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
728 if (CORBA::is_nil(myZone))
730 SALOME::ExceptionStruct es;
731 es.type = SALOME::BAD_PARAM;
732 es.text = "Invalid zone";
733 throw SALOME::SALOME_Exception(es);
736 HOMARD::listeHypo* maListe = myZone->GetHypo();
737 int numberOfHypo = maListe->length();
738 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
739 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
741 std::string nomHypo = std::string((*maListe)[NumeHypo]);
742 MESSAGE( ".. nomHypo = " << nomHypo );
743 InvalideHypo(nomHypo.c_str());
746 //=============================================================================
747 //=============================================================================
749 //=============================================================================
750 //=============================================================================
751 // Association de lien entre des structures identifiees par leurs noms
752 //=============================================================================
753 //=============================================================================
754 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
756 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
758 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
759 if (CORBA::is_nil(myCase))
761 SALOME::ExceptionStruct es;
762 es.type = SALOME::BAD_PARAM;
763 es.text = "Invalid case";
764 throw SALOME::SALOME_Exception(es);
768 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
769 if (CORBA::is_nil(myIteration))
771 SALOME::ExceptionStruct es;
772 es.type = SALOME::BAD_PARAM;
773 es.text = "Invalid iteration";
774 throw SALOME::SALOME_Exception(es);
778 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
779 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
780 if (CORBA::is_nil(aCasSO))
782 SALOME::ExceptionStruct es;
783 es.type = SALOME::BAD_PARAM;
784 es.text = "Invalid case";
785 throw SALOME::SALOME_Exception(es);
789 aStudyBuilder->NewCommand();
790 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
791 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
792 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
793 aStudyBuilder->CommitCommand();
795 myCase->AddIteration(nomIter);
796 myIteration->SetCaseName(nomCas);
798 //=====================================================================================
799 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
801 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
803 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
804 ASSERT(!CORBA::is_nil(myHypo));
805 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
806 ASSERT(!CORBA::is_nil(aHypoSO));
808 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
809 ASSERT(!CORBA::is_nil(myZone));
810 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
811 ASSERT(!CORBA::is_nil(aZoneSO));
813 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
815 aStudyBuilder->NewCommand();
817 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
818 aStudyBuilder->Addreference(aSubSO, aZoneSO);
820 aStudyBuilder->CommitCommand();
822 myZone->AddHypo(nomHypothesis);
823 myHypo->AddZone0(ZoneName, TypeUse);
825 //=============================================================================
826 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
828 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
830 // Verification de l'existence de l'hypothese
831 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
832 ASSERT(!CORBA::is_nil(myHypo));
833 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
834 ASSERT(!CORBA::is_nil(aHypoSO));
836 // Verification de l'existence de l'iteration
837 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
838 ASSERT(!CORBA::is_nil(myIteration));
839 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
840 ASSERT(!CORBA::is_nil(aIterSO));
842 // Gestion de l'arbre d'etudes
843 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
844 aStudyBuilder->NewCommand();
845 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
846 aStudyBuilder->Addreference(aSubSO, aHypoSO);
847 aStudyBuilder->CommitCommand();
850 myIteration->SetHypoName(nomHypo);
851 myHypo->LinkIteration(nomIter);
853 // On stocke les noms des champ a interpoler pour le futur controle de la donnee des pas de temps
854 myIteration->SupprFieldInterps() ;
855 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
856 int numberOfFieldsx2 = ListField->length();
857 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
859 std::string FieldName = std::string((*ListField)[iaux]) ;
860 myIteration->SetFieldInterp(FieldName.c_str()) ;
864 //=============================================================================
865 //=============================================================================
867 //=============================================================================
868 //=============================================================================
869 // Dissociation de lien entre des structures identifiees par leurs noms
870 //=============================================================================
871 //=============================================================================
872 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
874 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
876 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
877 ASSERT(!CORBA::is_nil(myHypo));
878 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
879 ASSERT(!CORBA::is_nil(aHypoSO));
881 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
882 ASSERT(!CORBA::is_nil(myZone));
883 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
884 ASSERT(!CORBA::is_nil(aZoneSO));
886 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
888 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
889 for (; it->More(); it->Next())
891 SALOMEDS::SObject_var aHypObj = it->Value();
892 SALOMEDS::SObject_var ptrObj;
893 if (aHypObj->ReferencedObject(ptrObj))
895 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
897 aStudyBuilder->NewCommand();
898 aStudyBuilder->RemoveObject(aHypObj);
899 aStudyBuilder->CommitCommand();
905 myZone->SupprHypo(nomHypothesis);
906 myHypo->SupprZone(ZoneName);
908 //=============================================================================
909 //=============================================================================
912 //=============================================================================
913 //=============================================================================
914 // Recuperation des listes
915 //=============================================================================
916 //=============================================================================
917 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
919 MESSAGE("GetAllBoundarysName");
922 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
923 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
924 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
926 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
927 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
929 ret[i++] = CORBA::string_dup((*it).first.c_str());
934 //=============================================================================
935 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
937 MESSAGE("GetAllCasesName");
940 HOMARD::listeCases_var ret = new HOMARD::listeCases;
941 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
942 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
944 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
945 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
947 ret[i++] = CORBA::string_dup((*it).first.c_str());
952 //=============================================================================
953 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
955 MESSAGE("GetAllHypothesesName");
958 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
959 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
960 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
962 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
963 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
965 ret[i++] = CORBA::string_dup((*it).first.c_str());
970 //=============================================================================
971 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
973 MESSAGE("GetAllIterationsName");
976 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
977 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
978 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
980 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
981 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
983 ret[i++] = CORBA::string_dup((*it).first.c_str());
988 //=============================================================================
989 HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName()
991 MESSAGE("GetAllYACSsName");
994 HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs;
995 ret->length(myContextMap[GetCurrentStudyID()]._mesYACSs.size());
996 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it;
998 for (it = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
999 it != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); it++)
1001 ret[i++] = CORBA::string_dup((*it).first.c_str());
1006 //=============================================================================
1007 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
1009 MESSAGE("GetAllZonesName");
1012 HOMARD::listeZones_var ret = new HOMARD::listeZones;
1013 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
1014 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
1016 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
1017 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
1019 ret[i++] = CORBA::string_dup((*it).first.c_str());
1024 //=============================================================================
1025 //=============================================================================
1027 //=============================================================================
1028 //=============================================================================
1029 // Recuperation des structures identifiees par leurs noms
1030 //=============================================================================
1031 //=============================================================================
1032 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
1034 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
1035 ASSERT(!CORBA::is_nil(myBoundary));
1036 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1038 //=============================================================================
1039 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
1041 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1042 ASSERT(!CORBA::is_nil(myCase));
1043 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1045 //=============================================================================
1046 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
1048 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
1049 ASSERT(!CORBA::is_nil(myHypothesis));
1050 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1052 //=============================================================================
1053 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
1055 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
1056 ASSERT(!CORBA::is_nil(myIteration));
1057 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1059 //=============================================================================
1060 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS)
1062 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
1063 ASSERT(!CORBA::is_nil(myYACS));
1064 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
1066 //=============================================================================
1067 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
1069 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
1070 ASSERT(!CORBA::is_nil(myZone));
1071 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1073 //=============================================================================
1074 //=============================================================================
1076 //=============================================================================
1077 //=============================================================================
1079 //=============================================================================
1080 //=============================================================================
1081 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)
1083 INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1084 INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
1089 if ( _PublisMeshIN != 0 ) option = 2 ;
1090 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option) ;
1091 myCase->SetDirName(DirName) ;
1093 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1097 //=============================================================================
1098 //=============================================================================
1100 //=============================================================================
1101 //=============================================================================
1102 // Recuperation des structures par le contexte
1103 //=============================================================================
1104 //=============================================================================
1105 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1107 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1108 ASSERT(!CORBA::is_nil(myCase));
1110 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1111 ASSERT(!CORBA::is_nil(myIteration));
1113 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1115 //=============================================================================
1116 //=============================================================================
1118 //=============================================================================
1119 //=============================================================================
1120 // Nouvelles structures
1121 //=============================================================================
1122 //=============================================================================
1123 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1125 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1126 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1127 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1128 return aCase._retn();
1130 //=============================================================================
1131 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1133 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1134 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1135 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1136 return aHypo._retn();
1138 //=============================================================================
1139 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1141 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1142 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1143 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1144 return aIter._retn();
1146 //=============================================================================
1147 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1149 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1150 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1151 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1152 return aBoundary._retn();
1154 //=============================================================================
1155 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1157 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1158 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1159 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1160 return aZone._retn();
1162 //=============================================================================
1163 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS()
1165 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1166 HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine);
1167 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this());
1168 return aYACS._retn();
1170 //=============================================================================
1171 //=============================================================================
1173 //=============================================================================
1174 //=============================================================================
1175 // Creation des structures identifiees par leurs noms
1176 //=============================================================================
1177 //=============================================================================
1178 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1180 // Creation d'un cas initial
1181 // nomCas : nom du cas a creer
1182 // MeshName, MeshFile : nom et fichier du maillage correspondant
1185 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1188 if ( _PublisMeshIN != 0 ) option = 2 ;
1189 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option) ;
1191 // Valeurs par defaut des filtrages
1192 myCase->SetPyram(0);
1194 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1196 //=============================================================================
1197 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1199 // nomCas : nom du cas a creer
1200 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1203 INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1204 std::string nomDirWork = getenv("PWD") ;
1207 // A. Decodage du point de reprise
1208 // A.1. Controle du repertoire de depart de l'iteration
1210 codret = chdir(DirNameStart) ;
1212 codret = _chdir(DirNameStart) ;
1216 SALOME::ExceptionStruct es;
1217 es.type = SALOME::BAD_PARAM;
1218 es.text = "The directory of the iteration does not exist.";
1219 throw SALOME::SALOME_Exception(es);
1222 // A.2. Reperage des fichiers du repertoire de reprise
1223 std::string file_configuration = "" ;
1224 std::string file_maillage_homard = "" ;
1228 struct dirent *dirp;
1229 dp = opendir(DirNameStart);
1230 while ( (dirp = readdir(dp)) != NULL )
1232 std::string file_name(dirp->d_name);
1233 // MESSAGE ( file_name );
1234 bilan = file_name.find("HOMARD.Configuration.") ;
1235 if ( bilan != string::npos ) { file_configuration = file_name ; }
1236 bilan = file_name.find("maill.") ;
1237 if ( bilan != string::npos )
1239 bilan = file_name.find(".hom.med") ;
1240 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1245 HANDLE hFind = INVALID_HANDLE_VALUE;
1246 WIN32_FIND_DATA ffd;
1247 hFind = FindFirstFile(DirNameStart, &ffd);
1248 if (INVALID_HANDLE_VALUE != hFind) {
1249 while (FindNextFile(hFind, &ffd) != 0) {
1250 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1251 std::string file_name(ffd.cFileName);
1252 bilan = file_name.find("HOMARD.Configuration.") ;
1253 if ( bilan != string::npos ) { file_configuration = file_name ; }
1254 bilan = file_name.find("maill.") ;
1255 if ( bilan != string::npos )
1257 bilan = file_name.find(".hom.med") ;
1258 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1264 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1265 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1267 if ( ( file_configuration == "" ) || ( file_maillage_homard == "" ) )
1269 SALOME::ExceptionStruct es;
1270 es.type = SALOME::BAD_PARAM;
1272 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1273 else { text = "The HOMARD mesh file cannot be found." ; }
1274 es.text = CORBA::string_dup(text.c_str());
1275 throw SALOME::SALOME_Exception(es);
1278 // B. Lecture du fichier de configuration
1279 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1285 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1286 std::ifstream fichier( file_configuration.c_str() );
1287 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1289 std::string ligne; // variable contenant chaque ligne lue
1290 std::string mot_cle;
1291 std::string argument;
1293 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1294 while ( std::getline( fichier, ligne ) )
1296 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1297 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1298 ligne_bis >> mot_cle ;
1299 // B.2. Des valeurs entieres : le second bloc de la ligne
1300 if ( mot_cle == "NumeIter" )
1302 ligne_bis >> NumeIter ;
1305 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1306 else if ( ( mot_cle == "TypeConf" ) || ( mot_cle == "TypeElem" ) )
1308 ligne_bis >> argument ;
1310 if ( mot_cle == "TypeConf" )
1312 if ( argument == "conforme" ) { TypeConf = 1 ; }
1313 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1314 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1315 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1317 else if ( mot_cle == "TypeElem" )
1319 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1320 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1323 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1324 // il faut les supprimer
1325 else if ( ( mot_cle == "CCNoMNP1" ) || ( mot_cle == "CCMaiNP1" ) )
1327 ligne_bis >> argument ;
1328 if ( argument[0] == '"' ) { decalage = 1 ; }
1329 else { decalage = 0 ; }
1330 size_t size = argument.size() + 1 - 2*decalage ;
1332 if ( mot_cle == "CCNoMNP1" )
1334 MeshName = new char[ size ];
1335 strncpy( MeshName, argument.c_str()+decalage, size );
1336 MeshName[size-1] = '\0' ;
1338 else if ( mot_cle == "CCMaiNP1" )
1340 MeshFile = new char[ size ];
1341 strncpy( MeshFile, argument.c_str()+decalage, size );
1342 MeshFile[size-1] = '\0' ;
1346 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1347 MESSAGE ( "==> MeshName : " << MeshName ) ;
1348 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1349 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1350 MESSAGE ( "==> Pyram : " << Pyram ) ;
1354 SALOME::ExceptionStruct es;
1355 es.type = SALOME::BAD_PARAM;
1356 std::string text = "The configuration file cannot be read." ;
1357 es.text = CORBA::string_dup(text.c_str());
1358 throw SALOME::SALOME_Exception(es);
1361 // C. Creation effective du cas
1364 if ( _PublisMeshIN != 0 ) option = 2 ;
1365 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, option) ;
1367 // D. Parametrages lus dans le fichier de configuration
1369 myCase->SetConfType (TypeConf) ;
1370 myCase->SetPyram (Pyram) ;
1372 // E. Copie du fichier de maillage homard
1373 // E.1. Repertoire associe au cas
1374 char* nomDirCase = myCase->GetDirName() ;
1375 // E.2. Repertoire associe a l'iteration de ce cas
1377 IterName = myCase->GetIter0Name() ;
1378 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1379 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1380 Iter->SetDirNameLoc(nomDirIter);
1381 std::string nomDirIterTotal ;
1382 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1384 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1386 if (_mkdir(nomDirIterTotal.c_str()) != 0)
1389 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1390 SALOME::ExceptionStruct es;
1391 es.type = SALOME::BAD_PARAM;
1392 std::string text = "The directory for the computation cannot be created." ;
1393 es.text = CORBA::string_dup(text.c_str());
1394 throw SALOME::SALOME_Exception(es);
1396 // E.3. Copie du maillage HOMARD au format MED
1398 codret = chdir(DirNameStart) ;
1400 codret = _chdir(DirNameStart) ;
1402 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1403 MESSAGE ( "commande : " << commande ) ;
1404 codret = system(commande.c_str()) ;
1405 MESSAGE ( "codret : " << codret ) ;
1408 SALOME::ExceptionStruct es;
1409 es.type = SALOME::BAD_PARAM;
1410 es.text = "The starting point for the case cannot be copied into the working directory.";
1411 throw SALOME::SALOME_Exception(es);
1421 chdir(nomDirWork.c_str());
1423 _chdir(nomDirWork.c_str());
1425 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1427 //=============================================================================
1428 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1430 // nomCas : nom du cas a creer
1431 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1434 INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1436 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1438 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1439 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1441 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1443 //=============================================================================
1444 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1446 // nomCas : nom du cas a creer
1447 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1448 // Number : numero de l'iteration de depart
1451 INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1454 SALOME::ExceptionStruct es;
1455 es.type = SALOME::BAD_PARAM;
1456 es.text = "The number of iteration must be positive.";
1457 throw SALOME::SALOME_Exception(es);
1461 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1463 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1464 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1466 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1468 //=============================================================================
1469 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1471 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1472 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1473 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1476 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1477 std::string nomDirWork = getenv("PWD") ;
1478 std::string DirNameStartIter ;
1480 int NumeIterMax = -1 ;
1482 // A.1. Controle du repertoire de depart du cas
1484 codret = chdir(DirNameStart) ;
1486 codret = _chdir(DirNameStart) ;
1490 SALOME::ExceptionStruct es;
1491 es.type = SALOME::BAD_PARAM;
1492 es.text = "The directory of the case for the pursuit does not exist.";
1493 throw SALOME::SALOME_Exception(es);
1496 // A.2. Reperage des sous-repertoire du repertoire de reprise
1497 bool existe = false ;
1500 struct dirent *dirp;
1501 dp = opendir(DirNameStart);
1502 while ( (dirp = readdir(dp)) != NULL ) {
1503 std::string DirName_1(dirp->d_name);
1505 HANDLE hFind = INVALID_HANDLE_VALUE;
1506 WIN32_FIND_DATA ffd;
1507 hFind = FindFirstFile(DirNameStart, &ffd);
1508 if (INVALID_HANDLE_VALUE != hFind) {
1509 while (FindNextFile(hFind, &ffd) != 0) {
1510 std::string DirName_1 = "";
1511 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1512 DirName_1 = std::string(ffd.cFileName);
1515 if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) )
1518 if ( chdir(DirName_1.c_str()) == 0 )
1520 // On cherche le fichier de configuration dans ce sous-repertoire
1521 codret = chdir(DirNameStart);
1523 struct dirent *dirp_1;
1524 dp_1 = opendir(DirName_1.c_str()) ;
1525 while ( (dirp_1 = readdir(dp_1)) != NULL )
1527 std::string file_name_1(dirp_1->d_name);
1529 if ( _chdir(DirName_1.c_str()) == 0 )
1531 codret = _chdir(DirNameStart);
1532 HANDLE hFind1 = INVALID_HANDLE_VALUE;
1533 WIN32_FIND_DATA ffd1;
1534 hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1);
1535 while (FindNextFile(hFind1, &ffd1) != 0)
1537 if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1538 std::string file_name_1(ffd1.cFileName);
1540 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1541 if ( bilan != string::npos )
1543 // Decodage du fichier pour trouver le numero d'iteration
1545 chdir(DirName_1.c_str()) ;
1547 _chdir(DirName_1.c_str()) ;
1550 std::ifstream fichier( file_name_1.c_str() );
1551 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1554 std::string ligne; // variable contenant chaque ligne lue
1555 std::string mot_cle;
1556 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1557 while ( std::getline( fichier, ligne ) )
1559 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1560 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1561 ligne_bis >> mot_cle ;
1562 if ( mot_cle == "NumeIter" )
1564 ligne_bis >> NumeIter ;
1566 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1567 if ( Number == - 1 )
1569 if ( NumeIter >= NumeIterMax )
1571 NumeIterMax = NumeIter ;
1572 DirNameStartIter = DirName_1 ;
1577 if ( NumeIter == Number )
1579 DirNameStartIter = DirName_1 ;
1589 SALOME::ExceptionStruct es;
1590 es.type = SALOME::BAD_PARAM;
1591 std::string text = "The configuration file cannot be read." ;
1592 es.text = CORBA::string_dup(text.c_str());
1593 throw SALOME::SALOME_Exception(es);
1596 chdir(DirNameStart) ;
1598 _chdir(DirNameStart) ;
1601 if ( existe ) { break ; }
1608 if ( existe ) { break ; }
1614 chdir(nomDirWork.c_str());
1618 _chdir(nomDirWork.c_str());
1621 if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) )
1623 SALOME::ExceptionStruct es;
1624 es.type = SALOME::BAD_PARAM;
1625 es.text = "The directory of the iteration does not exist.";
1626 throw SALOME::SALOME_Exception(es);
1630 return DirNameStartIter ;
1632 //=============================================================================
1633 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)
1635 // nomCas : nom du cas a creer
1636 // MeshName, MeshFile : nom et fichier du maillage correspondant
1637 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1638 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1639 // -1 : le maillage n'est pas fourni
1640 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1641 // Option : multiple de nombres premiers
1642 // 1 : aucune option
1643 // x2 : publication du maillage dans SMESH
1645 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1646 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1647 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1653 // A.2. Controle du nom :
1654 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1656 SALOME::ExceptionStruct es;
1657 es.type = SALOME::BAD_PARAM;
1658 es.text = "This case has already been defined.";
1659 throw SALOME::SALOME_Exception(es);
1663 // A.3. Controle du fichier du maillage
1664 int existeMeshFile ;
1665 if ( MeshOption >= 0 )
1667 existeMeshFile = MEDFileExist ( MeshFile ) ;
1668 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1669 if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) )
1671 SALOME::ExceptionStruct es;
1672 es.type = SALOME::BAD_PARAM;
1673 es.text = "The mesh file does not exist.";
1674 throw SALOME::SALOME_Exception(es);
1678 else { existeMeshFile = 0 ; }
1680 // B. Creation de l'objet cas et publication
1681 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1682 HOMARD::HOMARD_Cas_var myCase = newCase();
1683 myCase->SetName(nomCas);
1684 SALOMEDS::SObject_var aSO;
1685 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1686 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1688 // C. Caracteristiques du maillage
1689 if ( existeMeshFile != 0 )
1691 // Les valeurs extremes des coordonnees
1692 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1693 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1694 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1695 if (LesExtremes.size()!=10) { return false; }
1697 for (int i =0 ; i< LesExtremes.size() ; i++)
1698 aSeq[i]=LesExtremes[i] ;
1699 myCase->SetBoundingBox(aSeq) ;
1701 // MESSAGE ( "CreateCase0 : Les groupes" );
1702 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1703 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1704 aSeqGroupe->length(LesGroupes.size());
1705 std::set<std::string>::const_iterator it ;
1707 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1708 aSeqGroupe[i++]=(*it).c_str() ;
1709 myCase->SetGroups(aSeqGroupe) ;
1712 // D. L'iteration initiale du cas
1713 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1714 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1715 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1717 std::string NomIteration = std::string(MeshName) ;
1718 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1720 std::ostringstream nom;
1721 nom << MeshName << monNum;
1722 NomIteration = nom.str();
1725 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1727 // D.2. Creation de l'iteration
1728 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1729 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1730 anIter->SetName(NomIteration.c_str());
1731 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1733 // D.4. Maillage correspondant
1734 if ( existeMeshFile != 0 )
1736 anIter->SetMeshFile(MeshFile);
1737 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1739 anIter->SetMeshName(MeshName);
1741 // D.5. Numero d'iteration
1742 anIter->SetNumber(NumeIter);
1745 SetEtatIter(NomIteration.c_str(), -NumeIter);
1748 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1750 //=============================================================================
1751 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1753 INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1756 // A. Controle du nom :
1757 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1759 SALOME::ExceptionStruct es;
1760 es.type = SALOME::BAD_PARAM;
1761 es.text = "This hypothesis has already been defined.";
1762 throw SALOME::SALOME_Exception(es);
1766 // B. Creation de l'objet
1767 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1768 if (CORBA::is_nil(myHypothesis))
1770 SALOME::ExceptionStruct es;
1771 es.type = SALOME::BAD_PARAM;
1772 es.text = "Unable to create the hypothesis";
1773 throw SALOME::SALOME_Exception(es);
1776 myHypothesis->SetName(nomHypothesis);
1778 // C. Enregistrement
1779 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1781 SALOMEDS::SObject_var aSO;
1782 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1784 // D. Valeurs par defaut des options avancees
1785 myHypothesis->SetNivMax(-1);
1786 myHypothesis->SetDiamMin(-1.0);
1787 myHypothesis->SetAdapInit(0);
1788 myHypothesis->SetLevelOutput(0);
1790 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1793 //=============================================================================
1794 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1795 //=============================================================================
1797 INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1800 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1801 if (CORBA::is_nil(myIterationParent))
1803 SALOME::ExceptionStruct es;
1804 es.type = SALOME::BAD_PARAM;
1805 es.text = "The parent iteration is not defined.";
1806 throw SALOME::SALOME_Exception(es);
1810 const char* nomCas = myIterationParent->GetCaseName();
1811 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1812 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1813 if (CORBA::is_nil(myCase))
1815 SALOME::ExceptionStruct es;
1816 es.type = SALOME::BAD_PARAM;
1817 es.text = "Invalid case context";
1818 throw SALOME::SALOME_Exception(es);
1821 const char* nomDirCase = myCase->GetDirName();
1823 // Controle du nom :
1824 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1826 SALOME::ExceptionStruct es;
1827 es.type = SALOME::BAD_PARAM;
1828 es.text = "This iteration has already been defined.";
1829 throw SALOME::SALOME_Exception(es);
1833 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1834 if (CORBA::is_nil(myIteration))
1836 SALOME::ExceptionStruct es;
1837 es.type = SALOME::BAD_PARAM;
1838 es.text = "Unable to create the iteration";
1839 throw SALOME::SALOME_Exception(es);
1842 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1843 // Nom de l'iteration et du maillage
1844 myIteration->SetName(NomIteration);
1845 myIteration->SetMeshName(NomIteration);
1846 myIteration->SetState(1);
1848 int numero = myIterationParent->GetNumber() + 1;
1849 myIteration->SetNumber(numero);
1851 // Nombre d'iterations deja connues pour le cas, permettant
1852 // la creation d'un sous-repertoire unique
1853 int nbitercase = myCase->GetNumberofIter();
1854 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1855 myIteration->SetDirNameLoc(nomDirIter);
1857 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1858 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1859 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1860 // situation la plus frequente.
1861 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1862 // le nombre d'iterations du cas permet d'eviter les collisions.
1864 if ( nbitercase < 100 ) { jaux = 2 ; }
1865 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1866 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1867 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1869 std::ostringstream iaux ;
1870 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1871 std::stringstream MeshFile;
1872 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1873 myIteration->SetMeshFile(MeshFile.str().c_str());
1875 // Association avec le cas
1876 std::string label = "IterationHomard_" + std::string(nomIterParent);
1877 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1878 // Lien avec l'iteration precedente
1879 myIterationParent->LinkNextIteration(NomIteration);
1880 myIteration->SetIterParentName(nomIterParent);
1881 // Gestion de l'arbre d'etudes
1882 SALOMEDS::SObject_var aIterSOParent = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIterationParent)));
1883 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
1884 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
1885 aStudyBuilder->NewCommand();
1886 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
1887 aStudyBuilder->Addreference(aSubSO, aIterSOParent);
1888 aStudyBuilder->CommitCommand();
1890 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1892 //=============================================================================
1893 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1895 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1898 // Controle du nom :
1899 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1901 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1902 SALOME::ExceptionStruct es;
1903 es.type = SALOME::BAD_PARAM;
1904 es.text = "This boundary has already been defined";
1905 throw SALOME::SALOME_Exception(es);
1909 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1910 myBoundary->SetName(BoundaryName);
1911 myBoundary->SetType(BoundaryType);
1913 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1915 SALOMEDS::SObject_var aSO;
1916 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1918 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1920 //=============================================================================
1921 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1923 INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1924 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1925 myBoundary->SetMeshFile( MeshFile ) ;
1926 myBoundary->SetMeshName( MeshName ) ;
1928 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1930 //=============================================================================
1931 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1932 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1933 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1934 CORBA::Double Rayon)
1936 INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1938 SALOME::ExceptionStruct es;
1941 { es.text = "The radius must be positive." ;
1943 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1944 if ( daux < 0.0000001 )
1945 { es.text = "The axis must be a non 0 vector." ;
1949 es.type = SALOME::BAD_PARAM;
1950 throw SALOME::SALOME_Exception(es);
1954 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1955 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1957 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1959 //=============================================================================
1960 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1961 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1962 CORBA::Double Rayon)
1964 INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1966 SALOME::ExceptionStruct es;
1969 { es.text = "The radius must be positive." ;
1973 es.type = SALOME::BAD_PARAM;
1974 throw SALOME::SALOME_Exception(es);
1978 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1979 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1981 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1983 //=============================================================================
1984 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1985 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1986 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1988 INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1990 SALOME::ExceptionStruct es;
1992 if ( Angle <= 0.0 || Angle >= 90.0 )
1993 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1995 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1996 if ( daux < 0.0000001 )
1997 { es.text = "The axis must be a non 0 vector." ;
2001 es.type = SALOME::BAD_PARAM;
2002 throw SALOME::SALOME_Exception(es);
2006 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
2007 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
2009 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2011 //=============================================================================
2012 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
2013 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
2014 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
2016 INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
2018 SALOME::ExceptionStruct es;
2020 if ( Rayon1 < 0.0 || Rayon2 < 0.0 )
2021 { es.text = "The radius must be positive." ;
2023 double daux = fabs(Rayon2-Rayon1) ;
2024 if ( daux < 0.0000001 )
2025 { es.text = "The radius must be different." ;
2027 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
2028 if ( daux < 0.0000001 )
2029 { es.text = "The centers must be different." ;
2033 es.type = SALOME::BAD_PARAM;
2034 throw SALOME::SALOME_Exception(es);
2038 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
2039 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
2041 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2043 //=============================================================================
2044 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryTorus(const char* BoundaryName,
2045 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2046 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2047 CORBA::Double RayonRev, CORBA::Double RayonPri)
2049 INFOS ("CreateBoundaryTorus : BoundaryName = " << BoundaryName ) ;
2051 SALOME::ExceptionStruct es;
2053 if ( ( RayonRev <= 0.0 ) || ( RayonPri <= 0.0 ) )
2054 { es.text = "The radius must be positive." ;
2056 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2057 if ( daux < 0.0000001 )
2058 { es.text = "The axis must be a non 0 vector." ;
2062 es.type = SALOME::BAD_PARAM;
2063 throw SALOME::SALOME_Exception(es);
2067 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 5) ;
2068 myBoundary->SetTorus( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, RayonRev, RayonPri ) ;
2070 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2072 //=============================================================================
2073 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
2075 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
2078 // Controle du nom :
2079 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
2081 SALOME::ExceptionStruct es;
2082 es.type = SALOME::BAD_PARAM;
2083 es.text = "This zone has already been defined";
2084 throw SALOME::SALOME_Exception(es);
2088 HOMARD::HOMARD_Zone_var myZone = newZone();
2089 myZone->SetName(ZoneName);
2090 myZone->SetType(ZoneType);
2092 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
2094 SALOMEDS::SObject_var aSO;
2095 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
2097 return HOMARD::HOMARD_Zone::_duplicate(myZone);
2099 //=============================================================================
2100 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
2101 CORBA::Double Xmini, CORBA::Double Xmaxi,
2102 CORBA::Double Ymini, CORBA::Double Ymaxi,
2103 CORBA::Double Zmini, CORBA::Double Zmaxi)
2105 INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ;
2107 SALOME::ExceptionStruct es;
2109 if ( Xmini > Xmaxi )
2110 { es.text = "The X coordinates are not coherent." ;
2112 if ( Ymini > Ymaxi )
2113 { es.text = "The Y coordinates are not coherent." ;
2115 if ( Zmini > Zmaxi )
2116 { es.text = "The Z coordinates are not coherent." ;
2120 es.type = SALOME::BAD_PARAM;
2121 throw SALOME::SALOME_Exception(es);
2125 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
2126 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2128 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2130 //=============================================================================
2131 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
2132 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
2134 INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
2136 SALOME::ExceptionStruct es;
2139 { es.text = "The radius must be positive." ;
2143 es.type = SALOME::BAD_PARAM;
2144 throw SALOME::SALOME_Exception(es);
2148 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
2149 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
2151 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2153 //=============================================================================
2154 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
2155 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2156 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2157 CORBA::Double Rayon, CORBA::Double Haut)
2159 INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
2161 SALOME::ExceptionStruct es;
2164 { es.text = "The radius must be positive." ;
2166 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2167 if ( daux < 0.0000001 )
2168 { es.text = "The axis must be a non 0 vector." ;
2171 { es.text = "The height must be positive." ;
2175 es.type = SALOME::BAD_PARAM;
2176 throw SALOME::SALOME_Exception(es);
2180 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
2181 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
2183 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2185 //=============================================================================
2186 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
2187 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2188 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2189 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
2191 INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ;
2193 SALOME::ExceptionStruct es;
2195 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2196 { es.text = "The radius must be positive." ;
2198 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2199 if ( daux < 0.0000001 )
2200 { es.text = "The axis must be a non 0 vector." ;
2203 { es.text = "The height must be positive." ;
2205 if ( Rayon <= Rayonint )
2206 { es.text = "The external radius must be higher than the internal radius." ;
2210 es.type = SALOME::BAD_PARAM;
2211 throw SALOME::SALOME_Exception(es);
2215 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
2216 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
2218 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2220 //=============================================================================
2221 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
2222 CORBA::Double Umini, CORBA::Double Umaxi,
2223 CORBA::Double Vmini, CORBA::Double Vmaxi,
2226 INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
2227 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
2228 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
2229 // MESSAGE ("Orient = " << Orient ) ;
2231 SALOME::ExceptionStruct es;
2233 if ( Umini > Umaxi )
2234 { es.text = "The first coordinates are not coherent." ;
2236 if ( Vmini > Vmaxi )
2237 { es.text = "The second coordinates are not coherent." ;
2239 if ( Orient < 1 || Orient > 3 )
2240 { es.text = "The orientation must be 1, 2 or 3." ;
2244 es.type = SALOME::BAD_PARAM;
2245 throw SALOME::SALOME_Exception(es);
2249 double Xmini, Xmaxi ;
2250 double Ymini, Ymaxi ;
2251 double Zmini, Zmaxi ;
2259 else if ( Orient == 2 )
2266 else if ( Orient == 3 )
2273 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2275 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2276 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2278 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2280 //=============================================================================
2281 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2282 CORBA::Double Ucentre, CORBA::Double Vcentre,
2283 CORBA::Double Rayon,
2286 INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2288 SALOME::ExceptionStruct es;
2291 { es.text = "The radius must be positive." ;
2293 if ( Orient < 1 || Orient > 3 )
2294 { es.text = "The orientation must be 1, 2 or 3." ;
2298 es.type = SALOME::BAD_PARAM;
2299 throw SALOME::SALOME_Exception(es);
2307 { Xcentre = Ucentre ;
2310 else if ( Orient == 2 )
2313 Zcentre = Vcentre ; }
2314 else if ( Orient == 3 )
2315 { Xcentre = Vcentre ;
2317 Zcentre = Ucentre ; }
2318 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2320 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2321 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2323 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2325 //=============================================================================
2326 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2327 CORBA::Double Ucentre, CORBA::Double Vcentre,
2328 CORBA::Double Rayon, CORBA::Double Rayonint,
2331 INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2333 SALOME::ExceptionStruct es;
2335 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2336 { es.text = "The radius must be positive." ;
2338 if ( Orient < 1 || Orient > 3 )
2339 { es.text = "The orientation must be 1, 2 or 3." ;
2341 if ( Rayon <= Rayonint )
2342 { es.text = "The external radius must be higher than the internal radius." ;
2346 es.type = SALOME::BAD_PARAM;
2347 throw SALOME::SALOME_Exception(es);
2355 { Xcentre = Ucentre ;
2358 else if ( Orient == 2 )
2361 Zcentre = Vcentre ; }
2362 else if ( Orient == 3 )
2363 { Xcentre = Vcentre ;
2365 Zcentre = Ucentre ; }
2366 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2368 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2369 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2371 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2373 //=============================================================================
2374 //=============================================================================
2379 //=============================================================================
2380 //=============================================================================
2381 // Traitement d'une iteration
2382 // etatMenage = 1 : destruction du repertoire d'execution
2383 // modeHOMARD = 1 : adaptation
2384 // != 1 : information avec les options modeHOMARD
2385 // Option1 >0 : appel depuis python
2386 // <0 : appel depuis GUI
2387 // Option2 : multiple de nombres premiers
2388 // 1 : aucune option
2389 // x2 : publication du maillage dans SMESH
2390 //=============================================================================
2391 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2393 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2398 // A.1. L'objet iteration
2399 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2400 ASSERT(!CORBA::is_nil(myIteration));
2402 // A.2. Controle de la possibilite d'agir
2403 // A.2.1. Etat de l'iteration
2404 int etat = myIteration->GetState();
2405 MESSAGE ( "etat = "<<etat );
2406 // A.2.2. On ne calcule pas l'iteration initiale, ni une iteration deja calculee
2407 if ( modeHOMARD == 1 )
2411 SALOME::ExceptionStruct es;
2412 es.type = SALOME::BAD_PARAM;
2413 es.text = "This iteration is the first of the case and cannot be computed.";
2414 throw SALOME::SALOME_Exception(es);
2417 else if ( ( etat == 2 ) & ( modeHOMARD == 1 ) )
2419 SALOME::ExceptionStruct es;
2420 es.type = SALOME::BAD_PARAM;
2421 es.text = "This iteration is already computed.";
2422 throw SALOME::SALOME_Exception(es);
2426 // A.2.3. On n'analyse pas une iteration non calculee
2431 SALOME::ExceptionStruct es;
2432 es.type = SALOME::BAD_PARAM;
2433 es.text = "This iteration is not computed.";
2434 throw SALOME::SALOME_Exception(es);
2439 // A.3. Numero de l'iteration
2440 // siterp1 : numero de l'iteration a traiter
2442 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2443 // Ou si information :
2445 int NumeIter = myIteration->GetNumber();
2446 std::string siterp1 ;
2447 std::stringstream saux1 ;
2449 siterp1 = saux1.str() ;
2450 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2453 if ( modeHOMARD==1 )
2455 std::stringstream saux0 ;
2456 int iaux = max(0, NumeIter-1) ;
2458 siter = saux0.str() ;
2459 if (NumeIter < 11) { siter = "0" + siter ; }
2462 { siter = siterp1 ; }
2465 const char* nomCas = myIteration->GetCaseName();
2466 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2467 ASSERT(!CORBA::is_nil(myCase));
2469 // B. Les repertoires
2470 // B.1. Le repertoire courant
2471 std::string nomDirWork = getenv("PWD") ;
2472 // B.2. Le sous-repertoire de l'iteration a traiter
2473 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2474 MESSAGE( ". DirCompute = " << DirCompute );
2476 // C. Le fichier des messages
2477 // C.1. Le deroulement de l'execution de HOMARD
2478 std::string LogFile = DirCompute ;
2479 LogFile += "/Liste" ;
2480 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2482 MESSAGE (". LogFile = " << LogFile);
2483 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2484 // C.2. Le bilan de l'analyse du maillage
2485 std::string FileInfo = DirCompute ;
2487 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2489 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2490 else { FileInfo += "info_ap" ; }
2492 FileInfo += "." + siterp1 + ".bilan" ;
2493 myIteration->SetFileInfo(FileInfo.c_str());
2495 // D. On passe dans le repertoire de l'iteration a calculer
2496 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2503 // E. Les donnees de l'execution HOMARD
2504 // E.1. L'objet du texte du fichier de configuration
2505 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2506 myDriver->TexteInit(DirCompute, LogFile, _Langue);
2508 // E.2. Le maillage associe a l'iteration
2509 const char* NomMesh = myIteration->GetMeshName();
2510 MESSAGE ( ". NomMesh = " << NomMesh );
2511 const char* MeshFile = myIteration->GetMeshFile();
2512 MESSAGE ( ". MeshFile = " << MeshFile );
2514 // E.3. Les donnees du traitement HOMARD
2516 if ( modeHOMARD == 1 )
2519 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2520 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2521 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2525 InvalideIterInfo(NomIteration);
2526 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2528 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2529 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2530 myDriver->CreeFichierDonn();
2533 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2534 DriverTexteBoundary(myCase, myDriver) ;
2536 // E.5. Ecriture du texte dans le fichier
2537 MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<<codret );
2539 { myDriver->CreeFichier(); }
2543 int codretexec = 12 ;
2546 codretexec = myDriver->ExecuteHomard(Option1);
2548 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2549 // En mode adaptation, on ajuste l'etat de l'iteration
2550 if ( modeHOMARD == 1 )
2552 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2553 else { SetEtatIter(NomIteration,1); }
2554 // GERALD -- QMESSAGE BOX
2558 // H. Gestion des resultats
2561 std::string Commentaire ;
2562 // H.1. Le fichier des messages, dans tous les cas
2563 Commentaire = "log" ;
2564 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2565 else { Commentaire += "Info" ; }
2566 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2568 // H.2. Si tout s'est bien passe :
2569 if (codretexec == 0)
2571 // H.2.1. Le fichier de bilan
2572 Commentaire = "Summary" ;
2573 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2574 else { Commentaire += "Info" ; }
2575 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2576 // H.2.2. Le fichier de maillage obtenu
2577 if ( modeHOMARD == 1 )
2579 std::stringstream saux0 ;
2580 Commentaire = "Mesh" ;
2581 Commentaire += " " + siterp1 ;
2582 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2583 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2586 // H.3 Message d'erreur
2587 if (codretexec != 0)
2590 // Message d'erreur en cas de probleme en adaptation
2591 if ( modeHOMARD == 1 )
2593 text = "Error during the adaptation.\n" ;
2594 bool stopvu = false ;
2595 std::ifstream fichier( LogFile.c_str() );
2596 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
2598 std::string ligne; // variable contenant chaque ligne lue
2599 while ( std::getline( fichier, ligne ) )
2603 { text += ligne+ "\n"; }
2606 int position = ligne.find( "===== HOMARD ===== STOP =====" ) ;
2607 if ( position > 0 ) { stopvu = true ; }
2614 text = "Voir le fichier Liste.log.\n" ;
2617 SALOME::ExceptionStruct es;
2618 es.type = SALOME::BAD_PARAM;
2619 es.text = CORBA::string_dup(text.c_str());
2620 throw SALOME::SALOME_Exception(es);
2622 // En mode information, on force le succes pour pouvoir consulter le fichier log
2623 if ( modeHOMARD != 1 ) { codretexec = 0 ; }
2627 // I. Menage et retour dans le repertoire du cas
2631 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2634 chdir(nomDirWork.c_str());
2636 _chdir(nomDirWork.c_str());
2642 //=============================================================================
2643 // Calcul d'une iteration : partie specifique a l'adaptation
2644 //=============================================================================
2645 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)
2647 MESSAGE ( "ComputeAdap" );
2652 // Numero de l'iteration
2653 int NumeIter = myIteration->GetNumber();
2654 std::stringstream saux0 ;
2655 saux0 << NumeIter-1 ;
2656 std::string siter = saux0.str() ;
2657 if (NumeIter < 11) { siter = "0" + siter ; }
2659 // A.2. On verifie qu il y a une hypothese (erreur improbable);
2660 const char* nomHypo = myIteration->GetHypoName();
2661 if (std::string(nomHypo) == std::string(""))
2663 SALOME::ExceptionStruct es;
2664 es.type = SALOME::BAD_PARAM;
2665 es.text = "This iteration does not have any associated hypothesis.";
2666 throw SALOME::SALOME_Exception(es);
2669 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2670 ASSERT(!CORBA::is_nil(myHypo));
2672 // B. L'iteration parent
2673 const char* nomIterationParent = myIteration->GetIterParentName();
2674 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2675 ASSERT(!CORBA::is_nil(myIterationParent));
2676 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2677 if ( myIterationParent->GetState() == 1 )
2680 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2683 // GERALD -- QMESSAGE BOX
2684 VERIFICATION("Pb au calcul de l'iteration precedente" == 0);
2688 // C. Le sous-repertoire de l'iteration precedente
2689 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2690 MESSAGE( ". DirComputePa = " << DirComputePa );
2692 // D. Les donnees de l'adaptation HOMARD
2693 // D.1. Le type de conformite
2694 int ConfType = myCase->GetConfType();
2695 MESSAGE ( ". ConfType = " << ConfType );
2697 // D.2. Le maillage de depart
2698 const char* NomMeshParent = myIterationParent->GetMeshName();
2699 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2700 const char* MeshFileParent = myIterationParent->GetMeshFile();
2701 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2703 // D.3. Le maillage associe a l'iteration
2704 const char* MeshFile = myIteration->GetMeshFile();
2705 MESSAGE ( ". MeshFile = " << MeshFile );
2706 FILE *file = fopen(MeshFile,"r");
2710 if (etatMenage == 0)
2712 SALOME::ExceptionStruct es;
2713 es.type = SALOME::BAD_PARAM;
2714 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2715 es.text = CORBA::string_dup(text.c_str());
2716 throw SALOME::SALOME_Exception(es);
2721 std::string commande = "rm -f " + std::string(MeshFile);
2722 codret = system(commande.c_str());
2725 SALOME::ExceptionStruct es;
2726 es.type = SALOME::BAD_PARAM;
2727 es.text = "The mesh file cannot be deleted.";
2728 throw SALOME::SALOME_Exception(es);
2734 // D.4. Les types de raffinement et de deraffinement
2735 // Les appels corba sont lourds, il vaut mieux les grouper
2736 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2737 ASSERT(ListTypes->length() == 3);
2738 int TypeAdap = (*ListTypes)[0];
2739 int TypeRaff = (*ListTypes)[1];
2740 int TypeDera = (*ListTypes)[2];
2742 // E. Texte du fichier de configuration
2743 // E.1. Incontournables du texte
2744 myDriver->TexteAdap();
2746 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2747 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2748 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2750 // E.2. Ajout des informations liees aux zones eventuelles
2751 if ( TypeAdap == 0 )
2752 { DriverTexteZone(myHypo, myDriver) ; }
2754 // E.3. Ajout des informations liees aux champs eventuels
2755 if ( TypeAdap == 1 )
2756 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2758 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2759 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2760 int numberOfGroups = listeGroupes->length();
2761 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2762 if (numberOfGroups > 0)
2764 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2766 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2767 MESSAGE( "... GroupName = " << GroupName );
2768 myDriver->TexteGroup(GroupName);
2772 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2773 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2775 // E.6. Ajout des options avancees
2776 int Pyram = myCase->GetPyram();
2777 MESSAGE ( ". Pyram = " << Pyram );
2778 int NivMax = myHypo->GetNivMax();
2779 MESSAGE ( ". NivMax = " << NivMax );
2780 double DiamMin = myHypo->GetDiamMin() ;
2781 MESSAGE ( ". DiamMin = " << DiamMin );
2782 int AdapInit = myHypo->GetAdapInit();
2783 MESSAGE ( ". AdapInit = " << AdapInit );
2784 int LevelOutput = myHypo->GetLevelOutput();
2785 MESSAGE ( ". LevelOutput = " << LevelOutput );
2786 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2788 // E.7. Ajout des informations sur le deroulement de l'execution
2789 int MessInfo = myIteration->GetInfoCompute();
2790 MESSAGE ( ". MessInfo = " << MessInfo );
2791 myDriver->TexteInfoCompute(MessInfo);
2795 //=============================================================================
2796 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2797 // nomrep : nom du repertoire parent
2798 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2799 //=============================================================================
2800 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2802 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2803 // On verifie que le repertoire parent existe
2805 int codret = chdir(nomrep) ;
2807 int codret = _chdir(nomrep) ;
2811 SALOME::ExceptionStruct es;
2812 es.type = SALOME::BAD_PARAM;
2813 es.text = "The directory of the case does not exist.";
2814 throw SALOME::SALOME_Exception(es);
2817 std::string nomDirActuel = getenv("PWD") ;
2818 std::string DirName ;
2819 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2820 bool a_chercher = true ;
2821 while ( a_chercher )
2823 // On passe dans le repertoire parent
2830 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2832 if ( num < 100 ) { jaux = 2 ; }
2833 else if ( num < 1000 ) { jaux = 3 ; }
2834 else if ( num < 10000 ) { jaux = 4 ; }
2835 else if ( num < 100000 ) { jaux = 5 ; }
2837 std::ostringstream iaux ;
2838 iaux << std::setw(jaux) << std::setfill('0') << num ;
2839 std::ostringstream DirNameA ;
2840 DirNameA << "I" << iaux.str();
2841 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2842 // que c'est bien un probleme d'absence
2844 if ( chdir(DirNameA.str().c_str()) != 0 )
2847 if ( _chdir(DirNameA.str().c_str()) != 0 )
2850 bool existe = false ;
2853 struct dirent *dirp;
2854 dp = opendir(nomrep);
2855 while ( (dirp = readdir(dp)) != NULL )
2857 std::string file_name(dirp->d_name);
2859 HANDLE hFind = INVALID_HANDLE_VALUE;
2860 WIN32_FIND_DATA ffd;
2861 hFind = FindFirstFile(nomrep, &ffd);
2862 if (INVALID_HANDLE_VALUE != hFind) {
2863 while (FindNextFile(hFind, &ffd) != 0) {
2864 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2865 std::string file_name(ffd.cFileName);
2867 if ( file_name == DirNameA.str() ) { existe = true ; }
2877 DirName = DirNameA.str() ;
2878 a_chercher = false ;
2885 MESSAGE ( "==> DirName = " << DirName);
2886 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2888 chdir(nomDirActuel.c_str());
2890 _chdir(nomDirActuel.c_str());
2892 return CORBA::string_dup( DirName.c_str() );
2894 //=============================================================================
2895 // Calcul d'une iteration : gestion du repertoire de calcul
2896 // Si le sous-repertoire existe :
2897 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2898 // etatMenage = 1 : on fait le menage du repertoire
2899 // etatMenage = -1 : on ne fait rien
2900 //=============================================================================
2901 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2903 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2904 // B.2. Le repertoire du cas
2905 const char* nomDirCase = myCase->GetDirName();
2906 MESSAGE ( ". nomDirCase = " << nomDirCase );
2908 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2909 // B.3.1. Le nom du sous-repertoire
2910 const char* nomDirIt = myIteration->GetDirNameLoc();
2912 // B.3.2. Le nom complet du sous-repertoire
2913 std::stringstream DirCompute ;
2914 DirCompute << nomDirCase << "/" << nomDirIt;
2915 MESSAGE (". DirCompute = " << DirCompute.str() );
2917 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2919 if (chdir(DirCompute.str().c_str()) != 0)
2921 // Creation du repertoire car il n'existe pas :
2922 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2925 if (_chdir(DirCompute.str().c_str()) != 0)
2927 // Creation du repertoire car il n'existe pas :
2928 if (_mkdir(DirCompute.str().c_str()) != 0)
2931 // GERALD -- QMESSAGE BOX
2932 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2933 VERIFICATION("Pb a la creation du repertoire" == 0);
2938 // Le repertoire existe
2939 // On demande de faire le menage de son contenu :
2940 if (etatMenage == 1)
2942 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2943 std::string commande = "rm -rf " + DirCompute.str()+"/*" ;
2944 int codret = system(commande.c_str());
2947 // GERALD -- QMESSAGE BOX
2948 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2949 VERIFICATION("Pb au menage du repertoire de calcul" == 0);
2952 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2955 if (etatMenage == 0)
2959 struct dirent *dirp;
2960 dp = opendir(DirCompute.str().c_str());
2962 while ((dirp = readdir(dp)) != NULL && result )
2964 std::string file_name(dirp->d_name);
2965 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2969 HANDLE hFind = INVALID_HANDLE_VALUE;
2970 WIN32_FIND_DATA ffd;
2971 hFind = FindFirstFile(DirCompute.str().c_str(), &ffd);
2973 if (INVALID_HANDLE_VALUE != hFind) {
2974 while (FindNextFile(hFind, &ffd) != 0) {
2975 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2976 std::string file_name(ffd.cFileName);
2977 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2982 if ( result == false)
2984 SALOME::ExceptionStruct es;
2985 es.type = SALOME::BAD_PARAM;
2986 std::string text = "Directory : " + DirCompute.str() + " is not empty";
2987 es.text = CORBA::string_dup(text.c_str());
2988 throw SALOME::SALOME_Exception(es);
2989 VERIFICATION("Directory is not empty" == 0);
2995 return CORBA::string_dup( DirCompute.str().c_str() );
2997 //=============================================================================
2998 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2999 //=============================================================================
3000 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
3002 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
3003 // Le repertoire du cas
3004 const char* nomDirCase = myCase->GetDirName();
3005 MESSAGE ( ". nomDirCase = " << nomDirCase );
3007 // Le sous-repertoire de l'iteration precedente
3009 const char* nomIterationParent = myIteration->GetIterParentName();
3010 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
3011 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
3012 std::stringstream DirComputePa ;
3013 DirComputePa << nomDirCase << "/" << nomDirItPa;
3014 MESSAGE( ". nomDirItPa = " << nomDirItPa);
3015 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
3017 return CORBA::string_dup( DirComputePa.str().c_str() );
3019 //=============================================================================
3020 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
3021 //=============================================================================
3022 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3024 MESSAGE ( "... DriverTexteZone" );
3025 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
3026 int numberOfZonesx2 = ListZone->length();
3029 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
3031 std::string ZoneName = std::string((*ListZone)[iaux]);
3032 MESSAGE ( "... ZoneName = " << ZoneName);
3033 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
3034 ASSERT(!CORBA::is_nil(myZone));
3036 int ZoneType = myZone->GetType();
3037 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
3038 int TypeUse = atoi( TypeUsestr.c_str() );
3039 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
3040 NumZone = iaux/2 + 1 ;
3041 HOMARD::double_array* zone = myZone->GetCoords();
3042 if ( ZoneType == 2 || ( ZoneType>=11 && ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
3043 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
3044 else if ( ZoneType == 4 ) // Cas d une sphere
3045 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
3046 else if ( ZoneType == 5 || ( ZoneType>=31 && ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
3047 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
3048 else if ( ZoneType == 7 || ( ZoneType>=61 && ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
3049 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
3050 else { VERIFICATION("ZoneType est incorrect." == 0) ; }
3055 //=============================================================================
3056 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
3057 //=============================================================================
3058 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3060 MESSAGE ( "... DriverTexteField" );
3061 // Le fichier du champ
3062 char* FieldFile = myIteration->GetFieldFile();
3063 MESSAGE ( ". FieldFile = " << FieldFile );
3064 if (strlen(FieldFile) == 0)
3066 // GERALD -- QMESSAGE BOX
3067 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
3068 VERIFICATION("The file for the field is not given." == 0);
3070 // Les caracteristiques d'instants du champ de pilotage
3071 int TimeStep = myIteration->GetTimeStep();
3072 MESSAGE( ". TimeStep = " << TimeStep );
3073 int Rank = myIteration->GetRank();
3074 MESSAGE( ". Rank = " << Rank );
3075 // Les informations sur les champs
3076 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
3078 const char* FieldName = aInfosHypo->FieldName;
3080 int TypeThR = aInfosHypo->TypeThR;
3081 double ThreshR = aInfosHypo->ThreshR;
3082 int TypeThC = aInfosHypo->TypeThC;
3083 double ThreshC = aInfosHypo->ThreshC;
3084 // Saut entre mailles ou non ?
3085 int UsField = aInfosHypo->UsField;
3086 MESSAGE( ". UsField = " << UsField );
3087 // L'usage des composantes
3088 int UsCmpI = aInfosHypo->UsCmpI;
3089 MESSAGE( ". UsCmpI = " << UsCmpI );
3091 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
3094 HOMARD::listeComposantsHypo* mescompo = myHypo->GetComps();
3095 int numberOfCompos = mescompo->length();
3096 MESSAGE( ". numberOfCompos = " << numberOfCompos );
3097 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
3099 std::string nomCompo = std::string((*mescompo)[NumeComp]);
3100 MESSAGE( "... nomCompo = " << nomCompo );
3101 myDriver->TexteCompo(NumeComp, nomCompo);
3105 //=============================================================================
3106 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
3107 // On ecrit dans l'ordre :
3108 // 1. la definition des frontieres
3109 // 2. les liens avec les groupes
3110 // 3. un entier resumant le type de comportement pour les frontieres
3111 //=============================================================================
3112 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
3114 MESSAGE ( "... DriverTexteBoundary" );
3115 // 1. Recuperation des frontieres
3116 std::list<std::string> ListeBoundaryTraitees ;
3117 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3118 int numberOfitems = ListBoundaryGroupType->length();
3119 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
3120 int BoundaryOption = 1 ;
3121 // 2. Parcours des frontieres pour ecrire leur description
3122 int NumBoundaryAnalytical = 0 ;
3123 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3125 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3126 MESSAGE ( "... BoundaryName = " << BoundaryName);
3127 // 2.1. La frontiere a-t-elle deja ete ecrite ?
3128 // Cela arrive quand elle estliéé a plusieurs groupes. Il ne faut l'ecrire que la premiere fois
3130 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3131 while (it != ListeBoundaryTraitees.end())
3133 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3134 if ( BoundaryName == *it ) { A_faire = 0 ; }
3137 // 2.2. Ecriture de la frontiere
3140 // 2.2.1. Caracteristiques de la frontiere
3141 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3142 ASSERT(!CORBA::is_nil(myBoundary));
3143 int BoundaryType = myBoundary->GetType();
3144 MESSAGE ( "... BoundaryType = " << BoundaryType );
3145 // 2.2.2. Ecriture selon le type
3146 // 2.2.2.1. Cas d une frontiere discrete
3147 if (BoundaryType == 0)
3149 const char* MeshName = myBoundary->GetMeshName() ;
3150 const char* MeshFile = myBoundary->GetMeshFile() ;
3151 myDriver->TexteBoundaryDi( MeshName, MeshFile);
3152 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; }
3154 // 2.2.2.1. Cas d une frontiere analytique
3157 NumBoundaryAnalytical++ ;
3158 HOMARD::double_array* coor = myBoundary->GetCoords();
3159 if (BoundaryType == 1) // Cas d un cylindre
3161 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3162 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3164 else if (BoundaryType == 2) // Cas d une sphere
3166 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
3167 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3169 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
3171 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3172 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3174 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
3176 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3177 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3179 else if (BoundaryType == 5) // Cas d un tore
3181 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3182 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3185 // 2.2.3. Memorisation du traitement
3186 ListeBoundaryTraitees.push_back( BoundaryName );
3189 // 3. Parcours des frontieres pour ecrire les liens avec les groupes
3190 NumBoundaryAnalytical = 0 ;
3191 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3193 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3194 MESSAGE ( "... BoundaryName = " << BoundaryName);
3195 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3196 ASSERT(!CORBA::is_nil(myBoundary));
3197 int BoundaryType = myBoundary->GetType();
3198 MESSAGE ( "... BoundaryType = " << BoundaryType );
3199 // 3.1. Recuperation du nom du groupe
3200 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
3201 MESSAGE ( "... GroupName = " << GroupName);
3202 // 3.2. Cas d une frontiere discrete
3203 if ( BoundaryType == 0 )
3205 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
3207 // 3.3. Cas d une frontiere analytique
3210 NumBoundaryAnalytical++ ;
3211 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
3214 // 4. Ecriture de l'option finale
3215 myDriver->TexteBoundaryOption(BoundaryOption);
3219 //=============================================================================
3220 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
3221 //=============================================================================
3222 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3224 MESSAGE ( "... DriverTexteFieldInterp" );
3225 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
3226 MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp);
3227 if (TypeFieldInterp != 0)
3229 // Le fichier des champs
3230 char* FieldFile = myIteration->GetFieldFile();
3231 MESSAGE ( ". FieldFile = " << FieldFile );
3232 if (strlen(FieldFile) == 0)
3234 // GERALD -- QMESSAGE BOX
3235 VERIFICATION("The file for the field is not given." == 0);
3238 const char* MeshFile = myIteration->GetMeshFile();
3239 myDriver->TexteFieldInterp(FieldFile, MeshFile);
3242 // Interpolation de tous les champs
3243 if ( TypeFieldInterp == 1 )
3245 myDriver->TexteFieldInterpAll();
3247 // Interpolation de certains champs
3248 else if (TypeFieldInterp == 2)
3250 // Les champs et leurs instants pour l'iteration
3251 HOMARD::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank();
3252 int numberOfFieldsx3 = ListFieldTSR->length();
3253 MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 );
3254 // Les champs pour l'hypothese
3255 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
3256 int numberOfFieldsx2 = ListField->length();
3257 MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 );
3258 // On parcourt tous les champs de l'hypothese
3260 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
3263 std::string FieldName = std::string((*ListField)[iaux]) ;
3264 // Le type d'interpolation
3265 std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ;
3266 MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr );
3267 // On cherche à savoir si des instants ont été précisés pour cette itération
3269 for (int jaux = 0; jaux< numberOfFieldsx3; jaux++)
3272 std::string FieldName2 = std::string((*ListFieldTSR)[jaux]) ;
3273 MESSAGE( "..... FieldName2 = " << FieldName2 );
3274 // Quand c'est le bon champ, on ecrit le pas de temps
3275 if ( FieldName == FieldName2 )
3279 std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]) ;
3280 // Le numero d'ordre
3281 std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]) ;
3282 MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<<Rankstr );
3284 int TimeStep = atoi( TimeStepstr.c_str() );
3285 int Rank = atoi( Rankstr.c_str() );
3286 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank);
3290 // Si aucun instant n'a été défini
3294 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1);
3302 //===========================================================================
3303 //===========================================================================
3306 //===========================================================================
3307 //===========================================================================
3309 //===========================================================================
3310 //===========================================================================
3311 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
3312 SALOMEDS::SObject_ptr theSObject,
3313 CORBA::Object_ptr theObject,
3314 const char* theName)
3316 MESSAGE("PublishInStudy pour " << theName);
3317 SALOMEDS::SObject_var aResultSO;
3318 if (CORBA::is_nil(theStudy))
3320 SALOME::ExceptionStruct es;
3321 es.type = SALOME::BAD_PARAM;
3322 es.text = "Invalid study context";
3323 throw SALOME::SALOME_Exception(es);
3327 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
3328 // Rq : Iteration est publiee ailleurs
3329 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
3330 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
3331 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
3332 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject);
3333 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
3335 addInStudy(theStudy);
3337 // Controle de la non publication d'un objet de meme nom
3338 if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) )
3340 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
3341 if (listSO->length() >= 1)
3343 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
3344 aResultSO = listSO[0];
3345 return aResultSO._retn();
3349 // Caracteristiques de l'etude
3350 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
3351 aStudyBuilder->NewCommand();
3352 if(!aBoundary->_is_nil())
3353 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
3354 else if(!aCase->_is_nil())
3355 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
3356 else if(!aHypo->_is_nil())
3357 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
3358 else if(!aYACS->_is_nil())
3359 aResultSO = PublishYACSInStudy(theStudy, aStudyBuilder, aYACS, theName);
3360 else if(!aZone->_is_nil())
3361 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
3363 aStudyBuilder->CommitCommand();
3365 return aResultSO._retn();
3367 //=============================================================================
3368 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3369 SALOMEDS::StudyBuilder_var aStudyBuilder,
3370 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3372 MESSAGE("PublishBoundaryStudy pour "<<theName);
3373 SALOMEDS::SObject_var aResultSO;
3375 // Caracteristique de la Boundary
3376 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3378 // On recupere le module pere dans l etude
3379 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3380 if (theFatherHomard->_is_nil())
3382 MESSAGE("theFatherHomard->_is_nil()");
3383 return aResultSO._retn();
3386 // On ajoute la categorie des boundarys dans l etude si necessaire
3387 if ( _tag_boun == 0 )
3390 _tag_boun = _tag_gene ;
3392 MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun );
3393 SALOMEDS::SObject_var aSObject;
3394 if (!theFatherHomard->FindSubObject(_tag_boun, aSObject))
3396 MESSAGE("Ajout de la categorie des boundarys");
3397 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun);
3398 PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3400 else { MESSAGE("La categorie des boundarys existe deja."); }
3402 CORBA::Long BoundaryType = myBoundary->GetType();
3403 // MESSAGE("BoundaryType : "<<BoundaryType);
3406 switch (BoundaryType)
3409 { value = "BoundaryDiHomard" ;
3410 icone = "mesh_tree_mesh.png" ;
3414 { value = "BoundaryAnHomard" ;
3415 icone = "cylinderpointvector_2.png" ;
3419 { value = "BoundaryAnHomard" ;
3420 icone = "spherepoint_2.png" ;
3424 { value = "BoundaryAnHomard" ;
3425 icone = "conepointvector.png" ;
3429 { value = "BoundaryAnHomard" ;
3430 icone = "conedxyz.png" ;
3434 { value = "BoundaryAnHomard" ;
3435 icone = "toruspointvector.png" ;
3439 aResultSO = aStudyBuilder->NewObject(aSObject);
3440 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3441 return aResultSO._retn();
3443 //=============================================================================
3444 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
3445 SALOMEDS::StudyBuilder_var aStudyBuilder,
3446 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
3448 MESSAGE("PublishCaseInStudy pour "<<theName);
3449 SALOMEDS::SObject_var aResultSO;
3451 if (CORBA::is_nil(theObject)) {
3452 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
3453 return aResultSO._retn();
3455 if (theStudy->_is_nil()) {
3456 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
3457 return aResultSO._retn();
3460 // On recupere le module pere dans l etude
3461 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3462 if (theFatherHomard->_is_nil())
3464 MESSAGE("theFatherHomard->_is_nil()");
3465 return aResultSO._retn();
3469 MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene );
3470 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
3471 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
3472 _orb->object_to_string(theObject) ) ;
3474 return aResultSO._retn();
3476 //=============================================================================
3477 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3478 SALOMEDS::StudyBuilder_var aStudyBuilder,
3479 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3481 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3482 SALOMEDS::SObject_var aResultSO;
3484 // On recupere le module pere dans l etude
3485 // On ajoute la categorie des hypotheses dans l etude si necessaire
3486 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3487 if (theFatherHomard->_is_nil())
3489 MESSAGE("theFatherHomard->_is_nil()");
3490 return aResultSO._retn();
3493 // On ajoute la categorie des hypotheses dans l etude si necessaire
3494 SALOMEDS::SObject_var aSObject;
3495 if ( _tag_hypo == 0 )
3498 _tag_hypo = _tag_gene ;
3500 MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo );
3501 if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject))
3503 MESSAGE("Ajout de la categorie des hypotheses");
3504 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo);
3505 PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL);
3507 else { MESSAGE("La categorie des hypotheses existe deja."); }
3509 // Creation du resultat dans l'etude
3510 aResultSO = aStudyBuilder->NewObject(aSObject);
3511 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3513 return aResultSO._retn();
3515 //=============================================================================
3516 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theStudy,
3517 SALOMEDS::StudyBuilder_var aStudyBuilder,
3518 HOMARD::HOMARD_YACS_ptr theObject, const char* theName)
3520 MESSAGE("PublishYACSInStudy pour "<<theName);
3521 SALOMEDS::SObject_var aResultSO;
3523 // On recupere le module pere dans l etude
3524 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3525 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3526 if (theFatherHomard->_is_nil())
3528 MESSAGE("theFatherHomard->_is_nil()");
3529 return aResultSO._retn();
3531 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3532 if ( _tag_yacs == 0 )
3535 _tag_yacs = _tag_gene ;
3537 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs );
3538 SALOMEDS::SObject_var aSObject;
3539 if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject))
3541 MESSAGE("Ajout de la categorie des schemas YACS");
3542 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs);
3543 PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL);
3545 else { MESSAGE("La categorie des schemas YACS existe deja."); }
3547 // Creation du resultat dans l'etude
3548 aResultSO = aStudyBuilder->NewObject(aSObject);
3549 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ;
3551 return aResultSO._retn();
3554 //=============================================================================
3555 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
3556 SALOMEDS::StudyBuilder_var aStudyBuilder,
3557 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3559 MESSAGE("PublishZoneStudy pour "<<theName);
3560 SALOMEDS::SObject_var aResultSO;
3561 if (CORBA::is_nil(theObject))
3563 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3564 return aResultSO._retn();
3566 if (theStudy->_is_nil())
3568 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
3569 return aResultSO._retn();
3571 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3572 if (theFatherHomard->_is_nil())
3574 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3575 return aResultSO._retn();
3578 // Caracteristique de la zone
3579 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3580 CORBA::Long ZoneType = myZone->GetType();
3582 // On ajoute la categorie des zones dans l etude si necessaire
3583 if ( _tag_zone == 0 )
3586 _tag_zone = _tag_gene ;
3588 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone );
3589 SALOMEDS::SObject_var aSObject;
3590 if (!theFatherHomard->FindSubObject(_tag_zone, aSObject))
3592 MESSAGE("Ajout de la categorie des zones");
3593 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone);
3594 PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3596 else { MESSAGE("La categorie des zones existe deja."); }
3598 aResultSO = aStudyBuilder->NewObject(aSObject);
3607 { icone = "boxdxy_2.png" ;
3611 { icone = "boxdxyz_2.png" ;
3619 { icone = "disk_2.png" ;
3623 { icone = "spherepoint_2.png" ;
3627 { icone = "cylinderpointvector_2.png" ;
3635 { icone = "diskwithhole_2.png" ;
3639 { icone = "pipe_2.png" ;
3643 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3645 return aResultSO._retn();
3647 //===========================================================================
3648 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3649 SALOMEDS::SObject_var aResultSO,
3650 const char* name, const char* comment, const char* icone, const char* ior)
3652 MESSAGE("PublishInStudyAttr pour name = "<<name<<", comment = "<<comment);
3653 // MESSAGE("icone = "<<icone);
3654 // MESSAGE("ior = "<<ior);
3655 SALOMEDS::GenericAttribute_var anAttr ;
3659 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3660 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3661 aNameAttrib->SetValue(name);
3664 // Ajout du commentaire
3665 if ( comment != NULL )
3667 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3668 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3669 aCommentAttrib->SetValue(comment);
3673 if ( icone != NULL )
3675 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
3676 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3677 aPixmap->SetPixMap(icone);
3683 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3684 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3685 anIOR->SetValue(ior);
3689 //=====================================================================================
3690 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3692 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3694 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3695 ASSERT(!CORBA::is_nil(myCase));
3696 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3697 ASSERT(!CORBA::is_nil(aCaseSO));
3699 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3700 ASSERT(!CORBA::is_nil(myBoundary));
3701 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3702 ASSERT(!CORBA::is_nil(aBoundarySO));
3704 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3706 aStudyBuilder->NewCommand();
3708 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3709 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3710 // aStudyBuilder->RemoveReference(aSubSO);
3712 aStudyBuilder->CommitCommand();
3715 //=====================================================================================
3716 void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName)
3718 MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName );
3720 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3721 ASSERT(!CORBA::is_nil(myYACS));
3722 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3723 ASSERT(!CORBA::is_nil(aYACSSO));
3725 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3726 ASSERT(!CORBA::is_nil(myCase));
3727 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3728 ASSERT(!CORBA::is_nil(aCaseSO));
3730 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3732 aStudyBuilder->NewCommand();
3734 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3735 aStudyBuilder->Addreference(aSubSO, aCaseSO);
3737 aStudyBuilder->CommitCommand();
3740 //=============================================================================
3741 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3742 // Option = 0 : fichier issu d'une importation
3743 // Option = 1 : fichier issu d'une execution HOMARD
3745 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3746 if (CORBA::is_nil(myCurrentStudy))
3748 SALOME::ExceptionStruct es;
3749 es.type = SALOME::BAD_PARAM;
3750 es.text = "Invalid study context";
3751 throw SALOME::SALOME_Exception(es);
3755 // Le module SMESH est-il actif ?
3756 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3758 if (!CORBA::is_nil(aSmeshSO))
3760 // On verifie que le fichier n est pas deja publie
3761 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3762 for (; aIter->More(); aIter->Next())
3764 SALOMEDS::SObject_var aSO = aIter->Value();
3765 SALOMEDS::GenericAttribute_var aGAttr;
3766 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3768 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3769 CORBA::String_var value=anAttr->Value();
3770 if (strcmp((const char*)value,NomFich) == 0)
3772 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3773 // Pour un fichier importe, on ne republie pas
3774 if ( Option == 0 ) { return; }
3775 // Pour un fichier calcule, on commence par faire la depublication
3778 MESSAGE ( "PublishResultInSmesh : depublication" );
3779 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3780 CORBA::String_var value2=anAttr2->Value();
3781 std::string MeshName = string(value2) ;
3782 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3783 DeleteResultInSmesh(NomFich, MeshName) ;
3790 // On enregistre le fichier
3791 MESSAGE( "Enregistrement du fichier");
3792 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3793 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3794 ASSERT(!CORBA::is_nil(aSmeshEngine));
3795 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3796 SMESH::DriverMED_ReadStatus theStatus;
3797 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3799 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3800 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3801 for (int i = 0; i < mesMaillages->length(); i++)
3803 MESSAGE( ". Mise a jour des attributs du maillage");
3804 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3805 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3806 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3807 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3808 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3809 anAttr->SetValue(NomFich);
3810 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3811 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3813 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3814 else { icone = "mesh_tree_mesh.png" ; }
3815 anAttr2->SetPixMap( icone );
3819 //=============================================================================
3820 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
3822 MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3823 if (CORBA::is_nil(myCurrentStudy))
3825 SALOME::ExceptionStruct es;
3826 es.type = SALOME::BAD_PARAM;
3827 es.text = "Invalid study context";
3828 throw SALOME::SALOME_Exception(es);
3832 // Le module SMESH est-il actif ?
3833 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3835 if (CORBA::is_nil(aSmeshSO))
3839 // On verifie que le fichier est deja publie
3840 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3841 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3842 for (; aIter->More(); aIter->Next())
3844 SALOMEDS::SObject_var aSO = aIter->Value();
3845 SALOMEDS::GenericAttribute_var aGAttr;
3846 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3848 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3849 CORBA::String_var value=anAttr->Value();
3850 if (strcmp((const char*)value,NomFich.c_str()) == 0)
3852 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3854 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3855 CORBA::String_var value2=anAttr2->Value();
3856 if (strcmp((const char*)value2,MeshName.c_str()) == 0)
3858 myBuilder->RemoveObjectWithChildren( aSO ) ;
3866 //=============================================================================
3867 void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter)
3869 MESSAGE( "PublishMeshIterInSmesh " << NomIter);
3870 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3872 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3873 if (CORBA::is_nil(myIteration))
3875 SALOME::ExceptionStruct es;
3876 es.type = SALOME::BAD_PARAM;
3877 es.text = "Invalid iterationStudy Object";
3878 throw SALOME::SALOME_Exception(es);
3881 const char* MeshFile = myIteration->GetMeshFile() ;
3882 const char* MeshName = myIteration->GetMeshName() ;
3883 CORBA::Long Option = -1 ;
3884 int etat = myIteration->GetState();
3885 // Iteration initiale
3886 if ( etat <= 0 ) { Option = 0 ; }
3887 // ou iteration calculee
3888 else if ( etat == 2 ) { Option = 1 ; }
3889 // Publication effective apres menage eventuel
3892 DeleteResultInSmesh(MeshFile, MeshName) ;
3893 PublishResultInSmesh(MeshFile, Option) ;
3897 //=============================================================================
3898 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3900 // MESSAGE ("PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3901 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3903 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3904 if (CORBA::is_nil(myIteration))
3906 SALOME::ExceptionStruct es;
3907 es.type = SALOME::BAD_PARAM;
3908 es.text = "Invalid iterationStudy Object";
3909 throw SALOME::SALOME_Exception(es);
3913 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3915 aStudyBuilder->NewCommand();
3917 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3918 // Pour les fichiers med, on affiche une icone de maillage
3919 // Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte'
3920 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3922 std::string ior = " " ;
3923 if ( Commentaire[0] == 'I' )
3924 { icone = "med.png" ; }
3926 { icone = "texte_2.png" ; }
3927 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3929 aStudyBuilder->CommitCommand();
3932 //=============================================================================
3933 void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire)
3935 // MESSAGE ("PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3936 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3938 SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3939 if (CORBA::is_nil(myYACS))
3941 SALOME::ExceptionStruct es;
3942 es.type = SALOME::BAD_PARAM;
3943 es.text = "Invalid YACSStudy Object";
3944 throw SALOME::SALOME_Exception(es);
3948 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3950 aStudyBuilder->NewCommand();
3952 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3953 std::string icone = "texte_2.png" ;
3954 std::string ior = " " ;
3955 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3957 aStudyBuilder->CommitCommand();
3960 //=============================================================================
3961 //=============================================================================
3963 //=============================================================================
3964 //=============================================================================
3965 //=============================================================================
3966 // Creation d'un schema YACS
3967 // nomCas : nom du cas a traiter
3968 // FileName : nom du fichier contenant le script de lancement du calcul
3969 // DirName : le repertoire de lancement des calculs du schéma
3970 //=============================================================================
3971 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
3973 INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS );
3974 INFOS ( ". nomCas : " << nomCas);
3975 INFOS ( ". ScriptFile : " << ScriptFile);
3976 INFOS ( ". DirName : " << DirName);
3977 INFOS ( ". MeshFile : " << MeshFile);
3979 // A. Controle du nom :
3980 if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(nomYACS) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end())
3982 SALOME::ExceptionStruct es;
3983 es.type = SALOME::BAD_PARAM;
3984 es.text = "This schema YACS has already been defined.";
3985 throw SALOME::SALOME_Exception(es);
3989 // B. Creation de l'objet
3990 HOMARD::HOMARD_YACS_var myYACS = newYACS();
3991 if (CORBA::is_nil(myYACS))
3993 SALOME::ExceptionStruct es;
3994 es.type = SALOME::BAD_PARAM;
3995 es.text = "Unable to create the schema YACS";
3996 throw SALOME::SALOME_Exception(es);
3999 myYACS->SetName( nomYACS ) ;
4001 // C. Enregistrement
4002 myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS] = myYACS;
4004 SALOMEDS::SObject_var aSO;
4005 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, nomYACS);
4007 PublishCaseUnderYACS(nomYACS, nomCas);
4009 // D. Caracterisation
4011 myYACS->SetDirName( DirName ) ;
4012 myYACS->SetMeshFile( MeshFile ) ;
4013 myYACS->SetScriptFile( ScriptFile ) ;
4014 myYACS->SetCaseName( nomCas ) ;
4016 // D.2.1. Type constant
4017 myYACS->SetType( 1 ) ;
4018 // D.2.2. Fichier de sauvegarde dans le repertoire du cas
4019 HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ;
4020 std::string dirnamecase = caseyacs->GetDirName() ;
4021 std::string XMLFile ;
4022 XMLFile = dirnamecase + "/schema.xml" ;
4023 myYACS->SetXMLFile( XMLFile.c_str() ) ;
4025 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
4027 //=============================================================================
4028 // Ecriture d'un schema YACS
4029 //=============================================================================
4030 CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS)
4032 INFOS ( "YACSWrite : Ecriture de " << nomYACS );
4033 // Le repertoire du cas
4034 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
4035 ASSERT(!CORBA::is_nil(myYACS));
4036 // Le nom du fichier du schema
4037 std::string XMLFile ;
4038 XMLFile = myYACS->GetXMLFile() ;
4040 int codret = YACSWriteOnFile(nomYACS, XMLFile.c_str()) ;
4044 //=============================================================================
4045 // Ecriture d'un schema YACS sur un fichier donne
4046 //=============================================================================
4047 CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile)
4049 INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile );
4056 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
4057 ASSERT(!CORBA::is_nil(myYACS));
4058 // B.2. Les caracteristiques
4059 std::string DirName = myYACS->GetDirName() ;
4060 std::string MeshFile = myYACS->GetMeshFile() ;
4061 std::string ScriptFile = myYACS->GetScriptFile() ;
4065 const char* nomCas = myYACS->GetCaseName();
4066 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
4067 ASSERT(!CORBA::is_nil(myCase));
4068 // C.2. Les instructions python associees au cas
4069 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4070 std::string pythonCas = dumpCorbaCase.in();
4071 MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
4073 // D. Les iterations
4074 // D.1. L'iteration initiale
4075 HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
4076 std::string Iter0Name = myCase->GetIter0Name() ;
4077 MESSAGE (". Iter0Name = " << Iter0Name);
4078 std::string MeshName = Iter0->GetMeshName();
4079 MESSAGE (". MeshName = " << MeshName);
4080 // D.2. L'iteration numero 1
4081 HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
4082 int numberOfIter = maListe->length();
4083 if ( numberOfIter > 1 )
4085 MESSAGE (". numberOfIter = " << numberOfIter);
4086 SALOME::ExceptionStruct es ;
4087 es.type = SALOME::BAD_PARAM;
4088 std::string text = "Une seule iteration est permise." ;
4089 es.text = CORBA::string_dup(text.c_str());
4090 throw SALOME::SALOME_Exception(es);
4093 std::string Iter1Name = std::string((*maListe)[0]);
4094 MESSAGE ("... Iter1Name = " << Iter1Name);
4095 HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
4096 // D.3. Les instructions python associees a l'iteration
4097 CORBA::String_var dumpCorbaIter = Iter1->GetDumpPython();
4098 std::string pythonIter = dumpCorbaIter.in();
4099 MESSAGE ("pythonIter :\n"<<pythonIter<<"\n");
4101 // E. L'hypothese pour passer de l'iteration initiale a la suivante
4102 // E.1. La structure
4103 std::string nomHypo = Iter1->GetHypoName();
4104 MESSAGE (". nomHypo = " << nomHypo);
4105 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
4106 ASSERT(!CORBA::is_nil(myHypo));
4107 // E.2. Les caracteristiques de l'adaptation
4108 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
4109 ASSERT(ListTypes->length() == 3);
4110 int TypeAdap = (*ListTypes)[0];
4111 // int TypeRaff = (*ListTypes)[1];
4112 // int TypeDera = (*ListTypes)[2];
4113 // E.3. Les instructions python associees a l'hypothese
4114 CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
4115 std::string pythonHypo = dumpCorbaHypo.in();
4116 MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
4118 // F. Le fichier du schema de reference
4119 // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD
4120 std::string XMLFile_base ;
4121 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { XMLFile_base = getenv("HOMARD_ROOT_DIR") ; }
4124 SALOME::ExceptionStruct es ;
4125 es.type = SALOME::BAD_PARAM;
4126 std::string text = "HOMARD_ROOT_DIR est inconnu." ;
4127 es.text = CORBA::string_dup(text.c_str());
4128 throw SALOME::SALOME_Exception(es);
4131 XMLFile_base += "/share/salome/resources/homard/yacs_01." + _LangueShort + ".xml" ;
4133 MESSAGE("XMLFile_base ="<<XMLFile_base);
4135 // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4136 YACSDriver* myDriver = new YACSDriver(XMLFile, DirName);
4137 std::ifstream fichier( XMLFile_base.c_str() );
4138 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
4140 // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4141 std::string ligne; // variable contenant chaque ligne lue
4142 std::string mot_cle;
4143 while ( std::getline( fichier, ligne ) )
4145 // G.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
4146 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4147 ligne_bis >> mot_cle ;
4148 // G.1.2. Le maillage initial
4149 if ( mot_cle == "DataInit_MeshFile" )
4150 { myDriver->Texte_DataInit_MeshFile(MeshFile); }
4151 // G.1.3. Le script de lancement
4152 else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
4153 { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); }
4154 // G.1.4. Les options du cas
4155 else if ( mot_cle == "Iter_1_Case_Options" )
4156 { myDriver->Texte_Iter_1_Case_Options(pythonCas); }
4157 // G.1.5. Execution de HOMARD : le repertoire du cas
4158 else if ( mot_cle == "HOMARD_Exec_DirName" )
4159 { myDriver->Texte_HOMARD_Exec_DirName(); }
4160 // G.1.6. Execution de HOMARD : le nom du maillage
4161 else if ( mot_cle == "HOMARD_Exec_MeshName" )
4163 myDriver->Texte_HOMARD_Exec_MeshName(MeshName);
4164 std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ;
4165 myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ;
4167 // G.1.7. Execution de HOMARD : les options de l'hypothese
4168 else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
4169 { myDriver->Texte_python_1( pythonHypo, 3, "Hypo" ) ; }
4170 // G.1.8. Execution de HOMARD : les options de l'iteration
4171 else if ( mot_cle == "HOMARD_Exec_Iter_Options" )
4172 { myDriver->Texte_python_2( pythonIter, "TimeStep", "Iter" ) ; }
4173 // G.1.9. Zones et frontieres : les creations
4174 else if ( mot_cle == "Iter_1" )
4176 std::string texte_control = myDriver->Texte_Iter_1_control() ;
4177 if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; }
4178 texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ;
4179 myDriver->TexteAdd(texte_control);
4181 // G.1.10. Les parametres
4182 else if ( mot_cle == "PARAMETRES" )
4183 { myDriver->TexteAddParametres(); }
4184 // G.1.n. La ligne est recopiee telle quelle
4185 else { myDriver->TexteAdd(ligne); }
4187 // G.2. Ecriture du texte dans le fichier
4189 { myDriver->CreeFichier(); }
4193 SALOME::ExceptionStruct es;
4194 es.type = SALOME::BAD_PARAM;
4195 std::string text = "The reference file for the YACS schema cannot be read." ;
4196 es.text = CORBA::string_dup(text.c_str());
4197 throw SALOME::SALOME_Exception(es);
4202 // H. Publication du fichier dans l'arbre
4204 std::string Commentaire = "xml" ;
4205 PublishFileUnderYACS(nomYACS, XMLFile, Commentaire.c_str());
4209 //=============================================================================
4210 // Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
4211 //=============================================================================
4212 std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
4214 MESSAGE ( "YACSDriverTexteZone" );
4215 // A. Les zones associees a cette hypothese
4216 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
4217 int numberOfZonesx2 = ListZone->length();
4219 // B. Parcours des zones
4220 std::string texte_control ;
4221 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
4223 // 1. Reperage de la zone
4224 std::string ZoneName = std::string((*ListZone)[iaux]);
4225 MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
4226 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
4227 ASSERT(!CORBA::is_nil(myZone));
4228 // 2. Les instructions python associees a la zone
4229 // La premiere ligne est un commentaire a eliminer
4230 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4231 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4232 std::string pythonStructure_0 = dumpCorbaZone.in();
4233 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4234 std::istringstream tout (pythonStructure_0) ;
4236 std::string pythonStructure ;
4237 while ( std::getline( tout, ligne ) )
4238 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4239 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4240 // 3. Decodage du nom du service
4241 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4242 MESSAGE ( "... methode = " << methode);
4243 // 4. Mise en place des instructions
4244 int ZoneType = myZone->GetType();
4245 MESSAGE ( "... ZoneType = " << ZoneType);
4246 std::string texte_control_0 ;
4247 texte_control_0 = myDriver->Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName );
4248 texte_control += texte_control_0 ;
4253 return texte_control ;
4255 //=============================================================================
4256 // Ecriture d'un schema YACS : ecriture des frontieres associees au cas
4257 //=============================================================================
4258 std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver)
4260 MESSAGE ( "YACSDriverTexteBoundary" );
4261 // A. Les frontieres associees au cas
4262 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
4263 int numberOfitems = ListBoundaryGroupType->length();
4265 // B. Parcours des frontieres
4266 std::string texte_control ;
4267 std::list<std::string> ListeBoundaryTraitees ;
4268 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
4270 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
4271 MESSAGE ( "... BoundaryName = " << BoundaryName);
4272 // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver
4273 // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees
4275 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
4276 while (it != ListeBoundaryTraitees.end())
4278 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
4279 if ( BoundaryName == *it ) { A_faire = 0 ; }
4284 // 1. Caracteristiques de la frontiere
4285 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
4286 ASSERT(!CORBA::is_nil(myBoundary));
4287 // 2. Les instructions python associees a la frontiere
4288 // La premiere ligne est un commentaire a eliminer
4289 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4290 CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython();
4291 std::string pythonStructure_0 = dumpCorbaBoundary.in();
4292 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4293 std::istringstream tout (pythonStructure_0) ;
4295 std::string pythonStructure ;
4296 while ( std::getline( tout, ligne ) )
4297 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4298 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4299 // 3. Decodage du nom du service
4300 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4301 MESSAGE ( "... methode = " << methode);
4302 // 4. Mise en place des instructions
4303 int BoundaryType = myBoundary->GetType();
4304 MESSAGE ( "... BoundaryType = " << BoundaryType);
4305 std::string texte_control_0 ;
4306 texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName );
4307 texte_control += texte_control_0 ;
4308 // 5. Memorisation du traitement
4309 ListeBoundaryTraitees.push_back( BoundaryName );
4313 return texte_control ;
4316 //=============================================================================
4317 //=============================================================================
4318 // Next functions are inherited from SALOMEDS::Driver interface
4319 //=============================================================================
4320 //=============================================================================
4321 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
4323 CORBA::Boolean isMultiFile)
4325 MESSAGE ("Save for theURL = "<< theURL);
4326 SALOMEDS::TMPFile_var aStreamFile;
4328 // get temporary directory name
4329 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4331 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
4332 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4334 // HOMARD data file name
4335 std::string aFileName = "";
4337 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
4338 aFileName += "_HOMARD.dat";
4340 // initialize sequence of file names
4341 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
4342 aFileSeq->length(1);
4343 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
4345 // get full path to the data file
4346 aFileName = tmpDir + aFileName;
4350 std::ofstream f(aFileName.c_str());
4352 // clear temporary id map
4353 context._idmap.clear();
4358 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
4359 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
4360 HOMARD::HOMARD_Cas_var aCas = it_case->second;
4361 PortableServer::ServantBase_var aServant = GetServant(aCas);
4362 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4364 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
4365 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
4369 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4370 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
4371 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
4372 PortableServer::ServantBase_var aServant = GetServant(aZone);
4373 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4375 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
4376 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4379 // -> save hypotheses
4380 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4381 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
4382 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
4383 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4384 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4386 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
4387 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4390 // -> save iterations
4391 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4392 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
4393 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
4394 PortableServer::ServantBase_var aServant = GetServant(aIter);
4395 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4397 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
4398 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4401 // -> save boundaries
4402 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4403 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
4404 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
4405 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4406 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4407 if (aBoundaryServant) {
4408 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
4409 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4413 MESSAGE ("close file");
4416 // put temporary files to the stream
4417 MESSAGE ("put temporary files to the stream");
4418 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
4420 // remove temporary files
4421 MESSAGE ("remove temporary files");
4422 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4424 // return data stream
4425 MESSAGE ("return data stream");
4426 return aStreamFile._retn();
4429 //===========================================================================
4430 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
4432 CORBA::Boolean isMultiFile)
4434 // No specific ASCII persistence
4435 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
4436 return aStreamFile._retn();
4439 //===========================================================================
4440 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
4441 const SALOMEDS::TMPFile& theStream,
4443 CORBA::Boolean isMultiFile)
4445 MESSAGE ("Load pour theURL = "<< theURL);
4446 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
4448 // set current study
4449 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
4450 SetCurrentStudy(aStudy);
4452 // get temporary directory name
4453 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4455 // Convert the stream into sequence of files to process
4456 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
4459 // HOMARD data file name
4460 std::string aFileName = "";
4462 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
4463 aFileName = tmpDir + aFileName + "_HOMARD.dat";
4465 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4469 std::ifstream f(aFileName.c_str());
4472 context._mesCas.clear();
4473 context._mesHypotheses.clear();
4474 context._mesIterations.clear();
4475 context._mesZones.clear();
4476 context._mesBoundarys.clear();
4477 context._idmap.clear();
4483 std::getline(f, line);
4484 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
4485 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
4486 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
4487 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
4488 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
4489 std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS);
4490 if (line.substr(0, bounSignature.size()) == bounSignature) {
4491 // re-create boundary
4492 MESSAGE ("Recreation de la frontiere" );
4493 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
4494 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4495 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4496 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
4497 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
4498 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4501 else if (line.substr(0, caseSignature.size()) == caseSignature) {
4503 MESSAGE ("Recreation du cas" );
4504 HOMARD::HOMARD_Cas_var aCase = newCase();
4505 PortableServer::ServantBase_var aServant = GetServant(aCase);
4506 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4507 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
4508 context._mesCas[aCase->GetName()] = aCase;
4509 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
4512 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
4513 // re-create hypothesis
4514 MESSAGE ("Recreation de l hypothese" );
4515 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
4516 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4517 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4518 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
4519 context._mesHypotheses[aHypo->GetName()] = aHypo;
4520 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4523 else if (line.substr(0, iterSignature.size()) == iterSignature) {
4524 // re-create iteration
4525 MESSAGE ("Recreation de l'iteration" );
4526 HOMARD::HOMARD_Iteration_var aIter = newIteration();
4527 PortableServer::ServantBase_var aServant = GetServant(aIter);
4528 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4529 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
4530 context._mesIterations[aIter->GetName()] = aIter;
4531 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4534 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
4535 MESSAGE ("Recreation de la zone" );
4537 HOMARD::HOMARD_Zone_var aZone = newZone();
4538 PortableServer::ServantBase_var aServant = GetServant(aZone);
4539 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4540 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
4541 context._mesZones[aZone->GetName()] = aZone;
4542 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4545 else if (line.substr(0, zoneSignature.size()) == yacsSignature) {
4546 MESSAGE ("Recreation du schema YACS" );
4548 HOMARD::HOMARD_YACS_var aYACS = newYACS();
4549 PortableServer::ServantBase_var aServant = GetServant(aYACS);
4550 HOMARD_YACS_i* aYACSServant = dynamic_cast<HOMARD_YACS_i*>(aServant.in());
4551 if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) {
4552 context._mesYACSs[aYACS->GetName()] = aYACS;
4553 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aYACSServant);
4562 // Remove temporary files created from the stream
4564 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4569 //===========================================================================
4570 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
4571 const SALOMEDS::TMPFile& theStream,
4573 CORBA::Boolean isMultiFile)
4575 // No specific ASCII persistence
4576 return Load(theComponent, theStream, theURL, isMultiFile);
4579 //===========================================================================
4580 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
4582 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
4583 // clearing study context should be done here:
4584 // - destroy all servants and related CORBA objects
4586 // - remove context from myContextMap
4587 myContextMap.erase(theComponent->GetStudy()->StudyId());
4588 // - nullify myCurrentStudy
4589 myCurrentStudy = SALOMEDS::Study::_nil();
4593 //===========================================================================
4594 char* HOMARD_Gen_i::ComponentDataType()
4596 return CORBA::string_dup("HOMARD");
4599 //===========================================================================
4600 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
4601 const char* IORString,
4602 CORBA::Boolean isMultiFile,
4603 CORBA::Boolean isASCII)
4605 CORBA::String_var aString("");
4606 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
4607 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4608 CORBA::Object_var anObj = _orb->string_to_object(IORString);
4609 if (!CORBA::is_nil(anObj)) {
4610 PortableServer::ServantBase_var aServant = GetServant(anObj);
4611 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
4613 std::map<int, PortableServer::ServantBase*>::const_iterator it;
4614 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
4615 if (it->second == aStorable) {
4616 std::stringstream os;
4618 aString = CORBA::string_dup(os.str().c_str());
4624 return aString._retn();
4627 //===========================================================================
4628 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
4629 const char* aLocalPersistentID,
4630 CORBA::Boolean isMultiFile,
4631 CORBA::Boolean isASCII)
4633 CORBA::String_var aString("");
4634 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
4635 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4636 int id = atoi(aLocalPersistentID);
4637 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
4638 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
4639 if (!CORBA::is_nil(object)) {
4640 aString = _orb->object_to_string(object);
4644 return aString._retn();
4647 //===========================================================================
4648 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
4650 if(CORBA::is_nil(myCurrentStudy))
4653 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
4654 if(!aCas->_is_nil())
4657 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
4658 if(!aHypo->_is_nil())
4661 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
4662 if(!aZone->_is_nil())
4665 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
4666 if(!aBoundary->_is_nil())
4669 /* Iteration is not published directly
4670 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
4671 if(!aIter->_is_nil())
4677 //===========================================================================
4678 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
4680 // No Copy/Paste support
4684 //===========================================================================
4685 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
4686 CORBA::Long& theObjectID)
4688 // No Copy/Paste support
4689 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
4690 return aStreamFile._retn();
4693 //===========================================================================
4694 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
4695 CORBA::Long theObjectID)
4697 // No Copy/Paste support
4701 //===========================================================================
4702 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
4703 CORBA::Long theObjectID,
4704 SALOMEDS::SObject_ptr theSObject)
4706 // No Copy/Paste support
4707 SALOMEDS::SObject_var aResultSO;
4708 return aResultSO._retn();
4711 //===========================================================================
4712 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
4714 PortableServer::Servant aServant = 0;
4715 if (!CORBA::is_nil(theObject)) {
4717 aServant = _poa->reference_to_servant(theObject);
4725 //==========================================================================
4726 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
4727 CORBA::Boolean isPublished,
4728 CORBA::Boolean isMultiFile,
4729 CORBA::Boolean& isValidScript)
4731 MESSAGE ("Entree dans DumpPython");
4733 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
4734 if(CORBA::is_nil(aStudy))
4735 return new Engines::TMPFile(0);
4737 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
4738 if(CORBA::is_nil(aSO))
4739 return new Engines::TMPFile(0);
4741 std::string aScript = "\"\"\"\n";
4742 aScript += "Python script for HOMARD\n";
4743 aScript += "Copyright EDF-R&D 1996, 2011, 2014\n";
4744 aScript += "\"\"\"\n";
4745 aScript += "__revision__ = \"V1.2\"\n";
4746 aScript += "import HOMARD\n";
4748 aScript += "import salome\n";
4749 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4751 aScript += "def RebuildData(theStudy):\n";
4752 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
4755 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
4756 MESSAGE (". Au depart \n"<<aScript);
4759 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
4761 MESSAGE (". Ecritures des frontieres");
4762 aScript += "#\n# Creation of the boundaries";
4763 aScript += "\n# ==========================";
4765 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4766 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
4767 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
4769 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4770 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4771 std::string dumpBoundary = dumpCorbaBoundary.in();
4772 MESSAGE (dumpBoundary<<"\n");
4773 aScript += dumpBoundary;
4777 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
4779 MESSAGE (". Ecritures des zones");
4780 aScript += "#\n# Creation of the zones";
4781 aScript += "\n# =====================";
4783 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4784 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
4785 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
4787 HOMARD::HOMARD_Zone_var myZone = (*it_zone).second;
4788 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4789 std::string dumpZone = dumpCorbaZone.in();
4790 MESSAGE (dumpZone<<"\n");
4791 aScript += dumpZone;
4795 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
4797 MESSAGE (". Ecritures des hypotheses");
4798 aScript += "#\n# Creation of the hypotheses";
4799 aScript += "\n# ==========================";
4801 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4802 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
4803 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
4805 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4806 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4807 std::string dumpHypo = dumpCorbaHypo.in();
4808 MESSAGE (dumpHypo<<"\n");
4809 aScript += dumpHypo;
4813 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
4815 MESSAGE (". Ecritures des cas");
4816 aScript += "#\n# Creation of the cases";
4817 aScript += "\n# =====================";
4819 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4820 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4821 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
4823 std::string nomCas = (*it_cas).first;
4824 std::string dumpCas = std::string("\n# Creation of the case ") ;
4825 dumpCas += nomCas + std::string("\n");
4826 dumpCas += std::string("\t") + nomCas;
4827 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4829 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4830 CORBA::String_var cIter0= myCase->GetIter0Name();
4831 std::string iter0 = cIter0.in();
4833 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
4834 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4835 std::string mesh0 = cMesh0.in();
4836 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4837 std::string meshName0 = cMeshName0.in();
4838 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4839 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4840 std::string dumpCas2= dumpCorbaCase.in();
4842 MESSAGE (dumpCas<<dumpCas2<<"\n");
4843 aScript += dumpCas + dumpCas2;
4847 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
4849 MESSAGE (". Ecritures des iterations");
4850 aScript += "#\n# Creation of the iterations" ;
4851 aScript += "\n# ==========================";
4853 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4854 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
4855 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
4857 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4858 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4859 std::string dumpIter = dumpCorbaIter.in();
4860 MESSAGE (dumpIter<<"\n");
4861 aScript += dumpIter;
4865 if (myContextMap[GetCurrentStudyID()]._mesYACSs.size() > 0)
4867 MESSAGE (". Ecritures des schemas YACS");
4868 aScript += "#\n# Creation of the schemas YACS";
4869 aScript += "\n# ============================";
4871 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it_yacs;
4872 for ( it_yacs = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
4873 it_yacs != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); ++it_yacs)
4875 HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second;
4876 CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython();
4877 std::string dumpYACS = dumpCorbaYACS.in();
4878 MESSAGE (dumpYACS<<"\n");
4879 aScript += dumpYACS;
4882 MESSAGE (". Ecritures finales");
4884 aScript += "\n\tpass";
4887 if( !isMultiFile ) // remove unnecessary tabulation
4888 aScript = RemoveTabulation( aScript );
4890 // MESSAGE ("A ecrire \n"<<aScript);
4891 const size_t aLen = strlen(aScript.c_str());
4892 char* aBuffer = new char[aLen+1];
4893 strcpy(aBuffer, aScript.c_str());
4895 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4896 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4898 MESSAGE ("Sortie de DumpPython");
4899 return aStreamFile._retn();
4903 //=============================================================================
4904 //=============================================================================
4906 //=============================================================================
4907 //=============================================================================
4908 void HOMARD_Gen_i::IsValidStudy( )
4910 // MESSAGE( "IsValidStudy" );
4911 if (CORBA::is_nil(myCurrentStudy))
4913 SALOME::ExceptionStruct es;
4914 es.type = SALOME::BAD_PARAM;
4915 es.text = "Invalid study context";
4916 throw SALOME::SALOME_Exception(es);
4921 //=============================================================================
4922 char* HOMARD_Gen_i::VerifieDir(const char* nomDir)
4924 std::string casename = std::string("") ;
4925 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4926 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4927 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
4929 if (std::string(nomDir) == std::string(it->second->GetDirName()))
4931 casename = std::string(it->second->GetName()) ;
4935 return CORBA::string_dup( casename.c_str() );
4937 /*//=============================================================================
4938 void SALOMEException( std::string message )
4940 SALOME::ExceptionStruct es;
4941 es.type = SALOME::BAD_PARAM;
4943 throw SALOME::SALOME_Exception(es);
4946 //=============================================================================
4947 char* HOMARD_Gen_i::getVersion()
4949 #if HOMARD_DEVELOPMENT
4950 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4952 return CORBA::string_dup(HOMARD_VERSION_STR);
4955 //===============================================================================
4956 // Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere
4957 // ligne : la ligne a manipuler
4958 // caractere : le caractere a reperer
4959 // option : 0 : la chaine avant la premiere apparition du caractere
4960 // 1 : la chaine apres la premiere apparition du caractere
4961 // 2 : la chaine avant la derniere apparition du caractere
4962 // 3 : la chaine apres la derniere apparition du caractere
4963 // Si le caractere est absent, on retourne la chaine totale
4964 //===============================================================================
4965 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option )
4967 // MESSAGE("GetStringInTexte, recherche de '"<<caractere<<"' dans '"<<ligne<<"'"<<", option = "<<option);
4969 std::string chaine = ligne ;
4971 if ( option < 2 ) { position = ligne.find_first_of( caractere ) ; }
4972 else { position = ligne.find_last_of( caractere ) ; }
4973 // MESSAGE("position = "<<position);
4974 // MESSAGE("a = "<<ligne.substr( 0, position ).c_str());
4975 // MESSAGE("b = "<<ligne.substr( position+1 ).c_str());
4977 if ( position != std::string::npos )
4979 if ( ( option == 0 ) || ( option == 2 ) ) { chaine = ligne.substr( 0, position ) ; }
4980 else { chaine = ligne.substr( position+1 ) ; }
4985 //=============================================================================
4986 //=============================================================================
4987 // Gestion des preferences
4988 //=============================================================================
4989 //=============================================================================
4990 // Decodage du fichier d'arcihvage des preferences
4992 void HOMARD_Gen_i::SetPreferences( )
4994 MESSAGE ( "SetPreferences" );
4996 std::string ligne, mot_cle, salome_version ;
4999 // A. Les valeurs par defaut ; elles doivent etre coherentes
5000 std::string LanguageShort = "fr" ;
5001 int PublisMeshIN = 0 ;
5002 int PublisMeshOUT = 0 ;
5003 int YACSMaxIter = 0 ;
5004 int YACSMaxNode = 0 ;
5005 int YACSMaxElem = 0 ;
5007 // B. La version de salome
5008 // Cela se presente sous la forme :
5009 // [SALOME KERNEL] : 7.3.0
5011 File = getenv("KERNEL_ROOT_DIR") ;
5012 File += "/bin/salome/VERSION" ;
5013 MESSAGE ( "File = "<<File ) ;
5014 std::ifstream fichier0( File.c_str() ) ;
5015 if ( fichier0 ) // ce test échoue si le fichier n'est pas ouvert
5017 std::string ligne; // variable contenant chaque ligne lue
5018 while ( std::getline( fichier0, ligne ) )
5020 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
5021 ligne_bis >> mot_cle ;
5022 if ( mot_cle == "[SALOME" )
5024 salome_version = GetStringInTexte ( ligne, " ", 3 ) ;
5025 // MESSAGE ( "salome_version = "<<salome_version<<"|||");
5030 else { ok = false ; }
5032 // B. Decodage du fichier de preferences
5035 std::string PrefFile ;
5036 PrefFile = getenv("HOME") ;
5037 PrefFile += "/.config/salome/SalomeApprc." + salome_version ;
5038 MESSAGE ( "PrefFile = "<<PrefFile ) ;
5040 std::ifstream fichier( PrefFile.c_str() );
5041 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
5043 bool section_langue = false ;
5044 bool section_homard = false ;
5045 while ( std::getline( fichier, ligne ) )
5047 std::string chaine ;
5048 // 1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
5049 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
5050 ligne_bis >> mot_cle ;
5053 // 2.1. Debut d'une section
5054 // MESSAGE(mot_cle);
5055 if ( mot_cle == "<section" )
5056 { /*MESSAGE ( "Debut de la section : "<< ligne);*/
5057 ligne_bis >> mot_cle ;
5058 chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5059 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5060 if ( chaine == "language" ) { section_langue = true ; }
5061 if ( chaine == "HOMARD" ) { section_homard = true ; }
5062 // MESSAGE ( "section_langue = "<<section_langue<<", section_homard = "<<section_homard);
5064 // 2.2. Fin d'une section
5065 else if ( mot_cle == "</section>" )
5066 { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<<section_langue<<", section_homard = "<<section_homard);*/
5067 section_langue = false ;
5068 section_homard = false ; }
5072 else if ( section_langue || section_homard )
5073 { /*MESSAGE ( "a decoder : "<< ligne);*/
5074 ligne_bis >> mot_cle ;
5075 chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5076 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5077 // MESSAGE("chaine = "<<chaine<<"|");
5078 ligne_bis >> mot_cle ;
5079 std::string chaine2 = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5080 chaine2 = GetStringInTexte ( chaine2, "\"", 0 ) ;
5081 // MESSAGE("chaine2 = "<<chaine2<<"|");
5083 if ( section_langue )
5084 { if ( chaine2 == "language" ) { LanguageShort = chaine ; } }
5086 if ( section_homard )
5088 std::istringstream chainebis( chaine ) ;
5089 // 3.2.1. Les publications
5090 if ( chaine2 == "publish_mesh_in" ) { chainebis >> PublisMeshIN ; }
5091 if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT ; }
5092 // 3.2.2. Les maximum pour YACS
5093 if ( chaine2 == "max_iter" ) { chainebis >> YACSMaxIter ; }
5094 if ( chaine2 == "max_node" ) { chainebis >> YACSMaxNode ; }
5095 if ( chaine2 == "max_elem" ) { chainebis >> YACSMaxElem ; }
5102 // C. Enregistrement
5103 MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort );
5104 MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT);
5105 MESSAGE ("Enregistrement de YACSMaxIter = " << YACSMaxIter<<", YACSMaxNode = "<< YACSMaxNode<<", YACSMaxElem = "<< YACSMaxElem);
5106 SetLanguageShort( LanguageShort.c_str() ) ;
5107 SetPublisMesh(PublisMeshIN, PublisMeshOUT) ;
5108 SetYACSMaximum(YACSMaxIter, YACSMaxNode, YACSMaxElem) ;
5112 //===============================================================================
5114 //===============================================================================
5115 void HOMARD_Gen_i::SetLanguageShort(const char* LanguageShort)
5117 // MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort );
5118 _LangueShort = LanguageShort ;
5119 if ( _LangueShort == "fr" ) { _Langue = "Francais" ; }
5120 else { _Langue = "English" ; }
5123 char* HOMARD_Gen_i::GetLanguageShort()
5125 // MESSAGE ("GetLanguageShort");
5126 return CORBA::string_dup( _LangueShort.c_str() );
5128 //===============================================================================
5129 // Options de publications
5130 //===============================================================================
5131 void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT)
5133 _PublisMeshIN = PublisMeshIN ;
5134 _PublisMeshOUT = PublisMeshOUT ;
5137 CORBA::Long HOMARD_Gen_i::GetPublisMeshIN()
5139 return _PublisMeshIN ;
5141 CORBA::Long HOMARD_Gen_i::GetPublisMeshOUT()
5143 return _PublisMeshOUT ;
5145 //===============================================================================
5147 //===============================================================================
5148 void HOMARD_Gen_i::SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem)
5150 _YACSMaxIter = YACSMaxIter ;
5151 _YACSMaxNode = YACSMaxNode ;
5152 _YACSMaxElem = YACSMaxElem ;
5155 CORBA::Long HOMARD_Gen_i::GetYACSMaxIter()
5157 return _YACSMaxIter ;
5159 CORBA::Long HOMARD_Gen_i::GetYACSMaxNode()
5161 return _YACSMaxNode ;
5163 CORBA::Long HOMARD_Gen_i::GetYACSMaxElem()
5165 return _YACSMaxElem ;
5168 //=============================================================================
5172 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
5173 PortableServer::POA_ptr poa,
5174 PortableServer::ObjectId* contId,
5175 const char* instanceName,
5176 const char* interfaceName)
5178 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
5179 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
5180 return myHOMARD_Gen->getId();