1 // Copyright (C) 2011-2014 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, or (at your option) any later version.
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("IterationHomard")) continue;
632 if(value == std::string("HypoHomard")) continue;
633 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
634 aStudyBuilder->RemoveObject(so);
637 int etat = myIteration->GetState();
640 SetEtatIter(nomIter,1);
641 const char * nomCas = myIteration->GetCaseName();
642 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
643 if (CORBA::is_nil(myCase))
645 SALOME::ExceptionStruct es;
646 es.type = SALOME::BAD_PARAM;
647 es.text = "Invalid case context";
648 throw SALOME::SALOME_Exception(es);
651 std::string nomDir = myIteration->GetDirName();
652 std::string nomFichier = myIteration->GetMeshFile();
653 std::string commande = "rm -rf " + std::string(nomDir);
654 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
655 MESSAGE ( "commande = " << commande );
656 if ((system(commande.c_str())) != 0)
658 SALOME::ExceptionStruct es;
659 es.type = SALOME::BAD_PARAM;
660 es.text = "The directory for the calculation cannot be cleared." ;
661 throw SALOME::SALOME_Exception(es);
664 // Suppression du maillage publie dans SMESH
665 std::string MeshName = myIteration->GetMeshName() ;
666 DeleteResultInSmesh(nomFichier, MeshName) ;
670 //=============================================================================
671 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
673 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
674 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
675 if (CORBA::is_nil(myIteration))
677 SALOME::ExceptionStruct es;
678 es.type = SALOME::BAD_PARAM;
679 es.text = "Invalid iteration";
680 throw SALOME::SALOME_Exception(es);
684 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
685 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
686 for (; aIter->More(); aIter->Next())
688 SALOMEDS::SObject_var so = aIter->Value();
689 SALOMEDS::GenericAttribute_var anAttr;
690 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
691 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
692 std::string value (aCommentAttr->Value());
693 /* MESSAGE("... value = " << value);*/
694 if( (value == std::string("logInfo")) || ( value == std::string("SummaryInfo")) )
696 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
697 aStudyBuilder->RemoveObject(so);
701 const char * nomCas = myIteration->GetCaseName();
702 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
703 if (CORBA::is_nil(myCase))
705 SALOME::ExceptionStruct es;
706 es.type = SALOME::BAD_PARAM;
707 es.text = "Invalid case context";
708 throw SALOME::SALOME_Exception(es);
711 const char* nomDir = myIteration->GetDirName();
712 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
713 commande += std::string(nomDir) + "/Liste.*info" ;
714 /* MESSAGE ( "commande = " << commande );*/
715 if ((system(commande.c_str())) != 0)
717 SALOME::ExceptionStruct es;
718 es.type = SALOME::BAD_PARAM;
719 es.text = "The directory for the calculation cannot be cleared." ;
720 throw SALOME::SALOME_Exception(es);
724 //=============================================================================
725 void HOMARD_Gen_i::InvalideYACS(const char* YACSName)
727 MESSAGE( "InvalideYACS : YACSName = " << YACSName );
728 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[YACSName];
729 if (CORBA::is_nil(myYACS))
731 SALOME::ExceptionStruct es;
732 es.type = SALOME::BAD_PARAM;
733 es.text = "Invalid schema YACS";
734 throw SALOME::SALOME_Exception(es);
738 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
739 SALOMEDS::ChildIterator_var aYACS = myCurrentStudy->NewChildIterator(aYACSSO);
740 for (; aYACS->More(); aYACS->Next())
742 SALOMEDS::SObject_var so = aYACS->Value();
743 SALOMEDS::GenericAttribute_var anAttr;
744 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
745 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
746 std::string value (aCommentAttr->Value());
747 if( value == std::string("xml") )
749 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
750 aStudyBuilder->RemoveObject(so);
753 std::string nomFichier = myYACS->GetXMLFile();
754 std::string commande = "rm -rf " + std::string(nomFichier) ;
755 MESSAGE ( "commande = " << commande );
756 if ((system(commande.c_str())) != 0)
758 SALOME::ExceptionStruct es;
759 es.type = SALOME::BAD_PARAM;
760 es.text = "The XML file for the schema YACS cannot be removed." ;
761 throw SALOME::SALOME_Exception(es);
765 //=============================================================================
766 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
768 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
769 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
770 if (CORBA::is_nil(myZone))
772 SALOME::ExceptionStruct es;
773 es.type = SALOME::BAD_PARAM;
774 es.text = "Invalid zone";
775 throw SALOME::SALOME_Exception(es);
778 HOMARD::listeHypo* maListe = myZone->GetHypo();
779 int numberOfHypo = maListe->length();
780 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
781 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
783 std::string nomHypo = std::string((*maListe)[NumeHypo]);
784 MESSAGE( ".. nomHypo = " << nomHypo );
785 InvalideHypo(nomHypo.c_str());
788 //=============================================================================
789 //=============================================================================
791 //=============================================================================
792 //=============================================================================
793 // Association de lien entre des structures identifiees par leurs noms
794 //=============================================================================
795 //=============================================================================
796 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
798 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
800 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
801 if (CORBA::is_nil(myCase))
803 SALOME::ExceptionStruct es;
804 es.type = SALOME::BAD_PARAM;
805 es.text = "Invalid case";
806 throw SALOME::SALOME_Exception(es);
810 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
811 if (CORBA::is_nil(myIteration))
813 SALOME::ExceptionStruct es;
814 es.type = SALOME::BAD_PARAM;
815 es.text = "Invalid iteration";
816 throw SALOME::SALOME_Exception(es);
820 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
821 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
822 if (CORBA::is_nil(aCasSO))
824 SALOME::ExceptionStruct es;
825 es.type = SALOME::BAD_PARAM;
826 es.text = "Invalid case";
827 throw SALOME::SALOME_Exception(es);
831 aStudyBuilder->NewCommand();
832 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
833 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
834 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
835 aStudyBuilder->CommitCommand();
837 myCase->AddIteration(nomIter);
838 myIteration->SetCaseName(nomCas);
840 //=====================================================================================
841 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
843 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
845 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
846 ASSERT(!CORBA::is_nil(myHypo));
847 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
848 ASSERT(!CORBA::is_nil(aHypoSO));
850 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
851 ASSERT(!CORBA::is_nil(myZone));
852 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
853 ASSERT(!CORBA::is_nil(aZoneSO));
855 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
857 aStudyBuilder->NewCommand();
859 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
860 aStudyBuilder->Addreference(aSubSO, aZoneSO);
862 aStudyBuilder->CommitCommand();
864 myZone->AddHypo(nomHypothesis);
865 myHypo->AddZone0(ZoneName, TypeUse);
867 //=============================================================================
868 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
870 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
872 // Verification de l'existence de l'hypothese
873 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
874 ASSERT(!CORBA::is_nil(myHypo));
875 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
876 ASSERT(!CORBA::is_nil(aHypoSO));
878 // Verification de l'existence de l'iteration
879 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
880 ASSERT(!CORBA::is_nil(myIteration));
881 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
882 ASSERT(!CORBA::is_nil(aIterSO));
884 // Gestion de l'arbre d'etudes
885 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
886 aStudyBuilder->NewCommand();
887 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
888 aStudyBuilder->Addreference(aSubSO, aHypoSO);
889 aStudyBuilder->CommitCommand();
892 myIteration->SetHypoName(nomHypo);
893 myHypo->LinkIteration(nomIter);
895 // On stocke les noms des champ a interpoler pour le futur controle de la donnee des pas de temps
896 myIteration->SupprFieldInterps() ;
897 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
898 int numberOfFieldsx2 = ListField->length();
899 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
901 std::string FieldName = std::string((*ListField)[iaux]) ;
902 myIteration->SetFieldInterp(FieldName.c_str()) ;
906 //=============================================================================
907 //=============================================================================
909 //=============================================================================
910 //=============================================================================
911 // Dissociation de lien entre des structures identifiees par leurs noms
912 //=============================================================================
913 //=============================================================================
914 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
916 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
918 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
919 ASSERT(!CORBA::is_nil(myHypo));
920 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
921 ASSERT(!CORBA::is_nil(aHypoSO));
923 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
924 ASSERT(!CORBA::is_nil(myZone));
925 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
926 ASSERT(!CORBA::is_nil(aZoneSO));
928 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
930 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
931 for (; it->More(); it->Next())
933 SALOMEDS::SObject_var aHypObj = it->Value();
934 SALOMEDS::SObject_var ptrObj;
935 if (aHypObj->ReferencedObject(ptrObj))
937 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
939 aStudyBuilder->NewCommand();
940 aStudyBuilder->RemoveObject(aHypObj);
941 aStudyBuilder->CommitCommand();
947 myZone->SupprHypo(nomHypothesis);
948 myHypo->SupprZone(ZoneName);
950 //=============================================================================
951 //=============================================================================
954 //=============================================================================
955 //=============================================================================
956 // Recuperation des listes
957 //=============================================================================
958 //=============================================================================
959 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
961 MESSAGE("GetAllBoundarysName");
964 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
965 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
966 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
968 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
969 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
971 ret[i++] = CORBA::string_dup((*it).first.c_str());
976 //=============================================================================
977 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
979 MESSAGE("GetAllCasesName");
982 HOMARD::listeCases_var ret = new HOMARD::listeCases;
983 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
984 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
986 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
987 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
989 ret[i++] = CORBA::string_dup((*it).first.c_str());
994 //=============================================================================
995 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
997 MESSAGE("GetAllHypothesesName");
1000 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
1001 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
1002 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
1004 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
1005 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
1007 ret[i++] = CORBA::string_dup((*it).first.c_str());
1012 //=============================================================================
1013 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
1015 MESSAGE("GetAllIterationsName");
1018 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
1019 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
1020 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
1022 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
1023 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
1025 ret[i++] = CORBA::string_dup((*it).first.c_str());
1030 //=============================================================================
1031 HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName()
1033 MESSAGE("GetAllYACSsName");
1036 HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs;
1037 ret->length(myContextMap[GetCurrentStudyID()]._mesYACSs.size());
1038 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it;
1040 for (it = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
1041 it != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); it++)
1043 ret[i++] = CORBA::string_dup((*it).first.c_str());
1048 //=============================================================================
1049 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
1051 MESSAGE("GetAllZonesName");
1054 HOMARD::listeZones_var ret = new HOMARD::listeZones;
1055 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
1056 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
1058 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
1059 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
1061 ret[i++] = CORBA::string_dup((*it).first.c_str());
1066 //=============================================================================
1067 //=============================================================================
1069 //=============================================================================
1070 //=============================================================================
1071 // Recuperation des structures identifiees par leurs noms
1072 //=============================================================================
1073 //=============================================================================
1074 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
1076 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
1077 ASSERT(!CORBA::is_nil(myBoundary));
1078 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1080 //=============================================================================
1081 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
1083 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1084 ASSERT(!CORBA::is_nil(myCase));
1085 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1087 //=============================================================================
1088 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
1090 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
1091 ASSERT(!CORBA::is_nil(myHypothesis));
1092 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1094 //=============================================================================
1095 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
1097 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
1098 ASSERT(!CORBA::is_nil(myIteration));
1099 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1101 //=============================================================================
1102 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS)
1104 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
1105 ASSERT(!CORBA::is_nil(myYACS));
1106 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
1108 //=============================================================================
1109 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
1111 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
1112 ASSERT(!CORBA::is_nil(myZone));
1113 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1115 //=============================================================================
1116 //=============================================================================
1118 //=============================================================================
1119 //=============================================================================
1121 //=============================================================================
1122 //=============================================================================
1123 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)
1125 INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1126 INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
1131 if ( _PublisMeshIN != 0 ) option = 2 ;
1132 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option) ;
1133 myCase->SetDirName(DirName) ;
1135 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1139 //=============================================================================
1140 //=============================================================================
1142 //=============================================================================
1143 //=============================================================================
1144 // Recuperation des structures par le contexte
1145 //=============================================================================
1146 //=============================================================================
1147 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1149 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1150 ASSERT(!CORBA::is_nil(myCase));
1152 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1153 ASSERT(!CORBA::is_nil(myIteration));
1155 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1157 //=============================================================================
1158 //=============================================================================
1160 //=============================================================================
1161 //=============================================================================
1162 // Nouvelles structures
1163 //=============================================================================
1164 //=============================================================================
1165 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1167 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1168 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1169 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1170 return aCase._retn();
1172 //=============================================================================
1173 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1175 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1176 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1177 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1178 return aHypo._retn();
1180 //=============================================================================
1181 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1183 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1184 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1185 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1186 return aIter._retn();
1188 //=============================================================================
1189 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1191 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1192 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1193 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1194 return aBoundary._retn();
1196 //=============================================================================
1197 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1199 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1200 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1201 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1202 return aZone._retn();
1204 //=============================================================================
1205 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS()
1207 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1208 HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine);
1209 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this());
1210 return aYACS._retn();
1212 //=============================================================================
1213 //=============================================================================
1215 //=============================================================================
1216 //=============================================================================
1217 // Creation des structures identifiees par leurs noms
1218 //=============================================================================
1219 //=============================================================================
1220 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1222 // Creation d'un cas initial
1223 // nomCas : nom du cas a creer
1224 // MeshName, MeshFile : nom et fichier du maillage correspondant
1227 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1230 if ( _PublisMeshIN != 0 ) option = 2 ;
1231 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option) ;
1233 // Valeurs par defaut des filtrages
1234 myCase->SetPyram(0);
1236 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1238 //=============================================================================
1239 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1241 // nomCas : nom du cas a creer
1242 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1245 INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1246 std::string nomDirWork = getenv("PWD") ;
1249 // A. Decodage du point de reprise
1250 // A.1. Controle du repertoire de depart de l'iteration
1252 codret = chdir(DirNameStart) ;
1254 codret = _chdir(DirNameStart) ;
1258 SALOME::ExceptionStruct es;
1259 es.type = SALOME::BAD_PARAM;
1260 es.text = "The directory of the iteration does not exist.";
1261 throw SALOME::SALOME_Exception(es);
1264 // A.2. Reperage des fichiers du repertoire de reprise
1265 std::string file_configuration = "" ;
1266 std::string file_maillage_homard = "" ;
1270 struct dirent *dirp;
1271 dp = opendir(DirNameStart);
1272 while ( (dirp = readdir(dp)) != NULL )
1274 std::string file_name(dirp->d_name);
1275 // MESSAGE ( file_name );
1276 bilan = file_name.find("HOMARD.Configuration.") ;
1277 if ( bilan != string::npos ) { file_configuration = file_name ; }
1278 bilan = file_name.find("maill.") ;
1279 if ( bilan != string::npos )
1281 bilan = file_name.find(".hom.med") ;
1282 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1287 HANDLE hFind = INVALID_HANDLE_VALUE;
1288 WIN32_FIND_DATA ffd;
1289 hFind = FindFirstFile(DirNameStart, &ffd);
1290 if (INVALID_HANDLE_VALUE != hFind) {
1291 while (FindNextFile(hFind, &ffd) != 0) {
1292 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1293 std::string file_name(ffd.cFileName);
1294 bilan = file_name.find("HOMARD.Configuration.") ;
1295 if ( bilan != string::npos ) { file_configuration = file_name ; }
1296 bilan = file_name.find("maill.") ;
1297 if ( bilan != string::npos )
1299 bilan = file_name.find(".hom.med") ;
1300 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1306 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1307 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1309 if ( ( file_configuration == "" ) || ( file_maillage_homard == "" ) )
1311 SALOME::ExceptionStruct es;
1312 es.type = SALOME::BAD_PARAM;
1314 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1315 else { text = "The HOMARD mesh file cannot be found." ; }
1316 es.text = CORBA::string_dup(text.c_str());
1317 throw SALOME::SALOME_Exception(es);
1320 // B. Lecture du fichier de configuration
1321 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1327 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1328 std::ifstream fichier( file_configuration.c_str() );
1329 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1331 std::string ligne; // variable contenant chaque ligne lue
1332 std::string mot_cle;
1333 std::string argument;
1335 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1336 while ( std::getline( fichier, ligne ) )
1338 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1339 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1340 ligne_bis >> mot_cle ;
1341 // B.2. Des valeurs entieres : le second bloc de la ligne
1342 if ( mot_cle == "NumeIter" )
1344 ligne_bis >> NumeIter ;
1347 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1348 else if ( ( mot_cle == "TypeConf" ) || ( mot_cle == "TypeElem" ) )
1350 ligne_bis >> argument ;
1352 if ( mot_cle == "TypeConf" )
1354 if ( argument == "conforme" ) { TypeConf = 1 ; }
1355 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1356 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1357 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1359 else if ( mot_cle == "TypeElem" )
1361 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1362 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1365 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1366 // il faut les supprimer
1367 else if ( ( mot_cle == "CCNoMNP1" ) || ( mot_cle == "CCMaiNP1" ) )
1369 ligne_bis >> argument ;
1370 if ( argument[0] == '"' ) { decalage = 1 ; }
1371 else { decalage = 0 ; }
1372 size_t size = argument.size() + 1 - 2*decalage ;
1374 if ( mot_cle == "CCNoMNP1" )
1376 MeshName = new char[ size ];
1377 strncpy( MeshName, argument.c_str()+decalage, size );
1378 MeshName[size-1] = '\0' ;
1380 else if ( mot_cle == "CCMaiNP1" )
1382 MeshFile = new char[ size ];
1383 strncpy( MeshFile, argument.c_str()+decalage, size );
1384 MeshFile[size-1] = '\0' ;
1388 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1389 MESSAGE ( "==> MeshName : " << MeshName ) ;
1390 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1391 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1392 MESSAGE ( "==> Pyram : " << Pyram ) ;
1396 SALOME::ExceptionStruct es;
1397 es.type = SALOME::BAD_PARAM;
1398 std::string text = "The configuration file cannot be read." ;
1399 es.text = CORBA::string_dup(text.c_str());
1400 throw SALOME::SALOME_Exception(es);
1403 // C. Creation effective du cas
1406 if ( _PublisMeshIN != 0 ) option = 2 ;
1407 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, option) ;
1409 // D. Parametrages lus dans le fichier de configuration
1411 myCase->SetConfType (TypeConf) ;
1412 myCase->SetPyram (Pyram) ;
1414 // E. Copie du fichier de maillage homard
1415 // E.1. Repertoire associe au cas
1416 char* nomDirCase = myCase->GetDirName() ;
1417 // E.2. Repertoire associe a l'iteration de ce cas
1419 IterName = myCase->GetIter0Name() ;
1420 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1421 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1422 Iter->SetDirNameLoc(nomDirIter);
1423 std::string nomDirIterTotal ;
1424 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1426 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1428 if (_mkdir(nomDirIterTotal.c_str()) != 0)
1431 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1432 SALOME::ExceptionStruct es;
1433 es.type = SALOME::BAD_PARAM;
1434 std::string text = "The directory for the computation cannot be created." ;
1435 es.text = CORBA::string_dup(text.c_str());
1436 throw SALOME::SALOME_Exception(es);
1438 // E.3. Copie du maillage HOMARD au format MED
1440 codret = chdir(DirNameStart) ;
1442 codret = _chdir(DirNameStart) ;
1444 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1445 MESSAGE ( "commande : " << commande ) ;
1446 codret = system(commande.c_str()) ;
1447 MESSAGE ( "codret : " << codret ) ;
1450 SALOME::ExceptionStruct es;
1451 es.type = SALOME::BAD_PARAM;
1452 es.text = "The starting point for the case cannot be copied into the working directory.";
1453 throw SALOME::SALOME_Exception(es);
1463 chdir(nomDirWork.c_str());
1465 _chdir(nomDirWork.c_str());
1467 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1469 //=============================================================================
1470 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1472 // nomCas : nom du cas a creer
1473 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1476 INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1478 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1480 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1481 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1483 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1485 //=============================================================================
1486 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1488 // nomCas : nom du cas a creer
1489 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1490 // Number : numero de l'iteration de depart
1493 INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1496 SALOME::ExceptionStruct es;
1497 es.type = SALOME::BAD_PARAM;
1498 es.text = "The number of iteration must be positive.";
1499 throw SALOME::SALOME_Exception(es);
1503 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1505 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1506 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1508 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1510 //=============================================================================
1511 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1513 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1514 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1515 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1518 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1519 std::string nomDirWork = getenv("PWD") ;
1520 std::string DirNameStartIter ;
1522 int NumeIterMax = -1 ;
1524 // A.1. Controle du repertoire de depart du cas
1526 codret = chdir(DirNameStart) ;
1528 codret = _chdir(DirNameStart) ;
1532 SALOME::ExceptionStruct es;
1533 es.type = SALOME::BAD_PARAM;
1534 es.text = "The directory of the case for the pursuit does not exist.";
1535 throw SALOME::SALOME_Exception(es);
1538 // A.2. Reperage des sous-repertoire du repertoire de reprise
1539 bool existe = false ;
1542 struct dirent *dirp;
1543 dp = opendir(DirNameStart);
1544 while ( (dirp = readdir(dp)) != NULL ) {
1545 std::string DirName_1(dirp->d_name);
1547 HANDLE hFind = INVALID_HANDLE_VALUE;
1548 WIN32_FIND_DATA ffd;
1549 hFind = FindFirstFile(DirNameStart, &ffd);
1550 if (INVALID_HANDLE_VALUE != hFind) {
1551 while (FindNextFile(hFind, &ffd) != 0) {
1552 std::string DirName_1 = "";
1553 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1554 DirName_1 = std::string(ffd.cFileName);
1557 if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) )
1560 if ( chdir(DirName_1.c_str()) == 0 )
1562 // On cherche le fichier de configuration dans ce sous-repertoire
1563 codret = chdir(DirNameStart);
1565 struct dirent *dirp_1;
1566 dp_1 = opendir(DirName_1.c_str()) ;
1567 while ( (dirp_1 = readdir(dp_1)) != NULL )
1569 std::string file_name_1(dirp_1->d_name);
1571 if ( _chdir(DirName_1.c_str()) == 0 )
1573 codret = _chdir(DirNameStart);
1574 HANDLE hFind1 = INVALID_HANDLE_VALUE;
1575 WIN32_FIND_DATA ffd1;
1576 hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1);
1577 while (FindNextFile(hFind1, &ffd1) != 0)
1579 if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1580 std::string file_name_1(ffd1.cFileName);
1582 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1583 if ( bilan != string::npos )
1585 // Decodage du fichier pour trouver le numero d'iteration
1587 chdir(DirName_1.c_str()) ;
1589 _chdir(DirName_1.c_str()) ;
1592 std::ifstream fichier( file_name_1.c_str() );
1593 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1596 std::string ligne; // variable contenant chaque ligne lue
1597 std::string mot_cle;
1598 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1599 while ( std::getline( fichier, ligne ) )
1601 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1602 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1603 ligne_bis >> mot_cle ;
1604 if ( mot_cle == "NumeIter" )
1606 ligne_bis >> NumeIter ;
1608 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1609 if ( Number == - 1 )
1611 if ( NumeIter >= NumeIterMax )
1613 NumeIterMax = NumeIter ;
1614 DirNameStartIter = DirName_1 ;
1619 if ( NumeIter == Number )
1621 DirNameStartIter = DirName_1 ;
1631 SALOME::ExceptionStruct es;
1632 es.type = SALOME::BAD_PARAM;
1633 std::string text = "The configuration file cannot be read." ;
1634 es.text = CORBA::string_dup(text.c_str());
1635 throw SALOME::SALOME_Exception(es);
1638 chdir(DirNameStart) ;
1640 _chdir(DirNameStart) ;
1643 if ( existe ) { break ; }
1650 if ( existe ) { break ; }
1656 chdir(nomDirWork.c_str());
1660 _chdir(nomDirWork.c_str());
1663 if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) )
1665 SALOME::ExceptionStruct es;
1666 es.type = SALOME::BAD_PARAM;
1667 es.text = "The directory of the iteration does not exist.";
1668 throw SALOME::SALOME_Exception(es);
1672 return DirNameStartIter ;
1674 //=============================================================================
1675 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)
1677 // nomCas : nom du cas a creer
1678 // MeshName, MeshFile : nom et fichier du maillage correspondant
1679 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1680 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1681 // -1 : le maillage n'est pas fourni
1682 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1683 // Option : multiple de nombres premiers
1684 // 1 : aucune option
1685 // x2 : publication du maillage dans SMESH
1687 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1688 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1689 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1695 // A.2. Controle du nom :
1696 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1698 SALOME::ExceptionStruct es;
1699 es.type = SALOME::BAD_PARAM;
1700 es.text = "This case has already been defined.";
1701 throw SALOME::SALOME_Exception(es);
1705 // A.3. Controle du fichier du maillage
1706 int existeMeshFile ;
1707 if ( MeshOption >= 0 )
1709 existeMeshFile = MEDFileExist ( MeshFile ) ;
1710 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1711 if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) )
1713 SALOME::ExceptionStruct es;
1714 es.type = SALOME::BAD_PARAM;
1715 es.text = "The mesh file does not exist.";
1716 throw SALOME::SALOME_Exception(es);
1720 else { existeMeshFile = 0 ; }
1722 // B. Creation de l'objet cas et publication
1723 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1724 HOMARD::HOMARD_Cas_var myCase = newCase();
1725 myCase->SetName(nomCas);
1726 SALOMEDS::SObject_var aSO;
1727 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1728 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1730 // C. Caracteristiques du maillage
1731 if ( existeMeshFile != 0 )
1733 // Les valeurs extremes des coordonnees
1734 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1735 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1736 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1737 if (LesExtremes.size()!=10) { return false; }
1739 for (int i =0 ; i< LesExtremes.size() ; i++)
1740 aSeq[i]=LesExtremes[i] ;
1741 myCase->SetBoundingBox(aSeq) ;
1743 // MESSAGE ( "CreateCase0 : Les groupes" );
1744 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1745 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1746 aSeqGroupe->length(LesGroupes.size());
1747 std::set<std::string>::const_iterator it ;
1749 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1750 aSeqGroupe[i++]=(*it).c_str() ;
1751 myCase->SetGroups(aSeqGroupe) ;
1754 // D. L'iteration initiale du cas
1755 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1756 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1757 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1759 std::string NomIteration = std::string(MeshName) ;
1760 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1762 std::ostringstream nom;
1763 nom << MeshName << monNum;
1764 NomIteration = nom.str();
1767 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1769 // D.2. Creation de l'iteration
1770 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1771 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1772 anIter->SetName(NomIteration.c_str());
1773 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1775 // D.4. Maillage correspondant
1776 if ( existeMeshFile != 0 )
1778 anIter->SetMeshFile(MeshFile);
1779 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1781 anIter->SetMeshName(MeshName);
1783 // D.5. Numero d'iteration
1784 anIter->SetNumber(NumeIter);
1787 SetEtatIter(NomIteration.c_str(), -NumeIter);
1790 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1792 //=============================================================================
1793 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1795 INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1798 // A. Controle du nom :
1799 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1801 SALOME::ExceptionStruct es;
1802 es.type = SALOME::BAD_PARAM;
1803 es.text = "This hypothesis has already been defined.";
1804 throw SALOME::SALOME_Exception(es);
1808 // B. Creation de l'objet
1809 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1810 if (CORBA::is_nil(myHypothesis))
1812 SALOME::ExceptionStruct es;
1813 es.type = SALOME::BAD_PARAM;
1814 es.text = "Unable to create the hypothesis";
1815 throw SALOME::SALOME_Exception(es);
1818 myHypothesis->SetName(nomHypothesis);
1820 // C. Enregistrement
1821 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1823 SALOMEDS::SObject_var aSO;
1824 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1826 // D. Valeurs par defaut des options avancees
1827 myHypothesis->SetNivMax(-1);
1828 myHypothesis->SetDiamMin(-1.0);
1829 myHypothesis->SetAdapInit(0);
1830 myHypothesis->SetLevelOutput(0);
1832 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1835 //=============================================================================
1836 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1837 //=============================================================================
1839 INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1842 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1843 if (CORBA::is_nil(myIterationParent))
1845 SALOME::ExceptionStruct es;
1846 es.type = SALOME::BAD_PARAM;
1847 es.text = "The parent iteration is not defined.";
1848 throw SALOME::SALOME_Exception(es);
1852 const char* nomCas = myIterationParent->GetCaseName();
1853 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1854 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1855 if (CORBA::is_nil(myCase))
1857 SALOME::ExceptionStruct es;
1858 es.type = SALOME::BAD_PARAM;
1859 es.text = "Invalid case context";
1860 throw SALOME::SALOME_Exception(es);
1863 const char* nomDirCase = myCase->GetDirName();
1865 // Controle du nom :
1866 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1868 SALOME::ExceptionStruct es;
1869 es.type = SALOME::BAD_PARAM;
1870 es.text = "This iteration has already been defined.";
1871 throw SALOME::SALOME_Exception(es);
1875 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1876 if (CORBA::is_nil(myIteration))
1878 SALOME::ExceptionStruct es;
1879 es.type = SALOME::BAD_PARAM;
1880 es.text = "Unable to create the iteration";
1881 throw SALOME::SALOME_Exception(es);
1884 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1885 // Nom de l'iteration et du maillage
1886 myIteration->SetName(NomIteration);
1887 myIteration->SetMeshName(NomIteration);
1888 myIteration->SetState(1);
1890 int numero = myIterationParent->GetNumber() + 1;
1891 myIteration->SetNumber(numero);
1893 // Nombre d'iterations deja connues pour le cas, permettant
1894 // la creation d'un sous-repertoire unique
1895 int nbitercase = myCase->GetNumberofIter();
1896 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1897 myIteration->SetDirNameLoc(nomDirIter);
1899 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1900 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1901 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1902 // situation la plus frequente.
1903 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1904 // le nombre d'iterations du cas permet d'eviter les collisions.
1906 if ( nbitercase < 100 ) { jaux = 2 ; }
1907 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1908 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1909 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1911 std::ostringstream iaux ;
1912 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1913 std::stringstream MeshFile;
1914 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1915 myIteration->SetMeshFile(MeshFile.str().c_str());
1917 // Association avec le cas
1918 std::string label = "IterationHomard_" + std::string(nomIterParent);
1919 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1920 // Lien avec l'iteration precedente
1921 myIterationParent->LinkNextIteration(NomIteration);
1922 myIteration->SetIterParentName(nomIterParent);
1923 // Gestion de l'arbre d'etudes
1924 SALOMEDS::SObject_var aIterSOParent = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIterationParent)));
1925 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
1926 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
1927 aStudyBuilder->NewCommand();
1928 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
1929 aStudyBuilder->Addreference(aSubSO, aIterSOParent);
1930 aStudyBuilder->CommitCommand();
1932 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1934 //=============================================================================
1935 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1937 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1940 // Controle du nom :
1941 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1943 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1944 SALOME::ExceptionStruct es;
1945 es.type = SALOME::BAD_PARAM;
1946 es.text = "This boundary has already been defined";
1947 throw SALOME::SALOME_Exception(es);
1951 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1952 myBoundary->SetName(BoundaryName);
1953 myBoundary->SetType(BoundaryType);
1955 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1957 SALOMEDS::SObject_var aSO;
1958 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1960 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1962 //=============================================================================
1963 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1965 INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1966 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1967 myBoundary->SetMeshFile( MeshFile ) ;
1968 myBoundary->SetMeshName( MeshName ) ;
1970 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1972 //=============================================================================
1973 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1974 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1975 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1976 CORBA::Double Rayon)
1978 INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1980 SALOME::ExceptionStruct es;
1983 { es.text = "The radius must be positive." ;
1985 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1986 if ( daux < 0.0000001 )
1987 { es.text = "The axis must be a non 0 vector." ;
1991 es.type = SALOME::BAD_PARAM;
1992 throw SALOME::SALOME_Exception(es);
1996 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1997 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1999 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2001 //=============================================================================
2002 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
2003 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2004 CORBA::Double Rayon)
2006 INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
2008 SALOME::ExceptionStruct es;
2011 { es.text = "The radius must be positive." ;
2015 es.type = SALOME::BAD_PARAM;
2016 throw SALOME::SALOME_Exception(es);
2020 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
2021 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
2023 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2025 //=============================================================================
2026 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
2027 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
2028 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
2030 INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
2032 SALOME::ExceptionStruct es;
2034 if ( Angle <= 0.0 || Angle >= 90.0 )
2035 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
2037 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2038 if ( daux < 0.0000001 )
2039 { es.text = "The axis must be a non 0 vector." ;
2043 es.type = SALOME::BAD_PARAM;
2044 throw SALOME::SALOME_Exception(es);
2048 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
2049 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
2051 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2053 //=============================================================================
2054 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
2055 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
2056 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
2058 INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
2060 SALOME::ExceptionStruct es;
2062 if ( Rayon1 < 0.0 || Rayon2 < 0.0 )
2063 { es.text = "The radius must be positive." ;
2065 double daux = fabs(Rayon2-Rayon1) ;
2066 if ( daux < 0.0000001 )
2067 { es.text = "The radius must be different." ;
2069 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
2070 if ( daux < 0.0000001 )
2071 { es.text = "The centers must be different." ;
2075 es.type = SALOME::BAD_PARAM;
2076 throw SALOME::SALOME_Exception(es);
2080 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
2081 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
2083 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2085 //=============================================================================
2086 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryTorus(const char* BoundaryName,
2087 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2088 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2089 CORBA::Double RayonRev, CORBA::Double RayonPri)
2091 INFOS ("CreateBoundaryTorus : BoundaryName = " << BoundaryName ) ;
2093 SALOME::ExceptionStruct es;
2095 if ( ( RayonRev <= 0.0 ) || ( RayonPri <= 0.0 ) )
2096 { es.text = "The radius must be positive." ;
2098 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2099 if ( daux < 0.0000001 )
2100 { es.text = "The axis must be a non 0 vector." ;
2104 es.type = SALOME::BAD_PARAM;
2105 throw SALOME::SALOME_Exception(es);
2109 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 5) ;
2110 myBoundary->SetTorus( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, RayonRev, RayonPri ) ;
2112 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2114 //=============================================================================
2115 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
2117 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
2120 // Controle du nom :
2121 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
2123 SALOME::ExceptionStruct es;
2124 es.type = SALOME::BAD_PARAM;
2125 es.text = "This zone has already been defined";
2126 throw SALOME::SALOME_Exception(es);
2130 HOMARD::HOMARD_Zone_var myZone = newZone();
2131 myZone->SetName(ZoneName);
2132 myZone->SetType(ZoneType);
2134 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
2136 SALOMEDS::SObject_var aSO;
2137 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
2139 return HOMARD::HOMARD_Zone::_duplicate(myZone);
2141 //=============================================================================
2142 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
2143 CORBA::Double Xmini, CORBA::Double Xmaxi,
2144 CORBA::Double Ymini, CORBA::Double Ymaxi,
2145 CORBA::Double Zmini, CORBA::Double Zmaxi)
2147 INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ;
2149 SALOME::ExceptionStruct es;
2151 if ( Xmini > Xmaxi )
2152 { es.text = "The X coordinates are not coherent." ;
2154 if ( Ymini > Ymaxi )
2155 { es.text = "The Y coordinates are not coherent." ;
2157 if ( Zmini > Zmaxi )
2158 { es.text = "The Z coordinates are not coherent." ;
2162 es.type = SALOME::BAD_PARAM;
2163 throw SALOME::SALOME_Exception(es);
2167 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
2168 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2170 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2172 //=============================================================================
2173 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
2174 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
2176 INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
2178 SALOME::ExceptionStruct es;
2181 { es.text = "The radius must be positive." ;
2185 es.type = SALOME::BAD_PARAM;
2186 throw SALOME::SALOME_Exception(es);
2190 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
2191 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
2193 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2195 //=============================================================================
2196 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
2197 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2198 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2199 CORBA::Double Rayon, CORBA::Double Haut)
2201 INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
2203 SALOME::ExceptionStruct es;
2206 { es.text = "The radius must be positive." ;
2208 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2209 if ( daux < 0.0000001 )
2210 { es.text = "The axis must be a non 0 vector." ;
2213 { es.text = "The height must be positive." ;
2217 es.type = SALOME::BAD_PARAM;
2218 throw SALOME::SALOME_Exception(es);
2222 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
2223 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
2225 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2227 //=============================================================================
2228 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
2229 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2230 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2231 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
2233 INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ;
2235 SALOME::ExceptionStruct es;
2237 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2238 { es.text = "The radius must be positive." ;
2240 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2241 if ( daux < 0.0000001 )
2242 { es.text = "The axis must be a non 0 vector." ;
2245 { es.text = "The height must be positive." ;
2247 if ( Rayon <= Rayonint )
2248 { es.text = "The external radius must be higher than the internal radius." ;
2252 es.type = SALOME::BAD_PARAM;
2253 throw SALOME::SALOME_Exception(es);
2257 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
2258 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
2260 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2262 //=============================================================================
2263 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
2264 CORBA::Double Umini, CORBA::Double Umaxi,
2265 CORBA::Double Vmini, CORBA::Double Vmaxi,
2268 INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
2269 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
2270 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
2271 // MESSAGE ("Orient = " << Orient ) ;
2273 SALOME::ExceptionStruct es;
2275 if ( Umini > Umaxi )
2276 { es.text = "The first coordinates are not coherent." ;
2278 if ( Vmini > Vmaxi )
2279 { es.text = "The second coordinates are not coherent." ;
2281 if ( Orient < 1 || Orient > 3 )
2282 { es.text = "The orientation must be 1, 2 or 3." ;
2286 es.type = SALOME::BAD_PARAM;
2287 throw SALOME::SALOME_Exception(es);
2291 double Xmini, Xmaxi ;
2292 double Ymini, Ymaxi ;
2293 double Zmini, Zmaxi ;
2301 else if ( Orient == 2 )
2308 else if ( Orient == 3 )
2315 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2317 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2318 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2320 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2322 //=============================================================================
2323 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2324 CORBA::Double Ucentre, CORBA::Double Vcentre,
2325 CORBA::Double Rayon,
2328 INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2330 SALOME::ExceptionStruct es;
2333 { es.text = "The radius must be positive." ;
2335 if ( Orient < 1 || Orient > 3 )
2336 { es.text = "The orientation must be 1, 2 or 3." ;
2340 es.type = SALOME::BAD_PARAM;
2341 throw SALOME::SALOME_Exception(es);
2349 { Xcentre = Ucentre ;
2352 else if ( Orient == 2 )
2355 Zcentre = Vcentre ; }
2356 else if ( Orient == 3 )
2357 { Xcentre = Vcentre ;
2359 Zcentre = Ucentre ; }
2360 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2362 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2363 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2365 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2367 //=============================================================================
2368 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2369 CORBA::Double Ucentre, CORBA::Double Vcentre,
2370 CORBA::Double Rayon, CORBA::Double Rayonint,
2373 INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2375 SALOME::ExceptionStruct es;
2377 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2378 { es.text = "The radius must be positive." ;
2380 if ( Orient < 1 || Orient > 3 )
2381 { es.text = "The orientation must be 1, 2 or 3." ;
2383 if ( Rayon <= Rayonint )
2384 { es.text = "The external radius must be higher than the internal radius." ;
2388 es.type = SALOME::BAD_PARAM;
2389 throw SALOME::SALOME_Exception(es);
2397 { Xcentre = Ucentre ;
2400 else if ( Orient == 2 )
2403 Zcentre = Vcentre ; }
2404 else if ( Orient == 3 )
2405 { Xcentre = Vcentre ;
2407 Zcentre = Ucentre ; }
2408 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2410 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2411 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2413 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2415 //=============================================================================
2416 //=============================================================================
2421 //=============================================================================
2422 //=============================================================================
2423 // Traitement d'une iteration
2424 // etatMenage = 1 : destruction du repertoire d'execution
2425 // modeHOMARD = 1 : adaptation
2426 // != 1 : information avec les options modeHOMARD
2427 // Option1 >0 : appel depuis python
2428 // <0 : appel depuis GUI
2429 // Option2 : multiple de nombres premiers
2430 // 1 : aucune option
2431 // x2 : publication du maillage dans SMESH
2432 //=============================================================================
2433 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2435 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2440 // A.1. L'objet iteration
2441 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2442 ASSERT(!CORBA::is_nil(myIteration));
2444 // A.2. Controle de la possibilite d'agir
2445 // A.2.1. Etat de l'iteration
2446 int etat = myIteration->GetState();
2447 MESSAGE ( "etat = "<<etat );
2448 // A.2.2. On ne calcule pas l'iteration initiale, ni une iteration deja calculee
2449 if ( modeHOMARD == 1 )
2453 SALOME::ExceptionStruct es;
2454 es.type = SALOME::BAD_PARAM;
2455 es.text = "This iteration is the first of the case and cannot be computed.";
2456 throw SALOME::SALOME_Exception(es);
2459 else if ( ( etat == 2 ) & ( modeHOMARD == 1 ) )
2461 SALOME::ExceptionStruct es;
2462 es.type = SALOME::BAD_PARAM;
2463 es.text = "This iteration is already computed.";
2464 throw SALOME::SALOME_Exception(es);
2468 // A.2.3. On n'analyse pas une iteration non calculee
2473 SALOME::ExceptionStruct es;
2474 es.type = SALOME::BAD_PARAM;
2475 es.text = "This iteration is not computed.";
2476 throw SALOME::SALOME_Exception(es);
2481 // A.3. Numero de l'iteration
2482 // siterp1 : numero de l'iteration a traiter
2484 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2485 // Ou si information :
2487 int NumeIter = myIteration->GetNumber();
2488 std::string siterp1 ;
2489 std::stringstream saux1 ;
2491 siterp1 = saux1.str() ;
2492 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2495 if ( modeHOMARD==1 )
2497 std::stringstream saux0 ;
2498 int iaux = max(0, NumeIter-1) ;
2500 siter = saux0.str() ;
2501 if (NumeIter < 11) { siter = "0" + siter ; }
2504 { siter = siterp1 ; }
2507 const char* nomCas = myIteration->GetCaseName();
2508 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2509 ASSERT(!CORBA::is_nil(myCase));
2511 // B. Les repertoires
2512 // B.1. Le repertoire courant
2513 std::string nomDirWork = getenv("PWD") ;
2514 // B.2. Le sous-repertoire de l'iteration a traiter
2515 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2516 MESSAGE( ". DirCompute = " << DirCompute );
2518 // C. Le fichier des messages
2519 // C.1. Le deroulement de l'execution de HOMARD
2520 std::string LogFile = DirCompute ;
2521 LogFile += "/Liste" ;
2522 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2524 MESSAGE (". LogFile = " << LogFile);
2525 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2526 // C.2. Le bilan de l'analyse du maillage
2527 std::string FileInfo = DirCompute ;
2529 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2531 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2532 else { FileInfo += "info_ap" ; }
2534 FileInfo += "." + siterp1 + ".bilan" ;
2535 myIteration->SetFileInfo(FileInfo.c_str());
2537 // D. On passe dans le repertoire de l'iteration a calculer
2538 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2545 // E. Les donnees de l'execution HOMARD
2546 // E.1. L'objet du texte du fichier de configuration
2547 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2548 myDriver->TexteInit(DirCompute, LogFile, _Langue);
2550 // E.2. Le maillage associe a l'iteration
2551 const char* NomMesh = myIteration->GetMeshName();
2552 MESSAGE ( ". NomMesh = " << NomMesh );
2553 const char* MeshFile = myIteration->GetMeshFile();
2554 MESSAGE ( ". MeshFile = " << MeshFile );
2556 // E.3. Les donnees du traitement HOMARD
2558 if ( modeHOMARD == 1 )
2561 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2562 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2563 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2567 InvalideIterInfo(NomIteration);
2568 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2570 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2571 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2572 myDriver->CreeFichierDonn();
2575 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2576 DriverTexteBoundary(myCase, myDriver) ;
2578 // E.5. Ecriture du texte dans le fichier
2579 MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<<codret );
2581 { myDriver->CreeFichier(); }
2585 int codretexec = 12 ;
2588 codretexec = myDriver->ExecuteHomard(Option1);
2590 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2591 // En mode adaptation, on ajuste l'etat de l'iteration
2592 if ( modeHOMARD == 1 )
2594 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2595 else { SetEtatIter(NomIteration,1); }
2596 // GERALD -- QMESSAGE BOX
2600 // H. Gestion des resultats
2603 std::string Commentaire ;
2604 // H.1. Le fichier des messages, dans tous les cas
2605 Commentaire = "log" ;
2606 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2607 else { Commentaire += "Info" ; }
2608 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2610 // H.2. Si tout s'est bien passe :
2611 if (codretexec == 0)
2613 // H.2.1. Le fichier de bilan
2614 Commentaire = "Summary" ;
2615 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2616 else { Commentaire += "Info" ; }
2617 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2618 // H.2.2. Le fichier de maillage obtenu
2619 if ( modeHOMARD == 1 )
2621 std::stringstream saux0 ;
2622 Commentaire = "Mesh" ;
2623 Commentaire += " " + siterp1 ;
2624 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2625 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2628 // H.3 Message d'erreur
2629 if (codretexec != 0)
2631 std::string text = "" ;
2632 // Message d'erreur en cas de probleme en adaptation
2633 if ( modeHOMARD == 1 )
2635 text = "Error during the adaptation.\n" ;
2636 bool stopvu = false ;
2637 std::ifstream fichier( LogFile.c_str() );
2638 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
2640 std::string ligne; // variable contenant chaque ligne lue
2641 while ( std::getline( fichier, ligne ) )
2645 { text += ligne+ "\n"; }
2648 int position = ligne.find( "===== HOMARD ===== STOP =====" ) ;
2649 if ( position > 0 ) { stopvu = true ; }
2654 text += "\n\nSee the file " + LogFile + "\n" ;
2656 SALOME::ExceptionStruct es;
2657 es.type = SALOME::BAD_PARAM;
2658 es.text = CORBA::string_dup(text.c_str());
2659 throw SALOME::SALOME_Exception(es);
2661 // En mode information, on force le succes pour pouvoir consulter le fichier log
2662 if ( modeHOMARD != 1 ) { codretexec = 0 ; }
2666 // I. Menage et retour dans le repertoire du cas
2670 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2673 chdir(nomDirWork.c_str());
2675 _chdir(nomDirWork.c_str());
2681 //=============================================================================
2682 // Calcul d'une iteration : partie specifique a l'adaptation
2683 //=============================================================================
2684 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)
2686 MESSAGE ( "ComputeAdap" );
2691 // Numero de l'iteration
2692 int NumeIter = myIteration->GetNumber();
2693 std::stringstream saux0 ;
2694 saux0 << NumeIter-1 ;
2695 std::string siter = saux0.str() ;
2696 if (NumeIter < 11) { siter = "0" + siter ; }
2698 // A.2. On verifie qu il y a une hypothese (erreur improbable);
2699 const char* nomHypo = myIteration->GetHypoName();
2700 if (std::string(nomHypo) == std::string(""))
2702 SALOME::ExceptionStruct es;
2703 es.type = SALOME::BAD_PARAM;
2704 es.text = "This iteration does not have any associated hypothesis.";
2705 throw SALOME::SALOME_Exception(es);
2708 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2709 ASSERT(!CORBA::is_nil(myHypo));
2711 // B. L'iteration parent
2712 const char* nomIterationParent = myIteration->GetIterParentName();
2713 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2714 ASSERT(!CORBA::is_nil(myIterationParent));
2715 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2716 if ( myIterationParent->GetState() == 1 )
2719 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2722 // GERALD -- QMESSAGE BOX
2723 VERIFICATION("Pb au calcul de l'iteration precedente" == 0);
2727 // C. Le sous-repertoire de l'iteration precedente
2728 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2729 MESSAGE( ". DirComputePa = " << DirComputePa );
2731 // D. Les donnees de l'adaptation HOMARD
2732 // D.1. Le type de conformite
2733 int ConfType = myCase->GetConfType();
2734 MESSAGE ( ". ConfType = " << ConfType );
2736 // D.2. Le maillage de depart
2737 const char* NomMeshParent = myIterationParent->GetMeshName();
2738 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2739 const char* MeshFileParent = myIterationParent->GetMeshFile();
2740 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2742 // D.3. Le maillage associe a l'iteration
2743 const char* MeshFile = myIteration->GetMeshFile();
2744 MESSAGE ( ". MeshFile = " << MeshFile );
2745 FILE *file = fopen(MeshFile,"r");
2749 if (etatMenage == 0)
2751 SALOME::ExceptionStruct es;
2752 es.type = SALOME::BAD_PARAM;
2753 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2754 es.text = CORBA::string_dup(text.c_str());
2755 throw SALOME::SALOME_Exception(es);
2760 std::string commande = "rm -f " + std::string(MeshFile);
2761 codret = system(commande.c_str());
2764 SALOME::ExceptionStruct es;
2765 es.type = SALOME::BAD_PARAM;
2766 es.text = "The mesh file cannot be deleted.";
2767 throw SALOME::SALOME_Exception(es);
2773 // D.4. Les types de raffinement et de deraffinement
2774 // Les appels corba sont lourds, il vaut mieux les grouper
2775 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2776 ASSERT(ListTypes->length() == 3);
2777 int TypeAdap = (*ListTypes)[0];
2778 int TypeRaff = (*ListTypes)[1];
2779 int TypeDera = (*ListTypes)[2];
2780 // MESSAGE ( ". TypeAdap = " << TypeAdap << ", TypeRaff = " << TypeRaff << ", TypeDera = " << TypeDera );
2782 // E. Texte du fichier de configuration
2783 // E.1. Incontournables du texte
2784 myDriver->TexteAdap();
2786 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2787 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2788 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2790 // E.2. Ajout des informations liees aux zones eventuelles
2791 if ( TypeAdap == 0 )
2792 { DriverTexteZone(myHypo, myDriver) ; }
2794 // E.3. Ajout des informations liees aux champs eventuels
2795 if ( TypeAdap == 1 )
2796 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2798 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2799 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2800 int numberOfGroups = listeGroupes->length();
2801 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2802 if (numberOfGroups > 0)
2804 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2806 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2807 MESSAGE( "... GroupName = " << GroupName );
2808 myDriver->TexteGroup(GroupName);
2812 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2813 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2815 // E.6. Ajout des options avancees
2816 int Pyram = myCase->GetPyram();
2817 MESSAGE ( ". Pyram = " << Pyram );
2818 int NivMax = myHypo->GetNivMax();
2819 MESSAGE ( ". NivMax = " << NivMax );
2820 double DiamMin = myHypo->GetDiamMin() ;
2821 MESSAGE ( ". DiamMin = " << DiamMin );
2822 int AdapInit = myHypo->GetAdapInit();
2823 MESSAGE ( ". AdapInit = " << AdapInit );
2824 int LevelOutput = myHypo->GetLevelOutput();
2825 MESSAGE ( ". LevelOutput = " << LevelOutput );
2826 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2828 // E.7. Ajout des informations sur le deroulement de l'execution
2829 int MessInfo = myIteration->GetInfoCompute();
2830 MESSAGE ( ". MessInfo = " << MessInfo );
2831 myDriver->TexteInfoCompute(MessInfo);
2835 //=============================================================================
2836 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2837 // nomrep : nom du repertoire parent
2838 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2839 //=============================================================================
2840 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2842 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2843 // On verifie que le repertoire parent existe
2845 int codret = chdir(nomrep) ;
2847 int codret = _chdir(nomrep) ;
2851 SALOME::ExceptionStruct es;
2852 es.type = SALOME::BAD_PARAM;
2853 es.text = "The directory of the case does not exist.";
2854 throw SALOME::SALOME_Exception(es);
2857 std::string nomDirActuel = getenv("PWD") ;
2858 std::string DirName ;
2859 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2860 bool a_chercher = true ;
2861 while ( a_chercher )
2863 // On passe dans le repertoire parent
2870 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2872 if ( num < 100 ) { jaux = 2 ; }
2873 else if ( num < 1000 ) { jaux = 3 ; }
2874 else if ( num < 10000 ) { jaux = 4 ; }
2875 else if ( num < 100000 ) { jaux = 5 ; }
2877 std::ostringstream iaux ;
2878 iaux << std::setw(jaux) << std::setfill('0') << num ;
2879 std::ostringstream DirNameA ;
2880 DirNameA << "I" << iaux.str();
2881 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2882 // que c'est bien un probleme d'absence
2884 if ( chdir(DirNameA.str().c_str()) != 0 )
2886 if ( _chdir(DirNameA.str().c_str()) != 0 )
2889 bool existe = false ;
2892 struct dirent *dirp;
2893 dp = opendir(nomrep);
2894 while ( (dirp = readdir(dp)) != NULL )
2896 std::string file_name(dirp->d_name);
2898 HANDLE hFind = INVALID_HANDLE_VALUE;
2899 WIN32_FIND_DATA ffd;
2900 hFind = FindFirstFile(nomrep, &ffd);
2901 if (INVALID_HANDLE_VALUE != hFind) {
2902 while (FindNextFile(hFind, &ffd) != 0) {
2903 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2904 std::string file_name(ffd.cFileName);
2906 if ( file_name == DirNameA.str() ) { existe = true ; }
2916 DirName = DirNameA.str() ;
2917 a_chercher = false ;
2924 MESSAGE ( "==> DirName = " << DirName);
2925 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2927 chdir(nomDirActuel.c_str());
2929 _chdir(nomDirActuel.c_str());
2931 return CORBA::string_dup( DirName.c_str() );
2933 //=============================================================================
2934 // Calcul d'une iteration : gestion du repertoire de calcul
2935 // Si le sous-repertoire existe :
2936 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2937 // etatMenage = 1 : on fait le menage du repertoire
2938 // etatMenage = -1 : on ne fait rien
2939 //=============================================================================
2940 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2942 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2943 // B.2. Le repertoire du cas
2944 const char* nomDirCase = myCase->GetDirName();
2945 MESSAGE ( ". nomDirCase = " << nomDirCase );
2947 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2948 // B.3.1. Le nom du sous-repertoire
2949 const char* nomDirIt = myIteration->GetDirNameLoc();
2951 // B.3.2. Le nom complet du sous-repertoire
2952 std::stringstream DirCompute ;
2953 DirCompute << nomDirCase << "/" << nomDirIt;
2954 MESSAGE (". DirCompute = " << DirCompute.str() );
2956 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2958 if (chdir(DirCompute.str().c_str()) != 0)
2960 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2962 if (_chdir(DirCompute.str().c_str()) != 0)
2964 if (_mkdir(DirCompute.str().c_str()) != 0)
2967 // GERALD -- QMESSAGE BOX
2968 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2969 VERIFICATION("Pb a la creation du repertoire" == 0);
2974 // Le repertoire existe
2975 // On demande de faire le menage de son contenu :
2976 if (etatMenage == 1)
2978 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2979 std::string commande = "rm -rf " + DirCompute.str()+"/*" ;
2980 int codret = system(commande.c_str());
2983 // GERALD -- QMESSAGE BOX
2984 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2985 VERIFICATION("Pb au menage du repertoire de calcul" == 0);
2988 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2991 if (etatMenage == 0)
2995 struct dirent *dirp;
2996 dp = opendir(DirCompute.str().c_str());
2998 while ((dirp = readdir(dp)) != NULL && result )
3000 std::string file_name(dirp->d_name);
3001 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
3005 HANDLE hFind = INVALID_HANDLE_VALUE;
3006 WIN32_FIND_DATA ffd;
3007 hFind = FindFirstFile(DirCompute.str().c_str(), &ffd);
3009 if (INVALID_HANDLE_VALUE != hFind) {
3010 while (FindNextFile(hFind, &ffd) != 0) {
3011 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
3012 std::string file_name(ffd.cFileName);
3013 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
3018 if ( result == false)
3020 SALOME::ExceptionStruct es;
3021 es.type = SALOME::BAD_PARAM;
3022 std::string text = "Directory : " + DirCompute.str() + " is not empty";
3023 es.text = CORBA::string_dup(text.c_str());
3024 throw SALOME::SALOME_Exception(es);
3025 VERIFICATION("Directory is not empty" == 0);
3031 return CORBA::string_dup( DirCompute.str().c_str() );
3033 //=============================================================================
3034 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
3035 //=============================================================================
3036 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
3038 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
3039 // Le repertoire du cas
3040 const char* nomDirCase = myCase->GetDirName();
3041 MESSAGE ( ". nomDirCase = " << nomDirCase );
3043 // Le sous-repertoire de l'iteration precedente
3045 const char* nomIterationParent = myIteration->GetIterParentName();
3046 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
3047 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
3048 std::stringstream DirComputePa ;
3049 DirComputePa << nomDirCase << "/" << nomDirItPa;
3050 MESSAGE( ". nomDirItPa = " << nomDirItPa);
3051 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
3053 return CORBA::string_dup( DirComputePa.str().c_str() );
3055 //=============================================================================
3056 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
3057 //=============================================================================
3058 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3060 MESSAGE ( "... DriverTexteZone" );
3061 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
3062 int numberOfZonesx2 = ListZone->length();
3065 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
3067 std::string ZoneName = std::string((*ListZone)[iaux]);
3068 MESSAGE ( "... ZoneName = " << ZoneName);
3069 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
3070 ASSERT(!CORBA::is_nil(myZone));
3072 int ZoneType = myZone->GetType();
3073 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
3074 int TypeUse = atoi( TypeUsestr.c_str() );
3075 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
3076 NumZone = iaux/2 + 1 ;
3077 HOMARD::double_array* zone = myZone->GetCoords();
3078 if ( ZoneType == 2 || ( ZoneType>=11 && ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
3079 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
3080 else if ( ZoneType == 4 ) // Cas d une sphere
3081 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
3082 else if ( ZoneType == 5 || ( ZoneType>=31 && ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
3083 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
3084 else if ( ZoneType == 7 || ( ZoneType>=61 && ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
3085 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
3086 else { VERIFICATION("ZoneType est incorrect." == 0) ; }
3091 //=============================================================================
3092 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
3093 //=============================================================================
3094 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3096 MESSAGE ( "... DriverTexteField" );
3097 // Le fichier du champ
3098 char* FieldFile = myIteration->GetFieldFile();
3099 MESSAGE ( ". FieldFile = " << FieldFile );
3100 if (strlen(FieldFile) == 0)
3102 // GERALD -- QMESSAGE BOX
3103 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
3104 VERIFICATION("The file for the field is not given." == 0);
3106 // Les caracteristiques d'instants du champ de pilotage
3107 int TimeStep = myIteration->GetTimeStep();
3108 MESSAGE( ". TimeStep = " << TimeStep );
3109 int Rank = myIteration->GetRank();
3110 MESSAGE( ". Rank = " << Rank );
3111 // Les informations sur les champs
3112 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
3114 const char* FieldName = aInfosHypo->FieldName;
3116 int TypeThR = aInfosHypo->TypeThR;
3117 double ThreshR = aInfosHypo->ThreshR;
3118 int TypeThC = aInfosHypo->TypeThC;
3119 double ThreshC = aInfosHypo->ThreshC;
3120 // Saut entre mailles ou non ?
3121 int UsField = aInfosHypo->UsField;
3122 MESSAGE( ". UsField = " << UsField );
3123 // L'usage des composantes
3124 int UsCmpI = aInfosHypo->UsCmpI;
3125 MESSAGE( ". UsCmpI = " << UsCmpI );
3127 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
3130 HOMARD::listeComposantsHypo* mescompo = myHypo->GetComps();
3131 int numberOfCompos = mescompo->length();
3132 MESSAGE( ". numberOfCompos = " << numberOfCompos );
3133 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
3135 std::string nomCompo = std::string((*mescompo)[NumeComp]);
3136 MESSAGE( "... nomCompo = " << nomCompo );
3137 myDriver->TexteCompo(NumeComp, nomCompo);
3141 //=============================================================================
3142 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
3143 // On ecrit dans l'ordre :
3144 // 1. la definition des frontieres
3145 // 2. les liens avec les groupes
3146 // 3. un entier resumant le type de comportement pour les frontieres
3147 //=============================================================================
3148 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
3150 MESSAGE ( "... DriverTexteBoundary" );
3151 // 1. Recuperation des frontieres
3152 std::list<std::string> ListeBoundaryTraitees ;
3153 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3154 int numberOfitems = ListBoundaryGroupType->length();
3155 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
3156 int BoundaryOption = 1 ;
3157 // 2. Parcours des frontieres pour ecrire leur description
3158 int NumBoundaryAnalytical = 0 ;
3159 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3161 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3162 MESSAGE ( "... BoundaryName = " << BoundaryName);
3163 // 2.1. La frontiere a-t-elle deja ete ecrite ?
3164 // Cela arrive quand elle estliéé a plusieurs groupes. Il ne faut l'ecrire que la premiere fois
3166 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3167 while (it != ListeBoundaryTraitees.end())
3169 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3170 if ( BoundaryName == *it ) { A_faire = 0 ; }
3173 // 2.2. Ecriture de la frontiere
3176 // 2.2.1. Caracteristiques de la frontiere
3177 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3178 ASSERT(!CORBA::is_nil(myBoundary));
3179 int BoundaryType = myBoundary->GetType();
3180 MESSAGE ( "... BoundaryType = " << BoundaryType );
3181 // 2.2.2. Ecriture selon le type
3182 // 2.2.2.1. Cas d une frontiere discrete
3183 if (BoundaryType == 0)
3185 const char* MeshName = myBoundary->GetMeshName() ;
3186 const char* MeshFile = myBoundary->GetMeshFile() ;
3187 myDriver->TexteBoundaryDi( MeshName, MeshFile);
3188 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; }
3190 // 2.2.2.1. Cas d une frontiere analytique
3193 NumBoundaryAnalytical++ ;
3194 HOMARD::double_array* coor = myBoundary->GetCoords();
3195 if (BoundaryType == 1) // Cas d un cylindre
3197 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3198 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3200 else if (BoundaryType == 2) // Cas d une sphere
3202 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
3203 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3205 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
3207 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3208 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3210 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
3212 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3213 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3215 else if (BoundaryType == 5) // Cas d un tore
3217 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3218 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3221 // 2.2.3. Memorisation du traitement
3222 ListeBoundaryTraitees.push_back( BoundaryName );
3225 // 3. Parcours des frontieres pour ecrire les liens avec les groupes
3226 NumBoundaryAnalytical = 0 ;
3227 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3229 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3230 MESSAGE ( "... BoundaryName = " << BoundaryName);
3231 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3232 ASSERT(!CORBA::is_nil(myBoundary));
3233 int BoundaryType = myBoundary->GetType();
3234 MESSAGE ( "... BoundaryType = " << BoundaryType );
3235 // 3.1. Recuperation du nom du groupe
3236 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
3237 MESSAGE ( "... GroupName = " << GroupName);
3238 // 3.2. Cas d une frontiere discrete
3239 if ( BoundaryType == 0 )
3241 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
3243 // 3.3. Cas d une frontiere analytique
3246 NumBoundaryAnalytical++ ;
3247 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
3250 // 4. Ecriture de l'option finale
3251 myDriver->TexteBoundaryOption(BoundaryOption);
3255 //=============================================================================
3256 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
3257 //=============================================================================
3258 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3260 MESSAGE ( "... DriverTexteFieldInterp" );
3261 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
3262 MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp);
3263 if (TypeFieldInterp != 0)
3265 // Le fichier des champs
3266 char* FieldFile = myIteration->GetFieldFile();
3267 MESSAGE ( ". FieldFile = " << FieldFile );
3268 if (strlen(FieldFile) == 0)
3270 // GERALD -- QMESSAGE BOX
3271 VERIFICATION("The file for the field is not given." == 0);
3274 const char* MeshFile = myIteration->GetMeshFile();
3275 myDriver->TexteFieldInterp(FieldFile, MeshFile);
3278 // Interpolation de tous les champs
3279 if ( TypeFieldInterp == 1 )
3281 myDriver->TexteFieldInterpAll();
3283 // Interpolation de certains champs
3284 else if (TypeFieldInterp == 2)
3286 // Les champs et leurs instants pour l'iteration
3287 HOMARD::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank();
3288 int numberOfFieldsx3 = ListFieldTSR->length();
3289 MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 );
3290 // Les champs pour l'hypothese
3291 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
3292 int numberOfFieldsx2 = ListField->length();
3293 MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 );
3294 // On parcourt tous les champs de l'hypothese
3296 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
3299 std::string FieldName = std::string((*ListField)[iaux]) ;
3300 // Le type d'interpolation
3301 std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ;
3302 MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr );
3303 // On cherche à savoir si des instants ont été précisés pour cette itération
3305 for (int jaux = 0; jaux< numberOfFieldsx3; jaux++)
3308 std::string FieldName2 = std::string((*ListFieldTSR)[jaux]) ;
3309 MESSAGE( "..... FieldName2 = " << FieldName2 );
3310 // Quand c'est le bon champ, on ecrit le pas de temps
3311 if ( FieldName == FieldName2 )
3315 std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]) ;
3316 // Le numero d'ordre
3317 std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]) ;
3318 MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<<Rankstr );
3320 int TimeStep = atoi( TimeStepstr.c_str() );
3321 int Rank = atoi( Rankstr.c_str() );
3322 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank);
3326 // Si aucun instant n'a été défini
3330 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1);
3338 //===========================================================================
3339 //===========================================================================
3342 //===========================================================================
3343 //===========================================================================
3345 //===========================================================================
3346 //===========================================================================
3347 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
3348 SALOMEDS::SObject_ptr theSObject,
3349 CORBA::Object_ptr theObject,
3350 const char* theName)
3352 MESSAGE("PublishInStudy pour " << theName);
3353 SALOMEDS::SObject_var aResultSO;
3354 if (CORBA::is_nil(theStudy))
3356 SALOME::ExceptionStruct es;
3357 es.type = SALOME::BAD_PARAM;
3358 es.text = "Invalid study context";
3359 throw SALOME::SALOME_Exception(es);
3363 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
3364 // Rq : Iteration est publiee ailleurs
3365 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
3366 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
3367 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
3368 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject);
3369 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
3371 addInStudy(theStudy);
3373 // Controle de la non publication d'un objet de meme nom
3374 if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) )
3376 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
3377 if (listSO->length() >= 1)
3379 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
3380 aResultSO = listSO[0];
3381 return aResultSO._retn();
3385 // Caracteristiques de l'etude
3386 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
3387 aStudyBuilder->NewCommand();
3388 if(!aBoundary->_is_nil())
3389 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
3390 else if(!aCase->_is_nil())
3391 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
3392 else if(!aHypo->_is_nil())
3393 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
3394 else if(!aYACS->_is_nil())
3395 aResultSO = PublishYACSInStudy(theStudy, aStudyBuilder, aYACS, theName);
3396 else if(!aZone->_is_nil())
3397 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
3399 aStudyBuilder->CommitCommand();
3401 return aResultSO._retn();
3403 //=============================================================================
3404 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3405 SALOMEDS::StudyBuilder_var aStudyBuilder,
3406 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3408 MESSAGE("PublishBoundaryStudy pour "<<theName);
3409 SALOMEDS::SObject_var aResultSO;
3411 // Caracteristique de la Boundary
3412 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3414 // On recupere le module pere dans l etude
3415 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3416 if (theFatherHomard->_is_nil())
3418 MESSAGE("theFatherHomard->_is_nil()");
3419 return aResultSO._retn();
3422 // On ajoute la categorie des boundarys dans l etude si necessaire
3423 if ( _tag_boun == 0 )
3426 _tag_boun = _tag_gene ;
3428 MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun );
3429 SALOMEDS::SObject_var aSObject;
3430 if (!theFatherHomard->FindSubObject(_tag_boun, aSObject))
3432 MESSAGE("Ajout de la categorie des boundarys");
3433 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun);
3434 PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3436 else { MESSAGE("La categorie des boundarys existe deja."); }
3438 CORBA::Long BoundaryType = myBoundary->GetType();
3439 // MESSAGE("BoundaryType : "<<BoundaryType);
3442 switch (BoundaryType)
3445 { value = "BoundaryDiHomard" ;
3446 icone = "mesh_tree_mesh.png" ;
3450 { value = "BoundaryAnHomard" ;
3451 icone = "cylinderpointvector_2.png" ;
3455 { value = "BoundaryAnHomard" ;
3456 icone = "spherepoint_2.png" ;
3460 { value = "BoundaryAnHomard" ;
3461 icone = "conepointvector.png" ;
3465 { value = "BoundaryAnHomard" ;
3466 icone = "conedxyz.png" ;
3470 { value = "BoundaryAnHomard" ;
3471 icone = "toruspointvector.png" ;
3475 aResultSO = aStudyBuilder->NewObject(aSObject);
3476 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3477 return aResultSO._retn();
3479 //=============================================================================
3480 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
3481 SALOMEDS::StudyBuilder_var aStudyBuilder,
3482 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
3484 MESSAGE("PublishCaseInStudy pour "<<theName);
3485 SALOMEDS::SObject_var aResultSO;
3487 if (CORBA::is_nil(theObject)) {
3488 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
3489 return aResultSO._retn();
3491 if (theStudy->_is_nil()) {
3492 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
3493 return aResultSO._retn();
3496 // On recupere le module pere dans l etude
3497 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3498 if (theFatherHomard->_is_nil())
3500 MESSAGE("theFatherHomard->_is_nil()");
3501 return aResultSO._retn();
3505 MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene );
3506 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
3507 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
3508 _orb->object_to_string(theObject) ) ;
3510 return aResultSO._retn();
3512 //=============================================================================
3513 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3514 SALOMEDS::StudyBuilder_var aStudyBuilder,
3515 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3517 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3518 SALOMEDS::SObject_var aResultSO;
3520 // On recupere le module pere dans l etude
3521 // On ajoute la categorie des hypotheses dans l etude si necessaire
3522 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3523 if (theFatherHomard->_is_nil())
3525 MESSAGE("theFatherHomard->_is_nil()");
3526 return aResultSO._retn();
3529 // On ajoute la categorie des hypotheses dans l etude si necessaire
3530 SALOMEDS::SObject_var aSObject;
3531 if ( _tag_hypo == 0 )
3534 _tag_hypo = _tag_gene ;
3536 MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo );
3537 if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject))
3539 MESSAGE("Ajout de la categorie des hypotheses");
3540 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo);
3541 PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL);
3543 else { MESSAGE("La categorie des hypotheses existe deja."); }
3545 // Creation du resultat dans l'etude
3546 aResultSO = aStudyBuilder->NewObject(aSObject);
3547 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3549 return aResultSO._retn();
3551 //=============================================================================
3552 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theStudy,
3553 SALOMEDS::StudyBuilder_var aStudyBuilder,
3554 HOMARD::HOMARD_YACS_ptr theObject, const char* theName)
3556 MESSAGE("PublishYACSInStudy pour "<<theName);
3557 SALOMEDS::SObject_var aResultSO;
3559 // On recupere le module pere dans l etude
3560 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3561 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3562 if (theFatherHomard->_is_nil())
3564 MESSAGE("theFatherHomard->_is_nil()");
3565 return aResultSO._retn();
3567 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3568 if ( _tag_yacs == 0 )
3571 _tag_yacs = _tag_gene ;
3573 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs );
3574 SALOMEDS::SObject_var aSObject;
3575 if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject))
3577 MESSAGE("Ajout de la categorie des schemas YACS");
3578 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs);
3579 PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL);
3581 else { MESSAGE("La categorie des schemas YACS existe deja."); }
3583 // Creation du resultat dans l'etude
3584 aResultSO = aStudyBuilder->NewObject(aSObject);
3585 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ;
3587 return aResultSO._retn();
3590 //=============================================================================
3591 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
3592 SALOMEDS::StudyBuilder_var aStudyBuilder,
3593 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3595 MESSAGE("PublishZoneStudy pour "<<theName);
3596 SALOMEDS::SObject_var aResultSO;
3597 if (CORBA::is_nil(theObject))
3599 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3600 return aResultSO._retn();
3602 if (theStudy->_is_nil())
3604 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
3605 return aResultSO._retn();
3607 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3608 if (theFatherHomard->_is_nil())
3610 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3611 return aResultSO._retn();
3614 // Caracteristique de la zone
3615 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3616 CORBA::Long ZoneType = myZone->GetType();
3618 // On ajoute la categorie des zones dans l etude si necessaire
3619 if ( _tag_zone == 0 )
3622 _tag_zone = _tag_gene ;
3624 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone );
3625 SALOMEDS::SObject_var aSObject;
3626 if (!theFatherHomard->FindSubObject(_tag_zone, aSObject))
3628 MESSAGE("Ajout de la categorie des zones");
3629 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone);
3630 PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3632 else { MESSAGE("La categorie des zones existe deja."); }
3634 aResultSO = aStudyBuilder->NewObject(aSObject);
3643 { icone = "boxdxy_2.png" ;
3647 { icone = "boxdxyz_2.png" ;
3655 { icone = "disk_2.png" ;
3659 { icone = "spherepoint_2.png" ;
3663 { icone = "cylinderpointvector_2.png" ;
3671 { icone = "diskwithhole_2.png" ;
3675 { icone = "pipe_2.png" ;
3679 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3681 return aResultSO._retn();
3683 //===========================================================================
3684 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3685 SALOMEDS::SObject_var aResultSO,
3686 const char* name, const char* comment, const char* icone, const char* ior)
3688 MESSAGE("PublishInStudyAttr pour name = "<<name<<", comment = "<<comment);
3689 // MESSAGE("icone = "<<icone);
3690 // MESSAGE("ior = "<<ior);
3691 SALOMEDS::GenericAttribute_var anAttr ;
3695 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3696 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3697 aNameAttrib->SetValue(name);
3700 // Ajout du commentaire
3701 if ( comment != NULL )
3703 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3704 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3705 aCommentAttrib->SetValue(comment);
3709 if ( icone != NULL )
3711 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
3712 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3713 aPixmap->SetPixMap(icone);
3719 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3720 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3721 anIOR->SetValue(ior);
3725 //=====================================================================================
3726 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3728 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3730 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3731 ASSERT(!CORBA::is_nil(myCase));
3732 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3733 ASSERT(!CORBA::is_nil(aCaseSO));
3735 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3736 ASSERT(!CORBA::is_nil(myBoundary));
3737 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3738 ASSERT(!CORBA::is_nil(aBoundarySO));
3740 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3742 aStudyBuilder->NewCommand();
3744 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3745 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3746 // aStudyBuilder->RemoveReference(aSubSO);
3748 aStudyBuilder->CommitCommand();
3751 //=====================================================================================
3752 void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName)
3754 MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName );
3756 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3757 ASSERT(!CORBA::is_nil(myYACS));
3758 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3759 ASSERT(!CORBA::is_nil(aYACSSO));
3761 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3762 ASSERT(!CORBA::is_nil(myCase));
3763 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3764 ASSERT(!CORBA::is_nil(aCaseSO));
3766 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3768 aStudyBuilder->NewCommand();
3770 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3771 aStudyBuilder->Addreference(aSubSO, aCaseSO);
3773 aStudyBuilder->CommitCommand();
3776 //=============================================================================
3777 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3778 // Option = 0 : fichier issu d'une importation
3779 // Option = 1 : fichier issu d'une execution HOMARD
3781 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3782 if (CORBA::is_nil(myCurrentStudy))
3784 SALOME::ExceptionStruct es;
3785 es.type = SALOME::BAD_PARAM;
3786 es.text = "Invalid study context";
3787 throw SALOME::SALOME_Exception(es);
3791 // Le module SMESH est-il actif ?
3792 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3794 if (!CORBA::is_nil(aSmeshSO))
3796 // On verifie que le fichier n est pas deja publie
3797 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3798 for (; aIter->More(); aIter->Next())
3800 SALOMEDS::SObject_var aSO = aIter->Value();
3801 SALOMEDS::GenericAttribute_var aGAttr;
3802 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3804 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3805 CORBA::String_var value=anAttr->Value();
3806 if (strcmp((const char*)value,NomFich) == 0)
3808 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3809 // Pour un fichier importe, on ne republie pas
3810 if ( Option == 0 ) { return; }
3811 // Pour un fichier calcule, on commence par faire la depublication
3814 MESSAGE ( "PublishResultInSmesh : depublication" );
3815 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3816 CORBA::String_var value2=anAttr2->Value();
3817 std::string MeshName = string(value2) ;
3818 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3819 DeleteResultInSmesh(NomFich, MeshName) ;
3826 // On enregistre le fichier
3827 MESSAGE( "Enregistrement du fichier");
3828 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3829 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3830 ASSERT(!CORBA::is_nil(aSmeshEngine));
3831 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3832 SMESH::DriverMED_ReadStatus theStatus;
3833 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3835 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3836 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3837 for (int i = 0; i < mesMaillages->length(); i++)
3839 MESSAGE( ". Mise a jour des attributs du maillage");
3840 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3841 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3842 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3843 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3844 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3845 anAttr->SetValue(NomFich);
3846 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3847 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3849 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3850 else { icone = "mesh_tree_mesh.png" ; }
3851 anAttr2->SetPixMap( icone );
3855 //=============================================================================
3856 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
3858 MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3859 if (CORBA::is_nil(myCurrentStudy))
3861 SALOME::ExceptionStruct es;
3862 es.type = SALOME::BAD_PARAM;
3863 es.text = "Invalid study context";
3864 throw SALOME::SALOME_Exception(es);
3868 // Le module SMESH est-il actif ?
3869 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3871 if (CORBA::is_nil(aSmeshSO))
3875 // On verifie que le fichier est deja publie
3876 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3877 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3878 for (; aIter->More(); aIter->Next())
3880 SALOMEDS::SObject_var aSO = aIter->Value();
3881 SALOMEDS::GenericAttribute_var aGAttr;
3882 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3884 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3885 CORBA::String_var value=anAttr->Value();
3886 if (strcmp((const char*)value,NomFich.c_str()) == 0)
3888 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3890 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3891 CORBA::String_var value2=anAttr2->Value();
3892 if (strcmp((const char*)value2,MeshName.c_str()) == 0)
3894 myBuilder->RemoveObjectWithChildren( aSO ) ;
3902 //=============================================================================
3903 void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter)
3905 MESSAGE( "PublishMeshIterInSmesh " << NomIter);
3906 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3908 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3909 if (CORBA::is_nil(myIteration))
3911 SALOME::ExceptionStruct es;
3912 es.type = SALOME::BAD_PARAM;
3913 es.text = "Invalid iterationStudy Object";
3914 throw SALOME::SALOME_Exception(es);
3917 const char* MeshFile = myIteration->GetMeshFile() ;
3918 const char* MeshName = myIteration->GetMeshName() ;
3919 CORBA::Long Option = -1 ;
3920 int etat = myIteration->GetState();
3921 // Iteration initiale
3922 if ( etat <= 0 ) { Option = 0 ; }
3923 // ou iteration calculee
3924 else if ( etat == 2 ) { Option = 1 ; }
3925 // Publication effective apres menage eventuel
3928 DeleteResultInSmesh(MeshFile, MeshName) ;
3929 PublishResultInSmesh(MeshFile, Option) ;
3933 //=============================================================================
3934 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3936 // MESSAGE ("PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3937 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3939 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3940 if (CORBA::is_nil(myIteration))
3942 SALOME::ExceptionStruct es;
3943 es.type = SALOME::BAD_PARAM;
3944 es.text = "Invalid iterationStudy Object";
3945 throw SALOME::SALOME_Exception(es);
3949 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3951 aStudyBuilder->NewCommand();
3953 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3954 // Pour les fichiers med, on affiche une icone de maillage
3955 // Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte'
3956 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3958 std::string ior = " " ;
3959 if ( Commentaire[0] == 'I' )
3960 { icone = "med.png" ; }
3962 { icone = "texte_2.png" ; }
3963 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3965 aStudyBuilder->CommitCommand();
3968 //=============================================================================
3969 void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire)
3971 // MESSAGE ("PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3972 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3974 SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3975 if (CORBA::is_nil(myYACS))
3977 SALOME::ExceptionStruct es;
3978 es.type = SALOME::BAD_PARAM;
3979 es.text = "Invalid YACSStudy Object";
3980 throw SALOME::SALOME_Exception(es);
3984 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3986 aStudyBuilder->NewCommand();
3988 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3989 std::string icone = "texte_2.png" ;
3990 std::string ior = " " ;
3991 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3993 aStudyBuilder->CommitCommand();
3996 //=============================================================================
3997 //=============================================================================
3999 //=============================================================================
4000 //=============================================================================
4001 //=============================================================================
4002 // Creation d'un schema YACS
4003 // nomCas : nom du cas a traiter
4004 // FileName : nom du fichier contenant le script de lancement du calcul
4005 // DirName : le repertoire de lancement des calculs du schéma
4006 //=============================================================================
4007 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
4009 INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS );
4010 INFOS ( ". nomCas : " << nomCas);
4011 INFOS ( ". ScriptFile : " << ScriptFile);
4012 INFOS ( ". DirName : " << DirName);
4013 INFOS ( ". MeshFile : " << MeshFile);
4015 // A. Controle du nom :
4016 if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(nomYACS) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end())
4018 SALOME::ExceptionStruct es;
4019 es.type = SALOME::BAD_PARAM;
4020 es.text = "This schema YACS has already been defined.";
4021 throw SALOME::SALOME_Exception(es);
4025 // B. Creation de l'objet
4026 HOMARD::HOMARD_YACS_var myYACS = newYACS();
4027 if (CORBA::is_nil(myYACS))
4029 SALOME::ExceptionStruct es;
4030 es.type = SALOME::BAD_PARAM;
4031 es.text = "Unable to create the schema YACS";
4032 throw SALOME::SALOME_Exception(es);
4035 myYACS->SetName( nomYACS ) ;
4037 // C. Enregistrement
4038 myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS] = myYACS;
4040 SALOMEDS::SObject_var aSO;
4041 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, nomYACS);
4043 PublishCaseUnderYACS(nomYACS, nomCas);
4045 // D. Caracterisation
4047 myYACS->SetDirName( DirName ) ;
4048 myYACS->SetMeshFile( MeshFile ) ;
4049 myYACS->SetScriptFile( ScriptFile ) ;
4050 myYACS->SetCaseName( nomCas ) ;
4053 // D.2.1. Type constant
4054 myYACS->SetType( 1 ) ;
4055 // D.2.2. Convergence
4056 defaut_i = GetYACSMaxIter() ;
4057 myYACS->SetMaxIter( defaut_i ) ;
4058 defaut_i = GetYACSMaxNode() ;
4059 myYACS->SetMaxNode( defaut_i ) ;
4060 defaut_i = GetYACSMaxElem() ;
4061 myYACS->SetMaxElem( defaut_i ) ;
4062 // D.3. Fichier de sauvegarde dans le repertoire du cas
4063 HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ;
4064 std::string dirnamecase = caseyacs->GetDirName() ;
4065 std::string XMLFile ;
4066 XMLFile = dirnamecase + "/schema.xml" ;
4067 myYACS->SetXMLFile( XMLFile.c_str() ) ;
4069 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
4071 //=============================================================================
4072 // Ecriture d'un schema YACS
4073 //=============================================================================
4074 CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS)
4076 INFOS ( "YACSWrite : Ecriture de " << nomYACS );
4077 // Le repertoire du cas
4078 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
4079 ASSERT(!CORBA::is_nil(myYACS));
4080 // Le nom du fichier du schema
4081 std::string XMLFile ;
4082 XMLFile = myYACS->GetXMLFile() ;
4084 int codret = YACSWriteOnFile(nomYACS, XMLFile.c_str()) ;
4088 //=============================================================================
4089 // Ecriture d'un schema YACS sur un fichier donne
4090 //=============================================================================
4091 CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile)
4093 INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile );
4100 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
4101 ASSERT(!CORBA::is_nil(myYACS));
4102 // B.2. Les caracteristiques
4103 std::string DirName = myYACS->GetDirName() ;
4104 std::string MeshFile = myYACS->GetMeshFile() ;
4105 std::string ScriptFile = myYACS->GetScriptFile() ;
4106 // B.3. Les caracteristiques de convergence
4107 int MaxIter = myYACS->GetMaxIter() ;
4108 int MaxNode = myYACS->GetMaxNode() ;
4109 int MaxElem = myYACS->GetMaxElem() ;
4113 const char* nomCas = myYACS->GetCaseName();
4114 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
4115 ASSERT(!CORBA::is_nil(myCase));
4116 // C.2. Les instructions python associees au cas
4117 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4118 std::string pythonCas = dumpCorbaCase.in();
4119 MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
4121 // D. Les iterations
4122 // D.1. L'iteration initiale
4123 HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
4124 std::string Iter0Name = myCase->GetIter0Name() ;
4125 MESSAGE (". Iter0Name = " << Iter0Name);
4126 std::string MeshName = Iter0->GetMeshName();
4127 MESSAGE (". MeshName = " << MeshName);
4128 // D.2. L'iteration numero 1
4129 HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
4130 int numberOfIter = maListe->length();
4131 if ( numberOfIter > 1 )
4133 MESSAGE (". numberOfIter = " << numberOfIter);
4134 SALOME::ExceptionStruct es ;
4135 es.type = SALOME::BAD_PARAM;
4136 std::string text = "Une seule iteration est permise." ;
4137 es.text = CORBA::string_dup(text.c_str());
4138 throw SALOME::SALOME_Exception(es);
4141 std::string Iter1Name = std::string((*maListe)[0]);
4142 MESSAGE ("... Iter1Name = " << Iter1Name);
4143 HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
4144 // D.3. Les instructions python associees a l'iteration
4145 CORBA::String_var dumpCorbaIter = Iter1->GetDumpPython();
4146 std::string pythonIter = dumpCorbaIter.in();
4147 MESSAGE ("pythonIter :\n"<<pythonIter<<"\n");
4149 // E. L'hypothese pour passer de l'iteration initiale a la suivante
4150 // E.1. La structure
4151 std::string nomHypo = Iter1->GetHypoName();
4152 MESSAGE (". nomHypo = " << nomHypo);
4153 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
4154 ASSERT(!CORBA::is_nil(myHypo));
4155 // E.2. Les caracteristiques de l'adaptation
4156 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
4157 ASSERT(ListTypes->length() == 3);
4158 int TypeAdap = (*ListTypes)[0];
4159 // int TypeRaff = (*ListTypes)[1];
4160 // int TypeDera = (*ListTypes)[2];
4161 // E.3. Les instructions python associees a l'hypothese
4162 CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
4163 std::string pythonHypo = dumpCorbaHypo.in();
4164 MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
4166 // F. Le fichier du schema de reference
4167 // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD
4168 std::string XMLFile_base ;
4169 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { XMLFile_base = getenv("HOMARD_ROOT_DIR") ; }
4172 SALOME::ExceptionStruct es ;
4173 es.type = SALOME::BAD_PARAM;
4174 std::string text = "HOMARD_ROOT_DIR est inconnu." ;
4175 es.text = CORBA::string_dup(text.c_str());
4176 throw SALOME::SALOME_Exception(es);
4179 XMLFile_base += "/share/salome/resources/homard/yacs_01." + _LangueShort + ".xml" ;
4181 MESSAGE("XMLFile_base ="<<XMLFile_base);
4183 // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4184 YACSDriver* myDriver = new YACSDriver(XMLFile, DirName);
4185 std::ifstream fichier( XMLFile_base.c_str() );
4186 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
4188 // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4189 std::string ligne; // variable contenant chaque ligne lue
4190 std::string mot_cle;
4191 while ( std::getline( fichier, ligne ) )
4193 // G.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
4194 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4195 ligne_bis >> mot_cle ;
4196 // G.1.2. Le maillage initial
4197 if ( mot_cle == "DataInit_MeshFile" )
4198 { myDriver->Texte_DataInit_MeshFile(MeshFile); }
4199 // G.1.3. Le script de lancement
4200 else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
4201 { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); }
4202 // G.1.4. Les options du cas
4203 else if ( mot_cle == "Iter_1_Case_Options" )
4204 { myDriver->Texte_Iter_1_Case_Options(pythonCas); }
4205 // G.1.5. Execution de HOMARD : le repertoire du cas
4206 else if ( mot_cle == "HOMARD_Exec_DirName" )
4207 { myDriver->Texte_HOMARD_Exec_DirName(); }
4208 // G.1.6. Execution de HOMARD : le nom du maillage
4209 else if ( mot_cle == "HOMARD_Exec_MeshName" )
4211 myDriver->Texte_HOMARD_Exec_MeshName(MeshName);
4212 std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ;
4213 myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ;
4215 // G.1.7. Execution de HOMARD : les options de l'hypothese
4216 else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
4217 { myDriver->Texte_python_1( pythonHypo, 3, "Hypo" ) ; }
4218 // G.1.8. Execution de HOMARD : les options de l'iteration
4219 else if ( mot_cle == "HOMARD_Exec_Iter_Options" )
4220 { myDriver->Texte_python_2( pythonIter, "TimeStep", "Iter" ) ; }
4221 // G.1.9. Zones et frontieres : les creations
4222 else if ( mot_cle == "Iter_1" )
4224 std::string texte_control = myDriver->Texte_Iter_1_control() ;
4225 if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; }
4226 texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ;
4227 myDriver->TexteAdd(texte_control);
4229 // G.1.10. Les tests de convergence
4230 else if ( mot_cle == "Analyse_Test_Convergence" )
4231 { myDriver->TexteAnalyse_Test_Convergence(MaxIter, MaxNode, MaxElem); }
4232 // G.1.11. Les parametres
4233 else if ( mot_cle == "PARAMETRES" )
4234 { myDriver->TexteAddParametres(); }
4235 // G.1.n. La ligne est recopiee telle quelle
4236 else { myDriver->TexteAdd(ligne); }
4238 // G.2. Ecriture du texte dans le fichier
4240 { myDriver->CreeFichier(); }
4244 SALOME::ExceptionStruct es;
4245 es.type = SALOME::BAD_PARAM;
4246 std::string text = "The reference file for the YACS schema cannot be read." ;
4247 es.text = CORBA::string_dup(text.c_str());
4248 throw SALOME::SALOME_Exception(es);
4253 // H. Publication du fichier dans l'arbre
4255 std::string Commentaire = "xml" ;
4256 PublishFileUnderYACS(nomYACS, XMLFile, Commentaire.c_str());
4260 //=============================================================================
4261 // Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
4262 //=============================================================================
4263 std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
4265 MESSAGE ( "YACSDriverTexteZone" );
4266 // A. Les zones associees a cette hypothese
4267 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
4268 int numberOfZonesx2 = ListZone->length();
4270 // B. Parcours des zones
4271 std::string texte_control ;
4272 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
4274 // 1. Reperage de la zone
4275 std::string ZoneName = std::string((*ListZone)[iaux]);
4276 MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
4277 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
4278 ASSERT(!CORBA::is_nil(myZone));
4279 // 2. Les instructions python associees a la zone
4280 // La premiere ligne est un commentaire a eliminer
4281 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4282 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4283 std::string pythonStructure_0 = dumpCorbaZone.in();
4284 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4285 std::istringstream tout (pythonStructure_0) ;
4287 std::string pythonStructure ;
4288 while ( std::getline( tout, ligne ) )
4289 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4290 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4291 // 3. Decodage du nom du service
4292 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4293 MESSAGE ( "... methode = " << methode);
4294 // 4. Mise en place des instructions
4295 int ZoneType = myZone->GetType();
4296 MESSAGE ( "... ZoneType = " << ZoneType);
4297 std::string texte_control_0 ;
4298 texte_control_0 = myDriver->Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName );
4299 texte_control += texte_control_0 ;
4304 return texte_control ;
4306 //=============================================================================
4307 // Ecriture d'un schema YACS : ecriture des frontieres associees au cas
4308 //=============================================================================
4309 std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver)
4311 MESSAGE ( "YACSDriverTexteBoundary" );
4312 // A. Les frontieres associees au cas
4313 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
4314 int numberOfitems = ListBoundaryGroupType->length();
4316 // B. Parcours des frontieres
4317 std::string texte_control ;
4318 std::list<std::string> ListeBoundaryTraitees ;
4319 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
4321 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
4322 MESSAGE ( "... BoundaryName = " << BoundaryName);
4323 // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver
4324 // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees
4326 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
4327 while (it != ListeBoundaryTraitees.end())
4329 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
4330 if ( BoundaryName == *it ) { A_faire = 0 ; }
4335 // 1. Caracteristiques de la frontiere
4336 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
4337 ASSERT(!CORBA::is_nil(myBoundary));
4338 // 2. Les instructions python associees a la frontiere
4339 // La premiere ligne est un commentaire a eliminer
4340 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4341 CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython();
4342 std::string pythonStructure_0 = dumpCorbaBoundary.in();
4343 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4344 std::istringstream tout (pythonStructure_0) ;
4346 std::string pythonStructure ;
4347 while ( std::getline( tout, ligne ) )
4348 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4349 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4350 // 3. Decodage du nom du service
4351 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4352 MESSAGE ( "... methode = " << methode);
4353 // 4. Mise en place des instructions
4354 int BoundaryType = myBoundary->GetType();
4355 MESSAGE ( "... BoundaryType = " << BoundaryType);
4356 std::string texte_control_0 ;
4357 texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName );
4358 texte_control += texte_control_0 ;
4359 // 5. Memorisation du traitement
4360 ListeBoundaryTraitees.push_back( BoundaryName );
4364 return texte_control ;
4367 //=============================================================================
4368 //=============================================================================
4369 // Next functions are inherited from SALOMEDS::Driver interface
4370 //=============================================================================
4371 //=============================================================================
4372 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
4374 CORBA::Boolean isMultiFile)
4376 MESSAGE ("Save for theURL = "<< theURL);
4377 SALOMEDS::TMPFile_var aStreamFile;
4379 // get temporary directory name
4380 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4382 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
4383 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4385 // HOMARD data file name
4386 std::string aFileName = "";
4388 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
4389 aFileName += "_HOMARD.dat";
4391 // initialize sequence of file names
4392 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
4393 aFileSeq->length(1);
4394 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
4396 // get full path to the data file
4397 aFileName = tmpDir + aFileName;
4401 std::ofstream f(aFileName.c_str());
4403 // clear temporary id map
4404 context._idmap.clear();
4409 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
4410 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
4411 HOMARD::HOMARD_Cas_var aCas = it_case->second;
4412 PortableServer::ServantBase_var aServant = GetServant(aCas);
4413 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4415 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
4416 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
4420 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4421 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
4422 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
4423 PortableServer::ServantBase_var aServant = GetServant(aZone);
4424 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4426 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
4427 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4430 // -> save hypotheses
4431 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4432 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
4433 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
4434 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4435 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4437 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
4438 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4441 // -> save iterations
4442 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4443 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
4444 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
4445 PortableServer::ServantBase_var aServant = GetServant(aIter);
4446 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4448 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
4449 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4452 // -> save boundaries
4453 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4454 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
4455 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
4456 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4457 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4458 if (aBoundaryServant) {
4459 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
4460 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4464 MESSAGE ("close file");
4467 // put temporary files to the stream
4468 MESSAGE ("put temporary files to the stream");
4469 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
4471 // remove temporary files
4472 MESSAGE ("remove temporary files");
4473 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4475 // return data stream
4476 MESSAGE ("return data stream");
4477 return aStreamFile._retn();
4480 //===========================================================================
4481 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
4483 CORBA::Boolean isMultiFile)
4485 // No specific ASCII persistence
4486 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
4487 return aStreamFile._retn();
4490 //===========================================================================
4491 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
4492 const SALOMEDS::TMPFile& theStream,
4494 CORBA::Boolean isMultiFile)
4496 MESSAGE ("Load pour theURL = "<< theURL);
4497 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
4499 // set current study
4500 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
4501 SetCurrentStudy(aStudy);
4503 // get temporary directory name
4504 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4506 // Convert the stream into sequence of files to process
4507 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
4510 // HOMARD data file name
4511 std::string aFileName = "";
4513 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
4514 aFileName = tmpDir + aFileName + "_HOMARD.dat";
4516 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4520 std::ifstream f(aFileName.c_str());
4523 context._mesCas.clear();
4524 context._mesHypotheses.clear();
4525 context._mesIterations.clear();
4526 context._mesZones.clear();
4527 context._mesBoundarys.clear();
4528 context._idmap.clear();
4534 std::getline(f, line);
4535 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
4536 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
4537 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
4538 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
4539 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
4540 std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS);
4541 if (line.substr(0, bounSignature.size()) == bounSignature) {
4542 // re-create boundary
4543 MESSAGE ("Recreation de la frontiere" );
4544 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
4545 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4546 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4547 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
4548 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
4549 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4552 else if (line.substr(0, caseSignature.size()) == caseSignature) {
4554 MESSAGE ("Recreation du cas" );
4555 HOMARD::HOMARD_Cas_var aCase = newCase();
4556 PortableServer::ServantBase_var aServant = GetServant(aCase);
4557 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4558 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
4559 context._mesCas[aCase->GetName()] = aCase;
4560 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
4563 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
4564 // re-create hypothesis
4565 MESSAGE ("Recreation de l hypothese" );
4566 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
4567 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4568 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4569 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
4570 context._mesHypotheses[aHypo->GetName()] = aHypo;
4571 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4574 else if (line.substr(0, iterSignature.size()) == iterSignature) {
4575 // re-create iteration
4576 MESSAGE ("Recreation de l'iteration" );
4577 HOMARD::HOMARD_Iteration_var aIter = newIteration();
4578 PortableServer::ServantBase_var aServant = GetServant(aIter);
4579 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4580 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
4581 context._mesIterations[aIter->GetName()] = aIter;
4582 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4585 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
4586 MESSAGE ("Recreation de la zone" );
4588 HOMARD::HOMARD_Zone_var aZone = newZone();
4589 PortableServer::ServantBase_var aServant = GetServant(aZone);
4590 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4591 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
4592 context._mesZones[aZone->GetName()] = aZone;
4593 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4596 else if (line.substr(0, zoneSignature.size()) == yacsSignature) {
4597 MESSAGE ("Recreation du schema YACS" );
4599 HOMARD::HOMARD_YACS_var aYACS = newYACS();
4600 PortableServer::ServantBase_var aServant = GetServant(aYACS);
4601 HOMARD_YACS_i* aYACSServant = dynamic_cast<HOMARD_YACS_i*>(aServant.in());
4602 if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) {
4603 context._mesYACSs[aYACS->GetName()] = aYACS;
4604 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aYACSServant);
4613 // Remove temporary files created from the stream
4615 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4620 //===========================================================================
4621 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
4622 const SALOMEDS::TMPFile& theStream,
4624 CORBA::Boolean isMultiFile)
4626 // No specific ASCII persistence
4627 return Load(theComponent, theStream, theURL, isMultiFile);
4630 //===========================================================================
4631 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
4633 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
4634 // clearing study context should be done here:
4635 // - destroy all servants and related CORBA objects
4637 // - remove context from myContextMap
4638 myContextMap.erase(theComponent->GetStudy()->StudyId());
4639 // - nullify myCurrentStudy
4640 myCurrentStudy = SALOMEDS::Study::_nil();
4644 //===========================================================================
4645 char* HOMARD_Gen_i::ComponentDataType()
4647 return CORBA::string_dup("HOMARD");
4650 //===========================================================================
4651 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
4652 const char* IORString,
4653 CORBA::Boolean isMultiFile,
4654 CORBA::Boolean isASCII)
4656 CORBA::String_var aString("");
4657 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
4658 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4659 CORBA::Object_var anObj = _orb->string_to_object(IORString);
4660 if (!CORBA::is_nil(anObj)) {
4661 PortableServer::ServantBase_var aServant = GetServant(anObj);
4662 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
4664 std::map<int, PortableServer::ServantBase*>::const_iterator it;
4665 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
4666 if (it->second == aStorable) {
4667 std::stringstream os;
4669 aString = CORBA::string_dup(os.str().c_str());
4675 return aString._retn();
4678 //===========================================================================
4679 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
4680 const char* aLocalPersistentID,
4681 CORBA::Boolean isMultiFile,
4682 CORBA::Boolean isASCII)
4684 CORBA::String_var aString("");
4685 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
4686 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4687 int id = atoi(aLocalPersistentID);
4688 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
4689 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
4690 if (!CORBA::is_nil(object)) {
4691 aString = _orb->object_to_string(object);
4695 return aString._retn();
4698 //===========================================================================
4699 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
4701 if(CORBA::is_nil(myCurrentStudy))
4704 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
4705 if(!aCas->_is_nil())
4708 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
4709 if(!aHypo->_is_nil())
4712 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
4713 if(!aZone->_is_nil())
4716 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
4717 if(!aBoundary->_is_nil())
4720 /* Iteration is not published directly
4721 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
4722 if(!aIter->_is_nil())
4728 //===========================================================================
4729 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
4731 // No Copy/Paste support
4735 //===========================================================================
4736 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
4737 CORBA::Long& theObjectID)
4739 // No Copy/Paste support
4740 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
4741 return aStreamFile._retn();
4744 //===========================================================================
4745 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
4746 CORBA::Long theObjectID)
4748 // No Copy/Paste support
4752 //===========================================================================
4753 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
4754 CORBA::Long theObjectID,
4755 SALOMEDS::SObject_ptr theSObject)
4757 // No Copy/Paste support
4758 SALOMEDS::SObject_var aResultSO;
4759 return aResultSO._retn();
4762 //===========================================================================
4763 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
4765 PortableServer::Servant aServant = 0;
4766 if (!CORBA::is_nil(theObject)) {
4768 aServant = _poa->reference_to_servant(theObject);
4776 //==========================================================================
4777 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
4778 CORBA::Boolean isPublished,
4779 CORBA::Boolean isMultiFile,
4780 CORBA::Boolean& isValidScript)
4782 MESSAGE ("Entree dans DumpPython");
4784 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
4785 if(CORBA::is_nil(aStudy))
4786 return new Engines::TMPFile(0);
4788 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
4789 if(CORBA::is_nil(aSO))
4790 return new Engines::TMPFile(0);
4792 std::string aScript = "\"\"\"\n";
4793 aScript += "Python script for HOMARD\n";
4794 aScript += "Copyright EDF-R&D 1996, 2011, 2014\n";
4795 aScript += "\"\"\"\n";
4796 aScript += "__revision__ = \"V1.2\"\n";
4797 aScript += "import HOMARD\n";
4799 aScript += "import salome\n";
4800 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4802 aScript += "def RebuildData(theStudy):\n";
4803 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
4806 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
4807 MESSAGE (". Au depart \n"<<aScript);
4810 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
4812 MESSAGE (". Ecritures des frontieres");
4813 aScript += "#\n# Creation of the boundaries";
4814 aScript += "\n# ==========================";
4816 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4817 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
4818 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
4820 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4821 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4822 std::string dumpBoundary = dumpCorbaBoundary.in();
4823 MESSAGE (dumpBoundary<<"\n");
4824 aScript += dumpBoundary;
4828 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
4830 MESSAGE (". Ecritures des zones");
4831 aScript += "#\n# Creation of the zones";
4832 aScript += "\n# =====================";
4834 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4835 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
4836 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
4838 HOMARD::HOMARD_Zone_var myZone = (*it_zone).second;
4839 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4840 std::string dumpZone = dumpCorbaZone.in();
4841 MESSAGE (dumpZone<<"\n");
4842 aScript += dumpZone;
4846 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
4848 MESSAGE (". Ecritures des hypotheses");
4849 aScript += "#\n# Creation of the hypotheses";
4850 aScript += "\n# ==========================";
4852 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4853 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
4854 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
4856 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4857 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4858 std::string dumpHypo = dumpCorbaHypo.in();
4859 MESSAGE (dumpHypo<<"\n");
4860 aScript += dumpHypo;
4864 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
4866 MESSAGE (". Ecritures des cas");
4867 aScript += "#\n# Creation of the cases";
4868 aScript += "\n# =====================";
4870 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4871 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4872 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
4874 std::string nomCas = (*it_cas).first;
4875 std::string dumpCas = std::string("\n# Creation of the case ") ;
4876 dumpCas += nomCas + std::string("\n");
4877 dumpCas += std::string("\t") + nomCas;
4878 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4880 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4881 CORBA::String_var cIter0= myCase->GetIter0Name();
4882 std::string iter0 = cIter0.in();
4884 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
4885 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4886 std::string mesh0 = cMesh0.in();
4887 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4888 std::string meshName0 = cMeshName0.in();
4889 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4890 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4891 std::string dumpCas2= dumpCorbaCase.in();
4893 MESSAGE (dumpCas<<dumpCas2<<"\n");
4894 aScript += dumpCas + dumpCas2;
4898 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
4900 MESSAGE (". Ecritures des iterations");
4901 aScript += "#\n# Creation of the iterations" ;
4902 aScript += "\n# ==========================";
4904 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4905 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
4906 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
4908 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4909 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4910 std::string dumpIter = dumpCorbaIter.in();
4911 MESSAGE (dumpIter<<"\n");
4912 aScript += dumpIter;
4916 if (myContextMap[GetCurrentStudyID()]._mesYACSs.size() > 0)
4918 MESSAGE (". Ecritures des schemas YACS");
4919 aScript += "#\n# Creation of the schemas YACS";
4920 aScript += "\n# ============================";
4922 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it_yacs;
4923 for ( it_yacs = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
4924 it_yacs != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); ++it_yacs)
4926 HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second;
4927 CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython();
4928 std::string dumpYACS = dumpCorbaYACS.in();
4929 MESSAGE (dumpYACS<<"\n");
4930 aScript += dumpYACS;
4933 MESSAGE (". Ecritures finales");
4935 aScript += "\n\tpass";
4938 if( !isMultiFile ) // remove unnecessary tabulation
4939 aScript = RemoveTabulation( aScript );
4941 // MESSAGE ("A ecrire \n"<<aScript);
4942 const size_t aLen = strlen(aScript.c_str());
4943 char* aBuffer = new char[aLen+1];
4944 strcpy(aBuffer, aScript.c_str());
4946 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4947 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4949 MESSAGE ("Sortie de DumpPython");
4950 return aStreamFile._retn();
4954 //=============================================================================
4955 //=============================================================================
4957 //=============================================================================
4958 //=============================================================================
4959 void HOMARD_Gen_i::IsValidStudy( )
4961 // MESSAGE( "IsValidStudy" );
4962 if (CORBA::is_nil(myCurrentStudy))
4964 SALOME::ExceptionStruct es;
4965 es.type = SALOME::BAD_PARAM;
4966 es.text = "Invalid study context";
4967 throw SALOME::SALOME_Exception(es);
4972 //=============================================================================
4973 char* HOMARD_Gen_i::VerifieDir(const char* nomDir)
4975 std::string casename = std::string("") ;
4976 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4977 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4978 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
4980 if (std::string(nomDir) == std::string(it->second->GetDirName()))
4982 casename = std::string(it->second->GetName()) ;
4986 return CORBA::string_dup( casename.c_str() );
4988 /*//=============================================================================
4989 void SALOMEException( std::string message )
4991 SALOME::ExceptionStruct es;
4992 es.type = SALOME::BAD_PARAM;
4994 throw SALOME::SALOME_Exception(es);
4997 //=============================================================================
4998 char* HOMARD_Gen_i::getVersion()
5000 #if HOMARD_DEVELOPMENT
5001 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
5003 return CORBA::string_dup(HOMARD_VERSION_STR);
5006 //===============================================================================
5007 // Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere
5008 // ligne : la ligne a manipuler
5009 // caractere : le caractere a reperer
5010 // option : 0 : la chaine avant la premiere apparition du caractere
5011 // 1 : la chaine apres la premiere apparition du caractere
5012 // 2 : la chaine avant la derniere apparition du caractere
5013 // 3 : la chaine apres la derniere apparition du caractere
5014 // Si le caractere est absent, on retourne la chaine totale
5015 //===============================================================================
5016 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option )
5018 // MESSAGE("GetStringInTexte, recherche de '"<<caractere<<"' dans '"<<ligne<<"'"<<", option = "<<option);
5020 std::string chaine = ligne ;
5022 if ( option < 2 ) { position = ligne.find_first_of( caractere ) ; }
5023 else { position = ligne.find_last_of( caractere ) ; }
5024 // MESSAGE("position = "<<position);
5025 // MESSAGE("a = "<<ligne.substr( 0, position ).c_str());
5026 // MESSAGE("b = "<<ligne.substr( position+1 ).c_str());
5028 if ( position != std::string::npos )
5030 if ( ( option == 0 ) || ( option == 2 ) ) { chaine = ligne.substr( 0, position ) ; }
5031 else { chaine = ligne.substr( position+1 ) ; }
5036 //=============================================================================
5037 //=============================================================================
5038 // Gestion des preferences
5039 //=============================================================================
5040 //=============================================================================
5041 // Decodage du fichier d'arcihvage des preferences
5043 void HOMARD_Gen_i::SetPreferences( )
5045 MESSAGE ( "SetPreferences" );
5047 std::string ligne, mot_cle, salome_version ;
5050 // A. Les valeurs par defaut ; elles doivent etre coherentes
5051 std::string LanguageShort = "en" ;
5052 int PublisMeshIN = 0 ;
5053 int PublisMeshOUT = 0 ;
5054 int YACSMaxIter = 0 ;
5055 int YACSMaxNode = 0 ;
5056 int YACSMaxElem = 0 ;
5057 std::string YACSTypeTestchaine = "None" ;
5059 // B. La version de salome
5060 // Cela se presente sous la forme :
5061 // [SALOME KERNEL] : 7.3.0
5063 File = getenv("KERNEL_ROOT_DIR") ;
5064 File += "/bin/salome/VERSION" ;
5065 MESSAGE ( "File = "<<File ) ;
5066 std::ifstream fichier0( File.c_str() ) ;
5067 if ( fichier0 ) // ce test échoue si le fichier n'est pas ouvert
5069 std::string ligne; // variable contenant chaque ligne lue
5070 while ( std::getline( fichier0, ligne ) )
5072 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
5073 ligne_bis >> mot_cle ;
5074 if ( mot_cle == "[SALOME" )
5076 salome_version = GetStringInTexte ( ligne, " ", 3 ) ;
5077 // MESSAGE ( "salome_version = "<<salome_version<<"|||");
5082 else { ok = false ; }
5084 // B. Decodage du fichier de preferences
5087 std::string PrefFile ;
5088 PrefFile = getenv("HOME") ;
5089 PrefFile += "/.config/salome/SalomeApprc." + salome_version ;
5090 MESSAGE ( "PrefFile = "<<PrefFile ) ;
5092 std::ifstream fichier( PrefFile.c_str() );
5093 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
5095 bool section_langue = false ;
5096 bool section_homard = false ;
5097 while ( std::getline( fichier, ligne ) )
5099 std::string chaine ;
5100 // 1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
5101 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
5102 ligne_bis >> mot_cle ;
5105 // 2.1. Debut d'une section
5106 // MESSAGE(mot_cle);
5107 if ( mot_cle == "<section" )
5108 { /*MESSAGE ( "Debut de la section : "<< ligne);*/
5109 ligne_bis >> mot_cle ;
5110 chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5111 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5112 if ( chaine == "language" ) { section_langue = true ; }
5113 if ( chaine == "HOMARD" ) { section_homard = true ; }
5114 // MESSAGE ( "section_langue = "<<section_langue<<", section_homard = "<<section_homard);
5116 // 2.2. Fin d'une section
5117 else if ( mot_cle == "</section>" )
5118 { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<<section_langue<<", section_homard = "<<section_homard);*/
5119 section_langue = false ;
5120 section_homard = false ; }
5124 else if ( section_langue || section_homard )
5125 { MESSAGE ( "a decoder : "<< ligne);
5126 // La valeur : entre les deux premieres quotes
5127 chaine = GetStringInTexte ( ligne, "\"", 1 ) ;
5128 // MESSAGE("chaine 1 = |"<<chaine<<"|");
5129 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5130 // MESSAGE("chaine = |"<<chaine<<"|");
5131 // Le mot_cle : entre les deux dernieres quotes
5132 std::string chaine2 = GetStringInTexte ( ligne, "\"", 2 ) ;
5133 // MESSAGE("chaine2 1 = |"<<chaine2<<"|");
5134 chaine2 = GetStringInTexte ( chaine2, "\"", 3 ) ;
5135 // MESSAGE("chaine2 = |"<<chaine2<<"|");
5137 if ( section_langue )
5138 { if ( chaine2 == "language" ) { LanguageShort = chaine ; } }
5140 if ( section_homard )
5142 std::istringstream chainebis( chaine ) ;
5143 // 3.2.1. Les publications
5144 if ( chaine2 == "publish_mesh_in" ) { chainebis >> PublisMeshIN ; }
5145 if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT ; }
5146 // 3.2.2. Les maximum pour YACS
5147 if ( chaine2 == "yacs_max_iter" ) { chainebis >> YACSMaxIter ; }
5148 if ( chaine2 == "yacs_max_node" ) { chainebis >> YACSMaxNode ; }
5149 if ( chaine2 == "yacs_max_elem" ) { chainebis >> YACSMaxElem ; }
5150 if ( chaine2 == "yacs_type_test" ) { YACSTypeTestchaine = chaine ; }
5157 // C. Enregistrements
5158 MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort );
5159 SetLanguageShort( LanguageShort.c_str() ) ;
5161 MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT);
5162 SetPublisMesh(PublisMeshIN, PublisMeshOUT) ;
5164 MESSAGE ("Enregistrement de YACSMaxIter = " << YACSMaxIter<<", YACSMaxNode = "<< YACSMaxNode<<", YACSMaxElem = "<< YACSMaxElem);
5165 SetYACSMaximum(YACSMaxIter, YACSMaxNode, YACSMaxElem) ;
5167 MESSAGE ("Enregistrement de TypeTest = " << YACSTypeTestchaine.c_str() );
5169 if ( ( YACSTypeTestchaine == "VTest > VRef" ) || ( YACSTypeTestchaine == "VTest > VRef" ) ) { YACSTypeTest = 1 ; }
5170 else if ( ( YACSTypeTestchaine == "VTest < VRef" ) || ( YACSTypeTestchaine == "VTest < VRef" ) ) { YACSTypeTest = 2 ; }
5171 else { YACSTypeTest = 0 ; }
5172 MESSAGE ("==> TypeTest = " << YACSTypeTest );
5173 SetYACSConvergenceType( YACSTypeTest ) ;
5177 //===============================================================================
5179 //===============================================================================
5180 void HOMARD_Gen_i::SetLanguageShort(const char* LanguageShort)
5182 // MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort );
5183 _LangueShort = LanguageShort ;
5184 if ( _LangueShort == "fr" ) { _Langue = "Francais" ; }
5185 else { _Langue = "English" ; }
5188 char* HOMARD_Gen_i::GetLanguageShort()
5190 // MESSAGE ("GetLanguageShort");
5191 return CORBA::string_dup( _LangueShort.c_str() );
5193 //===============================================================================
5194 // Options de publications
5195 //===============================================================================
5196 void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT)
5198 _PublisMeshIN = PublisMeshIN ;
5199 _PublisMeshOUT = PublisMeshOUT ;
5202 CORBA::Long HOMARD_Gen_i::GetPublisMeshIN()
5204 return _PublisMeshIN ;
5206 CORBA::Long HOMARD_Gen_i::GetPublisMeshOUT()
5208 return _PublisMeshOUT ;
5210 //===============================================================================
5211 // YACS - test de convergence
5212 //===============================================================================
5213 void HOMARD_Gen_i::SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem)
5215 _YACSMaxIter = YACSMaxIter ;
5216 _YACSMaxNode = YACSMaxNode ;
5217 _YACSMaxElem = YACSMaxElem ;
5220 CORBA::Long HOMARD_Gen_i::GetYACSMaxIter()
5222 return _YACSMaxIter ;
5224 CORBA::Long HOMARD_Gen_i::GetYACSMaxNode()
5226 return _YACSMaxNode ;
5228 CORBA::Long HOMARD_Gen_i::GetYACSMaxElem()
5230 return _YACSMaxElem ;
5232 void HOMARD_Gen_i::SetYACSConvergenceType(CORBA::Long YACSTypeTest)
5234 _YACSTypeTest = YACSTypeTest ;
5237 CORBA::Long HOMARD_Gen_i::GetYACSConvergenceType()
5239 return _YACSTypeTest ;
5242 //=============================================================================
5246 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
5247 PortableServer::POA_ptr poa,
5248 PortableServer::ObjectId* contId,
5249 const char* instanceName,
5250 const char* interfaceName)
5252 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
5253 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
5254 return myHOMARD_Gen->getId();