1 // Copyright (C) 2011-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "HOMARD_Gen_i.hxx"
21 #include "HOMARD_Cas_i.hxx"
22 #include "HOMARD_Hypothesis_i.hxx"
23 #include "HOMARD_Iteration_i.hxx"
24 #include "HOMARD_Boundary_i.hxx"
25 #include "HOMARD_Zone_i.hxx"
26 #include "HOMARD_YACS_i.hxx"
27 #include "HomardDriver.hxx"
28 #include "HOMARD_DriverTools.hxx"
29 #include "HomardMedCommun.h"
30 #include "YACSDriver.hxx"
33 #include "HOMARD_version.h"
35 #include "utilities.h"
36 #include "Utils_SINGLETON.hxx"
37 #include "Utils_CorbaException.hxx"
38 #include "SALOMEDS_Tool.hxx"
39 #include "SALOME_LifeCycleCORBA.hxx"
40 #include "SALOMEconfig.h"
41 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
42 #include CORBA_CLIENT_HEADER(SMESH_Gen)
65 //=============================================================================
67 //=============================================================================
68 std::string RemoveTabulation( std::string theScript )
70 std::string::size_type aPos = 0;
71 while( aPos < theScript.length() )
73 aPos = theScript.find( "\n\t", aPos );
74 if( aPos == std::string::npos )
76 theScript.replace( aPos, 2, "\n" );
81 //=============================================================================
83 * standard constructor
85 //=============================================================================
86 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
87 PortableServer::POA_ptr poa,
88 PortableServer::ObjectId * contId,
89 const char *instanceName,
90 const char *interfaceName) :
91 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
93 MESSAGE("constructor");
95 _id = _poa->activate_object(_thisObj);
97 myHomard = new ::HOMARD_Gen();
98 _NS = SINGLETON_<SALOME_NamingService>::Instance();
99 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
110 //=================================
112 * standard destructor
114 //================================
115 HOMARD_Gen_i::~HOMARD_Gen_i()
118 //=============================================================================
119 //=============================================================================
120 // Utilitaires pour l'étude
121 //=============================================================================
122 //=============================================================================
123 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
125 ASSERT(!CORBA::is_nil(theStudy));
126 MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
127 SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
129 // Create SComponent labelled 'homard' if it doesn't already exit
130 SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
131 if (CORBA::is_nil(homardFather))
133 myBuilder->NewCommand();
134 MESSAGE("Add Component HOMARD");
136 bool aLocked = theStudy->GetProperties()->IsLocked();
137 if (aLocked) theStudy->GetProperties()->SetLocked(false);
139 homardFather = myBuilder->NewComponent(ComponentDataType());
140 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
141 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
142 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
143 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
144 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
145 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
146 if (!Comp->_is_nil())
148 aName->SetValue(ComponentDataType());
151 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
152 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
153 aPixmap->SetPixMap("HOMARD_2.png");
154 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
156 if (aLocked) theStudy->GetProperties()->SetLocked(true);
157 myBuilder->CommitCommand();
160 //=============================================================================
161 void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
163 MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID());
164 myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy);
165 this->addInStudy(myCurrentStudy);
167 //=============================================================================
168 SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
169 //=============================================================================
171 MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID());
172 return SALOMEDS::Study::_duplicate(myCurrentStudy);
174 //=============================================================================
175 CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
176 //=============================================================================
178 return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
180 //=============================================================================
181 //=============================================================================
183 //=============================================================================
184 //=============================================================================
185 // Utilitaires pour l'iteration
186 //=============================================================================
187 //=============================================================================
188 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
189 //=====================================================================================
191 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
192 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
193 if (CORBA::is_nil(myIteration))
195 SALOME::ExceptionStruct es;
196 es.type = SALOME::BAD_PARAM;
197 es.text = "Invalid iteration";
198 throw SALOME::SALOME_Exception(es);
202 myIteration->SetState(Etat);
204 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
205 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
209 icone = "iter0.png" ;
210 else if ( Etat == 2 )
211 icone = "iter_calculee.png" ;
213 icone = "iter_non_calculee.png" ;
214 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ;
216 aStudyBuilder->CommitCommand();
219 //=============================================================================
220 //=============================================================================
222 //=============================================================================
223 //=============================================================================
224 // Destruction des structures identifiees par leurs noms
225 //=============================================================================
226 //=============================================================================
227 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
229 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
230 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
231 if (CORBA::is_nil(myBoundary))
233 SALOME::ExceptionStruct es;
234 es.type = SALOME::BAD_PARAM;
235 es.text = "Invalid boundary";
236 throw SALOME::SALOME_Exception(es);
240 // On verifie que la frontiere n'est plus utilisee
241 HOMARD::listeCases* maListe = GetAllCasesName();
242 int numberOfCases = maListe->length();
243 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
244 std::string CaseName ;
245 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
247 HOMARD::HOMARD_Cas_var myCase ;
248 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
250 CaseName = std::string((*maListe)[NumeCas]);
251 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
252 myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
253 ASSERT(!CORBA::is_nil(myCase));
254 ListBoundaryGroupType = myCase->GetBoundaryGroup();
255 numberOfitems = ListBoundaryGroupType->length();
256 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
257 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
259 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
261 SALOME::ExceptionStruct es;
262 es.type = SALOME::BAD_PARAM;
263 es.text = "This boundary is used in a case and cannot be deleted.";
264 throw SALOME::SALOME_Exception(es);
270 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
271 myContextMap[GetCurrentStudyID()]._mesBoundarys.erase(BoundaryName);
272 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(BoundaryName, ComponentDataType());
273 SALOMEDS::SObject_var aSO =listSO[0];
274 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
275 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
279 //=============================================================================
280 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option)
282 // Pour detruire un cas
283 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
284 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
285 if (CORBA::is_nil(myCase))
287 SALOME::ExceptionStruct es;
288 es.type = SALOME::BAD_PARAM;
289 es.text = "Invalid case context";
290 throw SALOME::SALOME_Exception(es);
293 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
294 CORBA::String_var nomIter = myCase->GetIter0Name();
295 CORBA::Long Option1 = 0 ;
296 if ( DeleteIterationOption(nomIter, Option1, Option) != 0 )
301 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
302 myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas);
303 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType());
304 SALOMEDS::SObject_var aSO =listSO[0];
305 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
306 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
310 //=============================================================================
311 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
313 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
314 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
315 if (CORBA::is_nil(myHypo))
317 SALOME::ExceptionStruct es;
318 es.type = SALOME::BAD_PARAM;
319 es.text = "Invalid hypothesis";
320 throw SALOME::SALOME_Exception(es);
324 // On verifie que l'hypothese n'est plus utilisee
325 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
326 int numberOfIter = maListeIter->length();
327 if ( numberOfIter > 0 )
329 SALOME::ExceptionStruct es;
330 es.type = SALOME::BAD_PARAM;
331 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
332 throw SALOME::SALOME_Exception(es);
336 // suppression du lien avec les zones eventuelles
337 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
338 int numberOfZones = maListe->length();
339 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
340 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
342 std::string ZoneName = std::string((*maListe)[NumeZone]);
343 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
344 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
348 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
349 myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo);
350 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType());
351 SALOMEDS::SObject_var aSO =listSO[0];
352 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
353 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
357 //=============================================================================
358 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
360 // Option = 0 : On ne supprime pas le fichier du maillage associe
361 // Option = 1 : On supprime le fichier du maillage associe
362 // Pour detruire une iteration courante
363 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
364 CORBA::Long Option1 = 1 ;
365 return DeleteIterationOption(nomIter, Option1, Option);
367 //=============================================================================
368 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
370 // Option1 = 0 : On autorise la destruction de l'iteration 0
371 // Option1 = 1 : On interdit la destruction de l'iteration 0
373 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
374 // Option2 = 1 : On supprime le fichier du maillage associe
375 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
376 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
377 if (CORBA::is_nil(myIteration))
379 SALOME::ExceptionStruct es;
380 es.type = SALOME::BAD_PARAM;
381 es.text = "Invalid iteration";
382 throw SALOME::SALOME_Exception(es);
386 int numero = myIteration->GetNumber();
387 MESSAGE ( "DeleteIterationOption : numero = " << numero );
388 if ( numero == 0 && Option1 == 1 )
390 SALOME::ExceptionStruct es;
391 es.type = SALOME::BAD_PARAM;
392 es.text = "This iteration cannot be deleted.";
393 throw SALOME::SALOME_Exception(es);
397 // On detruit recursivement toutes les filles
398 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
399 int numberOfIter = maListe->length();
400 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
402 std::string nomIterFille = std::string((*maListe)[NumeIter]);
403 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
404 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
407 // On arrive ici pour une iteration sans fille
408 MESSAGE ( "Destruction effective de " << nomIter );
409 // On commence par invalider l'iteration pour faire le menage des dependances
410 // et eventuellement du maillage associe
412 if ( numero == 0 ) { option = 0 ; }
413 else { option = Option2 ; }
414 InvalideIterOption(nomIter, option) ;
416 // Retrait dans la descendance de l'iteration parent
419 std::string nomIterationParent = myIteration->GetIterParentName();
420 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
421 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
422 if (CORBA::is_nil(myIterationParent))
424 SALOME::ExceptionStruct es;
425 es.type = SALOME::BAD_PARAM;
426 es.text = "Invalid iteration";
427 throw SALOME::SALOME_Exception(es);
430 myIterationParent->UnLinkNextIteration(nomIter);
433 // suppression du lien avec l'hypothese
436 std::string nomHypo = myIteration->GetHypoName();
437 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
438 ASSERT(!CORBA::is_nil(myHypo));
439 myHypo->UnLinkIteration(nomIter);
442 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
443 myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter);
444 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType());
445 SALOMEDS::SObject_var aSO =listSO[0];
446 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
447 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
448 // on peut aussi faire RemoveObject
449 // MESSAGE ( "Au final" );
450 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
451 // numberOfIter = Liste->length();
452 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
454 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
455 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
460 //=============================================================================
461 CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option)
463 // Option = 0 : On ne supprime pas le fichier du schema associe
464 // Option = 1 : On supprime le fichier du schema associe
465 MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option );
466 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
467 if (CORBA::is_nil(myYACS))
469 SALOME::ExceptionStruct es;
470 es.type = SALOME::BAD_PARAM;
471 es.text = "Invalid schema YACS";
472 throw SALOME::SALOME_Exception(es);
475 // Suppression eventuelle du fichier XML
478 std::string nomFichier = myYACS->GetXMLFile();
479 std::string commande = "rm -rf " + nomFichier ;
480 MESSAGE ( "commande = " << commande );
481 if ((system(commande.c_str())) != 0)
483 SALOME::ExceptionStruct es;
484 es.type = SALOME::BAD_PARAM;
485 es.text = "The xml file for the schema YACS cannot be removed." ;
486 throw SALOME::SALOME_Exception(es);
490 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
491 myContextMap[GetCurrentStudyID()]._mesYACSs.erase(nomYACS);
492 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomYACS, ComponentDataType());
493 SALOMEDS::SObject_var aSO =listSO[0];
494 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
495 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
499 //=============================================================================
500 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
502 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
503 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone];
504 if (CORBA::is_nil(myZone))
506 SALOME::ExceptionStruct es;
507 es.type = SALOME::BAD_PARAM;
508 es.text = "Invalid zone";
509 throw SALOME::SALOME_Exception(es);
513 // On verifie que la zone n'est plus utilisee
514 HOMARD::listeHypo* maListe = myZone->GetHypo();
515 int numberOfHypo = maListe->length();
516 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
517 if ( numberOfHypo > 0 )
519 SALOME::ExceptionStruct es;
520 es.type = SALOME::BAD_PARAM;
521 es.text = "This zone is used in an hypothesis and cannot be deleted.";
522 throw SALOME::SALOME_Exception(es);
526 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
527 myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone);
528 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType());
529 SALOMEDS::SObject_var aSO =listSO[0];
530 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
531 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
535 //=============================================================================
536 //=============================================================================
538 //=============================================================================
539 //=============================================================================
540 // Invalidation des structures identifiees par leurs noms
541 //=============================================================================
542 //=============================================================================
543 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
545 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
546 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
547 if (CORBA::is_nil(myBoundary))
549 SALOME::ExceptionStruct es;
550 es.type = SALOME::BAD_PARAM;
551 es.text = "Invalid boundary";
552 throw SALOME::SALOME_Exception(es);
557 SALOME::ExceptionStruct es;
558 es.type = SALOME::BAD_PARAM;
559 es.text = "No change is allowed in a boundary. Ask for evolution.";
560 throw SALOME::SALOME_Exception(es);
564 //=============================================================================
565 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
567 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
568 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
569 if (CORBA::is_nil(myHypo))
571 SALOME::ExceptionStruct es;
572 es.type = SALOME::BAD_PARAM;
573 es.text = "Invalid hypothesis";
574 throw SALOME::SALOME_Exception(es);
578 HOMARD::listeIters* maListe = myHypo->GetIterations();
579 int numberOfIter = maListe->length();
580 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
582 std::string nomIter = std::string((*maListe)[NumeIter]);
583 MESSAGE( ".. nomIter = " << nomIter );
584 InvalideIter(nomIter.c_str());
587 //=============================================================================
588 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
590 MESSAGE("InvalideIter : nomIter = " << nomIter);
591 // Pour invalider totalement une iteration courante
592 CORBA::Long Option = 1 ;
593 return InvalideIterOption(nomIter, Option);
595 //=============================================================================
596 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
598 // Option = 0 : On ne supprime pas le fichier du maillage associe
599 // Option = 1 : On supprime le fichier du maillage associe
600 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
601 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
602 if (CORBA::is_nil(myIteration))
604 SALOME::ExceptionStruct es;
605 es.type = SALOME::BAD_PARAM;
606 es.text = "Invalid iteration";
607 throw SALOME::SALOME_Exception(es);
611 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
612 int numberOfIter = maListe->length();
613 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
615 std::string nomIterFille = std::string((*maListe)[NumeIter]);
616 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
617 InvalideIter(nomIterFille.c_str());
620 // On arrive ici pour une iteration sans fille
621 MESSAGE ( "Invalidation effective de " << nomIter );
622 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
623 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
624 for (; aIter->More(); aIter->Next())
626 SALOMEDS::SObject_var so = aIter->Value();
627 SALOMEDS::GenericAttribute_var anAttr;
628 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
629 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
630 std::string value (aCommentAttr->Value());
631 if(value == std::string("HypoHomard")) continue;
632 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
633 aStudyBuilder->RemoveObject(so);
636 int etat = myIteration->GetState();
639 SetEtatIter(nomIter,1);
640 const char * nomCas = myIteration->GetCaseName();
641 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
642 if (CORBA::is_nil(myCase))
644 SALOME::ExceptionStruct es;
645 es.type = SALOME::BAD_PARAM;
646 es.text = "Invalid case context";
647 throw SALOME::SALOME_Exception(es);
650 std::string nomDir = myIteration->GetDirName();
651 std::string nomFichier = myIteration->GetMeshFile();
652 std::string commande = "rm -rf " + std::string(nomDir);
653 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
654 MESSAGE ( "commande = " << commande );
655 if ((system(commande.c_str())) != 0)
657 SALOME::ExceptionStruct es;
658 es.type = SALOME::BAD_PARAM;
659 es.text = "The directory for the calculation cannot be cleared." ;
660 throw SALOME::SALOME_Exception(es);
663 // Suppression du maillage publie dans SMESH
664 std::string MeshName = myIteration->GetMeshName() ;
665 DeleteResultInSmesh(nomFichier, MeshName) ;
669 //=============================================================================
670 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
672 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
673 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
674 if (CORBA::is_nil(myIteration))
676 SALOME::ExceptionStruct es;
677 es.type = SALOME::BAD_PARAM;
678 es.text = "Invalid iteration";
679 throw SALOME::SALOME_Exception(es);
683 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
684 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
685 for (; aIter->More(); aIter->Next())
687 SALOMEDS::SObject_var so = aIter->Value();
688 SALOMEDS::GenericAttribute_var anAttr;
689 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
690 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
691 std::string value (aCommentAttr->Value());
692 /* MESSAGE("... value = " << value);*/
693 if( (value == std::string("logInfo")) || ( value == std::string("SummaryInfo")) )
695 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
696 aStudyBuilder->RemoveObject(so);
700 const char * nomCas = myIteration->GetCaseName();
701 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
702 if (CORBA::is_nil(myCase))
704 SALOME::ExceptionStruct es;
705 es.type = SALOME::BAD_PARAM;
706 es.text = "Invalid case context";
707 throw SALOME::SALOME_Exception(es);
710 const char* nomDir = myIteration->GetDirName();
711 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
712 commande += std::string(nomDir) + "/Liste.*info" ;
713 /* MESSAGE ( "commande = " << commande );*/
714 if ((system(commande.c_str())) != 0)
716 SALOME::ExceptionStruct es;
717 es.type = SALOME::BAD_PARAM;
718 es.text = "The directory for the calculation cannot be cleared." ;
719 throw SALOME::SALOME_Exception(es);
723 //=============================================================================
724 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
726 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
727 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
728 if (CORBA::is_nil(myZone))
730 SALOME::ExceptionStruct es;
731 es.type = SALOME::BAD_PARAM;
732 es.text = "Invalid zone";
733 throw SALOME::SALOME_Exception(es);
736 HOMARD::listeHypo* maListe = myZone->GetHypo();
737 int numberOfHypo = maListe->length();
738 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
739 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
741 std::string nomHypo = std::string((*maListe)[NumeHypo]);
742 MESSAGE( ".. nomHypo = " << nomHypo );
743 InvalideHypo(nomHypo.c_str());
746 //=============================================================================
747 //=============================================================================
749 //=============================================================================
750 //=============================================================================
751 // Association de lien entre des structures identifiees par leurs noms
752 //=============================================================================
753 //=============================================================================
754 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
756 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
758 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
759 if (CORBA::is_nil(myCase))
761 SALOME::ExceptionStruct es;
762 es.type = SALOME::BAD_PARAM;
763 es.text = "Invalid case";
764 throw SALOME::SALOME_Exception(es);
768 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
769 if (CORBA::is_nil(myIteration))
771 SALOME::ExceptionStruct es;
772 es.type = SALOME::BAD_PARAM;
773 es.text = "Invalid iteration";
774 throw SALOME::SALOME_Exception(es);
778 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
779 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
780 if (CORBA::is_nil(aCasSO))
782 SALOME::ExceptionStruct es;
783 es.type = SALOME::BAD_PARAM;
784 es.text = "Invalid case";
785 throw SALOME::SALOME_Exception(es);
789 aStudyBuilder->NewCommand();
790 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
791 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
792 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
793 aStudyBuilder->CommitCommand();
795 myCase->AddIteration(nomIter);
796 myIteration->SetCaseName(nomCas);
798 //=====================================================================================
799 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
801 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
803 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
804 ASSERT(!CORBA::is_nil(myHypo));
805 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
806 ASSERT(!CORBA::is_nil(aHypoSO));
808 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
809 ASSERT(!CORBA::is_nil(myZone));
810 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
811 ASSERT(!CORBA::is_nil(aZoneSO));
813 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
815 aStudyBuilder->NewCommand();
817 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
818 aStudyBuilder->Addreference(aSubSO, aZoneSO);
820 aStudyBuilder->CommitCommand();
822 myZone->AddHypo(nomHypothesis);
823 myHypo->AddZone0(ZoneName, TypeUse);
825 //=============================================================================
826 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
828 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
830 // Verification de l'existence de l'hypothese
831 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
832 ASSERT(!CORBA::is_nil(myHypo));
833 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
834 ASSERT(!CORBA::is_nil(aHypoSO));
836 // Verification de l'existence de l'iteration
837 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
838 ASSERT(!CORBA::is_nil(myIteration));
839 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
840 ASSERT(!CORBA::is_nil(aIterSO));
842 // Gestion de l'arbre d'etudes
843 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
844 aStudyBuilder->NewCommand();
845 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
846 aStudyBuilder->Addreference(aSubSO, aHypoSO);
847 aStudyBuilder->CommitCommand();
850 myIteration->SetHypoName(nomHypo);
851 myHypo->LinkIteration(nomIter);
853 // On stocke les noms des champ a interpoler pour le futur controle de la donnee des pas de temps
854 myIteration->SupprFieldInterps() ;
855 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
856 int numberOfFieldsx2 = ListField->length();
857 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
859 std::string FieldName = std::string((*ListField)[iaux]) ;
860 myIteration->SetFieldInterp(FieldName.c_str()) ;
864 //=============================================================================
865 //=============================================================================
867 //=============================================================================
868 //=============================================================================
869 // Dissociation de lien entre des structures identifiees par leurs noms
870 //=============================================================================
871 //=============================================================================
872 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
874 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
876 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
877 ASSERT(!CORBA::is_nil(myHypo));
878 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
879 ASSERT(!CORBA::is_nil(aHypoSO));
881 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
882 ASSERT(!CORBA::is_nil(myZone));
883 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
884 ASSERT(!CORBA::is_nil(aZoneSO));
886 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
888 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
889 for (; it->More(); it->Next())
891 SALOMEDS::SObject_var aHypObj = it->Value();
892 SALOMEDS::SObject_var ptrObj;
893 if (aHypObj->ReferencedObject(ptrObj))
895 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
897 aStudyBuilder->NewCommand();
898 aStudyBuilder->RemoveObject(aHypObj);
899 aStudyBuilder->CommitCommand();
905 myZone->SupprHypo(nomHypothesis);
906 myHypo->SupprZone(ZoneName);
908 //=============================================================================
909 //=============================================================================
912 //=============================================================================
913 //=============================================================================
914 // Recuperation des listes
915 //=============================================================================
916 //=============================================================================
917 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
919 MESSAGE("GetAllBoundarysName");
922 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
923 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
924 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
926 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
927 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
929 ret[i++] = CORBA::string_dup((*it).first.c_str());
934 //=============================================================================
935 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
937 MESSAGE("GetAllCasesName");
940 HOMARD::listeCases_var ret = new HOMARD::listeCases;
941 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
942 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
944 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
945 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
947 ret[i++] = CORBA::string_dup((*it).first.c_str());
952 //=============================================================================
953 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
955 MESSAGE("GetAllHypothesesName");
958 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
959 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
960 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
962 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
963 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
965 ret[i++] = CORBA::string_dup((*it).first.c_str());
970 //=============================================================================
971 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
973 MESSAGE("GetAllIterationsName");
976 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
977 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
978 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
980 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
981 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
983 ret[i++] = CORBA::string_dup((*it).first.c_str());
988 //=============================================================================
989 HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName()
991 MESSAGE("GetAllYACSsName");
994 HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs;
995 ret->length(myContextMap[GetCurrentStudyID()]._mesYACSs.size());
996 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it;
998 for (it = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
999 it != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); it++)
1001 ret[i++] = CORBA::string_dup((*it).first.c_str());
1006 //=============================================================================
1007 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
1009 MESSAGE("GetAllZonesName");
1012 HOMARD::listeZones_var ret = new HOMARD::listeZones;
1013 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
1014 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
1016 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
1017 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
1019 ret[i++] = CORBA::string_dup((*it).first.c_str());
1024 //=============================================================================
1025 //=============================================================================
1027 //=============================================================================
1028 //=============================================================================
1029 // Recuperation des structures identifiees par leurs noms
1030 //=============================================================================
1031 //=============================================================================
1032 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
1034 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
1035 ASSERT(!CORBA::is_nil(myBoundary));
1036 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1038 //=============================================================================
1039 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
1041 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1042 ASSERT(!CORBA::is_nil(myCase));
1043 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1045 //=============================================================================
1046 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
1048 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
1049 ASSERT(!CORBA::is_nil(myHypothesis));
1050 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1052 //=============================================================================
1053 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
1055 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
1056 ASSERT(!CORBA::is_nil(myIteration));
1057 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1059 //=============================================================================
1060 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS)
1062 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
1063 ASSERT(!CORBA::is_nil(myYACS));
1064 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
1066 //=============================================================================
1067 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
1069 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
1070 ASSERT(!CORBA::is_nil(myZone));
1071 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1073 //=============================================================================
1074 //=============================================================================
1076 //=============================================================================
1077 //=============================================================================
1079 //=============================================================================
1080 //=============================================================================
1081 void HOMARD_Gen_i::MeshInfo(const char* nomCas, const char* MeshName, const char* MeshFile, const char* DirName, CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte)
1083 INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1084 INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
1089 if ( _PublisMeshIN != 0 ) option = 2 ;
1090 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option) ;
1091 myCase->SetDirName(DirName) ;
1093 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1097 //=============================================================================
1098 //=============================================================================
1100 //=============================================================================
1101 //=============================================================================
1102 // Recuperation des structures par le contexte
1103 //=============================================================================
1104 //=============================================================================
1105 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1107 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1108 ASSERT(!CORBA::is_nil(myCase));
1110 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1111 ASSERT(!CORBA::is_nil(myIteration));
1113 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1115 //=============================================================================
1116 //=============================================================================
1118 //=============================================================================
1119 //=============================================================================
1120 // Nouvelles structures
1121 //=============================================================================
1122 //=============================================================================
1123 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1125 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1126 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1127 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1128 return aCase._retn();
1130 //=============================================================================
1131 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1133 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1134 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1135 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1136 return aHypo._retn();
1138 //=============================================================================
1139 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1141 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1142 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1143 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1144 return aIter._retn();
1146 //=============================================================================
1147 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1149 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1150 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1151 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1152 return aBoundary._retn();
1154 //=============================================================================
1155 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1157 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1158 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1159 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1160 return aZone._retn();
1162 //=============================================================================
1163 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS()
1165 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1166 HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine);
1167 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this());
1168 return aYACS._retn();
1170 //=============================================================================
1171 //=============================================================================
1173 //=============================================================================
1174 //=============================================================================
1175 // Creation des structures identifiees par leurs noms
1176 //=============================================================================
1177 //=============================================================================
1178 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1180 // Creation d'un cas initial
1181 // nomCas : nom du cas a creer
1182 // MeshName, MeshFile : nom et fichier du maillage correspondant
1185 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1188 if ( _PublisMeshIN != 0 ) option = 2 ;
1189 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option) ;
1191 // Valeurs par defaut des filtrages
1192 myCase->SetPyram(0);
1194 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1196 //=============================================================================
1197 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1199 // nomCas : nom du cas a creer
1200 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1203 INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1204 std::string nomDirWork = getenv("PWD") ;
1207 // A. Decodage du point de reprise
1208 // A.1. Controle du repertoire de depart de l'iteration
1210 codret = chdir(DirNameStart) ;
1212 codret = _chdir(DirNameStart) ;
1216 SALOME::ExceptionStruct es;
1217 es.type = SALOME::BAD_PARAM;
1218 es.text = "The directory of the iteration does not exist.";
1219 throw SALOME::SALOME_Exception(es);
1222 // A.2. Reperage des fichiers du repertoire de reprise
1223 std::string file_configuration = "" ;
1224 std::string file_maillage_homard = "" ;
1228 struct dirent *dirp;
1229 dp = opendir(DirNameStart);
1230 while ( (dirp = readdir(dp)) != NULL )
1232 std::string file_name(dirp->d_name);
1233 // MESSAGE ( file_name );
1234 bilan = file_name.find("HOMARD.Configuration.") ;
1235 if ( bilan != string::npos ) { file_configuration = file_name ; }
1236 bilan = file_name.find("maill.") ;
1237 if ( bilan != string::npos )
1239 bilan = file_name.find(".hom.med") ;
1240 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1245 HANDLE hFind = INVALID_HANDLE_VALUE;
1246 WIN32_FIND_DATA ffd;
1247 hFind = FindFirstFile(DirNameStart, &ffd);
1248 if (INVALID_HANDLE_VALUE != hFind) {
1249 while (FindNextFile(hFind, &ffd) != 0) {
1250 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1251 std::string file_name(ffd.cFileName);
1252 bilan = file_name.find("HOMARD.Configuration.") ;
1253 if ( bilan != string::npos ) { file_configuration = file_name ; }
1254 bilan = file_name.find("maill.") ;
1255 if ( bilan != string::npos )
1257 bilan = file_name.find(".hom.med") ;
1258 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1264 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1265 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1267 if ( ( file_configuration == "" ) || ( file_maillage_homard == "" ) )
1269 SALOME::ExceptionStruct es;
1270 es.type = SALOME::BAD_PARAM;
1272 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1273 else { text = "The HOMARD mesh file cannot be found." ; }
1274 es.text = CORBA::string_dup(text.c_str());
1275 throw SALOME::SALOME_Exception(es);
1278 // B. Lecture du fichier de configuration
1279 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1285 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1286 std::ifstream fichier( file_configuration.c_str() );
1287 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1289 std::string ligne; // variable contenant chaque ligne lue
1290 std::string mot_cle;
1291 std::string argument;
1293 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1294 while ( std::getline( fichier, ligne ) )
1296 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1297 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1298 ligne_bis >> mot_cle ;
1299 // B.2. Des valeurs entieres : le second bloc de la ligne
1300 if ( mot_cle == "NumeIter" )
1302 ligne_bis >> NumeIter ;
1305 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1306 else if ( ( mot_cle == "TypeConf" ) || ( mot_cle == "TypeElem" ) )
1308 ligne_bis >> argument ;
1310 if ( mot_cle == "TypeConf" )
1312 if ( argument == "conforme" ) { TypeConf = 1 ; }
1313 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1314 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1315 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1317 else if ( mot_cle == "TypeElem" )
1319 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1320 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1323 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1324 // il faut les supprimer
1325 else if ( ( mot_cle == "CCNoMNP1" ) || ( mot_cle == "CCMaiNP1" ) )
1327 ligne_bis >> argument ;
1328 if ( argument[0] == '"' ) { decalage = 1 ; }
1329 else { decalage = 0 ; }
1330 size_t size = argument.size() + 1 - 2*decalage ;
1332 if ( mot_cle == "CCNoMNP1" )
1334 MeshName = new char[ size ];
1335 strncpy( MeshName, argument.c_str()+decalage, size );
1336 MeshName[size-1] = '\0' ;
1338 else if ( mot_cle == "CCMaiNP1" )
1340 MeshFile = new char[ size ];
1341 strncpy( MeshFile, argument.c_str()+decalage, size );
1342 MeshFile[size-1] = '\0' ;
1346 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1347 MESSAGE ( "==> MeshName : " << MeshName ) ;
1348 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1349 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1350 MESSAGE ( "==> Pyram : " << Pyram ) ;
1354 SALOME::ExceptionStruct es;
1355 es.type = SALOME::BAD_PARAM;
1356 std::string text = "The configuration file cannot be read." ;
1357 es.text = CORBA::string_dup(text.c_str());
1358 throw SALOME::SALOME_Exception(es);
1361 // C. Creation effective du cas
1364 if ( _PublisMeshIN != 0 ) option = 2 ;
1365 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, option) ;
1367 // D. Parametrages lus dans le fichier de configuration
1369 myCase->SetConfType (TypeConf) ;
1370 myCase->SetPyram (Pyram) ;
1372 // E. Copie du fichier de maillage homard
1373 // E.1. Repertoire associe au cas
1374 char* nomDirCase = myCase->GetDirName() ;
1375 // E.2. Repertoire associe a l'iteration de ce cas
1377 IterName = myCase->GetIter0Name() ;
1378 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1379 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1380 Iter->SetDirNameLoc(nomDirIter);
1381 std::string nomDirIterTotal ;
1382 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1384 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1386 if (_mkdir(nomDirIterTotal.c_str()) != 0)
1389 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1390 SALOME::ExceptionStruct es;
1391 es.type = SALOME::BAD_PARAM;
1392 std::string text = "The directory for the computation cannot be created." ;
1393 es.text = CORBA::string_dup(text.c_str());
1394 throw SALOME::SALOME_Exception(es);
1396 // E.3. Copie du maillage HOMARD au format MED
1398 codret = chdir(DirNameStart) ;
1400 codret = _chdir(DirNameStart) ;
1402 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1403 MESSAGE ( "commande : " << commande ) ;
1404 codret = system(commande.c_str()) ;
1405 MESSAGE ( "codret : " << codret ) ;
1408 SALOME::ExceptionStruct es;
1409 es.type = SALOME::BAD_PARAM;
1410 es.text = "The starting point for the case cannot be copied into the working directory.";
1411 throw SALOME::SALOME_Exception(es);
1421 chdir(nomDirWork.c_str());
1423 _chdir(nomDirWork.c_str());
1425 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1427 //=============================================================================
1428 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1430 // nomCas : nom du cas a creer
1431 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1434 INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1436 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1438 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1439 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1441 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1443 //=============================================================================
1444 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1446 // nomCas : nom du cas a creer
1447 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1448 // Number : numero de l'iteration de depart
1451 INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1454 SALOME::ExceptionStruct es;
1455 es.type = SALOME::BAD_PARAM;
1456 es.text = "The number of iteration must be positive.";
1457 throw SALOME::SALOME_Exception(es);
1461 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1463 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1464 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1466 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1468 //=============================================================================
1469 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1471 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1472 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1473 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1476 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1477 std::string nomDirWork = getenv("PWD") ;
1478 std::string DirNameStartIter ;
1480 int NumeIterMax = -1 ;
1482 // A.1. Controle du repertoire de depart du cas
1484 codret = chdir(DirNameStart) ;
1486 codret = _chdir(DirNameStart) ;
1490 SALOME::ExceptionStruct es;
1491 es.type = SALOME::BAD_PARAM;
1492 es.text = "The directory of the case for the pursuit does not exist.";
1493 throw SALOME::SALOME_Exception(es);
1496 // A.2. Reperage des sous-repertoire du repertoire de reprise
1497 bool existe = false ;
1500 struct dirent *dirp;
1501 dp = opendir(DirNameStart);
1502 while ( (dirp = readdir(dp)) != NULL ) {
1503 std::string DirName_1(dirp->d_name);
1505 HANDLE hFind = INVALID_HANDLE_VALUE;
1506 WIN32_FIND_DATA ffd;
1507 hFind = FindFirstFile(DirNameStart, &ffd);
1508 if (INVALID_HANDLE_VALUE != hFind) {
1509 while (FindNextFile(hFind, &ffd) != 0) {
1510 std::string DirName_1 = "";
1511 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1512 DirName_1 = std::string(ffd.cFileName);
1515 if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) )
1518 if ( chdir(DirName_1.c_str()) == 0 )
1520 // On cherche le fichier de configuration dans ce sous-repertoire
1521 codret = chdir(DirNameStart);
1523 struct dirent *dirp_1;
1524 dp_1 = opendir(DirName_1.c_str()) ;
1525 while ( (dirp_1 = readdir(dp_1)) != NULL )
1527 std::string file_name_1(dirp_1->d_name);
1529 if ( _chdir(DirName_1.c_str()) == 0 )
1531 codret = _chdir(DirNameStart);
1532 HANDLE hFind1 = INVALID_HANDLE_VALUE;
1533 WIN32_FIND_DATA ffd1;
1534 hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1);
1535 while (FindNextFile(hFind1, &ffd1) != 0)
1537 if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1538 std::string file_name_1(ffd1.cFileName);
1540 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1541 if ( bilan != string::npos )
1543 // Decodage du fichier pour trouver le numero d'iteration
1545 chdir(DirName_1.c_str()) ;
1547 _chdir(DirName_1.c_str()) ;
1550 std::ifstream fichier( file_name_1.c_str() );
1551 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1554 std::string ligne; // variable contenant chaque ligne lue
1555 std::string mot_cle;
1556 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1557 while ( std::getline( fichier, ligne ) )
1559 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1560 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1561 ligne_bis >> mot_cle ;
1562 if ( mot_cle == "NumeIter" )
1564 ligne_bis >> NumeIter ;
1566 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1567 if ( Number == - 1 )
1569 if ( NumeIter >= NumeIterMax )
1571 NumeIterMax = NumeIter ;
1572 DirNameStartIter = DirName_1 ;
1577 if ( NumeIter == Number )
1579 DirNameStartIter = DirName_1 ;
1589 SALOME::ExceptionStruct es;
1590 es.type = SALOME::BAD_PARAM;
1591 std::string text = "The configuration file cannot be read." ;
1592 es.text = CORBA::string_dup(text.c_str());
1593 throw SALOME::SALOME_Exception(es);
1596 chdir(DirNameStart) ;
1598 _chdir(DirNameStart) ;
1601 if ( existe ) { break ; }
1608 if ( existe ) { break ; }
1614 chdir(nomDirWork.c_str());
1618 _chdir(nomDirWork.c_str());
1621 if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) )
1623 SALOME::ExceptionStruct es;
1624 es.type = SALOME::BAD_PARAM;
1625 es.text = "The directory of the iteration does not exist.";
1626 throw SALOME::SALOME_Exception(es);
1630 return DirNameStartIter ;
1632 //=============================================================================
1633 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* MeshName, const char* MeshFile, CORBA::Long MeshOption, CORBA::Long NumeIter, CORBA::Long Option)
1635 // nomCas : nom du cas a creer
1636 // MeshName, MeshFile : nom et fichier du maillage correspondant
1637 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1638 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1639 // -1 : le maillage n'est pas fourni
1640 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1641 // Option : multiple de nombres premiers
1642 // 1 : aucune option
1643 // x2 : publication du maillage dans SMESH
1645 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1646 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1647 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1653 // A.2. Controle du nom :
1654 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1656 SALOME::ExceptionStruct es;
1657 es.type = SALOME::BAD_PARAM;
1658 es.text = "This case has already been defined.";
1659 throw SALOME::SALOME_Exception(es);
1663 // A.3. Controle du fichier du maillage
1664 int existeMeshFile ;
1665 if ( MeshOption >= 0 )
1667 existeMeshFile = MEDFileExist ( MeshFile ) ;
1668 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1669 if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) )
1671 SALOME::ExceptionStruct es;
1672 es.type = SALOME::BAD_PARAM;
1673 es.text = "The mesh file does not exist.";
1674 throw SALOME::SALOME_Exception(es);
1678 else { existeMeshFile = 0 ; }
1680 // B. Creation de l'objet cas et publication
1681 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1682 HOMARD::HOMARD_Cas_var myCase = newCase();
1683 myCase->SetName(nomCas);
1684 SALOMEDS::SObject_var aSO;
1685 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1686 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1688 // C. Caracteristiques du maillage
1689 if ( existeMeshFile != 0 )
1691 // Les valeurs extremes des coordonnees
1692 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1693 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1694 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1695 if (LesExtremes.size()!=10) { return false; }
1697 for (int i =0 ; i< LesExtremes.size() ; i++)
1698 aSeq[i]=LesExtremes[i] ;
1699 myCase->SetBoundingBox(aSeq) ;
1701 // MESSAGE ( "CreateCase0 : Les groupes" );
1702 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1703 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1704 aSeqGroupe->length(LesGroupes.size());
1705 std::set<std::string>::const_iterator it ;
1707 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1708 aSeqGroupe[i++]=(*it).c_str() ;
1709 myCase->SetGroups(aSeqGroupe) ;
1712 // D. L'iteration initiale du cas
1713 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1714 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1715 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1717 std::string NomIteration = std::string(MeshName) ;
1718 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1720 std::ostringstream nom;
1721 nom << MeshName << monNum;
1722 NomIteration = nom.str();
1725 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1727 // D.2. Creation de l'iteration
1728 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1729 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1730 anIter->SetName(NomIteration.c_str());
1731 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1733 // D.4. Maillage correspondant
1734 if ( existeMeshFile != 0 )
1736 anIter->SetMeshFile(MeshFile);
1737 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1739 anIter->SetMeshName(MeshName);
1741 // D.5. Numero d'iteration
1742 anIter->SetNumber(NumeIter);
1745 SetEtatIter(NomIteration.c_str(), -NumeIter);
1748 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1750 //=============================================================================
1751 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1753 INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1756 // A. Controle du nom :
1757 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1759 SALOME::ExceptionStruct es;
1760 es.type = SALOME::BAD_PARAM;
1761 es.text = "This hypothesis has already been defined.";
1762 throw SALOME::SALOME_Exception(es);
1766 // B. Creation de l'objet
1767 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1768 if (CORBA::is_nil(myHypothesis))
1770 SALOME::ExceptionStruct es;
1771 es.type = SALOME::BAD_PARAM;
1772 es.text = "Unable to create the hypothesis";
1773 throw SALOME::SALOME_Exception(es);
1776 myHypothesis->SetName(nomHypothesis);
1778 // C. Enregistrement
1779 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1781 SALOMEDS::SObject_var aSO;
1782 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1784 // D. Valeurs par defaut des options avancees
1785 myHypothesis->SetNivMax(-1);
1786 myHypothesis->SetDiamMin(-1.0);
1787 myHypothesis->SetAdapInit(0);
1788 myHypothesis->SetLevelOutput(0);
1790 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1793 //=============================================================================
1794 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1795 //=============================================================================
1797 INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1800 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1801 if (CORBA::is_nil(myIterationParent))
1803 SALOME::ExceptionStruct es;
1804 es.type = SALOME::BAD_PARAM;
1805 es.text = "The parent iteration is not defined.";
1806 throw SALOME::SALOME_Exception(es);
1810 const char* nomCas = myIterationParent->GetCaseName();
1811 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1812 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1813 if (CORBA::is_nil(myCase))
1815 SALOME::ExceptionStruct es;
1816 es.type = SALOME::BAD_PARAM;
1817 es.text = "Invalid case context";
1818 throw SALOME::SALOME_Exception(es);
1821 const char* nomDirCase = myCase->GetDirName();
1823 // Controle du nom :
1824 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1826 SALOME::ExceptionStruct es;
1827 es.type = SALOME::BAD_PARAM;
1828 es.text = "This iteration has already been defined.";
1829 throw SALOME::SALOME_Exception(es);
1833 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1834 if (CORBA::is_nil(myIteration))
1836 SALOME::ExceptionStruct es;
1837 es.type = SALOME::BAD_PARAM;
1838 es.text = "Unable to create the iteration";
1839 throw SALOME::SALOME_Exception(es);
1842 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1843 // Nom de l'iteration et du maillage
1844 myIteration->SetName(NomIteration);
1845 myIteration->SetMeshName(NomIteration);
1846 myIteration->SetState(1);
1848 int numero = myIterationParent->GetNumber() + 1;
1849 myIteration->SetNumber(numero);
1851 // Nombre d'iterations deja connues pour le cas, permettant
1852 // la creation d'un sous-repertoire unique
1853 int nbitercase = myCase->GetNumberofIter();
1854 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1855 myIteration->SetDirNameLoc(nomDirIter);
1857 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1858 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1859 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1860 // situation la plus frequente.
1861 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1862 // le nombre d'iterations du cas permet d'eviter les collisions.
1864 if ( nbitercase < 100 ) { jaux = 2 ; }
1865 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1866 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1867 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1869 std::ostringstream iaux ;
1870 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1871 std::stringstream MeshFile;
1872 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1873 myIteration->SetMeshFile(MeshFile.str().c_str());
1875 // Association avec le cas
1876 std::string label = "IterationHomard_" + std::string(nomIterParent);
1877 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1878 // Lien avec l'iteration precedente
1879 myIterationParent->LinkNextIteration(NomIteration);
1880 myIteration->SetIterParentName(nomIterParent);
1881 // Gestion de l'arbre d'etudes
1882 SALOMEDS::SObject_var aIterSOParent = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIterationParent)));
1883 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
1884 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
1885 aStudyBuilder->NewCommand();
1886 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
1887 aStudyBuilder->Addreference(aSubSO, aIterSOParent);
1888 aStudyBuilder->CommitCommand();
1890 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1892 //=============================================================================
1893 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1895 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1898 // Controle du nom :
1899 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1901 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1902 SALOME::ExceptionStruct es;
1903 es.type = SALOME::BAD_PARAM;
1904 es.text = "This boundary has already been defined";
1905 throw SALOME::SALOME_Exception(es);
1909 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1910 myBoundary->SetName(BoundaryName);
1911 myBoundary->SetType(BoundaryType);
1913 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1915 SALOMEDS::SObject_var aSO;
1916 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1918 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1920 //=============================================================================
1921 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1923 INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1924 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1925 myBoundary->SetMeshFile( MeshFile ) ;
1926 myBoundary->SetMeshName( MeshName ) ;
1928 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1930 //=============================================================================
1931 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1932 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1933 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1934 CORBA::Double Rayon)
1936 INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1938 SALOME::ExceptionStruct es;
1941 { es.text = "The radius must be positive." ;
1943 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1944 if ( daux < 0.0000001 )
1945 { es.text = "The axis must be a non 0 vector." ;
1949 es.type = SALOME::BAD_PARAM;
1950 throw SALOME::SALOME_Exception(es);
1954 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1955 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1957 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1959 //=============================================================================
1960 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1961 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1962 CORBA::Double Rayon)
1964 INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1966 SALOME::ExceptionStruct es;
1969 { es.text = "The radius must be positive." ;
1973 es.type = SALOME::BAD_PARAM;
1974 throw SALOME::SALOME_Exception(es);
1978 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1979 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1981 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1983 //=============================================================================
1984 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1985 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1986 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1988 INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1990 SALOME::ExceptionStruct es;
1992 if ( Angle <= 0.0 || Angle >= 90.0 )
1993 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1995 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1996 if ( daux < 0.0000001 )
1997 { es.text = "The axis must be a non 0 vector." ;
2001 es.type = SALOME::BAD_PARAM;
2002 throw SALOME::SALOME_Exception(es);
2006 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
2007 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
2009 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2011 //=============================================================================
2012 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
2013 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
2014 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
2016 INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
2018 SALOME::ExceptionStruct es;
2020 if ( Rayon1 < 0.0 || Rayon2 < 0.0 )
2021 { es.text = "The radius must be positive." ;
2023 double daux = fabs(Rayon2-Rayon1) ;
2024 if ( daux < 0.0000001 )
2025 { es.text = "The radius must be different." ;
2027 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
2028 if ( daux < 0.0000001 )
2029 { es.text = "The centers must be different." ;
2033 es.type = SALOME::BAD_PARAM;
2034 throw SALOME::SALOME_Exception(es);
2038 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
2039 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
2041 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2043 //=============================================================================
2044 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
2046 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
2049 // Controle du nom :
2050 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
2052 SALOME::ExceptionStruct es;
2053 es.type = SALOME::BAD_PARAM;
2054 es.text = "This zone has already been defined";
2055 throw SALOME::SALOME_Exception(es);
2059 HOMARD::HOMARD_Zone_var myZone = newZone();
2060 myZone->SetName(ZoneName);
2061 myZone->SetType(ZoneType);
2063 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
2065 SALOMEDS::SObject_var aSO;
2066 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
2068 return HOMARD::HOMARD_Zone::_duplicate(myZone);
2070 //=============================================================================
2071 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
2072 CORBA::Double Xmini, CORBA::Double Xmaxi,
2073 CORBA::Double Ymini, CORBA::Double Ymaxi,
2074 CORBA::Double Zmini, CORBA::Double Zmaxi)
2076 INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ;
2078 SALOME::ExceptionStruct es;
2080 if ( Xmini > Xmaxi )
2081 { es.text = "The X coordinates are not coherent." ;
2083 if ( Ymini > Ymaxi )
2084 { es.text = "The Y coordinates are not coherent." ;
2086 if ( Zmini > Zmaxi )
2087 { es.text = "The Z coordinates are not coherent." ;
2091 es.type = SALOME::BAD_PARAM;
2092 throw SALOME::SALOME_Exception(es);
2096 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
2097 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2099 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2101 //=============================================================================
2102 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
2103 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
2105 INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
2107 SALOME::ExceptionStruct es;
2110 { es.text = "The radius must be positive." ;
2114 es.type = SALOME::BAD_PARAM;
2115 throw SALOME::SALOME_Exception(es);
2119 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
2120 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
2122 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2124 //=============================================================================
2125 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
2126 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2127 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2128 CORBA::Double Rayon, CORBA::Double Haut)
2130 INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
2132 SALOME::ExceptionStruct es;
2135 { es.text = "The radius must be positive." ;
2137 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2138 if ( daux < 0.0000001 )
2139 { es.text = "The axis must be a non 0 vector." ;
2142 { es.text = "The height must be positive." ;
2146 es.type = SALOME::BAD_PARAM;
2147 throw SALOME::SALOME_Exception(es);
2151 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
2152 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
2154 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2156 //=============================================================================
2157 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
2158 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2159 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2160 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
2162 INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ;
2164 SALOME::ExceptionStruct es;
2166 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2167 { es.text = "The radius must be positive." ;
2169 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2170 if ( daux < 0.0000001 )
2171 { es.text = "The axis must be a non 0 vector." ;
2174 { es.text = "The height must be positive." ;
2176 if ( Rayon <= Rayonint )
2177 { es.text = "The external radius must be higher than the internal radius." ;
2181 es.type = SALOME::BAD_PARAM;
2182 throw SALOME::SALOME_Exception(es);
2186 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
2187 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
2189 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2191 //=============================================================================
2192 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
2193 CORBA::Double Umini, CORBA::Double Umaxi,
2194 CORBA::Double Vmini, CORBA::Double Vmaxi,
2197 INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
2198 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
2199 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
2200 // MESSAGE ("Orient = " << Orient ) ;
2202 SALOME::ExceptionStruct es;
2204 if ( Umini > Umaxi )
2205 { es.text = "The first coordinates are not coherent." ;
2207 if ( Vmini > Vmaxi )
2208 { es.text = "The second coordinates are not coherent." ;
2210 if ( Orient < 1 || Orient > 3 )
2211 { es.text = "The orientation must be 1, 2 or 3." ;
2215 es.type = SALOME::BAD_PARAM;
2216 throw SALOME::SALOME_Exception(es);
2220 double Xmini, Xmaxi ;
2221 double Ymini, Ymaxi ;
2222 double Zmini, Zmaxi ;
2230 else if ( Orient == 2 )
2237 else if ( Orient == 3 )
2244 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2246 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2247 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2249 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2251 //=============================================================================
2252 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2253 CORBA::Double Ucentre, CORBA::Double Vcentre,
2254 CORBA::Double Rayon,
2257 INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2259 SALOME::ExceptionStruct es;
2262 { es.text = "The radius must be positive." ;
2264 if ( Orient < 1 || Orient > 3 )
2265 { es.text = "The orientation must be 1, 2 or 3." ;
2269 es.type = SALOME::BAD_PARAM;
2270 throw SALOME::SALOME_Exception(es);
2278 { Xcentre = Ucentre ;
2281 else if ( Orient == 2 )
2284 Zcentre = Vcentre ; }
2285 else if ( Orient == 3 )
2286 { Xcentre = Vcentre ;
2288 Zcentre = Ucentre ; }
2289 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2291 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2292 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2294 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2296 //=============================================================================
2297 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2298 CORBA::Double Ucentre, CORBA::Double Vcentre,
2299 CORBA::Double Rayon, CORBA::Double Rayonint,
2302 INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2304 SALOME::ExceptionStruct es;
2306 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2307 { es.text = "The radius must be positive." ;
2309 if ( Orient < 1 || Orient > 3 )
2310 { es.text = "The orientation must be 1, 2 or 3." ;
2312 if ( Rayon <= Rayonint )
2313 { es.text = "The external radius must be higher than the internal radius." ;
2317 es.type = SALOME::BAD_PARAM;
2318 throw SALOME::SALOME_Exception(es);
2326 { Xcentre = Ucentre ;
2329 else if ( Orient == 2 )
2332 Zcentre = Vcentre ; }
2333 else if ( Orient == 3 )
2334 { Xcentre = Vcentre ;
2336 Zcentre = Ucentre ; }
2337 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2339 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2340 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2342 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2344 //=============================================================================
2345 //=============================================================================
2350 //=============================================================================
2351 //=============================================================================
2352 // Traitement d'une iteration
2353 // etatMenage = 1 : destruction du repertoire d'execution
2354 // modeHOMARD = 1 : adaptation
2355 // != 1 : information avec les options modeHOMARD
2356 // Option1 >0 : appel depuis python
2357 // <0 : appel depuis GUI
2358 // Option2 : multiple de nombres premiers
2359 // 1 : aucune option
2360 // x2 : publication du maillage dans SMESH
2361 //=============================================================================
2362 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2364 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2369 // A.1. L'objet iteration
2370 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2371 ASSERT(!CORBA::is_nil(myIteration));
2373 // A.2. Controle de la possibilite d'agir
2374 // A.2.1. Etat de l'iteration
2375 int etat = myIteration->GetState();
2376 MESSAGE ( "etat = "<<etat );
2377 // A.2.2. On ne calcule pas l'iteration initiale, ni une iteration deja calculee
2378 if ( modeHOMARD == 1 )
2382 SALOME::ExceptionStruct es;
2383 es.type = SALOME::BAD_PARAM;
2384 es.text = "This iteration is the first of the case and cannot be computed.";
2385 throw SALOME::SALOME_Exception(es);
2388 else if ( ( etat == 2 ) & ( modeHOMARD == 1 ) )
2390 SALOME::ExceptionStruct es;
2391 es.type = SALOME::BAD_PARAM;
2392 es.text = "This iteration is already computed.";
2393 throw SALOME::SALOME_Exception(es);
2397 // A.2.3. On n'analyse pas une iteration non calculee
2402 SALOME::ExceptionStruct es;
2403 es.type = SALOME::BAD_PARAM;
2404 es.text = "This iteration is not computed.";
2405 throw SALOME::SALOME_Exception(es);
2410 // A.3. Numero de l'iteration
2411 // siterp1 : numero de l'iteration a traiter
2413 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2414 // Ou si information :
2416 int NumeIter = myIteration->GetNumber();
2417 std::string siterp1 ;
2418 std::stringstream saux1 ;
2420 siterp1 = saux1.str() ;
2421 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2424 if ( modeHOMARD==1 )
2426 std::stringstream saux0 ;
2427 int iaux = max(0, NumeIter-1) ;
2429 siter = saux0.str() ;
2430 if (NumeIter < 11) { siter = "0" + siter ; }
2433 { siter = siterp1 ; }
2436 const char* nomCas = myIteration->GetCaseName();
2437 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2438 ASSERT(!CORBA::is_nil(myCase));
2440 // B. Les repertoires
2441 // B.1. Le repertoire courant
2442 std::string nomDirWork = getenv("PWD") ;
2443 // B.2. Le sous-repertoire de l'iteration a traiter
2444 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2445 MESSAGE( ". DirCompute = " << DirCompute );
2447 // C. Le fichier des messages
2448 // C.1. Le deroulement de l'execution de HOMARD
2449 std::string LogFile = DirCompute ;
2450 LogFile += "/Liste" ;
2451 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2453 MESSAGE (". LogFile = " << LogFile);
2454 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2455 // C.2. Le bilan de l'analyse du maillage
2456 std::string FileInfo = DirCompute ;
2458 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2460 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2461 else { FileInfo += "info_ap" ; }
2463 FileInfo += "." + siterp1 + ".bilan" ;
2464 myIteration->SetFileInfo(FileInfo.c_str());
2466 // D. On passe dans le repertoire de l'iteration a calculer
2467 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2474 // E. Les donnees de l'execution HOMARD
2475 // E.1. L'objet du texte du fichier de configuration
2476 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2477 myDriver->TexteInit(DirCompute, LogFile, _Langue);
2479 // E.2. Le maillage associe a l'iteration
2480 const char* NomMesh = myIteration->GetMeshName();
2481 MESSAGE ( ". NomMesh = " << NomMesh );
2482 const char* MeshFile = myIteration->GetMeshFile();
2483 MESSAGE ( ". MeshFile = " << MeshFile );
2485 // E.3. Les donnees du traitement HOMARD
2487 if ( modeHOMARD == 1 )
2490 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2491 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2492 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2496 InvalideIterInfo(NomIteration);
2497 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2499 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2500 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2501 myDriver->CreeFichierDonn();
2504 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2505 DriverTexteBoundary(myCase, myDriver) ;
2507 // E.5. Ecriture du texte dans le fichier
2508 MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<<codret );
2510 { myDriver->CreeFichier(); }
2514 int codretexec = 12 ;
2517 codretexec = myDriver->ExecuteHomard(Option1);
2519 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2520 // En mode adaptation, on ajuste l'etat de l'iteration
2521 if ( modeHOMARD == 1 )
2523 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2524 else { SetEtatIter(NomIteration,1); }
2525 // GERALD -- QMESSAGE BOX
2529 // H. Gestion des resultats
2532 std::string Commentaire ;
2533 // H.1. Le fichier des messages, dans tous les cas
2534 Commentaire = "log" ;
2535 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2536 else { Commentaire += "Info" ; }
2537 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2539 // H.2. Si tout s'est bien passe :
2540 if (codretexec == 0)
2542 // H.2.1. Le fichier de bilan
2543 Commentaire = "Summary" ;
2544 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2545 else { Commentaire += "Info" ; }
2546 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2547 // H.2.2. Le fichier de maillage obtenu
2548 if ( modeHOMARD == 1 )
2550 std::stringstream saux0 ;
2551 Commentaire = "Mesh" ;
2552 Commentaire += " " + siterp1 ;
2553 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2554 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2557 // H.3 Message d'erreur
2558 if (codretexec != 0)
2561 // Message d'erreur en cas de probleme en adaptation
2562 if ( modeHOMARD == 1 )
2564 text = "Error during the adaptation.\n" ;
2565 bool stopvu = false ;
2566 std::ifstream fichier( LogFile.c_str() );
2567 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
2569 std::string ligne; // variable contenant chaque ligne lue
2570 while ( std::getline( fichier, ligne ) )
2574 { text += ligne+ "\n"; }
2577 int position = ligne.find( "===== HOMARD ===== STOP =====" ) ;
2578 if ( position > 0 ) { stopvu = true ; }
2585 text = "Voir le fichier Liste.log.\n" ;
2588 SALOME::ExceptionStruct es;
2589 es.type = SALOME::BAD_PARAM;
2590 es.text = CORBA::string_dup(text.c_str());
2591 throw SALOME::SALOME_Exception(es);
2593 // En mode information, on force le succes pour pouvoir consulter le fichier log
2594 if ( modeHOMARD != 1 ) { codretexec = 0 ; }
2598 // I. Menage et retour dans le repertoire du cas
2602 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2605 chdir(nomDirWork.c_str());
2607 _chdir(nomDirWork.c_str());
2613 //=============================================================================
2614 // Calcul d'une iteration : partie specifique a l'adaptation
2615 //=============================================================================
2616 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)
2618 MESSAGE ( "ComputeAdap" );
2623 // Numero de l'iteration
2624 int NumeIter = myIteration->GetNumber();
2625 std::stringstream saux0 ;
2626 saux0 << NumeIter-1 ;
2627 std::string siter = saux0.str() ;
2628 if (NumeIter < 11) { siter = "0" + siter ; }
2630 // A.2. On verifie qu il y a une hypothese (erreur improbable);
2631 const char* nomHypo = myIteration->GetHypoName();
2632 if (std::string(nomHypo) == std::string(""))
2634 SALOME::ExceptionStruct es;
2635 es.type = SALOME::BAD_PARAM;
2636 es.text = "This iteration does not have any associated hypothesis.";
2637 throw SALOME::SALOME_Exception(es);
2640 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2641 ASSERT(!CORBA::is_nil(myHypo));
2643 // B. L'iteration parent
2644 const char* nomIterationParent = myIteration->GetIterParentName();
2645 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2646 ASSERT(!CORBA::is_nil(myIterationParent));
2647 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2648 if ( myIterationParent->GetState() == 1 )
2651 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2654 // GERALD -- QMESSAGE BOX
2655 VERIFICATION("Pb au calcul de l'iteration precedente" == 0);
2659 // C. Le sous-repertoire de l'iteration precedente
2660 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2661 MESSAGE( ". DirComputePa = " << DirComputePa );
2663 // D. Les donnees de l'adaptation HOMARD
2664 // D.1. Le type de conformite
2665 int ConfType = myCase->GetConfType();
2666 MESSAGE ( ". ConfType = " << ConfType );
2668 // D.2. Le maillage de depart
2669 const char* NomMeshParent = myIterationParent->GetMeshName();
2670 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2671 const char* MeshFileParent = myIterationParent->GetMeshFile();
2672 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2674 // D.3. Le maillage associe a l'iteration
2675 const char* MeshFile = myIteration->GetMeshFile();
2676 MESSAGE ( ". MeshFile = " << MeshFile );
2677 FILE *file = fopen(MeshFile,"r");
2681 if (etatMenage == 0)
2683 SALOME::ExceptionStruct es;
2684 es.type = SALOME::BAD_PARAM;
2685 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2686 es.text = CORBA::string_dup(text.c_str());
2687 throw SALOME::SALOME_Exception(es);
2692 std::string commande = "rm -f " + std::string(MeshFile);
2693 codret = system(commande.c_str());
2696 SALOME::ExceptionStruct es;
2697 es.type = SALOME::BAD_PARAM;
2698 es.text = "The mesh file cannot be deleted.";
2699 throw SALOME::SALOME_Exception(es);
2705 // D.4. Les types de raffinement et de deraffinement
2706 // Les appels corba sont lourds, il vaut mieux les grouper
2707 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2708 ASSERT(ListTypes->length() == 3);
2709 int TypeAdap = (*ListTypes)[0];
2710 int TypeRaff = (*ListTypes)[1];
2711 int TypeDera = (*ListTypes)[2];
2713 // E. Texte du fichier de configuration
2714 // E.1. Incontournables du texte
2715 myDriver->TexteAdap();
2717 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2718 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2719 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2721 // E.2. Ajout des informations liees aux zones eventuelles
2722 if ( TypeAdap == 0 )
2723 { DriverTexteZone(myHypo, myDriver) ; }
2725 // E.3. Ajout des informations liees aux champs eventuels
2726 if ( TypeAdap == 1 )
2727 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2729 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2730 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2731 int numberOfGroups = listeGroupes->length();
2732 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2733 if (numberOfGroups > 0)
2735 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2737 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2738 MESSAGE( "... GroupName = " << GroupName );
2739 myDriver->TexteGroup(GroupName);
2743 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2744 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2746 // E.6. Ajout des options avancees
2747 int Pyram = myCase->GetPyram();
2748 MESSAGE ( ". Pyram = " << Pyram );
2749 int NivMax = myHypo->GetNivMax();
2750 MESSAGE ( ". NivMax = " << NivMax );
2751 double DiamMin = myHypo->GetDiamMin() ;
2752 MESSAGE ( ". DiamMin = " << DiamMin );
2753 int AdapInit = myHypo->GetAdapInit();
2754 MESSAGE ( ". AdapInit = " << AdapInit );
2755 int LevelOutput = myHypo->GetLevelOutput();
2756 MESSAGE ( ". LevelOutput = " << LevelOutput );
2757 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2759 // E.7. Ajout des informations sur le deroulement de l'execution
2760 int MessInfo = myIteration->GetInfoCompute();
2761 MESSAGE ( ". MessInfo = " << MessInfo );
2762 myDriver->TexteInfoCompute(MessInfo);
2766 //=============================================================================
2767 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2768 // nomrep : nom du repertoire parent
2769 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2770 //=============================================================================
2771 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2773 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2774 // On verifie que le repertoire parent existe
2776 int codret = chdir(nomrep) ;
2778 int codret = _chdir(nomrep) ;
2782 SALOME::ExceptionStruct es;
2783 es.type = SALOME::BAD_PARAM;
2784 es.text = "The directory of the case does not exist.";
2785 throw SALOME::SALOME_Exception(es);
2788 std::string nomDirActuel = getenv("PWD") ;
2789 std::string DirName ;
2790 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2791 bool a_chercher = true ;
2792 while ( a_chercher )
2794 // On passe dans le repertoire parent
2801 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2803 if ( num < 100 ) { jaux = 2 ; }
2804 else if ( num < 1000 ) { jaux = 3 ; }
2805 else if ( num < 10000 ) { jaux = 4 ; }
2806 else if ( num < 100000 ) { jaux = 5 ; }
2808 std::ostringstream iaux ;
2809 iaux << std::setw(jaux) << std::setfill('0') << num ;
2810 std::ostringstream DirNameA ;
2811 DirNameA << "I" << iaux.str();
2812 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2813 // que c'est bien un probleme d'absence
2815 if ( chdir(DirNameA.str().c_str()) != 0 )
2818 if ( _chdir(DirNameA.str().c_str()) != 0 )
2821 bool existe = false ;
2824 struct dirent *dirp;
2825 dp = opendir(nomrep);
2826 while ( (dirp = readdir(dp)) != NULL )
2828 std::string file_name(dirp->d_name);
2830 HANDLE hFind = INVALID_HANDLE_VALUE;
2831 WIN32_FIND_DATA ffd;
2832 hFind = FindFirstFile(nomrep, &ffd);
2833 if (INVALID_HANDLE_VALUE != hFind) {
2834 while (FindNextFile(hFind, &ffd) != 0) {
2835 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2836 std::string file_name(ffd.cFileName);
2838 if ( file_name == DirNameA.str() ) { existe = true ; }
2848 DirName = DirNameA.str() ;
2849 a_chercher = false ;
2856 MESSAGE ( "==> DirName = " << DirName);
2857 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2859 chdir(nomDirActuel.c_str());
2861 _chdir(nomDirActuel.c_str());
2863 return CORBA::string_dup( DirName.c_str() );
2865 //=============================================================================
2866 // Calcul d'une iteration : gestion du repertoire de calcul
2867 // Si le sous-repertoire existe :
2868 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2869 // etatMenage = 1 : on fait le menage du repertoire
2870 // etatMenage = -1 : on ne fait rien
2871 //=============================================================================
2872 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2874 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2875 // B.2. Le repertoire du cas
2876 const char* nomDirCase = myCase->GetDirName();
2877 MESSAGE ( ". nomDirCase = " << nomDirCase );
2879 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2880 // B.3.1. Le nom du sous-repertoire
2881 const char* nomDirIt = myIteration->GetDirNameLoc();
2883 // B.3.2. Le nom complet du sous-repertoire
2884 std::stringstream DirCompute ;
2885 DirCompute << nomDirCase << "/" << nomDirIt;
2886 MESSAGE (". DirCompute = " << DirCompute.str() );
2888 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2890 if (chdir(DirCompute.str().c_str()) != 0)
2892 // Creation du repertoire car il n'existe pas :
2893 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2896 if (_chdir(DirCompute.str().c_str()) != 0)
2898 // Creation du repertoire car il n'existe pas :
2899 if (_mkdir(DirCompute.str().c_str()) != 0)
2902 // GERALD -- QMESSAGE BOX
2903 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2904 VERIFICATION("Pb a la creation du repertoire" == 0);
2909 // Le repertoire existe
2910 // On demande de faire le menage de son contenu :
2911 if (etatMenage == 1)
2913 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2914 std::string commande = "rm -rf " + DirCompute.str()+"/*" ;
2915 int codret = system(commande.c_str());
2918 // GERALD -- QMESSAGE BOX
2919 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2920 VERIFICATION("Pb au menage du repertoire de calcul" == 0);
2923 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2926 if (etatMenage == 0)
2930 struct dirent *dirp;
2931 dp = opendir(DirCompute.str().c_str());
2933 while ((dirp = readdir(dp)) != NULL && result )
2935 std::string file_name(dirp->d_name);
2936 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2940 HANDLE hFind = INVALID_HANDLE_VALUE;
2941 WIN32_FIND_DATA ffd;
2942 hFind = FindFirstFile(DirCompute.str().c_str(), &ffd);
2944 if (INVALID_HANDLE_VALUE != hFind) {
2945 while (FindNextFile(hFind, &ffd) != 0) {
2946 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2947 std::string file_name(ffd.cFileName);
2948 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2953 if ( result == false)
2955 SALOME::ExceptionStruct es;
2956 es.type = SALOME::BAD_PARAM;
2957 std::string text = "Directory : " + DirCompute.str() + " is not empty";
2958 es.text = CORBA::string_dup(text.c_str());
2959 throw SALOME::SALOME_Exception(es);
2960 VERIFICATION("Directory is not empty" == 0);
2966 return CORBA::string_dup( DirCompute.str().c_str() );
2968 //=============================================================================
2969 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2970 //=============================================================================
2971 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2973 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2974 // Le repertoire du cas
2975 const char* nomDirCase = myCase->GetDirName();
2976 MESSAGE ( ". nomDirCase = " << nomDirCase );
2978 // Le sous-repertoire de l'iteration precedente
2980 const char* nomIterationParent = myIteration->GetIterParentName();
2981 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2982 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
2983 std::stringstream DirComputePa ;
2984 DirComputePa << nomDirCase << "/" << nomDirItPa;
2985 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2986 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2988 return CORBA::string_dup( DirComputePa.str().c_str() );
2990 //=============================================================================
2991 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2992 //=============================================================================
2993 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2995 MESSAGE ( "... DriverTexteZone" );
2996 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2997 int numberOfZonesx2 = ListZone->length();
3000 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
3002 std::string ZoneName = std::string((*ListZone)[iaux]);
3003 MESSAGE ( "... ZoneName = " << ZoneName);
3004 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
3005 ASSERT(!CORBA::is_nil(myZone));
3007 int ZoneType = myZone->GetType();
3008 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
3009 int TypeUse = atoi( TypeUsestr.c_str() );
3010 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
3011 NumZone = iaux/2 + 1 ;
3012 HOMARD::double_array* zone = myZone->GetCoords();
3013 if ( ZoneType == 2 || ( ZoneType>=11 && ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
3014 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
3015 else if ( ZoneType == 4 ) // Cas d une sphere
3016 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
3017 else if ( ZoneType == 5 || ( ZoneType>=31 && ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
3018 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
3019 else if ( ZoneType == 7 || ( ZoneType>=61 && ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
3020 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
3021 else { VERIFICATION("ZoneType est incorrect." == 0) ; }
3026 //=============================================================================
3027 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
3028 //=============================================================================
3029 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3031 MESSAGE ( "... DriverTexteField" );
3032 // Le fichier du champ
3033 char* FieldFile = myIteration->GetFieldFile();
3034 MESSAGE ( ". FieldFile = " << FieldFile );
3035 if (strlen(FieldFile) == 0)
3037 // GERALD -- QMESSAGE BOX
3038 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
3039 VERIFICATION("The file for the field is not given." == 0);
3041 // Les caracteristiques d'instants du champ de pilotage
3042 int TimeStep = myIteration->GetTimeStep();
3043 MESSAGE( ". TimeStep = " << TimeStep );
3044 int Rank = myIteration->GetRank();
3045 MESSAGE( ". Rank = " << Rank );
3046 // Les informations sur les champs
3047 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
3049 const char* FieldName = aInfosHypo->FieldName;
3051 int TypeThR = aInfosHypo->TypeThR;
3052 double ThreshR = aInfosHypo->ThreshR;
3053 int TypeThC = aInfosHypo->TypeThC;
3054 double ThreshC = aInfosHypo->ThreshC;
3055 // Saut entre mailles ou non ?
3056 int UsField = aInfosHypo->UsField;
3057 MESSAGE( ". UsField = " << UsField );
3058 // L'usage des composantes
3059 int UsCmpI = aInfosHypo->UsCmpI;
3060 MESSAGE( ". UsCmpI = " << UsCmpI );
3062 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
3065 HOMARD::listeComposantsHypo* mescompo = myHypo->GetComps();
3066 int numberOfCompos = mescompo->length();
3067 MESSAGE( ". numberOfCompos = " << numberOfCompos );
3068 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
3070 std::string nomCompo = std::string((*mescompo)[NumeComp]);
3071 MESSAGE( "... nomCompo = " << nomCompo );
3072 myDriver->TexteCompo(NumeComp, nomCompo);
3076 //=============================================================================
3077 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
3078 // On ecrit dans l'ordre :
3079 // 1. la definition des frontieres
3080 // 2. les liens avec les groupes
3081 // 3. un entier resumant le type de comportement pour les frontieres
3082 //=============================================================================
3083 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
3085 MESSAGE ( "... DriverTexteBoundary" );
3086 // 1. Recuperation des frontieres
3087 std::list<std::string> ListeBoundaryTraitees ;
3088 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3089 int numberOfitems = ListBoundaryGroupType->length();
3090 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
3091 int BoundaryOption = 1 ;
3092 // 2. Parcours des frontieres pour ecrire leur description
3093 int NumBoundaryAnalytical = 0 ;
3094 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3096 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3097 MESSAGE ( "... BoundaryName = " << BoundaryName);
3098 // 2.1. La frontiere a-t-elle deja ete ecrite ?
3099 // Cela arrive quand elle estliéé a plusieurs groupes. Il ne faut l'ecrire que la premiere fois
3101 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3102 while (it != ListeBoundaryTraitees.end())
3104 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3105 if ( BoundaryName == *it ) { A_faire = 0 ; }
3108 // 2.2. Ecriture de la frontiere
3111 // 2.2.1. Caracteristiques de la frontiere
3112 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3113 ASSERT(!CORBA::is_nil(myBoundary));
3114 int BoundaryType = myBoundary->GetType();
3115 MESSAGE ( "... BoundaryType = " << BoundaryType );
3116 // 2.2.2. Ecriture selon le type
3117 // 2.2.2.1. Cas d une frontiere discrete
3118 if (BoundaryType == 0)
3120 const char* MeshName = myBoundary->GetMeshName() ;
3121 const char* MeshFile = myBoundary->GetMeshFile() ;
3122 myDriver->TexteBoundaryDi( MeshName, MeshFile);
3123 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; }
3125 // 2.2.2.1. Cas d une frontiere analytique
3128 NumBoundaryAnalytical++ ;
3129 HOMARD::double_array* coor = myBoundary->GetCoords();
3130 if (BoundaryType == 1) // Cas d un cylindre
3132 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3133 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3135 else if (BoundaryType == 2) // Cas d une sphere
3137 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
3138 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3140 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
3142 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3143 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3145 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
3147 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3148 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3151 // 2.2.3. Memorisation du traitement
3152 ListeBoundaryTraitees.push_back( BoundaryName );
3155 // 3. Parcours des frontieres pour ecrire les liens avec les groupes
3156 NumBoundaryAnalytical = 0 ;
3157 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3159 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3160 MESSAGE ( "... BoundaryName = " << BoundaryName);
3161 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3162 ASSERT(!CORBA::is_nil(myBoundary));
3163 int BoundaryType = myBoundary->GetType();
3164 MESSAGE ( "... BoundaryType = " << BoundaryType );
3165 // 3.1. Recuperation du nom du groupe
3166 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
3167 MESSAGE ( "... GroupName = " << GroupName);
3168 // 3.2. Cas d une frontiere discrete
3169 if ( BoundaryType == 0 )
3171 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
3173 // 3.3. Cas d une frontiere analytique
3176 NumBoundaryAnalytical++ ;
3177 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
3180 // 4. Ecriture de l'option finale
3181 myDriver->TexteBoundaryOption(BoundaryOption);
3185 //=============================================================================
3186 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
3187 //=============================================================================
3188 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3190 MESSAGE ( "... DriverTexteFieldInterp" );
3191 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
3192 MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp);
3193 if (TypeFieldInterp != 0)
3195 // Le fichier des champs
3196 char* FieldFile = myIteration->GetFieldFile();
3197 MESSAGE ( ". FieldFile = " << FieldFile );
3198 if (strlen(FieldFile) == 0)
3200 // GERALD -- QMESSAGE BOX
3201 VERIFICATION("The file for the field is not given." == 0);
3204 const char* MeshFile = myIteration->GetMeshFile();
3205 myDriver->TexteFieldInterp(FieldFile, MeshFile);
3208 // Interpolation de tous les champs
3209 if ( TypeFieldInterp == 1 )
3211 myDriver->TexteFieldInterpAll();
3213 // Interpolation de certains champs
3214 else if (TypeFieldInterp == 2)
3216 // Les champs et leurs instants pour l'iteration
3217 HOMARD::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank();
3218 int numberOfFieldsx3 = ListFieldTSR->length();
3219 MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 );
3220 // Les champs pour l'hypothese
3221 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
3222 int numberOfFieldsx2 = ListField->length();
3223 MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 );
3224 // On parcourt tous les champs de l'hypothese
3226 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
3229 std::string FieldName = std::string((*ListField)[iaux]) ;
3230 // Le type d'interpolation
3231 std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ;
3232 MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr );
3233 // On cherche à savoir si des instants ont été précisés pour cette itération
3235 for (int jaux = 0; jaux< numberOfFieldsx3; jaux++)
3238 std::string FieldName2 = std::string((*ListFieldTSR)[jaux]) ;
3239 MESSAGE( "..... FieldName2 = " << FieldName2 );
3240 // Quand c'est le bon champ, on ecrit le pas de temps
3241 if ( FieldName == FieldName2 )
3245 std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]) ;
3246 // Le numero d'ordre
3247 std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]) ;
3248 MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<<Rankstr );
3250 int TimeStep = atoi( TimeStepstr.c_str() );
3251 int Rank = atoi( Rankstr.c_str() );
3252 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank);
3256 // Si aucun instant n'a été défini
3260 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1);
3268 //===========================================================================
3269 //===========================================================================
3272 //===========================================================================
3273 //===========================================================================
3275 //===========================================================================
3276 //===========================================================================
3277 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
3278 SALOMEDS::SObject_ptr theSObject,
3279 CORBA::Object_ptr theObject,
3280 const char* theName)
3282 MESSAGE("PublishInStudy pour " << theName);
3283 SALOMEDS::SObject_var aResultSO;
3284 if (CORBA::is_nil(theStudy))
3286 SALOME::ExceptionStruct es;
3287 es.type = SALOME::BAD_PARAM;
3288 es.text = "Invalid study context";
3289 throw SALOME::SALOME_Exception(es);
3293 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
3294 // Rq : Iteration est publiee ailleurs
3295 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
3296 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
3297 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
3298 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject);
3299 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
3301 addInStudy(theStudy);
3303 // Controle de la non publication d'un objet de meme nom
3304 if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) )
3306 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
3307 if (listSO->length() >= 1)
3309 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
3310 aResultSO = listSO[0];
3311 return aResultSO._retn();
3315 // Caracteristiques de l'etude
3316 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
3317 aStudyBuilder->NewCommand();
3318 if(!aBoundary->_is_nil())
3319 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
3320 else if(!aCase->_is_nil())
3321 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
3322 else if(!aHypo->_is_nil())
3323 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
3324 else if(!aYACS->_is_nil())
3325 aResultSO = PublishYACSInStudy(theStudy, aStudyBuilder, aYACS, theName);
3326 else if(!aZone->_is_nil())
3327 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
3329 aStudyBuilder->CommitCommand();
3331 return aResultSO._retn();
3333 //=============================================================================
3334 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3335 SALOMEDS::StudyBuilder_var aStudyBuilder,
3336 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3338 MESSAGE("PublishBoundaryStudy pour "<<theName);
3339 SALOMEDS::SObject_var aResultSO;
3341 // Caracteristique de la Boundary
3342 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3344 // On recupere le module pere dans l etude
3345 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3346 if (theFatherHomard->_is_nil())
3348 MESSAGE("theFatherHomard->_is_nil()");
3349 return aResultSO._retn();
3352 // On ajoute la categorie des boundarys dans l etude si necessaire
3353 if ( _tag_boun == 0 )
3356 _tag_boun = _tag_gene ;
3358 MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun );
3359 SALOMEDS::SObject_var aSObject;
3360 if (!theFatherHomard->FindSubObject(_tag_boun, aSObject))
3362 MESSAGE("Ajout de la categorie des boundarys");
3363 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun);
3364 PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3366 else { MESSAGE("La categorie des boundarys existe deja."); }
3368 CORBA::Long BoundaryType = myBoundary->GetType();
3369 // MESSAGE("BoundaryType : "<<BoundaryType);
3372 switch (BoundaryType)
3375 { value = "BoundaryDiHomard" ;
3376 icone = "mesh_tree_mesh.png" ;
3380 { value = "BoundaryAnHomard" ;
3381 icone = "cylinderpointvector_2.png" ;
3385 { value = "BoundaryAnHomard" ;
3386 icone = "spherepoint_2.png" ;
3390 { value = "BoundaryAnHomard" ;
3391 icone = "conepointvector.png" ;
3395 { value = "BoundaryAnHomard" ;
3396 icone = "conedxyz.png" ;
3400 aResultSO = aStudyBuilder->NewObject(aSObject);
3401 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3402 return aResultSO._retn();
3404 //=============================================================================
3405 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
3406 SALOMEDS::StudyBuilder_var aStudyBuilder,
3407 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
3409 MESSAGE("PublishCaseInStudy pour "<<theName);
3410 SALOMEDS::SObject_var aResultSO;
3412 if (CORBA::is_nil(theObject)) {
3413 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
3414 return aResultSO._retn();
3416 if (theStudy->_is_nil()) {
3417 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
3418 return aResultSO._retn();
3421 // On recupere le module pere dans l etude
3422 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3423 if (theFatherHomard->_is_nil())
3425 MESSAGE("theFatherHomard->_is_nil()");
3426 return aResultSO._retn();
3430 MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene );
3431 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
3432 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
3433 _orb->object_to_string(theObject) ) ;
3435 return aResultSO._retn();
3437 //=============================================================================
3438 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3439 SALOMEDS::StudyBuilder_var aStudyBuilder,
3440 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3442 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3443 SALOMEDS::SObject_var aResultSO;
3445 // On recupere le module pere dans l etude
3446 // On ajoute la categorie des hypotheses dans l etude si necessaire
3447 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3448 if (theFatherHomard->_is_nil())
3450 MESSAGE("theFatherHomard->_is_nil()");
3451 return aResultSO._retn();
3454 // On ajoute la categorie des hypotheses dans l etude si necessaire
3455 SALOMEDS::SObject_var aSObject;
3456 if ( _tag_hypo == 0 )
3459 _tag_hypo = _tag_gene ;
3461 MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo );
3462 if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject))
3464 MESSAGE("Ajout de la categorie des hypotheses");
3465 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo);
3466 PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL);
3468 else { MESSAGE("La categorie des hypotheses existe deja."); }
3470 // Creation du resultat dans l'etude
3471 aResultSO = aStudyBuilder->NewObject(aSObject);
3472 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3474 return aResultSO._retn();
3476 //=============================================================================
3477 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theStudy,
3478 SALOMEDS::StudyBuilder_var aStudyBuilder,
3479 HOMARD::HOMARD_YACS_ptr theObject, const char* theName)
3481 MESSAGE("PublishYACSInStudy pour "<<theName);
3482 SALOMEDS::SObject_var aResultSO;
3484 // On recupere le module pere dans l etude
3485 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3486 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3487 if (theFatherHomard->_is_nil())
3489 MESSAGE("theFatherHomard->_is_nil()");
3490 return aResultSO._retn();
3492 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3493 if ( _tag_yacs == 0 )
3496 _tag_yacs = _tag_gene ;
3498 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs );
3499 SALOMEDS::SObject_var aSObject;
3500 if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject))
3502 MESSAGE("Ajout de la categorie des schemas YACS");
3503 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs);
3504 PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL);
3506 else { MESSAGE("La categorie des schemas YACS existe deja."); }
3508 // Creation du resultat dans l'etude
3509 aResultSO = aStudyBuilder->NewObject(aSObject);
3510 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ;
3512 return aResultSO._retn();
3515 //=============================================================================
3516 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
3517 SALOMEDS::StudyBuilder_var aStudyBuilder,
3518 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3520 MESSAGE("PublishZoneStudy pour "<<theName);
3521 SALOMEDS::SObject_var aResultSO;
3522 if (CORBA::is_nil(theObject))
3524 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3525 return aResultSO._retn();
3527 if (theStudy->_is_nil())
3529 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
3530 return aResultSO._retn();
3532 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3533 if (theFatherHomard->_is_nil())
3535 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3536 return aResultSO._retn();
3539 // Caracteristique de la zone
3540 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3541 CORBA::Long ZoneType = myZone->GetType();
3543 // On ajoute la categorie des zones dans l etude si necessaire
3544 if ( _tag_zone == 0 )
3547 _tag_zone = _tag_gene ;
3549 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone );
3550 SALOMEDS::SObject_var aSObject;
3551 if (!theFatherHomard->FindSubObject(_tag_zone, aSObject))
3553 MESSAGE("Ajout de la categorie des zones");
3554 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone);
3555 PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3557 else { MESSAGE("La categorie des zones existe deja."); }
3559 aResultSO = aStudyBuilder->NewObject(aSObject);
3568 { icone = "boxdxy_2.png" ;
3572 { icone = "boxdxyz_2.png" ;
3580 { icone = "disk_2.png" ;
3584 { icone = "spherepoint_2.png" ;
3588 { icone = "cylinderpointvector_2.png" ;
3596 { icone = "diskwithhole_2.png" ;
3600 { icone = "pipe_2.png" ;
3604 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3606 return aResultSO._retn();
3608 //===========================================================================
3609 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3610 SALOMEDS::SObject_var aResultSO,
3611 const char* name, const char* comment, const char* icone, const char* ior)
3613 MESSAGE("PublishInStudyAttr pour name = "<<name<<", comment = "<<comment);
3614 // MESSAGE("icone = "<<icone);
3615 // MESSAGE("ior = "<<ior);
3616 SALOMEDS::GenericAttribute_var anAttr ;
3620 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3621 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3622 aNameAttrib->SetValue(name);
3625 // Ajout du commentaire
3626 if ( comment != NULL )
3628 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3629 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3630 aCommentAttrib->SetValue(comment);
3634 if ( icone != NULL )
3636 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
3637 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3638 aPixmap->SetPixMap(icone);
3644 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3645 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3646 anIOR->SetValue(ior);
3650 //=====================================================================================
3651 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3653 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3655 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3656 ASSERT(!CORBA::is_nil(myCase));
3657 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3658 ASSERT(!CORBA::is_nil(aCaseSO));
3660 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3661 ASSERT(!CORBA::is_nil(myBoundary));
3662 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3663 ASSERT(!CORBA::is_nil(aBoundarySO));
3665 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3667 aStudyBuilder->NewCommand();
3669 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3670 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3671 // aStudyBuilder->RemoveReference(aSubSO);
3673 aStudyBuilder->CommitCommand();
3676 //=====================================================================================
3677 void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName)
3679 MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName );
3681 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3682 ASSERT(!CORBA::is_nil(myYACS));
3683 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3684 ASSERT(!CORBA::is_nil(aYACSSO));
3686 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3687 ASSERT(!CORBA::is_nil(myCase));
3688 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3689 ASSERT(!CORBA::is_nil(aCaseSO));
3691 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3693 aStudyBuilder->NewCommand();
3695 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3696 aStudyBuilder->Addreference(aSubSO, aCaseSO);
3698 aStudyBuilder->CommitCommand();
3701 //=============================================================================
3702 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3703 // Option = 0 : fichier issu d'une importation
3704 // Option = 1 : fichier issu d'une execution HOMARD
3706 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3707 if (CORBA::is_nil(myCurrentStudy))
3709 SALOME::ExceptionStruct es;
3710 es.type = SALOME::BAD_PARAM;
3711 es.text = "Invalid study context";
3712 throw SALOME::SALOME_Exception(es);
3716 // Le module SMESH est-il actif ?
3717 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3719 if (!CORBA::is_nil(aSmeshSO))
3721 // On verifie que le fichier n est pas deja publie
3722 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3723 for (; aIter->More(); aIter->Next())
3725 SALOMEDS::SObject_var aSO = aIter->Value();
3726 SALOMEDS::GenericAttribute_var aGAttr;
3727 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3729 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3730 CORBA::String_var value=anAttr->Value();
3731 if (strcmp((const char*)value,NomFich) == 0)
3733 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3734 // Pour un fichier importe, on ne republie pas
3735 if ( Option == 0 ) { return; }
3736 // Pour un fichier calcule, on commence par faire la depublication
3739 MESSAGE ( "PublishResultInSmesh : depublication" );
3740 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3741 CORBA::String_var value2=anAttr2->Value();
3742 std::string MeshName = string(value2) ;
3743 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3744 DeleteResultInSmesh(NomFich, MeshName) ;
3751 // On enregistre le fichier
3752 MESSAGE( "Enregistrement du fichier");
3753 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3754 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3755 ASSERT(!CORBA::is_nil(aSmeshEngine));
3756 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3757 SMESH::DriverMED_ReadStatus theStatus;
3758 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3760 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3761 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3762 for (int i = 0; i < mesMaillages->length(); i++)
3764 MESSAGE( ". Mise a jour des attributs du maillage");
3765 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3766 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3767 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3768 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3769 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3770 anAttr->SetValue(NomFich);
3771 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3772 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3774 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3775 else { icone = "mesh_tree_mesh.png" ; }
3776 anAttr2->SetPixMap( icone );
3780 //=============================================================================
3781 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
3783 MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3784 if (CORBA::is_nil(myCurrentStudy))
3786 SALOME::ExceptionStruct es;
3787 es.type = SALOME::BAD_PARAM;
3788 es.text = "Invalid study context";
3789 throw SALOME::SALOME_Exception(es);
3793 // Le module SMESH est-il actif ?
3794 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3796 if (CORBA::is_nil(aSmeshSO))
3800 // On verifie que le fichier est deja publie
3801 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3802 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3803 for (; aIter->More(); aIter->Next())
3805 SALOMEDS::SObject_var aSO = aIter->Value();
3806 SALOMEDS::GenericAttribute_var aGAttr;
3807 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3809 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3810 CORBA::String_var value=anAttr->Value();
3811 if (strcmp((const char*)value,NomFich.c_str()) == 0)
3813 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3815 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3816 CORBA::String_var value2=anAttr2->Value();
3817 if (strcmp((const char*)value2,MeshName.c_str()) == 0)
3819 myBuilder->RemoveObjectWithChildren( aSO ) ;
3827 //=============================================================================
3828 void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter)
3830 MESSAGE( "PublishMeshIterInSmesh " << NomIter);
3831 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3833 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3834 if (CORBA::is_nil(myIteration))
3836 SALOME::ExceptionStruct es;
3837 es.type = SALOME::BAD_PARAM;
3838 es.text = "Invalid iterationStudy Object";
3839 throw SALOME::SALOME_Exception(es);
3842 const char* MeshFile = myIteration->GetMeshFile() ;
3843 const char* MeshName = myIteration->GetMeshName() ;
3844 CORBA::Long Option = -1 ;
3845 int etat = myIteration->GetState();
3846 // Iteration initiale
3847 if ( etat <= 0 ) { Option = 0 ; }
3848 // ou iteration calculee
3849 else if ( etat == 2 ) { Option = 1 ; }
3850 // Publication effective apres menage eventuel
3853 DeleteResultInSmesh(MeshFile, MeshName) ;
3854 PublishResultInSmesh(MeshFile, Option) ;
3858 //=============================================================================
3859 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3861 // MESSAGE ("PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3862 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3864 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3865 if (CORBA::is_nil(myIteration))
3867 SALOME::ExceptionStruct es;
3868 es.type = SALOME::BAD_PARAM;
3869 es.text = "Invalid iterationStudy Object";
3870 throw SALOME::SALOME_Exception(es);
3874 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3876 aStudyBuilder->NewCommand();
3878 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3879 // Pour les fichiers med, on affiche une icone de maillage
3880 // Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte'
3881 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3883 std::string ior = " " ;
3884 if ( Commentaire[0] == 'I' )
3885 { icone = "med.png" ; }
3887 { icone = "texte_2.png" ; }
3888 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3890 aStudyBuilder->CommitCommand();
3893 //=============================================================================
3894 void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire)
3896 // MESSAGE ("PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3897 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3899 SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3900 if (CORBA::is_nil(myYACS))
3902 SALOME::ExceptionStruct es;
3903 es.type = SALOME::BAD_PARAM;
3904 es.text = "Invalid YACSStudy Object";
3905 throw SALOME::SALOME_Exception(es);
3909 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3911 aStudyBuilder->NewCommand();
3913 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3914 std::string icone = "texte_2.png" ;
3915 std::string ior = " " ;
3916 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3918 aStudyBuilder->CommitCommand();
3921 //=============================================================================
3922 //=============================================================================
3924 //=============================================================================
3925 //=============================================================================
3926 //=============================================================================
3927 // Creation d'un schema YACS
3928 // nomCas : nom du cas a traiter
3929 // FileName : nom du fichier contenant le script de lancement du calcul
3930 // DirName : le repertoire de lancement des calculs du schéma
3931 //=============================================================================
3932 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
3934 INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS );
3935 INFOS ( ". nomCas : " << nomCas);
3936 INFOS ( ". ScriptFile : " << ScriptFile);
3937 INFOS ( ". DirName : " << DirName);
3938 INFOS ( ". MeshFile : " << MeshFile);
3940 // A. Controle du nom :
3941 if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(nomYACS) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end())
3943 SALOME::ExceptionStruct es;
3944 es.type = SALOME::BAD_PARAM;
3945 es.text = "This schema YACS has already been defined.";
3946 throw SALOME::SALOME_Exception(es);
3950 // B. Creation de l'objet
3951 HOMARD::HOMARD_YACS_var myYACS = newYACS();
3952 if (CORBA::is_nil(myYACS))
3954 SALOME::ExceptionStruct es;
3955 es.type = SALOME::BAD_PARAM;
3956 es.text = "Unable to create the schema YACS";
3957 throw SALOME::SALOME_Exception(es);
3960 myYACS->SetName( nomYACS ) ;
3962 // C. Enregistrement
3963 myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS] = myYACS;
3965 SALOMEDS::SObject_var aSO;
3966 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, nomYACS);
3968 PublishCaseUnderYACS(nomYACS, nomCas);
3970 // D. Caracterisation
3972 myYACS->SetDirName( DirName ) ;
3973 myYACS->SetMeshFile( MeshFile ) ;
3974 myYACS->SetScriptFile( ScriptFile ) ;
3975 myYACS->SetCaseName( nomCas ) ;
3977 // D.2.1. Type constant
3978 myYACS->SetType( 1 ) ;
3979 // D.2.2. Fichier de sauvegarde dans le repertoire du cas
3980 HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ;
3981 std::string dirnamecase = caseyacs->GetDirName() ;
3982 std::string XMLFile ;
3983 XMLFile = dirnamecase + "/schema.xml" ;
3984 myYACS->SetXMLFile( XMLFile.c_str() ) ;
3986 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
3988 //=============================================================================
3989 // Ecriture d'un schema YACS
3990 //=============================================================================
3991 CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS)
3993 INFOS ( "YACSWrite : Ecriture de " << nomYACS );
3994 // Le repertoire du cas
3995 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3996 ASSERT(!CORBA::is_nil(myYACS));
3997 // Le nom du fichier du schema
3998 std::string XMLFile ;
3999 XMLFile = myYACS->GetXMLFile() ;
4001 int codret = YACSWriteOnFile(nomYACS, XMLFile.c_str()) ;
4005 //=============================================================================
4006 // Ecriture d'un schema YACS sur un fichier donne
4007 //=============================================================================
4008 CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile)
4010 INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile );
4017 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
4018 ASSERT(!CORBA::is_nil(myYACS));
4019 // B.2. Les caracteristiques
4020 std::string DirName = myYACS->GetDirName() ;
4021 std::string MeshFile = myYACS->GetMeshFile() ;
4022 std::string ScriptFile = myYACS->GetScriptFile() ;
4026 const char* nomCas = myYACS->GetCaseName();
4027 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
4028 ASSERT(!CORBA::is_nil(myCase));
4029 // C.2. Les instructions python associees au cas
4030 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4031 std::string pythonCas = dumpCorbaCase.in();
4032 MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
4034 // D. Les iterations
4035 // D.1. L'iteration initiale
4036 HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
4037 std::string Iter0Name = myCase->GetIter0Name() ;
4038 MESSAGE (". Iter0Name = " << Iter0Name);
4039 std::string MeshName = Iter0->GetMeshName();
4040 MESSAGE (". MeshName = " << MeshName);
4041 // D.2. L'iteration numero 1
4042 HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
4043 int numberOfIter = maListe->length();
4044 if ( numberOfIter > 1 )
4046 MESSAGE (". numberOfIter = " << numberOfIter);
4047 SALOME::ExceptionStruct es ;
4048 es.type = SALOME::BAD_PARAM;
4049 std::string text = "Une seule iteration est permise." ;
4050 es.text = CORBA::string_dup(text.c_str());
4051 throw SALOME::SALOME_Exception(es);
4054 std::string Iter1Name = std::string((*maListe)[0]);
4055 MESSAGE ("... Iter1Name = " << Iter1Name);
4056 HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
4057 // D.3. Les instructions python associees a l'iteration
4058 CORBA::String_var dumpCorbaIter = Iter1->GetDumpPython();
4059 std::string pythonIter = dumpCorbaIter.in();
4060 MESSAGE ("pythonIter :\n"<<pythonIter<<"\n");
4062 // E. L'hypothese pour passer de l'iteration initiale a la suivante
4063 // E.1. La structure
4064 std::string nomHypo = Iter1->GetHypoName();
4065 MESSAGE (". nomHypo = " << nomHypo);
4066 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
4067 ASSERT(!CORBA::is_nil(myHypo));
4068 // E.2. Les caracteristiques de l'adaptation
4069 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
4070 ASSERT(ListTypes->length() == 3);
4071 int TypeAdap = (*ListTypes)[0];
4072 // int TypeRaff = (*ListTypes)[1];
4073 // int TypeDera = (*ListTypes)[2];
4074 // E.3. Les instructions python associees a l'hypothese
4075 CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
4076 std::string pythonHypo = dumpCorbaHypo.in();
4077 MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
4079 // F. Le fichier du schema de reference
4080 // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD
4081 std::string XMLFile_base ;
4082 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { XMLFile_base = getenv("HOMARD_ROOT_DIR") ; }
4085 SALOME::ExceptionStruct es ;
4086 es.type = SALOME::BAD_PARAM;
4087 std::string text = "HOMARD_ROOT_DIR est inconnu." ;
4088 es.text = CORBA::string_dup(text.c_str());
4089 throw SALOME::SALOME_Exception(es);
4092 XMLFile_base += "/share/salome/resources/homard/yacs_01." + _LangueShort + ".xml" ;
4094 MESSAGE("XMLFile_base ="<<XMLFile_base);
4096 // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4097 YACSDriver* myDriver = new YACSDriver(XMLFile, DirName);
4098 std::ifstream fichier( XMLFile_base.c_str() );
4099 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
4101 // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4102 std::string ligne; // variable contenant chaque ligne lue
4103 std::string mot_cle;
4104 while ( std::getline( fichier, ligne ) )
4106 // G.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
4107 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4108 ligne_bis >> mot_cle ;
4109 // G.1.2. Le maillage initial
4110 if ( mot_cle == "DataInit_MeshFile" )
4111 { myDriver->Texte_DataInit_MeshFile(MeshFile); }
4112 // G.1.3. Le script de lancement
4113 else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
4114 { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); }
4115 // G.1.4. Les options du cas
4116 else if ( mot_cle == "Iter_1_Case_Options" )
4117 { myDriver->Texte_Iter_1_Case_Options(pythonCas); }
4118 // G.1.5. Execution de HOMARD : le repertoire du cas
4119 else if ( mot_cle == "HOMARD_Exec_DirName" )
4120 { myDriver->Texte_HOMARD_Exec_DirName(); }
4121 // G.1.6. Execution de HOMARD : le nom du maillage
4122 else if ( mot_cle == "HOMARD_Exec_MeshName" )
4124 myDriver->Texte_HOMARD_Exec_MeshName(MeshName);
4125 std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ;
4126 myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ;
4128 // G.1.7. Execution de HOMARD : les options de l'hypothese
4129 else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
4130 { myDriver->Texte_python_1( pythonHypo, 3, "Hypo" ) ; }
4131 // G.1.8. Execution de HOMARD : les options de l'iteration
4132 else if ( mot_cle == "HOMARD_Exec_Iter_Options" )
4133 { myDriver->Texte_python_2( pythonIter, "TimeStep", "Iter" ) ; }
4134 // G.1.9. Zones et frontieres : les creations
4135 else if ( mot_cle == "Iter_1" )
4137 std::string texte_control = myDriver->Texte_Iter_1_control() ;
4138 if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; }
4139 texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ;
4140 myDriver->TexteAdd(texte_control);
4142 // G.1.10. Les parametres
4143 else if ( mot_cle == "PARAMETRES" )
4144 { myDriver->TexteAddParametres(); }
4145 // G.1.n. La ligne est recopiee telle quelle
4146 else { myDriver->TexteAdd(ligne); }
4148 // G.2. Ecriture du texte dans le fichier
4150 { myDriver->CreeFichier(); }
4154 SALOME::ExceptionStruct es;
4155 es.type = SALOME::BAD_PARAM;
4156 std::string text = "The reference file for the YACS schema cannot be read." ;
4157 es.text = CORBA::string_dup(text.c_str());
4158 throw SALOME::SALOME_Exception(es);
4163 // H. Publication du fichier dans l'arbre
4165 std::string Commentaire = "xml" ;
4166 PublishFileUnderYACS(nomYACS, XMLFile, Commentaire.c_str());
4170 //=============================================================================
4171 // Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
4172 //=============================================================================
4173 std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
4175 MESSAGE ( "YACSDriverTexteZone" );
4176 // A. Les zones associees a cette hypothese
4177 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
4178 int numberOfZonesx2 = ListZone->length();
4180 // B. Parcours des zones
4181 std::string texte_control ;
4182 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
4184 // 1. Reperage de la zone
4185 std::string ZoneName = std::string((*ListZone)[iaux]);
4186 MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
4187 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
4188 ASSERT(!CORBA::is_nil(myZone));
4189 // 2. Les instructions python associees a la zone
4190 // La premiere ligne est un commentaire a eliminer
4191 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4192 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4193 std::string pythonStructure_0 = dumpCorbaZone.in();
4194 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4195 std::istringstream tout (pythonStructure_0) ;
4197 std::string pythonStructure ;
4198 while ( std::getline( tout, ligne ) )
4199 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4200 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4201 // 3. Decodage du nom du service
4202 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4203 MESSAGE ( "... methode = " << methode);
4204 // 4. Mise en place des instructions
4205 int ZoneType = myZone->GetType();
4206 MESSAGE ( "... ZoneType = " << ZoneType);
4207 std::string texte_control_0 ;
4208 texte_control_0 = myDriver->Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName );
4209 texte_control += texte_control_0 ;
4214 return texte_control ;
4216 //=============================================================================
4217 // Ecriture d'un schema YACS : ecriture des frontieres associees au cas
4218 //=============================================================================
4219 std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver)
4221 MESSAGE ( "YACSDriverTexteBoundary" );
4222 // A. Les frontieres associees au cas
4223 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
4224 int numberOfitems = ListBoundaryGroupType->length();
4226 // B. Parcours des frontieres
4227 std::string texte_control ;
4228 std::list<std::string> ListeBoundaryTraitees ;
4229 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
4231 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
4232 MESSAGE ( "... BoundaryName = " << BoundaryName);
4233 // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver
4234 // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees
4236 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
4237 while (it != ListeBoundaryTraitees.end())
4239 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
4240 if ( BoundaryName == *it ) { A_faire = 0 ; }
4245 // 1. Caracteristiques de la frontiere
4246 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
4247 ASSERT(!CORBA::is_nil(myBoundary));
4248 // 2. Les instructions python associees a la frontiere
4249 // La premiere ligne est un commentaire a eliminer
4250 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4251 CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython();
4252 std::string pythonStructure_0 = dumpCorbaBoundary.in();
4253 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4254 std::istringstream tout (pythonStructure_0) ;
4256 std::string pythonStructure ;
4257 while ( std::getline( tout, ligne ) )
4258 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4259 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4260 // 3. Decodage du nom du service
4261 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4262 MESSAGE ( "... methode = " << methode);
4263 // 4. Mise en place des instructions
4264 int BoundaryType = myBoundary->GetType();
4265 MESSAGE ( "... BoundaryType = " << BoundaryType);
4266 std::string texte_control_0 ;
4267 texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName );
4268 texte_control += texte_control_0 ;
4269 // 5. Memorisation du traitement
4270 ListeBoundaryTraitees.push_back( BoundaryName );
4274 return texte_control ;
4277 //=============================================================================
4278 //=============================================================================
4279 // Next functions are inherited from SALOMEDS::Driver interface
4280 //=============================================================================
4281 //=============================================================================
4282 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
4284 CORBA::Boolean isMultiFile)
4286 MESSAGE ("Save for theURL = "<< theURL);
4287 SALOMEDS::TMPFile_var aStreamFile;
4289 // get temporary directory name
4290 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4292 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
4293 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4295 // HOMARD data file name
4296 std::string aFileName = "";
4298 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
4299 aFileName += "_HOMARD.dat";
4301 // initialize sequence of file names
4302 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
4303 aFileSeq->length(1);
4304 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
4306 // get full path to the data file
4307 aFileName = tmpDir + aFileName;
4311 std::ofstream f(aFileName.c_str());
4313 // clear temporary id map
4314 context._idmap.clear();
4319 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
4320 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
4321 HOMARD::HOMARD_Cas_var aCas = it_case->second;
4322 PortableServer::ServantBase_var aServant = GetServant(aCas);
4323 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4325 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
4326 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
4330 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4331 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
4332 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
4333 PortableServer::ServantBase_var aServant = GetServant(aZone);
4334 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4336 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
4337 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4340 // -> save hypotheses
4341 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4342 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
4343 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
4344 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4345 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4347 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
4348 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4351 // -> save iterations
4352 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4353 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
4354 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
4355 PortableServer::ServantBase_var aServant = GetServant(aIter);
4356 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4358 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
4359 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4362 // -> save boundaries
4363 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4364 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
4365 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
4366 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4367 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4368 if (aBoundaryServant) {
4369 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
4370 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4374 MESSAGE ("close file");
4377 // put temporary files to the stream
4378 MESSAGE ("put temporary files to the stream");
4379 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
4381 // remove temporary files
4382 MESSAGE ("remove temporary files");
4383 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4385 // return data stream
4386 MESSAGE ("return data stream");
4387 return aStreamFile._retn();
4390 //===========================================================================
4391 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
4393 CORBA::Boolean isMultiFile)
4395 // No specific ASCII persistence
4396 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
4397 return aStreamFile._retn();
4400 //===========================================================================
4401 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
4402 const SALOMEDS::TMPFile& theStream,
4404 CORBA::Boolean isMultiFile)
4406 MESSAGE ("Load pour theURL = "<< theURL);
4407 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
4409 // set current study
4410 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
4411 SetCurrentStudy(aStudy);
4413 // get temporary directory name
4414 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4416 // Convert the stream into sequence of files to process
4417 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
4420 // HOMARD data file name
4421 std::string aFileName = "";
4423 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
4424 aFileName = tmpDir + aFileName + "_HOMARD.dat";
4426 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4430 std::ifstream f(aFileName.c_str());
4433 context._mesCas.clear();
4434 context._mesHypotheses.clear();
4435 context._mesIterations.clear();
4436 context._mesZones.clear();
4437 context._mesBoundarys.clear();
4438 context._idmap.clear();
4444 std::getline(f, line);
4445 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
4446 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
4447 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
4448 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
4449 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
4450 std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS);
4451 if (line.substr(0, bounSignature.size()) == bounSignature) {
4452 // re-create boundary
4453 MESSAGE ("Recreation de la frontiere" );
4454 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
4455 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4456 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4457 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
4458 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
4459 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4462 else if (line.substr(0, caseSignature.size()) == caseSignature) {
4464 MESSAGE ("Recreation du cas" );
4465 HOMARD::HOMARD_Cas_var aCase = newCase();
4466 PortableServer::ServantBase_var aServant = GetServant(aCase);
4467 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4468 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
4469 context._mesCas[aCase->GetName()] = aCase;
4470 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
4473 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
4474 // re-create hypothesis
4475 MESSAGE ("Recreation de l hypothese" );
4476 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
4477 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4478 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4479 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
4480 context._mesHypotheses[aHypo->GetName()] = aHypo;
4481 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4484 else if (line.substr(0, iterSignature.size()) == iterSignature) {
4485 // re-create iteration
4486 MESSAGE ("Recreation de l'iteration" );
4487 HOMARD::HOMARD_Iteration_var aIter = newIteration();
4488 PortableServer::ServantBase_var aServant = GetServant(aIter);
4489 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4490 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
4491 context._mesIterations[aIter->GetName()] = aIter;
4492 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4495 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
4496 MESSAGE ("Recreation de la zone" );
4498 HOMARD::HOMARD_Zone_var aZone = newZone();
4499 PortableServer::ServantBase_var aServant = GetServant(aZone);
4500 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4501 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
4502 context._mesZones[aZone->GetName()] = aZone;
4503 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4506 else if (line.substr(0, zoneSignature.size()) == yacsSignature) {
4507 MESSAGE ("Recreation du schema YACS" );
4509 HOMARD::HOMARD_YACS_var aYACS = newYACS();
4510 PortableServer::ServantBase_var aServant = GetServant(aYACS);
4511 HOMARD_YACS_i* aYACSServant = dynamic_cast<HOMARD_YACS_i*>(aServant.in());
4512 if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) {
4513 context._mesYACSs[aYACS->GetName()] = aYACS;
4514 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aYACSServant);
4523 // Remove temporary files created from the stream
4525 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4530 //===========================================================================
4531 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
4532 const SALOMEDS::TMPFile& theStream,
4534 CORBA::Boolean isMultiFile)
4536 // No specific ASCII persistence
4537 return Load(theComponent, theStream, theURL, isMultiFile);
4540 //===========================================================================
4541 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
4543 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
4544 // clearing study context should be done here:
4545 // - destroy all servants and related CORBA objects
4547 // - remove context from myContextMap
4548 myContextMap.erase(theComponent->GetStudy()->StudyId());
4549 // - nullify myCurrentStudy
4550 myCurrentStudy = SALOMEDS::Study::_nil();
4554 //===========================================================================
4555 char* HOMARD_Gen_i::ComponentDataType()
4557 return CORBA::string_dup("HOMARD");
4560 //===========================================================================
4561 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
4562 const char* IORString,
4563 CORBA::Boolean isMultiFile,
4564 CORBA::Boolean isASCII)
4566 CORBA::String_var aString("");
4567 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
4568 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4569 CORBA::Object_var anObj = _orb->string_to_object(IORString);
4570 if (!CORBA::is_nil(anObj)) {
4571 PortableServer::ServantBase_var aServant = GetServant(anObj);
4572 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
4574 std::map<int, PortableServer::ServantBase*>::const_iterator it;
4575 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
4576 if (it->second == aStorable) {
4577 std::stringstream os;
4579 aString = CORBA::string_dup(os.str().c_str());
4585 return aString._retn();
4588 //===========================================================================
4589 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
4590 const char* aLocalPersistentID,
4591 CORBA::Boolean isMultiFile,
4592 CORBA::Boolean isASCII)
4594 CORBA::String_var aString("");
4595 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
4596 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4597 int id = atoi(aLocalPersistentID);
4598 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
4599 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
4600 if (!CORBA::is_nil(object)) {
4601 aString = _orb->object_to_string(object);
4605 return aString._retn();
4608 //===========================================================================
4609 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
4611 if(CORBA::is_nil(myCurrentStudy))
4614 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
4615 if(!aCas->_is_nil())
4618 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
4619 if(!aHypo->_is_nil())
4622 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
4623 if(!aZone->_is_nil())
4626 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
4627 if(!aBoundary->_is_nil())
4630 /* Iteration is not published directly
4631 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
4632 if(!aIter->_is_nil())
4638 //===========================================================================
4639 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
4641 // No Copy/Paste support
4645 //===========================================================================
4646 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
4647 CORBA::Long& theObjectID)
4649 // No Copy/Paste support
4650 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
4651 return aStreamFile._retn();
4654 //===========================================================================
4655 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
4656 CORBA::Long theObjectID)
4658 // No Copy/Paste support
4662 //===========================================================================
4663 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
4664 CORBA::Long theObjectID,
4665 SALOMEDS::SObject_ptr theSObject)
4667 // No Copy/Paste support
4668 SALOMEDS::SObject_var aResultSO;
4669 return aResultSO._retn();
4672 //===========================================================================
4673 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
4675 PortableServer::Servant aServant = 0;
4676 if (!CORBA::is_nil(theObject)) {
4678 aServant = _poa->reference_to_servant(theObject);
4686 //==========================================================================
4687 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
4688 CORBA::Boolean isPublished,
4689 CORBA::Boolean isMultiFile,
4690 CORBA::Boolean& isValidScript)
4692 MESSAGE ("Entree dans DumpPython");
4694 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
4695 if(CORBA::is_nil(aStudy))
4696 return new Engines::TMPFile(0);
4698 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
4699 if(CORBA::is_nil(aSO))
4700 return new Engines::TMPFile(0);
4702 std::string aScript = "\"\"\"\n";
4703 aScript += "Python script for HOMARD\n";
4704 aScript += "Copyright EDF-R&D 1996, 2011, 2014\n";
4705 aScript += "\"\"\"\n";
4706 aScript += "__revision__ = \"V1.2\"\n";
4707 aScript += "import HOMARD\n";
4709 aScript += "import salome\n";
4710 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4712 aScript += "def RebuildData(theStudy):\n";
4713 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
4716 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
4717 MESSAGE (". Au depart \n"<<aScript);
4720 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
4722 MESSAGE (". Ecritures des frontieres");
4723 aScript += "#\n# Creation of the boundaries";
4724 aScript += "\n# ==========================";
4726 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4727 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
4728 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
4730 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4731 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4732 std::string dumpBoundary = dumpCorbaBoundary.in();
4733 MESSAGE (dumpBoundary<<"\n");
4734 aScript += dumpBoundary;
4738 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
4740 MESSAGE (". Ecritures des zones");
4741 aScript += "#\n# Creation of the zones";
4742 aScript += "\n# =====================";
4744 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4745 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
4746 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
4748 HOMARD::HOMARD_Zone_var myZone = (*it_zone).second;
4749 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4750 std::string dumpZone = dumpCorbaZone.in();
4751 MESSAGE (dumpZone<<"\n");
4752 aScript += dumpZone;
4756 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
4758 MESSAGE (". Ecritures des hypotheses");
4759 aScript += "#\n# Creation of the hypotheses";
4760 aScript += "\n# ==========================";
4762 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4763 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
4764 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
4766 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4767 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4768 std::string dumpHypo = dumpCorbaHypo.in();
4769 MESSAGE (dumpHypo<<"\n");
4770 aScript += dumpHypo;
4774 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
4776 MESSAGE (". Ecritures des cas");
4777 aScript += "#\n# Creation of the cases";
4778 aScript += "\n# =====================";
4780 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4781 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4782 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
4784 std::string nomCas = (*it_cas).first;
4785 std::string dumpCas = std::string("\n# Creation of the case ") ;
4786 dumpCas += nomCas + std::string("\n");
4787 dumpCas += std::string("\t") + nomCas;
4788 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4790 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4791 CORBA::String_var cIter0= myCase->GetIter0Name();
4792 std::string iter0 = cIter0.in();
4794 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
4795 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4796 std::string mesh0 = cMesh0.in();
4797 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4798 std::string meshName0 = cMeshName0.in();
4799 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4800 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4801 std::string dumpCas2= dumpCorbaCase.in();
4803 MESSAGE (dumpCas<<dumpCas2<<"\n");
4804 aScript += dumpCas + dumpCas2;
4808 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
4810 MESSAGE (". Ecritures des iterations");
4811 aScript += "#\n# Creation of the iterations" ;
4812 aScript += "\n# ==========================";
4814 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4815 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
4816 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
4818 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4819 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4820 std::string dumpIter = dumpCorbaIter.in();
4821 MESSAGE (dumpIter<<"\n");
4822 aScript += dumpIter;
4826 if (myContextMap[GetCurrentStudyID()]._mesYACSs.size() > 0)
4828 MESSAGE (". Ecritures des schemas YACS");
4829 aScript += "#\n# Creation of the schemas YACS";
4830 aScript += "\n# ============================";
4832 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it_yacs;
4833 for ( it_yacs = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
4834 it_yacs != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); ++it_yacs)
4836 HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second;
4837 CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython();
4838 std::string dumpYACS = dumpCorbaYACS.in();
4839 MESSAGE (dumpYACS<<"\n");
4840 aScript += dumpYACS;
4843 MESSAGE (". Ecritures finales");
4845 aScript += "\n\tpass";
4848 if( !isMultiFile ) // remove unnecessary tabulation
4849 aScript = RemoveTabulation( aScript );
4851 // MESSAGE ("A ecrire \n"<<aScript);
4852 const size_t aLen = strlen(aScript.c_str());
4853 char* aBuffer = new char[aLen+1];
4854 strcpy(aBuffer, aScript.c_str());
4856 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4857 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4859 MESSAGE ("Sortie de DumpPython");
4860 return aStreamFile._retn();
4864 //=============================================================================
4865 //=============================================================================
4867 //=============================================================================
4868 //=============================================================================
4869 void HOMARD_Gen_i::IsValidStudy( )
4871 // MESSAGE( "IsValidStudy" );
4872 if (CORBA::is_nil(myCurrentStudy))
4874 SALOME::ExceptionStruct es;
4875 es.type = SALOME::BAD_PARAM;
4876 es.text = "Invalid study context";
4877 throw SALOME::SALOME_Exception(es);
4882 //=============================================================================
4883 char* HOMARD_Gen_i::VerifieDir(const char* nomDir)
4885 std::string casename = std::string("") ;
4886 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4887 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4888 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
4890 if (std::string(nomDir) == std::string(it->second->GetDirName()))
4892 casename = std::string(it->second->GetName()) ;
4896 return CORBA::string_dup( casename.c_str() );
4898 /*//=============================================================================
4899 void SALOMEException( std::string message )
4901 SALOME::ExceptionStruct es;
4902 es.type = SALOME::BAD_PARAM;
4904 throw SALOME::SALOME_Exception(es);
4907 //=============================================================================
4908 char* HOMARD_Gen_i::getVersion()
4910 #if HOMARD_DEVELOPMENT
4911 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4913 return CORBA::string_dup(HOMARD_VERSION_STR);
4916 //===============================================================================
4917 // Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere
4918 // ligne : la ligne a manipuler
4919 // caractere : le caractere a reperer
4920 // option : 0 : la chaine avant la premiere apparition du caractere
4921 // 1 : la chaine apres la premiere apparition du caractere
4922 // 2 : la chaine avant la derniere apparition du caractere
4923 // 3 : la chaine apres la derniere apparition du caractere
4924 // Si le caractere est absent, on retourne la chaine totale
4925 //===============================================================================
4926 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option )
4928 // MESSAGE("GetStringInTexte, recherche de '"<<caractere<<"' dans '"<<ligne<<"'"<<", option = "<<option);
4930 std::string chaine = ligne ;
4932 if ( option < 2 ) { position = ligne.find_first_of( caractere ) ; }
4933 else { position = ligne.find_last_of( caractere ) ; }
4934 // MESSAGE("position = "<<position);
4935 // MESSAGE("a = "<<ligne.substr( 0, position ).c_str());
4936 // MESSAGE("b = "<<ligne.substr( position+1 ).c_str());
4938 if ( position != std::string::npos )
4940 if ( ( option == 0 ) || ( option == 2 ) ) { chaine = ligne.substr( 0, position ) ; }
4941 else { chaine = ligne.substr( position+1 ) ; }
4946 //=============================================================================
4947 //=============================================================================
4948 // Gestion des preferences
4949 //=============================================================================
4950 //=============================================================================
4951 // Decodage du fichier d'arcihvage des preferences
4953 void HOMARD_Gen_i::SetPreferences( )
4955 MESSAGE ( "SetPreferences" );
4957 std::string ligne, mot_cle, salome_version ;
4960 // A. Les valeurs par defaut ; elles doivent etre coherentes
4961 std::string LanguageShort = "fr" ;
4962 int PublisMeshIN = 0 ;
4963 int PublisMeshOUT = 0 ;
4964 int YACSMaxIter = 0 ;
4965 int YACSMaxNode = 0 ;
4966 int YACSMaxElem = 0 ;
4968 // B. La version de salome
4969 // Cela se presente sous la forme :
4970 // [SALOME KERNEL] : 7.3.0
4972 File = getenv("KERNEL_ROOT_DIR") ;
4973 File += "/bin/salome/VERSION" ;
4974 MESSAGE ( "File = "<<File ) ;
4975 std::ifstream fichier0( File.c_str() ) ;
4976 if ( fichier0 ) // ce test échoue si le fichier n'est pas ouvert
4978 std::string ligne; // variable contenant chaque ligne lue
4979 while ( std::getline( fichier0, ligne ) )
4981 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4982 ligne_bis >> mot_cle ;
4983 if ( mot_cle == "[SALOME" )
4985 salome_version = GetStringInTexte ( ligne, " ", 3 ) ;
4986 // MESSAGE ( "salome_version = "<<salome_version<<"|||");
4991 else { ok = false ; }
4993 // B. Decodage du fichier de preferences
4996 std::string PrefFile ;
4997 PrefFile = getenv("HOME") ;
4998 PrefFile += "/.config/salome/SalomeApprc." + salome_version ;
4999 MESSAGE ( "PrefFile = "<<PrefFile ) ;
5001 std::ifstream fichier( PrefFile.c_str() );
5002 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
5004 bool section_langue = false ;
5005 bool section_homard = false ;
5006 while ( std::getline( fichier, ligne ) )
5008 std::string chaine ;
5009 // 1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
5010 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
5011 ligne_bis >> mot_cle ;
5014 // 2.1. Debut d'une section
5015 // MESSAGE(mot_cle);
5016 if ( mot_cle == "<section" )
5017 { /*MESSAGE ( "Debut de la section : "<< ligne);*/
5018 ligne_bis >> mot_cle ;
5019 chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5020 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5021 if ( chaine == "language" ) { section_langue = true ; }
5022 if ( chaine == "HOMARD" ) { section_homard = true ; }
5023 // MESSAGE ( "section_langue = "<<section_langue<<", section_homard = "<<section_homard);
5025 // 2.2. Fin d'une section
5026 else if ( mot_cle == "</section>" )
5027 { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<<section_langue<<", section_homard = "<<section_homard);*/
5028 section_langue = false ;
5029 section_homard = false ; }
5033 else if ( section_langue || section_homard )
5034 { /*MESSAGE ( "a decoder : "<< ligne);*/
5035 ligne_bis >> mot_cle ;
5036 chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5037 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5038 // MESSAGE("chaine = "<<chaine<<"|");
5039 ligne_bis >> mot_cle ;
5040 std::string chaine2 = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5041 chaine2 = GetStringInTexte ( chaine2, "\"", 0 ) ;
5042 // MESSAGE("chaine2 = "<<chaine2<<"|");
5044 if ( section_langue )
5045 { if ( chaine2 == "language" ) { LanguageShort = chaine ; } }
5047 if ( section_homard )
5049 std::istringstream chainebis( chaine ) ;
5050 // 3.2.1. Les publications
5051 if ( chaine2 == "publish_mesh_in" ) { chainebis >> PublisMeshIN ; }
5052 if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT ; }
5053 // 3.2.2. Les maximum pour YACS
5054 if ( chaine2 == "max_iter" ) { chainebis >> YACSMaxIter ; }
5055 if ( chaine2 == "max_node" ) { chainebis >> YACSMaxNode ; }
5056 if ( chaine2 == "max_elem" ) { chainebis >> YACSMaxElem ; }
5063 // C. Enregistrement
5064 MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort );
5065 MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT);
5066 MESSAGE ("Enregistrement de YACSMaxIter = " << YACSMaxIter<<", YACSMaxNode = "<< YACSMaxNode<<", YACSMaxElem = "<< YACSMaxElem);
5067 SetLanguageShort( LanguageShort.c_str() ) ;
5068 SetPublisMesh(PublisMeshIN, PublisMeshOUT) ;
5069 SetYACSMaximum(YACSMaxIter, YACSMaxNode, YACSMaxElem) ;
5073 //===============================================================================
5075 //===============================================================================
5076 void HOMARD_Gen_i::SetLanguageShort(const char* LanguageShort)
5078 // MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort );
5079 _LangueShort = LanguageShort ;
5080 if ( _LangueShort == "fr" ) { _Langue = "Francais" ; }
5081 else { _Langue = "English" ; }
5084 char* HOMARD_Gen_i::GetLanguageShort()
5086 // MESSAGE ("GetLanguageShort");
5087 return CORBA::string_dup( _LangueShort.c_str() );
5089 //===============================================================================
5090 // Options de publications
5091 //===============================================================================
5092 void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT)
5094 _PublisMeshIN = PublisMeshIN ;
5095 _PublisMeshOUT = PublisMeshOUT ;
5098 CORBA::Long HOMARD_Gen_i::GetPublisMeshIN()
5100 return _PublisMeshIN ;
5102 CORBA::Long HOMARD_Gen_i::GetPublisMeshOUT()
5104 return _PublisMeshOUT ;
5106 //===============================================================================
5108 //===============================================================================
5109 void HOMARD_Gen_i::SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem)
5111 _YACSMaxIter = YACSMaxIter ;
5112 _YACSMaxNode = YACSMaxNode ;
5113 _YACSMaxElem = YACSMaxElem ;
5116 CORBA::Long HOMARD_Gen_i::GetYACSMaxIter()
5118 return _YACSMaxIter ;
5120 CORBA::Long HOMARD_Gen_i::GetYACSMaxNode()
5122 return _YACSMaxNode ;
5124 CORBA::Long HOMARD_Gen_i::GetYACSMaxElem()
5126 return _YACSMaxElem ;
5129 //=============================================================================
5133 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
5134 PortableServer::POA_ptr poa,
5135 PortableServer::ObjectId* contId,
5136 const char* instanceName,
5137 const char* interfaceName)
5139 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
5140 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
5141 return myHOMARD_Gen->getId();