1 // Copyright (C) 2011-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "HOMARD_Gen_i.hxx"
21 #include "HOMARD_Cas_i.hxx"
22 #include "HOMARD_Hypothesis_i.hxx"
23 #include "HOMARD_Iteration_i.hxx"
24 #include "HOMARD_Boundary_i.hxx"
25 #include "HOMARD_Zone_i.hxx"
26 #include "HOMARD_YACS_i.hxx"
27 #include "HomardDriver.hxx"
28 #include "HOMARD_DriverTools.hxx"
29 #include "HomardMedCommun.h"
30 #include "YACSDriver.hxx"
32 #include "HOMARD_version.h"
34 #include "utilities.h"
35 #include "Utils_SINGLETON.hxx"
36 #include "Utils_CorbaException.hxx"
37 #include "SALOMEDS_Tool.hxx"
38 #include "SALOME_LifeCycleCORBA.hxx"
39 #include "SALOMEconfig.h"
40 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
41 #include CORBA_CLIENT_HEADER(SMESH_Gen)
58 //=============================================================================
60 //=============================================================================
61 std::string RemoveTabulation( std::string theScript )
63 std::string::size_type aPos = 0;
64 while( aPos < theScript.length() )
66 aPos = theScript.find( "\n\t", aPos );
67 if( aPos == std::string::npos )
69 theScript.replace( aPos, 2, "\n" );
74 //=============================================================================
76 * standard constructor
78 //=============================================================================
79 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
80 PortableServer::POA_ptr poa,
81 PortableServer::ObjectId * contId,
82 const char *instanceName,
83 const char *interfaceName) :
84 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
86 MESSAGE("constructor");
88 _id = _poa->activate_object(_thisObj);
90 myHomard = new ::HOMARD_Gen();
91 _NS = SINGLETON_<SALOME_NamingService>::Instance();
92 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
95 //=================================
99 //================================
100 HOMARD_Gen_i::~HOMARD_Gen_i()
103 //=============================================================================
104 //=============================================================================
105 // Utilitaires pour l'étude
106 //=============================================================================
107 //=============================================================================
108 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
110 ASSERT(!CORBA::is_nil(theStudy));
111 MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
112 SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
114 // Create SComponent labelled 'homard' if it doesn't already exit
115 SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
116 if (CORBA::is_nil(homardFather))
118 myBuilder->NewCommand();
119 MESSAGE("Add Component HOMARD");
121 bool aLocked = theStudy->GetProperties()->IsLocked();
122 if (aLocked) theStudy->GetProperties()->SetLocked(false);
124 homardFather = myBuilder->NewComponent(ComponentDataType());
125 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
126 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
127 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
128 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
129 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
130 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
131 if (!Comp->_is_nil())
133 aName->SetValue(ComponentDataType());
136 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
137 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
138 aPixmap->SetPixMap("HOMARD_2.png");
139 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
141 if (aLocked) theStudy->GetProperties()->SetLocked(true);
142 myBuilder->CommitCommand();
145 //=============================================================================
146 void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
148 MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID());
149 myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy);
150 this->addInStudy(myCurrentStudy);
152 //=============================================================================
153 SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
154 //=============================================================================
156 MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID());
157 return SALOMEDS::Study::_duplicate(myCurrentStudy);
159 //=============================================================================
160 CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
161 //=============================================================================
163 return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
165 //=============================================================================
166 //=============================================================================
168 //=============================================================================
169 //=============================================================================
170 // Utilitaires pour l'iteration
171 //=============================================================================
172 //=============================================================================
173 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
174 //=====================================================================================
176 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
177 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
178 if (CORBA::is_nil(myIteration))
180 SALOME::ExceptionStruct es;
181 es.type = SALOME::BAD_PARAM;
182 es.text = "Invalid iteration";
183 throw SALOME::SALOME_Exception(es);
187 myIteration->SetState(Etat);
189 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
190 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
194 icone = "iter0.png" ;
195 else if ( Etat == 2 )
196 icone = "iter_calculee.png" ;
198 icone = "iter_non_calculee.png" ;
199 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ;
201 aStudyBuilder->CommitCommand();
204 //=============================================================================
205 //=============================================================================
207 //=============================================================================
208 //=============================================================================
209 // Destruction des structures identifiees par leurs noms
210 //=============================================================================
211 //=============================================================================
212 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
214 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
215 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
216 if (CORBA::is_nil(myBoundary))
218 SALOME::ExceptionStruct es;
219 es.type = SALOME::BAD_PARAM;
220 es.text = "Invalid boundary";
221 throw SALOME::SALOME_Exception(es);
225 // On verifie que la frontiere n'est plus utilisee
226 HOMARD::listeCases* maListe = GetAllCasesName();
227 int numberOfCases = maListe->length();
228 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
229 std::string CaseName ;
230 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
232 HOMARD::HOMARD_Cas_var myCase ;
233 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
235 CaseName = std::string((*maListe)[NumeCas]);
236 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
237 myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
238 ASSERT(!CORBA::is_nil(myCase));
239 ListBoundaryGroupType = myCase->GetBoundaryGroup();
240 numberOfitems = ListBoundaryGroupType->length();
241 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
242 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
244 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
246 SALOME::ExceptionStruct es;
247 es.type = SALOME::BAD_PARAM;
248 es.text = "This boundary is used in a case and cannot be deleted.";
249 throw SALOME::SALOME_Exception(es);
255 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
256 myContextMap[GetCurrentStudyID()]._mesBoundarys.erase(BoundaryName);
257 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(BoundaryName, ComponentDataType());
258 SALOMEDS::SObject_var aSO =listSO[0];
259 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
260 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
264 //=============================================================================
265 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option)
267 // Pour detruire un cas
268 MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option );
269 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
270 if (CORBA::is_nil(myCase))
272 SALOME::ExceptionStruct es;
273 es.type = SALOME::BAD_PARAM;
274 es.text = "Invalid case context";
275 throw SALOME::SALOME_Exception(es);
278 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
279 CORBA::String_var nomIter = myCase->GetIter0Name();
280 CORBA::Long Option1 = 0 ;
281 if ( DeleteIterationOption(nomIter, Option1, Option) != 0 )
286 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
287 myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas);
288 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType());
289 SALOMEDS::SObject_var aSO =listSO[0];
290 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
291 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
295 //=============================================================================
296 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
298 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
299 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
300 if (CORBA::is_nil(myHypo))
302 SALOME::ExceptionStruct es;
303 es.type = SALOME::BAD_PARAM;
304 es.text = "Invalid hypothesis";
305 throw SALOME::SALOME_Exception(es);
309 // On verifie que l'hypothese n'est plus utilisee
310 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
311 int numberOfIter = maListeIter->length();
312 if ( numberOfIter > 0 )
314 SALOME::ExceptionStruct es;
315 es.type = SALOME::BAD_PARAM;
316 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
317 throw SALOME::SALOME_Exception(es);
321 // suppression du lien avec les zones eventuelles
322 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
323 int numberOfZones = maListe->length();
324 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
325 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
327 std::string ZoneName = std::string((*maListe)[NumeZone]);
328 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
329 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
333 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
334 myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo);
335 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType());
336 SALOMEDS::SObject_var aSO =listSO[0];
337 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
338 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
342 //=============================================================================
343 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
345 // Option = 0 : On ne supprime pas le fichier du maillage associe
346 // Option = 1 : On supprime le fichier du maillage associe
347 // Pour detruire une iteration courante
348 MESSAGE ( "DeleteIteration : nomIter = " << nomIter << ", avec option = " << Option );
349 CORBA::Long Option1 = 1 ;
350 return DeleteIterationOption(nomIter, Option1, Option);
352 //=============================================================================
353 CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long Option1, CORBA::Long Option2)
355 // Option1 = 0 : On autorise la destruction de l'iteration 0
356 // Option1 = 1 : On interdit la destruction de l'iteration 0
358 // Option2 = 0 : On ne supprime pas le fichier du maillage associe
359 // Option2 = 1 : On supprime le fichier du maillage associe
360 MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 );
361 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
362 if (CORBA::is_nil(myIteration))
364 SALOME::ExceptionStruct es;
365 es.type = SALOME::BAD_PARAM;
366 es.text = "Invalid iteration";
367 throw SALOME::SALOME_Exception(es);
371 int numero = myIteration->GetNumber();
372 MESSAGE ( "DeleteIterationOption : numero = " << numero );
373 if ( numero == 0 and Option1 == 1 )
375 SALOME::ExceptionStruct es;
376 es.type = SALOME::BAD_PARAM;
377 es.text = "This iteration cannot be deleted.";
378 throw SALOME::SALOME_Exception(es);
382 // On detruit recursivement toutes les filles
383 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
384 int numberOfIter = maListe->length();
385 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
387 std::string nomIterFille = std::string((*maListe)[NumeIter]);
388 MESSAGE ( ".. appel recursif de DeleteIterationOption pour nomIter = " << nomIterFille.c_str() );
389 DeleteIterationOption(nomIterFille.c_str(), Option1, Option2);
392 // On arrive ici pour une iteration sans fille
393 MESSAGE ( "Destruction effective de " << nomIter );
394 // On commence par invalider l'iteration pour faire le menage des dependances
395 // et eventuellement du maillage associe
397 if ( numero == 0 ) { option = 0 ; }
398 else { option = Option2 ; }
399 InvalideIterOption(nomIter, option) ;
401 // Retrait dans la descendance de l'iteration parent
404 std::string nomIterationParent = myIteration->GetIterParentName();
405 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
406 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
407 if (CORBA::is_nil(myIterationParent))
409 SALOME::ExceptionStruct es;
410 es.type = SALOME::BAD_PARAM;
411 es.text = "Invalid iteration";
412 throw SALOME::SALOME_Exception(es);
415 myIterationParent->UnLinkNextIteration(nomIter);
418 // suppression du lien avec l'hypothese
421 std::string nomHypo = myIteration->GetHypoName();
422 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
423 ASSERT(!CORBA::is_nil(myHypo));
424 myHypo->UnLinkIteration(nomIter);
427 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
428 myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter);
429 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType());
430 SALOMEDS::SObject_var aSO =listSO[0];
431 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
432 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
433 // on peut aussi faire RemoveObject
434 // MESSAGE ( "Au final" );
435 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
436 // numberOfIter = Liste->length();
437 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
439 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
440 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
445 //=============================================================================
446 CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option)
448 // Option = 0 : On ne supprime pas le fichier du schema associe
449 // Option = 1 : On supprime le fichier du schema associe
450 // Pour detruire une iteration courante
451 MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option );
452 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
453 if (CORBA::is_nil(myYACS))
455 SALOME::ExceptionStruct es;
456 es.type = SALOME::BAD_PARAM;
457 es.text = "Invalid schema YACS";
458 throw SALOME::SALOME_Exception(es);
461 ASSERT("Programmer le menage du fichier"!=0);
462 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
463 myContextMap[GetCurrentStudyID()]._mesYACSs.erase(nomYACS);
464 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomYACS, ComponentDataType());
465 SALOMEDS::SObject_var aSO =listSO[0];
466 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
467 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
471 //=============================================================================
472 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
474 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
475 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone];
476 if (CORBA::is_nil(myZone))
478 SALOME::ExceptionStruct es;
479 es.type = SALOME::BAD_PARAM;
480 es.text = "Invalid zone";
481 throw SALOME::SALOME_Exception(es);
485 // On verifie que la zone n'est plus utilisee
486 HOMARD::listeHypo* maListe = myZone->GetHypo();
487 int numberOfHypo = maListe->length();
488 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
489 if ( numberOfHypo > 0 )
491 SALOME::ExceptionStruct es;
492 es.type = SALOME::BAD_PARAM;
493 es.text = "This zone is used in an hypothesis and cannot be deleted.";
494 throw SALOME::SALOME_Exception(es);
498 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
499 myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone);
500 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType());
501 SALOMEDS::SObject_var aSO =listSO[0];
502 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
503 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
507 //=============================================================================
508 //=============================================================================
510 //=============================================================================
511 //=============================================================================
512 // Invalidation des structures identifiees par leurs noms
513 //=============================================================================
514 //=============================================================================
515 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
517 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
518 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
519 if (CORBA::is_nil(myBoundary))
521 SALOME::ExceptionStruct es;
522 es.type = SALOME::BAD_PARAM;
523 es.text = "Invalid boundary";
524 throw SALOME::SALOME_Exception(es);
529 SALOME::ExceptionStruct es;
530 es.type = SALOME::BAD_PARAM;
531 es.text = "No change is allowed in a boundary. Ask for evolution.";
532 throw SALOME::SALOME_Exception(es);
536 //=============================================================================
537 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
539 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
540 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
541 if (CORBA::is_nil(myHypo))
543 SALOME::ExceptionStruct es;
544 es.type = SALOME::BAD_PARAM;
545 es.text = "Invalid hypothesis";
546 throw SALOME::SALOME_Exception(es);
550 HOMARD::listeIters* maListe = myHypo->GetIterations();
551 int numberOfIter = maListe->length();
552 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
554 std::string nomIter = std::string((*maListe)[NumeIter]);
555 MESSAGE( ".. nomIter = " << nomIter );
556 InvalideIter(nomIter.c_str());
559 //=============================================================================
560 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
562 MESSAGE("InvalideIter : nomIter = " << nomIter);
563 // Pour invalider totalement une iteration courante
564 CORBA::Long Option = 1 ;
565 return InvalideIterOption(nomIter, Option);
567 //=============================================================================
568 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
570 // Option = 0 : On ne supprime pas le fichier du maillage associe
571 // Option = 1 : On supprime le fichier du maillage associe
572 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
573 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
574 if (CORBA::is_nil(myIteration))
576 SALOME::ExceptionStruct es;
577 es.type = SALOME::BAD_PARAM;
578 es.text = "Invalid iteration";
579 throw SALOME::SALOME_Exception(es);
583 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
584 int numberOfIter = maListe->length();
585 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
587 std::string nomIterFille = std::string((*maListe)[NumeIter]);
588 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
589 InvalideIter(nomIterFille.c_str());
592 // On arrive ici pour une iteration sans fille
593 MESSAGE ( "Invalidation effective de " << nomIter );
594 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
595 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
596 for (; aIter->More(); aIter->Next())
598 SALOMEDS::SObject_var so = aIter->Value();
599 SALOMEDS::GenericAttribute_var anAttr;
600 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
601 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
602 std::string value (aCommentAttr->Value());
603 if(value == std::string("HypoHomard")) continue;
604 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
605 aStudyBuilder->RemoveObject(so);
608 int etat = myIteration->GetState();
611 SetEtatIter(nomIter,1);
612 const char * nomCas = myIteration->GetCaseName();
613 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
614 if (CORBA::is_nil(myCase))
616 SALOME::ExceptionStruct es;
617 es.type = SALOME::BAD_PARAM;
618 es.text = "Invalid case context";
619 throw SALOME::SALOME_Exception(es);
622 std::string nomDir = myIteration->GetDirName();
623 std::string nomFichier = myIteration->GetMeshFile();
624 std::string commande= "rm -rf " + std::string(nomDir);
625 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
626 MESSAGE ( "commande = " << commande );
627 if ((system(commande.c_str())) != 0)
629 SALOME::ExceptionStruct es;
630 es.type = SALOME::BAD_PARAM;
631 es.text = "The directory for the calculation cannot be cleared." ;
632 throw SALOME::SALOME_Exception(es);
635 // Suppression du maillage publie dans SMESH
636 std::string MeshName = myIteration->GetMeshName() ;
637 DeleteResultInSmesh(nomFichier, MeshName) ;
641 //=============================================================================
642 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
644 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
645 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
646 if (CORBA::is_nil(myIteration))
648 SALOME::ExceptionStruct es;
649 es.type = SALOME::BAD_PARAM;
650 es.text = "Invalid iteration";
651 throw SALOME::SALOME_Exception(es);
655 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
656 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
657 for (; aIter->More(); aIter->Next())
659 SALOMEDS::SObject_var so = aIter->Value();
660 SALOMEDS::GenericAttribute_var anAttr;
661 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
662 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
663 std::string value (aCommentAttr->Value());
664 /* MESSAGE("... value = " << value);*/
665 if( (value == std::string("logInfo")) or ( value == std::string("SummaryInfo")) )
667 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
668 aStudyBuilder->RemoveObject(so);
672 const char * nomCas = myIteration->GetCaseName();
673 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
674 if (CORBA::is_nil(myCase))
676 SALOME::ExceptionStruct es;
677 es.type = SALOME::BAD_PARAM;
678 es.text = "Invalid case context";
679 throw SALOME::SALOME_Exception(es);
682 const char* nomDir = myIteration->GetDirName();
683 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
684 commande += std::string(nomDir) + "/Liste.*info" ;
685 /* MESSAGE ( "commande = " << commande );*/
686 if ((system(commande.c_str())) != 0)
688 SALOME::ExceptionStruct es;
689 es.type = SALOME::BAD_PARAM;
690 es.text = "The directory for the calculation cannot be cleared." ;
691 throw SALOME::SALOME_Exception(es);
695 //=============================================================================
696 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
698 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
699 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
700 if (CORBA::is_nil(myZone))
702 SALOME::ExceptionStruct es;
703 es.type = SALOME::BAD_PARAM;
704 es.text = "Invalid zone";
705 throw SALOME::SALOME_Exception(es);
708 HOMARD::listeHypo* maListe = myZone->GetHypo();
709 int numberOfHypo = maListe->length();
710 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
711 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
713 std::string nomHypo = std::string((*maListe)[NumeHypo]);
714 MESSAGE( ".. nomHypo = " << nomHypo );
715 InvalideHypo(nomHypo.c_str());
718 //=============================================================================
719 //=============================================================================
721 //=============================================================================
722 //=============================================================================
723 // Association de lien entre des structures identifiees par leurs noms
724 //=============================================================================
725 //=============================================================================
726 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
728 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
730 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
731 if (CORBA::is_nil(myCase))
733 SALOME::ExceptionStruct es;
734 es.type = SALOME::BAD_PARAM;
735 es.text = "Invalid case";
736 throw SALOME::SALOME_Exception(es);
740 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
741 if (CORBA::is_nil(myIteration))
743 SALOME::ExceptionStruct es;
744 es.type = SALOME::BAD_PARAM;
745 es.text = "Invalid iteration";
746 throw SALOME::SALOME_Exception(es);
750 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
751 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
752 if (CORBA::is_nil(aCasSO))
754 SALOME::ExceptionStruct es;
755 es.type = SALOME::BAD_PARAM;
756 es.text = "Invalid case";
757 throw SALOME::SALOME_Exception(es);
761 aStudyBuilder->NewCommand();
762 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
763 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
764 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
765 aStudyBuilder->CommitCommand();
767 myCase->AddIteration(nomIter);
768 myIteration->SetCaseName(nomCas);
770 //=====================================================================================
771 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
773 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
775 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
776 ASSERT(!CORBA::is_nil(myHypo));
777 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
778 ASSERT(!CORBA::is_nil(aHypoSO));
780 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
781 ASSERT(!CORBA::is_nil(myZone));
782 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
783 ASSERT(!CORBA::is_nil(aZoneSO));
785 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
787 aStudyBuilder->NewCommand();
789 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
790 aStudyBuilder->Addreference(aSubSO, aZoneSO);
792 aStudyBuilder->CommitCommand();
794 myZone->AddHypo(nomHypothesis);
795 myHypo->AddZone0(ZoneName, TypeUse);
797 //=============================================================================
798 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
800 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
802 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
803 ASSERT(!CORBA::is_nil(myHypo));
804 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
805 ASSERT(!CORBA::is_nil(aHypoSO));
807 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
808 ASSERT(!CORBA::is_nil(myIteration));
809 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
810 ASSERT(!CORBA::is_nil(aIterSO));
812 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
814 aStudyBuilder->NewCommand();
816 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
817 aStudyBuilder->Addreference(aSubSO, aHypoSO);
819 aStudyBuilder->CommitCommand();
821 myIteration->SetHypoName(nomHypo);
822 myHypo->LinkIteration(nomIter);
824 //=============================================================================
825 //=============================================================================
827 //=============================================================================
828 //=============================================================================
829 // Dissociation de lien entre des structures identifiees par leurs noms
830 //=============================================================================
831 //=============================================================================
832 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
834 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
836 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
837 ASSERT(!CORBA::is_nil(myHypo));
838 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
839 ASSERT(!CORBA::is_nil(aHypoSO));
841 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
842 ASSERT(!CORBA::is_nil(myZone));
843 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
844 ASSERT(!CORBA::is_nil(aZoneSO));
846 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
848 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
849 for (; it->More(); it->Next())
851 SALOMEDS::SObject_var aHypObj = it->Value();
852 SALOMEDS::SObject_var ptrObj;
853 if (aHypObj->ReferencedObject(ptrObj))
855 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
857 aStudyBuilder->NewCommand();
858 aStudyBuilder->RemoveObject(aHypObj);
859 aStudyBuilder->CommitCommand();
865 myZone->SupprHypo(nomHypothesis);
866 myHypo->SupprZone(ZoneName);
868 //=============================================================================
869 //=============================================================================
872 //=============================================================================
873 //=============================================================================
874 // Recuperation des listes
875 //=============================================================================
876 //=============================================================================
877 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
879 MESSAGE("GetAllBoundarysName");
882 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
883 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
884 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
886 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
887 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
889 ret[i++] = CORBA::string_dup((*it).first.c_str());
894 //=============================================================================
895 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
897 MESSAGE("GetAllCasesName");
900 HOMARD::listeCases_var ret = new HOMARD::listeCases;
901 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
902 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
904 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
905 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
907 ret[i++] = CORBA::string_dup((*it).first.c_str());
912 //=============================================================================
913 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
915 MESSAGE("GetAllHypothesesName");
918 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
919 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
920 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
922 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
923 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
925 ret[i++] = CORBA::string_dup((*it).first.c_str());
930 //=============================================================================
931 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
933 MESSAGE("GetAllIterationsName");
936 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
937 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
938 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
940 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
941 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
943 ret[i++] = CORBA::string_dup((*it).first.c_str());
948 //=============================================================================
949 HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName()
951 MESSAGE("GetAllYACSsName");
954 HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs;
955 ret->length(myContextMap[GetCurrentStudyID()]._mesYACSs.size());
956 std::map<std::string, HOMARD::HOMARD_YACS_var>::const_iterator it;
958 for (it = myContextMap[GetCurrentStudyID()]._mesYACSs.begin();
959 it != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); it++)
961 ret[i++] = CORBA::string_dup((*it).first.c_str());
966 //=============================================================================
967 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
969 MESSAGE("GetAllZonesName");
972 HOMARD::listeZones_var ret = new HOMARD::listeZones;
973 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
974 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
976 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
977 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
979 ret[i++] = CORBA::string_dup((*it).first.c_str());
984 //=============================================================================
985 //=============================================================================
987 //=============================================================================
988 //=============================================================================
989 // Recuperation des structures identifiees par leurs noms
990 //=============================================================================
991 //=============================================================================
992 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
994 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
995 ASSERT(!CORBA::is_nil(myBoundary));
996 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
998 //=============================================================================
999 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
1001 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1002 ASSERT(!CORBA::is_nil(myCase));
1003 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1005 //=============================================================================
1006 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
1008 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
1009 ASSERT(!CORBA::is_nil(myHypothesis));
1010 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1012 //=============================================================================
1013 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
1015 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
1016 ASSERT(!CORBA::is_nil(myIteration));
1017 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1019 //=============================================================================
1020 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* YACSName)
1022 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[YACSName];
1023 ASSERT(!CORBA::is_nil(myYACS));
1024 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
1026 //=============================================================================
1027 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
1029 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
1030 ASSERT(!CORBA::is_nil(myZone));
1031 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1033 //=============================================================================
1034 //=============================================================================
1036 //=============================================================================
1037 //=============================================================================
1039 //=============================================================================
1040 //=============================================================================
1041 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)
1043 INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1044 INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
1048 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, 1) ;
1049 myCase->SetDirName(DirName) ;
1051 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1055 //=============================================================================
1056 //=============================================================================
1058 //=============================================================================
1059 //=============================================================================
1060 // Recuperation des structures par le contexte
1061 //=============================================================================
1062 //=============================================================================
1063 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1065 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1066 ASSERT(!CORBA::is_nil(myCase));
1068 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1069 ASSERT(!CORBA::is_nil(myIteration));
1071 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1073 //=============================================================================
1074 //=============================================================================
1076 //=============================================================================
1077 //=============================================================================
1078 // Nouvelles structures
1079 //=============================================================================
1080 //=============================================================================
1081 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1083 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1084 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1085 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1086 return aCase._retn();
1088 //=============================================================================
1089 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1091 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1092 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1093 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1094 return aHypo._retn();
1096 //=============================================================================
1097 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1099 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1100 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1101 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1102 return aIter._retn();
1104 //=============================================================================
1105 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1107 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1108 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1109 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1110 return aBoundary._retn();
1112 //=============================================================================
1113 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1115 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1116 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1117 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1118 return aZone._retn();
1120 //=============================================================================
1121 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS()
1123 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1124 HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine);
1125 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this());
1126 return aYACS._retn();
1128 //=============================================================================
1129 //=============================================================================
1131 //=============================================================================
1132 //=============================================================================
1133 // Creation des structures identifiees par leurs noms
1134 //=============================================================================
1135 //=============================================================================
1136 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1138 // Creation d'un cas initial
1139 // nomCas : nom du cas a creer
1140 // MeshName, MeshFile : nom et fichier du maillage correspondant
1143 INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1145 // Par defaut, on ne publie pas le maillage
1146 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, 1) ;
1148 // Valeurs par defaut des filtrages
1149 myCase->SetPyram(0);
1151 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1153 //=============================================================================
1154 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1156 // nomCas : nom du cas a creer
1157 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1160 INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1161 std::string nomDirWork = getenv("PWD") ;
1164 // A. Decodage du point de reprise
1165 // A.1. Controle du repertoire de depart de l'iteration
1166 codret = chdir(DirNameStart) ;
1169 SALOME::ExceptionStruct es;
1170 es.type = SALOME::BAD_PARAM;
1171 es.text = "The directory of the iteration does not exist.";
1172 throw SALOME::SALOME_Exception(es);
1175 // A.2. Reperage des fichiers du repertoire de reprise
1176 std::string file_configuration = "" ;
1177 std::string file_maillage_homard = "" ;
1180 struct dirent *dirp;
1181 dp = opendir(DirNameStart);
1182 while ( (dirp = readdir(dp)) != NULL )
1184 std::string file_name(dirp->d_name);
1185 // MESSAGE ( file_name );
1186 bilan = file_name.find("HOMARD.Configuration.") ;
1187 if ( bilan != string::npos ) { file_configuration = file_name ; }
1188 bilan = file_name.find("maill.") ;
1189 if ( bilan != string::npos )
1191 bilan = file_name.find(".hom.med") ;
1192 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1196 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1197 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1199 if ( ( file_configuration == "" ) or ( file_maillage_homard == "" ) )
1201 SALOME::ExceptionStruct es;
1202 es.type = SALOME::BAD_PARAM;
1204 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1205 else { text = "The HOMARD mesh file cannot be found." ; }
1206 es.text = CORBA::string_dup(text.c_str());
1207 throw SALOME::SALOME_Exception(es);
1210 // B. Lecture du fichier de configuration
1211 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1217 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1218 std::ifstream fichier( file_configuration.c_str() );
1219 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1221 std::string ligne; // variable contenant chaque ligne lue
1222 std::string mot_cle;
1223 std::string argument;
1225 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1226 while ( std::getline( fichier, ligne ) )
1228 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1229 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1230 ligne_bis >> mot_cle ;
1231 // B.2. Des valeurs entieres : le second bloc de la ligne
1232 if ( mot_cle == "NumeIter" )
1234 ligne_bis >> NumeIter ;
1237 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1238 else if ( ( mot_cle == "TypeConf" ) or ( mot_cle == "TypeElem" ) )
1240 ligne_bis >> argument ;
1242 if ( mot_cle == "TypeConf" )
1244 if ( argument == "conforme" ) { TypeConf = 1 ; }
1245 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1246 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1247 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1249 else if ( mot_cle == "TypeElem" )
1251 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1252 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1255 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1256 // il faut les supprimer
1257 else if ( ( mot_cle == "CCNoMNP1" ) or ( mot_cle == "CCMaiNP1" ) )
1259 ligne_bis >> argument ;
1260 if ( argument[0] == '"' ) { decalage = 1 ; }
1261 else { decalage = 0 ; }
1262 size_t size = argument.size() + 1 - 2*decalage ;
1264 if ( mot_cle == "CCNoMNP1" )
1266 MeshName = new char[ size ];
1267 strncpy( MeshName, argument.c_str()+decalage, size );
1268 MeshName[size-1] = '\0' ;
1270 else if ( mot_cle == "CCMaiNP1" )
1272 MeshFile = new char[ size ];
1273 strncpy( MeshFile, argument.c_str()+decalage, size );
1274 MeshFile[size-1] = '\0' ;
1278 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1279 MESSAGE ( "==> MeshName : " << MeshName ) ;
1280 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1281 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1282 MESSAGE ( "==> Pyram : " << Pyram ) ;
1286 SALOME::ExceptionStruct es;
1287 es.type = SALOME::BAD_PARAM;
1288 std::string text = "The configuration file cannot be read." ;
1289 es.text = CORBA::string_dup(text.c_str());
1290 throw SALOME::SALOME_Exception(es);
1293 // C. Creation effective du cas
1295 // Par defaut, on ne publie pas le maillage
1296 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, 1) ;
1298 // D. Parametrages lus dans le fichier de configuration
1300 myCase->SetConfType (TypeConf) ;
1301 myCase->SetPyram (Pyram) ;
1303 // E. Copie du fichier de maillage homard
1304 // E.1. Repertoire associe au cas
1305 char* nomDirCase = myCase->GetDirName() ;
1306 // E.2. Repertoire associe a l'iteration de ce cas
1308 IterName = myCase->GetIter0Name() ;
1309 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1310 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1311 Iter->SetDirNameLoc(nomDirIter);
1312 std::string nomDirIterTotal ;
1313 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1314 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1316 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1317 SALOME::ExceptionStruct es;
1318 es.type = SALOME::BAD_PARAM;
1319 std::string text = "The directory for the computation cannot be created." ;
1320 es.text = CORBA::string_dup(text.c_str());
1321 throw SALOME::SALOME_Exception(es);
1323 // E.3. Copie du maillage HOMARD au format MED
1324 codret = chdir(DirNameStart) ;
1325 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1326 MESSAGE ( "commande : " << commande ) ;
1327 codret = system(commande.c_str()) ;
1328 MESSAGE ( "codret : " << codret ) ;
1331 SALOME::ExceptionStruct es;
1332 es.type = SALOME::BAD_PARAM;
1333 es.text = "The starting point for the case cannot be copied into the working directory.";
1334 throw SALOME::SALOME_Exception(es);
1343 chdir(nomDirWork.c_str());
1345 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1347 //=============================================================================
1348 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1350 // nomCas : nom du cas a creer
1351 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1354 INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1356 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1358 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1359 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1361 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1363 //=============================================================================
1364 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1366 // nomCas : nom du cas a creer
1367 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1368 // Number : numero de l'iteration de depart
1371 INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1374 SALOME::ExceptionStruct es;
1375 es.type = SALOME::BAD_PARAM;
1376 es.text = "The number of iteration must be positive.";
1377 throw SALOME::SALOME_Exception(es);
1381 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1383 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1384 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1386 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1388 //=============================================================================
1389 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1391 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1392 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1393 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1396 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1397 std::string nomDirWork = getenv("PWD") ;
1398 std::string DirNameStartIter ;
1400 int NumeIterMax = -1 ;
1402 // A.1. Controle du repertoire de depart du cas
1403 codret = chdir(DirNameStart) ;
1406 SALOME::ExceptionStruct es;
1407 es.type = SALOME::BAD_PARAM;
1408 es.text = "The directory of the case for the pursuit does not exist.";
1409 throw SALOME::SALOME_Exception(es);
1412 // A.2. Reperage des sous-repertoire du repertoire de reprise
1413 bool existe = false ;
1415 struct dirent *dirp;
1416 dp = opendir(DirNameStart);
1417 while ( (dirp = readdir(dp)) != NULL )
1419 std::string DirName_1(dirp->d_name);
1420 if ( ( DirName_1 != "." ) and ( DirName_1 != ".." ) )
1422 if ( chdir(DirName_1.c_str()) == 0 )
1424 // On cherche le fichier de configuration dans ce sous-repertoire
1425 codret = chdir(DirNameStart) ;
1427 struct dirent *dirp_1;
1428 dp_1 = opendir(DirName_1.c_str()) ;
1429 while ( (dirp_1 = readdir(dp_1)) != NULL )
1431 std::string file_name_1(dirp_1->d_name);
1432 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1433 if ( bilan != string::npos )
1435 // Decodage du fichier pour trouver le numero d'iteration
1436 chdir(DirName_1.c_str()) ;
1437 std::ifstream fichier( file_name_1.c_str() );
1438 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1441 std::string ligne; // variable contenant chaque ligne lue
1442 std::string mot_cle;
1443 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1444 while ( std::getline( fichier, ligne ) )
1446 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1447 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1448 ligne_bis >> mot_cle ;
1449 if ( mot_cle == "NumeIter" )
1451 ligne_bis >> NumeIter ;
1453 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1454 if ( Number == - 1 )
1456 if ( NumeIter >= NumeIterMax )
1458 NumeIterMax = NumeIter ;
1459 DirNameStartIter = DirName_1 ;
1464 if ( NumeIter == Number )
1466 DirNameStartIter = DirName_1 ;
1476 SALOME::ExceptionStruct es;
1477 es.type = SALOME::BAD_PARAM;
1478 std::string text = "The configuration file cannot be read." ;
1479 es.text = CORBA::string_dup(text.c_str());
1480 throw SALOME::SALOME_Exception(es);
1482 chdir(DirNameStart) ;
1484 if ( existe ) { break ; }
1487 if ( existe ) { break ; }
1493 chdir(nomDirWork.c_str());
1495 if ( ( Number >= 0 and ( not existe ) ) or ( Number < 0 and ( NumeIterMax == -1 ) ) )
1497 SALOME::ExceptionStruct es;
1498 es.type = SALOME::BAD_PARAM;
1499 es.text = "The directory of the iteration does not exist.";
1500 throw SALOME::SALOME_Exception(es);
1504 return DirNameStartIter ;
1506 //=============================================================================
1507 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)
1509 // nomCas : nom du cas a creer
1510 // MeshName, MeshFile : nom et fichier du maillage correspondant
1511 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1512 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1513 // -1 : le maillage n'est pas fourni
1514 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1515 // Option : multiple de nombres premiers
1516 // 1 : aucune option
1517 // x2 : publication du maillage dans SMESH
1519 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1520 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1521 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1527 // A.2. Controle du nom :
1528 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1530 SALOME::ExceptionStruct es;
1531 es.type = SALOME::BAD_PARAM;
1532 es.text = "This case has already been defined.";
1533 throw SALOME::SALOME_Exception(es);
1537 // A.3. Controle du fichier du maillage
1538 int existeMeshFile ;
1539 if ( MeshOption >= 0 )
1541 existeMeshFile = MEDFileExist ( MeshFile ) ;
1542 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1543 if ( ( existeMeshFile == 0 ) and ( MeshOption == 0 ) )
1545 SALOME::ExceptionStruct es;
1546 es.type = SALOME::BAD_PARAM;
1547 es.text = "The mesh file does not exist.";
1548 throw SALOME::SALOME_Exception(es);
1552 else { existeMeshFile = 0 ; }
1554 // B. Creation de l'objet cas et publication
1555 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1556 HOMARD::HOMARD_Cas_var myCase = newCase();
1557 myCase->SetName(nomCas);
1558 SALOMEDS::SObject_var aSO;
1559 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1560 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1562 // C. Caracteristiques du maillage
1563 if ( existeMeshFile != 0 )
1565 // Les valeurs extremes des coordonnees
1566 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1567 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1568 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1569 if (LesExtremes.size()!=10) { return false; }
1571 for (int i =0 ; i< LesExtremes.size() ; i++)
1572 aSeq[i]=LesExtremes[i] ;
1573 myCase->SetBoundingBox(aSeq) ;
1575 // MESSAGE ( "CreateCase0 : Les groupes" );
1576 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1577 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1578 aSeqGroupe->length(LesGroupes.size());
1579 std::set<std::string>::const_iterator it ;
1581 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1582 aSeqGroupe[i++]=(*it).c_str() ;
1583 myCase->SetGroups(aSeqGroupe) ;
1586 // D. L'iteration initiale du cas
1587 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1588 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1589 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1591 std::string NomIteration = std::string(MeshName) ;
1592 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1594 std::ostringstream nom;
1595 nom << MeshName << monNum;
1596 NomIteration = nom.str();
1599 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1601 // D.2. Creation de l'iteration
1602 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1603 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1604 anIter->SetName(NomIteration.c_str());
1605 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1607 // D.4. Maillage correspondant
1608 if ( existeMeshFile != 0 )
1610 anIter->SetMeshFile(MeshFile);
1611 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1613 anIter->SetMeshName(MeshName);
1615 // D.5. Numero d'iteration
1616 anIter->SetNumber(NumeIter);
1619 SetEtatIter(NomIteration.c_str(), -NumeIter);
1622 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1624 //=============================================================================
1625 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1627 INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1630 // A. Controle du nom :
1631 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1633 SALOME::ExceptionStruct es;
1634 es.type = SALOME::BAD_PARAM;
1635 es.text = "This hypothesis has already been defined.";
1636 throw SALOME::SALOME_Exception(es);
1640 // B. Creation de l'objet
1641 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1642 if (CORBA::is_nil(myHypothesis))
1644 SALOME::ExceptionStruct es;
1645 es.type = SALOME::BAD_PARAM;
1646 es.text = "Unable to create the hypothesis";
1647 throw SALOME::SALOME_Exception(es);
1650 myHypothesis->SetName(nomHypothesis);
1652 // C. Enregistrement
1653 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1655 SALOMEDS::SObject_var aSO;
1656 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1658 // D. Valeurs par defaut des options avancees
1659 myHypothesis->SetNivMax(-1);
1660 myHypothesis->SetDiamMin(-1.0);
1661 myHypothesis->SetAdapInit(0);
1662 myHypothesis->SetLevelOutput(0);
1664 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1667 //=============================================================================
1668 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1669 //=============================================================================
1671 INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1674 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1675 if (CORBA::is_nil(myIterationParent))
1677 SALOME::ExceptionStruct es;
1678 es.type = SALOME::BAD_PARAM;
1679 es.text = "The parent iteration is not defined.";
1680 throw SALOME::SALOME_Exception(es);
1684 const char* nomCas = myIterationParent->GetCaseName();
1685 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1686 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1687 if (CORBA::is_nil(myCase))
1689 SALOME::ExceptionStruct es;
1690 es.type = SALOME::BAD_PARAM;
1691 es.text = "Invalid case context";
1692 throw SALOME::SALOME_Exception(es);
1695 const char* nomDirCase = myCase->GetDirName();
1697 // Controle du nom :
1698 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1700 SALOME::ExceptionStruct es;
1701 es.type = SALOME::BAD_PARAM;
1702 es.text = "This iteration has already been defined.";
1703 throw SALOME::SALOME_Exception(es);
1707 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1708 if (CORBA::is_nil(myIteration))
1710 SALOME::ExceptionStruct es;
1711 es.type = SALOME::BAD_PARAM;
1712 es.text = "Unable to create the iteration";
1713 throw SALOME::SALOME_Exception(es);
1716 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1717 // Nom de l'iteration et du maillage
1718 myIteration->SetName(NomIteration);
1719 myIteration->SetMeshName(NomIteration);
1720 myIteration->SetState(1);
1722 int numero = myIterationParent->GetNumber() + 1;
1723 myIteration->SetNumber(numero);
1725 // Nombre d'iterations deja connues pour le cas, permettant
1726 // la creation d'un sous-repertoire unique
1727 int nbitercase = myCase->GetNumberofIter();
1728 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1729 myIteration->SetDirNameLoc(nomDirIter);
1731 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1732 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1733 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1734 // situation la plus frequente.
1735 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1736 // le nombre d'iterations du cas permet d'eviter les collisions.
1738 if ( nbitercase < 100 ) { jaux = 2 ; }
1739 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1740 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1741 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1743 std::ostringstream iaux ;
1744 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1745 std::stringstream MeshFile;
1746 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1747 myIteration->SetMeshFile(MeshFile.str().c_str());
1749 // Association avec le cas
1750 std::string label = "IterationHomard_" + std::string(nomIterParent);
1751 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1752 // Lien avec l'iteration precedente
1753 myIterationParent->LinkNextIteration(NomIteration);
1754 myIteration->SetIterParentName(nomIterParent);
1756 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1758 //=============================================================================
1759 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1761 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1764 // Controle du nom :
1765 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1767 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1768 SALOME::ExceptionStruct es;
1769 es.type = SALOME::BAD_PARAM;
1770 es.text = "This boundary has already been defined";
1771 throw SALOME::SALOME_Exception(es);
1775 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1776 myBoundary->SetName(BoundaryName);
1777 myBoundary->SetType(BoundaryType);
1779 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1781 SALOMEDS::SObject_var aSO;
1782 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1784 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1786 //=============================================================================
1787 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1789 INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1790 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1791 myBoundary->SetMeshFile( MeshFile ) ;
1792 myBoundary->SetMeshName( MeshName ) ;
1794 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1796 //=============================================================================
1797 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1798 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1799 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1800 CORBA::Double Rayon)
1802 INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1804 SALOME::ExceptionStruct es;
1807 { es.text = "The radius must be positive." ;
1809 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1810 if ( daux < 0.0000001 )
1811 { es.text = "The axis must be a non 0 vector." ;
1815 es.type = SALOME::BAD_PARAM;
1816 throw SALOME::SALOME_Exception(es);
1820 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1821 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1823 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1825 //=============================================================================
1826 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1827 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1828 CORBA::Double Rayon)
1830 INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1832 SALOME::ExceptionStruct es;
1835 { es.text = "The radius must be positive." ;
1839 es.type = SALOME::BAD_PARAM;
1840 throw SALOME::SALOME_Exception(es);
1844 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1845 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1847 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1849 //=============================================================================
1850 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1851 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1852 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1854 INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1856 SALOME::ExceptionStruct es;
1858 if ( Angle <= 0.0 or Angle >= 90.0 )
1859 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1861 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1862 if ( daux < 0.0000001 )
1863 { es.text = "The axis must be a non 0 vector." ;
1867 es.type = SALOME::BAD_PARAM;
1868 throw SALOME::SALOME_Exception(es);
1872 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
1873 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
1875 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1877 //=============================================================================
1878 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
1879 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
1880 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
1882 INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
1884 SALOME::ExceptionStruct es;
1886 if ( Rayon1 < 0.0 or Rayon2 < 0.0 )
1887 { es.text = "The radius must be positive." ;
1889 double daux = fabs(Rayon2-Rayon1) ;
1890 if ( daux < 0.0000001 )
1891 { es.text = "The radius must be different." ;
1893 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
1894 if ( daux < 0.0000001 )
1895 { es.text = "The centers must be different." ;
1899 es.type = SALOME::BAD_PARAM;
1900 throw SALOME::SALOME_Exception(es);
1904 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
1905 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
1907 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1909 //=============================================================================
1910 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
1912 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
1915 // Controle du nom :
1916 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
1918 SALOME::ExceptionStruct es;
1919 es.type = SALOME::BAD_PARAM;
1920 es.text = "This zone has already been defined";
1921 throw SALOME::SALOME_Exception(es);
1925 HOMARD::HOMARD_Zone_var myZone = newZone();
1926 myZone->SetName(ZoneName);
1927 myZone->SetType(ZoneType);
1929 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
1931 SALOMEDS::SObject_var aSO;
1932 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
1934 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1936 //=============================================================================
1937 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
1938 CORBA::Double Xmini, CORBA::Double Xmaxi,
1939 CORBA::Double Ymini, CORBA::Double Ymaxi,
1940 CORBA::Double Zmini, CORBA::Double Zmaxi)
1942 INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ;
1944 SALOME::ExceptionStruct es;
1946 if ( Xmini > Xmaxi )
1947 { es.text = "The X coordinates are not coherent." ;
1949 if ( Ymini > Ymaxi )
1950 { es.text = "The Y coordinates are not coherent." ;
1952 if ( Zmini > Zmaxi )
1953 { es.text = "The Z coordinates are not coherent." ;
1957 es.type = SALOME::BAD_PARAM;
1958 throw SALOME::SALOME_Exception(es);
1962 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
1963 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
1965 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1967 //=============================================================================
1968 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
1969 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
1971 INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
1973 SALOME::ExceptionStruct es;
1976 { es.text = "The radius must be positive." ;
1980 es.type = SALOME::BAD_PARAM;
1981 throw SALOME::SALOME_Exception(es);
1985 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
1986 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1988 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1990 //=============================================================================
1991 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
1992 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1993 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1994 CORBA::Double Rayon, CORBA::Double Haut)
1996 INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
1998 SALOME::ExceptionStruct es;
2001 { es.text = "The radius must be positive." ;
2003 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2004 if ( daux < 0.0000001 )
2005 { es.text = "The axis must be a non 0 vector." ;
2008 { es.text = "The height must be positive." ;
2012 es.type = SALOME::BAD_PARAM;
2013 throw SALOME::SALOME_Exception(es);
2017 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
2018 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
2020 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2022 //=============================================================================
2023 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
2024 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
2025 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
2026 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
2028 INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ;
2030 SALOME::ExceptionStruct es;
2032 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
2033 { es.text = "The radius must be positive." ;
2035 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
2036 if ( daux < 0.0000001 )
2037 { es.text = "The axis must be a non 0 vector." ;
2040 { es.text = "The height must be positive." ;
2042 if ( Rayon <= Rayonint )
2043 { es.text = "The external radius must be higher than the internal radius." ;
2047 es.type = SALOME::BAD_PARAM;
2048 throw SALOME::SALOME_Exception(es);
2052 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
2053 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
2055 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2057 //=============================================================================
2058 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
2059 CORBA::Double Umini, CORBA::Double Umaxi,
2060 CORBA::Double Vmini, CORBA::Double Vmaxi,
2063 INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
2064 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
2065 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
2066 // MESSAGE ("Orient = " << Orient ) ;
2068 SALOME::ExceptionStruct es;
2070 if ( Umini > Umaxi )
2071 { es.text = "The first coordinates are not coherent." ;
2073 if ( Vmini > Vmaxi )
2074 { es.text = "The second coordinates are not coherent." ;
2076 if ( Orient < 1 or Orient > 3 )
2077 { es.text = "The orientation must be 1, 2 or 3." ;
2081 es.type = SALOME::BAD_PARAM;
2082 throw SALOME::SALOME_Exception(es);
2086 double Xmini, Xmaxi ;
2087 double Ymini, Ymaxi ;
2088 double Zmini, Zmaxi ;
2096 else if ( Orient == 2 )
2103 else if ( Orient == 3 )
2110 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2112 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2113 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2115 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2117 //=============================================================================
2118 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2119 CORBA::Double Ucentre, CORBA::Double Vcentre,
2120 CORBA::Double Rayon,
2123 INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2125 SALOME::ExceptionStruct es;
2128 { es.text = "The radius must be positive." ;
2130 if ( Orient < 1 or Orient > 3 )
2131 { es.text = "The orientation must be 1, 2 or 3." ;
2135 es.type = SALOME::BAD_PARAM;
2136 throw SALOME::SALOME_Exception(es);
2144 { Xcentre = Ucentre ;
2147 else if ( Orient == 2 )
2150 Zcentre = Vcentre ; }
2151 else if ( Orient == 3 )
2152 { Xcentre = Vcentre ;
2154 Zcentre = Ucentre ; }
2155 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2157 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2158 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2160 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2162 //=============================================================================
2163 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2164 CORBA::Double Ucentre, CORBA::Double Vcentre,
2165 CORBA::Double Rayon, CORBA::Double Rayonint,
2168 INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2170 SALOME::ExceptionStruct es;
2172 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
2173 { es.text = "The radius must be positive." ;
2175 if ( Orient < 1 or Orient > 3 )
2176 { es.text = "The orientation must be 1, 2 or 3." ;
2178 if ( Rayon <= Rayonint )
2179 { es.text = "The external radius must be higher than the internal radius." ;
2183 es.type = SALOME::BAD_PARAM;
2184 throw SALOME::SALOME_Exception(es);
2192 { Xcentre = Ucentre ;
2195 else if ( Orient == 2 )
2198 Zcentre = Vcentre ; }
2199 else if ( Orient == 3 )
2200 { Xcentre = Vcentre ;
2202 Zcentre = Ucentre ; }
2203 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2205 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2206 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2208 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2210 //=============================================================================
2211 //=============================================================================
2216 //=============================================================================
2217 //=============================================================================
2218 // Traitement d'une iteration
2219 // etatMenage = 1 : destruction du repertoire d'execution
2220 // modeHOMARD = 1 : adaptation
2221 // != 1 : information avec les options modeHOMARD
2222 // Option1 >0 : appel depuis python
2223 // <0 : appel depuis GUI
2224 // Option2 : multiple de nombres premiers
2225 // 1 : aucune option
2226 // x2 : publication du maillage dans SMESH
2227 //=============================================================================
2228 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2230 INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 );
2235 // A.1. L'objet iteration
2236 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2237 ASSERT(!CORBA::is_nil(myIteration));
2239 // A.2. Numero de l'iteration
2240 // siterp1 : numero de l'iteration a traiter
2242 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2243 // Ou si information :
2245 int NumeIter = myIteration->GetNumber();
2246 std::string siterp1 ;
2247 std::stringstream saux1 ;
2249 siterp1 = saux1.str() ;
2250 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2253 if ( modeHOMARD==1 )
2255 std::stringstream saux0 ;
2256 int iaux = max(0, NumeIter-1) ;
2258 siter = saux0.str() ;
2259 if (NumeIter < 11) { siter = "0" + siter ; }
2262 { siter = siterp1 ; }
2265 const char* nomCas = myIteration->GetCaseName();
2266 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2267 ASSERT(!CORBA::is_nil(myCase));
2269 // B. Les repertoires
2270 // B.1. Le repertoire courant
2271 std::string nomDirWork = getenv("PWD") ;
2272 // B.2. Le sous-repertoire de l'iteration a traiter
2273 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2274 MESSAGE( ". DirCompute = " << DirCompute );
2276 // C. Le fichier des messages
2277 // C.1. Le deroulement de l'execution de HOMARD
2278 std::string LogFile = DirCompute ;
2279 LogFile += "/Liste" ;
2280 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2282 MESSAGE (". LogFile = " << LogFile);
2283 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2284 // C.2. Le bilan de l'analyse du maillage
2285 std::string FileInfo = DirCompute ;
2287 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2289 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2290 else { FileInfo += "info_ap" ; }
2292 FileInfo += "." + siterp1 + ".bilan" ;
2293 myIteration->SetFileInfo(FileInfo.c_str());
2295 // D. On passe dans le repertoire de l'iteration a calculer
2296 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2299 // E. Les donnees de l'execution HOMARD
2300 // E.1. L'objet du texte du fichier de configuration
2301 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2302 std::string Langue = "Francais" ;
2303 myDriver->TexteInit(DirCompute, LogFile, Langue);
2305 // E.2. Le maillage associe a l'iteration
2306 const char* NomMesh = myIteration->GetMeshName();
2307 MESSAGE ( ". NomMesh = " << NomMesh );
2308 const char* MeshFile = myIteration->GetMeshFile();
2309 MESSAGE ( ". MeshFile = " << MeshFile );
2311 // E.3. Les donnees du traitement HOMARD
2313 if ( modeHOMARD == 1 )
2316 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2317 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2318 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2322 InvalideIterInfo(NomIteration);
2323 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2325 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2326 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2327 myDriver->CreeFichierDonn();
2330 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2331 DriverTexteBoundary(myCase, myDriver) ;
2333 // E.5. Ecriture du texte dans le fichier
2335 { myDriver->CreeFichier(); }
2339 int codretexec = 12 ;
2342 codretexec = myDriver->ExecuteHomard(Option1);
2344 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2345 if ( modeHOMARD == 1 )
2347 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2348 else { SetEtatIter(NomIteration,1); }
2349 // GERALD -- QMESSAGE BOX
2353 // H. Gestion des resultats
2356 std::string Commentaire ;
2357 // H.1. Le fichier des messages, dans tous les cas
2358 Commentaire = "log" ;
2359 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2360 else { Commentaire += "Info" ; }
2361 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2363 // H.2. Si tout s'est bien passe :
2364 if (codretexec == 0)
2366 // H.2.1. Le fichier de bilan
2367 Commentaire = "Summary" ;
2368 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2369 else { Commentaire += "Info" ; }
2370 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2371 // H.2.2. Le fichier de maillage obtenu
2372 if ( modeHOMARD == 1 )
2374 std::stringstream saux0 ;
2375 Commentaire = "Iteration" ;
2376 Commentaire += " " + siter ;
2377 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2378 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2381 // H.3 Message d'erreur en cas de probleme
2384 SALOME::ExceptionStruct es;
2385 es.type = SALOME::BAD_PARAM;
2386 std::string text = "Error during the adaptation.\n" ;
2389 ifstream fichier(LogFile.c_str(), ios::in);
2391 while(getline(fichier, ligne) and (ligne != "===== HOMARD ===== STOP ====="));
2392 while (getline(fichier, ligne)) { text += ligne+ "\n";};
2395 text += "no log file ....";
2397 es.text = CORBA::string_dup(text.c_str());
2398 throw SALOME::SALOME_Exception(es);
2402 // I. Menage et retour dans le repertoire du cas
2406 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2407 chdir(nomDirWork.c_str());
2412 //=============================================================================
2413 // Calcul d'une iteration : partie specifique a l'adaptation
2414 //=============================================================================
2415 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)
2417 MESSAGE ( "ComputeAdap" );
2422 // Etat de l'iteration
2423 int etat = myIteration->GetState();
2424 // Numero de l'iteration
2425 int NumeIter = myIteration->GetNumber();
2426 std::stringstream saux0 ;
2427 saux0 << NumeIter-1 ;
2428 std::string siter = saux0.str() ;
2429 if (NumeIter < 11) { siter = "0" + siter ; }
2431 // A.2. On ne calcule pas l iteration initiale
2434 MESSAGE ( "etat = "<<etat );
2435 SALOME::ExceptionStruct es;
2436 es.type = SALOME::BAD_PARAM;
2437 es.text = "This iteration is the first of the case and cannot be computed.";
2438 throw SALOME::SALOME_Exception(es);
2442 // A.3. On verifie qu il y a une hypothese (erreur improbable);
2443 const char* nomHypo = myIteration->GetHypoName();
2444 if (std::string(nomHypo) == std::string(""))
2446 SALOME::ExceptionStruct es;
2447 es.type = SALOME::BAD_PARAM;
2448 es.text = "This iteration does not have any associated hypothesis.";
2449 throw SALOME::SALOME_Exception(es);
2452 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2453 ASSERT(!CORBA::is_nil(myHypo));
2455 // B. L'iteration parent
2456 const char* nomIterationParent = myIteration->GetIterParentName();
2457 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2458 ASSERT(!CORBA::is_nil(myIterationParent));
2459 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2460 if ( myIterationParent->GetState() == 1 )
2463 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2466 // GERALD -- QMESSAGE BOX
2467 ASSERT("Pb au calcul de l'iteration precedente" == 0);
2471 // C. Le sous-repertoire de l'iteration precedente
2472 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2473 MESSAGE( ". DirComputePa = " << DirComputePa );
2475 // D. Les donnees de l'adaptation HOMARD
2476 // D.1. Le type de conformite
2477 int ConfType = myCase->GetConfType();
2478 MESSAGE ( ". ConfType = " << ConfType );
2480 // D.2. Le maillage de depart
2481 const char* NomMeshParent = myIterationParent->GetMeshName();
2482 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2483 const char* MeshFileParent = myIterationParent->GetMeshFile();
2484 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2486 // D.3. Le maillage associe a l'iteration
2487 const char* MeshFile = myIteration->GetMeshFile();
2488 MESSAGE ( ". MeshFile = " << MeshFile );
2489 FILE *file = fopen(MeshFile,"r");
2493 if (etatMenage == 0)
2495 SALOME::ExceptionStruct es;
2496 es.type = SALOME::BAD_PARAM;
2497 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2498 es.text = CORBA::string_dup(text.c_str());
2499 throw SALOME::SALOME_Exception(es);
2504 std::string commande = "rm -f " + std::string(MeshFile);
2505 codret = system(commande.c_str());
2508 SALOME::ExceptionStruct es;
2509 es.type = SALOME::BAD_PARAM;
2510 es.text = "The mesh file cannot be deleted.";
2511 throw SALOME::SALOME_Exception(es);
2517 // D.4. Les types de raffinement et de deraffinement
2518 // Les appels corba sont lourds, il vaut mieux les grouper
2519 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2520 ASSERT(ListTypes->length() == 3);
2521 int TypeAdap = (*ListTypes)[0];
2522 int TypeRaff = (*ListTypes)[1];
2523 int TypeDera = (*ListTypes)[2];
2525 // E. Texte du fichier de configuration
2526 // E.1. Incontournables du texte
2527 myDriver->TexteAdap();
2529 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2530 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2531 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2533 // E.2. Ajout des informations liees aux zones eventuelles
2534 if ( TypeAdap == 0 )
2535 { DriverTexteZone(myHypo, myDriver) ; }
2537 // E.3. Ajout des informations liees aux champs eventuels
2538 if ( TypeAdap == 1 )
2539 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2541 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2542 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2543 int numberOfGroups = listeGroupes->length();
2544 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2545 if (numberOfGroups > 0)
2547 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2549 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2550 MESSAGE( "... GroupName = " << GroupName );
2551 myDriver->TexteGroup(GroupName);
2555 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2556 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2558 // E.6. Ajout des options avancees
2559 int Pyram = myCase->GetPyram();
2560 MESSAGE ( ". Pyram = " << Pyram );
2561 int NivMax = myHypo->GetNivMax();
2562 MESSAGE ( ". NivMax = " << NivMax );
2563 double DiamMin = myHypo->GetDiamMin() ;
2564 MESSAGE ( ". DiamMin = " << DiamMin );
2565 int AdapInit = myHypo->GetAdapInit();
2566 MESSAGE ( ". AdapInit = " << AdapInit );
2567 int LevelOutput = myHypo->GetLevelOutput();
2568 MESSAGE ( ". LevelOutput = " << LevelOutput );
2569 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2571 // E.7. Ajout des informations sur le deroulement de l'execution
2572 int MessInfo = myIteration->GetInfoCompute();
2573 MESSAGE ( ". MessInfo = " << MessInfo );
2574 myDriver->TexteInfoCompute(MessInfo);
2578 //=============================================================================
2579 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2580 // nomrep : nom du repertoire parent
2581 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2582 //=============================================================================
2583 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2585 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2586 // On verifie que le repertoire parent existe
2587 int codret = chdir(nomrep) ;
2590 SALOME::ExceptionStruct es;
2591 es.type = SALOME::BAD_PARAM;
2592 es.text = "The directory of the case does not exist.";
2593 throw SALOME::SALOME_Exception(es);
2596 std::string nomDirActuel = getenv("PWD") ;
2597 std::string DirName ;
2598 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2599 bool a_chercher = true ;
2600 while ( a_chercher )
2602 // On passe dans le repertoire parent
2604 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2606 if ( num < 100 ) { jaux = 2 ; }
2607 else if ( num < 1000 ) { jaux = 3 ; }
2608 else if ( num < 10000 ) { jaux = 4 ; }
2609 else if ( num < 100000 ) { jaux = 5 ; }
2611 std::ostringstream iaux ;
2612 iaux << std::setw(jaux) << std::setfill('0') << num ;
2613 std::ostringstream DirNameA ;
2614 DirNameA << "I" << iaux.str();
2615 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2616 // que c'est bien un probleme d'absence
2617 if ( chdir(DirNameA.str().c_str()) != 0 )
2619 bool existe = false ;
2621 struct dirent *dirp;
2622 dp = opendir(nomrep);
2623 while ( (dirp = readdir(dp)) != NULL )
2625 std::string file_name(dirp->d_name);
2626 if ( file_name == DirNameA.str() ) { existe = true ; }
2631 DirName = DirNameA.str() ;
2632 a_chercher = false ;
2639 MESSAGE ( "==> DirName = " << DirName);
2640 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2641 chdir(nomDirActuel.c_str());
2643 return CORBA::string_dup( DirName.c_str() );
2645 //=============================================================================
2646 // Calcul d'une iteration : gestion du repertoire de calcul
2647 // Si le sous-repertoire existe :
2648 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2649 // etatMenage = 1 : on fait le menage du repertoire
2650 // etatMenage = -1 : on ne fait rien
2651 //=============================================================================
2652 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2654 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2655 // B.2. Le repertoire du cas
2656 const char* nomDirCase = myCase->GetDirName();
2657 MESSAGE ( ". nomDirCase = " << nomDirCase );
2659 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2660 // B.3.1. Le nom du sous-repertoire
2661 const char* nomDirIt = myIteration->GetDirNameLoc();
2663 // B.3.2. Le nom complet du sous-repertoire
2664 std::stringstream DirCompute ;
2665 DirCompute << nomDirCase << "/" << nomDirIt;
2666 MESSAGE (". DirCompute = " << DirCompute.str() );
2668 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2669 if (chdir(DirCompute.str().c_str()) != 0)
2671 // Creation du repertoire car il n'existe pas :
2672 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2674 // GERALD -- QMESSAGE BOX
2675 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2676 ASSERT("Pb a la creation du repertoire" == 0);
2681 // Le repertoire existe
2682 // On demande de faire le menage de son contenu :
2683 if (etatMenage == 1)
2685 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2686 std::string commande= "rm -rf " + DirCompute.str()+"/*" ;
2687 int codret = system(commande.c_str());
2690 // GERALD -- QMESSAGE BOX
2691 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2692 ASSERT("Pb au menage du repertoire de calcul" == 0);
2695 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2698 if (etatMenage == 0)
2701 struct dirent *dirp;
2702 dp = opendir(DirCompute.str().c_str());
2704 while ((dirp = readdir(dp)) != NULL && result )
2706 std::string file_name(dirp->d_name);
2707 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2710 if ( result == false)
2712 SALOME::ExceptionStruct es;
2713 es.type = SALOME::BAD_PARAM;
2714 std::string text = "Directory : " + DirCompute.str() + "is not empty";
2715 es.text = CORBA::string_dup(text.c_str());
2716 throw SALOME::SALOME_Exception(es);
2717 ASSERT("Directory is not empty" == 0);
2723 return CORBA::string_dup( DirCompute.str().c_str() );
2725 //=============================================================================
2726 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2727 //=============================================================================
2728 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2730 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2731 // Le repertoire du cas
2732 const char* nomDirCase = myCase->GetDirName();
2733 MESSAGE ( ". nomDirCase = " << nomDirCase );
2735 // Le sous-repertoire de l'iteration precedente
2737 const char* nomIterationParent = myIteration->GetIterParentName();
2738 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2739 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
2740 std::stringstream DirComputePa ;
2741 DirComputePa << nomDirCase << "/" << nomDirItPa;
2742 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2743 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2745 return CORBA::string_dup( DirComputePa.str().c_str() );
2747 //=============================================================================
2748 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2749 //=============================================================================
2750 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2752 MESSAGE ( "... DriverTexteZone" );
2753 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2754 int numberOfZonesx2 = ListZone->length();
2757 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2759 std::string ZoneName = std::string((*ListZone)[iaux]);
2760 MESSAGE ( "... ZoneName = " << ZoneName);
2761 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
2762 ASSERT(!CORBA::is_nil(myZone));
2764 int ZoneType = myZone->GetType();
2765 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
2766 int TypeUse = atoi( TypeUsestr.c_str() );
2767 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
2768 NumZone = iaux/2 + 1 ;
2769 HOMARD::double_array* zone = myZone->GetCoords();
2770 if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
2771 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); }
2772 else if ( ZoneType == 4 ) // Cas d une sphere
2773 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); }
2774 else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
2775 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); }
2776 else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
2777 { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); }
2778 else { ASSERT("ZoneType est incorrect." == 0) ; }
2783 //=============================================================================
2784 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
2785 //=============================================================================
2786 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2788 MESSAGE ( "... DriverTexteField" );
2789 // Le fichier du champ
2790 char* FieldFile = myIteration->GetFieldFile();
2791 MESSAGE ( ". FieldFile = " << FieldFile );
2792 if (strlen(FieldFile) == 0)
2794 // GERALD -- QMESSAGE BOX
2795 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2796 ASSERT("The file for the field is not given." == 0);
2798 // Les caracteristiques d'instants
2799 int TimeStep = myIteration->GetTimeStep();
2800 MESSAGE( ". TimeStep = " << TimeStep );
2801 int Rank = myIteration->GetRank();
2802 MESSAGE( ". Rank = " << Rank );
2803 // Les informations sur les champs
2804 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
2806 const char* FieldName = aInfosHypo->FieldName;
2808 int TypeThR = aInfosHypo->TypeThR;
2809 double ThreshR = aInfosHypo->ThreshR;
2810 int TypeThC = aInfosHypo->TypeThC;
2811 double ThreshC = aInfosHypo->ThreshC;
2812 // Saut entre mailles ou non ?
2813 int UsField = aInfosHypo->UsField;
2814 MESSAGE( ". UsField = " << UsField );
2815 // L'usage des composantes
2816 int UsCmpI = aInfosHypo->UsCmpI;
2817 MESSAGE( ". UsCmpI = " << UsCmpI );
2819 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
2822 HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp();
2823 int numberOfCompos = mescompo->length();
2824 MESSAGE( ". numberOfCompos = " << numberOfCompos );
2825 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
2827 std::string nomCompo = std::string((*mescompo)[NumeComp]);
2828 MESSAGE( "... nomCompo = " << nomCompo );
2829 myDriver->TexteCompo(NumeComp, nomCompo);
2833 //=============================================================================
2834 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
2835 //=============================================================================
2836 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
2838 MESSAGE ( "... DriverTexteBoundary" );
2839 // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
2840 std::list<std::string> ListeBoundaryTraitees ;
2841 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
2842 int numberOfitems = ListBoundaryGroupType->length();
2843 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
2844 int BoundaryOption = 1 ;
2845 int NumBoundaryAnalytical = 0 ;
2846 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2848 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2849 MESSAGE ( "... BoundaryName = " << BoundaryName);
2851 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
2852 while (it != ListeBoundaryTraitees.end())
2854 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
2855 if ( BoundaryName == *it ) { A_faire = 0 ; }
2860 // Caracteristiques de la frontiere
2861 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2862 ASSERT(!CORBA::is_nil(myBoundary));
2863 int BoundaryType = myBoundary->GetType();
2864 MESSAGE ( "... BoundaryType = " << BoundaryType );
2865 // Ecriture selon le type
2866 if (BoundaryType == 0) // Cas d une frontiere discrete
2868 const char* MeshName = myBoundary->GetMeshName() ;
2869 const char* MeshFile = myBoundary->GetMeshFile() ;
2870 myDriver->TexteBoundaryDi( MeshName, MeshFile);
2871 if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; }
2873 else // Cas d une frontiere analytique
2875 NumBoundaryAnalytical++ ;
2876 HOMARD::double_array* coor = myBoundary->GetCoords();
2877 if (BoundaryType == 1) // Cas d un cylindre
2879 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2880 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2882 else if (BoundaryType == 2) // Cas d une sphere
2884 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
2885 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2887 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
2889 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2890 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2892 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
2894 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
2895 if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; }
2898 // Memorisation du traitement
2899 ListeBoundaryTraitees.push_back( BoundaryName );
2902 NumBoundaryAnalytical = 0 ;
2903 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2905 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2906 MESSAGE ( "... BoundaryName = " << BoundaryName);
2907 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2908 ASSERT(!CORBA::is_nil(myBoundary));
2909 int BoundaryType = myBoundary->GetType();
2910 MESSAGE ( "... BoundaryType = " << BoundaryType );
2911 // Recuperation du nom du groupe
2912 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
2913 MESSAGE ( "... GroupName = " << GroupName);
2914 if (BoundaryType == 0) // Cas d une frontiere discrete
2916 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
2918 else // Cas d une frontiere analytique
2920 NumBoundaryAnalytical++ ;
2921 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
2924 myDriver->TexteBoundaryOption(BoundaryOption);
2927 //=============================================================================
2928 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
2929 //=============================================================================
2930 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2932 MESSAGE ( "... DriverTexteFieldInterp" );
2933 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
2934 if (TypeFieldInterp != 0)
2936 // Le fichier des champs
2937 char* FieldFile = myIteration->GetFieldFile();
2938 MESSAGE ( ". FieldFile = " << FieldFile );
2939 if (strlen(FieldFile) == 0)
2941 // GERALD -- QMESSAGE BOX
2942 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2943 ASSERT("The file for the field is not given." == 0);
2945 // Les caracteristiques d'instants
2946 int TimeStep = myIteration->GetTimeStep();
2947 MESSAGE( ". TimeStep = " << TimeStep );
2948 int Rank = myIteration->GetRank();
2949 MESSAGE( ". Rank = " << Rank );
2951 const char* MeshFile = myIteration->GetMeshFile();
2952 myDriver->TexteFieldInterp(TypeFieldInterp, FieldFile, MeshFile, TimeStep, Rank);
2954 if (TypeFieldInterp == 2)
2956 HOMARD::listFieldInterpHypo* meschamps = myHypo->GetListFieldInterp();
2957 int numberOfFields = meschamps->length();
2958 MESSAGE( ". numberOfFields = " << numberOfFields );
2959 for (int NumeChamp = 0; NumeChamp< numberOfFields; NumeChamp++)
2961 std::string nomChamp = std::string((*meschamps)[NumeChamp]);
2962 MESSAGE( "... nomChamp = " << nomChamp );
2963 myDriver->TexteFieldInterpName(NumeChamp, nomChamp);
2969 //===========================================================================
2970 //===========================================================================
2973 //===========================================================================
2974 //===========================================================================
2976 //===========================================================================
2977 //===========================================================================
2978 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
2979 SALOMEDS::SObject_ptr theSObject,
2980 CORBA::Object_ptr theObject,
2981 const char* theName)
2983 MESSAGE("PublishInStudy pour " << theName);
2984 SALOMEDS::SObject_var aResultSO;
2985 if (CORBA::is_nil(theStudy))
2987 SALOME::ExceptionStruct es;
2988 es.type = SALOME::BAD_PARAM;
2989 es.text = "Invalid study context";
2990 throw SALOME::SALOME_Exception(es);
2994 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
2995 // Rq : Iteration est publiee ailleurs
2996 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
2997 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
2998 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
2999 HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject);
3000 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
3002 addInStudy(theStudy);
3004 // Controle de la non publication d'un objet de meme nom
3005 if ( (!aBoundary->_is_nil()) or (!aHypo->_is_nil()) or (!aYACS->_is_nil()) or (!aZone->_is_nil()) )
3007 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
3008 if (listSO->length() >= 1)
3010 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
3011 aResultSO = listSO[0];
3012 return aResultSO._retn();
3016 // Caracteristiques de l'etude
3017 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
3018 aStudyBuilder->NewCommand();
3019 if(!aBoundary->_is_nil())
3020 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
3021 else if(!aCase->_is_nil())
3022 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
3023 else if(!aHypo->_is_nil())
3024 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
3025 else if(!aZone->_is_nil())
3026 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
3027 else if(!aYACS->_is_nil())
3028 aResultSO = PublishYACSInStudy(theStudy, aStudyBuilder, aYACS, theName);
3030 aStudyBuilder->CommitCommand();
3032 return aResultSO._retn();
3034 //=============================================================================
3035 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3036 SALOMEDS::StudyBuilder_var aStudyBuilder,
3037 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3039 MESSAGE("PublishBoundaryStudy pour "<<theName);
3040 SALOMEDS::SObject_var aResultSO;
3041 SALOMEDS::GenericAttribute_var anAttr;
3043 // Caracteristique de la Boundary
3044 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3046 // On recupere le module pere dans l etude
3047 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3048 if (theFatherHomard->_is_nil())
3050 MESSAGE("theFatherHomard->_is_nil()");
3051 return aResultSO._retn();
3054 // On ajoute la categorie des boundarys dans l etude si necessaire
3055 SALOMEDS::SObject_var aSObject;
3056 if (!theFatherHomard->FindSubObject(101, aSObject))
3058 MESSAGE("Ajout de la categorie des boundarys");
3059 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, 101);
3060 PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3062 else { MESSAGE("La categorie des boundarys existe deja."); }
3064 CORBA::Long BoundaryType = myBoundary->GetType();
3065 // MESSAGE("BoundaryType : "<<BoundaryType);
3068 switch (BoundaryType)
3071 { value = "BoundaryDiHomard" ;
3072 icone = "mesh_tree_mesh.png" ;
3076 { value = "BoundaryAnHomard" ;
3077 icone = "cylinderpointvector_2.png" ;
3081 { value = "BoundaryAnHomard" ;
3082 icone = "spherepoint_2.png" ;
3086 { value = "BoundaryAnHomard" ;
3087 icone = "conepointvector.png" ;
3091 { value = "BoundaryAnHomard" ;
3092 icone = "conedxyz.png" ;
3096 aResultSO = aStudyBuilder->NewObject(aSObject);
3097 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3098 return aResultSO._retn();
3100 //=============================================================================
3101 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
3102 SALOMEDS::StudyBuilder_var aStudyBuilder,
3103 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
3105 MESSAGE("PublishCaseInStudy pour "<<theName);
3106 SALOMEDS::SObject_var aResultSO;
3107 SALOMEDS::GenericAttribute_var anAttr;
3109 if (CORBA::is_nil(theObject)) {
3110 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
3111 return aResultSO._retn();
3113 if (theStudy->_is_nil()) {
3114 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
3115 return aResultSO._retn();
3118 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3119 if (theFatherHomard->_is_nil())
3121 MESSAGE("theFatherHomard->_is_nil()");
3122 return aResultSO._retn();
3125 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
3126 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
3127 _orb->object_to_string(theObject) ) ;
3128 return aResultSO._retn();
3130 //=============================================================================
3131 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3132 SALOMEDS::StudyBuilder_var aStudyBuilder,
3133 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3135 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3136 SALOMEDS::SObject_var aResultSO;
3137 SALOMEDS::GenericAttribute_var anAttr;
3139 // On recupere le module pere dans l etude
3140 // On ajoute la categorie des hypotheses dans l etude si necessaire
3141 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3142 if (theFatherHomard->_is_nil())
3144 MESSAGE("theFatherHomard->_is_nil()");
3145 return aResultSO._retn();
3147 SALOMEDS::SObject_var aSObject;
3148 if (!theFatherHomard->FindSubObject(0, aSObject))
3150 MESSAGE("Ajout de la categorie des hypotheses");
3151 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, 0);
3152 PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL);
3154 else { MESSAGE("La categorie des hypotheses existe deja."); }
3156 // Creation du resultat dans l'etude
3157 aResultSO = aStudyBuilder->NewObject(aSObject);
3158 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3160 return aResultSO._retn();
3162 //=============================================================================
3163 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theStudy,
3164 SALOMEDS::StudyBuilder_var aStudyBuilder,
3165 HOMARD::HOMARD_YACS_ptr theObject, const char* theName)
3167 MESSAGE("PublishYACSInStudy pour "<<theName);
3168 SALOMEDS::SObject_var aResultSO;
3169 SALOMEDS::GenericAttribute_var anAttr;
3171 // On recupere le module pere dans l etude
3172 // On ajoute la categorie des schemas YACS dans l etude si necessaire
3173 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3174 if (theFatherHomard->_is_nil())
3176 MESSAGE("theFatherHomard->_is_nil()");
3177 return aResultSO._retn();
3179 SALOMEDS::SObject_var aSObject;
3180 if (!theFatherHomard->FindSubObject(102, aSObject))
3182 MESSAGE("Ajout de la categorie des schemas YACS");
3183 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, 102);
3184 PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL);
3186 else { MESSAGE("La categorie des schemas YACS existe deja."); }
3188 // Creation du resultat dans l'etude
3189 aResultSO = aStudyBuilder->NewObject(aSObject);
3190 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ;
3192 return aResultSO._retn();
3195 //=============================================================================
3196 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
3197 SALOMEDS::StudyBuilder_var aStudyBuilder,
3198 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
3200 MESSAGE("PublishZoneStudy pour "<<theName);
3201 SALOMEDS::SObject_var aResultSO;
3202 SALOMEDS::GenericAttribute_var anAttr;
3204 if (CORBA::is_nil(theObject))
3206 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3207 return aResultSO._retn();
3209 if (theStudy->_is_nil())
3211 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
3212 return aResultSO._retn();
3214 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3215 if (theFatherHomard->_is_nil())
3217 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3218 return aResultSO._retn();
3221 // Caracteristique de la zone
3222 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3223 CORBA::Long ZoneType = myZone->GetType();
3225 // On ajoute la categorie des zones dans l etude si necessaire
3226 SALOMEDS::SObject_var aSObject;
3227 if (!theFatherHomard->FindSubObject(100, aSObject))
3229 MESSAGE("Ajout de la categorie des zones");
3230 aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, 100);
3231 PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3233 else { MESSAGE("La categorie des zones existe deja."); }
3235 aResultSO = aStudyBuilder->NewObject(aSObject);
3244 { icone = "boxdxy_2.png" ;
3248 { icone = "boxdxyz_2.png" ;
3256 { icone = "disk_2.png" ;
3260 { icone = "spherepoint_2.png" ;
3264 { icone = "cylinderpointvector_2.png" ;
3272 { icone = "diskwithhole_2.png" ;
3276 { icone = "pipe_2.png" ;
3280 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3282 return aResultSO._retn();
3284 //===========================================================================
3285 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3286 SALOMEDS::SObject_var aResultSO,
3287 const char* name, const char* value, const char* icone, const char* ior)
3289 MESSAGE("PublishInStudyAttr pour name = "<<name);
3290 MESSAGE("value = "<<value);
3291 // MESSAGE("icone = "<<icone);
3292 // MESSAGE("ior = "<<ior);
3293 SALOMEDS::GenericAttribute_var anAttr ;
3297 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3298 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3299 aNameAttrib->SetValue(name);
3302 // Ajout du commentaire
3303 if ( value != NULL )
3305 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3306 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3307 aCommentAttrib->SetValue(value);
3311 if ( icone != NULL )
3313 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap");
3314 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3315 aPixmap->SetPixMap(icone);
3321 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3322 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3323 anIOR->SetValue(ior);
3327 //=====================================================================================
3328 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3330 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3332 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3333 ASSERT(!CORBA::is_nil(myCase));
3334 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3335 ASSERT(!CORBA::is_nil(aCaseSO));
3337 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3338 ASSERT(!CORBA::is_nil(myBoundary));
3339 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3340 ASSERT(!CORBA::is_nil(aBoundarySO));
3342 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3344 aStudyBuilder->NewCommand();
3346 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3347 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3349 aStudyBuilder->CommitCommand();
3352 //=============================================================================
3353 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3354 // Option = 0 : fichier issu d'une importation
3355 // Option = 1 : fichier issu d'une execution HOMARD
3357 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3358 if (CORBA::is_nil(myCurrentStudy))
3360 SALOME::ExceptionStruct es;
3361 es.type = SALOME::BAD_PARAM;
3362 es.text = "Invalid study context";
3363 throw SALOME::SALOME_Exception(es);
3367 // Le module SMESH est-il actif ?
3368 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3370 if (!CORBA::is_nil(aSmeshSO))
3372 // On verifie que le fichier n est pas deja publie
3373 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3374 for (; aIter->More(); aIter->Next())
3376 SALOMEDS::SObject_var aSO = aIter->Value();
3377 SALOMEDS::GenericAttribute_var aGAttr;
3378 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3380 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3381 CORBA::String_var value=anAttr->Value();
3382 if (strcmp((const char*)value,NomFich) == 0)
3384 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3385 // Pour un fichier importe, on ne republie pas
3390 // Pour un fichier calcule, on commence par faire la depublication
3393 MESSAGE ( "PublishResultInSmesh : depublication" );
3394 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3395 CORBA::String_var value2=anAttr2->Value();
3396 std::string MeshName = string(value2) ;
3397 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3398 DeleteResultInSmesh(NomFich, MeshName) ;
3405 // On enregistre le fichier
3406 MESSAGE( "Enregistrement du fichier");
3407 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3408 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3409 ASSERT(!CORBA::is_nil(aSmeshEngine));
3410 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3411 SMESH::DriverMED_ReadStatus theStatus;
3412 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3414 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3415 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3416 for (int i = 0; i < mesMaillages->length(); i++)
3418 MESSAGE( ". Mise a jour des attributs du maillage");
3419 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3420 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3421 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3422 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3423 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3424 anAttr->SetValue(NomFich);
3425 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3426 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3428 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3429 else { icone = "mesh_tree_mesh.png" ; }
3430 anAttr2->SetPixMap( icone );
3434 //=============================================================================
3435 void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName)
3437 MESSAGE (" DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3438 if (CORBA::is_nil(myCurrentStudy))
3440 SALOME::ExceptionStruct es;
3441 es.type = SALOME::BAD_PARAM;
3442 es.text = "Invalid study context";
3443 throw SALOME::SALOME_Exception(es);
3447 // Le module SMESH est-il actif ?
3448 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3450 if (CORBA::is_nil(aSmeshSO))
3454 // On verifie que le fichier est deja publie
3455 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3456 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3457 for (; aIter->More(); aIter->Next())
3459 SALOMEDS::SObject_var aSO = aIter->Value();
3460 SALOMEDS::GenericAttribute_var aGAttr;
3461 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3463 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3464 CORBA::String_var value=anAttr->Value();
3465 if (strcmp((const char*)value,NomFich.c_str()) == 0)
3467 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3469 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3470 CORBA::String_var value2=anAttr2->Value();
3471 if (strcmp((const char*)value2,MeshName.c_str()) == 0)
3473 myBuilder->RemoveObjectWithChildren( aSO ) ;
3481 //=============================================================================
3482 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3484 // MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3485 if (CORBA::is_nil(myCurrentStudy))
3487 SALOME::ExceptionStruct es;
3488 es.type = SALOME::BAD_PARAM;
3489 es.text = "Invalid study context";
3490 throw SALOME::SALOME_Exception(es);
3494 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3495 if (CORBA::is_nil(myIteration))
3497 SALOME::ExceptionStruct es;
3498 es.type = SALOME::BAD_PARAM;
3499 es.text = "Invalid iteration";
3500 throw SALOME::SALOME_Exception(es);
3503 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3504 if (CORBA::is_nil(myIteration))
3506 SALOME::ExceptionStruct es;
3507 es.type = SALOME::BAD_PARAM;
3508 es.text = "Invalid iterationStudy Object";
3509 throw SALOME::SALOME_Exception(es);
3513 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3515 aStudyBuilder->NewCommand();
3517 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3518 // Pour les fichiers med, on affiche une icone de maillage
3519 // Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte'
3520 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3522 std::string ior = " " ;
3523 if ( Commentaire[0] == 'I' )
3524 { icone = "med.png" ; }
3526 { icone = "texte_2.png" ; }
3527 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3529 aStudyBuilder->CommitCommand();
3532 //=============================================================================
3533 //=============================================================================
3535 //=============================================================================
3536 //=============================================================================
3537 //=============================================================================
3538 // Creation d'un schema YACS
3539 // nomCas : nom du cas a traiter
3540 // FileName : nom du fichier contenant le script de lancement du calcul
3541 // DirName : le repertoire de lancement des calculs du schéma
3542 //=============================================================================
3543 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* YACSName, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
3545 INFOS ( "CreateYACSSchema : Schema YACS " << YACSName );
3546 INFOS ( ". nomCas : " << nomCas);
3547 INFOS ( ". ScriptFile : " << ScriptFile);
3548 INFOS ( ". DirName : " << DirName);
3549 INFOS ( ". MeshFile : " << MeshFile);
3551 // A. Controle du nom :
3552 if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(YACSName) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end())
3554 SALOME::ExceptionStruct es;
3555 es.type = SALOME::BAD_PARAM;
3556 es.text = "This schema YACS has already been defined.";
3557 throw SALOME::SALOME_Exception(es);
3561 // B. Creation de l'objet
3562 HOMARD::HOMARD_YACS_var myYACS = newYACS();
3563 if (CORBA::is_nil(myYACS))
3565 SALOME::ExceptionStruct es;
3566 es.type = SALOME::BAD_PARAM;
3567 es.text = "Unable to create the schema YACS";
3568 throw SALOME::SALOME_Exception(es);
3571 myYACS->SetName( YACSName ) ;
3573 // C. Enregistrement
3574 myContextMap[GetCurrentStudyID()]._mesYACSs[YACSName] = myYACS;
3576 SALOMEDS::SObject_var aSO;
3577 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, YACSName);
3579 // D. Caracterisation
3580 myYACS->SetDirName( DirName ) ;
3581 myYACS->SetMeshFile( MeshFile ) ;
3582 myYACS->SetScriptFile( ScriptFile ) ;
3583 myYACS->SetCaseName( nomCas ) ;
3584 myYACS->SetType( 1 ) ;
3586 return HOMARD::HOMARD_YACS::_duplicate(myYACS);
3588 //=============================================================================
3589 // Ecriture d'un schema YACS
3590 //=============================================================================
3591 CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* YACSFile)
3593 INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << YACSFile );
3600 HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS];
3601 ASSERT(!CORBA::is_nil(myYACS));
3602 // B.2. Les caracteristiques
3603 std::string DirName = myYACS->GetDirName() ;
3604 std::string MeshFile = myYACS->GetMeshFile() ;
3605 std::string ScriptFile = myYACS->GetScriptFile() ;
3609 const char* nomCas = myYACS->GetCaseName();
3610 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
3611 ASSERT(!CORBA::is_nil(myCase));
3612 // C.2. Les instructions python associees au cas
3613 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
3614 std::string pythonCas = dumpCorbaCase.in();
3615 MESSAGE ("pythonCas :\n"<<pythonCas<<"\n");
3617 // D. Les iterations
3618 // D.1. L'iteration initiale
3619 HOMARD::HOMARD_Iteration_var Iter0 = myCase->GetIter0() ;
3620 std::string Iter0Name = myCase->GetIter0Name() ;
3621 MESSAGE (". Iter0Name = " << Iter0Name);
3622 // D.2. L'iteration numero 1
3623 HOMARD::listeIterFilles* maListe = Iter0->GetIterations();
3624 int numberOfIter = maListe->length();
3625 if ( numberOfIter > 1 )
3627 MESSAGE (". numberOfIter = " << numberOfIter);
3628 SALOME::ExceptionStruct es ;
3629 es.type = SALOME::BAD_PARAM;
3630 std::string text = "Une seule iteration est permise." ;
3631 es.text = CORBA::string_dup(text.c_str());
3632 throw SALOME::SALOME_Exception(es);
3635 std::string Iter1Name = std::string((*maListe)[0]);
3636 MESSAGE ("... Iter1Name = " << Iter1Name);
3637 HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ;
3638 MESSAGE (". Iter1 = " << Iter1);
3640 // E. L'hypothese pour passer de l'iteration initiale a la suivante
3641 // E.1. La structure
3642 std::string nomHypo = Iter1->GetHypoName();
3643 MESSAGE (". nomHypo = " << nomHypo);
3644 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
3645 ASSERT(!CORBA::is_nil(myHypo));
3646 // E.2. Les caracteristiques de l'adaptation
3647 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
3648 ASSERT(ListTypes->length() == 3);
3649 int TypeAdap = (*ListTypes)[0];
3650 // int TypeRaff = (*ListTypes)[1];
3651 // int TypeDera = (*ListTypes)[2];
3652 // E.3. Les instructions python associees a l'hypothese
3653 CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython();
3654 std::string pythonHypo = dumpCorbaHypo.in();
3655 MESSAGE ("pythonHypo :\n"<<pythonHypo<<"\n");
3657 // F. Le fichier du schema de reference
3658 // HOMARD_ROOT_DIR : repertoire ou se trouve le module HOMARD
3659 std::string YACSFile_base ;
3660 if ( getenv("HOMARD_ROOT_DIR") != NULL ) { YACSFile_base = getenv("HOMARD_ROOT_DIR") ; }
3661 else { ASSERT("HOMARD_ROOT_DIR est inconnu." == 0) ; }
3662 YACSFile_base += "/share/salome/resources/homard/yacs_01.xml" ;
3663 MESSAGE("YACSFile_base ="<<YACSFile_base);
3665 // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
3666 YACSDriver* myDriver = new YACSDriver(YACSFile, DirName);
3667 std::ifstream fichier( YACSFile_base.c_str() );
3668 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
3670 // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
3671 std::string ligne; // variable contenant chaque ligne lue
3672 std::string mot_cle;
3673 while ( std::getline( fichier, ligne ) )
3675 // G.1.1. Pour la ligne courante, on identifie le premier mot : le mot-cle eventuel
3676 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
3677 ligne_bis >> mot_cle ;
3678 // G.1.2. Le maillage initial
3679 if ( mot_cle == "DataInit_MeshFile" )
3681 myDriver->Texte_DataInit_MeshFile(MeshFile);
3683 // G.1.3. Le script de lancement
3684 else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" )
3686 myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile);
3688 // G.1.4. Les options du cas
3689 else if ( mot_cle == "HOMARD_Init_au_debut_Case_Options" )
3691 myDriver->Texte_HOMARD_Init_au_debut_Case_Options(pythonCas);
3693 // G.1.5. Execution de HOMARD : le repertoire du cas
3694 else if ( mot_cle == "HOMARD_Exec_DirName" )
3696 myDriver->Texte_HOMARD_Exec_DirName();
3698 // G.1.6. Execution de HOMARD : les options de l'hypothese
3699 else if ( mot_cle == "HOMARD_Exec_Hypo_Options" )
3701 myDriver->Texte_python( pythonHypo, 3, "Hypo" ) ;
3703 // G.1.7. Zones et frontieres : les creations
3704 else if ( mot_cle == "HOMARD_Init_au_debut" )
3706 std::string texte_control = myDriver->Texte_HOMARD_Init_au_debut_control() ;
3707 if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; }
3708 texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ;
3709 myDriver->TexteAdd(texte_control);
3711 // G.1.8. Zones : les parametres
3712 else if ( mot_cle == "PARAMETRES" )
3714 if ( TypeAdap == 0 )
3715 { myDriver->TexteAddParametres(); }
3717 // G.1.n. La ligne est recopiee telle quelle
3720 myDriver->TexteAdd(ligne);
3723 // G.2. Ecriture du texte dans le fichier
3725 { myDriver->CreeFichier(); }
3729 SALOME::ExceptionStruct es;
3730 es.type = SALOME::BAD_PARAM;
3731 std::string text = "The reference file for the YACS schema cannot be read." ;
3732 es.text = CORBA::string_dup(text.c_str());
3733 throw SALOME::SALOME_Exception(es);
3740 //=============================================================================
3741 // Ecriture d'un schema YACS : ecriture des zones associees a une hypothese
3742 //=============================================================================
3743 std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, YACSDriver* myDriver)
3745 MESSAGE ( "YACSDriverTexteZone" );
3746 // A. Les zones associees a cette hypothese
3747 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
3748 int numberOfZonesx2 = ListZone->length();
3750 // B. Parcours des zones
3751 std::string texte_control ;
3752 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
3754 // 1. Reperage de la zone
3755 std::string ZoneName = std::string((*ListZone)[iaux]);
3756 MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <<iaux);
3757 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
3758 ASSERT(!CORBA::is_nil(myZone));
3759 // 2. Les instructions python associees a la zone
3760 // La premiere ligne est un commentaire a eliminer
3761 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
3762 CORBA::String_var dumpCorbaZone = myZone->GetDumpPython();
3763 std::string pythonStructure_0 = dumpCorbaZone.in();
3764 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
3765 std::istringstream tout (pythonStructure_0) ;
3767 std::string pythonStructure ;
3768 while ( std::getline( tout, ligne ) )
3769 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
3770 MESSAGE ("pythonStructure :\n"<<pythonStructure);
3771 // 3. Decodage du nom du service
3772 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
3773 MESSAGE ( "... methode = " << methode);
3774 // 4. Mise en place des instructions
3775 int ZoneType = myZone->GetType();
3776 MESSAGE ( "... ZoneType = " << ZoneType);
3777 std::string texte_control_0 ;
3778 texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Zone(ZoneType, pythonStructure, methode, ZoneName );
3779 texte_control += texte_control_0 ;
3784 return texte_control ;
3786 //=============================================================================
3787 // Ecriture d'un schema YACS : ecriture des frontieres associees au cas
3788 //=============================================================================
3789 std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, YACSDriver* myDriver)
3791 MESSAGE ( "YACSDriverTexteBoundary" );
3792 // A. Les frontieres associees au cas
3793 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
3794 int numberOfitems = ListBoundaryGroupType->length();
3796 // B. Parcours des frontieres
3797 std::string texte_control ;
3798 std::list<std::string> ListeBoundaryTraitees ;
3799 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
3801 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
3802 MESSAGE ( "... BoundaryName = " << BoundaryName);
3803 // Attention a n'ecrire la definition qu'une seule fois car elle peut se trouver
3804 // plusieurs fois dans la definition du cas, d'ou la liste ListeBoundaryTraitees
3806 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
3807 while (it != ListeBoundaryTraitees.end())
3809 MESSAGE ( "..... BoundaryNameTraitee = " << *it);
3810 if ( BoundaryName == *it ) { A_faire = 0 ; }
3815 // 1. Caracteristiques de la frontiere
3816 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3817 ASSERT(!CORBA::is_nil(myBoundary));
3818 // 2. Les instructions python associees a la frontiere
3819 // La premiere ligne est un commentaire a eliminer
3820 // La seconde ligne est l'instruction a proprement parler ; on ne garde que ce qui suit le "."
3821 CORBA::String_var dumpCorbaBoundary = myBoundary->GetDumpPython();
3822 std::string pythonStructure_0 = dumpCorbaBoundary.in();
3823 MESSAGE ("pythonStructure_0 :"<<pythonStructure_0);
3824 std::istringstream tout (pythonStructure_0) ;
3826 std::string pythonStructure ;
3827 while ( std::getline( tout, ligne ) )
3828 { pythonStructure = GetStringInTexte ( ligne, ".", 1 ) ; }
3829 MESSAGE ("pythonStructure :\n"<<pythonStructure);
3830 // 3. Decodage du nom du service
3831 std::string methode = GetStringInTexte ( pythonStructure, "(", 0 ) ;
3832 MESSAGE ( "... methode = " << methode);
3833 // 4. Mise en place des instructions
3834 int BoundaryType = myBoundary->GetType();
3835 MESSAGE ( "... BoundaryType = " << BoundaryType);
3836 std::string texte_control_0 ;
3837 texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Boundary(BoundaryType, pythonStructure, methode, BoundaryName );
3838 texte_control += texte_control_0 ;
3839 // 5. Memorisation du traitement
3840 ListeBoundaryTraitees.push_back( BoundaryName );
3844 return texte_control ;
3847 //=============================================================================
3848 //=============================================================================
3849 // Next functions are inherited from SALOMEDS::Driver interface
3850 //=============================================================================
3851 //=============================================================================
3852 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
3854 CORBA::Boolean isMultiFile)
3856 MESSAGE (" Save for theURL = "<< theURL);
3857 SALOMEDS::TMPFile_var aStreamFile;
3859 // get temporary directory name
3860 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3862 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3863 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3865 // HOMARD data file name
3866 std::string aFileName = "";
3868 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3869 aFileName += "_HOMARD.dat";
3871 // initialize sequence of file names
3872 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
3873 aFileSeq->length(1);
3874 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
3876 // get full path to the data file
3877 aFileName = tmpDir + aFileName;
3881 std::ofstream f(aFileName.c_str());
3883 // clear temporary id map
3884 context._idmap.clear();
3889 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
3890 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
3891 HOMARD::HOMARD_Cas_var aCas = it_case->second;
3892 PortableServer::ServantBase_var aServant = GetServant(aCas);
3893 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3895 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
3896 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
3900 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3901 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
3902 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
3903 PortableServer::ServantBase_var aServant = GetServant(aZone);
3904 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3906 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
3907 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3910 // -> save hypotheses
3911 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3912 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
3913 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
3914 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3915 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3917 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
3918 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3921 // -> save iterations
3922 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3923 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
3924 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
3925 PortableServer::ServantBase_var aServant = GetServant(aIter);
3926 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3928 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
3929 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3932 // -> save boundaries
3933 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3934 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
3935 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
3936 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3937 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3938 if (aBoundaryServant) {
3939 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
3940 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3944 MESSAGE ("close file");
3947 // put temporary files to the stream
3948 MESSAGE ("put temporary files to the stream");
3949 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
3951 // remove temporary files
3952 MESSAGE ("remove temporary files");
3953 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3955 // return data stream
3956 MESSAGE ("return data stream");
3957 return aStreamFile._retn();
3960 //===========================================================================
3961 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
3963 CORBA::Boolean isMultiFile)
3965 // No specific ASCII persistence
3966 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
3967 return aStreamFile._retn();
3970 //===========================================================================
3971 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
3972 const SALOMEDS::TMPFile& theStream,
3974 CORBA::Boolean isMultiFile)
3976 MESSAGE (" Load pour theURL = "<< theURL);
3977 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3979 // set current study
3980 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
3981 SetCurrentStudy(aStudy);
3983 // get temporary directory name
3984 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3986 // Convert the stream into sequence of files to process
3987 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
3990 // HOMARD data file name
3991 std::string aFileName = "";
3993 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3994 aFileName = tmpDir + aFileName + "_HOMARD.dat";
3996 StudyContext& context = myContextMap[ aStudy->StudyId() ];
4000 std::ifstream f(aFileName.c_str());
4003 context._mesCas.clear();
4004 context._mesHypotheses.clear();
4005 context._mesIterations.clear();
4006 context._mesZones.clear();
4007 context._mesBoundarys.clear();
4008 context._idmap.clear();
4014 std::getline(f, line);
4015 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
4016 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
4017 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
4018 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
4019 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
4020 std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS);
4021 if (line.substr(0, bounSignature.size()) == bounSignature) {
4022 // re-create boundary
4023 MESSAGE (" Recreation de la frontiere" );
4024 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
4025 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
4026 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
4027 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
4028 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
4029 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
4032 else if (line.substr(0, caseSignature.size()) == caseSignature) {
4034 MESSAGE (" Recreation du cas" );
4035 HOMARD::HOMARD_Cas_var aCase = newCase();
4036 PortableServer::ServantBase_var aServant = GetServant(aCase);
4037 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
4038 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
4039 context._mesCas[aCase->GetName()] = aCase;
4040 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
4043 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
4044 // re-create hypothesis
4045 MESSAGE (" Recreation de l hypothese" );
4046 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
4047 PortableServer::ServantBase_var aServant = GetServant(aHypo);
4048 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
4049 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
4050 context._mesHypotheses[aHypo->GetName()] = aHypo;
4051 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
4054 else if (line.substr(0, iterSignature.size()) == iterSignature) {
4055 // re-create iteration
4056 MESSAGE (" Recreation de l iteration" );
4057 HOMARD::HOMARD_Iteration_var aIter = newIteration();
4058 PortableServer::ServantBase_var aServant = GetServant(aIter);
4059 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
4060 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
4061 context._mesIterations[aIter->GetName()] = aIter;
4062 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
4065 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
4066 MESSAGE (" Recreation de la zone" );
4068 HOMARD::HOMARD_Zone_var aZone = newZone();
4069 PortableServer::ServantBase_var aServant = GetServant(aZone);
4070 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
4071 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
4072 context._mesZones[aZone->GetName()] = aZone;
4073 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
4076 else if (line.substr(0, zoneSignature.size()) == yacsSignature) {
4077 MESSAGE (" Recreation du schema YACS" );
4079 HOMARD::HOMARD_YACS_var aYACS = newYACS();
4080 PortableServer::ServantBase_var aServant = GetServant(aYACS);
4081 HOMARD_YACS_i* aYACSServant = dynamic_cast<HOMARD_YACS_i*>(aServant.in());
4082 if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) {
4083 context._mesYACSs[aYACS->GetName()] = aYACS;
4084 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aYACSServant);
4093 // Remove temporary files created from the stream
4095 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
4100 //===========================================================================
4101 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
4102 const SALOMEDS::TMPFile& theStream,
4104 CORBA::Boolean isMultiFile)
4106 // No specific ASCII persistence
4107 return Load(theComponent, theStream, theURL, isMultiFile);
4110 //===========================================================================
4111 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
4113 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
4114 // clearing study context should be done here:
4115 // - destroy all servants and related CORBA objects
4117 // - remove context from myContextMap
4118 myContextMap.erase(theComponent->GetStudy()->StudyId());
4119 // - nullify myCurrentStudy
4120 myCurrentStudy = SALOMEDS::Study::_nil();
4124 //===========================================================================
4125 char* HOMARD_Gen_i::ComponentDataType()
4127 return CORBA::string_dup("HOMARD");
4130 //===========================================================================
4131 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
4132 const char* IORString,
4133 CORBA::Boolean isMultiFile,
4134 CORBA::Boolean isASCII)
4136 CORBA::String_var aString("");
4137 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
4138 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4139 CORBA::Object_var anObj = _orb->string_to_object(IORString);
4140 if (!CORBA::is_nil(anObj)) {
4141 PortableServer::ServantBase_var aServant = GetServant(anObj);
4142 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
4144 std::map<int, PortableServer::ServantBase*>::const_iterator it;
4145 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
4146 if (it->second == aStorable) {
4147 std::stringstream os;
4149 aString = CORBA::string_dup(os.str().c_str());
4155 return aString._retn();
4158 //===========================================================================
4159 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
4160 const char* aLocalPersistentID,
4161 CORBA::Boolean isMultiFile,
4162 CORBA::Boolean isASCII)
4164 CORBA::String_var aString("");
4165 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
4166 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
4167 int id = atoi(aLocalPersistentID);
4168 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
4169 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
4170 if (!CORBA::is_nil(object)) {
4171 aString = _orb->object_to_string(object);
4175 return aString._retn();
4178 //===========================================================================
4179 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
4181 if(CORBA::is_nil(myCurrentStudy))
4184 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
4185 if(!aCas->_is_nil())
4188 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
4189 if(!aHypo->_is_nil())
4192 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
4193 if(!aZone->_is_nil())
4196 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
4197 if(!aBoundary->_is_nil())
4200 /* Iteration is not published directly
4201 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
4202 if(!aIter->_is_nil())
4208 //===========================================================================
4209 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
4211 // No Copy/Paste support
4215 //===========================================================================
4216 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
4217 CORBA::Long& theObjectID)
4219 // No Copy/Paste support
4220 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
4221 return aStreamFile._retn();
4224 //===========================================================================
4225 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
4226 CORBA::Long theObjectID)
4228 // No Copy/Paste support
4232 //===========================================================================
4233 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
4234 CORBA::Long theObjectID,
4235 SALOMEDS::SObject_ptr theSObject)
4237 // No Copy/Paste support
4238 SALOMEDS::SObject_var aResultSO;
4239 return aResultSO._retn();
4242 //===========================================================================
4243 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
4245 PortableServer::Servant aServant = 0;
4246 if (!CORBA::is_nil(theObject)) {
4248 aServant = _poa->reference_to_servant(theObject);
4256 //==========================================================================
4257 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
4258 CORBA::Boolean isPublished,
4259 CORBA::Boolean isMultiFile,
4260 CORBA::Boolean& isValidScript)
4262 MESSAGE ("Entree dans DumpPython");
4264 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
4265 if(CORBA::is_nil(aStudy))
4266 return new Engines::TMPFile(0);
4268 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
4269 if(CORBA::is_nil(aSO))
4270 return new Engines::TMPFile(0);
4272 std::string aScript = "\"\"\"\n";
4273 aScript += "Python script for HOMARD\n";
4274 aScript += "Copyright EDF-R&D 2013\n";
4275 aScript += "\"\"\"\n";
4276 aScript += "__revision__ = \"V1.2\"\n";
4277 aScript += "import HOMARD\n";
4279 aScript += "import salome\n";
4280 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
4282 aScript += "def RebuildData(theStudy):\n";
4283 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
4286 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
4287 MESSAGE (". Au depart \n"<<aScript);
4290 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
4292 MESSAGE (". Ecritures des frontieres");
4293 aScript += "#\n# Creation of the boundaries";
4294 aScript += "\n# ==========================";
4296 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
4297 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
4298 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
4300 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
4301 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
4302 std::string dumpBoundary = dumpCorbaBoundary.in();
4303 MESSAGE (dumpBoundary<<"\n");
4304 aScript += dumpBoundary;
4308 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
4310 MESSAGE (". Ecritures des zones");
4311 aScript += "#\n# Creation of the zones";
4312 aScript += "\n# =====================";
4314 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
4315 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
4316 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
4318 HOMARD::HOMARD_Zone_var maZone = (*it_zone).second;
4319 CORBA::String_var dumpCorbaZone = maZone->GetDumpPython();
4320 std::string dumpZone = dumpCorbaZone.in();
4321 MESSAGE (dumpZone<<"\n");
4322 aScript += dumpZone;
4326 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
4328 MESSAGE (". Ecritures des hypotheses");
4329 aScript += "#\n# Creation of the hypotheses";
4330 aScript += "\n# ==========================";
4332 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
4333 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
4334 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
4336 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
4337 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
4338 std::string dumpHypo = dumpCorbaHypo.in();
4339 MESSAGE (dumpHypo<<"\n");
4340 aScript += dumpHypo;
4344 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
4346 MESSAGE (". Ecritures des cas");
4347 aScript += "#\n# Creation of the cases";
4348 aScript += "\n# =====================";
4350 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
4351 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4352 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
4354 std::string nomCas = (*it_cas).first;
4355 std::string dumpCas = std::string("\n# Creation of the case ") ;
4356 dumpCas += nomCas + std::string("\n");
4357 dumpCas += std::string("\t") + nomCas;
4358 dumpCas += std::string(" = homard.CreateCase(\"") + nomCas + std::string("\", \"");
4360 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
4361 CORBA::String_var cIter0= myCase->GetIter0Name();
4362 std::string iter0 = cIter0.in();
4364 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
4365 CORBA::String_var cMesh0= myIteration->GetMeshFile();
4366 std::string mesh0 = cMesh0.in();
4367 CORBA::String_var cMeshName0= myIteration->GetMeshName();
4368 std::string meshName0 = cMeshName0.in();
4369 dumpCas += meshName0 + std::string("\", \"")+ mesh0 + std::string("\")\n");
4370 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
4371 std::string dumpCas2= dumpCorbaCase.in();
4373 MESSAGE (dumpCas<<dumpCas2<<"\n");
4374 aScript += dumpCas + dumpCas2;
4378 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
4380 MESSAGE (". Ecritures des iterations");
4381 aScript += "#\n# Creation of the iterations" ;
4382 aScript += "\n# ==========================";
4384 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
4385 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
4386 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
4388 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
4389 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
4390 std::string dumpIter = dumpCorbaIter.in();
4391 MESSAGE (dumpIter<<"\n");
4392 aScript += dumpIter;
4395 MESSAGE (". Ecritures finales");
4397 aScript += "\n\tpass";
4400 if( !isMultiFile ) // remove unnecessary tabulation
4401 aScript = RemoveTabulation( aScript );
4403 // MESSAGE ("A ecrire \n"<<aScript);
4404 const size_t aLen = strlen(aScript.c_str());
4405 char* aBuffer = new char[aLen+1];
4406 strcpy(aBuffer, aScript.c_str());
4408 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
4409 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
4411 MESSAGE ("Sortie de DumpPython");
4412 return aStreamFile._retn();
4416 //=============================================================================
4417 //=============================================================================
4419 //=============================================================================
4420 //=============================================================================
4421 void HOMARD_Gen_i::IsValidStudy( )
4423 // MESSAGE( "IsValidStudy" );
4424 if (CORBA::is_nil(myCurrentStudy))
4426 SALOME::ExceptionStruct es;
4427 es.type = SALOME::BAD_PARAM;
4428 es.text = "Invalid study context";
4429 throw SALOME::SALOME_Exception(es);
4434 //=============================================================================
4435 CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir)
4437 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4438 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4439 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
4441 if (std::string(nomDir) == std::string(it->second->GetDirName())) return false;
4445 /*//=============================================================================
4446 void SALOMEException( std::string message )
4448 SALOME::ExceptionStruct es;
4449 es.type = SALOME::BAD_PARAM;
4451 throw SALOME::SALOME_Exception(es);
4454 //=============================================================================
4455 char* HOMARD_Gen_i::getVersion()
4457 #if HOMARD_DEVELOPMENT
4458 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4460 return CORBA::string_dup(HOMARD_VERSION_STR);
4463 //===============================================================================
4464 // Recuperation de la chaine de caracteres par rapport l'apparition d'un texte
4465 // ligne : la ligne a manipuler
4466 // texte : le texte a reperer
4467 // option : 0 : la chaine avant le texte
4468 // 1 : la chaine apres le texte
4469 // Si le texte est absent, on retourne la chaine totale
4470 //===============================================================================
4471 std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string texte, int option )
4473 // MESSAGE("GetStringInTexte, recherche de '"<<texte<<"' dans '"<<ligne<<"'"<<", option = "<<option);
4475 std::string chaine = ligne ;
4476 int position = ligne.find_first_of( texte ) ;
4479 if ( option == 0 ) { chaine = ligne.substr( 0, position ) ; }
4480 else { chaine = ligne.substr( position+1 ) ; }
4482 // Conversion de type
4487 //=============================================================================
4490 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
4491 PortableServer::POA_ptr poa,
4492 PortableServer::ObjectId* contId,
4493 const char* instanceName,
4494 const char* interfaceName)
4496 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
4497 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
4498 return myHOMARD_Gen->getId();