1 // Copyright (C) 2011-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "HOMARD_Gen_i.hxx"
21 #include "HOMARD_Cas_i.hxx"
22 #include "HOMARD_Hypothesis_i.hxx"
23 #include "HOMARD_Iteration_i.hxx"
24 #include "HOMARD_Boundary_i.hxx"
25 #include "HOMARD_Zone_i.hxx"
26 #include "HOMARD_YACS_i.hxx"
27 #include "HomardDriver.hxx"
28 #include "HOMARD_DriverTools.hxx"
29 #include "HomardMedCommun.h"
30 #include "YACSDriver.hxx"
33 #include "HOMARD_version.h"
35 #include "utilities.h"
36 #include "Basics_Utils.hxx"
37 #include "Utils_SINGLETON.hxx"
38 #include "Utils_CorbaException.hxx"
39 #include "SALOMEDS_Tool.hxx"
40 #include "SALOME_LifeCycleCORBA.hxx"
41 #include "SALOMEconfig.h"
42 #include <SMESH_Gen_i.hxx>
43 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
44 #include CORBA_CLIENT_HEADER(SMESH_Gen)
67 //=============================================================================
69 //=============================================================================
70 std::string RemoveTabulation( std::string theScript )
72 std::string::size_type aPos = 0;
73 while( aPos < theScript.length() )
75 aPos = theScript.find( "\n\t", aPos );
76 if( aPos == std::string::npos )
78 theScript.replace( aPos, 2, "\n" );
83 //=============================================================================
85 * standard constructor
87 //=============================================================================
88 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
89 PortableServer::POA_ptr poa,
90 PortableServer::ObjectId * contId,
91 const char *instanceName,
92 const char *interfaceName) :
93 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
95 MESSAGE("constructor");
97 _id = _poa->activate_object(_thisObj);
99 myHomard = new ::HOMARD_Gen();
100 _NS = SINGLETON_<SALOME_NamingService>::Instance();
101 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
104 myStudy = SALOMEDS::Study::_duplicate( SMESH_Gen_i::getStudyServant() );
114 //=================================
116 * standard destructor
118 //================================
119 HOMARD_Gen_i::~HOMARD_Gen_i()
122 //=============================================================================
123 //=============================================================================
124 // Utilitaires pour l'??tude
125 //=============================================================================
126 //=============================================================================
127 void HOMARD_Gen_i::UpdateStudy()
129 ASSERT(!CORBA::is_nil(myStudy));
130 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
132 // Create SComponent labelled 'homard' if it doesn't already exit
133 SALOMEDS::SComponent_var homardFather = myStudy->FindComponent(ComponentDataType());
134 if (CORBA::is_nil(homardFather))
136 myBuilder->NewCommand();
137 MESSAGE("Add Component HOMARD");
139 bool aLocked = myStudy->GetProperties()->IsLocked();
140 if (aLocked) myStudy->GetProperties()->SetLocked(false);
142 homardFather = myBuilder->NewComponent(ComponentDataType());
143 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
144 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
145 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
146 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
147 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
148 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
149 if (!Comp->_is_nil())
151 aName->SetValue(ComponentDataType());
154 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
155 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
156 aPixmap->SetPixMap("HOMARD_2.png");
157 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
159 if (aLocked) myStudy->GetProperties()->SetLocked(true);
160 myBuilder->CommitCommand();
164 //=============================================================================
165 //=============================================================================
166 // Utilitaires pour l'iteration
167 //=============================================================================
168 //=============================================================================
169 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
170 //=====================================================================================
172 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
173 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
174 if (CORBA::is_nil(myIteration))
176 SALOME::ExceptionStruct es;
177 es.type = SALOME::BAD_PARAM;
178 es.text = "Invalid iteration";
179 throw SALOME::SALOME_Exception(es);
183 myIteration->SetState(Etat);
185 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
186 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
190 icone = "iter0.png" ;
191 else if ( Etat == 2 )
192 icone = "iter_calculee.png" ;
194 icone = "iter_non_calculee.png" ;
195 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ;
197 aStudyBuilder->CommitCommand();
200 //=============================================================================
201 //=============================================================================
203 //=============================================================================
204 //=============================================================================
205 // Destruction des structures identifiees par leurs noms
206 //=============================================================================
207 //=============================================================================
208 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
210 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
211 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
212 if (CORBA::is_nil(myBoundary))
214 SALOME::ExceptionStruct es;
215 es.type = SALOME::BAD_PARAM;
216 es.text = "Invalid boundary";
217 throw SALOME::SALOME_Exception(es);
221 // On verifie que la frontiere n'est plus utilisee
222 HOMARD::listeCases* maListe = GetAllCasesName();
223 int numberOfCases = maListe->length();
224 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
225 std::string CaseName ;
226 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
228 HOMARD::HOMARD_Cas_var myCase ;
229 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
231 CaseName = std::string((*maListe)[NumeCas]);
232 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
233 myCase = myStudyContext._mesCas[CaseName];
234 ASSERT(!CORBA::is_nil(myCase));
235 ListBoundaryGroupType = myCase->GetBoundaryGroup();
236 numberOfitems = ListBoundaryGroupType->length();
237 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
238 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
240 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
242 SALOME::ExceptionStruct es;
243 es.type = SALOME::BAD_PARAM;
244 es.text = "This boundary is used in a case and cannot be deleted.";
245 throw SALOME::SALOME_Exception(es);
251 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
252 myStudyContext._mesBoundarys.erase(BoundaryName);
253 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(BoundaryName, ComponentDataType());
254 SALOMEDS::SObject_var aSO =listSO[0];
255 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
256 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
260 //=============================================================================
261 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option)
263 // Pour detruire un cas
264 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
265 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
266 if (CORBA::is_nil(myCase))
268 SALOME::ExceptionStruct es;
269 es.type = SALOME::BAD_PARAM;
270 es.text = "Invalid case context";
271 throw SALOME::SALOME_Exception(es);
274 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
275 CORBA::String_var nomIter = myCase->GetIter0Name();
276 CORBA::Long Option1 = 0 ;
277 if ( DeleteIterationOption(nomIter, Option1, Option) != 0 )
282 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
283 myStudyContext._mesCas.erase(nomCas);
284 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomCas, ComponentDataType());
285 SALOMEDS::SObject_var aSO =listSO[0];
286 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
287 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
291 //=============================================================================
292 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
294 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
295 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
296 if (CORBA::is_nil(myHypo))
298 SALOME::ExceptionStruct es;
299 es.type = SALOME::BAD_PARAM;
300 es.text = "Invalid hypothesis";
301 throw SALOME::SALOME_Exception(es);
305 // On verifie que l'hypothese n'est plus utilisee
306 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
307 int numberOfIter = maListeIter->length();
308 if ( numberOfIter > 0 )
310 SALOME::ExceptionStruct es;
311 es.type = SALOME::BAD_PARAM;
312 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
313 throw SALOME::SALOME_Exception(es);
317 // suppression du lien avec les zones eventuelles
318 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
319 int numberOfZones = maListe->length();
320 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
321 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
323 std::string ZoneName = std::string((*maListe)[NumeZone]);
324 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
325 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
329 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
330 myStudyContext._mesHypotheses.erase(nomHypo);
331 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomHypo, ComponentDataType());
332 SALOMEDS::SObject_var aSO =listSO[0];
333 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
334 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
338 //=============================================================================
339 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
341 // Option = 0 : On ne supprime pas le fichier du maillage associe
342 // Option = 1 : On supprime le fichier du maillage associe
343 // Pour detruire une iteration courante
344 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
345 CORBA::Long Option1 = 1 ;
346 return DeleteIterationOption(nomIter, Option1, Option);
348 //=============================================================================
349 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
351 // Option1 = 0 : On autorise la destruction de l'iteration 0
352 // Option1 = 1 : On interdit la destruction de l'iteration 0
354 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
355 // Option2 = 1 : On supprime le fichier du maillage associe
356 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
357 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
358 if (CORBA::is_nil(myIteration))
360 SALOME::ExceptionStruct es;
361 es.type = SALOME::BAD_PARAM;
362 es.text = "Invalid iteration";
363 throw SALOME::SALOME_Exception(es);
367 int numero = myIteration->GetNumber();
368 MESSAGE ( "DeleteIterationOption : numero = " << numero );
369 if ( numero == 0 && Option1 == 1 )
371 SALOME::ExceptionStruct es;
372 es.type = SALOME::BAD_PARAM;
373 es.text = "This iteration cannot be deleted.";
374 throw SALOME::SALOME_Exception(es);
378 // On detruit recursivement toutes les filles
379 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
380 int numberOfIter = maListe->length();
381 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
383 std::string nomIterFille = std::string((*maListe)[NumeIter]);
384 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
385 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
388 // On arrive ici pour une iteration sans fille
389 MESSAGE ( "Destruction effective de " << nomIter );
390 // On commence par invalider l'iteration pour faire le menage des dependances
391 // et eventuellement du maillage associe
393 if ( numero == 0 ) { option = 0 ; }
394 else { option = Option2 ; }
395 InvalideIterOption(nomIter, option) ;
397 // Retrait dans la descendance de l'iteration parent
400 std::string nomIterationParent = myIteration->GetIterParentName();
401 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
402 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
403 if (CORBA::is_nil(myIterationParent))
405 SALOME::ExceptionStruct es;
406 es.type = SALOME::BAD_PARAM;
407 es.text = "Invalid iteration";
408 throw SALOME::SALOME_Exception(es);
411 myIterationParent->UnLinkNextIteration(nomIter);
414 // suppression du lien avec l'hypothese
417 std::string nomHypo = myIteration->GetHypoName();
418 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
419 ASSERT(!CORBA::is_nil(myHypo));
420 myHypo->UnLinkIteration(nomIter);
423 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
424 myStudyContext._mesIterations.erase(nomIter);
425 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomIter, ComponentDataType());
426 SALOMEDS::SObject_var aSO =listSO[0];
427 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
428 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
429 // on peut aussi faire RemoveObject
430 // MESSAGE ( "Au final" );
431 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
432 // numberOfIter = Liste->length();
433 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
435 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
436 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
441 //=============================================================================
442 CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option)
444 // Option = 0 : On ne supprime pas le fichier du schema associe
445 // Option = 1 : On supprime le fichier du schema associe
446 MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option );
447 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
448 if (CORBA::is_nil(myYACS))
450 SALOME::ExceptionStruct es;
451 es.type = SALOME::BAD_PARAM;
452 es.text = "Invalid schema YACS";
453 throw SALOME::SALOME_Exception(es);
456 // Suppression eventuelle du fichier XML
459 std::string nomFichier = myYACS->GetXMLFile();
460 std::string commande = "rm -rf " + nomFichier ;
461 MESSAGE ( "commande = " << commande );
462 if ((system(commande.c_str())) != 0)
464 SALOME::ExceptionStruct es;
465 es.type = SALOME::BAD_PARAM;
466 es.text = "The xml file for the schema YACS cannot be removed." ;
467 throw SALOME::SALOME_Exception(es);
471 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
472 myStudyContext._mesYACSs.erase(nomYACS);
473 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomYACS, ComponentDataType());
474 SALOMEDS::SObject_var aSO =listSO[0];
475 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
476 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
480 //=============================================================================
481 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
483 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
484 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[nomZone];
485 if (CORBA::is_nil(myZone))
487 SALOME::ExceptionStruct es;
488 es.type = SALOME::BAD_PARAM;
489 es.text = "Invalid zone";
490 throw SALOME::SALOME_Exception(es);
494 // On verifie que la zone n'est plus utilisee
495 HOMARD::listeHypo* maListe = myZone->GetHypo();
496 int numberOfHypo = maListe->length();
497 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
498 if ( numberOfHypo > 0 )
500 SALOME::ExceptionStruct es;
501 es.type = SALOME::BAD_PARAM;
502 es.text = "This zone is used in an hypothesis and cannot be deleted.";
503 throw SALOME::SALOME_Exception(es);
507 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
508 myStudyContext._mesZones.erase(nomZone);
509 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomZone, ComponentDataType());
510 SALOMEDS::SObject_var aSO =listSO[0];
511 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
512 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
516 //=============================================================================
517 //=============================================================================
519 //=============================================================================
520 //=============================================================================
521 // Invalidation des structures identifiees par leurs noms
522 //=============================================================================
523 //=============================================================================
524 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
526 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
527 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
528 if (CORBA::is_nil(myBoundary))
530 SALOME::ExceptionStruct es;
531 es.type = SALOME::BAD_PARAM;
532 es.text = "Invalid boundary";
533 throw SALOME::SALOME_Exception(es);
538 SALOME::ExceptionStruct es;
539 es.type = SALOME::BAD_PARAM;
540 es.text = "No change is allowed in a boundary. Ask for evolution.";
541 throw SALOME::SALOME_Exception(es);
545 //=============================================================================
546 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
548 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
549 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
550 if (CORBA::is_nil(myHypo))
552 SALOME::ExceptionStruct es;
553 es.type = SALOME::BAD_PARAM;
554 es.text = "Invalid hypothesis";
555 throw SALOME::SALOME_Exception(es);
559 HOMARD::listeIters* maListe = myHypo->GetIterations();
560 int numberOfIter = maListe->length();
561 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
563 std::string nomIter = std::string((*maListe)[NumeIter]);
564 MESSAGE( ".. nomIter = " << nomIter );
565 InvalideIter(nomIter.c_str());
568 //=============================================================================
569 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
571 MESSAGE("InvalideIter : nomIter = " << nomIter);
572 // Pour invalider totalement une iteration courante
573 CORBA::Long Option = 1 ;
574 return InvalideIterOption(nomIter, Option);
576 //=============================================================================
577 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
579 // Option = 0 : On ne supprime pas le fichier du maillage associe
580 // Option = 1 : On supprime le fichier du maillage associe
581 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
582 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
583 if (CORBA::is_nil(myIteration))
585 SALOME::ExceptionStruct es;
586 es.type = SALOME::BAD_PARAM;
587 es.text = "Invalid iteration";
588 throw SALOME::SALOME_Exception(es);
592 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
593 int numberOfIter = maListe->length();
594 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
596 std::string nomIterFille = std::string((*maListe)[NumeIter]);
597 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
598 InvalideIter(nomIterFille.c_str());
601 // On arrive ici pour une iteration sans fille
602 MESSAGE ( "Invalidation effective de " << nomIter );
603 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
604 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO);
605 for (; aIter->More(); aIter->Next())
607 SALOMEDS::SObject_var so = aIter->Value();
608 SALOMEDS::GenericAttribute_var anAttr;
609 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
610 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
611 std::string value (aCommentAttr->Value());
612 if(value == std::string("IterationHomard")) continue;
613 if(value == std::string("HypoHomard")) continue;
614 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
615 aStudyBuilder->RemoveObject(so);
618 int etat = myIteration->GetState();
621 SetEtatIter(nomIter,1);
622 const char * nomCas = myIteration->GetCaseName();
623 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
624 if (CORBA::is_nil(myCase))
626 SALOME::ExceptionStruct es;
627 es.type = SALOME::BAD_PARAM;
628 es.text = "Invalid case context";
629 throw SALOME::SALOME_Exception(es);
632 std::string nomDir = myIteration->GetDirName();
633 std::string nomFichier = myIteration->GetMeshFile();
634 std::string commande = "rm -rf " + std::string(nomDir);
635 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
636 MESSAGE ( "commande = " << commande );
637 if ((system(commande.c_str())) != 0)
639 SALOME::ExceptionStruct es;
640 es.type = SALOME::BAD_PARAM;
641 es.text = "The directory for the calculation cannot be cleared." ;
642 throw SALOME::SALOME_Exception(es);
645 // Suppression du maillage publie dans SMESH
646 std::string MeshName = myIteration->GetMeshName() ;
647 DeleteResultInSmesh(nomFichier, MeshName) ;
651 //=============================================================================
652 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
654 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
655 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
656 if (CORBA::is_nil(myIteration))
658 SALOME::ExceptionStruct es;
659 es.type = SALOME::BAD_PARAM;
660 es.text = "Invalid iteration";
661 throw SALOME::SALOME_Exception(es);
665 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
666 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO);
667 for (; aIter->More(); aIter->Next())
669 SALOMEDS::SObject_var so = aIter->Value();
670 SALOMEDS::GenericAttribute_var anAttr;
671 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
672 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
673 std::string value (aCommentAttr->Value());
674 /* MESSAGE("... value = " << value);*/
675 if( (value == std::string("logInfo")) || ( value == std::string("SummaryInfo")) )
677 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
678 aStudyBuilder->RemoveObject(so);
682 const char * nomCas = myIteration->GetCaseName();
683 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
684 if (CORBA::is_nil(myCase))
686 SALOME::ExceptionStruct es;
687 es.type = SALOME::BAD_PARAM;
688 es.text = "Invalid case context";
689 throw SALOME::SALOME_Exception(es);
692 const char* nomDir = myIteration->GetDirName();
693 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
694 commande += std::string(nomDir) + "/Liste.*info" ;
695 /* MESSAGE ( "commande = " << commande );*/
696 if ((system(commande.c_str())) != 0)
698 SALOME::ExceptionStruct es;
699 es.type = SALOME::BAD_PARAM;
700 es.text = "The directory for the calculation cannot be cleared." ;
701 throw SALOME::SALOME_Exception(es);
705 //=============================================================================
706 void HOMARD_Gen_i::InvalideYACS(const char* YACSName)
708 MESSAGE( "InvalideYACS : YACSName = " << YACSName );
709 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[YACSName];
710 if (CORBA::is_nil(myYACS))
712 SALOME::ExceptionStruct es;
713 es.type = SALOME::BAD_PARAM;
714 es.text = "Invalid schema YACS";
715 throw SALOME::SALOME_Exception(es);
719 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
720 SALOMEDS::ChildIterator_var aYACS = myStudy->NewChildIterator(aYACSSO);
721 for (; aYACS->More(); aYACS->Next())
723 SALOMEDS::SObject_var so = aYACS->Value();
724 SALOMEDS::GenericAttribute_var anAttr;
725 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
726 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
727 std::string value (aCommentAttr->Value());
728 if( value == std::string("xml") )
730 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
731 aStudyBuilder->RemoveObject(so);
734 std::string nomFichier = myYACS->GetXMLFile();
735 std::string commande = "rm -rf " + std::string(nomFichier) ;
736 MESSAGE ( "commande = " << commande );
737 if ((system(commande.c_str())) != 0)
739 SALOME::ExceptionStruct es;
740 es.type = SALOME::BAD_PARAM;
741 es.text = "The XML file for the schema YACS cannot be removed." ;
742 throw SALOME::SALOME_Exception(es);
746 //=============================================================================
747 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
749 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
750 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
751 if (CORBA::is_nil(myZone))
753 SALOME::ExceptionStruct es;
754 es.type = SALOME::BAD_PARAM;
755 es.text = "Invalid zone";
756 throw SALOME::SALOME_Exception(es);
759 HOMARD::listeHypo* maListe = myZone->GetHypo();
760 int numberOfHypo = maListe->length();
761 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
762 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
764 std::string nomHypo = std::string((*maListe)[NumeHypo]);
765 MESSAGE( ".. nomHypo = " << nomHypo );
766 InvalideHypo(nomHypo.c_str());
769 //=============================================================================
770 //=============================================================================
772 //=============================================================================
773 //=============================================================================
774 // Association de lien entre des structures identifiees par leurs noms
775 //=============================================================================
776 //=============================================================================
777 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
779 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
781 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
782 if (CORBA::is_nil(myCase))
784 SALOME::ExceptionStruct es;
785 es.type = SALOME::BAD_PARAM;
786 es.text = "Invalid case";
787 throw SALOME::SALOME_Exception(es);
791 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
792 if (CORBA::is_nil(myIteration))
794 SALOME::ExceptionStruct es;
795 es.type = SALOME::BAD_PARAM;
796 es.text = "Invalid iteration";
797 throw SALOME::SALOME_Exception(es);
801 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
802 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase)));
803 if (CORBA::is_nil(aCasSO))
805 SALOME::ExceptionStruct es;
806 es.type = SALOME::BAD_PARAM;
807 es.text = "Invalid case";
808 throw SALOME::SALOME_Exception(es);
812 aStudyBuilder->NewCommand();
813 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
814 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
815 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
816 aStudyBuilder->CommitCommand();
818 myCase->AddIteration(nomIter);
819 myIteration->SetCaseName(nomCas);
821 //=====================================================================================
822 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
824 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
826 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis];
827 ASSERT(!CORBA::is_nil(myHypo));
828 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
829 ASSERT(!CORBA::is_nil(aHypoSO));
831 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
832 ASSERT(!CORBA::is_nil(myZone));
833 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone)));
834 ASSERT(!CORBA::is_nil(aZoneSO));
836 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
838 aStudyBuilder->NewCommand();
840 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
841 aStudyBuilder->Addreference(aSubSO, aZoneSO);
843 aStudyBuilder->CommitCommand();
845 myZone->AddHypo(nomHypothesis);
846 myHypo->AddZone0(ZoneName, TypeUse);
848 //=============================================================================
849 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
851 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
853 // Verification de l'existence de l'hypothese
854 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
855 ASSERT(!CORBA::is_nil(myHypo));
856 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
857 ASSERT(!CORBA::is_nil(aHypoSO));
859 // Verification de l'existence de l'iteration
860 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
861 ASSERT(!CORBA::is_nil(myIteration));
862 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
863 ASSERT(!CORBA::is_nil(aIterSO));
865 // Gestion de l'arbre d'etudes
866 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
867 aStudyBuilder->NewCommand();
868 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
869 aStudyBuilder->Addreference(aSubSO, aHypoSO);
870 aStudyBuilder->CommitCommand();
873 myIteration->SetHypoName(nomHypo);
874 myHypo->LinkIteration(nomIter);
876 // On stocke les noms des champ a interpoler pour le futur controle de la donnee des pas de temps
877 myIteration->SupprFieldInterps() ;
878 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
879 int numberOfFieldsx2 = ListField->length();
880 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
882 std::string FieldName = std::string((*ListField)[iaux]) ;
883 myIteration->SetFieldInterp(FieldName.c_str()) ;
887 //=============================================================================
888 //=============================================================================
890 //=============================================================================
891 //=============================================================================
892 // Dissociation de lien entre des structures identifiees par leurs noms
893 //=============================================================================
894 //=============================================================================
895 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
897 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
899 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis];
900 ASSERT(!CORBA::is_nil(myHypo));
901 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
902 ASSERT(!CORBA::is_nil(aHypoSO));
904 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
905 ASSERT(!CORBA::is_nil(myZone));
906 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone)));
907 ASSERT(!CORBA::is_nil(aZoneSO));
909 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
911 SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(aHypoSO);
912 for (; it->More(); it->Next())
914 SALOMEDS::SObject_var aHypObj = it->Value();
915 SALOMEDS::SObject_var ptrObj;
916 if (aHypObj->ReferencedObject(ptrObj))
918 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
920 aStudyBuilder->NewCommand();
921 aStudyBuilder->RemoveObject(aHypObj);
922 aStudyBuilder->CommitCommand();
928 myZone->SupprHypo(nomHypothesis);
929 myHypo->SupprZone(ZoneName);
931 //=============================================================================
932 //=============================================================================
935 //=============================================================================
936 //=============================================================================
937 // Recuperation des listes
938 //=============================================================================
939 //=============================================================================
940 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
942 MESSAGE("GetAllBoundarysName");
945 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
946 ret->length(myStudyContext._mesBoundarys.size());
947 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
949 for (it = myStudyContext._mesBoundarys.begin();
950 it != myStudyContext._mesBoundarys.end(); it++)
952 ret[i++] = CORBA::string_dup((*it).first.c_str());
957 //=============================================================================
958 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
960 MESSAGE("GetAllCasesName");
963 HOMARD::listeCases_var ret = new HOMARD::listeCases;
964 ret->length(myStudyContext._mesCas.size());
965 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
967 for (it = myStudyContext._mesCas.begin();
968 it != myStudyContext._mesCas.end(); it++)
970 ret[i++] = CORBA::string_dup((*it).first.c_str());
975 //=============================================================================
976 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
978 MESSAGE("GetAllHypothesesName");
981 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
982 ret->length(myStudyContext._mesHypotheses.size());
983 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
985 for (it = myStudyContext._mesHypotheses.begin();
986 it != myStudyContext._mesHypotheses.end(); it++)
988 ret[i++] = CORBA::string_dup((*it).first.c_str());
993 //=============================================================================
994 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
996 MESSAGE("GetAllIterationsName");
999 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
1000 ret->length(myStudyContext._mesIterations.size());
1001 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
1003 for (it = myStudyContext._mesIterations.begin();
1004 it != myStudyContext._mesIterations.end(); it++)
1006 ret[i++] = CORBA::string_dup((*it).first.c_str());
1011 //=============================================================================
1012 HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName()
1014 MESSAGE("GetAllYACSsName");
1017 HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs;
1018 ret->length(myStudyContext._mesYACSs.size());
1019 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it;
1021 for (it = myStudyContext._mesYACSs.begin();
1022 it != myStudyContext._mesYACSs.end(); it++)
1024 ret[i++] = CORBA::string_dup((*it).first.c_str());
1029 //=============================================================================
1030 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
1032 MESSAGE("GetAllZonesName");
1035 HOMARD::listeZones_var ret = new HOMARD::listeZones;
1036 ret->length(myStudyContext._mesZones.size());
1037 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
1039 for (it = myStudyContext._mesZones.begin();
1040 it != myStudyContext._mesZones.end(); it++)
1042 ret[i++] = CORBA::string_dup((*it).first.c_str());
1047 //=============================================================================
1048 //=============================================================================
1050 //=============================================================================
1051 //=============================================================================
1052 // Recuperation des structures identifiees par leurs noms
1053 //=============================================================================
1054 //=============================================================================
1055 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
1057 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[nomBoundary];
1058 ASSERT(!CORBA::is_nil(myBoundary));
1059 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1061 //=============================================================================
1062 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
1064 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
1065 ASSERT(!CORBA::is_nil(myCase));
1066 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1068 //=============================================================================
1069 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
1071 HOMARD::HOMARD_Hypothesis_var myHypothesis = myStudyContext._mesHypotheses[nomHypothesis];
1072 ASSERT(!CORBA::is_nil(myHypothesis));
1073 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1075 //=============================================================================
1076 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
1078 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIterationation];
1079 ASSERT(!CORBA::is_nil(myIteration));
1080 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1082 //=============================================================================
1083 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS)
1085 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
1086 ASSERT(!CORBA::is_nil(myYACS));
1087 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
1089 //=============================================================================
1090 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
1092 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
1093 ASSERT(!CORBA::is_nil(myZone));
1094 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1096 //=============================================================================
1097 //=============================================================================
1099 //=============================================================================
1100 //=============================================================================
1102 //=============================================================================
1103 //=============================================================================
1104 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)
1106 INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1107 INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
1112 if ( _PublisMeshIN != 0 ) option = 2 ;
1113 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option) ;
1114 myCase->SetDirName(DirName) ;
1116 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1120 //=============================================================================
1121 //=============================================================================
1123 //=============================================================================
1124 //=============================================================================
1125 // Recuperation des structures par le contexte
1126 //=============================================================================
1127 //=============================================================================
1128 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1130 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
1131 ASSERT(!CORBA::is_nil(myCase));
1133 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1134 ASSERT(!CORBA::is_nil(myIteration));
1136 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1138 //=============================================================================
1139 //=============================================================================
1141 //=============================================================================
1142 //=============================================================================
1143 // Nouvelles structures
1144 //=============================================================================
1145 //=============================================================================
1146 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1148 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1149 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1150 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1151 return aCase._retn();
1153 //=============================================================================
1154 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1156 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1157 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1158 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1159 return aHypo._retn();
1161 //=============================================================================
1162 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1164 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1165 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1166 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1167 return aIter._retn();
1169 //=============================================================================
1170 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1172 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1173 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1174 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1175 return aBoundary._retn();
1177 //=============================================================================
1178 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1180 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1181 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1182 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1183 return aZone._retn();
1185 //=============================================================================
1186 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS()
1188 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1189 HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine);
1190 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this());
1191 return aYACS._retn();
1193 //=============================================================================
1194 //=============================================================================
1196 //=============================================================================
1197 //=============================================================================
1198 // Creation des structures identifiees par leurs noms
1199 //=============================================================================
1200 //=============================================================================
1201 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1203 // Creation d'un cas initial
1204 // nomCas : nom du cas a creer
1205 // MeshName, MeshFile : nom et fichier du maillage correspondant
1208 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1211 if ( _PublisMeshIN != 0 ) option = 2 ;
1212 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option) ;
1214 // Valeurs par defaut des filtrages
1215 myCase->SetPyram(0);
1217 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1219 //=============================================================================
1220 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1222 // nomCas : nom du cas a creer
1223 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1226 INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1227 std::string nomDirWork = getenv("PWD") ;
1230 // A. Decodage du point de reprise
1231 // A.1. Controle du repertoire de depart de l'iteration
1232 codret = CHDIR(DirNameStart) ;
1235 SALOME::ExceptionStruct es;
1236 es.type = SALOME::BAD_PARAM;
1237 es.text = "The directory of the iteration does not exist.";
1238 throw SALOME::SALOME_Exception(es);
1241 // A.2. Reperage des fichiers du repertoire de reprise
1242 std::string file_configuration = "" ;
1243 std::string file_maillage_homard = "" ;
1247 struct dirent *dirp;
1248 dp = opendir(DirNameStart);
1249 while ( (dirp = readdir(dp)) != NULL )
1251 std::string file_name(dirp->d_name);
1252 // MESSAGE ( file_name );
1253 bilan = file_name.find("HOMARD.Configuration.") ;
1254 if ( bilan != string::npos ) { file_configuration = file_name ; }
1255 bilan = file_name.find("maill.") ;
1256 if ( bilan != string::npos )
1258 bilan = file_name.find(".hom.med") ;
1259 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1264 HANDLE hFind = INVALID_HANDLE_VALUE;
1265 WIN32_FIND_DATA ffd;
1266 hFind = FindFirstFile(DirNameStart, &ffd);
1267 if (INVALID_HANDLE_VALUE != hFind) {
1268 while (FindNextFile(hFind, &ffd) != 0) {
1269 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1270 std::string file_name(ffd.cFileName);
1271 bilan = file_name.find("HOMARD.Configuration.") ;
1272 if ( bilan != string::npos ) { file_configuration = file_name ; }
1273 bilan = file_name.find("maill.") ;
1274 if ( bilan != string::npos )
1276 bilan = file_name.find(".hom.med") ;
1277 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1283 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1284 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1286 if ( ( file_configuration == "" ) || ( file_maillage_homard == "" ) )
1288 SALOME::ExceptionStruct es;
1289 es.type = SALOME::BAD_PARAM;
1291 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1292 else { text = "The HOMARD mesh file cannot be found." ; }
1293 es.text = CORBA::string_dup(text.c_str());
1294 throw SALOME::SALOME_Exception(es);
1297 // B. Lecture du fichier de configuration
1298 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1305 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1306 std::ifstream fichier( file_configuration.c_str() );
1307 if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
1309 std::string ligne; // variable contenant chaque ligne lue
1310 std::string mot_cle;
1311 std::string argument;
1313 // cette boucle sur les lignes s'arr??te d??s qu'une erreur de lecture survient
1314 while ( std::getline( fichier, ligne ) )
1316 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1317 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1318 ligne_bis >> mot_cle ;
1319 // B.2. Des valeurs entieres : le second bloc de la ligne
1320 if ( mot_cle == "NumeIter" )
1322 ligne_bis >> NumeIter ;
1325 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1326 else if ( ( mot_cle == "TypeConf" ) || ( mot_cle == "TypeElem" ) )
1328 ligne_bis >> argument ;
1330 if ( mot_cle == "TypeConf" )
1332 if ( argument == "conforme" ) { TypeConf = 1 ; }
1333 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1334 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1335 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1337 else if ( mot_cle == "TypeElem" )
1339 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1340 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1343 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1344 // il faut les supprimer
1345 else if ( ( mot_cle == "CCNoMNP1" ) || ( mot_cle == "CCMaiNP1" ) )
1347 ligne_bis >> argument ;
1348 if ( argument[0] == '"' ) { decalage = 1 ; }
1349 else { decalage = 0 ; }
1350 size_t size = argument.size() + 1 - 2*decalage ;
1352 if ( mot_cle == "CCNoMNP1" )
1354 MeshName = new char[ size ];
1355 strncpy( MeshName, argument.c_str()+decalage, size );
1356 MeshName[size-1] = '\0' ;
1358 else if ( mot_cle == "CCMaiNP1" )
1360 MeshFile = new char[ size ];
1361 strncpy( MeshFile, argument.c_str()+decalage, size );
1362 MeshFile[size-1] = '\0' ;
1366 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1367 MESSAGE ( "==> MeshName : " << MeshName ) ;
1368 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1369 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1370 MESSAGE ( "==> Pyram : " << Pyram ) ;
1374 SALOME::ExceptionStruct es;
1375 es.type = SALOME::BAD_PARAM;
1376 std::string text = "The configuration file cannot be read." ;
1377 es.text = CORBA::string_dup(text.c_str());
1378 throw SALOME::SALOME_Exception(es);
1381 // C. Creation effective du cas
1384 if ( _PublisMeshIN != 0 ) option = 2 ;
1385 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, option) ;
1387 // D. Parametrages lus dans le fichier de configuration
1389 myCase->SetConfType (TypeConf) ;
1390 myCase->SetExtType (TypeExt) ;
1391 myCase->SetPyram (Pyram) ;
1393 // E. Copie du fichier de maillage homard
1394 // E.1. Repertoire associe au cas
1395 char* nomDirCase = myCase->GetDirName() ;
1396 // E.2. Repertoire associe a l'iteration de ce cas
1398 IterName = myCase->GetIter0Name() ;
1399 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1400 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1401 Iter->SetDirNameLoc(nomDirIter);
1402 std::string nomDirIterTotal ;
1403 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1405 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1407 if (_mkdir(nomDirIterTotal.c_str()) != 0)
1410 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1411 SALOME::ExceptionStruct es;
1412 es.type = SALOME::BAD_PARAM;
1413 std::string text = "The directory for the computation cannot be created." ;
1414 es.text = CORBA::string_dup(text.c_str());
1415 throw SALOME::SALOME_Exception(es);
1417 // E.3. Copie du maillage HOMARD au format MED
1418 codret = CHDIR(DirNameStart) ;
1419 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1420 MESSAGE ( "commande : " << commande ) ;
1421 codret = system(commande.c_str()) ;
1422 MESSAGE ( "codret : " << codret ) ;
1425 SALOME::ExceptionStruct es;
1426 es.type = SALOME::BAD_PARAM;
1427 es.text = "The starting point for the case cannot be copied into the working directory.";
1428 throw SALOME::SALOME_Exception(es);
1437 CHDIR(nomDirWork.c_str());
1438 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1440 //=============================================================================
1441 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1443 // nomCas : nom du cas a creer
1444 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1447 INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1449 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1451 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1452 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1454 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1456 //=============================================================================
1457 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1459 // nomCas : nom du cas a creer
1460 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1461 // Number : numero de l'iteration de depart
1464 INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1467 SALOME::ExceptionStruct es;
1468 es.type = SALOME::BAD_PARAM;
1469 es.text = "The number of iteration must be positive.";
1470 throw SALOME::SALOME_Exception(es);
1474 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1476 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1477 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1479 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1481 //=============================================================================
1482 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1484 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1485 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1486 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1489 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1490 std::string nomDirWork = getenv("PWD") ;
1491 std::string DirNameStartIter ;
1493 int NumeIterMax = -1 ;
1495 // A.1. Controle du repertoire de depart du cas
1496 codret = CHDIR(DirNameStart) ;
1499 SALOME::ExceptionStruct es;
1500 es.type = SALOME::BAD_PARAM;
1501 es.text = "The directory of the case for the pursuit does not exist.";
1502 throw SALOME::SALOME_Exception(es);
1505 // A.2. Reperage des sous-repertoire du repertoire de reprise
1506 bool existe = false ;
1509 struct dirent *dirp;
1510 dp = opendir(DirNameStart);
1511 while ( (dirp = readdir(dp)) != NULL ) {
1512 std::string DirName_1(dirp->d_name);
1514 HANDLE hFind = INVALID_HANDLE_VALUE;
1515 WIN32_FIND_DATA ffd;
1516 hFind = FindFirstFile(DirNameStart, &ffd);
1517 if (INVALID_HANDLE_VALUE != hFind) {
1518 while (FindNextFile(hFind, &ffd) != 0) {
1519 std::string DirName_1 = "";
1520 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1521 DirName_1 = std::string(ffd.cFileName);
1524 if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) )
1526 if ( CHDIR(DirName_1.c_str()) == 0 )
1528 // On cherche le fichier de configuration dans ce sous-repertoire
1529 codret = CHDIR(DirNameStart);
1532 struct dirent *dirp_1;
1533 dp_1 = opendir(DirName_1.c_str()) ;
1534 while ( (dirp_1 = readdir(dp_1)) != NULL )
1536 std::string file_name_1(dirp_1->d_name);
1538 HANDLE hFind1 = INVALID_HANDLE_VALUE;
1539 WIN32_FIND_DATA ffd1;
1540 hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1);
1541 while (FindNextFile(hFind1, &ffd1) != 0)
1543 if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1544 std::string file_name_1(ffd1.cFileName);
1546 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1547 if ( bilan != string::npos )
1549 // Decodage du fichier pour trouver le numero d'iteration
1550 CHDIR(DirName_1.c_str()) ;
1552 std::ifstream fichier( file_name_1.c_str() );
1553 if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
1556 std::string ligne; // variable contenant chaque ligne lue
1557 std::string mot_cle;
1558 // cette boucle sur les lignes s'arr??te d??s qu'une erreur de lecture survient
1559 while ( std::getline( fichier, ligne ) )
1561 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1562 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1563 ligne_bis >> mot_cle ;
1564 if ( mot_cle == "NumeIter" )
1566 ligne_bis >> NumeIter ;
1568 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1569 if ( Number == - 1 )
1571 if ( NumeIter >= NumeIterMax )
1573 NumeIterMax = NumeIter ;
1574 DirNameStartIter = DirName_1 ;
1579 if ( NumeIter == Number )
1581 DirNameStartIter = DirName_1 ;
1591 SALOME::ExceptionStruct es;
1592 es.type = SALOME::BAD_PARAM;
1593 std::string text = "The configuration file cannot be read." ;
1594 es.text = CORBA::string_dup(text.c_str());
1595 throw SALOME::SALOME_Exception(es);
1597 CHDIR(DirNameStart) ;
1599 if ( existe ) { break ; }
1606 if ( existe ) { break ; }
1615 CHDIR(nomDirWork.c_str());
1617 if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) )
1619 SALOME::ExceptionStruct es;
1620 es.type = SALOME::BAD_PARAM;
1621 es.text = "The directory of the iteration does not exist.";
1622 throw SALOME::SALOME_Exception(es);
1626 return DirNameStartIter ;
1628 //=============================================================================
1629 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)
1631 // nomCas : nom du cas a creer
1632 // MeshName, MeshFile : nom et fichier du maillage correspondant
1633 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1634 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1635 // -1 : le maillage n'est pas fourni
1636 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1637 // Option : multiple de nombres premiers
1638 // 1 : aucune option
1639 // x2 : publication du maillage dans SMESH
1641 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1642 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1643 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1649 // A.2. Controle du nom :
1650 if ((myStudyContext._mesCas).find(nomCas)!=(myStudyContext._mesCas).end())
1652 SALOME::ExceptionStruct es;
1653 es.type = SALOME::BAD_PARAM;
1654 es.text = "This case has already been defined.";
1655 throw SALOME::SALOME_Exception(es);
1659 // A.3. Controle du fichier du maillage
1660 int existeMeshFile ;
1661 if ( MeshOption >= 0 )
1663 existeMeshFile = MEDFileExist ( MeshFile ) ;
1664 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1665 if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) )
1667 SALOME::ExceptionStruct es;
1668 es.type = SALOME::BAD_PARAM;
1669 es.text = "The mesh file does not exist.";
1670 throw SALOME::SALOME_Exception(es);
1674 else { existeMeshFile = 0 ; }
1676 // B. Creation de l'objet cas et publication
1677 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1678 HOMARD::HOMARD_Cas_var myCase = newCase();
1679 myCase->SetName(nomCas);
1680 SALOMEDS::SObject_var aSO;
1681 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myCase, nomCas);
1682 myStudyContext._mesCas[nomCas] = myCase;
1684 // C. Caracteristiques du maillage
1685 if ( existeMeshFile != 0 )
1687 // Les valeurs extremes des coordonnees
1688 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1689 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1690 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1691 if (LesExtremes.size()!=10) { return 0; }
1693 for (int i =0 ; i< LesExtremes.size() ; i++)
1694 aSeq[i]=LesExtremes[i] ;
1695 myCase->SetBoundingBox(aSeq) ;
1697 // MESSAGE ( "CreateCase0 : Les groupes" );
1698 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1699 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1700 aSeqGroupe->length(LesGroupes.size());
1701 std::set<std::string>::const_iterator it ;
1703 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1704 aSeqGroupe[i++]=(*it).c_str() ;
1705 myCase->SetGroups(aSeqGroupe) ;
1708 // D. L'iteration initiale du cas
1709 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1710 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1711 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1713 std::string NomIteration = std::string(MeshName) ;
1714 while ( (myStudyContext._mesIterations).find(NomIteration) != (myStudyContext._mesIterations.end()) )
1716 std::ostringstream nom;
1717 nom << MeshName << monNum;
1718 NomIteration = nom.str();
1721 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1723 // D.2. Creation de l'iteration
1724 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1725 myStudyContext._mesIterations[NomIteration] = anIter;
1726 anIter->SetName(NomIteration.c_str());
1727 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1729 // D.4. Maillage correspondant
1730 if ( existeMeshFile != 0 )
1732 anIter->SetMeshFile(MeshFile);
1733 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1735 anIter->SetMeshName(MeshName);
1737 // D.5. Numero d'iteration
1738 anIter->SetNumber(NumeIter);
1741 SetEtatIter(NomIteration.c_str(), -NumeIter);
1744 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1746 //=============================================================================
1747 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1749 INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1752 // A. Controle du nom :
1753 if ((myStudyContext._mesHypotheses).find(nomHypothesis) != (myStudyContext._mesHypotheses).end())
1755 SALOME::ExceptionStruct es;
1756 es.type = SALOME::BAD_PARAM;
1757 es.text = "This hypothesis has already been defined.";
1758 throw SALOME::SALOME_Exception(es);
1762 // B. Creation de l'objet
1763 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1764 if (CORBA::is_nil(myHypothesis))
1766 SALOME::ExceptionStruct es;
1767 es.type = SALOME::BAD_PARAM;
1768 es.text = "Unable to create the hypothesis";
1769 throw SALOME::SALOME_Exception(es);
1772 myHypothesis->SetName(nomHypothesis);
1774 // C. Enregistrement
1775 myStudyContext._mesHypotheses[nomHypothesis] = myHypothesis;
1777 SALOMEDS::SObject_var aSO;
1778 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myHypothesis, nomHypothesis);
1780 // D. Valeurs par defaut des options avancees
1781 myHypothesis->SetNivMax(-1);
1782 myHypothesis->SetDiamMin(-1.0);
1783 myHypothesis->SetAdapInit(0);
1784 myHypothesis->SetExtraOutput(1);
1786 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1789 //=============================================================================
1790 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1791 //=============================================================================
1793 INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1796 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterParent];
1797 if (CORBA::is_nil(myIterationParent))
1799 SALOME::ExceptionStruct es;
1800 es.type = SALOME::BAD_PARAM;
1801 es.text = "The parent iteration is not defined.";
1802 throw SALOME::SALOME_Exception(es);
1806 const char* nomCas = myIterationParent->GetCaseName();
1807 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1808 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
1809 if (CORBA::is_nil(myCase))
1811 SALOME::ExceptionStruct es;
1812 es.type = SALOME::BAD_PARAM;
1813 es.text = "Invalid case context";
1814 throw SALOME::SALOME_Exception(es);
1817 const char* nomDirCase = myCase->GetDirName();
1819 // Controle du nom :
1820 if ((myStudyContext._mesIterations).find(NomIteration)!=(myStudyContext._mesIterations).end())
1822 SALOME::ExceptionStruct es;
1823 es.type = SALOME::BAD_PARAM;
1824 es.text = "This iteration has already been defined.";
1825 throw SALOME::SALOME_Exception(es);
1829 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1830 if (CORBA::is_nil(myIteration))
1832 SALOME::ExceptionStruct es;
1833 es.type = SALOME::BAD_PARAM;
1834 es.text = "Unable to create the iteration";
1835 throw SALOME::SALOME_Exception(es);
1838 myStudyContext._mesIterations[std::string(NomIteration)] = myIteration;
1839 // Nom de l'iteration et du maillage
1840 myIteration->SetName(NomIteration);
1841 myIteration->SetMeshName(NomIteration);
1842 myIteration->SetState(1);
1844 int numero = myIterationParent->GetNumber() + 1;
1845 myIteration->SetNumber(numero);
1847 // Nombre d'iterations deja connues pour le cas, permettant
1848 // la creation d'un sous-repertoire unique
1849 int nbitercase = myCase->GetNumberofIter();
1850 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1851 myIteration->SetDirNameLoc(nomDirIter);
1853 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1854 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1855 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1856 // situation la plus frequente.
1857 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1858 // le nombre d'iterations du cas permet d'eviter les collisions.
1860 if ( nbitercase < 100 ) { jaux = 2 ; }
1861 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1862 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1863 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1865 std::ostringstream iaux ;
1866 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1867 std::stringstream MeshFile;
1868 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1869 myIteration->SetMeshFile(MeshFile.str().c_str());
1871 // Association avec le cas
1872 std::string label = "IterationHomard_" + std::string(nomIterParent);
1873 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1874 // Lien avec l'iteration precedente
1875 myIterationParent->LinkNextIteration(NomIteration);
1876 myIteration->SetIterParentName(nomIterParent);
1877 // Gestion de l'arbre d'etudes
1878 SALOMEDS::SObject_var aIterSOParent = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIterationParent)));
1879 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
1880 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
1881 aStudyBuilder->NewCommand();
1882 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
1883 aStudyBuilder->Addreference(aSubSO, aIterSOParent);
1884 aStudyBuilder->CommitCommand();
1886 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1888 //=============================================================================
1889 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1891 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1894 // Controle du nom :
1895 if ((myStudyContext._mesBoundarys).find(BoundaryName)!=(myStudyContext._mesBoundarys).end())
1897 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1898 SALOME::ExceptionStruct es;
1899 es.type = SALOME::BAD_PARAM;
1900 es.text = "This boundary has already been defined";
1901 throw SALOME::SALOME_Exception(es);
1905 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1906 myBoundary->SetName(BoundaryName);
1907 myBoundary->SetType(BoundaryType);
1909 myStudyContext._mesBoundarys[BoundaryName] = myBoundary;
1911 SALOMEDS::SObject_var aSO;
1912 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myBoundary, BoundaryName);
1914 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1916 //=============================================================================
1917 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1919 INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << ", MeshName = " << MeshName );
1920 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1921 myBoundary->SetMeshFile( MeshFile ) ;
1922 myBoundary->SetMeshName( MeshName ) ;
1924 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1926 //=============================================================================
1927 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1928 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1929 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1930 CORBA::Double Rayon)
1932 INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1934 SALOME::ExceptionStruct es;
1937 { es.text = "The radius must be positive." ;
1939 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1940 if ( daux < 0.0000001 )
1941 { es.text = "The axis must be a non 0 vector." ;
1945 es.type = SALOME::BAD_PARAM;
1946 throw SALOME::SALOME_Exception(es);
1950 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1951 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1953 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1955 //=============================================================================
1956 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1957 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1958 CORBA::Double Rayon)
1960 INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1962 SALOME::ExceptionStruct es;
1965 { es.text = "The radius must be positive." ;
1969 es.type = SALOME::BAD_PARAM;
1970 throw SALOME::SALOME_Exception(es);
1974 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1975 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1977 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1979 //=============================================================================
1980 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1981 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1982 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1984 INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1986 SALOME::ExceptionStruct es;
1988 if ( Angle <= 0.0 || Angle >= 90.0 )
1989 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1991 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1992 if ( daux < 0.0000001 )
1993 { es.text = "The axis must be a non 0 vector." ;
1997 es.type = SALOME::BAD_PARAM;
1998 throw SALOME::SALOME_Exception(es);
2002 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
2003 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
2005 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2007 //=============================================================================
2008 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
2009 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
2010 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
2012 INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
2014 SALOME::ExceptionStruct es;
2016 if ( Rayon1 < 0.0 || Rayon2 < 0.0 )
2017 { es.text = "The radius must be positive." ;
2019 double daux = fabs(Rayon2-Rayon1) ;
2020 if ( daux < 0.0000001 )
2021 { es.text = "The radius must be different." ;
2023 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
2024 if ( daux < 0.0000001 )
2025 { es.text = "The centers must be different." ;
2029 es.type = SALOME::BAD_PARAM;
2030 throw SALOME::SALOME_Exception(es);
2034 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
2035 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
2037 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2039 //=============================================================================
2040 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryTorus(const char* BoundaryName,
2041 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2042 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2043 CORBA::Double RayonRev, CORBA::Double RayonPri)
2045 INFOS ("CreateBoundaryTorus : BoundaryName = " << BoundaryName ) ;
2047 SALOME::ExceptionStruct es;
2049 if ( ( RayonRev <= 0.0 ) || ( RayonPri <= 0.0 ) )
2050 { es.text = "The radius must be positive." ;
2052 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2053 if ( daux < 0.0000001 )
2054 { es.text = "The axis must be a non 0 vector." ;
2058 es.type = SALOME::BAD_PARAM;
2059 throw SALOME::SALOME_Exception(es);
2063 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 5) ;
2064 myBoundary->SetTorus( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, RayonRev, RayonPri ) ;
2066 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2068 //=============================================================================
2069 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
2071 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
2074 // Controle du nom :
2075 if ((myStudyContext._mesZones).find(ZoneName)!=(myStudyContext._mesZones).end())
2077 SALOME::ExceptionStruct es;
2078 es.type = SALOME::BAD_PARAM;
2079 es.text = "This zone has already been defined";
2080 throw SALOME::SALOME_Exception(es);
2084 HOMARD::HOMARD_Zone_var myZone = newZone();
2085 myZone->SetName(ZoneName);
2086 myZone->SetType(ZoneType);
2088 myStudyContext._mesZones[ZoneName] = myZone;
2090 SALOMEDS::SObject_var aSO;
2091 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myZone, ZoneName);
2093 return HOMARD::HOMARD_Zone::_duplicate(myZone);
2095 //=============================================================================
2096 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
2097 CORBA::Double Xmini, CORBA::Double Xmaxi,
2098 CORBA::Double Ymini, CORBA::Double Ymaxi,
2099 CORBA::Double Zmini, CORBA::Double Zmaxi)
2101 INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ;
2103 SALOME::ExceptionStruct es;
2105 if ( Xmini > Xmaxi )
2106 { es.text = "The X coordinates are not coherent." ;
2108 if ( Ymini > Ymaxi )
2109 { es.text = "The Y coordinates are not coherent." ;
2111 if ( Zmini > Zmaxi )
2112 { es.text = "The Z coordinates are not coherent." ;
2116 es.type = SALOME::BAD_PARAM;
2117 throw SALOME::SALOME_Exception(es);
2121 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
2122 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2124 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2126 //=============================================================================
2127 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
2128 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
2130 INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
2132 SALOME::ExceptionStruct es;
2135 { es.text = "The radius must be positive." ;
2139 es.type = SALOME::BAD_PARAM;
2140 throw SALOME::SALOME_Exception(es);
2144 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
2145 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
2147 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2149 //=============================================================================
2150 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
2151 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2152 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2153 CORBA::Double Rayon, CORBA::Double Haut)
2155 INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
2157 SALOME::ExceptionStruct es;
2160 { es.text = "The radius must be positive." ;
2162 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2163 if ( daux < 0.0000001 )
2164 { es.text = "The axis must be a non 0 vector." ;
2167 { es.text = "The height must be positive." ;
2171 es.type = SALOME::BAD_PARAM;
2172 throw SALOME::SALOME_Exception(es);
2176 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
2177 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
2179 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2181 //=============================================================================
2182 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
2183 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2184 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2185 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
2187 INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ;
2189 SALOME::ExceptionStruct es;
2191 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2192 { es.text = "The radius must be positive." ;
2194 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2195 if ( daux < 0.0000001 )
2196 { es.text = "The axis must be a non 0 vector." ;
2199 { es.text = "The height must be positive." ;
2201 if ( Rayon <= Rayonint )
2202 { es.text = "The external radius must be higher than the internal radius." ;
2206 es.type = SALOME::BAD_PARAM;
2207 throw SALOME::SALOME_Exception(es);
2211 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
2212 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
2214 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2216 //=============================================================================
2217 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
2218 CORBA::Double Umini, CORBA::Double Umaxi,
2219 CORBA::Double Vmini, CORBA::Double Vmaxi,
2222 INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
2223 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
2224 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
2225 // MESSAGE ("Orient = " << Orient ) ;
2227 SALOME::ExceptionStruct es;
2229 if ( Umini > Umaxi )
2230 { es.text = "The first coordinates are not coherent." ;
2232 if ( Vmini > Vmaxi )
2233 { es.text = "The second coordinates are not coherent." ;
2235 if ( Orient < 1 || Orient > 3 )
2236 { es.text = "The orientation must be 1, 2 or 3." ;
2240 es.type = SALOME::BAD_PARAM;
2241 throw SALOME::SALOME_Exception(es);
2245 double Xmini, Xmaxi ;
2246 double Ymini, Ymaxi ;
2247 double Zmini, Zmaxi ;
2255 else if ( Orient == 2 )
2262 else if ( Orient == 3 )
2269 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2271 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2272 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2274 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2276 //=============================================================================
2277 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2278 CORBA::Double Ucentre, CORBA::Double Vcentre,
2279 CORBA::Double Rayon,
2282 INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2284 SALOME::ExceptionStruct es;
2287 { es.text = "The radius must be positive." ;
2289 if ( Orient < 1 || Orient > 3 )
2290 { es.text = "The orientation must be 1, 2 or 3." ;
2294 es.type = SALOME::BAD_PARAM;
2295 throw SALOME::SALOME_Exception(es);
2303 { Xcentre = Ucentre ;
2306 else if ( Orient == 2 )
2309 Zcentre = Vcentre ; }
2310 else if ( Orient == 3 )
2311 { Xcentre = Vcentre ;
2313 Zcentre = Ucentre ; }
2314 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2316 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2317 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2319 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2321 //=============================================================================
2322 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2323 CORBA::Double Ucentre, CORBA::Double Vcentre,
2324 CORBA::Double Rayon, CORBA::Double Rayonint,
2327 INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2329 SALOME::ExceptionStruct es;
2331 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2332 { es.text = "The radius must be positive." ;
2334 if ( Orient < 1 || Orient > 3 )
2335 { es.text = "The orientation must be 1, 2 or 3." ;
2337 if ( Rayon <= Rayonint )
2338 { es.text = "The external radius must be higher than the internal radius." ;
2342 es.type = SALOME::BAD_PARAM;
2343 throw SALOME::SALOME_Exception(es);
2351 { Xcentre = Ucentre ;
2354 else if ( Orient == 2 )
2357 Zcentre = Vcentre ; }
2358 else if ( Orient == 3 )
2359 { Xcentre = Vcentre ;
2361 Zcentre = Ucentre ; }
2362 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2364 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2365 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2367 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2369 //=============================================================================
2370 //=============================================================================
2375 //=============================================================================
2376 //=============================================================================
2377 // Traitement d'une iteration
2378 // etatMenage = 1 : destruction du repertoire d'execution
2379 // modeHOMARD = 1 : adaptation
2380 // != 1 : information avec les options modeHOMARD
2381 // Option1 >0 : appel depuis python
2382 // <0 : appel depuis GUI
2383 // Option2 : multiple de nombres premiers
2384 // 1 : aucune option
2385 // x2 : publication du maillage dans SMESH
2386 //=============================================================================
2387 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2389 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2394 // A.1. L'objet iteration
2395 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIteration];
2396 ASSERT(!CORBA::is_nil(myIteration));
2398 // A.2. Controle de la possibilite d'agir
2399 // A.2.1. Etat de l'iteration
2400 int etat = myIteration->GetState();
2401 MESSAGE ( "etat = "<<etat );
2402 // A.2.2. On ne calcule pas l'iteration initiale, ni une iteration deja calculee
2403 if ( modeHOMARD == 1 )
2407 SALOME::ExceptionStruct es;
2408 es.type = SALOME::BAD_PARAM;
2409 es.text = "This iteration is the first of the case and cannot be computed.";
2410 throw SALOME::SALOME_Exception(es);
2413 else if ( ( etat == 2 ) & ( modeHOMARD == 1 ) )
2415 SALOME::ExceptionStruct es;
2416 es.type = SALOME::BAD_PARAM;
2417 es.text = "This iteration is already computed.";
2418 throw SALOME::SALOME_Exception(es);
2422 // A.2.3. On n'analyse pas une iteration non calculee
2427 SALOME::ExceptionStruct es;
2428 es.type = SALOME::BAD_PARAM;
2429 es.text = "This iteration is not computed.";
2430 throw SALOME::SALOME_Exception(es);
2435 // A.3. Numero de l'iteration
2436 // siterp1 : numero de l'iteration a traiter
2438 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2439 // Ou si information :
2441 int NumeIter = myIteration->GetNumber();
2442 std::string siterp1 ;
2443 std::stringstream saux1 ;
2445 siterp1 = saux1.str() ;
2446 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2449 if ( modeHOMARD==1 )
2451 std::stringstream saux0 ;
2452 int iaux = max(0, NumeIter-1) ;
2454 siter = saux0.str() ;
2455 if (NumeIter < 11) { siter = "0" + siter ; }
2458 { siter = siterp1 ; }
2461 const char* nomCas = myIteration->GetCaseName();
2462 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2463 ASSERT(!CORBA::is_nil(myCase));
2465 // B. Les repertoires
2466 // B.1. Le repertoire courant
2467 std::string nomDirWork = getenv("PWD") ;
2468 // B.2. Le sous-repertoire de l'iteration a traiter
2469 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2470 MESSAGE( ". DirCompute = " << DirCompute );
2472 // C. Le fichier des messages
2473 // C.1. Le deroulement de l'execution de HOMARD
2474 std::string LogFile = DirCompute ;
2475 LogFile += "/Liste" ;
2476 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2478 MESSAGE (". LogFile = " << LogFile);
2479 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2480 // C.2. Le bilan de l'analyse du maillage
2481 std::string FileInfo = DirCompute ;
2483 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2485 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2486 else { FileInfo += "info_ap" ; }
2488 FileInfo += "." + siterp1 + ".bilan" ;
2489 myIteration->SetFileInfo(FileInfo.c_str());
2491 // D. On passe dans le repertoire de l'iteration a calculer
2492 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2495 // E. Les donnees de l'execution HOMARD
2496 // E.1. L'objet du texte du fichier de configuration
2497 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2498 myDriver->TexteInit(DirCompute, LogFile, _Langue);
2500 // E.2. Le maillage associe a l'iteration
2501 const char* NomMesh = myIteration->GetMeshName();
2502 MESSAGE ( ". NomMesh = " << NomMesh );
2503 const char* MeshFile = myIteration->GetMeshFile();
2504 MESSAGE ( ". MeshFile = " << MeshFile );
2506 // E.3. Les donnees du traitement HOMARD
2508 if ( modeHOMARD == 1 )
2511 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2512 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2513 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2517 InvalideIterInfo(NomIteration);
2518 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2520 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2521 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2522 myDriver->CreeFichierDonn();
2525 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2526 DriverTexteBoundary(myCase, myDriver) ;
2528 // E.5. Ecriture du texte dans le fichier
2529 MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<<codret );
2531 { myDriver->CreeFichier(); }
2535 int codretexec = 12 ;
2538 codretexec = myDriver->ExecuteHomard(Option1);
2540 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2541 // En mode adaptation, on ajuste l'etat de l'iteration
2542 if ( modeHOMARD == 1 )
2544 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2545 else { SetEtatIter(NomIteration,1); }
2546 // GERALD -- QMESSAGE BOX
2550 // H. Gestion des resultats
2553 std::string Commentaire ;
2554 // H.1. Le fichier des messages, dans tous les cas
2555 Commentaire = "log" ;
2556 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2557 else { Commentaire += "Info" ; }
2558 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2560 // H.2. Si tout s'est bien passe :
2561 if (codretexec == 0)
2563 // H.2.1. Le fichier de bilan
2564 Commentaire = "Summary" ;
2565 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2566 else { Commentaire += "Info" ; }
2567 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2568 // H.2.2. Le fichier de maillage obtenu
2569 if ( modeHOMARD == 1 )
2571 std::stringstream saux0 ;
2572 Commentaire = "Mesh" ;
2573 Commentaire += " " + siterp1 ;
2574 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2575 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2578 // H.3 Message d'erreur
2579 if (codretexec != 0)
2581 std::string text = "" ;
2582 // Message d'erreur en cas de probleme en adaptation
2583 if ( modeHOMARD == 1 )
2585 text = "Error during the adaptation.\n" ;
2586 bool stopvu = false ;
2587 std::ifstream fichier( LogFile.c_str() );
2588 if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
2590 std::string ligne; // variable contenant chaque ligne lue
2591 while ( std::getline( fichier, ligne ) )
2595 { text += ligne+ "\n"; }
2598 int position = ligne.find( "===== HOMARD ===== STOP =====" ) ;
2599 if ( position > 0 ) { stopvu = true ; }
2604 text += "\n\nSee the file " + LogFile + "\n" ;
2606 SALOME::ExceptionStruct es;
2607 es.type = SALOME::BAD_PARAM;
2608 es.text = CORBA::string_dup(text.c_str());
2609 throw SALOME::SALOME_Exception(es);
2611 // En mode information, on force le succes pour pouvoir consulter le fichier log
2612 if ( modeHOMARD != 1 ) { codretexec = 0 ; }
2616 // I. Menage et retour dans le repertoire du cas
2620 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2622 CHDIR(nomDirWork.c_str());
2627 //=============================================================================
2628 // Calcul d'une iteration : partie specifique a l'adaptation
2629 //=============================================================================
2630 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)
2632 MESSAGE ( "ComputeAdap" );
2637 // Numero de l'iteration
2638 int NumeIter = myIteration->GetNumber();
2639 std::stringstream saux0 ;
2640 saux0 << NumeIter-1 ;
2641 std::string siter = saux0.str() ;
2642 if (NumeIter < 11) { siter = "0" + siter ; }
2644 // A.2. On verifie qu il y a une hypothese (erreur improbable);
2645 const char* nomHypo = myIteration->GetHypoName();
2646 if (std::string(nomHypo) == std::string(""))
2648 SALOME::ExceptionStruct es;
2649 es.type = SALOME::BAD_PARAM;
2650 es.text = "This iteration does not have any associated hypothesis.";
2651 throw SALOME::SALOME_Exception(es);
2654 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
2655 ASSERT(!CORBA::is_nil(myHypo));
2657 // B. L'iteration parent
2658 const char* nomIterationParent = myIteration->GetIterParentName();
2659 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
2660 ASSERT(!CORBA::is_nil(myIterationParent));
2661 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2662 if ( myIterationParent->GetState() == 1 )
2665 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2668 // GERALD -- QMESSAGE BOX
2669 VERIFICATION("Pb au calcul de l'iteration precedente" == 0);
2673 // C. Le sous-repertoire de l'iteration precedente
2674 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2675 MESSAGE( ". DirComputePa = " << DirComputePa );
2677 // D. Les donnees de l'adaptation HOMARD
2678 // D.1. Le type de conformite
2679 int ConfType = myCase->GetConfType();
2680 MESSAGE ( ". ConfType = " << ConfType );
2682 // D.1. Le type externe
2683 int ExtType = myCase->GetExtType();
2684 MESSAGE ( ". ExtType = " << ExtType );
2686 // D.3. Le maillage de depart
2687 const char* NomMeshParent = myIterationParent->GetMeshName();
2688 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2689 const char* MeshFileParent = myIterationParent->GetMeshFile();
2690 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2692 // D.4. Le maillage associe a l'iteration
2693 const char* MeshFile = myIteration->GetMeshFile();
2694 MESSAGE ( ". MeshFile = " << MeshFile );
2695 FILE *file = fopen(MeshFile,"r");
2699 if (etatMenage == 0)
2701 SALOME::ExceptionStruct es;
2702 es.type = SALOME::BAD_PARAM;
2703 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2704 es.text = CORBA::string_dup(text.c_str());
2705 throw SALOME::SALOME_Exception(es);
2710 std::string commande = "rm -f " + std::string(MeshFile);
2711 codret = system(commande.c_str());
2714 SALOME::ExceptionStruct es;
2715 es.type = SALOME::BAD_PARAM;
2716 es.text = "The mesh file cannot be deleted.";
2717 throw SALOME::SALOME_Exception(es);
2723 // D.5. Les types de raffinement et de deraffinement
2724 // Les appels corba sont lourds, il vaut mieux les grouper
2725 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2726 ASSERT(ListTypes->length() == 3);
2727 int TypeAdap = (*ListTypes)[0];
2728 int TypeRaff = (*ListTypes)[1];
2729 int TypeDera = (*ListTypes)[2];
2730 // MESSAGE ( ". TypeAdap = " << TypeAdap << ", TypeRaff = " << TypeRaff << ", TypeDera = " << TypeDera );
2732 // E. Texte du fichier de configuration
2733 // E.1. Incontournables du texte
2734 myDriver->TexteAdap(ExtType);
2736 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2737 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2738 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2740 // E.2. Ajout des informations liees aux zones eventuelles
2741 if ( TypeAdap == 0 )
2742 { DriverTexteZone(myHypo, myDriver) ; }
2744 // E.3. Ajout des informations liees aux champs eventuels
2745 if ( TypeAdap == 1 )
2746 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2748 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2749 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2750 int numberOfGroups = listeGroupes->length();
2751 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2752 if (numberOfGroups > 0)
2754 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2756 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2757 MESSAGE( "... GroupName = " << GroupName );
2758 myDriver->TexteGroup(GroupName);
2762 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2763 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2765 // E.6. Ajout des options avancees
2766 int Pyram = myCase->GetPyram();
2767 MESSAGE ( ". Pyram = " << Pyram );
2768 int NivMax = myHypo->GetNivMax();
2769 MESSAGE ( ". NivMax = " << NivMax );
2770 double DiamMin = myHypo->GetDiamMin() ;
2771 MESSAGE ( ". DiamMin = " << DiamMin );
2772 int AdapInit = myHypo->GetAdapInit();
2773 MESSAGE ( ". AdapInit = " << AdapInit );
2774 int ExtraOutput = myHypo->GetExtraOutput();
2775 MESSAGE ( ". ExtraOutput = " << ExtraOutput );
2776 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, ExtraOutput);
2778 // E.7. Ajout des informations sur le deroulement de l'execution
2779 int MessInfo = myIteration->GetInfoCompute();
2780 MESSAGE ( ". MessInfo = " << MessInfo );
2781 myDriver->TexteInfoCompute(MessInfo);
2785 //=============================================================================
2786 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2787 // nomrep : nom du repertoire parent
2788 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2789 //=============================================================================
2790 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2792 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2793 // On verifie que le repertoire parent existe
2794 int codret = CHDIR(nomrep) ;
2797 SALOME::ExceptionStruct es;
2798 es.type = SALOME::BAD_PARAM;
2799 es.text = "The directory of the case does not exist.";
2800 throw SALOME::SALOME_Exception(es);
2803 std::string nomDirActuel = getenv("PWD") ;
2804 std::string DirName ;
2805 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2806 bool a_chercher = true ;
2807 while ( a_chercher )
2809 // On passe dans le repertoire parent
2812 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2814 if ( num < 100 ) { jaux = 2 ; }
2815 else if ( num < 1000 ) { jaux = 3 ; }
2816 else if ( num < 10000 ) { jaux = 4 ; }
2817 else if ( num < 100000 ) { jaux = 5 ; }
2819 std::ostringstream iaux ;
2820 iaux << std::setw(jaux) << std::setfill('0') << num ;
2821 std::ostringstream DirNameA ;
2822 DirNameA << "I" << iaux.str();
2823 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2824 // que c'est bien un probleme d'absence
2825 if ( CHDIR(DirNameA.str().c_str()) != 0 )
2827 bool existe = false ;
2830 struct dirent *dirp;
2831 dp = opendir(nomrep);
2832 while ( (dirp = readdir(dp)) != NULL )
2834 std::string file_name(dirp->d_name);
2836 HANDLE hFind = INVALID_HANDLE_VALUE;
2837 WIN32_FIND_DATA ffd;
2838 hFind = FindFirstFile(nomrep, &ffd);
2839 if (INVALID_HANDLE_VALUE != hFind) {
2840 while (FindNextFile(hFind, &ffd) != 0) {
2841 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2842 std::string file_name(ffd.cFileName);
2844 if ( file_name == DirNameA.str() ) { existe = true ; }
2853 DirName = DirNameA.str() ;
2854 a_chercher = false ;
2861 MESSAGE ( "==> DirName = " << DirName);
2862 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2863 CHDIR(nomDirActuel.c_str());
2864 return CORBA::string_dup( DirName.c_str() );
2866 //=============================================================================
2867 // Calcul d'une iteration : gestion du repertoire de calcul
2868 // Si le sous-repertoire existe :
2869 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2870 // etatMenage = 1 : on fait le menage du repertoire
2871 // etatMenage = -1 : on ne fait rien
2872 //=============================================================================
2873 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2875 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2876 // B.2. Le repertoire du cas
2877 const char* nomDirCase = myCase->GetDirName();
2878 MESSAGE ( ". nomDirCase = " << nomDirCase );
2880 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2881 // B.3.1. Le nom du sous-repertoire
2882 const char* nomDirIt = myIteration->GetDirNameLoc();
2884 // B.3.2. Le nom complet du sous-repertoire
2885 std::stringstream DirCompute ;
2886 DirCompute << nomDirCase << "/" << nomDirIt;
2887 MESSAGE (". DirCompute = " << DirCompute.str() );
2889 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2890 if (CHDIR(DirCompute.str().c_str()) != 0)
2893 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2895 if (_mkdir(DirCompute.str().c_str()) != 0)
2898 // GERALD -- QMESSAGE BOX
2899 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2900 VERIFICATION("Pb a la creation du repertoire" == 0);
2905 // Le repertoire existe
2906 // On demande de faire le menage de son contenu :
2907 if (etatMenage == 1)
2909 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2910 std::string commande = "rm -rf " + DirCompute.str()+"/*" ;
2911 int codret = system(commande.c_str());
2914 // GERALD -- QMESSAGE BOX
2915 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2916 VERIFICATION("Pb au menage du repertoire de calcul" == 0);
2919 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2922 if (etatMenage == 0)
2926 struct dirent *dirp;
2927 dp = opendir(DirCompute.str().c_str());
2929 while ((dirp = readdir(dp)) != NULL && result )
2931 std::string file_name(dirp->d_name);
2932 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2936 HANDLE hFind = INVALID_HANDLE_VALUE;
2937 WIN32_FIND_DATA ffd;
2938 hFind = FindFirstFile(DirCompute.str().c_str(), &ffd);
2940 if (INVALID_HANDLE_VALUE != hFind) {
2941 while (FindNextFile(hFind, &ffd) != 0) {
2942 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2943 std::string file_name(ffd.cFileName);
2944 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2949 if ( result == false)
2951 SALOME::ExceptionStruct es;
2952 es.type = SALOME::BAD_PARAM;
2953 std::string text = "Directory : " + DirCompute.str() + " is not empty";
2954 es.text = CORBA::string_dup(text.c_str());
2955 throw SALOME::SALOME_Exception(es);
2956 VERIFICATION("Directory is not empty" == 0);
2962 return CORBA::string_dup( DirCompute.str().c_str() );
2964 //=============================================================================
2965 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2966 //=============================================================================
2967 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2969 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2970 // Le repertoire du cas
2971 const char* nomDirCase = myCase->GetDirName();
2972 MESSAGE ( ". nomDirCase = " << nomDirCase );
2974 // Le sous-repertoire de l'iteration precedente
2976 const char* nomIterationParent = myIteration->GetIterParentName();
2977 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
2978 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
2979 std::stringstream DirComputePa ;
2980 DirComputePa << nomDirCase << "/" << nomDirItPa;
2981 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2982 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2984 return CORBA::string_dup( DirComputePa.str().c_str() );
2986 //=============================================================================
2987 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2988 //=============================================================================
2989 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2991 MESSAGE ( "... DriverTexteZone" );
2992 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2993 int numberOfZonesx2 = ListZone->length();
2996 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2998 std::string ZoneName = std::string((*ListZone)[iaux]);
2999 MESSAGE ( "... ZoneName = " << ZoneName);
3000 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
3001 ASSERT(!CORBA::is_nil(myZone));
3003 int ZoneType = myZone->GetType();
3004 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
3005 int TypeUse = atoi( TypeUsestr.c_str() );
3006 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
3007 NumZone = iaux/2 + 1 ;
3008 HOMARD::double_array* zone = myZone->GetCoords();
3009 if ( ZoneType == 2 || ( ZoneType>=11 && ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
3010 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
3011 else if ( ZoneType == 4 ) // Cas d une sphere
3012 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
3013 else if ( ZoneType == 5 || ( ZoneType>=31 && ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
3014 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
3015 else if ( ZoneType == 7 || ( ZoneType>=61 && ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
3016 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
3017 else { VERIFICATION("ZoneType est incorrect." == 0) ; }
3022 //=============================================================================
3023 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
3024 //=============================================================================
3025 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3027 MESSAGE ( "... DriverTexteField" );
3028 // Le fichier du champ
3029 char* FieldFile = myIteration->GetFieldFile();
3030 MESSAGE ( ". FieldFile = " << FieldFile );
3031 if (strlen(FieldFile) == 0)
3033 // GERALD -- QMESSAGE BOX
3034 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
3035 VERIFICATION("The file for the field is not given." == 0);
3037 // Les caracteristiques d'instants du champ de pilotage
3038 int TimeStep = myIteration->GetTimeStep();
3039 MESSAGE( ". TimeStep = " << TimeStep );
3040 int Rank = myIteration->GetRank();
3041 MESSAGE( ". Rank = " << Rank );
3042 // Les informations sur les champs
3043 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
3045 const char* FieldName = aInfosHypo->FieldName;
3047 int TypeThR = aInfosHypo->TypeThR;
3048 double ThreshR = aInfosHypo->ThreshR;
3049 int TypeThC = aInfosHypo->TypeThC;
3050 double ThreshC = aInfosHypo->ThreshC;
3051 // Saut entre mailles ou non ?
3052 int UsField = aInfosHypo->UsField;
3053 MESSAGE( ". UsField = " << UsField );
3054 // L'usage des composantes
3055 int UsCmpI = aInfosHypo->UsCmpI;
3056 MESSAGE( ". UsCmpI = " << UsCmpI );
3058 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
3061 HOMARD::listeComposantsHypo* mescompo = myHypo->GetComps();
3062 int numberOfCompos = mescompo->length();
3063 MESSAGE( ". numberOfCompos = " << numberOfCompos );
3064 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
3066 std::string nomCompo = std::string((*mescompo)[NumeComp]);
3067 if ((system(nomCompo.c_str())) != 0)
3069 MESSAGE( "... nomCompo = " << nomCompo );
3070 myDriver->TexteCompo(NumeComp, nomCompo);
3075 //=============================================================================
3076 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
3077 // On ecrit dans l'ordre :
3078 // 1. la definition des frontieres
3079 // 2. les liens avec les groupes
3080 // 3. un entier resumant le type de comportement pour les frontieres
3081 //=============================================================================
3082 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
3084 MESSAGE ( "... DriverTexteBoundary" );
3085 // 1. Recuperation des frontieres
3086 std::list<std::string> ListeBoundaryTraitees ;
3087 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3088 int numberOfitems = ListBoundaryGroupType->length();
3089 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
3090 int BoundaryOption = 1 ;
3091 // 2. Parcours des frontieres pour ecrire leur description
3092 int NumBoundaryAnalytical = 0 ;
3093 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3095 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3096 MESSAGE ( "... BoundaryName = " << BoundaryName);
3097 // 2.1. La frontiere a-t-elle deja ete ecrite ?
3098 // Cela arrive quand elle est liee a plusieurs groupes. Il ne faut l'ecrire que la premiere fois
3100 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3101 while (it != ListeBoundaryTraitees.end())
3103 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3104 if ( BoundaryName == *it ) { A_faire = 0 ; }
3107 // 2.2. Ecriture de la frontiere
3110 // 2.2.1. Caracteristiques de la frontiere
3111 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3112 ASSERT(!CORBA::is_nil(myBoundary));
3113 int BoundaryType = myBoundary->GetType();
3114 MESSAGE ( "... BoundaryType = " << BoundaryType );
3115 // 2.2.2. Ecriture selon le type
3116 // 2.2.2.1. Cas d une frontiere discrete
3117 if (BoundaryType == 0)
3119 const char* MeshName = myBoundary->GetMeshName() ;
3120 MESSAGE ( ". MeshName = " << MeshName );
3121 const char* MeshFile = myBoundary->GetMeshFile() ;
3122 MESSAGE ( ". MeshFile = " << MeshFile );
3123 myDriver->TexteBoundaryDi( MeshName, MeshFile);
3124 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; }
3126 // 2.2.2.1. Cas d une frontiere analytique
3129 NumBoundaryAnalytical++ ;
3130 HOMARD::double_array* coor = myBoundary->GetCoords();
3131 if (BoundaryType == 1) // Cas d un cylindre
3133 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3134 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3136 else if (BoundaryType == 2) // Cas d une sphere
3138 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
3139 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3141 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
3143 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3144 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3146 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
3148 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3149 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3151 else if (BoundaryType == 5) // Cas d un tore
3153 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3154 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3157 // 2.2.3. Memorisation du traitement
3158 ListeBoundaryTraitees.push_back( BoundaryName );
3161 // 3. Parcours des frontieres pour ecrire les liens avec les groupes
3162 NumBoundaryAnalytical = 0 ;
3163 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3165 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3166 MESSAGE ( "... BoundaryName = " << BoundaryName);
3167 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3168 ASSERT(!CORBA::is_nil(myBoundary));
3169 int BoundaryType = myBoundary->GetType();
3170 MESSAGE ( "... BoundaryType = " << BoundaryType );
3171 // 3.1. Recuperation du nom du groupe
3172 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
3173 MESSAGE ( "... GroupName = " << GroupName);
3174 // 3.2. Cas d une frontiere discrete
3175 if ( BoundaryType == 0 )
3177 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
3179 // 3.3. Cas d une frontiere analytique
3182 NumBoundaryAnalytical++ ;
3183 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
3186 // 4. Ecriture de l'option finale
3187 myDriver->TexteBoundaryOption(BoundaryOption);
3191 //=============================================================================
3192 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
3193 //=============================================================================
3194 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3196 MESSAGE ( "... DriverTexteFieldInterp" );
3197 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
3198 MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp);
3199 if (TypeFieldInterp != 0)
3201 // Le fichier des champs
3202 char* FieldFile = myIteration->GetFieldFile();
3203 MESSAGE ( ". FieldFile = " << FieldFile );
3204 if (strlen(FieldFile) == 0)
3206 // GERALD -- QMESSAGE BOX
3207 VERIFICATION("The file for the field is not given." == 0);
3210 const char* MeshFile = myIteration->GetMeshFile();
3211 myDriver->TexteFieldInterp(FieldFile, MeshFile);
3214 // Interpolation de tous les champs
3215 if ( TypeFieldInterp == 1 )
3217 myDriver->TexteFieldInterpAll();
3219 // Interpolation de certains champs
3220 else if (TypeFieldInterp == 2)
3222 // Les champs et leurs instants pour l'iteration
3223 HOMARD::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank();
3224 int numberOfFieldsx3 = ListFieldTSR->length();
3225 MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 );
3226 // Les champs pour l'hypothese
3227 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
3228 int numberOfFieldsx2 = ListField->length();
3229 MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 );
3230 // On parcourt tous les champs de l'hypothese
3232 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
3235 std::string FieldName = std::string((*ListField)[iaux]) ;
3236 // Le type d'interpolation
3237 std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ;
3238 MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr );
3239 // On cherche ?? savoir si des instants ont ??t?? pr??cis??s pour cette it??ration
3241 for (int jaux = 0; jaux< numberOfFieldsx3; jaux++)
3244 std::string FieldName2 = std::string((*ListFieldTSR)[jaux]) ;
3245 MESSAGE( "..... FieldName2 = " << FieldName2 );
3246 // Quand c'est le bon champ, on ecrit le pas de temps
3247 if ( FieldName == FieldName2 )
3251 std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]) ;
3252 // Le numero d'ordre
3253 std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]) ;
3254 MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<<Rankstr );
3256 int TimeStep = atoi( TimeStepstr.c_str() );
3257 int Rank = atoi( Rankstr.c_str() );
3258 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank);
3262 // Si aucun instant n'a ??t?? d??fini
3266 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1);
3274 //===========================================================================
3275 //===========================================================================
3278 //===========================================================================
3279 //===========================================================================
3281 //===========================================================================
3282 //===========================================================================
3283 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr theSObject,
3284 CORBA::Object_ptr theObject,
3285 const char* theName)
3287 MESSAGE("PublishInStudy pour " << theName);
3288 SALOMEDS::SObject_var aResultSO;
3289 if (CORBA::is_nil(myStudy))
3291 SALOME::ExceptionStruct es;
3292 es.type = SALOME::BAD_PARAM;
3293 es.text = "Invalid study context";
3294 throw SALOME::SALOME_Exception(es);
3298 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
3299 // Rq : Iteration est publiee ailleurs
3300 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
3301 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
3302 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
3303 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject);
3304 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
3308 // Controle de la non publication d'un objet de meme nom
3309 if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) )
3311 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(theName, ComponentDataType());
3312 if (listSO->length() >= 1)
3314 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
3315 aResultSO = listSO[0];
3316 return aResultSO._retn();
3320 // Caracteristiques de l'etude
3321 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3322 aStudyBuilder->NewCommand();
3323 if(!aBoundary->_is_nil())
3324 aResultSO = PublishBoundaryInStudy(aStudyBuilder, aBoundary, theName);
3325 else if(!aCase->_is_nil())
3326 aResultSO = PublishCaseInStudy(aStudyBuilder, aCase, theName);
3327 else if(!aHypo->_is_nil())
3328 aResultSO = PublishHypotheseInStudy(aStudyBuilder, aHypo, theName);
3329 else if(!aYACS->_is_nil())
3330 aResultSO = PublishYACSInStudy(aStudyBuilder, aYACS, theName);
3331 else if(!aZone->_is_nil())
3332 aResultSO = PublishZoneInStudy(aStudyBuilder, aZone, theName);
3334 aStudyBuilder->CommitCommand();
3336 return aResultSO._retn();
3338 //=============================================================================
3339 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy( SALOMEDS::StudyBuilder_var aStudyBuilder,
3340 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3342 MESSAGE("PublishBoundaryStudy pour "<<theName);
3343 SALOMEDS::SObject_var aResultSO;
3345 // Caracteristique de la Boundary
3346 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[theName];
3348 // On recupere le module pere dans l etude
3349 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3350 if (theFatherHomard->_is_nil())
3352 MESSAGE("theFatherHomard->_is_nil()");
3353 return aResultSO._retn();
3356 // On ajoute la categorie des boundarys dans l etude si necessaire
3357 if ( _tag_boun == 0 )
3360 _tag_boun = _tag_gene ;
3362 MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun );
3363 SALOMEDS::SObject_var aSObject;
3364 if (!theFatherHomard->FindSubObject(_tag_boun, aSObject))
3366 MESSAGE("Ajout de la categorie des boundarys");
3367 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun);
3368 PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3370 else { MESSAGE("La categorie des boundarys existe deja."); }
3372 CORBA::Long BoundaryType = myBoundary->GetType();
3373 // MESSAGE("BoundaryType : "<<BoundaryType);
3376 switch (BoundaryType)
3379 { value = "BoundaryDiHomard" ;
3380 icone = "mesh_tree_mesh.png" ;
3384 { value = "BoundaryAnHomard" ;
3385 icone = "cylinderpointvector_2.png" ;
3389 { value = "BoundaryAnHomard" ;
3390 icone = "spherepoint_2.png" ;
3394 { value = "BoundaryAnHomard" ;
3395 icone = "conepointvector.png" ;
3399 { value = "BoundaryAnHomard" ;
3400 icone = "conedxyz.png" ;
3404 { value = "BoundaryAnHomard" ;
3405 icone = "toruspointvector.png" ;
3409 aResultSO = aStudyBuilder->NewObject(aSObject);
3410 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3411 return aResultSO._retn();
3413 //=============================================================================
3414 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3415 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
3417 MESSAGE("PublishCaseInStudy pour "<<theName);
3418 SALOMEDS::SObject_var aResultSO;
3420 if (CORBA::is_nil(theObject)) {
3421 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
3422 return aResultSO._retn();
3424 if (myStudy->_is_nil()) {
3425 MESSAGE("HOMARD_Gen_i::myStudy->_is_nil()");
3426 return aResultSO._retn();
3429 // On recupere le module pere dans l etude
3430 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3431 if (theFatherHomard->_is_nil())
3433 MESSAGE("theFatherHomard->_is_nil()");
3434 return aResultSO._retn();
3438 MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene );
3439 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
3440 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
3441 _orb->object_to_string(theObject) ) ;
3443 return aResultSO._retn();
3445 //=============================================================================
3446 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3447 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3449 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3450 SALOMEDS::SObject_var aResultSO;
3452 // On recupere le module pere dans l etude
3453 // On ajoute la categorie des hypotheses dans l etude si necessaire
3454 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3455 if (theFatherHomard->_is_nil())
3457 MESSAGE("theFatherHomard->_is_nil()");
3458 return aResultSO._retn();
3461 // On ajoute la categorie des hypotheses dans l etude si necessaire
3462 SALOMEDS::SObject_var aSObject;
3463 if ( _tag_hypo == 0 )
3466 _tag_hypo = _tag_gene ;
3468 MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo );
3469 if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject))
3471 MESSAGE("Ajout de la categorie des hypotheses");
3472 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo);
3473 PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL);
3475 else { MESSAGE("La categorie des hypotheses existe deja."); }
3477 // Creation du resultat dans l'etude
3478 aResultSO = aStudyBuilder->NewObject(aSObject);
3479 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3481 return aResultSO._retn();
3483 //=============================================================================
3484 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3485 HOMARD::HOMARD_YACS_ptr theObject, const char* theName)
3487 MESSAGE("PublishYACSInStudy pour "<<theName);
3488 SALOMEDS::SObject_var aResultSO;
3490 // On recupere le module pere dans l etude
3491 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3492 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3493 if (theFatherHomard->_is_nil())
3495 MESSAGE("theFatherHomard->_is_nil()");
3496 return aResultSO._retn();
3498 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3499 if ( _tag_yacs == 0 )
3502 _tag_yacs = _tag_gene ;
3504 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs );
3505 SALOMEDS::SObject_var aSObject;
3506 if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject))
3508 MESSAGE("Ajout de la categorie des schemas YACS");
3509 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs);
3510 PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL);
3512 else { MESSAGE("La categorie des schemas YACS existe deja."); }
3514 // Creation du resultat dans l'etude
3515 aResultSO = aStudyBuilder->NewObject(aSObject);
3516 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ;
3518 return aResultSO._retn();
3521 //=============================================================================
3522 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3523 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3525 MESSAGE("PublishZoneStudy pour "<<theName);
3526 SALOMEDS::SObject_var aResultSO;
3527 if (CORBA::is_nil(theObject))
3529 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3530 return aResultSO._retn();
3532 if (myStudy->_is_nil())
3534 MESSAGE("PublishZoneInStudy : myStudy->_is_nil()");
3535 return aResultSO._retn();
3537 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3538 if (theFatherHomard->_is_nil())
3540 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3541 return aResultSO._retn();
3544 // Caracteristique de la zone
3545 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[theName];
3546 CORBA::Long ZoneType = myZone->GetType();
3548 // On ajoute la categorie des zones dans l etude si necessaire
3549 if ( _tag_zone == 0 )
3552 _tag_zone = _tag_gene ;
3554 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone );
3555 SALOMEDS::SObject_var aSObject;
3556 if (!theFatherHomard->FindSubObject(_tag_zone, aSObject))
3558 MESSAGE("Ajout de la categorie des zones");
3559 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone);
3560 PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3562 else { MESSAGE("La categorie des zones existe deja."); }
3564 aResultSO = aStudyBuilder->NewObject(aSObject);
3573 { icone = "boxdxy_2.png" ;
3577 { icone = "boxdxyz_2.png" ;
3585 { icone = "disk_2.png" ;
3589 { icone = "spherepoint_2.png" ;
3593 { icone = "cylinderpointvector_2.png" ;
3601 { icone = "diskwithhole_2.png" ;
3605 { icone = "pipe_2.png" ;
3609 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3611 return aResultSO._retn();
3613 //===========================================================================
3614 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3615 SALOMEDS::SObject_var aResultSO,
3616 const char* name, const char* comment, const char* icone, const char* ior)
3618 MESSAGE("PublishInStudyAttr pour name = "<<name<<", comment = "<<comment);
3619 // MESSAGE("icone = "<<icone);
3620 // MESSAGE("ior = "<<ior);
3621 SALOMEDS::GenericAttribute_var anAttr ;
3625 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3626 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3627 aNameAttrib->SetValue(name);
3630 // Ajout du commentaire
3631 if ( comment != NULL )
3633 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3634 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3635 aCommentAttrib->SetValue(comment);
3639 if ( icone != NULL )
3641 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
3642 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3643 aPixmap->SetPixMap(icone);
3649 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3650 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3651 anIOR->SetValue(ior);
3655 //=====================================================================================
3656 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3658 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3660 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName];
3661 ASSERT(!CORBA::is_nil(myCase));
3662 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3663 ASSERT(!CORBA::is_nil(aCaseSO));
3665 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3666 ASSERT(!CORBA::is_nil(myBoundary));
3667 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3668 ASSERT(!CORBA::is_nil(aBoundarySO));
3670 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3672 aStudyBuilder->NewCommand();
3674 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3675 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3676 // aStudyBuilder->RemoveReference(aSubSO);
3678 aStudyBuilder->CommitCommand();
3681 //=====================================================================================
3682 void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName)
3684 MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName );
3686 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
3687 ASSERT(!CORBA::is_nil(myYACS));
3688 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3689 ASSERT(!CORBA::is_nil(aYACSSO));
3691 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName];
3692 ASSERT(!CORBA::is_nil(myCase));
3693 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3694 ASSERT(!CORBA::is_nil(aCaseSO));
3696 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3698 aStudyBuilder->NewCommand();
3700 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3701 aStudyBuilder->Addreference(aSubSO, aCaseSO);
3703 aStudyBuilder->CommitCommand();
3706 //=============================================================================
3707 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3708 // Option = 0 : fichier issu d'une importation
3709 // Option = 1 : fichier issu d'une execution HOMARD
3711 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3712 if (CORBA::is_nil(myStudy))
3714 SALOME::ExceptionStruct es;
3715 es.type = SALOME::BAD_PARAM;
3716 es.text = "Invalid study context";
3717 throw SALOME::SALOME_Exception(es);
3721 // Le module SMESH est-il actif ?
3722 SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH");
3724 if (!CORBA::is_nil(aSmeshSO))
3726 // On verifie que le fichier n est pas deja publie
3727 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO);
3728 for (; aIter->More(); aIter->Next())
3730 SALOMEDS::SObject_var aSO = aIter->Value();
3731 SALOMEDS::GenericAttribute_var aGAttr;
3732 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3734 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3735 CORBA::String_var value=anAttr->Value();
3736 if (strcmp((const char*)value,NomFich) == 0)
3738 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3739 // Pour un fichier importe, on ne republie pas
3740 if ( Option == 0 ) { return; }
3741 // Pour un fichier calcule, on commence par faire la depublication
3744 MESSAGE ( "PublishResultInSmesh : depublication" );
3745 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3746 CORBA::String_var value2=anAttr2->Value();
3747 std::string MeshName = string(value2) ;
3748 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3749 DeleteResultInSmesh(NomFich, MeshName) ;
3756 // On enregistre le fichier
3757 MESSAGE( "Enregistrement du fichier");
3758 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3759 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3760 ASSERT(!CORBA::is_nil(aSmeshEngine));
3761 aSmeshEngine->UpdateStudy();
3762 SMESH::DriverMED_ReadStatus theStatus;
3763 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3765 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3766 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3767 for (int i = 0; i < mesMaillages->length(); i++)
3769 MESSAGE( ". Mise a jour des attributs du maillage");
3770 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3771 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3772 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3773 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3774 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3775 anAttr->SetValue(NomFich);
3776 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3777 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3779 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3780 else { icone = "mesh_tree_mesh.png" ; }
3781 anAttr2->SetPixMap( icone );
3785 //=============================================================================
3786 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
3788 MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3789 if (CORBA::is_nil(myStudy))
3791 SALOME::ExceptionStruct es;
3792 es.type = SALOME::BAD_PARAM;
3793 es.text = "Invalid study context";
3794 throw SALOME::SALOME_Exception(es);
3798 // Le module SMESH est-il actif ?
3799 SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH");
3801 if (CORBA::is_nil(aSmeshSO))
3805 // On verifie que le fichier est deja publie
3806 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
3807 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO);
3808 for (; aIter->More(); aIter->Next())
3810 SALOMEDS::SObject_var aSO = aIter->Value();
3811 SALOMEDS::GenericAttribute_var aGAttr;
3812 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3814 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3815 CORBA::String_var value=anAttr->Value();
3816 if (strcmp((const char*)value,NomFich.c_str()) == 0)
3818 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3820 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3821 CORBA::String_var value2=anAttr2->Value();
3822 if (strcmp((const char*)value2,MeshName.c_str()) == 0)
3824 myBuilder->RemoveObjectWithChildren( aSO ) ;
3832 //=============================================================================
3833 void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter)
3835 MESSAGE( "PublishMeshIterInSmesh " << NomIter);
3836 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter];
3838 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3839 if (CORBA::is_nil(myIteration))
3841 SALOME::ExceptionStruct es;
3842 es.type = SALOME::BAD_PARAM;
3843 es.text = "Invalid iterationStudy Object";
3844 throw SALOME::SALOME_Exception(es);
3847 const char* MeshFile = myIteration->GetMeshFile() ;
3848 const char* MeshName = myIteration->GetMeshName() ;
3849 CORBA::Long Option = -1 ;
3850 int etat = myIteration->GetState();
3851 // Iteration initiale
3852 if ( etat <= 0 ) { Option = 0 ; }
3853 // ou iteration calculee
3854 else if ( etat == 2 ) { Option = 1 ; }
3855 // Publication effective apres menage eventuel
3858 DeleteResultInSmesh(MeshFile, MeshName) ;
3859 PublishResultInSmesh(MeshFile, Option) ;
3863 //=============================================================================
3864 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3866 // MESSAGE ("PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3867 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter];
3869 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3870 if (CORBA::is_nil(myIteration))
3872 SALOME::ExceptionStruct es;
3873 es.type = SALOME::BAD_PARAM;
3874 es.text = "Invalid iterationStudy Object";
3875 throw SALOME::SALOME_Exception(es);
3879 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3881 aStudyBuilder->NewCommand();
3883 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3884 // Pour les fichiers med, on affiche une icone de maillage
3885 // Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte'
3886 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3888 std::string ior = " " ;
3889 if ( Commentaire[0] == 'M' )
3890 { icone = "med.png" ; }
3892 { icone = "texte_2.png" ; }
3893 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3895 aStudyBuilder->CommitCommand();
3898 //=============================================================================
3899 void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire)
3901 // MESSAGE ("PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3902 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
3904 SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3905 if (CORBA::is_nil(myYACS))
3907 SALOME::ExceptionStruct es;
3908 es.type = SALOME::BAD_PARAM;
3909 es.text = "Invalid YACSStudy Object";
3910 throw SALOME::SALOME_Exception(es);
3914 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3916 aStudyBuilder->NewCommand();
3918 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3919 std::string icone = "texte_2.png" ;
3920 std::string ior = " " ;
3921 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3923 aStudyBuilder->CommitCommand();
3926 //=============================================================================
3927 //=============================================================================
3929 //=============================================================================
3930 //=============================================================================
3931 //=============================================================================
3932 // Creation d'un schema YACS
3933 // nomCas : nom du cas a traiter
3934 // FileName : nom du fichier contenant le script de lancement du calcul
3935 // DirName : le repertoire de lancement des calculs du sch??ma
3936 //=============================================================================
3937 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
3939 INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS );
3940 INFOS ( ". nomCas : " << nomCas);
3941 INFOS ( ". ScriptFile : " << ScriptFile);
3942 INFOS ( ". DirName : " << DirName);
3943 INFOS ( ". MeshFile : " << MeshFile);
3945 // A. Controle du nom :
3946 if ((myStudyContext._mesYACSs).find(nomYACS) != (myStudyContext._mesYACSs).end())
3948 SALOME::ExceptionStruct es;
3949 es.type = SALOME::BAD_PARAM;
3950 es.text = "This schema YACS has already been defined.";
3951 throw SALOME::SALOME_Exception(es);
3955 // B. Creation de l'objet
3956 HOMARD::HOMARD_YACS_var myYACS = newYACS();
3957 if (CORBA::is_nil(myYACS))
3959 SALOME::ExceptionStruct es;
3960 es.type = SALOME::BAD_PARAM;
3961 es.text = "Unable to create the schema YACS";
3962 throw SALOME::SALOME_Exception(es);
3965 myYACS->SetName( nomYACS ) ;
3967 // C. Enregistrement
3968 myStudyContext._mesYACSs[nomYACS] = myYACS;
3970 SALOMEDS::SObject_var aSO;
3971 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myYACS, nomYACS);
3973 PublishCaseUnderYACS(nomYACS, nomCas);
3975 // D. Caracterisation
3977 myYACS->SetDirName( DirName ) ;
3978 myYACS->SetMeshFile( MeshFile ) ;
3979 myYACS->SetScriptFile( ScriptFile ) ;
3980 myYACS->SetCaseName( nomCas ) ;
3983 // D.2.1. Type constant
3984 myYACS->SetType( 1 ) ;
3985 // D.2.2. Convergence
3986 defaut_i = GetYACSMaxIter() ;
3987 myYACS->SetMaxIter( defaut_i ) ;
3988 defaut_i = GetYACSMaxNode() ;
3989 myYACS->SetMaxNode( defaut_i ) ;
3990 defaut_i = GetYACSMaxElem() ;
3991 myYACS->SetMaxElem( defaut_i ) ;
3992 // D.3. Fichier de sauvegarde dans le repertoire du cas
3993 HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ;
3994 std::string dirnamecase = caseyacs->GetDirName() ;
3995 std::string XMLFile ;
3996 XMLFile = dirnamecase + "/schema.xml" ;
3997 myYACS->SetXMLFile( XMLFile.c_str() ) ;
3999 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
4001 //=============================================================================
4002 // Ecriture d'un schema YACS
4003 //=============================================================================
4004 CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS)
4006 INFOS ( "YACSWrite : Ecriture de " << nomYACS );
4007 // Le repertoire du cas
4008 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
4009 ASSERT(!CORBA::is_nil(myYACS));
4010 // Le nom du fichier du schema
4011 std::string XMLFile ;
4012 XMLFile = myYACS->GetXMLFile() ;
4014 int codret = YACSWriteOnFile(nomYACS, XMLFile.c_str()) ;
4018 //=============================================================================
4019 // Ecriture d'un schema YACS sur un fichier donne
4020 //=============================================================================
4021 CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile)
4023 INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile );
4030 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
4031 ASSERT(!CORBA::is_nil(myYACS));
4032 // B.2. Les caracteristiques
4033 std::string DirName = myYACS->GetDirName() ;
4034 std::string MeshFile = myYACS->GetMeshFile() ;
4035 std::string ScriptFile = myYACS->GetScriptFile() ;
4036 // B.3. Les caracteristiques de convergence
4037 int MaxIter = myYACS->GetMaxIter() ;
4038 int MaxNode = myYACS->GetMaxNode() ;
4039 int MaxElem = myYACS->GetMaxElem() ;
4043 const char* nomCas = myYACS->GetCaseName();
4044 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
4045 ASSERT(!CORBA::is_nil(myCase));
4046 // C.2. Les instructions python associees au cas
4047 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4048 std::string pythonCas = dumpCorbaCase.in();
4049 MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
4051 // D. Les iterations
4052 // D.1. L'iteration initiale
4053 HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
4054 std::string Iter0Name = myCase->GetIter0Name() ;
4055 MESSAGE (". Iter0Name = " << Iter0Name);
4056 std::string MeshName = Iter0->GetMeshName();
4057 MESSAGE (". MeshName = " << MeshName);
4058 // D.2. L'iteration numero 1
4059 HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
4060 int numberOfIter = maListe->length();
4061 if ( numberOfIter > 1 )
4063 MESSAGE (". numberOfIter = " << numberOfIter);
4064 SALOME::ExceptionStruct es ;
4065 es.type = SALOME::BAD_PARAM;
4066 std::string text = "Une seule iteration est permise." ;
4067 es.text = CORBA::string_dup(text.c_str());
4068 throw SALOME::SALOME_Exception(es);
4071 std::string Iter1Name = std::string((*maListe)[0]);
4072 MESSAGE ("... Iter1Name = " << Iter1Name);
4073 HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
4074 // D.3. Les instructions python associees a l'iteration
4075 CORBA::String_var dumpCorbaIter = Iter1->GetDumpPython();
4076 std::string pythonIter = dumpCorbaIter.in();
4077 MESSAGE ("pythonIter :\n"<<pythonIter<<"\n");
4079 // E. L'hypothese pour passer de l'iteration initiale a la suivante
4080 // E.1. La structure
4081 std::string nomHypo = Iter1->GetHypoName();
4082 MESSAGE (". nomHypo = " << nomHypo);
4083 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
4084 ASSERT(!CORBA::is_nil(myHypo));
4085 // E.2. Les caracteristiques de l'adaptation
4086 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
4087 ASSERT(ListTypes->length() == 3);
4088 int TypeAdap = (*ListTypes)[0];
4089 // int TypeRaff = (*ListTypes)[1];
4090 // int TypeDera = (*ListTypes)[2];
4091 // E.3. Les instructions python associees a l'hypothese
4092 CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
4093 std::string pythonHypo = dumpCorbaHypo.in();
4094 MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
4096 // F. Le fichier du schema de reference
4097 // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD
4098 std::string XMLFile_base ;
4099 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { XMLFile_base = getenv("HOMARD_ROOT_DIR") ; }
4102 SALOME::ExceptionStruct es ;
4103 es.type = SALOME::BAD_PARAM;
4104 std::string text = "HOMARD_ROOT_DIR est inconnu." ;
4105 es.text = CORBA::string_dup(text.c_str());
4106 throw SALOME::SALOME_Exception(es);
4109 XMLFile_base += "/share/salome/resources/homard/yacs_01." + _LangueShort + ".xml" ;
4111 MESSAGE("XMLFile_base ="<<XMLFile_base);
4113 // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4114 YACSDriver* myDriver = new YACSDriver(XMLFile, DirName);
4115 std::ifstream fichier( XMLFile_base.c_str() );
4116 if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
4118 // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4119 std::string ligne; // variable contenant chaque ligne lue
4120 std::string mot_cle;
4121 while ( std::getline( fichier, ligne ) )
4123 // G.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
4124 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4125 ligne_bis >> mot_cle ;
4126 // G.1.2. Le maillage initial
4127 if ( mot_cle == "DataInit_MeshFile" )
4128 { myDriver->Texte_DataInit_MeshFile(MeshFile); }
4129 // G.1.3. Le script de lancement
4130 else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
4131 { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); }
4132 // G.1.4. Les options du cas
4133 else if ( mot_cle == "Iter_1_Case_Options" )
4134 { myDriver->Texte_Iter_1_Case_Options(pythonCas); }
4135 // G.1.5. Execution de HOMARD : le repertoire du cas
4136 else if ( mot_cle == "HOMARD_Exec_DirName" )
4137 { myDriver->Texte_HOMARD_Exec_DirName(); }
4138 // G.1.6. Execution de HOMARD : le nom du maillage
4139 else if ( mot_cle == "HOMARD_Exec_MeshName" )
4141 myDriver->Texte_HOMARD_Exec_MeshName(MeshName);
4142 std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ;
4143 myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ;
4145 // G.1.7. Execution de HOMARD : les options de l'hypothese
4146 else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
4147 { myDriver->Texte_python_1( pythonHypo, 3, "Hypo" ) ; }
4148 // G.1.8. Execution de HOMARD : les options de l'iteration
4149 else if ( mot_cle == "HOMARD_Exec_Iter_Options" )
4150 { myDriver->Texte_python_2( pythonIter, "TimeStep", "Iter" ) ; }
4151 // G.1.9. a. Creation eventuelles des zones et frontieres
4153 else if ( mot_cle == "Iter_1" )
4155 std::string texte_control = "" ;
4156 if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; }
4157 texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ;
4158 texte_control += myDriver->Texte_Iter_1_control() ;
4159 myDriver->TexteAdd(texte_control);
4161 // G.1.10. Les tests de convergence
4162 else if ( mot_cle == "Analyse_Test_Convergence" )
4163 { myDriver->TexteAnalyse_Test_Convergence(MaxIter, MaxNode, MaxElem); }
4164 // G.1.11. Les parametres
4165 else if ( mot_cle == "PARAMETRES" )
4166 { myDriver->TexteAddParametres(); }
4167 // G.1.n. La ligne est recopiee telle quelle
4168 else { myDriver->TexteAdd(ligne); }
4170 // G.2. Ecriture du texte dans le fichier
4172 { myDriver->CreeFichier(); }
4176 SALOME::ExceptionStruct es;
4177 es.type = SALOME::BAD_PARAM;
4178 std::string text = "The reference file for the YACS schema cannot be read." ;
4179 es.text = CORBA::string_dup(text.c_str());
4180 throw SALOME::SALOME_Exception(es);
4185 // H. Publication du fichier dans l'arbre
4187 std::string Commentaire = "xml" ;
4188 PublishFileUnderYACS(nomYACS, XMLFile, Commentaire.c_str());
4192 //=============================================================================
4193 // Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
4194 //=============================================================================
4195 std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
4197 MESSAGE ( "YACSDriverTexteZone" );
4198 // A. Les zones associees a cette hypothese
4199 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
4200 int numberOfZonesx2 = ListZone->length();
4202 // B. Parcours des zones
4203 std::string texte_control ;
4204 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
4206 // 1. Reperage de la zone
4207 std::string ZoneName = std::string((*ListZone)[iaux]);
4208 MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
4209 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
4210 ASSERT(!CORBA::is_nil(myZone));
4211 // 2. Les instructions python associees a la zone
4212 // La premiere ligne est un commentaire a eliminer
4213 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4214 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4215 std::string pythonStructure_0 = dumpCorbaZone.in();
4216 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4217 std::istringstream tout (pythonStructure_0) ;
4219 std::string pythonStructure ;
4220 while ( std::getline( tout, ligne ) )
4221 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4222 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4223 // 3. Decodage du nom du service
4224 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4225 MESSAGE ( "... methode = " << methode);
4226 // 4. Mise en place des instructions
4227 int ZoneType = myZone->GetType();
4228 MESSAGE ( "... ZoneType = " << ZoneType);
4229 std::string texte_control_0 ;
4230 texte_control_0 = myDriver->Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName );
4231 texte_control += texte_control_0 ;
4236 return texte_control ;
4238 //=============================================================================
4239 // Ecriture d'un schema YACS : ecriture des frontieres associees au cas
4240 //=============================================================================
4241 std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver)
4243 MESSAGE ( "YACSDriverTexteBoundary" );
4244 // A. Les frontieres associees au cas
4245 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
4246 int numberOfitems = ListBoundaryGroupType->length();
4248 // B. Parcours des frontieres
4249 std::string texte_control ;
4250 std::list<std::string> ListeBoundaryTraitees ;
4251 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
4253 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
4254 MESSAGE ( "... BoundaryName = " << BoundaryName);
4255 // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver
4256 // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees
4258 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
4259 while (it != ListeBoundaryTraitees.end())
4261 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
4262 if ( BoundaryName == *it ) { A_faire = 0 ; }
4267 // 1. Caracteristiques de la frontiere
4268 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
4269 ASSERT(!CORBA::is_nil(myBoundary));
4270 // 2. Les instructions python associees a la frontiere
4271 // La premiere ligne est un commentaire a eliminer
4272 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4273 CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython();
4274 std::string pythonStructure_0 = dumpCorbaBoundary.in();
4275 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4276 std::istringstream tout (pythonStructure_0) ;
4278 std::string pythonStructure ;
4279 while ( std::getline( tout, ligne ) )
4280 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4281 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4282 // 3. Decodage du nom du service
4283 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4284 MESSAGE ( "... methode = " << methode);
4285 // 4. Mise en place des instructions
4286 int BoundaryType = myBoundary->GetType();
4287 MESSAGE ( "... BoundaryType = " << BoundaryType);
4288 const char* MeshName ;
4289 const char* MeshFile ;
4290 if (BoundaryType == 0)
4292 MeshName = myBoundary->GetMeshName() ;
4293 MESSAGE ( ". MeshName = " << MeshName );
4294 MeshFile = myBoundary->GetMeshFile() ;
4295 MESSAGE ( ". MeshFile = " << MeshFile );
4297 std::string texte_control_0 ;
4298 texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName, MeshName, MeshFile );
4299 texte_control += texte_control_0 ;
4300 // 5. Memorisation du traitement
4301 ListeBoundaryTraitees.push_back( BoundaryName );
4305 return texte_control ;
4308 //=============================================================================
4309 //=============================================================================
4310 // Next functions are inherited from SALOMEDS::Driver interface
4311 //=============================================================================
4312 //=============================================================================
4313 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
4315 CORBA::Boolean isMultiFile)
4317 MESSAGE ("Save for theURL = "<< theURL);
4318 SALOMEDS::TMPFile_var aStreamFile;
4320 // get temporary directory name
4321 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4323 StudyContext& context = myStudyContext;
4325 // HOMARD data file name
4326 std::string aFileName = "";
4328 aFileName = SALOMEDS_Tool::GetNameFromPath(Kernel_Utils::encode(SMESH_Gen_i::getStudyServant()->URL()));
4329 aFileName += "_HOMARD.dat";
4331 // initialize sequence of file names
4332 SALOMEDS_Tool::ListOfFiles aFileSeq;
4333 aFileSeq.reserve(1);
4334 aFileSeq.push_back(CORBA::string_dup(aFileName.c_str())) ;
4336 // get full path to the data file
4337 aFileName = tmpDir + aFileName;
4341 std::ofstream f(aFileName.c_str());
4343 // clear temporary id map
4344 context._idmap.clear();
4349 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
4350 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
4351 HOMARD::HOMARD_Cas_var aCas = it_case->second;
4352 PortableServer::ServantBase_var aServant = GetServant(aCas);
4353 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4355 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
4356 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
4360 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4361 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
4362 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
4363 PortableServer::ServantBase_var aServant = GetServant(aZone);
4364 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4366 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
4367 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4370 // -> save hypotheses
4371 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4372 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
4373 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
4374 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4375 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4377 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
4378 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4381 // -> save iterations
4382 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4383 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
4384 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
4385 PortableServer::ServantBase_var aServant = GetServant(aIter);
4386 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4388 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
4389 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4392 // -> save boundaries
4393 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4394 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
4395 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
4396 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4397 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4398 if (aBoundaryServant) {
4399 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
4400 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4404 MESSAGE ("close file");
4407 // put temporary files to the stream
4408 MESSAGE ("put temporary files to the stream");
4409 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq, isMultiFile);
4411 // remove temporary files
4412 MESSAGE ("remove temporary files");
4413 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true);
4415 // return data stream
4416 MESSAGE ("return data stream");
4417 return aStreamFile._retn();
4420 //===========================================================================
4421 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
4423 CORBA::Boolean isMultiFile)
4425 // No specific ASCII persistence
4426 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
4427 return aStreamFile._retn();
4430 //===========================================================================
4431 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
4432 const SALOMEDS::TMPFile& theStream,
4434 CORBA::Boolean isMultiFile)
4436 MESSAGE ("Load pour theURL = "<< theURL);
4438 // set current study
4439 if (myStudy->_is_nil())
4442 // get temporary directory name
4443 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4445 // Convert the stream into sequence of files to process
4446 SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
4449 // HOMARD data file name
4450 std::string aFileName = "";
4452 aFileName = SALOMEDS_Tool::GetNameFromPath(Kernel_Utils::encode(SMESH_Gen_i::getStudyServant()->URL()));
4453 aFileName = tmpDir + aFileName + "_HOMARD.dat";
4455 StudyContext& context = myStudyContext;
4459 std::ifstream f(aFileName.c_str());
4462 context._mesCas.clear();
4463 context._mesHypotheses.clear();
4464 context._mesIterations.clear();
4465 context._mesZones.clear();
4466 context._mesBoundarys.clear();
4467 context._idmap.clear();
4473 std::getline(f, line);
4474 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
4475 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
4476 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
4477 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
4478 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
4479 std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS);
4480 if (line.substr(0, bounSignature.size()) == bounSignature) {
4481 // re-create boundary
4482 MESSAGE ("Recreation de la frontiere" );
4483 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
4484 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4485 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4486 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
4487 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
4488 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4491 else if (line.substr(0, caseSignature.size()) == caseSignature) {
4493 MESSAGE ("Recreation du cas" );
4494 HOMARD::HOMARD_Cas_var aCase = newCase();
4495 PortableServer::ServantBase_var aServant = GetServant(aCase);
4496 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4497 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
4498 context._mesCas[aCase->GetName()] = aCase;
4499 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
4502 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
4503 // re-create hypothesis
4504 MESSAGE ("Recreation de l hypothese" );
4505 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
4506 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4507 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4508 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
4509 context._mesHypotheses[aHypo->GetName()] = aHypo;
4510 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4513 else if (line.substr(0, iterSignature.size()) == iterSignature) {
4514 // re-create iteration
4515 MESSAGE ("Recreation de l'iteration" );
4516 HOMARD::HOMARD_Iteration_var aIter = newIteration();
4517 PortableServer::ServantBase_var aServant = GetServant(aIter);
4518 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4519 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
4520 context._mesIterations[aIter->GetName()] = aIter;
4521 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4524 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
4525 MESSAGE ("Recreation de la zone" );
4527 HOMARD::HOMARD_Zone_var aZone = newZone();
4528 PortableServer::ServantBase_var aServant = GetServant(aZone);
4529 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4530 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
4531 context._mesZones[aZone->GetName()] = aZone;
4532 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4535 else if (line.substr(0, zoneSignature.size()) == yacsSignature) {
4536 MESSAGE ("Recreation du schema YACS" );
4538 HOMARD::HOMARD_YACS_var aYACS = newYACS();
4539 PortableServer::ServantBase_var aServant = GetServant(aYACS);
4540 HOMARD_YACS_i* aYACSServant = dynamic_cast<HOMARD_YACS_i*>(aServant.in());
4541 if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) {
4542 context._mesYACSs[aYACS->GetName()] = aYACS;
4543 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aYACSServant);
4552 // Remove temporary files created from the stream
4554 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true);
4559 //===========================================================================
4560 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
4561 const SALOMEDS::TMPFile& theStream,
4563 CORBA::Boolean isMultiFile)
4565 // No specific ASCII persistence
4566 return Load(theComponent, theStream, theURL, isMultiFile);
4569 //===========================================================================
4570 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
4574 //===========================================================================
4575 char* HOMARD_Gen_i::ComponentDataType()
4577 return CORBA::string_dup("HOMARD");
4580 //===========================================================================
4581 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
4582 const char* IORString,
4583 CORBA::Boolean isMultiFile,
4584 CORBA::Boolean isASCII)
4586 CORBA::String_var aString("");
4587 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
4588 StudyContext context = myStudyContext;
4589 CORBA::Object_var anObj = _orb->string_to_object(IORString);
4590 if (!CORBA::is_nil(anObj)) {
4591 PortableServer::ServantBase_var aServant = GetServant(anObj);
4592 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
4594 std::map<int, PortableServer::ServantBase*>::const_iterator it;
4595 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
4596 if (it->second == aStorable) {
4597 std::stringstream os;
4599 aString = CORBA::string_dup(os.str().c_str());
4605 return aString._retn();
4608 //===========================================================================
4609 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
4610 const char* aLocalPersistentID,
4611 CORBA::Boolean isMultiFile,
4612 CORBA::Boolean isASCII)
4614 CORBA::String_var aString("");
4615 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
4616 StudyContext context = myStudyContext;
4617 int id = atoi(aLocalPersistentID);
4618 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
4619 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
4620 if (!CORBA::is_nil(object)) {
4621 aString = _orb->object_to_string(object);
4625 return aString._retn();
4628 //===========================================================================
4629 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
4631 if(CORBA::is_nil(myStudy))
4634 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
4635 if(!aCas->_is_nil())
4638 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
4639 if(!aHypo->_is_nil())
4642 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
4643 if(!aZone->_is_nil())
4646 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
4647 if(!aBoundary->_is_nil())
4650 /* Iteration is not published directly
4651 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
4652 if(!aIter->_is_nil())
4658 //===========================================================================
4659 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
4661 // No Copy/Paste support
4665 //===========================================================================
4666 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
4667 CORBA::Long& theObjectID)
4669 // No Copy/Paste support
4670 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
4671 return aStreamFile._retn();
4674 //===========================================================================
4675 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
4676 CORBA::Long theObjectID)
4678 // No Copy/Paste support
4682 //===========================================================================
4683 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
4684 CORBA::Long theObjectID,
4685 SALOMEDS::SObject_ptr theSObject)
4687 // No Copy/Paste support
4688 SALOMEDS::SObject_var aResultSO;
4689 return aResultSO._retn();
4692 //===========================================================================
4693 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
4695 PortableServer::Servant aServant = 0;
4696 if (!CORBA::is_nil(theObject)) {
4698 aServant = _poa->reference_to_servant(theObject);
4706 //==========================================================================
4707 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Boolean isPublished,
4708 CORBA::Boolean isMultiFile,
4709 CORBA::Boolean& isValidScript)
4711 MESSAGE ("Entree dans DumpPython");
4714 SALOMEDS::SObject_var aSO = SMESH_Gen_i::getStudyServant()->FindComponent("HOMARD");
4715 if(CORBA::is_nil(aSO))
4716 return new Engines::TMPFile(0);
4718 std::string aScript = "\"\"\"\n";
4719 aScript += "Python script for HOMARD\n";
4720 aScript += "Copyright 1996, 2011, 2015 EDF\n";
4721 aScript += "\"\"\"\n";
4722 aScript += "__revision__ = \"V1.2\"\n";
4723 aScript += "import HOMARD\n";
4725 aScript += "import salome\n";
4726 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4727 aScript += "\thomard.UpdateStudy()\n";
4728 MESSAGE (". Au depart \n"<<aScript);
4731 if (myStudyContext._mesBoundarys.size() > 0)
4733 MESSAGE (". Ecritures des frontieres");
4734 aScript += "#\n# Creation of the boundaries";
4735 aScript += "\n# ==========================";
4737 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4738 for (it_boundary = myStudyContext._mesBoundarys.begin();
4739 it_boundary != myStudyContext._mesBoundarys.end(); ++it_boundary)
4741 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4742 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4743 std::string dumpBoundary = dumpCorbaBoundary.in();
4744 MESSAGE (dumpBoundary<<"\n");
4745 aScript += dumpBoundary;
4749 if (myStudyContext._mesZones.size() > 0)
4751 MESSAGE (". Ecritures des zones");
4752 aScript += "#\n# Creation of the zones";
4753 aScript += "\n# =====================";
4755 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4756 for ( it_zone = myStudyContext._mesZones.begin();
4757 it_zone != myStudyContext._mesZones.end(); ++it_zone)
4759 HOMARD::HOMARD_Zone_var myZone = (*it_zone).second;
4760 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4761 std::string dumpZone = dumpCorbaZone.in();
4762 MESSAGE (dumpZone<<"\n");
4763 aScript += dumpZone;
4767 if (myStudyContext._mesHypotheses.size() > 0)
4769 MESSAGE (". Ecritures des hypotheses");
4770 aScript += "#\n# Creation of the hypotheses";
4771 aScript += "\n# ==========================";
4773 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4774 for ( it_hypo = myStudyContext._mesHypotheses.begin();
4775 it_hypo != myStudyContext._mesHypotheses.end(); it_hypo++)
4777 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4778 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4779 std::string dumpHypo = dumpCorbaHypo.in();
4780 MESSAGE (dumpHypo<<"\n");
4781 aScript += dumpHypo;
4785 if (myStudyContext._mesCas.size() > 0)
4787 MESSAGE (". Ecritures des cas");
4788 aScript += "#\n# Creation of the cases";
4789 aScript += "\n# =====================";
4791 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4792 for (it_cas = myStudyContext._mesCas.begin();
4793 it_cas != myStudyContext._mesCas.end(); it_cas++)
4795 std::string nomCas = (*it_cas).first;
4796 std::string dumpCas = std::string("\n# Creation of the case ") ;
4797 dumpCas += nomCas + std::string("\n");
4798 dumpCas += std::string("\t") + nomCas;
4799 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4801 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4802 CORBA::String_var cIter0= myCase->GetIter0Name();
4803 std::string iter0 = cIter0.in();
4805 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[iter0];
4806 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4807 std::string mesh0 = cMesh0.in();
4808 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4809 std::string meshName0 = cMeshName0.in();
4810 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4811 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4812 std::string dumpCas2= dumpCorbaCase.in();
4814 MESSAGE (dumpCas<<dumpCas2<<"\n");
4815 aScript += dumpCas + dumpCas2;
4819 if (myStudyContext._mesIterations.size() > 0)
4821 MESSAGE (". Ecritures des iterations");
4822 aScript += "#\n# Creation of the iterations" ;
4823 aScript += "\n# ==========================";
4825 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4826 for (it_iter = myStudyContext._mesIterations.begin();
4827 it_iter != myStudyContext._mesIterations.end(); ++it_iter)
4829 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4830 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4831 std::string dumpIter = dumpCorbaIter.in();
4832 MESSAGE (dumpIter<<"\n");
4833 aScript += dumpIter;
4837 if (myStudyContext._mesYACSs.size() > 0)
4839 MESSAGE (". Ecritures des schemas YACS");
4840 aScript += "#\n# Creation of the schemas YACS";
4841 aScript += "\n# ============================";
4843 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it_yacs;
4844 for ( it_yacs = myStudyContext._mesYACSs.begin();
4845 it_yacs != myStudyContext._mesYACSs.end(); ++it_yacs)
4847 HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second;
4848 CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython();
4849 std::string dumpYACS = dumpCorbaYACS.in();
4850 MESSAGE (dumpYACS<<"\n");
4851 aScript += dumpYACS;
4854 MESSAGE (". Ecritures finales");
4856 aScript += "\n\tpass";
4859 if( !isMultiFile ) // remove unnecessary tabulation
4860 aScript = RemoveTabulation( aScript );
4862 // MESSAGE ("A ecrire \n"<<aScript);
4863 const size_t aLen = strlen(aScript.c_str());
4864 char* aBuffer = new char[aLen+1];
4865 strcpy(aBuffer, aScript.c_str());
4867 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4868 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4870 MESSAGE ("Sortie de DumpPython");
4871 return aStreamFile._retn();
4875 //=============================================================================
4876 //=============================================================================
4878 //=============================================================================
4879 //=============================================================================
4880 void HOMARD_Gen_i::IsValidStudy( )
4882 // MESSAGE( "IsValidStudy" );
4883 if (CORBA::is_nil(SMESH_Gen_i::getStudyServant()))
4885 SALOME::ExceptionStruct es;
4886 es.type = SALOME::BAD_PARAM;
4887 es.text = "Invalid study context";
4888 throw SALOME::SALOME_Exception(es);
4893 //=============================================================================
4894 char* HOMARD_Gen_i::VerifieDir(const char* nomDir)
4896 std::string casename = std::string("") ;
4897 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4898 for (it = myStudyContext._mesCas.begin();
4899 it != myStudyContext._mesCas.end(); it++)
4901 if (std::string(nomDir) == std::string(it->second->GetDirName()))
4903 casename = std::string(it->second->GetName()) ;
4907 return CORBA::string_dup( casename.c_str() );
4909 /*//=============================================================================
4910 void SALOMEException( std::string message )
4912 SALOME::ExceptionStruct es;
4913 es.type = SALOME::BAD_PARAM;
4915 throw SALOME::SALOME_Exception(es);
4918 //=============================================================================
4919 char* HOMARD_Gen_i::getVersion()
4921 #if HOMARD_DEVELOPMENT
4922 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4924 return CORBA::string_dup(HOMARD_VERSION_STR);
4927 //===============================================================================
4928 // Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere
4929 // ligne : la ligne a manipuler
4930 // caractere : le caractere a reperer
4931 // option : 0 : la chaine avant la premiere apparition du caractere
4932 // 1 : la chaine apres la premiere apparition du caractere
4933 // 2 : la chaine avant la derniere apparition du caractere
4934 // 3 : la chaine apres la derniere apparition du caractere
4935 // Si le caractere est absent, on retourne la chaine totale
4936 //===============================================================================
4937 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option )
4939 // MESSAGE("GetStringInTexte, recherche de '"<<caractere<<"' dans '"<<ligne<<"'"<<", option = "<<option);
4941 std::string chaine = ligne ;
4943 if ( option < 2 ) { position = ligne.find_first_of( caractere ) ; }
4944 else { position = ligne.find_last_of( caractere ) ; }
4945 // MESSAGE("position = "<<position);
4946 // MESSAGE("a = "<<ligne.substr( 0, position ).c_str());
4947 // MESSAGE("b = "<<ligne.substr( position+1 ).c_str());
4949 if ( position != std::string::npos )
4951 if ( ( option == 0 ) || ( option == 2 ) ) { chaine = ligne.substr( 0, position ) ; }
4952 else { chaine = ligne.substr( position+1 ) ; }
4957 //=============================================================================
4958 //=============================================================================
4959 // Gestion des preferences
4960 //=============================================================================
4961 //=============================================================================
4962 // Decodage du fichier d'arcihvage des preferences
4964 void HOMARD_Gen_i::SetPreferences( )
4966 MESSAGE ( "SetPreferences" );
4968 std::string ligne, mot_cle, salome_version ;
4971 // A. Les valeurs par defaut ; elles doivent etre coherentes
4972 std::string LanguageShort = "en" ;
4973 int PublisMeshIN = 0 ;
4974 int PublisMeshOUT = 0 ;
4975 int YACSMaxIter = 0 ;
4976 int YACSMaxNode = 0 ;
4977 int YACSMaxElem = 0 ;
4978 std::string YACSTypeTestchaine = "None" ;
4980 // B. La version de salome
4981 // Cela se presente sous la forme :
4982 // [SALOME KERNEL] : 7.3.0
4984 File = getenv("KERNEL_ROOT_DIR") ;
4985 File += "/bin/salome/VERSION" ;
4986 MESSAGE ( "File = "<<File ) ;
4987 std::ifstream fichier0( File.c_str() ) ;
4988 if ( fichier0 ) // ce test ??choue si le fichier n'est pas ouvert
4990 std::string ligne; // variable contenant chaque ligne lue
4991 while ( std::getline( fichier0, ligne ) )
4993 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4994 ligne_bis >> mot_cle ;
4995 if ( mot_cle == "[SALOME" )
4997 salome_version = GetStringInTexte ( ligne, " ", 3 ) ;
4998 // MESSAGE ( "salome_version = "<<salome_version<<"|||");
5003 else { ok = false ; }
5005 // B. Decodage du fichier de preferences
5008 std::string PrefFile ;
5009 PrefFile = getenv("HOME") ;
5010 PrefFile += "/.config/salome/SalomeApprc." + salome_version ;
5011 MESSAGE ( "PrefFile = "<<PrefFile ) ;
5013 std::ifstream fichier( PrefFile.c_str() );
5014 if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
5016 bool section_langue = false ;
5017 bool section_homard = false ;
5018 while ( std::getline( fichier, ligne ) )
5020 std::string chaine ;
5021 // 1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
5022 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
5023 ligne_bis >> mot_cle ;
5026 // 2.1. Debut d'une section
5027 // MESSAGE(mot_cle);
5028 if ( mot_cle == "<section" )
5029 { /*MESSAGE ( "Debut de la section : "<< ligne);*/
5030 ligne_bis >> mot_cle ;
5031 chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5032 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5033 if ( chaine == "language" ) { section_langue = true ; }
5034 if ( chaine == "HOMARD" ) { section_homard = true ; }
5035 // MESSAGE ( "section_langue = "<<section_langue<<", section_homard = "<<section_homard);
5037 // 2.2. Fin d'une section
5038 else if ( mot_cle == "</section>" )
5039 { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<<section_langue<<", section_homard = "<<section_homard);*/
5040 section_langue = false ;
5041 section_homard = false ; }
5045 else if ( section_langue || section_homard )
5046 { MESSAGE ( "a decoder : "<< ligne);
5047 // La valeur : entre les deux premieres quotes
5048 chaine = GetStringInTexte ( ligne, "\"", 1 ) ;
5049 // MESSAGE("chaine 1 = |"<<chaine<<"|");
5050 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5051 // MESSAGE("chaine = |"<<chaine<<"|");
5052 // Le mot_cle : entre les deux dernieres quotes
5053 std::string chaine2 = GetStringInTexte ( ligne, "\"", 2 ) ;
5054 // MESSAGE("chaine2 1 = |"<<chaine2<<"|");
5055 chaine2 = GetStringInTexte ( chaine2, "\"", 3 ) ;
5056 // MESSAGE("chaine2 = |"<<chaine2<<"|");
5058 if ( section_langue )
5059 { if ( chaine2 == "language" ) { LanguageShort = chaine ; } }
5061 if ( section_homard )
5063 std::istringstream chainebis( chaine ) ;
5064 // 3.2.1. Les publications
5065 if ( chaine2 == "publish_mesh_in" ) { chainebis >> PublisMeshIN ; }
5066 if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT ; }
5067 // 3.2.2. Les maximum pour YACS
5068 if ( chaine2 == "yacs_max_iter" ) { chainebis >> YACSMaxIter ; }
5069 if ( chaine2 == "yacs_max_node" ) { chainebis >> YACSMaxNode ; }
5070 if ( chaine2 == "yacs_max_elem" ) { chainebis >> YACSMaxElem ; }
5071 if ( chaine2 == "yacs_type_test" ) { YACSTypeTestchaine = chaine ; }
5078 // C. Enregistrements
5079 MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort );
5080 SetLanguageShort( LanguageShort.c_str() ) ;
5082 MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT);
5083 SetPublisMesh(PublisMeshIN, PublisMeshOUT) ;
5085 MESSAGE ("Enregistrement de YACSMaxIter = " << YACSMaxIter<<", YACSMaxNode = "<< YACSMaxNode<<", YACSMaxElem = "<< YACSMaxElem);
5086 SetYACSMaximum(YACSMaxIter, YACSMaxNode, YACSMaxElem) ;
5088 MESSAGE ("Enregistrement de TypeTest = " << YACSTypeTestchaine.c_str() );
5090 if ( ( YACSTypeTestchaine == "VTest > VRef" ) || ( YACSTypeTestchaine == "VTest > VRef" ) ) { YACSTypeTest = 1 ; }
5091 else if ( ( YACSTypeTestchaine == "VTest < VRef" ) || ( YACSTypeTestchaine == "VTest < VRef" ) ) { YACSTypeTest = 2 ; }
5092 else { YACSTypeTest = 0 ; }
5093 MESSAGE ("==> TypeTest = " << YACSTypeTest );
5094 SetYACSConvergenceType( YACSTypeTest ) ;
5098 //===============================================================================
5100 //===============================================================================
5101 void HOMARD_Gen_i::SetLanguageShort(const char* LanguageShort)
5103 // MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort );
5104 _LangueShort = LanguageShort ;
5105 if ( _LangueShort == "fr" ) { _Langue = "Francais" ; }
5106 else { _Langue = "English" ; }
5109 char* HOMARD_Gen_i::GetLanguageShort()
5111 // MESSAGE ("GetLanguageShort");
5112 return CORBA::string_dup( _LangueShort.c_str() );
5114 //===============================================================================
5115 // Options de publications
5116 //===============================================================================
5117 void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT)
5119 _PublisMeshIN = PublisMeshIN ;
5120 _PublisMeshOUT = PublisMeshOUT ;
5123 CORBA::Long HOMARD_Gen_i::GetPublisMeshIN()
5125 return _PublisMeshIN ;
5127 CORBA::Long HOMARD_Gen_i::GetPublisMeshOUT()
5129 return _PublisMeshOUT ;
5131 //===============================================================================
5132 // YACS - test de convergence
5133 //===============================================================================
5134 void HOMARD_Gen_i::SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem)
5136 _YACSMaxIter = YACSMaxIter ;
5137 _YACSMaxNode = YACSMaxNode ;
5138 _YACSMaxElem = YACSMaxElem ;
5141 CORBA::Long HOMARD_Gen_i::GetYACSMaxIter()
5143 return _YACSMaxIter ;
5145 CORBA::Long HOMARD_Gen_i::GetYACSMaxNode()
5147 return _YACSMaxNode ;
5149 CORBA::Long HOMARD_Gen_i::GetYACSMaxElem()
5151 return _YACSMaxElem ;
5153 void HOMARD_Gen_i::SetYACSConvergenceType(CORBA::Long YACSTypeTest)
5155 _YACSTypeTest = YACSTypeTest ;
5158 CORBA::Long HOMARD_Gen_i::GetYACSConvergenceType()
5160 return _YACSTypeTest ;
5163 //=============================================================================
5167 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
5168 PortableServer::POA_ptr poa,
5169 PortableServer::ObjectId* contId,
5170 const char* instanceName,
5171 const char* interfaceName)
5173 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
5174 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
5175 return myHOMARD_Gen->getId();