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 "Utils_SINGLETON.hxx"
37 #include "Utils_CorbaException.hxx"
38 #include "SALOMEDS_Tool.hxx"
39 #include "SALOME_LifeCycleCORBA.hxx"
40 #include "SALOMEconfig.h"
41 #include <SMESH_Gen_i.hxx>
42 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
43 #include CORBA_CLIENT_HEADER(SMESH_Gen)
66 //=============================================================================
68 //=============================================================================
69 std::string RemoveTabulation( std::string theScript )
71 std::string::size_type aPos = 0;
72 while( aPos < theScript.length() )
74 aPos = theScript.find( "\n\t", aPos );
75 if( aPos == std::string::npos )
77 theScript.replace( aPos, 2, "\n" );
82 //=============================================================================
84 * standard constructor
86 //=============================================================================
87 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
88 PortableServer::POA_ptr poa,
89 PortableServer::ObjectId * contId,
90 const char *instanceName,
91 const char *interfaceName) :
92 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
94 MESSAGE("constructor");
96 _id = _poa->activate_object(_thisObj);
98 myHomard = new ::HOMARD_Gen();
99 _NS = SINGLETON_<SALOME_NamingService>::Instance();
100 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
103 myStudy = SALOMEDS::Study::_duplicate( SMESH_Gen_i::getStudyServant() );
113 //=================================
115 * standard destructor
117 //================================
118 HOMARD_Gen_i::~HOMARD_Gen_i()
121 //=============================================================================
122 //=============================================================================
123 // Utilitaires pour l'étude
124 //=============================================================================
125 //=============================================================================
126 void HOMARD_Gen_i::UpdateStudy()
128 ASSERT(!CORBA::is_nil(myStudy));
129 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
131 // Create SComponent labelled 'homard' if it doesn't already exit
132 SALOMEDS::SComponent_var homardFather = myStudy->FindComponent(ComponentDataType());
133 if (CORBA::is_nil(homardFather))
135 myBuilder->NewCommand();
136 MESSAGE("Add Component HOMARD");
138 bool aLocked = myStudy->GetProperties()->IsLocked();
139 if (aLocked) myStudy->GetProperties()->SetLocked(false);
141 homardFather = myBuilder->NewComponent(ComponentDataType());
142 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
143 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
144 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
145 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
146 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
147 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
148 if (!Comp->_is_nil())
150 aName->SetValue(ComponentDataType());
153 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
154 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
155 aPixmap->SetPixMap("HOMARD_2.png");
156 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
158 if (aLocked) myStudy->GetProperties()->SetLocked(true);
159 myBuilder->CommitCommand();
163 //=============================================================================
164 //=============================================================================
165 // Utilitaires pour l'iteration
166 //=============================================================================
167 //=============================================================================
168 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
169 //=====================================================================================
171 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
172 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
173 if (CORBA::is_nil(myIteration))
175 SALOME::ExceptionStruct es;
176 es.type = SALOME::BAD_PARAM;
177 es.text = "Invalid iteration";
178 throw SALOME::SALOME_Exception(es);
182 myIteration->SetState(Etat);
184 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
185 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
189 icone = "iter0.png" ;
190 else if ( Etat == 2 )
191 icone = "iter_calculee.png" ;
193 icone = "iter_non_calculee.png" ;
194 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ;
196 aStudyBuilder->CommitCommand();
199 //=============================================================================
200 //=============================================================================
202 //=============================================================================
203 //=============================================================================
204 // Destruction des structures identifiees par leurs noms
205 //=============================================================================
206 //=============================================================================
207 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
209 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
210 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
211 if (CORBA::is_nil(myBoundary))
213 SALOME::ExceptionStruct es;
214 es.type = SALOME::BAD_PARAM;
215 es.text = "Invalid boundary";
216 throw SALOME::SALOME_Exception(es);
220 // On verifie que la frontiere n'est plus utilisee
221 HOMARD::listeCases* maListe = GetAllCasesName();
222 int numberOfCases = maListe->length();
223 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
224 std::string CaseName ;
225 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
227 HOMARD::HOMARD_Cas_var myCase ;
228 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
230 CaseName = std::string((*maListe)[NumeCas]);
231 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
232 myCase = myStudyContext._mesCas[CaseName];
233 ASSERT(!CORBA::is_nil(myCase));
234 ListBoundaryGroupType = myCase->GetBoundaryGroup();
235 numberOfitems = ListBoundaryGroupType->length();
236 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
237 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
239 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
241 SALOME::ExceptionStruct es;
242 es.type = SALOME::BAD_PARAM;
243 es.text = "This boundary is used in a case and cannot be deleted.";
244 throw SALOME::SALOME_Exception(es);
250 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
251 myStudyContext._mesBoundarys.erase(BoundaryName);
252 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(BoundaryName, ComponentDataType());
253 SALOMEDS::SObject_var aSO =listSO[0];
254 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
255 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
259 //=============================================================================
260 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option)
262 // Pour detruire un cas
263 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
264 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
265 if (CORBA::is_nil(myCase))
267 SALOME::ExceptionStruct es;
268 es.type = SALOME::BAD_PARAM;
269 es.text = "Invalid case context";
270 throw SALOME::SALOME_Exception(es);
273 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
274 CORBA::String_var nomIter = myCase->GetIter0Name();
275 CORBA::Long Option1 = 0 ;
276 if ( DeleteIterationOption(nomIter, Option1, Option) != 0 )
281 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
282 myStudyContext._mesCas.erase(nomCas);
283 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomCas, ComponentDataType());
284 SALOMEDS::SObject_var aSO =listSO[0];
285 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
286 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
290 //=============================================================================
291 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
293 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
294 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
295 if (CORBA::is_nil(myHypo))
297 SALOME::ExceptionStruct es;
298 es.type = SALOME::BAD_PARAM;
299 es.text = "Invalid hypothesis";
300 throw SALOME::SALOME_Exception(es);
304 // On verifie que l'hypothese n'est plus utilisee
305 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
306 int numberOfIter = maListeIter->length();
307 if ( numberOfIter > 0 )
309 SALOME::ExceptionStruct es;
310 es.type = SALOME::BAD_PARAM;
311 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
312 throw SALOME::SALOME_Exception(es);
316 // suppression du lien avec les zones eventuelles
317 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
318 int numberOfZones = maListe->length();
319 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
320 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
322 std::string ZoneName = std::string((*maListe)[NumeZone]);
323 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
324 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
328 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
329 myStudyContext._mesHypotheses.erase(nomHypo);
330 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomHypo, ComponentDataType());
331 SALOMEDS::SObject_var aSO =listSO[0];
332 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
333 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
337 //=============================================================================
338 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
340 // Option = 0 : On ne supprime pas le fichier du maillage associe
341 // Option = 1 : On supprime le fichier du maillage associe
342 // Pour detruire une iteration courante
343 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
344 CORBA::Long Option1 = 1 ;
345 return DeleteIterationOption(nomIter, Option1, Option);
347 //=============================================================================
348 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
350 // Option1 = 0 : On autorise la destruction de l'iteration 0
351 // Option1 = 1 : On interdit la destruction de l'iteration 0
353 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
354 // Option2 = 1 : On supprime le fichier du maillage associe
355 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
356 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
357 if (CORBA::is_nil(myIteration))
359 SALOME::ExceptionStruct es;
360 es.type = SALOME::BAD_PARAM;
361 es.text = "Invalid iteration";
362 throw SALOME::SALOME_Exception(es);
366 int numero = myIteration->GetNumber();
367 MESSAGE ( "DeleteIterationOption : numero = " << numero );
368 if ( numero == 0 && Option1 == 1 )
370 SALOME::ExceptionStruct es;
371 es.type = SALOME::BAD_PARAM;
372 es.text = "This iteration cannot be deleted.";
373 throw SALOME::SALOME_Exception(es);
377 // On detruit recursivement toutes les filles
378 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
379 int numberOfIter = maListe->length();
380 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
382 std::string nomIterFille = std::string((*maListe)[NumeIter]);
383 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
384 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
387 // On arrive ici pour une iteration sans fille
388 MESSAGE ( "Destruction effective de " << nomIter );
389 // On commence par invalider l'iteration pour faire le menage des dependances
390 // et eventuellement du maillage associe
392 if ( numero == 0 ) { option = 0 ; }
393 else { option = Option2 ; }
394 InvalideIterOption(nomIter, option) ;
396 // Retrait dans la descendance de l'iteration parent
399 std::string nomIterationParent = myIteration->GetIterParentName();
400 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
401 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
402 if (CORBA::is_nil(myIterationParent))
404 SALOME::ExceptionStruct es;
405 es.type = SALOME::BAD_PARAM;
406 es.text = "Invalid iteration";
407 throw SALOME::SALOME_Exception(es);
410 myIterationParent->UnLinkNextIteration(nomIter);
413 // suppression du lien avec l'hypothese
416 std::string nomHypo = myIteration->GetHypoName();
417 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
418 ASSERT(!CORBA::is_nil(myHypo));
419 myHypo->UnLinkIteration(nomIter);
422 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
423 myStudyContext._mesIterations.erase(nomIter);
424 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomIter, ComponentDataType());
425 SALOMEDS::SObject_var aSO =listSO[0];
426 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
427 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
428 // on peut aussi faire RemoveObject
429 // MESSAGE ( "Au final" );
430 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
431 // numberOfIter = Liste->length();
432 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
434 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
435 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
440 //=============================================================================
441 CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option)
443 // Option = 0 : On ne supprime pas le fichier du schema associe
444 // Option = 1 : On supprime le fichier du schema associe
445 MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option );
446 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
447 if (CORBA::is_nil(myYACS))
449 SALOME::ExceptionStruct es;
450 es.type = SALOME::BAD_PARAM;
451 es.text = "Invalid schema YACS";
452 throw SALOME::SALOME_Exception(es);
455 // Suppression eventuelle du fichier XML
458 std::string nomFichier = myYACS->GetXMLFile();
459 std::string commande = "rm -rf " + nomFichier ;
460 MESSAGE ( "commande = " << commande );
461 if ((system(commande.c_str())) != 0)
463 SALOME::ExceptionStruct es;
464 es.type = SALOME::BAD_PARAM;
465 es.text = "The xml file for the schema YACS cannot be removed." ;
466 throw SALOME::SALOME_Exception(es);
470 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
471 myStudyContext._mesYACSs.erase(nomYACS);
472 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomYACS, ComponentDataType());
473 SALOMEDS::SObject_var aSO =listSO[0];
474 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
475 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
479 //=============================================================================
480 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
482 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
483 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[nomZone];
484 if (CORBA::is_nil(myZone))
486 SALOME::ExceptionStruct es;
487 es.type = SALOME::BAD_PARAM;
488 es.text = "Invalid zone";
489 throw SALOME::SALOME_Exception(es);
493 // On verifie que la zone n'est plus utilisee
494 HOMARD::listeHypo* maListe = myZone->GetHypo();
495 int numberOfHypo = maListe->length();
496 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
497 if ( numberOfHypo > 0 )
499 SALOME::ExceptionStruct es;
500 es.type = SALOME::BAD_PARAM;
501 es.text = "This zone is used in an hypothesis and cannot be deleted.";
502 throw SALOME::SALOME_Exception(es);
506 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
507 myStudyContext._mesZones.erase(nomZone);
508 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomZone, ComponentDataType());
509 SALOMEDS::SObject_var aSO =listSO[0];
510 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
511 myStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
515 //=============================================================================
516 //=============================================================================
518 //=============================================================================
519 //=============================================================================
520 // Invalidation des structures identifiees par leurs noms
521 //=============================================================================
522 //=============================================================================
523 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
525 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
526 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
527 if (CORBA::is_nil(myBoundary))
529 SALOME::ExceptionStruct es;
530 es.type = SALOME::BAD_PARAM;
531 es.text = "Invalid boundary";
532 throw SALOME::SALOME_Exception(es);
537 SALOME::ExceptionStruct es;
538 es.type = SALOME::BAD_PARAM;
539 es.text = "No change is allowed in a boundary. Ask for evolution.";
540 throw SALOME::SALOME_Exception(es);
544 //=============================================================================
545 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
547 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
548 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
549 if (CORBA::is_nil(myHypo))
551 SALOME::ExceptionStruct es;
552 es.type = SALOME::BAD_PARAM;
553 es.text = "Invalid hypothesis";
554 throw SALOME::SALOME_Exception(es);
558 HOMARD::listeIters* maListe = myHypo->GetIterations();
559 int numberOfIter = maListe->length();
560 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
562 std::string nomIter = std::string((*maListe)[NumeIter]);
563 MESSAGE( ".. nomIter = " << nomIter );
564 InvalideIter(nomIter.c_str());
567 //=============================================================================
568 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
570 MESSAGE("InvalideIter : nomIter = " << nomIter);
571 // Pour invalider totalement une iteration courante
572 CORBA::Long Option = 1 ;
573 return InvalideIterOption(nomIter, Option);
575 //=============================================================================
576 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
578 // Option = 0 : On ne supprime pas le fichier du maillage associe
579 // Option = 1 : On supprime le fichier du maillage associe
580 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
581 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
582 if (CORBA::is_nil(myIteration))
584 SALOME::ExceptionStruct es;
585 es.type = SALOME::BAD_PARAM;
586 es.text = "Invalid iteration";
587 throw SALOME::SALOME_Exception(es);
591 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
592 int numberOfIter = maListe->length();
593 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
595 std::string nomIterFille = std::string((*maListe)[NumeIter]);
596 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
597 InvalideIter(nomIterFille.c_str());
600 // On arrive ici pour une iteration sans fille
601 MESSAGE ( "Invalidation effective de " << nomIter );
602 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
603 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO);
604 for (; aIter->More(); aIter->Next())
606 SALOMEDS::SObject_var so = aIter->Value();
607 SALOMEDS::GenericAttribute_var anAttr;
608 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
609 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
610 std::string value (aCommentAttr->Value());
611 if(value == std::string("IterationHomard")) continue;
612 if(value == std::string("HypoHomard")) continue;
613 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
614 aStudyBuilder->RemoveObject(so);
617 int etat = myIteration->GetState();
620 SetEtatIter(nomIter,1);
621 const char * nomCas = myIteration->GetCaseName();
622 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
623 if (CORBA::is_nil(myCase))
625 SALOME::ExceptionStruct es;
626 es.type = SALOME::BAD_PARAM;
627 es.text = "Invalid case context";
628 throw SALOME::SALOME_Exception(es);
631 std::string nomDir = myIteration->GetDirName();
632 std::string nomFichier = myIteration->GetMeshFile();
633 std::string commande = "rm -rf " + std::string(nomDir);
634 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
635 MESSAGE ( "commande = " << commande );
636 if ((system(commande.c_str())) != 0)
638 SALOME::ExceptionStruct es;
639 es.type = SALOME::BAD_PARAM;
640 es.text = "The directory for the calculation cannot be cleared." ;
641 throw SALOME::SALOME_Exception(es);
644 // Suppression du maillage publie dans SMESH
645 std::string MeshName = myIteration->GetMeshName() ;
646 DeleteResultInSmesh(nomFichier, MeshName) ;
650 //=============================================================================
651 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
653 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
654 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
655 if (CORBA::is_nil(myIteration))
657 SALOME::ExceptionStruct es;
658 es.type = SALOME::BAD_PARAM;
659 es.text = "Invalid iteration";
660 throw SALOME::SALOME_Exception(es);
664 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
665 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO);
666 for (; aIter->More(); aIter->Next())
668 SALOMEDS::SObject_var so = aIter->Value();
669 SALOMEDS::GenericAttribute_var anAttr;
670 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
671 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
672 std::string value (aCommentAttr->Value());
673 /* MESSAGE("... value = " << value);*/
674 if( (value == std::string("logInfo")) || ( value == std::string("SummaryInfo")) )
676 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
677 aStudyBuilder->RemoveObject(so);
681 const char * nomCas = myIteration->GetCaseName();
682 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
683 if (CORBA::is_nil(myCase))
685 SALOME::ExceptionStruct es;
686 es.type = SALOME::BAD_PARAM;
687 es.text = "Invalid case context";
688 throw SALOME::SALOME_Exception(es);
691 const char* nomDir = myIteration->GetDirName();
692 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
693 commande += std::string(nomDir) + "/Liste.*info" ;
694 /* MESSAGE ( "commande = " << commande );*/
695 if ((system(commande.c_str())) != 0)
697 SALOME::ExceptionStruct es;
698 es.type = SALOME::BAD_PARAM;
699 es.text = "The directory for the calculation cannot be cleared." ;
700 throw SALOME::SALOME_Exception(es);
704 //=============================================================================
705 void HOMARD_Gen_i::InvalideYACS(const char* YACSName)
707 MESSAGE( "InvalideYACS : YACSName = " << YACSName );
708 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[YACSName];
709 if (CORBA::is_nil(myYACS))
711 SALOME::ExceptionStruct es;
712 es.type = SALOME::BAD_PARAM;
713 es.text = "Invalid schema YACS";
714 throw SALOME::SALOME_Exception(es);
718 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
719 SALOMEDS::ChildIterator_var aYACS = myStudy->NewChildIterator(aYACSSO);
720 for (; aYACS->More(); aYACS->Next())
722 SALOMEDS::SObject_var so = aYACS->Value();
723 SALOMEDS::GenericAttribute_var anAttr;
724 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
725 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
726 std::string value (aCommentAttr->Value());
727 if( value == std::string("xml") )
729 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
730 aStudyBuilder->RemoveObject(so);
733 std::string nomFichier = myYACS->GetXMLFile();
734 std::string commande = "rm -rf " + std::string(nomFichier) ;
735 MESSAGE ( "commande = " << commande );
736 if ((system(commande.c_str())) != 0)
738 SALOME::ExceptionStruct es;
739 es.type = SALOME::BAD_PARAM;
740 es.text = "The XML file for the schema YACS cannot be removed." ;
741 throw SALOME::SALOME_Exception(es);
745 //=============================================================================
746 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
748 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
749 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
750 if (CORBA::is_nil(myZone))
752 SALOME::ExceptionStruct es;
753 es.type = SALOME::BAD_PARAM;
754 es.text = "Invalid zone";
755 throw SALOME::SALOME_Exception(es);
758 HOMARD::listeHypo* maListe = myZone->GetHypo();
759 int numberOfHypo = maListe->length();
760 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
761 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
763 std::string nomHypo = std::string((*maListe)[NumeHypo]);
764 MESSAGE( ".. nomHypo = " << nomHypo );
765 InvalideHypo(nomHypo.c_str());
768 //=============================================================================
769 //=============================================================================
771 //=============================================================================
772 //=============================================================================
773 // Association de lien entre des structures identifiees par leurs noms
774 //=============================================================================
775 //=============================================================================
776 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
778 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
780 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
781 if (CORBA::is_nil(myCase))
783 SALOME::ExceptionStruct es;
784 es.type = SALOME::BAD_PARAM;
785 es.text = "Invalid case";
786 throw SALOME::SALOME_Exception(es);
790 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
791 if (CORBA::is_nil(myIteration))
793 SALOME::ExceptionStruct es;
794 es.type = SALOME::BAD_PARAM;
795 es.text = "Invalid iteration";
796 throw SALOME::SALOME_Exception(es);
800 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
801 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase)));
802 if (CORBA::is_nil(aCasSO))
804 SALOME::ExceptionStruct es;
805 es.type = SALOME::BAD_PARAM;
806 es.text = "Invalid case";
807 throw SALOME::SALOME_Exception(es);
811 aStudyBuilder->NewCommand();
812 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
813 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
814 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
815 aStudyBuilder->CommitCommand();
817 myCase->AddIteration(nomIter);
818 myIteration->SetCaseName(nomCas);
820 //=====================================================================================
821 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
823 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
825 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis];
826 ASSERT(!CORBA::is_nil(myHypo));
827 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
828 ASSERT(!CORBA::is_nil(aHypoSO));
830 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
831 ASSERT(!CORBA::is_nil(myZone));
832 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone)));
833 ASSERT(!CORBA::is_nil(aZoneSO));
835 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
837 aStudyBuilder->NewCommand();
839 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
840 aStudyBuilder->Addreference(aSubSO, aZoneSO);
842 aStudyBuilder->CommitCommand();
844 myZone->AddHypo(nomHypothesis);
845 myHypo->AddZone0(ZoneName, TypeUse);
847 //=============================================================================
848 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
850 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
852 // Verification de l'existence de l'hypothese
853 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
854 ASSERT(!CORBA::is_nil(myHypo));
855 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
856 ASSERT(!CORBA::is_nil(aHypoSO));
858 // Verification de l'existence de l'iteration
859 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter];
860 ASSERT(!CORBA::is_nil(myIteration));
861 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
862 ASSERT(!CORBA::is_nil(aIterSO));
864 // Gestion de l'arbre d'etudes
865 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
866 aStudyBuilder->NewCommand();
867 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
868 aStudyBuilder->Addreference(aSubSO, aHypoSO);
869 aStudyBuilder->CommitCommand();
872 myIteration->SetHypoName(nomHypo);
873 myHypo->LinkIteration(nomIter);
875 // On stocke les noms des champ a interpoler pour le futur controle de la donnee des pas de temps
876 myIteration->SupprFieldInterps() ;
877 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
878 int numberOfFieldsx2 = ListField->length();
879 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
881 std::string FieldName = std::string((*ListField)[iaux]) ;
882 myIteration->SetFieldInterp(FieldName.c_str()) ;
886 //=============================================================================
887 //=============================================================================
889 //=============================================================================
890 //=============================================================================
891 // Dissociation de lien entre des structures identifiees par leurs noms
892 //=============================================================================
893 //=============================================================================
894 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
896 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
898 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis];
899 ASSERT(!CORBA::is_nil(myHypo));
900 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
901 ASSERT(!CORBA::is_nil(aHypoSO));
903 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
904 ASSERT(!CORBA::is_nil(myZone));
905 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone)));
906 ASSERT(!CORBA::is_nil(aZoneSO));
908 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
910 SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(aHypoSO);
911 for (; it->More(); it->Next())
913 SALOMEDS::SObject_var aHypObj = it->Value();
914 SALOMEDS::SObject_var ptrObj;
915 if (aHypObj->ReferencedObject(ptrObj))
917 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
919 aStudyBuilder->NewCommand();
920 aStudyBuilder->RemoveObject(aHypObj);
921 aStudyBuilder->CommitCommand();
927 myZone->SupprHypo(nomHypothesis);
928 myHypo->SupprZone(ZoneName);
930 //=============================================================================
931 //=============================================================================
934 //=============================================================================
935 //=============================================================================
936 // Recuperation des listes
937 //=============================================================================
938 //=============================================================================
939 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
941 MESSAGE("GetAllBoundarysName");
944 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
945 ret->length(myStudyContext._mesBoundarys.size());
946 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
948 for (it = myStudyContext._mesBoundarys.begin();
949 it != myStudyContext._mesBoundarys.end(); it++)
951 ret[i++] = CORBA::string_dup((*it).first.c_str());
956 //=============================================================================
957 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
959 MESSAGE("GetAllCasesName");
962 HOMARD::listeCases_var ret = new HOMARD::listeCases;
963 ret->length(myStudyContext._mesCas.size());
964 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
966 for (it = myStudyContext._mesCas.begin();
967 it != myStudyContext._mesCas.end(); it++)
969 ret[i++] = CORBA::string_dup((*it).first.c_str());
974 //=============================================================================
975 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
977 MESSAGE("GetAllHypothesesName");
980 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
981 ret->length(myStudyContext._mesHypotheses.size());
982 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
984 for (it = myStudyContext._mesHypotheses.begin();
985 it != myStudyContext._mesHypotheses.end(); it++)
987 ret[i++] = CORBA::string_dup((*it).first.c_str());
992 //=============================================================================
993 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
995 MESSAGE("GetAllIterationsName");
998 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
999 ret->length(myStudyContext._mesIterations.size());
1000 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
1002 for (it = myStudyContext._mesIterations.begin();
1003 it != myStudyContext._mesIterations.end(); it++)
1005 ret[i++] = CORBA::string_dup((*it).first.c_str());
1010 //=============================================================================
1011 HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName()
1013 MESSAGE("GetAllYACSsName");
1016 HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs;
1017 ret->length(myStudyContext._mesYACSs.size());
1018 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it;
1020 for (it = myStudyContext._mesYACSs.begin();
1021 it != myStudyContext._mesYACSs.end(); it++)
1023 ret[i++] = CORBA::string_dup((*it).first.c_str());
1028 //=============================================================================
1029 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
1031 MESSAGE("GetAllZonesName");
1034 HOMARD::listeZones_var ret = new HOMARD::listeZones;
1035 ret->length(myStudyContext._mesZones.size());
1036 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
1038 for (it = myStudyContext._mesZones.begin();
1039 it != myStudyContext._mesZones.end(); it++)
1041 ret[i++] = CORBA::string_dup((*it).first.c_str());
1046 //=============================================================================
1047 //=============================================================================
1049 //=============================================================================
1050 //=============================================================================
1051 // Recuperation des structures identifiees par leurs noms
1052 //=============================================================================
1053 //=============================================================================
1054 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
1056 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[nomBoundary];
1057 ASSERT(!CORBA::is_nil(myBoundary));
1058 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1060 //=============================================================================
1061 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
1063 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
1064 ASSERT(!CORBA::is_nil(myCase));
1065 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1067 //=============================================================================
1068 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
1070 HOMARD::HOMARD_Hypothesis_var myHypothesis = myStudyContext._mesHypotheses[nomHypothesis];
1071 ASSERT(!CORBA::is_nil(myHypothesis));
1072 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1074 //=============================================================================
1075 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
1077 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIterationation];
1078 ASSERT(!CORBA::is_nil(myIteration));
1079 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1081 //=============================================================================
1082 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS)
1084 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
1085 ASSERT(!CORBA::is_nil(myYACS));
1086 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
1088 //=============================================================================
1089 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
1091 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
1092 ASSERT(!CORBA::is_nil(myZone));
1093 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1095 //=============================================================================
1096 //=============================================================================
1098 //=============================================================================
1099 //=============================================================================
1101 //=============================================================================
1102 //=============================================================================
1103 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)
1105 INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1106 INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
1111 if ( _PublisMeshIN != 0 ) option = 2 ;
1112 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option) ;
1113 myCase->SetDirName(DirName) ;
1115 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1119 //=============================================================================
1120 //=============================================================================
1122 //=============================================================================
1123 //=============================================================================
1124 // Recuperation des structures par le contexte
1125 //=============================================================================
1126 //=============================================================================
1127 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1129 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
1130 ASSERT(!CORBA::is_nil(myCase));
1132 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1133 ASSERT(!CORBA::is_nil(myIteration));
1135 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1137 //=============================================================================
1138 //=============================================================================
1140 //=============================================================================
1141 //=============================================================================
1142 // Nouvelles structures
1143 //=============================================================================
1144 //=============================================================================
1145 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1147 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1148 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1149 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1150 return aCase._retn();
1152 //=============================================================================
1153 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1155 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1156 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1157 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1158 return aHypo._retn();
1160 //=============================================================================
1161 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1163 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1164 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1165 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1166 return aIter._retn();
1168 //=============================================================================
1169 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1171 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1172 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1173 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1174 return aBoundary._retn();
1176 //=============================================================================
1177 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1179 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1180 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1181 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1182 return aZone._retn();
1184 //=============================================================================
1185 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS()
1187 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1188 HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine);
1189 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this());
1190 return aYACS._retn();
1192 //=============================================================================
1193 //=============================================================================
1195 //=============================================================================
1196 //=============================================================================
1197 // Creation des structures identifiees par leurs noms
1198 //=============================================================================
1199 //=============================================================================
1200 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1202 // Creation d'un cas initial
1203 // nomCas : nom du cas a creer
1204 // MeshName, MeshFile : nom et fichier du maillage correspondant
1207 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1210 if ( _PublisMeshIN != 0 ) option = 2 ;
1211 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option) ;
1213 // Valeurs par defaut des filtrages
1214 myCase->SetPyram(0);
1216 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1218 //=============================================================================
1219 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1221 // nomCas : nom du cas a creer
1222 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1225 INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1226 std::string nomDirWork = getenv("PWD") ;
1229 // A. Decodage du point de reprise
1230 // A.1. Controle du repertoire de depart de l'iteration
1231 codret = CHDIR(DirNameStart) ;
1234 SALOME::ExceptionStruct es;
1235 es.type = SALOME::BAD_PARAM;
1236 es.text = "The directory of the iteration does not exist.";
1237 throw SALOME::SALOME_Exception(es);
1240 // A.2. Reperage des fichiers du repertoire de reprise
1241 std::string file_configuration = "" ;
1242 std::string file_maillage_homard = "" ;
1246 struct dirent *dirp;
1247 dp = opendir(DirNameStart);
1248 while ( (dirp = readdir(dp)) != NULL )
1250 std::string file_name(dirp->d_name);
1251 // MESSAGE ( file_name );
1252 bilan = file_name.find("HOMARD.Configuration.") ;
1253 if ( bilan != string::npos ) { file_configuration = file_name ; }
1254 bilan = file_name.find("maill.") ;
1255 if ( bilan != string::npos )
1257 bilan = file_name.find(".hom.med") ;
1258 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1263 HANDLE hFind = INVALID_HANDLE_VALUE;
1264 WIN32_FIND_DATA ffd;
1265 hFind = FindFirstFile(DirNameStart, &ffd);
1266 if (INVALID_HANDLE_VALUE != hFind) {
1267 while (FindNextFile(hFind, &ffd) != 0) {
1268 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1269 std::string file_name(ffd.cFileName);
1270 bilan = file_name.find("HOMARD.Configuration.") ;
1271 if ( bilan != string::npos ) { file_configuration = file_name ; }
1272 bilan = file_name.find("maill.") ;
1273 if ( bilan != string::npos )
1275 bilan = file_name.find(".hom.med") ;
1276 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1282 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1283 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1285 if ( ( file_configuration == "" ) || ( file_maillage_homard == "" ) )
1287 SALOME::ExceptionStruct es;
1288 es.type = SALOME::BAD_PARAM;
1290 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1291 else { text = "The HOMARD mesh file cannot be found." ; }
1292 es.text = CORBA::string_dup(text.c_str());
1293 throw SALOME::SALOME_Exception(es);
1296 // B. Lecture du fichier de configuration
1297 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1304 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1305 std::ifstream fichier( file_configuration.c_str() );
1306 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1308 std::string ligne; // variable contenant chaque ligne lue
1309 std::string mot_cle;
1310 std::string argument;
1312 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1313 while ( std::getline( fichier, ligne ) )
1315 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1316 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1317 ligne_bis >> mot_cle ;
1318 // B.2. Des valeurs entieres : le second bloc de la ligne
1319 if ( mot_cle == "NumeIter" )
1321 ligne_bis >> NumeIter ;
1324 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1325 else if ( ( mot_cle == "TypeConf" ) || ( mot_cle == "TypeElem" ) )
1327 ligne_bis >> argument ;
1329 if ( mot_cle == "TypeConf" )
1331 if ( argument == "conforme" ) { TypeConf = 1 ; }
1332 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1333 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1334 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1336 else if ( mot_cle == "TypeElem" )
1338 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1339 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1342 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1343 // il faut les supprimer
1344 else if ( ( mot_cle == "CCNoMNP1" ) || ( mot_cle == "CCMaiNP1" ) )
1346 ligne_bis >> argument ;
1347 if ( argument[0] == '"' ) { decalage = 1 ; }
1348 else { decalage = 0 ; }
1349 size_t size = argument.size() + 1 - 2*decalage ;
1351 if ( mot_cle == "CCNoMNP1" )
1353 MeshName = new char[ size ];
1354 strncpy( MeshName, argument.c_str()+decalage, size );
1355 MeshName[size-1] = '\0' ;
1357 else if ( mot_cle == "CCMaiNP1" )
1359 MeshFile = new char[ size ];
1360 strncpy( MeshFile, argument.c_str()+decalage, size );
1361 MeshFile[size-1] = '\0' ;
1365 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1366 MESSAGE ( "==> MeshName : " << MeshName ) ;
1367 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1368 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1369 MESSAGE ( "==> Pyram : " << Pyram ) ;
1373 SALOME::ExceptionStruct es;
1374 es.type = SALOME::BAD_PARAM;
1375 std::string text = "The configuration file cannot be read." ;
1376 es.text = CORBA::string_dup(text.c_str());
1377 throw SALOME::SALOME_Exception(es);
1380 // C. Creation effective du cas
1383 if ( _PublisMeshIN != 0 ) option = 2 ;
1384 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, option) ;
1386 // D. Parametrages lus dans le fichier de configuration
1388 myCase->SetConfType (TypeConf) ;
1389 myCase->SetExtType (TypeExt) ;
1390 myCase->SetPyram (Pyram) ;
1392 // E. Copie du fichier de maillage homard
1393 // E.1. Repertoire associe au cas
1394 char* nomDirCase = myCase->GetDirName() ;
1395 // E.2. Repertoire associe a l'iteration de ce cas
1397 IterName = myCase->GetIter0Name() ;
1398 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1399 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1400 Iter->SetDirNameLoc(nomDirIter);
1401 std::string nomDirIterTotal ;
1402 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1404 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1406 if (_mkdir(nomDirIterTotal.c_str()) != 0)
1409 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1410 SALOME::ExceptionStruct es;
1411 es.type = SALOME::BAD_PARAM;
1412 std::string text = "The directory for the computation cannot be created." ;
1413 es.text = CORBA::string_dup(text.c_str());
1414 throw SALOME::SALOME_Exception(es);
1416 // E.3. Copie du maillage HOMARD au format MED
1417 codret = CHDIR(DirNameStart) ;
1418 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1419 MESSAGE ( "commande : " << commande ) ;
1420 codret = system(commande.c_str()) ;
1421 MESSAGE ( "codret : " << codret ) ;
1424 SALOME::ExceptionStruct es;
1425 es.type = SALOME::BAD_PARAM;
1426 es.text = "The starting point for the case cannot be copied into the working directory.";
1427 throw SALOME::SALOME_Exception(es);
1436 CHDIR(nomDirWork.c_str());
1437 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1439 //=============================================================================
1440 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1442 // nomCas : nom du cas a creer
1443 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1446 INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1448 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1450 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1451 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1453 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1455 //=============================================================================
1456 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1458 // nomCas : nom du cas a creer
1459 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1460 // Number : numero de l'iteration de depart
1463 INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1466 SALOME::ExceptionStruct es;
1467 es.type = SALOME::BAD_PARAM;
1468 es.text = "The number of iteration must be positive.";
1469 throw SALOME::SALOME_Exception(es);
1473 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1475 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1476 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1478 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1480 //=============================================================================
1481 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1483 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1484 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1485 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1488 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1489 std::string nomDirWork = getenv("PWD") ;
1490 std::string DirNameStartIter ;
1492 int NumeIterMax = -1 ;
1494 // A.1. Controle du repertoire de depart du cas
1495 codret = CHDIR(DirNameStart) ;
1498 SALOME::ExceptionStruct es;
1499 es.type = SALOME::BAD_PARAM;
1500 es.text = "The directory of the case for the pursuit does not exist.";
1501 throw SALOME::SALOME_Exception(es);
1504 // A.2. Reperage des sous-repertoire du repertoire de reprise
1505 bool existe = false ;
1508 struct dirent *dirp;
1509 dp = opendir(DirNameStart);
1510 while ( (dirp = readdir(dp)) != NULL ) {
1511 std::string DirName_1(dirp->d_name);
1513 HANDLE hFind = INVALID_HANDLE_VALUE;
1514 WIN32_FIND_DATA ffd;
1515 hFind = FindFirstFile(DirNameStart, &ffd);
1516 if (INVALID_HANDLE_VALUE != hFind) {
1517 while (FindNextFile(hFind, &ffd) != 0) {
1518 std::string DirName_1 = "";
1519 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1520 DirName_1 = std::string(ffd.cFileName);
1523 if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) )
1525 if ( CHDIR(DirName_1.c_str()) == 0 )
1527 // On cherche le fichier de configuration dans ce sous-repertoire
1528 codret = CHDIR(DirNameStart);
1531 struct dirent *dirp_1;
1532 dp_1 = opendir(DirName_1.c_str()) ;
1533 while ( (dirp_1 = readdir(dp_1)) != NULL )
1535 std::string file_name_1(dirp_1->d_name);
1537 HANDLE hFind1 = INVALID_HANDLE_VALUE;
1538 WIN32_FIND_DATA ffd1;
1539 hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1);
1540 while (FindNextFile(hFind1, &ffd1) != 0)
1542 if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
1543 std::string file_name_1(ffd1.cFileName);
1545 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1546 if ( bilan != string::npos )
1548 // Decodage du fichier pour trouver le numero d'iteration
1549 CHDIR(DirName_1.c_str()) ;
1551 std::ifstream fichier( file_name_1.c_str() );
1552 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1555 std::string ligne; // variable contenant chaque ligne lue
1556 std::string mot_cle;
1557 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1558 while ( std::getline( fichier, ligne ) )
1560 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1561 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1562 ligne_bis >> mot_cle ;
1563 if ( mot_cle == "NumeIter" )
1565 ligne_bis >> NumeIter ;
1567 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1568 if ( Number == - 1 )
1570 if ( NumeIter >= NumeIterMax )
1572 NumeIterMax = NumeIter ;
1573 DirNameStartIter = DirName_1 ;
1578 if ( NumeIter == Number )
1580 DirNameStartIter = DirName_1 ;
1590 SALOME::ExceptionStruct es;
1591 es.type = SALOME::BAD_PARAM;
1592 std::string text = "The configuration file cannot be read." ;
1593 es.text = CORBA::string_dup(text.c_str());
1594 throw SALOME::SALOME_Exception(es);
1596 CHDIR(DirNameStart) ;
1598 if ( existe ) { break ; }
1605 if ( existe ) { break ; }
1614 CHDIR(nomDirWork.c_str());
1616 if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) )
1618 SALOME::ExceptionStruct es;
1619 es.type = SALOME::BAD_PARAM;
1620 es.text = "The directory of the iteration does not exist.";
1621 throw SALOME::SALOME_Exception(es);
1625 return DirNameStartIter ;
1627 //=============================================================================
1628 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)
1630 // nomCas : nom du cas a creer
1631 // MeshName, MeshFile : nom et fichier du maillage correspondant
1632 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1633 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1634 // -1 : le maillage n'est pas fourni
1635 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1636 // Option : multiple de nombres premiers
1637 // 1 : aucune option
1638 // x2 : publication du maillage dans SMESH
1640 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1641 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1642 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1648 // A.2. Controle du nom :
1649 if ((myStudyContext._mesCas).find(nomCas)!=(myStudyContext._mesCas).end())
1651 SALOME::ExceptionStruct es;
1652 es.type = SALOME::BAD_PARAM;
1653 es.text = "This case has already been defined.";
1654 throw SALOME::SALOME_Exception(es);
1658 // A.3. Controle du fichier du maillage
1659 int existeMeshFile ;
1660 if ( MeshOption >= 0 )
1662 existeMeshFile = MEDFileExist ( MeshFile ) ;
1663 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1664 if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) )
1666 SALOME::ExceptionStruct es;
1667 es.type = SALOME::BAD_PARAM;
1668 es.text = "The mesh file does not exist.";
1669 throw SALOME::SALOME_Exception(es);
1673 else { existeMeshFile = 0 ; }
1675 // B. Creation de l'objet cas et publication
1676 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1677 HOMARD::HOMARD_Cas_var myCase = newCase();
1678 myCase->SetName(nomCas);
1679 SALOMEDS::SObject_var aSO;
1680 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myCase, nomCas);
1681 myStudyContext._mesCas[nomCas] = myCase;
1683 // C. Caracteristiques du maillage
1684 if ( existeMeshFile != 0 )
1686 // Les valeurs extremes des coordonnees
1687 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1688 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1689 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1690 if (LesExtremes.size()!=10) { return 0; }
1692 for (int i =0 ; i< LesExtremes.size() ; i++)
1693 aSeq[i]=LesExtremes[i] ;
1694 myCase->SetBoundingBox(aSeq) ;
1696 // MESSAGE ( "CreateCase0 : Les groupes" );
1697 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1698 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1699 aSeqGroupe->length(LesGroupes.size());
1700 std::set<std::string>::const_iterator it ;
1702 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1703 aSeqGroupe[i++]=(*it).c_str() ;
1704 myCase->SetGroups(aSeqGroupe) ;
1707 // D. L'iteration initiale du cas
1708 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1709 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1710 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1712 std::string NomIteration = std::string(MeshName) ;
1713 while ( (myStudyContext._mesIterations).find(NomIteration) != (myStudyContext._mesIterations.end()) )
1715 std::ostringstream nom;
1716 nom << MeshName << monNum;
1717 NomIteration = nom.str();
1720 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1722 // D.2. Creation de l'iteration
1723 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1724 myStudyContext._mesIterations[NomIteration] = anIter;
1725 anIter->SetName(NomIteration.c_str());
1726 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1728 // D.4. Maillage correspondant
1729 if ( existeMeshFile != 0 )
1731 anIter->SetMeshFile(MeshFile);
1732 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1734 anIter->SetMeshName(MeshName);
1736 // D.5. Numero d'iteration
1737 anIter->SetNumber(NumeIter);
1740 SetEtatIter(NomIteration.c_str(), -NumeIter);
1743 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1745 //=============================================================================
1746 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1748 INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1751 // A. Controle du nom :
1752 if ((myStudyContext._mesHypotheses).find(nomHypothesis) != (myStudyContext._mesHypotheses).end())
1754 SALOME::ExceptionStruct es;
1755 es.type = SALOME::BAD_PARAM;
1756 es.text = "This hypothesis has already been defined.";
1757 throw SALOME::SALOME_Exception(es);
1761 // B. Creation de l'objet
1762 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1763 if (CORBA::is_nil(myHypothesis))
1765 SALOME::ExceptionStruct es;
1766 es.type = SALOME::BAD_PARAM;
1767 es.text = "Unable to create the hypothesis";
1768 throw SALOME::SALOME_Exception(es);
1771 myHypothesis->SetName(nomHypothesis);
1773 // C. Enregistrement
1774 myStudyContext._mesHypotheses[nomHypothesis] = myHypothesis;
1776 SALOMEDS::SObject_var aSO;
1777 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myHypothesis, nomHypothesis);
1779 // D. Valeurs par defaut des options avancees
1780 myHypothesis->SetNivMax(-1);
1781 myHypothesis->SetDiamMin(-1.0);
1782 myHypothesis->SetAdapInit(0);
1783 myHypothesis->SetExtraOutput(1);
1785 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1788 //=============================================================================
1789 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1790 //=============================================================================
1792 INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1795 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterParent];
1796 if (CORBA::is_nil(myIterationParent))
1798 SALOME::ExceptionStruct es;
1799 es.type = SALOME::BAD_PARAM;
1800 es.text = "The parent iteration is not defined.";
1801 throw SALOME::SALOME_Exception(es);
1805 const char* nomCas = myIterationParent->GetCaseName();
1806 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1807 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
1808 if (CORBA::is_nil(myCase))
1810 SALOME::ExceptionStruct es;
1811 es.type = SALOME::BAD_PARAM;
1812 es.text = "Invalid case context";
1813 throw SALOME::SALOME_Exception(es);
1816 const char* nomDirCase = myCase->GetDirName();
1818 // Controle du nom :
1819 if ((myStudyContext._mesIterations).find(NomIteration)!=(myStudyContext._mesIterations).end())
1821 SALOME::ExceptionStruct es;
1822 es.type = SALOME::BAD_PARAM;
1823 es.text = "This iteration has already been defined.";
1824 throw SALOME::SALOME_Exception(es);
1828 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1829 if (CORBA::is_nil(myIteration))
1831 SALOME::ExceptionStruct es;
1832 es.type = SALOME::BAD_PARAM;
1833 es.text = "Unable to create the iteration";
1834 throw SALOME::SALOME_Exception(es);
1837 myStudyContext._mesIterations[std::string(NomIteration)] = myIteration;
1838 // Nom de l'iteration et du maillage
1839 myIteration->SetName(NomIteration);
1840 myIteration->SetMeshName(NomIteration);
1841 myIteration->SetState(1);
1843 int numero = myIterationParent->GetNumber() + 1;
1844 myIteration->SetNumber(numero);
1846 // Nombre d'iterations deja connues pour le cas, permettant
1847 // la creation d'un sous-repertoire unique
1848 int nbitercase = myCase->GetNumberofIter();
1849 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1850 myIteration->SetDirNameLoc(nomDirIter);
1852 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1853 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1854 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1855 // situation la plus frequente.
1856 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1857 // le nombre d'iterations du cas permet d'eviter les collisions.
1859 if ( nbitercase < 100 ) { jaux = 2 ; }
1860 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1861 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1862 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1864 std::ostringstream iaux ;
1865 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1866 std::stringstream MeshFile;
1867 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1868 myIteration->SetMeshFile(MeshFile.str().c_str());
1870 // Association avec le cas
1871 std::string label = "IterationHomard_" + std::string(nomIterParent);
1872 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1873 // Lien avec l'iteration precedente
1874 myIterationParent->LinkNextIteration(NomIteration);
1875 myIteration->SetIterParentName(nomIterParent);
1876 // Gestion de l'arbre d'etudes
1877 SALOMEDS::SObject_var aIterSOParent = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIterationParent)));
1878 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
1879 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
1880 aStudyBuilder->NewCommand();
1881 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
1882 aStudyBuilder->Addreference(aSubSO, aIterSOParent);
1883 aStudyBuilder->CommitCommand();
1885 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1887 //=============================================================================
1888 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1890 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1893 // Controle du nom :
1894 if ((myStudyContext._mesBoundarys).find(BoundaryName)!=(myStudyContext._mesBoundarys).end())
1896 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1897 SALOME::ExceptionStruct es;
1898 es.type = SALOME::BAD_PARAM;
1899 es.text = "This boundary has already been defined";
1900 throw SALOME::SALOME_Exception(es);
1904 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1905 myBoundary->SetName(BoundaryName);
1906 myBoundary->SetType(BoundaryType);
1908 myStudyContext._mesBoundarys[BoundaryName] = myBoundary;
1910 SALOMEDS::SObject_var aSO;
1911 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myBoundary, BoundaryName);
1913 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1915 //=============================================================================
1916 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1918 INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << ", MeshName = " << MeshName );
1919 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1920 myBoundary->SetMeshFile( MeshFile ) ;
1921 myBoundary->SetMeshName( MeshName ) ;
1923 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1925 //=============================================================================
1926 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1927 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1928 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1929 CORBA::Double Rayon)
1931 INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1933 SALOME::ExceptionStruct es;
1936 { es.text = "The radius must be positive." ;
1938 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1939 if ( daux < 0.0000001 )
1940 { es.text = "The axis must be a non 0 vector." ;
1944 es.type = SALOME::BAD_PARAM;
1945 throw SALOME::SALOME_Exception(es);
1949 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1950 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1952 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1954 //=============================================================================
1955 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1956 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1957 CORBA::Double Rayon)
1959 INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1961 SALOME::ExceptionStruct es;
1964 { es.text = "The radius must be positive." ;
1968 es.type = SALOME::BAD_PARAM;
1969 throw SALOME::SALOME_Exception(es);
1973 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1974 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1976 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1978 //=============================================================================
1979 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1980 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1981 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1983 INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1985 SALOME::ExceptionStruct es;
1987 if ( Angle <= 0.0 || Angle >= 90.0 )
1988 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1990 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1991 if ( daux < 0.0000001 )
1992 { es.text = "The axis must be a non 0 vector." ;
1996 es.type = SALOME::BAD_PARAM;
1997 throw SALOME::SALOME_Exception(es);
2001 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
2002 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
2004 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2006 //=============================================================================
2007 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
2008 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
2009 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
2011 INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
2013 SALOME::ExceptionStruct es;
2015 if ( Rayon1 < 0.0 || Rayon2 < 0.0 )
2016 { es.text = "The radius must be positive." ;
2018 double daux = fabs(Rayon2-Rayon1) ;
2019 if ( daux < 0.0000001 )
2020 { es.text = "The radius must be different." ;
2022 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
2023 if ( daux < 0.0000001 )
2024 { es.text = "The centers must be different." ;
2028 es.type = SALOME::BAD_PARAM;
2029 throw SALOME::SALOME_Exception(es);
2033 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
2034 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
2036 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2038 //=============================================================================
2039 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryTorus(const char* BoundaryName,
2040 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2041 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2042 CORBA::Double RayonRev, CORBA::Double RayonPri)
2044 INFOS ("CreateBoundaryTorus : BoundaryName = " << BoundaryName ) ;
2046 SALOME::ExceptionStruct es;
2048 if ( ( RayonRev <= 0.0 ) || ( RayonPri <= 0.0 ) )
2049 { es.text = "The radius must be positive." ;
2051 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2052 if ( daux < 0.0000001 )
2053 { es.text = "The axis must be a non 0 vector." ;
2057 es.type = SALOME::BAD_PARAM;
2058 throw SALOME::SALOME_Exception(es);
2062 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 5) ;
2063 myBoundary->SetTorus( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, RayonRev, RayonPri ) ;
2065 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
2067 //=============================================================================
2068 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
2070 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
2073 // Controle du nom :
2074 if ((myStudyContext._mesZones).find(ZoneName)!=(myStudyContext._mesZones).end())
2076 SALOME::ExceptionStruct es;
2077 es.type = SALOME::BAD_PARAM;
2078 es.text = "This zone has already been defined";
2079 throw SALOME::SALOME_Exception(es);
2083 HOMARD::HOMARD_Zone_var myZone = newZone();
2084 myZone->SetName(ZoneName);
2085 myZone->SetType(ZoneType);
2087 myStudyContext._mesZones[ZoneName] = myZone;
2089 SALOMEDS::SObject_var aSO;
2090 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myZone, ZoneName);
2092 return HOMARD::HOMARD_Zone::_duplicate(myZone);
2094 //=============================================================================
2095 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
2096 CORBA::Double Xmini, CORBA::Double Xmaxi,
2097 CORBA::Double Ymini, CORBA::Double Ymaxi,
2098 CORBA::Double Zmini, CORBA::Double Zmaxi)
2100 INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ;
2102 SALOME::ExceptionStruct es;
2104 if ( Xmini > Xmaxi )
2105 { es.text = "The X coordinates are not coherent." ;
2107 if ( Ymini > Ymaxi )
2108 { es.text = "The Y coordinates are not coherent." ;
2110 if ( Zmini > Zmaxi )
2111 { es.text = "The Z coordinates are not coherent." ;
2115 es.type = SALOME::BAD_PARAM;
2116 throw SALOME::SALOME_Exception(es);
2120 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
2121 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2123 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2125 //=============================================================================
2126 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
2127 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
2129 INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
2131 SALOME::ExceptionStruct es;
2134 { es.text = "The radius must be positive." ;
2138 es.type = SALOME::BAD_PARAM;
2139 throw SALOME::SALOME_Exception(es);
2143 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
2144 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
2146 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2148 //=============================================================================
2149 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
2150 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2151 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2152 CORBA::Double Rayon, CORBA::Double Haut)
2154 INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
2156 SALOME::ExceptionStruct es;
2159 { es.text = "The radius must be positive." ;
2161 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2162 if ( daux < 0.0000001 )
2163 { es.text = "The axis must be a non 0 vector." ;
2166 { es.text = "The height must be positive." ;
2170 es.type = SALOME::BAD_PARAM;
2171 throw SALOME::SALOME_Exception(es);
2175 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
2176 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
2178 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2180 //=============================================================================
2181 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
2182 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2183 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2184 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
2186 INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ;
2188 SALOME::ExceptionStruct es;
2190 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2191 { es.text = "The radius must be positive." ;
2193 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2194 if ( daux < 0.0000001 )
2195 { es.text = "The axis must be a non 0 vector." ;
2198 { es.text = "The height must be positive." ;
2200 if ( Rayon <= Rayonint )
2201 { es.text = "The external radius must be higher than the internal radius." ;
2205 es.type = SALOME::BAD_PARAM;
2206 throw SALOME::SALOME_Exception(es);
2210 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
2211 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
2213 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2215 //=============================================================================
2216 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
2217 CORBA::Double Umini, CORBA::Double Umaxi,
2218 CORBA::Double Vmini, CORBA::Double Vmaxi,
2221 INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
2222 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
2223 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
2224 // MESSAGE ("Orient = " << Orient ) ;
2226 SALOME::ExceptionStruct es;
2228 if ( Umini > Umaxi )
2229 { es.text = "The first coordinates are not coherent." ;
2231 if ( Vmini > Vmaxi )
2232 { es.text = "The second coordinates are not coherent." ;
2234 if ( Orient < 1 || Orient > 3 )
2235 { es.text = "The orientation must be 1, 2 or 3." ;
2239 es.type = SALOME::BAD_PARAM;
2240 throw SALOME::SALOME_Exception(es);
2244 double Xmini, Xmaxi ;
2245 double Ymini, Ymaxi ;
2246 double Zmini, Zmaxi ;
2254 else if ( Orient == 2 )
2261 else if ( Orient == 3 )
2268 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2270 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2271 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2273 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2275 //=============================================================================
2276 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2277 CORBA::Double Ucentre, CORBA::Double Vcentre,
2278 CORBA::Double Rayon,
2281 INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2283 SALOME::ExceptionStruct es;
2286 { es.text = "The radius must be positive." ;
2288 if ( Orient < 1 || Orient > 3 )
2289 { es.text = "The orientation must be 1, 2 or 3." ;
2293 es.type = SALOME::BAD_PARAM;
2294 throw SALOME::SALOME_Exception(es);
2302 { Xcentre = Ucentre ;
2305 else if ( Orient == 2 )
2308 Zcentre = Vcentre ; }
2309 else if ( Orient == 3 )
2310 { Xcentre = Vcentre ;
2312 Zcentre = Ucentre ; }
2313 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2315 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2316 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2318 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2320 //=============================================================================
2321 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2322 CORBA::Double Ucentre, CORBA::Double Vcentre,
2323 CORBA::Double Rayon, CORBA::Double Rayonint,
2326 INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2328 SALOME::ExceptionStruct es;
2330 if ( Rayon <= 0.0 || Rayonint <= 0.0 )
2331 { es.text = "The radius must be positive." ;
2333 if ( Orient < 1 || Orient > 3 )
2334 { es.text = "The orientation must be 1, 2 or 3." ;
2336 if ( Rayon <= Rayonint )
2337 { es.text = "The external radius must be higher than the internal radius." ;
2341 es.type = SALOME::BAD_PARAM;
2342 throw SALOME::SALOME_Exception(es);
2350 { Xcentre = Ucentre ;
2353 else if ( Orient == 2 )
2356 Zcentre = Vcentre ; }
2357 else if ( Orient == 3 )
2358 { Xcentre = Vcentre ;
2360 Zcentre = Ucentre ; }
2361 else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; }
2363 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2364 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2366 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2368 //=============================================================================
2369 //=============================================================================
2374 //=============================================================================
2375 //=============================================================================
2376 // Traitement d'une iteration
2377 // etatMenage = 1 : destruction du repertoire d'execution
2378 // modeHOMARD = 1 : adaptation
2379 // != 1 : information avec les options modeHOMARD
2380 // Option1 >0 : appel depuis python
2381 // <0 : appel depuis GUI
2382 // Option2 : multiple de nombres premiers
2383 // 1 : aucune option
2384 // x2 : publication du maillage dans SMESH
2385 //=============================================================================
2386 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2388 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2393 // A.1. L'objet iteration
2394 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIteration];
2395 ASSERT(!CORBA::is_nil(myIteration));
2397 // A.2. Controle de la possibilite d'agir
2398 // A.2.1. Etat de l'iteration
2399 int etat = myIteration->GetState();
2400 MESSAGE ( "etat = "<<etat );
2401 // A.2.2. On ne calcule pas l'iteration initiale, ni une iteration deja calculee
2402 if ( modeHOMARD == 1 )
2406 SALOME::ExceptionStruct es;
2407 es.type = SALOME::BAD_PARAM;
2408 es.text = "This iteration is the first of the case and cannot be computed.";
2409 throw SALOME::SALOME_Exception(es);
2412 else if ( ( etat == 2 ) & ( modeHOMARD == 1 ) )
2414 SALOME::ExceptionStruct es;
2415 es.type = SALOME::BAD_PARAM;
2416 es.text = "This iteration is already computed.";
2417 throw SALOME::SALOME_Exception(es);
2421 // A.2.3. On n'analyse pas une iteration non calculee
2426 SALOME::ExceptionStruct es;
2427 es.type = SALOME::BAD_PARAM;
2428 es.text = "This iteration is not computed.";
2429 throw SALOME::SALOME_Exception(es);
2434 // A.3. Numero de l'iteration
2435 // siterp1 : numero de l'iteration a traiter
2437 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2438 // Ou si information :
2440 int NumeIter = myIteration->GetNumber();
2441 std::string siterp1 ;
2442 std::stringstream saux1 ;
2444 siterp1 = saux1.str() ;
2445 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2448 if ( modeHOMARD==1 )
2450 std::stringstream saux0 ;
2451 int iaux = max(0, NumeIter-1) ;
2453 siter = saux0.str() ;
2454 if (NumeIter < 11) { siter = "0" + siter ; }
2457 { siter = siterp1 ; }
2460 const char* nomCas = myIteration->GetCaseName();
2461 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
2462 ASSERT(!CORBA::is_nil(myCase));
2464 // B. Les repertoires
2465 // B.1. Le repertoire courant
2466 std::string nomDirWork = getenv("PWD") ;
2467 // B.2. Le sous-repertoire de l'iteration a traiter
2468 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2469 MESSAGE( ". DirCompute = " << DirCompute );
2471 // C. Le fichier des messages
2472 // C.1. Le deroulement de l'execution de HOMARD
2473 std::string LogFile = DirCompute ;
2474 LogFile += "/Liste" ;
2475 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2477 MESSAGE (". LogFile = " << LogFile);
2478 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2479 // C.2. Le bilan de l'analyse du maillage
2480 std::string FileInfo = DirCompute ;
2482 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2484 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2485 else { FileInfo += "info_ap" ; }
2487 FileInfo += "." + siterp1 + ".bilan" ;
2488 myIteration->SetFileInfo(FileInfo.c_str());
2490 // D. On passe dans le repertoire de l'iteration a calculer
2491 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2494 // E. Les donnees de l'execution HOMARD
2495 // E.1. L'objet du texte du fichier de configuration
2496 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2497 myDriver->TexteInit(DirCompute, LogFile, _Langue);
2499 // E.2. Le maillage associe a l'iteration
2500 const char* NomMesh = myIteration->GetMeshName();
2501 MESSAGE ( ". NomMesh = " << NomMesh );
2502 const char* MeshFile = myIteration->GetMeshFile();
2503 MESSAGE ( ". MeshFile = " << MeshFile );
2505 // E.3. Les donnees du traitement HOMARD
2507 if ( modeHOMARD == 1 )
2510 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2511 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2512 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2516 InvalideIterInfo(NomIteration);
2517 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2519 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2520 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2521 myDriver->CreeFichierDonn();
2524 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2525 DriverTexteBoundary(myCase, myDriver) ;
2527 // E.5. Ecriture du texte dans le fichier
2528 MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<<codret );
2530 { myDriver->CreeFichier(); }
2534 int codretexec = 12 ;
2537 codretexec = myDriver->ExecuteHomard(Option1);
2539 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2540 // En mode adaptation, on ajuste l'etat de l'iteration
2541 if ( modeHOMARD == 1 )
2543 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2544 else { SetEtatIter(NomIteration,1); }
2545 // GERALD -- QMESSAGE BOX
2549 // H. Gestion des resultats
2552 std::string Commentaire ;
2553 // H.1. Le fichier des messages, dans tous les cas
2554 Commentaire = "log" ;
2555 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2556 else { Commentaire += "Info" ; }
2557 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2559 // H.2. Si tout s'est bien passe :
2560 if (codretexec == 0)
2562 // H.2.1. Le fichier de bilan
2563 Commentaire = "Summary" ;
2564 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2565 else { Commentaire += "Info" ; }
2566 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2567 // H.2.2. Le fichier de maillage obtenu
2568 if ( modeHOMARD == 1 )
2570 std::stringstream saux0 ;
2571 Commentaire = "Mesh" ;
2572 Commentaire += " " + siterp1 ;
2573 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2574 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2577 // H.3 Message d'erreur
2578 if (codretexec != 0)
2580 std::string text = "" ;
2581 // Message d'erreur en cas de probleme en adaptation
2582 if ( modeHOMARD == 1 )
2584 text = "Error during the adaptation.\n" ;
2585 bool stopvu = false ;
2586 std::ifstream fichier( LogFile.c_str() );
2587 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
2589 std::string ligne; // variable contenant chaque ligne lue
2590 while ( std::getline( fichier, ligne ) )
2594 { text += ligne+ "\n"; }
2597 int position = ligne.find( "===== HOMARD ===== STOP =====" ) ;
2598 if ( position > 0 ) { stopvu = true ; }
2603 text += "\n\nSee the file " + LogFile + "\n" ;
2605 SALOME::ExceptionStruct es;
2606 es.type = SALOME::BAD_PARAM;
2607 es.text = CORBA::string_dup(text.c_str());
2608 throw SALOME::SALOME_Exception(es);
2610 // En mode information, on force le succes pour pouvoir consulter le fichier log
2611 if ( modeHOMARD != 1 ) { codretexec = 0 ; }
2615 // I. Menage et retour dans le repertoire du cas
2619 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2621 CHDIR(nomDirWork.c_str());
2626 //=============================================================================
2627 // Calcul d'une iteration : partie specifique a l'adaptation
2628 //=============================================================================
2629 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)
2631 MESSAGE ( "ComputeAdap" );
2636 // Numero de l'iteration
2637 int NumeIter = myIteration->GetNumber();
2638 std::stringstream saux0 ;
2639 saux0 << NumeIter-1 ;
2640 std::string siter = saux0.str() ;
2641 if (NumeIter < 11) { siter = "0" + siter ; }
2643 // A.2. On verifie qu il y a une hypothese (erreur improbable);
2644 const char* nomHypo = myIteration->GetHypoName();
2645 if (std::string(nomHypo) == std::string(""))
2647 SALOME::ExceptionStruct es;
2648 es.type = SALOME::BAD_PARAM;
2649 es.text = "This iteration does not have any associated hypothesis.";
2650 throw SALOME::SALOME_Exception(es);
2653 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
2654 ASSERT(!CORBA::is_nil(myHypo));
2656 // B. L'iteration parent
2657 const char* nomIterationParent = myIteration->GetIterParentName();
2658 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
2659 ASSERT(!CORBA::is_nil(myIterationParent));
2660 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2661 if ( myIterationParent->GetState() == 1 )
2664 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2667 // GERALD -- QMESSAGE BOX
2668 VERIFICATION("Pb au calcul de l'iteration precedente" == 0);
2672 // C. Le sous-repertoire de l'iteration precedente
2673 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2674 MESSAGE( ". DirComputePa = " << DirComputePa );
2676 // D. Les donnees de l'adaptation HOMARD
2677 // D.1. Le type de conformite
2678 int ConfType = myCase->GetConfType();
2679 MESSAGE ( ". ConfType = " << ConfType );
2681 // D.1. Le type externe
2682 int ExtType = myCase->GetExtType();
2683 MESSAGE ( ". ExtType = " << ExtType );
2685 // D.3. Le maillage de depart
2686 const char* NomMeshParent = myIterationParent->GetMeshName();
2687 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2688 const char* MeshFileParent = myIterationParent->GetMeshFile();
2689 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2691 // D.4. Le maillage associe a l'iteration
2692 const char* MeshFile = myIteration->GetMeshFile();
2693 MESSAGE ( ". MeshFile = " << MeshFile );
2694 FILE *file = fopen(MeshFile,"r");
2698 if (etatMenage == 0)
2700 SALOME::ExceptionStruct es;
2701 es.type = SALOME::BAD_PARAM;
2702 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2703 es.text = CORBA::string_dup(text.c_str());
2704 throw SALOME::SALOME_Exception(es);
2709 std::string commande = "rm -f " + std::string(MeshFile);
2710 codret = system(commande.c_str());
2713 SALOME::ExceptionStruct es;
2714 es.type = SALOME::BAD_PARAM;
2715 es.text = "The mesh file cannot be deleted.";
2716 throw SALOME::SALOME_Exception(es);
2722 // D.5. Les types de raffinement et de deraffinement
2723 // Les appels corba sont lourds, il vaut mieux les grouper
2724 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2725 ASSERT(ListTypes->length() == 3);
2726 int TypeAdap = (*ListTypes)[0];
2727 int TypeRaff = (*ListTypes)[1];
2728 int TypeDera = (*ListTypes)[2];
2729 // MESSAGE ( ". TypeAdap = " << TypeAdap << ", TypeRaff = " << TypeRaff << ", TypeDera = " << TypeDera );
2731 // E. Texte du fichier de configuration
2732 // E.1. Incontournables du texte
2733 myDriver->TexteAdap(ExtType);
2735 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2736 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2737 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2739 // E.2. Ajout des informations liees aux zones eventuelles
2740 if ( TypeAdap == 0 )
2741 { DriverTexteZone(myHypo, myDriver) ; }
2743 // E.3. Ajout des informations liees aux champs eventuels
2744 if ( TypeAdap == 1 )
2745 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2747 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2748 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2749 int numberOfGroups = listeGroupes->length();
2750 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2751 if (numberOfGroups > 0)
2753 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2755 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2756 MESSAGE( "... GroupName = " << GroupName );
2757 myDriver->TexteGroup(GroupName);
2761 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2762 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2764 // E.6. Ajout des options avancees
2765 int Pyram = myCase->GetPyram();
2766 MESSAGE ( ". Pyram = " << Pyram );
2767 int NivMax = myHypo->GetNivMax();
2768 MESSAGE ( ". NivMax = " << NivMax );
2769 double DiamMin = myHypo->GetDiamMin() ;
2770 MESSAGE ( ". DiamMin = " << DiamMin );
2771 int AdapInit = myHypo->GetAdapInit();
2772 MESSAGE ( ". AdapInit = " << AdapInit );
2773 int ExtraOutput = myHypo->GetExtraOutput();
2774 MESSAGE ( ". ExtraOutput = " << ExtraOutput );
2775 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, ExtraOutput);
2777 // E.7. Ajout des informations sur le deroulement de l'execution
2778 int MessInfo = myIteration->GetInfoCompute();
2779 MESSAGE ( ". MessInfo = " << MessInfo );
2780 myDriver->TexteInfoCompute(MessInfo);
2784 //=============================================================================
2785 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2786 // nomrep : nom du repertoire parent
2787 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2788 //=============================================================================
2789 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2791 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2792 // On verifie que le repertoire parent existe
2793 int codret = CHDIR(nomrep) ;
2796 SALOME::ExceptionStruct es;
2797 es.type = SALOME::BAD_PARAM;
2798 es.text = "The directory of the case does not exist.";
2799 throw SALOME::SALOME_Exception(es);
2802 std::string nomDirActuel = getenv("PWD") ;
2803 std::string DirName ;
2804 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2805 bool a_chercher = true ;
2806 while ( a_chercher )
2808 // On passe dans le repertoire parent
2811 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2813 if ( num < 100 ) { jaux = 2 ; }
2814 else if ( num < 1000 ) { jaux = 3 ; }
2815 else if ( num < 10000 ) { jaux = 4 ; }
2816 else if ( num < 100000 ) { jaux = 5 ; }
2818 std::ostringstream iaux ;
2819 iaux << std::setw(jaux) << std::setfill('0') << num ;
2820 std::ostringstream DirNameA ;
2821 DirNameA << "I" << iaux.str();
2822 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2823 // que c'est bien un probleme d'absence
2824 if ( CHDIR(DirNameA.str().c_str()) != 0 )
2826 bool existe = false ;
2829 struct dirent *dirp;
2830 dp = opendir(nomrep);
2831 while ( (dirp = readdir(dp)) != NULL )
2833 std::string file_name(dirp->d_name);
2835 HANDLE hFind = INVALID_HANDLE_VALUE;
2836 WIN32_FIND_DATA ffd;
2837 hFind = FindFirstFile(nomrep, &ffd);
2838 if (INVALID_HANDLE_VALUE != hFind) {
2839 while (FindNextFile(hFind, &ffd) != 0) {
2840 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2841 std::string file_name(ffd.cFileName);
2843 if ( file_name == DirNameA.str() ) { existe = true ; }
2852 DirName = DirNameA.str() ;
2853 a_chercher = false ;
2860 MESSAGE ( "==> DirName = " << DirName);
2861 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2862 CHDIR(nomDirActuel.c_str());
2863 return CORBA::string_dup( DirName.c_str() );
2865 //=============================================================================
2866 // Calcul d'une iteration : gestion du repertoire de calcul
2867 // Si le sous-repertoire existe :
2868 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2869 // etatMenage = 1 : on fait le menage du repertoire
2870 // etatMenage = -1 : on ne fait rien
2871 //=============================================================================
2872 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2874 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2875 // B.2. Le repertoire du cas
2876 const char* nomDirCase = myCase->GetDirName();
2877 MESSAGE ( ". nomDirCase = " << nomDirCase );
2879 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2880 // B.3.1. Le nom du sous-repertoire
2881 const char* nomDirIt = myIteration->GetDirNameLoc();
2883 // B.3.2. Le nom complet du sous-repertoire
2884 std::stringstream DirCompute ;
2885 DirCompute << nomDirCase << "/" << nomDirIt;
2886 MESSAGE (". DirCompute = " << DirCompute.str() );
2888 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2889 if (CHDIR(DirCompute.str().c_str()) != 0)
2892 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2894 if (_mkdir(DirCompute.str().c_str()) != 0)
2897 // GERALD -- QMESSAGE BOX
2898 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2899 VERIFICATION("Pb a la creation du repertoire" == 0);
2904 // Le repertoire existe
2905 // On demande de faire le menage de son contenu :
2906 if (etatMenage == 1)
2908 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2909 std::string commande = "rm -rf " + DirCompute.str()+"/*" ;
2910 int codret = system(commande.c_str());
2913 // GERALD -- QMESSAGE BOX
2914 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2915 VERIFICATION("Pb au menage du repertoire de calcul" == 0);
2918 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2921 if (etatMenage == 0)
2925 struct dirent *dirp;
2926 dp = opendir(DirCompute.str().c_str());
2928 while ((dirp = readdir(dp)) != NULL && result )
2930 std::string file_name(dirp->d_name);
2931 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2935 HANDLE hFind = INVALID_HANDLE_VALUE;
2936 WIN32_FIND_DATA ffd;
2937 hFind = FindFirstFile(DirCompute.str().c_str(), &ffd);
2939 if (INVALID_HANDLE_VALUE != hFind) {
2940 while (FindNextFile(hFind, &ffd) != 0) {
2941 if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories
2942 std::string file_name(ffd.cFileName);
2943 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2948 if ( result == false)
2950 SALOME::ExceptionStruct es;
2951 es.type = SALOME::BAD_PARAM;
2952 std::string text = "Directory : " + DirCompute.str() + " is not empty";
2953 es.text = CORBA::string_dup(text.c_str());
2954 throw SALOME::SALOME_Exception(es);
2955 VERIFICATION("Directory is not empty" == 0);
2961 return CORBA::string_dup( DirCompute.str().c_str() );
2963 //=============================================================================
2964 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2965 //=============================================================================
2966 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2968 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2969 // Le repertoire du cas
2970 const char* nomDirCase = myCase->GetDirName();
2971 MESSAGE ( ". nomDirCase = " << nomDirCase );
2973 // Le sous-repertoire de l'iteration precedente
2975 const char* nomIterationParent = myIteration->GetIterParentName();
2976 HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent];
2977 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
2978 std::stringstream DirComputePa ;
2979 DirComputePa << nomDirCase << "/" << nomDirItPa;
2980 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2981 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2983 return CORBA::string_dup( DirComputePa.str().c_str() );
2985 //=============================================================================
2986 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2987 //=============================================================================
2988 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2990 MESSAGE ( "... DriverTexteZone" );
2991 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2992 int numberOfZonesx2 = ListZone->length();
2995 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2997 std::string ZoneName = std::string((*ListZone)[iaux]);
2998 MESSAGE ( "... ZoneName = " << ZoneName);
2999 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
3000 ASSERT(!CORBA::is_nil(myZone));
3002 int ZoneType = myZone->GetType();
3003 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
3004 int TypeUse = atoi( TypeUsestr.c_str() );
3005 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
3006 NumZone = iaux/2 + 1 ;
3007 HOMARD::double_array* zone = myZone->GetCoords();
3008 if ( ZoneType == 2 || ( ZoneType>=11 && ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
3009 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
3010 else if ( ZoneType == 4 ) // Cas d une sphere
3011 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
3012 else if ( ZoneType == 5 || ( ZoneType>=31 && ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
3013 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
3014 else if ( ZoneType == 7 || ( ZoneType>=61 && ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
3015 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
3016 else { VERIFICATION("ZoneType est incorrect." == 0) ; }
3021 //=============================================================================
3022 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
3023 //=============================================================================
3024 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3026 MESSAGE ( "... DriverTexteField" );
3027 // Le fichier du champ
3028 char* FieldFile = myIteration->GetFieldFile();
3029 MESSAGE ( ". FieldFile = " << FieldFile );
3030 if (strlen(FieldFile) == 0)
3032 // GERALD -- QMESSAGE BOX
3033 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
3034 VERIFICATION("The file for the field is not given." == 0);
3036 // Les caracteristiques d'instants du champ de pilotage
3037 int TimeStep = myIteration->GetTimeStep();
3038 MESSAGE( ". TimeStep = " << TimeStep );
3039 int Rank = myIteration->GetRank();
3040 MESSAGE( ". Rank = " << Rank );
3041 // Les informations sur les champs
3042 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
3044 const char* FieldName = aInfosHypo->FieldName;
3046 int TypeThR = aInfosHypo->TypeThR;
3047 double ThreshR = aInfosHypo->ThreshR;
3048 int TypeThC = aInfosHypo->TypeThC;
3049 double ThreshC = aInfosHypo->ThreshC;
3050 // Saut entre mailles ou non ?
3051 int UsField = aInfosHypo->UsField;
3052 MESSAGE( ". UsField = " << UsField );
3053 // L'usage des composantes
3054 int UsCmpI = aInfosHypo->UsCmpI;
3055 MESSAGE( ". UsCmpI = " << UsCmpI );
3057 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
3060 HOMARD::listeComposantsHypo* mescompo = myHypo->GetComps();
3061 int numberOfCompos = mescompo->length();
3062 MESSAGE( ". numberOfCompos = " << numberOfCompos );
3063 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
3065 std::string nomCompo = std::string((*mescompo)[NumeComp]);
3066 if ((system(nomCompo.c_str())) != 0)
3068 MESSAGE( "... nomCompo = " << nomCompo );
3069 myDriver->TexteCompo(NumeComp, nomCompo);
3074 //=============================================================================
3075 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
3076 // On ecrit dans l'ordre :
3077 // 1. la definition des frontieres
3078 // 2. les liens avec les groupes
3079 // 3. un entier resumant le type de comportement pour les frontieres
3080 //=============================================================================
3081 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
3083 MESSAGE ( "... DriverTexteBoundary" );
3084 // 1. Recuperation des frontieres
3085 std::list<std::string> ListeBoundaryTraitees ;
3086 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3087 int numberOfitems = ListBoundaryGroupType->length();
3088 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
3089 int BoundaryOption = 1 ;
3090 // 2. Parcours des frontieres pour ecrire leur description
3091 int NumBoundaryAnalytical = 0 ;
3092 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3094 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3095 MESSAGE ( "... BoundaryName = " << BoundaryName);
3096 // 2.1. La frontiere a-t-elle deja ete ecrite ?
3097 // Cela arrive quand elle est liee a plusieurs groupes. Il ne faut l'ecrire que la premiere fois
3099 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3100 while (it != ListeBoundaryTraitees.end())
3102 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3103 if ( BoundaryName == *it ) { A_faire = 0 ; }
3106 // 2.2. Ecriture de la frontiere
3109 // 2.2.1. Caracteristiques de la frontiere
3110 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3111 ASSERT(!CORBA::is_nil(myBoundary));
3112 int BoundaryType = myBoundary->GetType();
3113 MESSAGE ( "... BoundaryType = " << BoundaryType );
3114 // 2.2.2. Ecriture selon le type
3115 // 2.2.2.1. Cas d une frontiere discrete
3116 if (BoundaryType == 0)
3118 const char* MeshName = myBoundary->GetMeshName() ;
3119 MESSAGE ( ". MeshName = " << MeshName );
3120 const char* MeshFile = myBoundary->GetMeshFile() ;
3121 MESSAGE ( ". MeshFile = " << MeshFile );
3122 myDriver->TexteBoundaryDi( MeshName, MeshFile);
3123 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; }
3125 // 2.2.2.1. Cas d une frontiere analytique
3128 NumBoundaryAnalytical++ ;
3129 HOMARD::double_array* coor = myBoundary->GetCoords();
3130 if (BoundaryType == 1) // Cas d un cylindre
3132 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3133 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3135 else if (BoundaryType == 2) // Cas d une sphere
3137 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
3138 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3140 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
3142 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
3143 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3145 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
3147 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3148 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3150 else if (BoundaryType == 5) // Cas d un tore
3152 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
3153 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
3156 // 2.2.3. Memorisation du traitement
3157 ListeBoundaryTraitees.push_back( BoundaryName );
3160 // 3. Parcours des frontieres pour ecrire les liens avec les groupes
3161 NumBoundaryAnalytical = 0 ;
3162 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3164 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3165 MESSAGE ( "... BoundaryName = " << BoundaryName);
3166 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3167 ASSERT(!CORBA::is_nil(myBoundary));
3168 int BoundaryType = myBoundary->GetType();
3169 MESSAGE ( "... BoundaryType = " << BoundaryType );
3170 // 3.1. Recuperation du nom du groupe
3171 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
3172 MESSAGE ( "... GroupName = " << GroupName);
3173 // 3.2. Cas d une frontiere discrete
3174 if ( BoundaryType == 0 )
3176 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
3178 // 3.3. Cas d une frontiere analytique
3181 NumBoundaryAnalytical++ ;
3182 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
3185 // 4. Ecriture de l'option finale
3186 myDriver->TexteBoundaryOption(BoundaryOption);
3190 //=============================================================================
3191 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
3192 //=============================================================================
3193 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
3195 MESSAGE ( "... DriverTexteFieldInterp" );
3196 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
3197 MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp);
3198 if (TypeFieldInterp != 0)
3200 // Le fichier des champs
3201 char* FieldFile = myIteration->GetFieldFile();
3202 MESSAGE ( ". FieldFile = " << FieldFile );
3203 if (strlen(FieldFile) == 0)
3205 // GERALD -- QMESSAGE BOX
3206 VERIFICATION("The file for the field is not given." == 0);
3209 const char* MeshFile = myIteration->GetMeshFile();
3210 myDriver->TexteFieldInterp(FieldFile, MeshFile);
3213 // Interpolation de tous les champs
3214 if ( TypeFieldInterp == 1 )
3216 myDriver->TexteFieldInterpAll();
3218 // Interpolation de certains champs
3219 else if (TypeFieldInterp == 2)
3221 // Les champs et leurs instants pour l'iteration
3222 HOMARD::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank();
3223 int numberOfFieldsx3 = ListFieldTSR->length();
3224 MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 );
3225 // Les champs pour l'hypothese
3226 HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps();
3227 int numberOfFieldsx2 = ListField->length();
3228 MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 );
3229 // On parcourt tous les champs de l'hypothese
3231 for (int iaux = 0; iaux< numberOfFieldsx2; iaux++)
3234 std::string FieldName = std::string((*ListField)[iaux]) ;
3235 // Le type d'interpolation
3236 std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ;
3237 MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr );
3238 // On cherche à savoir si des instants ont été précisés pour cette itération
3240 for (int jaux = 0; jaux< numberOfFieldsx3; jaux++)
3243 std::string FieldName2 = std::string((*ListFieldTSR)[jaux]) ;
3244 MESSAGE( "..... FieldName2 = " << FieldName2 );
3245 // Quand c'est le bon champ, on ecrit le pas de temps
3246 if ( FieldName == FieldName2 )
3250 std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]) ;
3251 // Le numero d'ordre
3252 std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]) ;
3253 MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<<Rankstr );
3255 int TimeStep = atoi( TimeStepstr.c_str() );
3256 int Rank = atoi( Rankstr.c_str() );
3257 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank);
3261 // Si aucun instant n'a été défini
3265 myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1);
3273 //===========================================================================
3274 //===========================================================================
3277 //===========================================================================
3278 //===========================================================================
3280 //===========================================================================
3281 //===========================================================================
3282 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr theSObject,
3283 CORBA::Object_ptr theObject,
3284 const char* theName)
3286 MESSAGE("PublishInStudy pour " << theName);
3287 SALOMEDS::SObject_var aResultSO;
3288 if (CORBA::is_nil(myStudy))
3290 SALOME::ExceptionStruct es;
3291 es.type = SALOME::BAD_PARAM;
3292 es.text = "Invalid study context";
3293 throw SALOME::SALOME_Exception(es);
3297 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
3298 // Rq : Iteration est publiee ailleurs
3299 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
3300 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
3301 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
3302 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject);
3303 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
3307 // Controle de la non publication d'un objet de meme nom
3308 if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) )
3310 SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(theName, ComponentDataType());
3311 if (listSO->length() >= 1)
3313 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
3314 aResultSO = listSO[0];
3315 return aResultSO._retn();
3319 // Caracteristiques de l'etude
3320 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3321 aStudyBuilder->NewCommand();
3322 if(!aBoundary->_is_nil())
3323 aResultSO = PublishBoundaryInStudy(aStudyBuilder, aBoundary, theName);
3324 else if(!aCase->_is_nil())
3325 aResultSO = PublishCaseInStudy(aStudyBuilder, aCase, theName);
3326 else if(!aHypo->_is_nil())
3327 aResultSO = PublishHypotheseInStudy(aStudyBuilder, aHypo, theName);
3328 else if(!aYACS->_is_nil())
3329 aResultSO = PublishYACSInStudy(aStudyBuilder, aYACS, theName);
3330 else if(!aZone->_is_nil())
3331 aResultSO = PublishZoneInStudy(aStudyBuilder, aZone, theName);
3333 aStudyBuilder->CommitCommand();
3335 return aResultSO._retn();
3337 //=============================================================================
3338 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy( SALOMEDS::StudyBuilder_var aStudyBuilder,
3339 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3341 MESSAGE("PublishBoundaryStudy pour "<<theName);
3342 SALOMEDS::SObject_var aResultSO;
3344 // Caracteristique de la Boundary
3345 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[theName];
3347 // On recupere le module pere dans l etude
3348 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3349 if (theFatherHomard->_is_nil())
3351 MESSAGE("theFatherHomard->_is_nil()");
3352 return aResultSO._retn();
3355 // On ajoute la categorie des boundarys dans l etude si necessaire
3356 if ( _tag_boun == 0 )
3359 _tag_boun = _tag_gene ;
3361 MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun );
3362 SALOMEDS::SObject_var aSObject;
3363 if (!theFatherHomard->FindSubObject(_tag_boun, aSObject))
3365 MESSAGE("Ajout de la categorie des boundarys");
3366 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun);
3367 PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3369 else { MESSAGE("La categorie des boundarys existe deja."); }
3371 CORBA::Long BoundaryType = myBoundary->GetType();
3372 // MESSAGE("BoundaryType : "<<BoundaryType);
3375 switch (BoundaryType)
3378 { value = "BoundaryDiHomard" ;
3379 icone = "mesh_tree_mesh.png" ;
3383 { value = "BoundaryAnHomard" ;
3384 icone = "cylinderpointvector_2.png" ;
3388 { value = "BoundaryAnHomard" ;
3389 icone = "spherepoint_2.png" ;
3393 { value = "BoundaryAnHomard" ;
3394 icone = "conepointvector.png" ;
3398 { value = "BoundaryAnHomard" ;
3399 icone = "conedxyz.png" ;
3403 { value = "BoundaryAnHomard" ;
3404 icone = "toruspointvector.png" ;
3408 aResultSO = aStudyBuilder->NewObject(aSObject);
3409 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3410 return aResultSO._retn();
3412 //=============================================================================
3413 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3414 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
3416 MESSAGE("PublishCaseInStudy pour "<<theName);
3417 SALOMEDS::SObject_var aResultSO;
3419 if (CORBA::is_nil(theObject)) {
3420 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
3421 return aResultSO._retn();
3423 if (myStudy->_is_nil()) {
3424 MESSAGE("HOMARD_Gen_i::myStudy->_is_nil()");
3425 return aResultSO._retn();
3428 // On recupere le module pere dans l etude
3429 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3430 if (theFatherHomard->_is_nil())
3432 MESSAGE("theFatherHomard->_is_nil()");
3433 return aResultSO._retn();
3437 MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene );
3438 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
3439 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
3440 _orb->object_to_string(theObject) ) ;
3442 return aResultSO._retn();
3444 //=============================================================================
3445 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3446 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3448 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3449 SALOMEDS::SObject_var aResultSO;
3451 // On recupere le module pere dans l etude
3452 // On ajoute la categorie des hypotheses dans l etude si necessaire
3453 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3454 if (theFatherHomard->_is_nil())
3456 MESSAGE("theFatherHomard->_is_nil()");
3457 return aResultSO._retn();
3460 // On ajoute la categorie des hypotheses dans l etude si necessaire
3461 SALOMEDS::SObject_var aSObject;
3462 if ( _tag_hypo == 0 )
3465 _tag_hypo = _tag_gene ;
3467 MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo );
3468 if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject))
3470 MESSAGE("Ajout de la categorie des hypotheses");
3471 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo);
3472 PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL);
3474 else { MESSAGE("La categorie des hypotheses existe deja."); }
3476 // Creation du resultat dans l'etude
3477 aResultSO = aStudyBuilder->NewObject(aSObject);
3478 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3480 return aResultSO._retn();
3482 //=============================================================================
3483 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3484 HOMARD::HOMARD_YACS_ptr theObject, const char* theName)
3486 MESSAGE("PublishYACSInStudy pour "<<theName);
3487 SALOMEDS::SObject_var aResultSO;
3489 // On recupere le module pere dans l etude
3490 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3491 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3492 if (theFatherHomard->_is_nil())
3494 MESSAGE("theFatherHomard->_is_nil()");
3495 return aResultSO._retn();
3497 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3498 if ( _tag_yacs == 0 )
3501 _tag_yacs = _tag_gene ;
3503 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs );
3504 SALOMEDS::SObject_var aSObject;
3505 if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject))
3507 MESSAGE("Ajout de la categorie des schemas YACS");
3508 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs);
3509 PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL);
3511 else { MESSAGE("La categorie des schemas YACS existe deja."); }
3513 // Creation du resultat dans l'etude
3514 aResultSO = aStudyBuilder->NewObject(aSObject);
3515 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ;
3517 return aResultSO._retn();
3520 //=============================================================================
3521 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder,
3522 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3524 MESSAGE("PublishZoneStudy pour "<<theName);
3525 SALOMEDS::SObject_var aResultSO;
3526 if (CORBA::is_nil(theObject))
3528 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3529 return aResultSO._retn();
3531 if (myStudy->_is_nil())
3533 MESSAGE("PublishZoneInStudy : myStudy->_is_nil()");
3534 return aResultSO._retn();
3536 SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType());
3537 if (theFatherHomard->_is_nil())
3539 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3540 return aResultSO._retn();
3543 // Caracteristique de la zone
3544 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[theName];
3545 CORBA::Long ZoneType = myZone->GetType();
3547 // On ajoute la categorie des zones dans l etude si necessaire
3548 if ( _tag_zone == 0 )
3551 _tag_zone = _tag_gene ;
3553 MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone );
3554 SALOMEDS::SObject_var aSObject;
3555 if (!theFatherHomard->FindSubObject(_tag_zone, aSObject))
3557 MESSAGE("Ajout de la categorie des zones");
3558 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone);
3559 PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3561 else { MESSAGE("La categorie des zones existe deja."); }
3563 aResultSO = aStudyBuilder->NewObject(aSObject);
3572 { icone = "boxdxy_2.png" ;
3576 { icone = "boxdxyz_2.png" ;
3584 { icone = "disk_2.png" ;
3588 { icone = "spherepoint_2.png" ;
3592 { icone = "cylinderpointvector_2.png" ;
3600 { icone = "diskwithhole_2.png" ;
3604 { icone = "pipe_2.png" ;
3608 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3610 return aResultSO._retn();
3612 //===========================================================================
3613 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3614 SALOMEDS::SObject_var aResultSO,
3615 const char* name, const char* comment, const char* icone, const char* ior)
3617 MESSAGE("PublishInStudyAttr pour name = "<<name<<", comment = "<<comment);
3618 // MESSAGE("icone = "<<icone);
3619 // MESSAGE("ior = "<<ior);
3620 SALOMEDS::GenericAttribute_var anAttr ;
3624 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3625 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3626 aNameAttrib->SetValue(name);
3629 // Ajout du commentaire
3630 if ( comment != NULL )
3632 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3633 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3634 aCommentAttrib->SetValue(comment);
3638 if ( icone != NULL )
3640 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
3641 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3642 aPixmap->SetPixMap(icone);
3648 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3649 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3650 anIOR->SetValue(ior);
3654 //=====================================================================================
3655 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3657 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3659 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName];
3660 ASSERT(!CORBA::is_nil(myCase));
3661 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3662 ASSERT(!CORBA::is_nil(aCaseSO));
3664 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
3665 ASSERT(!CORBA::is_nil(myBoundary));
3666 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3667 ASSERT(!CORBA::is_nil(aBoundarySO));
3669 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3671 aStudyBuilder->NewCommand();
3673 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3674 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3675 // aStudyBuilder->RemoveReference(aSubSO);
3677 aStudyBuilder->CommitCommand();
3680 //=====================================================================================
3681 void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName)
3683 MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName );
3685 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
3686 ASSERT(!CORBA::is_nil(myYACS));
3687 SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3688 ASSERT(!CORBA::is_nil(aYACSSO));
3690 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName];
3691 ASSERT(!CORBA::is_nil(myCase));
3692 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3693 ASSERT(!CORBA::is_nil(aCaseSO));
3695 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3697 aStudyBuilder->NewCommand();
3699 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3700 aStudyBuilder->Addreference(aSubSO, aCaseSO);
3702 aStudyBuilder->CommitCommand();
3705 //=============================================================================
3706 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3707 // Option = 0 : fichier issu d'une importation
3708 // Option = 1 : fichier issu d'une execution HOMARD
3710 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3711 if (CORBA::is_nil(myStudy))
3713 SALOME::ExceptionStruct es;
3714 es.type = SALOME::BAD_PARAM;
3715 es.text = "Invalid study context";
3716 throw SALOME::SALOME_Exception(es);
3720 // Le module SMESH est-il actif ?
3721 SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH");
3723 if (!CORBA::is_nil(aSmeshSO))
3725 // On verifie que le fichier n est pas deja publie
3726 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO);
3727 for (; aIter->More(); aIter->Next())
3729 SALOMEDS::SObject_var aSO = aIter->Value();
3730 SALOMEDS::GenericAttribute_var aGAttr;
3731 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3733 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3734 CORBA::String_var value=anAttr->Value();
3735 if (strcmp((const char*)value,NomFich) == 0)
3737 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3738 // Pour un fichier importe, on ne republie pas
3739 if ( Option == 0 ) { return; }
3740 // Pour un fichier calcule, on commence par faire la depublication
3743 MESSAGE ( "PublishResultInSmesh : depublication" );
3744 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3745 CORBA::String_var value2=anAttr2->Value();
3746 std::string MeshName = string(value2) ;
3747 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3748 DeleteResultInSmesh(NomFich, MeshName) ;
3755 // On enregistre le fichier
3756 MESSAGE( "Enregistrement du fichier");
3757 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3758 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3759 ASSERT(!CORBA::is_nil(aSmeshEngine));
3760 aSmeshEngine->UpdateStudy();
3761 SMESH::DriverMED_ReadStatus theStatus;
3762 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3764 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3765 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3766 for (int i = 0; i < mesMaillages->length(); i++)
3768 MESSAGE( ". Mise a jour des attributs du maillage");
3769 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3770 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3771 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3772 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3773 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3774 anAttr->SetValue(NomFich);
3775 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3776 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3778 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3779 else { icone = "mesh_tree_mesh.png" ; }
3780 anAttr2->SetPixMap( icone );
3784 //=============================================================================
3785 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
3787 MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3788 if (CORBA::is_nil(myStudy))
3790 SALOME::ExceptionStruct es;
3791 es.type = SALOME::BAD_PARAM;
3792 es.text = "Invalid study context";
3793 throw SALOME::SALOME_Exception(es);
3797 // Le module SMESH est-il actif ?
3798 SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH");
3800 if (CORBA::is_nil(aSmeshSO))
3804 // On verifie que le fichier est deja publie
3805 SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
3806 SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO);
3807 for (; aIter->More(); aIter->Next())
3809 SALOMEDS::SObject_var aSO = aIter->Value();
3810 SALOMEDS::GenericAttribute_var aGAttr;
3811 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3813 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3814 CORBA::String_var value=anAttr->Value();
3815 if (strcmp((const char*)value,NomFich.c_str()) == 0)
3817 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3819 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3820 CORBA::String_var value2=anAttr2->Value();
3821 if (strcmp((const char*)value2,MeshName.c_str()) == 0)
3823 myBuilder->RemoveObjectWithChildren( aSO ) ;
3831 //=============================================================================
3832 void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter)
3834 MESSAGE( "PublishMeshIterInSmesh " << NomIter);
3835 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter];
3837 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3838 if (CORBA::is_nil(myIteration))
3840 SALOME::ExceptionStruct es;
3841 es.type = SALOME::BAD_PARAM;
3842 es.text = "Invalid iterationStudy Object";
3843 throw SALOME::SALOME_Exception(es);
3846 const char* MeshFile = myIteration->GetMeshFile() ;
3847 const char* MeshName = myIteration->GetMeshName() ;
3848 CORBA::Long Option = -1 ;
3849 int etat = myIteration->GetState();
3850 // Iteration initiale
3851 if ( etat <= 0 ) { Option = 0 ; }
3852 // ou iteration calculee
3853 else if ( etat == 2 ) { Option = 1 ; }
3854 // Publication effective apres menage eventuel
3857 DeleteResultInSmesh(MeshFile, MeshName) ;
3858 PublishResultInSmesh(MeshFile, Option) ;
3862 //=============================================================================
3863 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3865 // MESSAGE ("PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3866 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter];
3868 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3869 if (CORBA::is_nil(myIteration))
3871 SALOME::ExceptionStruct es;
3872 es.type = SALOME::BAD_PARAM;
3873 es.text = "Invalid iterationStudy Object";
3874 throw SALOME::SALOME_Exception(es);
3878 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3880 aStudyBuilder->NewCommand();
3882 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3883 // Pour les fichiers med, on affiche une icone de maillage
3884 // Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte'
3885 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3887 std::string ior = " " ;
3888 if ( Commentaire[0] == 'M' )
3889 { icone = "med.png" ; }
3891 { icone = "texte_2.png" ; }
3892 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3894 aStudyBuilder->CommitCommand();
3897 //=============================================================================
3898 void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire)
3900 // MESSAGE ("PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3901 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
3903 SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS)));
3904 if (CORBA::is_nil(myYACS))
3906 SALOME::ExceptionStruct es;
3907 es.type = SALOME::BAD_PARAM;
3908 es.text = "Invalid YACSStudy Object";
3909 throw SALOME::SALOME_Exception(es);
3913 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder();
3915 aStudyBuilder->NewCommand();
3917 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO);
3918 std::string icone = "texte_2.png" ;
3919 std::string ior = " " ;
3920 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3922 aStudyBuilder->CommitCommand();
3925 //=============================================================================
3926 //=============================================================================
3928 //=============================================================================
3929 //=============================================================================
3930 //=============================================================================
3931 // Creation d'un schema YACS
3932 // nomCas : nom du cas a traiter
3933 // FileName : nom du fichier contenant le script de lancement du calcul
3934 // DirName : le repertoire de lancement des calculs du schéma
3935 //=============================================================================
3936 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
3938 INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS );
3939 INFOS ( ". nomCas : " << nomCas);
3940 INFOS ( ". ScriptFile : " << ScriptFile);
3941 INFOS ( ". DirName : " << DirName);
3942 INFOS ( ". MeshFile : " << MeshFile);
3944 // A. Controle du nom :
3945 if ((myStudyContext._mesYACSs).find(nomYACS) != (myStudyContext._mesYACSs).end())
3947 SALOME::ExceptionStruct es;
3948 es.type = SALOME::BAD_PARAM;
3949 es.text = "This schema YACS has already been defined.";
3950 throw SALOME::SALOME_Exception(es);
3954 // B. Creation de l'objet
3955 HOMARD::HOMARD_YACS_var myYACS = newYACS();
3956 if (CORBA::is_nil(myYACS))
3958 SALOME::ExceptionStruct es;
3959 es.type = SALOME::BAD_PARAM;
3960 es.text = "Unable to create the schema YACS";
3961 throw SALOME::SALOME_Exception(es);
3964 myYACS->SetName( nomYACS ) ;
3966 // C. Enregistrement
3967 myStudyContext._mesYACSs[nomYACS] = myYACS;
3969 SALOMEDS::SObject_var aSO;
3970 SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myYACS, nomYACS);
3972 PublishCaseUnderYACS(nomYACS, nomCas);
3974 // D. Caracterisation
3976 myYACS->SetDirName( DirName ) ;
3977 myYACS->SetMeshFile( MeshFile ) ;
3978 myYACS->SetScriptFile( ScriptFile ) ;
3979 myYACS->SetCaseName( nomCas ) ;
3982 // D.2.1. Type constant
3983 myYACS->SetType( 1 ) ;
3984 // D.2.2. Convergence
3985 defaut_i = GetYACSMaxIter() ;
3986 myYACS->SetMaxIter( defaut_i ) ;
3987 defaut_i = GetYACSMaxNode() ;
3988 myYACS->SetMaxNode( defaut_i ) ;
3989 defaut_i = GetYACSMaxElem() ;
3990 myYACS->SetMaxElem( defaut_i ) ;
3991 // D.3. Fichier de sauvegarde dans le repertoire du cas
3992 HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ;
3993 std::string dirnamecase = caseyacs->GetDirName() ;
3994 std::string XMLFile ;
3995 XMLFile = dirnamecase + "/schema.xml" ;
3996 myYACS->SetXMLFile( XMLFile.c_str() ) ;
3998 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
4000 //=============================================================================
4001 // Ecriture d'un schema YACS
4002 //=============================================================================
4003 CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS)
4005 INFOS ( "YACSWrite : Ecriture de " << nomYACS );
4006 // Le repertoire du cas
4007 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
4008 ASSERT(!CORBA::is_nil(myYACS));
4009 // Le nom du fichier du schema
4010 std::string XMLFile ;
4011 XMLFile = myYACS->GetXMLFile() ;
4013 int codret = YACSWriteOnFile(nomYACS, XMLFile.c_str()) ;
4017 //=============================================================================
4018 // Ecriture d'un schema YACS sur un fichier donne
4019 //=============================================================================
4020 CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile)
4022 INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile );
4029 HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS];
4030 ASSERT(!CORBA::is_nil(myYACS));
4031 // B.2. Les caracteristiques
4032 std::string DirName = myYACS->GetDirName() ;
4033 std::string MeshFile = myYACS->GetMeshFile() ;
4034 std::string ScriptFile = myYACS->GetScriptFile() ;
4035 // B.3. Les caracteristiques de convergence
4036 int MaxIter = myYACS->GetMaxIter() ;
4037 int MaxNode = myYACS->GetMaxNode() ;
4038 int MaxElem = myYACS->GetMaxElem() ;
4042 const char* nomCas = myYACS->GetCaseName();
4043 HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas];
4044 ASSERT(!CORBA::is_nil(myCase));
4045 // C.2. Les instructions python associees au cas
4046 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4047 std::string pythonCas = dumpCorbaCase.in();
4048 MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
4050 // D. Les iterations
4051 // D.1. L'iteration initiale
4052 HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
4053 std::string Iter0Name = myCase->GetIter0Name() ;
4054 MESSAGE (". Iter0Name = " << Iter0Name);
4055 std::string MeshName = Iter0->GetMeshName();
4056 MESSAGE (". MeshName = " << MeshName);
4057 // D.2. L'iteration numero 1
4058 HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
4059 int numberOfIter = maListe->length();
4060 if ( numberOfIter > 1 )
4062 MESSAGE (". numberOfIter = " << numberOfIter);
4063 SALOME::ExceptionStruct es ;
4064 es.type = SALOME::BAD_PARAM;
4065 std::string text = "Une seule iteration est permise." ;
4066 es.text = CORBA::string_dup(text.c_str());
4067 throw SALOME::SALOME_Exception(es);
4070 std::string Iter1Name = std::string((*maListe)[0]);
4071 MESSAGE ("... Iter1Name = " << Iter1Name);
4072 HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
4073 // D.3. Les instructions python associees a l'iteration
4074 CORBA::String_var dumpCorbaIter = Iter1->GetDumpPython();
4075 std::string pythonIter = dumpCorbaIter.in();
4076 MESSAGE ("pythonIter :\n"<<pythonIter<<"\n");
4078 // E. L'hypothese pour passer de l'iteration initiale a la suivante
4079 // E.1. La structure
4080 std::string nomHypo = Iter1->GetHypoName();
4081 MESSAGE (". nomHypo = " << nomHypo);
4082 HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo];
4083 ASSERT(!CORBA::is_nil(myHypo));
4084 // E.2. Les caracteristiques de l'adaptation
4085 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
4086 ASSERT(ListTypes->length() == 3);
4087 int TypeAdap = (*ListTypes)[0];
4088 // int TypeRaff = (*ListTypes)[1];
4089 // int TypeDera = (*ListTypes)[2];
4090 // E.3. Les instructions python associees a l'hypothese
4091 CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
4092 std::string pythonHypo = dumpCorbaHypo.in();
4093 MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
4095 // F. Le fichier du schema de reference
4096 // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD
4097 std::string XMLFile_base ;
4098 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { XMLFile_base = getenv("HOMARD_ROOT_DIR") ; }
4101 SALOME::ExceptionStruct es ;
4102 es.type = SALOME::BAD_PARAM;
4103 std::string text = "HOMARD_ROOT_DIR est inconnu." ;
4104 es.text = CORBA::string_dup(text.c_str());
4105 throw SALOME::SALOME_Exception(es);
4108 XMLFile_base += "/share/salome/resources/homard/yacs_01." + _LangueShort + ".xml" ;
4110 MESSAGE("XMLFile_base ="<<XMLFile_base);
4112 // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4113 YACSDriver* myDriver = new YACSDriver(XMLFile, DirName);
4114 std::ifstream fichier( XMLFile_base.c_str() );
4115 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
4117 // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
4118 std::string ligne; // variable contenant chaque ligne lue
4119 std::string mot_cle;
4120 while ( std::getline( fichier, ligne ) )
4122 // G.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
4123 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4124 ligne_bis >> mot_cle ;
4125 // G.1.2. Le maillage initial
4126 if ( mot_cle == "DataInit_MeshFile" )
4127 { myDriver->Texte_DataInit_MeshFile(MeshFile); }
4128 // G.1.3. Le script de lancement
4129 else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
4130 { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); }
4131 // G.1.4. Les options du cas
4132 else if ( mot_cle == "Iter_1_Case_Options" )
4133 { myDriver->Texte_Iter_1_Case_Options(pythonCas); }
4134 // G.1.5. Execution de HOMARD : le repertoire du cas
4135 else if ( mot_cle == "HOMARD_Exec_DirName" )
4136 { myDriver->Texte_HOMARD_Exec_DirName(); }
4137 // G.1.6. Execution de HOMARD : le nom du maillage
4138 else if ( mot_cle == "HOMARD_Exec_MeshName" )
4140 myDriver->Texte_HOMARD_Exec_MeshName(MeshName);
4141 std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ;
4142 myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ;
4144 // G.1.7. Execution de HOMARD : les options de l'hypothese
4145 else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
4146 { myDriver->Texte_python_1( pythonHypo, 3, "Hypo" ) ; }
4147 // G.1.8. Execution de HOMARD : les options de l'iteration
4148 else if ( mot_cle == "HOMARD_Exec_Iter_Options" )
4149 { myDriver->Texte_python_2( pythonIter, "TimeStep", "Iter" ) ; }
4150 // G.1.9. a. Creation eventuelles des zones et frontieres
4152 else if ( mot_cle == "Iter_1" )
4154 std::string texte_control = "" ;
4155 if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; }
4156 texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ;
4157 texte_control += myDriver->Texte_Iter_1_control() ;
4158 myDriver->TexteAdd(texte_control);
4160 // G.1.10. Les tests de convergence
4161 else if ( mot_cle == "Analyse_Test_Convergence" )
4162 { myDriver->TexteAnalyse_Test_Convergence(MaxIter, MaxNode, MaxElem); }
4163 // G.1.11. Les parametres
4164 else if ( mot_cle == "PARAMETRES" )
4165 { myDriver->TexteAddParametres(); }
4166 // G.1.n. La ligne est recopiee telle quelle
4167 else { myDriver->TexteAdd(ligne); }
4169 // G.2. Ecriture du texte dans le fichier
4171 { myDriver->CreeFichier(); }
4175 SALOME::ExceptionStruct es;
4176 es.type = SALOME::BAD_PARAM;
4177 std::string text = "The reference file for the YACS schema cannot be read." ;
4178 es.text = CORBA::string_dup(text.c_str());
4179 throw SALOME::SALOME_Exception(es);
4184 // H. Publication du fichier dans l'arbre
4186 std::string Commentaire = "xml" ;
4187 PublishFileUnderYACS(nomYACS, XMLFile, Commentaire.c_str());
4191 //=============================================================================
4192 // Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
4193 //=============================================================================
4194 std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
4196 MESSAGE ( "YACSDriverTexteZone" );
4197 // A. Les zones associees a cette hypothese
4198 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
4199 int numberOfZonesx2 = ListZone->length();
4201 // B. Parcours des zones
4202 std::string texte_control ;
4203 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
4205 // 1. Reperage de la zone
4206 std::string ZoneName = std::string((*ListZone)[iaux]);
4207 MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
4208 HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName];
4209 ASSERT(!CORBA::is_nil(myZone));
4210 // 2. Les instructions python associees a la zone
4211 // La premiere ligne est un commentaire a eliminer
4212 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4213 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4214 std::string pythonStructure_0 = dumpCorbaZone.in();
4215 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4216 std::istringstream tout (pythonStructure_0) ;
4218 std::string pythonStructure ;
4219 while ( std::getline( tout, ligne ) )
4220 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4221 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4222 // 3. Decodage du nom du service
4223 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4224 MESSAGE ( "... methode = " << methode);
4225 // 4. Mise en place des instructions
4226 int ZoneType = myZone->GetType();
4227 MESSAGE ( "... ZoneType = " << ZoneType);
4228 std::string texte_control_0 ;
4229 texte_control_0 = myDriver->Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName );
4230 texte_control += texte_control_0 ;
4235 return texte_control ;
4237 //=============================================================================
4238 // Ecriture d'un schema YACS : ecriture des frontieres associees au cas
4239 //=============================================================================
4240 std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver)
4242 MESSAGE ( "YACSDriverTexteBoundary" );
4243 // A. Les frontieres associees au cas
4244 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
4245 int numberOfitems = ListBoundaryGroupType->length();
4247 // B. Parcours des frontieres
4248 std::string texte_control ;
4249 std::list<std::string> ListeBoundaryTraitees ;
4250 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
4252 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
4253 MESSAGE ( "... BoundaryName = " << BoundaryName);
4254 // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver
4255 // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees
4257 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
4258 while (it != ListeBoundaryTraitees.end())
4260 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
4261 if ( BoundaryName == *it ) { A_faire = 0 ; }
4266 // 1. Caracteristiques de la frontiere
4267 HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName];
4268 ASSERT(!CORBA::is_nil(myBoundary));
4269 // 2. Les instructions python associees a la frontiere
4270 // La premiere ligne est un commentaire a eliminer
4271 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
4272 CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython();
4273 std::string pythonStructure_0 = dumpCorbaBoundary.in();
4274 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
4275 std::istringstream tout (pythonStructure_0) ;
4277 std::string pythonStructure ;
4278 while ( std::getline( tout, ligne ) )
4279 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
4280 MESSAGE ("pythonStructure :\n"<<pythonStructure);
4281 // 3. Decodage du nom du service
4282 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
4283 MESSAGE ( "... methode = " << methode);
4284 // 4. Mise en place des instructions
4285 int BoundaryType = myBoundary->GetType();
4286 MESSAGE ( "... BoundaryType = " << BoundaryType);
4287 const char* MeshName ;
4288 const char* MeshFile ;
4289 if (BoundaryType == 0)
4291 MeshName = myBoundary->GetMeshName() ;
4292 MESSAGE ( ". MeshName = " << MeshName );
4293 MeshFile = myBoundary->GetMeshFile() ;
4294 MESSAGE ( ". MeshFile = " << MeshFile );
4296 std::string texte_control_0 ;
4297 texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName, MeshName, MeshFile );
4298 texte_control += texte_control_0 ;
4299 // 5. Memorisation du traitement
4300 ListeBoundaryTraitees.push_back( BoundaryName );
4304 return texte_control ;
4307 //=============================================================================
4308 //=============================================================================
4309 // Next functions are inherited from SALOMEDS::Driver interface
4310 //=============================================================================
4311 //=============================================================================
4312 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
4314 CORBA::Boolean isMultiFile)
4316 MESSAGE ("Save for theURL = "<< theURL);
4317 SALOMEDS::TMPFile_var aStreamFile;
4319 // get temporary directory name
4320 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4322 StudyContext& context = myStudyContext;
4324 // HOMARD data file name
4325 std::string aFileName = "";
4327 aFileName = SALOMEDS_Tool::GetNameFromPath(SMESH_Gen_i::getStudyServant()->URL());
4328 aFileName += "_HOMARD.dat";
4330 // initialize sequence of file names
4331 SALOMEDS_Tool::ListOfFiles aFileSeq;
4332 aFileSeq.reserve(1);
4333 aFileSeq.push_back(CORBA::string_dup(aFileName.c_str())) ;
4335 // get full path to the data file
4336 aFileName = tmpDir + aFileName;
4340 std::ofstream f(aFileName.c_str());
4342 // clear temporary id map
4343 context._idmap.clear();
4348 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
4349 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
4350 HOMARD::HOMARD_Cas_var aCas = it_case->second;
4351 PortableServer::ServantBase_var aServant = GetServant(aCas);
4352 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4354 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
4355 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
4359 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4360 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
4361 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
4362 PortableServer::ServantBase_var aServant = GetServant(aZone);
4363 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4365 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
4366 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4369 // -> save hypotheses
4370 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4371 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
4372 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
4373 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4374 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4376 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
4377 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4380 // -> save iterations
4381 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4382 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
4383 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
4384 PortableServer::ServantBase_var aServant = GetServant(aIter);
4385 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4387 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
4388 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4391 // -> save boundaries
4392 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4393 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
4394 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
4395 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4396 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4397 if (aBoundaryServant) {
4398 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
4399 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4403 MESSAGE ("close file");
4406 // put temporary files to the stream
4407 MESSAGE ("put temporary files to the stream");
4408 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq, isMultiFile);
4410 // remove temporary files
4411 MESSAGE ("remove temporary files");
4412 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true);
4414 // return data stream
4415 MESSAGE ("return data stream");
4416 return aStreamFile._retn();
4419 //===========================================================================
4420 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
4422 CORBA::Boolean isMultiFile)
4424 // No specific ASCII persistence
4425 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
4426 return aStreamFile._retn();
4429 //===========================================================================
4430 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
4431 const SALOMEDS::TMPFile& theStream,
4433 CORBA::Boolean isMultiFile)
4435 MESSAGE ("Load pour theURL = "<< theURL);
4437 // set current study
4438 if (myStudy->_is_nil())
4441 // get temporary directory name
4442 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
4444 // Convert the stream into sequence of files to process
4445 SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
4448 // HOMARD data file name
4449 std::string aFileName = "";
4451 aFileName = SALOMEDS_Tool::GetNameFromPath(SMESH_Gen_i::getStudyServant()->URL());
4452 aFileName = tmpDir + aFileName + "_HOMARD.dat";
4454 StudyContext& context = myStudyContext;
4458 std::ifstream f(aFileName.c_str());
4461 context._mesCas.clear();
4462 context._mesHypotheses.clear();
4463 context._mesIterations.clear();
4464 context._mesZones.clear();
4465 context._mesBoundarys.clear();
4466 context._idmap.clear();
4472 std::getline(f, line);
4473 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
4474 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
4475 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
4476 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
4477 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
4478 std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS);
4479 if (line.substr(0, bounSignature.size()) == bounSignature) {
4480 // re-create boundary
4481 MESSAGE ("Recreation de la frontiere" );
4482 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
4483 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4484 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4485 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
4486 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
4487 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4490 else if (line.substr(0, caseSignature.size()) == caseSignature) {
4492 MESSAGE ("Recreation du cas" );
4493 HOMARD::HOMARD_Cas_var aCase = newCase();
4494 PortableServer::ServantBase_var aServant = GetServant(aCase);
4495 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4496 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
4497 context._mesCas[aCase->GetName()] = aCase;
4498 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
4501 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
4502 // re-create hypothesis
4503 MESSAGE ("Recreation de l hypothese" );
4504 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
4505 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4506 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4507 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
4508 context._mesHypotheses[aHypo->GetName()] = aHypo;
4509 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4512 else if (line.substr(0, iterSignature.size()) == iterSignature) {
4513 // re-create iteration
4514 MESSAGE ("Recreation de l'iteration" );
4515 HOMARD::HOMARD_Iteration_var aIter = newIteration();
4516 PortableServer::ServantBase_var aServant = GetServant(aIter);
4517 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4518 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
4519 context._mesIterations[aIter->GetName()] = aIter;
4520 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4523 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
4524 MESSAGE ("Recreation de la zone" );
4526 HOMARD::HOMARD_Zone_var aZone = newZone();
4527 PortableServer::ServantBase_var aServant = GetServant(aZone);
4528 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4529 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
4530 context._mesZones[aZone->GetName()] = aZone;
4531 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4534 else if (line.substr(0, zoneSignature.size()) == yacsSignature) {
4535 MESSAGE ("Recreation du schema YACS" );
4537 HOMARD::HOMARD_YACS_var aYACS = newYACS();
4538 PortableServer::ServantBase_var aServant = GetServant(aYACS);
4539 HOMARD_YACS_i* aYACSServant = dynamic_cast<HOMARD_YACS_i*>(aServant.in());
4540 if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) {
4541 context._mesYACSs[aYACS->GetName()] = aYACS;
4542 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aYACSServant);
4551 // Remove temporary files created from the stream
4553 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true);
4558 //===========================================================================
4559 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
4560 const SALOMEDS::TMPFile& theStream,
4562 CORBA::Boolean isMultiFile)
4564 // No specific ASCII persistence
4565 return Load(theComponent, theStream, theURL, isMultiFile);
4568 //===========================================================================
4569 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
4573 //===========================================================================
4574 char* HOMARD_Gen_i::ComponentDataType()
4576 return CORBA::string_dup("HOMARD");
4579 //===========================================================================
4580 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
4581 const char* IORString,
4582 CORBA::Boolean isMultiFile,
4583 CORBA::Boolean isASCII)
4585 CORBA::String_var aString("");
4586 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
4587 StudyContext context = myStudyContext;
4588 CORBA::Object_var anObj = _orb->string_to_object(IORString);
4589 if (!CORBA::is_nil(anObj)) {
4590 PortableServer::ServantBase_var aServant = GetServant(anObj);
4591 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
4593 std::map<int, PortableServer::ServantBase*>::const_iterator it;
4594 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
4595 if (it->second == aStorable) {
4596 std::stringstream os;
4598 aString = CORBA::string_dup(os.str().c_str());
4604 return aString._retn();
4607 //===========================================================================
4608 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
4609 const char* aLocalPersistentID,
4610 CORBA::Boolean isMultiFile,
4611 CORBA::Boolean isASCII)
4613 CORBA::String_var aString("");
4614 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
4615 StudyContext context = myStudyContext;
4616 int id = atoi(aLocalPersistentID);
4617 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
4618 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
4619 if (!CORBA::is_nil(object)) {
4620 aString = _orb->object_to_string(object);
4624 return aString._retn();
4627 //===========================================================================
4628 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
4630 if(CORBA::is_nil(myStudy))
4633 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
4634 if(!aCas->_is_nil())
4637 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
4638 if(!aHypo->_is_nil())
4641 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
4642 if(!aZone->_is_nil())
4645 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
4646 if(!aBoundary->_is_nil())
4649 /* Iteration is not published directly
4650 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
4651 if(!aIter->_is_nil())
4657 //===========================================================================
4658 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
4660 // No Copy/Paste support
4664 //===========================================================================
4665 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
4666 CORBA::Long& theObjectID)
4668 // No Copy/Paste support
4669 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
4670 return aStreamFile._retn();
4673 //===========================================================================
4674 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
4675 CORBA::Long theObjectID)
4677 // No Copy/Paste support
4681 //===========================================================================
4682 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
4683 CORBA::Long theObjectID,
4684 SALOMEDS::SObject_ptr theSObject)
4686 // No Copy/Paste support
4687 SALOMEDS::SObject_var aResultSO;
4688 return aResultSO._retn();
4691 //===========================================================================
4692 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
4694 PortableServer::Servant aServant = 0;
4695 if (!CORBA::is_nil(theObject)) {
4697 aServant = _poa->reference_to_servant(theObject);
4705 //==========================================================================
4706 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Boolean isPublished,
4707 CORBA::Boolean isMultiFile,
4708 CORBA::Boolean& isValidScript)
4710 MESSAGE ("Entree dans DumpPython");
4713 SALOMEDS::SObject_var aSO = SMESH_Gen_i::getStudyServant()->FindComponent("HOMARD");
4714 if(CORBA::is_nil(aSO))
4715 return new Engines::TMPFile(0);
4717 std::string aScript = "\"\"\"\n";
4718 aScript += "Python script for HOMARD\n";
4719 aScript += "Copyright 1996, 2011, 2015 EDF\n";
4720 aScript += "\"\"\"\n";
4721 aScript += "__revision__ = \"V1.2\"\n";
4722 aScript += "import HOMARD\n";
4724 aScript += "import salome\n";
4725 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4726 aScript += "\thomard.UpdateStudy()\n";
4727 MESSAGE (". Au depart \n"<<aScript);
4730 if (myStudyContext._mesBoundarys.size() > 0)
4732 MESSAGE (". Ecritures des frontieres");
4733 aScript += "#\n# Creation of the boundaries";
4734 aScript += "\n# ==========================";
4736 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4737 for (it_boundary = myStudyContext._mesBoundarys.begin();
4738 it_boundary != myStudyContext._mesBoundarys.end(); ++it_boundary)
4740 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4741 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4742 std::string dumpBoundary = dumpCorbaBoundary.in();
4743 MESSAGE (dumpBoundary<<"\n");
4744 aScript += dumpBoundary;
4748 if (myStudyContext._mesZones.size() > 0)
4750 MESSAGE (". Ecritures des zones");
4751 aScript += "#\n# Creation of the zones";
4752 aScript += "\n# =====================";
4754 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4755 for ( it_zone = myStudyContext._mesZones.begin();
4756 it_zone != myStudyContext._mesZones.end(); ++it_zone)
4758 HOMARD::HOMARD_Zone_var myZone = (*it_zone).second;
4759 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
4760 std::string dumpZone = dumpCorbaZone.in();
4761 MESSAGE (dumpZone<<"\n");
4762 aScript += dumpZone;
4766 if (myStudyContext._mesHypotheses.size() > 0)
4768 MESSAGE (". Ecritures des hypotheses");
4769 aScript += "#\n# Creation of the hypotheses";
4770 aScript += "\n# ==========================";
4772 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4773 for ( it_hypo = myStudyContext._mesHypotheses.begin();
4774 it_hypo != myStudyContext._mesHypotheses.end(); it_hypo++)
4776 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4777 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4778 std::string dumpHypo = dumpCorbaHypo.in();
4779 MESSAGE (dumpHypo<<"\n");
4780 aScript += dumpHypo;
4784 if (myStudyContext._mesCas.size() > 0)
4786 MESSAGE (". Ecritures des cas");
4787 aScript += "#\n# Creation of the cases";
4788 aScript += "\n# =====================";
4790 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4791 for (it_cas = myStudyContext._mesCas.begin();
4792 it_cas != myStudyContext._mesCas.end(); it_cas++)
4794 std::string nomCas = (*it_cas).first;
4795 std::string dumpCas = std::string("\n# Creation of the case ") ;
4796 dumpCas += nomCas + std::string("\n");
4797 dumpCas += std::string("\t") + nomCas;
4798 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4800 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4801 CORBA::String_var cIter0= myCase->GetIter0Name();
4802 std::string iter0 = cIter0.in();
4804 HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[iter0];
4805 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4806 std::string mesh0 = cMesh0.in();
4807 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4808 std::string meshName0 = cMeshName0.in();
4809 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4810 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4811 std::string dumpCas2= dumpCorbaCase.in();
4813 MESSAGE (dumpCas<<dumpCas2<<"\n");
4814 aScript += dumpCas + dumpCas2;
4818 if (myStudyContext._mesIterations.size() > 0)
4820 MESSAGE (". Ecritures des iterations");
4821 aScript += "#\n# Creation of the iterations" ;
4822 aScript += "\n# ==========================";
4824 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4825 for (it_iter = myStudyContext._mesIterations.begin();
4826 it_iter != myStudyContext._mesIterations.end(); ++it_iter)
4828 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4829 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4830 std::string dumpIter = dumpCorbaIter.in();
4831 MESSAGE (dumpIter<<"\n");
4832 aScript += dumpIter;
4836 if (myStudyContext._mesYACSs.size() > 0)
4838 MESSAGE (". Ecritures des schemas YACS");
4839 aScript += "#\n# Creation of the schemas YACS";
4840 aScript += "\n# ============================";
4842 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it_yacs;
4843 for ( it_yacs = myStudyContext._mesYACSs.begin();
4844 it_yacs != myStudyContext._mesYACSs.end(); ++it_yacs)
4846 HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second;
4847 CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython();
4848 std::string dumpYACS = dumpCorbaYACS.in();
4849 MESSAGE (dumpYACS<<"\n");
4850 aScript += dumpYACS;
4853 MESSAGE (". Ecritures finales");
4855 aScript += "\n\tpass";
4858 if( !isMultiFile ) // remove unnecessary tabulation
4859 aScript = RemoveTabulation( aScript );
4861 // MESSAGE ("A ecrire \n"<<aScript);
4862 const size_t aLen = strlen(aScript.c_str());
4863 char* aBuffer = new char[aLen+1];
4864 strcpy(aBuffer, aScript.c_str());
4866 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4867 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4869 MESSAGE ("Sortie de DumpPython");
4870 return aStreamFile._retn();
4874 //=============================================================================
4875 //=============================================================================
4877 //=============================================================================
4878 //=============================================================================
4879 void HOMARD_Gen_i::IsValidStudy( )
4881 // MESSAGE( "IsValidStudy" );
4882 if (CORBA::is_nil(SMESH_Gen_i::getStudyServant()))
4884 SALOME::ExceptionStruct es;
4885 es.type = SALOME::BAD_PARAM;
4886 es.text = "Invalid study context";
4887 throw SALOME::SALOME_Exception(es);
4892 //=============================================================================
4893 char* HOMARD_Gen_i::VerifieDir(const char* nomDir)
4895 std::string casename = std::string("") ;
4896 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4897 for (it = myStudyContext._mesCas.begin();
4898 it != myStudyContext._mesCas.end(); it++)
4900 if (std::string(nomDir) == std::string(it->second->GetDirName()))
4902 casename = std::string(it->second->GetName()) ;
4906 return CORBA::string_dup( casename.c_str() );
4908 /*//=============================================================================
4909 void SALOMEException( std::string message )
4911 SALOME::ExceptionStruct es;
4912 es.type = SALOME::BAD_PARAM;
4914 throw SALOME::SALOME_Exception(es);
4917 //=============================================================================
4918 char* HOMARD_Gen_i::getVersion()
4920 #if HOMARD_DEVELOPMENT
4921 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4923 return CORBA::string_dup(HOMARD_VERSION_STR);
4926 //===============================================================================
4927 // Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere
4928 // ligne : la ligne a manipuler
4929 // caractere : le caractere a reperer
4930 // option : 0 : la chaine avant la premiere apparition du caractere
4931 // 1 : la chaine apres la premiere apparition du caractere
4932 // 2 : la chaine avant la derniere apparition du caractere
4933 // 3 : la chaine apres la derniere apparition du caractere
4934 // Si le caractere est absent, on retourne la chaine totale
4935 //===============================================================================
4936 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option )
4938 // MESSAGE("GetStringInTexte, recherche de '"<<caractere<<"' dans '"<<ligne<<"'"<<", option = "<<option);
4940 std::string chaine = ligne ;
4942 if ( option < 2 ) { position = ligne.find_first_of( caractere ) ; }
4943 else { position = ligne.find_last_of( caractere ) ; }
4944 // MESSAGE("position = "<<position);
4945 // MESSAGE("a = "<<ligne.substr( 0, position ).c_str());
4946 // MESSAGE("b = "<<ligne.substr( position+1 ).c_str());
4948 if ( position != std::string::npos )
4950 if ( ( option == 0 ) || ( option == 2 ) ) { chaine = ligne.substr( 0, position ) ; }
4951 else { chaine = ligne.substr( position+1 ) ; }
4956 //=============================================================================
4957 //=============================================================================
4958 // Gestion des preferences
4959 //=============================================================================
4960 //=============================================================================
4961 // Decodage du fichier d'arcihvage des preferences
4963 void HOMARD_Gen_i::SetPreferences( )
4965 MESSAGE ( "SetPreferences" );
4967 std::string ligne, mot_cle, salome_version ;
4970 // A. Les valeurs par defaut ; elles doivent etre coherentes
4971 std::string LanguageShort = "en" ;
4972 int PublisMeshIN = 0 ;
4973 int PublisMeshOUT = 0 ;
4974 int YACSMaxIter = 0 ;
4975 int YACSMaxNode = 0 ;
4976 int YACSMaxElem = 0 ;
4977 std::string YACSTypeTestchaine = "None" ;
4979 // B. La version de salome
4980 // Cela se presente sous la forme :
4981 // [SALOME KERNEL] : 7.3.0
4983 File = getenv("KERNEL_ROOT_DIR") ;
4984 File += "/bin/salome/VERSION" ;
4985 MESSAGE ( "File = "<<File ) ;
4986 std::ifstream fichier0( File.c_str() ) ;
4987 if ( fichier0 ) // ce test échoue si le fichier n'est pas ouvert
4989 std::string ligne; // variable contenant chaque ligne lue
4990 while ( std::getline( fichier0, ligne ) )
4992 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
4993 ligne_bis >> mot_cle ;
4994 if ( mot_cle == "[SALOME" )
4996 salome_version = GetStringInTexte ( ligne, " ", 3 ) ;
4997 // MESSAGE ( "salome_version = "<<salome_version<<"|||");
5002 else { ok = false ; }
5004 // B. Decodage du fichier de preferences
5007 std::string PrefFile ;
5008 PrefFile = getenv("HOME") ;
5009 PrefFile += "/.config/salome/SalomeApprc." + salome_version ;
5010 MESSAGE ( "PrefFile = "<<PrefFile ) ;
5012 std::ifstream fichier( PrefFile.c_str() );
5013 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
5015 bool section_langue = false ;
5016 bool section_homard = false ;
5017 while ( std::getline( fichier, ligne ) )
5019 std::string chaine ;
5020 // 1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
5021 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
5022 ligne_bis >> mot_cle ;
5025 // 2.1. Debut d'une section
5026 // MESSAGE(mot_cle);
5027 if ( mot_cle == "<section" )
5028 { /*MESSAGE ( "Debut de la section : "<< ligne);*/
5029 ligne_bis >> mot_cle ;
5030 chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ;
5031 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5032 if ( chaine == "language" ) { section_langue = true ; }
5033 if ( chaine == "HOMARD" ) { section_homard = true ; }
5034 // MESSAGE ( "section_langue = "<<section_langue<<", section_homard = "<<section_homard);
5036 // 2.2. Fin d'une section
5037 else if ( mot_cle == "</section>" )
5038 { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<<section_langue<<", section_homard = "<<section_homard);*/
5039 section_langue = false ;
5040 section_homard = false ; }
5044 else if ( section_langue || section_homard )
5045 { MESSAGE ( "a decoder : "<< ligne);
5046 // La valeur : entre les deux premieres quotes
5047 chaine = GetStringInTexte ( ligne, "\"", 1 ) ;
5048 // MESSAGE("chaine 1 = |"<<chaine<<"|");
5049 chaine = GetStringInTexte ( chaine, "\"", 0 ) ;
5050 // MESSAGE("chaine = |"<<chaine<<"|");
5051 // Le mot_cle : entre les deux dernieres quotes
5052 std::string chaine2 = GetStringInTexte ( ligne, "\"", 2 ) ;
5053 // MESSAGE("chaine2 1 = |"<<chaine2<<"|");
5054 chaine2 = GetStringInTexte ( chaine2, "\"", 3 ) ;
5055 // MESSAGE("chaine2 = |"<<chaine2<<"|");
5057 if ( section_langue )
5058 { if ( chaine2 == "language" ) { LanguageShort = chaine ; } }
5060 if ( section_homard )
5062 std::istringstream chainebis( chaine ) ;
5063 // 3.2.1. Les publications
5064 if ( chaine2 == "publish_mesh_in" ) { chainebis >> PublisMeshIN ; }
5065 if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT ; }
5066 // 3.2.2. Les maximum pour YACS
5067 if ( chaine2 == "yacs_max_iter" ) { chainebis >> YACSMaxIter ; }
5068 if ( chaine2 == "yacs_max_node" ) { chainebis >> YACSMaxNode ; }
5069 if ( chaine2 == "yacs_max_elem" ) { chainebis >> YACSMaxElem ; }
5070 if ( chaine2 == "yacs_type_test" ) { YACSTypeTestchaine = chaine ; }
5077 // C. Enregistrements
5078 MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort );
5079 SetLanguageShort( LanguageShort.c_str() ) ;
5081 MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT);
5082 SetPublisMesh(PublisMeshIN, PublisMeshOUT) ;
5084 MESSAGE ("Enregistrement de YACSMaxIter = " << YACSMaxIter<<", YACSMaxNode = "<< YACSMaxNode<<", YACSMaxElem = "<< YACSMaxElem);
5085 SetYACSMaximum(YACSMaxIter, YACSMaxNode, YACSMaxElem) ;
5087 MESSAGE ("Enregistrement de TypeTest = " << YACSTypeTestchaine.c_str() );
5089 if ( ( YACSTypeTestchaine == "VTest > VRef" ) || ( YACSTypeTestchaine == "VTest > VRef" ) ) { YACSTypeTest = 1 ; }
5090 else if ( ( YACSTypeTestchaine == "VTest < VRef" ) || ( YACSTypeTestchaine == "VTest < VRef" ) ) { YACSTypeTest = 2 ; }
5091 else { YACSTypeTest = 0 ; }
5092 MESSAGE ("==> TypeTest = " << YACSTypeTest );
5093 SetYACSConvergenceType( YACSTypeTest ) ;
5097 //===============================================================================
5099 //===============================================================================
5100 void HOMARD_Gen_i::SetLanguageShort(const char* LanguageShort)
5102 // MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort );
5103 _LangueShort = LanguageShort ;
5104 if ( _LangueShort == "fr" ) { _Langue = "Francais" ; }
5105 else { _Langue = "English" ; }
5108 char* HOMARD_Gen_i::GetLanguageShort()
5110 // MESSAGE ("GetLanguageShort");
5111 return CORBA::string_dup( _LangueShort.c_str() );
5113 //===============================================================================
5114 // Options de publications
5115 //===============================================================================
5116 void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT)
5118 _PublisMeshIN = PublisMeshIN ;
5119 _PublisMeshOUT = PublisMeshOUT ;
5122 CORBA::Long HOMARD_Gen_i::GetPublisMeshIN()
5124 return _PublisMeshIN ;
5126 CORBA::Long HOMARD_Gen_i::GetPublisMeshOUT()
5128 return _PublisMeshOUT ;
5130 //===============================================================================
5131 // YACS - test de convergence
5132 //===============================================================================
5133 void HOMARD_Gen_i::SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem)
5135 _YACSMaxIter = YACSMaxIter ;
5136 _YACSMaxNode = YACSMaxNode ;
5137 _YACSMaxElem = YACSMaxElem ;
5140 CORBA::Long HOMARD_Gen_i::GetYACSMaxIter()
5142 return _YACSMaxIter ;
5144 CORBA::Long HOMARD_Gen_i::GetYACSMaxNode()
5146 return _YACSMaxNode ;
5148 CORBA::Long HOMARD_Gen_i::GetYACSMaxElem()
5150 return _YACSMaxElem ;
5152 void HOMARD_Gen_i::SetYACSConvergenceType(CORBA::Long YACSTypeTest)
5154 _YACSTypeTest = YACSTypeTest ;
5157 CORBA::Long HOMARD_Gen_i::GetYACSConvergenceType()
5159 return _YACSTypeTest ;
5162 //=============================================================================
5166 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
5167 PortableServer::POA_ptr poa,
5168 PortableServer::ObjectId* contId,
5169 const char* instanceName,
5170 const char* interfaceName)
5172 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
5173 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
5174 return myHOMARD_Gen->getId();