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 "HomardDriver.hxx"
27 #include "HOMARD_DriverTools.hxx"
28 #include "HomardMedCommun.h"
30 #include "HOMARD_version.h"
32 #include "utilities.h"
33 #include "Utils_SINGLETON.hxx"
34 #include "Utils_CorbaException.hxx"
35 #include "SALOMEDS_Tool.hxx"
36 #include "SALOME_LifeCycleCORBA.hxx"
37 #include "SALOMEconfig.h"
38 #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
39 #include CORBA_CLIENT_HEADER(SMESH_Gen)
56 //=============================================================================
58 //=============================================================================
59 std::string RemoveTabulation( std::string theScript )
61 std::string::size_type aPos = 0;
62 while( aPos < theScript.length() )
64 aPos = theScript.find( "\n\t", aPos );
65 if( aPos == std::string::npos )
67 theScript.replace( aPos, 2, "\n" );
72 //=============================================================================
74 * standard constructor
76 //=============================================================================
77 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
78 PortableServer::POA_ptr poa,
79 PortableServer::ObjectId * contId,
80 const char *instanceName,
81 const char *interfaceName) :
82 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
84 MESSAGE("constructor");
86 _id = _poa->activate_object(_thisObj);
88 myHomard = new ::HOMARD_Gen();
89 _NS = SINGLETON_<SALOME_NamingService>::Instance();
90 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
93 //=================================
97 //================================
98 HOMARD_Gen_i::~HOMARD_Gen_i()
101 //=============================================================================
102 //=============================================================================
103 // Utilitaires pour l'étude
104 //=============================================================================
105 //=============================================================================
106 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
108 ASSERT(!CORBA::is_nil(theStudy));
109 MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
110 SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
112 // Create SComponent labelled 'homard' if it doesn't already exit
113 SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
114 if (CORBA::is_nil(homardFather))
116 myBuilder->NewCommand();
117 MESSAGE("Add Component HOMARD");
119 bool aLocked = theStudy->GetProperties()->IsLocked();
120 if (aLocked) theStudy->GetProperties()->SetLocked(false);
122 homardFather = myBuilder->NewComponent(ComponentDataType());
123 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
124 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
125 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
126 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
127 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
128 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
129 if (!Comp->_is_nil())
131 aName->SetValue(ComponentDataType());
134 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
135 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
136 aPixmap->SetPixMap("HOMARD_2.png");
137 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
139 if (aLocked) theStudy->GetProperties()->SetLocked(true);
140 myBuilder->CommitCommand();
143 //=============================================================================
144 void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
146 MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID());
147 myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy);
148 this->addInStudy(myCurrentStudy);
150 //=============================================================================
151 SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
152 //=============================================================================
154 MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID());
155 return SALOMEDS::Study::_duplicate(myCurrentStudy);
157 //=============================================================================
158 CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
159 //=============================================================================
161 return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
163 //=============================================================================
164 //=============================================================================
166 //=============================================================================
167 //=============================================================================
168 // Utilitaires pour l'iteration
169 //=============================================================================
170 //=============================================================================
171 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat)
172 //=====================================================================================
174 MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter );
175 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
176 if (CORBA::is_nil(myIteration))
178 SALOME::ExceptionStruct es;
179 es.type = SALOME::BAD_PARAM;
180 es.text = "Invalid iteration";
181 throw SALOME::SALOME_Exception(es);
185 myIteration->SetState(Etat);
187 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
188 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
192 icone = "iter0.png" ;
193 else if ( Etat == 2 )
194 icone = "iter_calculee.png" ;
196 icone = "iter_non_calculee.png" ;
197 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone.c_str(), NULL) ;
199 aStudyBuilder->CommitCommand();
202 //=============================================================================
203 //=============================================================================
205 //=============================================================================
206 //=============================================================================
207 // Destruction des structures identifiees par leurs noms
208 //=============================================================================
209 //=============================================================================
210 CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName)
212 MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName );
213 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
214 if (CORBA::is_nil(myBoundary))
216 SALOME::ExceptionStruct es;
217 es.type = SALOME::BAD_PARAM;
218 es.text = "Invalid boundary";
219 throw SALOME::SALOME_Exception(es);
223 // On verifie que la frontiere n'est plus utilisee
224 HOMARD::listeCases* maListe = GetAllCasesName();
225 int numberOfCases = maListe->length();
226 MESSAGE ( ".. Nombre de cas = " << numberOfCases );
227 std::string CaseName ;
228 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType ;
230 HOMARD::HOMARD_Cas_var myCase ;
231 for (int NumeCas = 0; NumeCas< numberOfCases; NumeCas++)
233 CaseName = std::string((*maListe)[NumeCas]);
234 MESSAGE ( "... Examen du cas = " << CaseName.c_str() );
235 myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
236 ASSERT(!CORBA::is_nil(myCase));
237 ListBoundaryGroupType = myCase->GetBoundaryGroup();
238 numberOfitems = ListBoundaryGroupType->length();
239 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
240 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
242 if ( std::string((*ListBoundaryGroupType)[NumBoundary]) == BoundaryName )
244 SALOME::ExceptionStruct es;
245 es.type = SALOME::BAD_PARAM;
246 es.text = "This boundary is used in a case and cannot be deleted.";
247 throw SALOME::SALOME_Exception(es);
253 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
254 myContextMap[GetCurrentStudyID()]._mesBoundarys.erase(BoundaryName);
255 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(BoundaryName, ComponentDataType());
256 SALOMEDS::SObject_var aSO =listSO[0];
257 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
258 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
262 //=============================================================================
263 CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas)
265 // Pour detruire un cas
266 MESSAGE ( "DeleteCase : nomCas = " << nomCas );
267 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
268 if (CORBA::is_nil(myCase))
270 SALOME::ExceptionStruct es;
271 es.type = SALOME::BAD_PARAM;
272 es.text = "Invalid case context";
273 throw SALOME::SALOME_Exception(es);
276 // On commence par detruire toutes les iterations en partant de l'initiale et y compris elle
277 CORBA::String_var nomIter = myCase->GetIter0Name();
278 CORBA::Long Option1 = 0 ;
279 CORBA::Long Option2 = 1 ;
280 if ( DeleteIterationOption(nomIter, Option1, Option2) != 0 )
285 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
286 myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas);
287 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType());
288 SALOMEDS::SObject_var aSO =listSO[0];
289 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
290 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
294 //=============================================================================
295 CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo)
297 MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo );
298 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
299 if (CORBA::is_nil(myHypo))
301 SALOME::ExceptionStruct es;
302 es.type = SALOME::BAD_PARAM;
303 es.text = "Invalid hypothesis";
304 throw SALOME::SALOME_Exception(es);
308 // On verifie que l'hypothese n'est plus utilisee
309 HOMARD::listeIters* maListeIter = myHypo->GetIterations();
310 int numberOfIter = maListeIter->length();
311 if ( numberOfIter > 0 )
313 SALOME::ExceptionStruct es;
314 es.type = SALOME::BAD_PARAM;
315 es.text = "This hypothesis is used in an iteration and cannot be deleted.";
316 throw SALOME::SALOME_Exception(es);
320 // suppression du lien avec les zones eventuelles
321 HOMARD::listeZonesHypo* maListe = myHypo->GetZones();
322 int numberOfZones = maListe->length();
323 MESSAGE ( ".. Nombre de zones = " << numberOfZones );
324 for (int NumeZone = 0; NumeZone< numberOfZones; NumeZone++)
326 std::string ZoneName = std::string((*maListe)[NumeZone]);
327 MESSAGE ( ".. suppression du lien avec la zone = " << ZoneName.c_str() );
328 DissociateHypoZone(nomHypo, ZoneName.c_str()) ;
332 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
333 myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo);
334 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType());
335 SALOMEDS::SObject_var aSO =listSO[0];
336 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
337 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
341 //=============================================================================
342 CORBA::Long HOMARD_Gen_i::DeleteIteration(const char* nomIter, CORBA::Long Option)
344 // Option = 0 : On ne supprime pas le fichier du maillage associe
345 // Option = 1 : On supprime le fichier du maillage associe
346 // Option = 2 : On supprime le fichier du maillage associe, sauf si c'est la derniere iteration
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 eventeullement du maillage associe
396 InvalideIterOption(nomIter, Option2) ;
398 // Retrait dans la descendance de l'iteration parent
401 const char* nomIterationParent = myIteration->GetIterParentName();
402 MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent );
403 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
404 if (CORBA::is_nil(myIterationParent))
406 SALOME::ExceptionStruct es;
407 es.type = SALOME::BAD_PARAM;
408 es.text = "Invalid iteration";
409 throw SALOME::SALOME_Exception(es);
412 myIterationParent->UnLinkNextIteration(nomIter);
415 // suppression du lien avec l'hypothese
418 const char* nomHypo = myIteration->GetHypoName();
419 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
420 ASSERT(!CORBA::is_nil(myHypo));
421 myHypo->UnLinkIteration(nomIter);
424 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
425 myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter);
426 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType());
427 SALOMEDS::SObject_var aSO =listSO[0];
428 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
429 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
430 // on peut aussi faire RemoveObject
431 // MESSAGE ( "Au final" );
432 // HOMARD::listeIterations* Liste = GetAllIterationsName() ;
433 // numberOfIter = Liste->length();
434 // for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
436 // std::string nomIterFille = std::string((*Liste)[NumeIter]);
437 // MESSAGE ( ".. nomIter = " << nomIterFille.c_str() );
442 //=============================================================================
443 CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone)
445 MESSAGE ( "DeleteZone : nomZone = " << nomZone );
446 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone];
447 if (CORBA::is_nil(myZone))
449 SALOME::ExceptionStruct es;
450 es.type = SALOME::BAD_PARAM;
451 es.text = "Invalid zone";
452 throw SALOME::SALOME_Exception(es);
456 // On verifie que la zone n'est plus utilisee
457 HOMARD::listeHypo* maListe = myZone->GetHypo();
458 int numberOfHypo = maListe->length();
459 MESSAGE ( ".. Nombre d'hypotheses = " << numberOfHypo );
460 if ( numberOfHypo > 0 )
462 SALOME::ExceptionStruct es;
463 es.type = SALOME::BAD_PARAM;
464 es.text = "This zone is used in an hypothesis and cannot be deleted.";
465 throw SALOME::SALOME_Exception(es);
469 // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete
470 myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone);
471 SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType());
472 SALOMEDS::SObject_var aSO =listSO[0];
473 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
474 myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO);
478 //=============================================================================
479 //=============================================================================
481 //=============================================================================
482 //=============================================================================
483 // Invalidation des structures identifiees par leurs noms
484 //=============================================================================
485 //=============================================================================
486 void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName)
488 MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName );
489 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
490 if (CORBA::is_nil(myBoundary))
492 SALOME::ExceptionStruct es;
493 es.type = SALOME::BAD_PARAM;
494 es.text = "Invalid boundary";
495 throw SALOME::SALOME_Exception(es);
500 SALOME::ExceptionStruct es;
501 es.type = SALOME::BAD_PARAM;
502 es.text = "No change is allowed in a boundary. Ask for evolution.";
503 throw SALOME::SALOME_Exception(es);
507 //=============================================================================
508 void HOMARD_Gen_i::InvalideHypo(const char* nomHypo)
510 MESSAGE( "InvalideHypo : nomHypo = " << nomHypo );
511 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
512 if (CORBA::is_nil(myHypo))
514 SALOME::ExceptionStruct es;
515 es.type = SALOME::BAD_PARAM;
516 es.text = "Invalid hypothesis";
517 throw SALOME::SALOME_Exception(es);
521 HOMARD::listeIters* maListe = myHypo->GetIterations();
522 int numberOfIter = maListe->length();
523 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
525 std::string nomIter = std::string((*maListe)[NumeIter]);
526 MESSAGE( ".. nomIter = " << nomIter );
527 InvalideIter(nomIter.c_str());
530 //=============================================================================
531 void HOMARD_Gen_i::InvalideIter(const char* nomIter)
533 MESSAGE("InvalideIter : nomIter = " << nomIter);
534 // Pour invalider totalement une iteration courante
535 CORBA::Long Option = 1 ;
536 return InvalideIterOption(nomIter, Option);
538 //=============================================================================
539 void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option)
541 // Option = 0 : On ne supprime pas le fichier du maillage associe
542 // Option = 1 : On supprime le fichier du maillage associe
543 MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option );
544 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
545 if (CORBA::is_nil(myIteration))
547 SALOME::ExceptionStruct es;
548 es.type = SALOME::BAD_PARAM;
549 es.text = "Invalid iteration";
550 throw SALOME::SALOME_Exception(es);
554 HOMARD::listeIterFilles* maListe = myIteration->GetIterations();
555 int numberOfIter = maListe->length();
556 for (int NumeIter = 0; NumeIter< numberOfIter; NumeIter++)
558 std::string nomIterFille = std::string((*maListe)[NumeIter]);
559 MESSAGE ( ".. appel recursif de InvalideIter pour nomIter = " << nomIterFille.c_str() );
560 InvalideIter(nomIterFille.c_str());
563 // On arrive ici pour une iteration sans fille
564 MESSAGE ( "Invalidation effective de " << nomIter );
565 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
566 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
567 for (; aIter->More(); aIter->Next())
569 SALOMEDS::SObject_var so = aIter->Value();
570 SALOMEDS::GenericAttribute_var anAttr;
571 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
572 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
573 std::string value (aCommentAttr->Value());
574 if(value == std::string("HypoHomard")) continue;
575 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
576 aStudyBuilder->RemoveObject(so);
579 int etat = myIteration->GetState();
582 SetEtatIter(nomIter,1);
583 const char * nomCas = myIteration->GetCaseName();
584 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
585 if (CORBA::is_nil(myCase))
587 SALOME::ExceptionStruct es;
588 es.type = SALOME::BAD_PARAM;
589 es.text = "Invalid case context";
590 throw SALOME::SALOME_Exception(es);
593 const char* nomDir = myIteration->GetDirName();
594 const char* nomFichier = myIteration->GetMeshFile();
595 std::string commande= "rm -rf " + std::string(nomDir);
596 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
597 MESSAGE ( "commande = " << commande );
598 if ((system(commande.c_str())) != 0)
600 SALOME::ExceptionStruct es;
601 es.type = SALOME::BAD_PARAM;
602 es.text = "The directory for the calculation cannot be cleared." ;
603 throw SALOME::SALOME_Exception(es);
606 // Suppression du maillage publie dans SMESH
607 const char* MeshName = myIteration->GetMeshName() ;
608 DeleteResultInSmesh(nomFichier, MeshName) ;
612 //=============================================================================
613 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
615 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
616 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
617 if (CORBA::is_nil(myIteration))
619 SALOME::ExceptionStruct es;
620 es.type = SALOME::BAD_PARAM;
621 es.text = "Invalid iteration";
622 throw SALOME::SALOME_Exception(es);
626 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
627 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
628 for (; aIter->More(); aIter->Next())
630 SALOMEDS::SObject_var so = aIter->Value();
631 SALOMEDS::GenericAttribute_var anAttr;
632 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
633 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
634 std::string value (aCommentAttr->Value());
635 /* MESSAGE("... value = " << value);*/
636 if( (value == std::string("logInfo")) or ( value == std::string("SummaryInfo")) )
638 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
639 aStudyBuilder->RemoveObject(so);
643 const char * nomCas = myIteration->GetCaseName();
644 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
645 if (CORBA::is_nil(myCase))
647 SALOME::ExceptionStruct es;
648 es.type = SALOME::BAD_PARAM;
649 es.text = "Invalid case context";
650 throw SALOME::SALOME_Exception(es);
653 const char* nomDir = myIteration->GetDirName();
654 std::string commande = "rm -f " + std::string(nomDir) + "/info* " ;
655 commande += std::string(nomDir) + "/Liste.*info" ;
656 /* MESSAGE ( "commande = " << commande );*/
657 if ((system(commande.c_str())) != 0)
659 SALOME::ExceptionStruct es;
660 es.type = SALOME::BAD_PARAM;
661 es.text = "The directory for the calculation cannot be cleared." ;
662 throw SALOME::SALOME_Exception(es);
666 //=============================================================================
667 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
669 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
670 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
671 if (CORBA::is_nil(myZone))
673 SALOME::ExceptionStruct es;
674 es.type = SALOME::BAD_PARAM;
675 es.text = "Invalid zone";
676 throw SALOME::SALOME_Exception(es);
679 HOMARD::listeHypo* maListe = myZone->GetHypo();
680 int numberOfHypo = maListe->length();
681 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
682 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
684 std::string nomHypo = std::string((*maListe)[NumeHypo]);
685 MESSAGE( ".. nomHypo = " << nomHypo );
686 InvalideHypo(nomHypo.c_str());
689 //=============================================================================
690 //=============================================================================
692 //=============================================================================
693 //=============================================================================
694 // Association de lien entre des structures identifiees par leurs noms
695 //=============================================================================
696 //=============================================================================
697 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
699 MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter );
701 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
702 if (CORBA::is_nil(myCase))
704 SALOME::ExceptionStruct es;
705 es.type = SALOME::BAD_PARAM;
706 es.text = "Invalid case";
707 throw SALOME::SALOME_Exception(es);
711 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
712 if (CORBA::is_nil(myIteration))
714 SALOME::ExceptionStruct es;
715 es.type = SALOME::BAD_PARAM;
716 es.text = "Invalid iteration";
717 throw SALOME::SALOME_Exception(es);
721 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
722 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
723 if (CORBA::is_nil(aCasSO))
725 SALOME::ExceptionStruct es;
726 es.type = SALOME::BAD_PARAM;
727 es.text = "Invalid case";
728 throw SALOME::SALOME_Exception(es);
732 aStudyBuilder->NewCommand();
733 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
734 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
735 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
736 aStudyBuilder->CommitCommand();
738 myCase->AddIteration(nomIter);
739 myIteration->SetCaseName(nomCas);
741 //=====================================================================================
742 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
744 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
746 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
747 ASSERT(!CORBA::is_nil(myHypo));
748 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
749 ASSERT(!CORBA::is_nil(aHypoSO));
751 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
752 ASSERT(!CORBA::is_nil(myZone));
753 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
754 ASSERT(!CORBA::is_nil(aZoneSO));
756 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
758 aStudyBuilder->NewCommand();
760 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
761 aStudyBuilder->Addreference(aSubSO, aZoneSO);
763 aStudyBuilder->CommitCommand();
765 myZone->AddHypo(nomHypothesis);
766 myHypo->AddZone0(ZoneName, TypeUse);
768 //=============================================================================
769 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
771 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
773 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
774 ASSERT(!CORBA::is_nil(myHypo));
775 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
776 ASSERT(!CORBA::is_nil(aHypoSO));
778 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
779 ASSERT(!CORBA::is_nil(myIteration));
780 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
781 ASSERT(!CORBA::is_nil(aIterSO));
783 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
785 aStudyBuilder->NewCommand();
787 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
788 aStudyBuilder->Addreference(aSubSO, aHypoSO);
790 aStudyBuilder->CommitCommand();
792 myIteration->SetHypoName(nomHypo);
793 myHypo->LinkIteration(nomIter);
795 //=============================================================================
796 //=============================================================================
798 //=============================================================================
799 //=============================================================================
800 // Dissociation de lien entre des structures identifiees par leurs noms
801 //=============================================================================
802 //=============================================================================
803 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
805 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
807 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
808 ASSERT(!CORBA::is_nil(myHypo));
809 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
810 ASSERT(!CORBA::is_nil(aHypoSO));
812 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
813 ASSERT(!CORBA::is_nil(myZone));
814 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
815 ASSERT(!CORBA::is_nil(aZoneSO));
817 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
819 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
820 for (; it->More(); it->Next())
822 SALOMEDS::SObject_var aHypObj = it->Value();
823 SALOMEDS::SObject_var ptrObj;
824 if (aHypObj->ReferencedObject(ptrObj))
826 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
828 aStudyBuilder->NewCommand();
829 aStudyBuilder->RemoveObject(aHypObj);
830 aStudyBuilder->CommitCommand();
836 myZone->SupprHypo(nomHypothesis);
837 myHypo->SupprZone(ZoneName);
839 //=============================================================================
840 //=============================================================================
843 //=============================================================================
844 //=============================================================================
845 // Recuperation des listes
846 //=============================================================================
847 //=============================================================================
848 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
850 MESSAGE("GetAllCasesName");
853 HOMARD::listeCases_var ret = new HOMARD::listeCases;
854 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
855 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
857 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
858 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
860 ret[i++] = CORBA::string_dup((*it).first.c_str());
865 //=============================================================================
866 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
868 MESSAGE("GetAllHypothesesName");
871 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
872 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
873 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
875 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
876 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
878 ret[i++] = CORBA::string_dup((*it).first.c_str());
883 //=============================================================================
884 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
886 MESSAGE("GetAllZonesName");
889 HOMARD::listeZones_var ret = new HOMARD::listeZones;
890 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
891 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
893 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
894 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
896 ret[i++] = CORBA::string_dup((*it).first.c_str());
901 //=============================================================================
902 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
904 MESSAGE("GetAllIterationsName");
907 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
908 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
909 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
911 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
912 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
914 ret[i++] = CORBA::string_dup((*it).first.c_str());
919 //=============================================================================
920 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
922 MESSAGE("GetAllBoundarysName");
925 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
926 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
927 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
929 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
930 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
932 ret[i++] = CORBA::string_dup((*it).first.c_str());
937 //=============================================================================
938 //=============================================================================
940 //=============================================================================
941 //=============================================================================
942 // Recuperation des structures identifiees par leurs noms
943 //=============================================================================
944 //=============================================================================
945 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
947 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
948 ASSERT(!CORBA::is_nil(myCase));
949 return HOMARD::HOMARD_Cas::_duplicate(myCase);
951 //=============================================================================
952 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
954 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
955 ASSERT(!CORBA::is_nil(myZone));
956 return HOMARD::HOMARD_Zone::_duplicate(myZone);
958 //=============================================================================
959 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
961 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
962 ASSERT(!CORBA::is_nil(myHypothesis));
963 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
965 //=============================================================================
966 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
968 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
969 ASSERT(!CORBA::is_nil(myIteration));
970 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
972 //=============================================================================
973 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
975 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
976 ASSERT(!CORBA::is_nil(myBoundary));
977 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
979 //=============================================================================
980 //=============================================================================
982 //=============================================================================
983 //=============================================================================
985 //=============================================================================
986 //=============================================================================
987 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)
989 MESSAGE ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
990 MESSAGE ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
994 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, 1) ;
995 myCase->SetDirName(DirName) ;
997 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1001 //=============================================================================
1002 //=============================================================================
1004 //=============================================================================
1005 //=============================================================================
1006 // Recuperation des structures par le contexte
1007 //=============================================================================
1008 //=============================================================================
1009 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1011 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1012 ASSERT(!CORBA::is_nil(myCase));
1014 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1015 ASSERT(!CORBA::is_nil(myIteration));
1017 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1019 //=============================================================================
1020 //=============================================================================
1022 //=============================================================================
1023 //=============================================================================
1024 // Nouvelles structures
1025 //=============================================================================
1026 //=============================================================================
1027 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1029 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1030 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1031 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1032 return aCase._retn();
1034 //=============================================================================
1035 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1037 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1038 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1039 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1040 return aHypo._retn();
1042 //=============================================================================
1043 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1045 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1046 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1047 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1048 return aIter._retn();
1050 //=============================================================================
1051 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1053 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1054 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1055 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1056 return aBoundary._retn();
1058 //=============================================================================
1059 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1061 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1062 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1063 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1064 return aZone._retn();
1066 //=============================================================================
1067 //=============================================================================
1069 //=============================================================================
1070 //=============================================================================
1071 // Creation des structures identifiees par leurs noms
1072 //=============================================================================
1073 //=============================================================================
1074 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1076 // Creation d'un cas initial
1077 // nomCas : nom du cas a creer
1078 // MeshName, MeshFile : nom et fichier du maillage correspondant
1081 MESSAGE ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1083 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, 2) ;
1085 // Valeurs par defaut des filtrages
1086 myCase->SetPyram(0);
1088 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1090 //=============================================================================
1091 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart)
1093 // nomCas : nom du cas a creer
1094 // DirNameStart : nom du repertoire contenant l'iteration de reprise
1097 MESSAGE ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1098 std::string nomDirWork = getenv("PWD") ;
1101 // A. Decodage du point de reprise
1102 // A.1. Controle du repertoire de depart de l'iteration
1103 codret = chdir(DirNameStart) ;
1106 SALOME::ExceptionStruct es;
1107 es.type = SALOME::BAD_PARAM;
1108 es.text = "The directory of the iteration does not exist.";
1109 throw SALOME::SALOME_Exception(es);
1112 // A.2. Reperage des fichiers du repertoire de reprise
1113 std::string file_configuration = "" ;
1114 std::string file_maillage_homard = "" ;
1117 struct dirent *dirp;
1118 dp = opendir(DirNameStart);
1119 while ( (dirp = readdir(dp)) != NULL )
1121 std::string file_name(dirp->d_name);
1122 // MESSAGE ( file_name );
1123 bilan = file_name.find("HOMARD.Configuration.") ;
1124 if ( bilan != string::npos ) { file_configuration = file_name ; }
1125 bilan = file_name.find("maill.") ;
1126 if ( bilan != string::npos )
1128 bilan = file_name.find(".hom.med") ;
1129 if ( bilan != string::npos ) { file_maillage_homard = file_name ; }
1133 MESSAGE ( "==> file_configuration : " << file_configuration ) ;
1134 MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ;
1136 if ( ( file_configuration == "" ) or ( file_maillage_homard == "" ) )
1138 SALOME::ExceptionStruct es;
1139 es.type = SALOME::BAD_PARAM;
1141 if ( file_configuration == "" ) { text = "The configuration file cannot be found." ; }
1142 else { text = "The HOMARD mesh file cannot be found." ; }
1143 es.text = CORBA::string_dup(text.c_str());
1144 throw SALOME::SALOME_Exception(es);
1147 // B. Lecture du fichier de configuration
1148 // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration
1154 // le constructeur de ifstream permet d'ouvrir un fichier en lecture
1155 std::ifstream fichier( file_configuration.c_str() );
1156 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1158 std::string ligne; // variable contenant chaque ligne lue
1159 std::string mot_cle;
1160 std::string argument;
1162 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1163 while ( std::getline( fichier, ligne ) )
1165 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1166 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1167 ligne_bis >> mot_cle ;
1168 // B.2. Des valeurs entieres : le second bloc de la ligne
1169 if ( mot_cle == "NumeIter" )
1171 ligne_bis >> NumeIter ;
1174 // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur
1175 else if ( ( mot_cle == "TypeConf" ) or ( mot_cle == "TypeElem" ) )
1177 ligne_bis >> argument ;
1179 if ( mot_cle == "TypeConf" )
1181 if ( argument == "conforme" ) { TypeConf = 1 ; }
1182 else if ( argument == "non_conforme_1_noeud" ) { TypeConf = 2 ; }
1183 else if ( argument == "non_conforme_1_arete" ) { TypeConf = 3 ; }
1184 else if ( argument == "non_conforme_indicateur" ) { TypeConf = 4 ; }
1186 else if ( mot_cle == "TypeElem" )
1188 if ( argument == "ignore_pyra" ) { Pyram = 1 ; }
1189 else if ( argument == "HOMARD" ) { Pyram = 0 ; }
1192 // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes :
1193 // il faut les supprimer
1194 else if ( ( mot_cle == "CCNoMNP1" ) or ( mot_cle == "CCMaiNP1" ) )
1196 ligne_bis >> argument ;
1197 if ( argument[0] == '"' ) { decalage = 1 ; }
1198 else { decalage = 0 ; }
1199 size_t size = argument.size() + 1 - 2*decalage ;
1201 if ( mot_cle == "CCNoMNP1" )
1203 MeshName = new char[ size ];
1204 strncpy( MeshName, argument.c_str()+decalage, size );
1205 MeshName[size-1] = '\0' ;
1207 else if ( mot_cle == "CCMaiNP1" )
1209 MeshFile = new char[ size ];
1210 strncpy( MeshFile, argument.c_str()+decalage, size );
1211 MeshFile[size-1] = '\0' ;
1215 MESSAGE ( "==> TypeConf : " << TypeConf ) ;
1216 MESSAGE ( "==> MeshName : " << MeshName ) ;
1217 MESSAGE ( "==> MeshFile : " << MeshFile ) ;
1218 MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1219 MESSAGE ( "==> Pyram : " << Pyram ) ;
1223 SALOME::ExceptionStruct es;
1224 es.type = SALOME::BAD_PARAM;
1225 std::string text = "The configuration file cannot be read." ;
1226 es.text = CORBA::string_dup(text.c_str());
1227 throw SALOME::SALOME_Exception(es);
1230 // C. Creation effective du cas
1232 HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, 2) ;
1234 // D. Parametrages lus dans le fichier de configuration
1236 myCase->SetConfType (TypeConf) ;
1237 myCase->SetPyram (Pyram) ;
1239 // E. Copie du fichier de maillage homard
1240 // E.1. Repertoire associe au cas
1241 char* nomDirCase = myCase->GetDirName() ;
1242 // E.2. Repertoire associe a l'iteration de ce cas
1244 IterName = myCase->GetIter0Name() ;
1245 HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ;
1246 char* nomDirIter = CreateDirNameIter(nomDirCase, 0 );
1247 Iter->SetDirNameLoc(nomDirIter);
1248 std::string nomDirIterTotal ;
1249 nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ;
1250 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
1252 MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ;
1253 SALOME::ExceptionStruct es;
1254 es.type = SALOME::BAD_PARAM;
1255 std::string text = "The directory for the computation cannot be created." ;
1256 es.text = CORBA::string_dup(text.c_str());
1257 throw SALOME::SALOME_Exception(es);
1259 // E.3. Copie du maillage HOMARD au format MED
1260 codret = chdir(DirNameStart) ;
1261 std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ;
1262 MESSAGE ( "commande : " << commande ) ;
1263 codret = system(commande.c_str()) ;
1264 MESSAGE ( "codret : " << codret ) ;
1267 SALOME::ExceptionStruct es;
1268 es.type = SALOME::BAD_PARAM;
1269 es.text = "The starting point for the case cannot be copied into the working directory.";
1270 throw SALOME::SALOME_Exception(es);
1279 chdir(nomDirWork.c_str());
1281 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1283 //=============================================================================
1284 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart)
1286 // nomCas : nom du cas a creer
1287 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1290 MESSAGE ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart );
1292 std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ;
1294 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1295 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1297 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1299 //=============================================================================
1300 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number)
1302 // nomCas : nom du cas a creer
1303 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1304 // Number : numero de l'iteration de depart
1307 MESSAGE ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number );
1310 SALOME::ExceptionStruct es;
1311 es.type = SALOME::BAD_PARAM;
1312 es.text = "The number of iteration must be positive.";
1313 throw SALOME::SALOME_Exception(es);
1317 std::string DirNameStartIter = CreateCase1(DirNameStart, Number) ;
1319 DirNameStartIter = string(DirNameStart) + "/" + DirNameStartIter ;
1320 HOMARD::HOMARD_Cas_ptr myCase = CreateCaseFromIteration(nomCas, DirNameStartIter.c_str()) ;
1322 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1324 //=============================================================================
1325 std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number)
1327 // Retourne le nom du repertoire ou se trouve l'iteration voulue.
1328 // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise
1329 // Number : numero de l'iteration de depart ou -1 si on cherche la derniere
1332 MESSAGE ( "CreateCase1 : DirNameStart = " << DirNameStart << ", Number = " << Number );
1333 std::string nomDirWork = getenv("PWD") ;
1334 std::string DirNameStartIter ;
1336 int NumeIterMax = -1 ;
1338 // A.1. Controle du repertoire de depart du cas
1339 codret = chdir(DirNameStart) ;
1342 SALOME::ExceptionStruct es;
1343 es.type = SALOME::BAD_PARAM;
1344 es.text = "The directory of the case for the pursuit does not exist.";
1345 throw SALOME::SALOME_Exception(es);
1348 // A.2. Reperage des sous-repertoire du repertoire de reprise
1349 bool existe = false ;
1351 struct dirent *dirp;
1352 dp = opendir(DirNameStart);
1353 while ( (dirp = readdir(dp)) != NULL )
1355 std::string DirName_1(dirp->d_name);
1356 if ( ( DirName_1 != "." ) and ( DirName_1 != ".." ) )
1358 if ( chdir(DirName_1.c_str()) == 0 )
1360 // On cherche le fichier de configuration dans ce sous-repertoire
1361 codret = chdir(DirNameStart) ;
1363 struct dirent *dirp_1;
1364 dp_1 = opendir(DirName_1.c_str()) ;
1365 while ( (dirp_1 = readdir(dp_1)) != NULL )
1367 std::string file_name_1(dirp_1->d_name);
1368 int bilan = file_name_1.find("HOMARD.Configuration.") ;
1369 if ( bilan != string::npos )
1371 // Decodage du fichier pour trouver le numero d'iteration
1372 chdir(DirName_1.c_str()) ;
1373 std::ifstream fichier( file_name_1.c_str() );
1374 if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
1377 std::string ligne; // variable contenant chaque ligne lue
1378 std::string mot_cle;
1379 // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
1380 while ( std::getline( fichier, ligne ) )
1382 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
1383 std::istringstream ligne_bis(ligne); // variable contenant chaque ligne sous forme de flux
1384 ligne_bis >> mot_cle ;
1385 if ( mot_cle == "NumeIter" )
1387 ligne_bis >> NumeIter ;
1389 // MESSAGE ( "==> NumeIter : " << NumeIter ) ;
1390 if ( Number == - 1 )
1392 if ( NumeIter >= NumeIterMax )
1394 NumeIterMax = NumeIter ;
1395 DirNameStartIter = DirName_1 ;
1400 if ( NumeIter == Number )
1402 DirNameStartIter = DirName_1 ;
1412 SALOME::ExceptionStruct es;
1413 es.type = SALOME::BAD_PARAM;
1414 std::string text = "The configuration file cannot be read." ;
1415 es.text = CORBA::string_dup(text.c_str());
1416 throw SALOME::SALOME_Exception(es);
1418 chdir(DirNameStart) ;
1420 if ( existe ) { break ; }
1423 if ( existe ) { break ; }
1429 chdir(nomDirWork.c_str());
1431 if ( ( Number >= 0 and ( not existe ) ) or ( Number < 0 and ( NumeIterMax == -1 ) ) )
1433 SALOME::ExceptionStruct es;
1434 es.type = SALOME::BAD_PARAM;
1435 es.text = "The directory of the iteration does not exist.";
1436 throw SALOME::SALOME_Exception(es);
1440 return DirNameStartIter ;
1442 //=============================================================================
1443 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)
1445 // nomCas : nom du cas a creer
1446 // MeshName, MeshFile : nom et fichier du maillage correspondant
1447 // MeshOption : 0 : le maillage fourni est obligatoirement present ==> erreur si absent
1448 // 1 : le maillage fourni peut ne pas exister ==> on continue si absent
1449 // -1 : le maillage n'est pas fourni
1450 // NumeIter : numero de l'iteration correspondante : 0, pour un depart, n>0 pour une poursuite
1451 // Option : multiple de nombres premiers
1452 // 1 : aucune option
1453 // x2 : publication du maillage dans SMESH
1455 MESSAGE ( "CreateCase0 : nomCas = " << nomCas );
1456 MESSAGE ( "CreateCase0 : MeshName = " << MeshName << ", MeshFile = " << MeshFile << ", MeshOption = " << MeshOption );
1457 MESSAGE ( "CreateCase0 : NumeIter = " << NumeIter << ", Option = " << Option );
1463 // A.2. Controle du nom :
1464 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1466 SALOME::ExceptionStruct es;
1467 es.type = SALOME::BAD_PARAM;
1468 es.text = "This case has already been defined.";
1469 throw SALOME::SALOME_Exception(es);
1473 // A.3. Controle du fichier du maillage
1474 int existeMeshFile ;
1475 if ( MeshOption >= 0 )
1477 existeMeshFile = MEDFileExist ( MeshFile ) ;
1478 MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile );
1479 if ( ( existeMeshFile == 0 ) and ( MeshOption == 0 ) )
1481 SALOME::ExceptionStruct es;
1482 es.type = SALOME::BAD_PARAM;
1483 es.text = "The mesh file does not exist.";
1484 throw SALOME::SALOME_Exception(es);
1488 else { existeMeshFile = 0 ; }
1490 // B. Creation de l'objet cas et publication
1491 // MESSAGE ( "CreateCase0 : Creation de l'objet" );
1492 HOMARD::HOMARD_Cas_var myCase = newCase();
1493 myCase->SetName(nomCas);
1494 SALOMEDS::SObject_var aSO;
1495 PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1496 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1498 // C. Caracteristiques du maillage
1499 if ( existeMeshFile != 0 )
1501 // Les valeurs extremes des coordonnees
1502 // MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" );
1503 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile) ;
1504 HOMARD::extrema_var aSeq = new HOMARD::extrema() ;
1505 if (LesExtremes.size()!=10) { return false; }
1507 for (int i =0 ; i< LesExtremes.size() ; i++)
1508 aSeq[i]=LesExtremes[i] ;
1509 myCase->SetBoundingBox(aSeq) ;
1511 // MESSAGE ( "CreateCase0 : Les groupes" );
1512 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile) ;
1513 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType ;
1514 aSeqGroupe->length(LesGroupes.size());
1515 std::set<std::string>::const_iterator it ;
1517 for (it=LesGroupes.begin() ; it != LesGroupes.end() ; it++)
1518 aSeqGroupe[i++]=(*it).c_str() ;
1519 myCase->SetGroups(aSeqGroupe) ;
1522 // D. L'iteration initiale du cas
1523 MESSAGE ( "CreateCase0 : iteration initiale du cas" );
1524 // D.1. Recherche d'un nom : par defaut, on prend le nom du maillage correspondant.
1525 // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc.
1527 std::string NomIteration = std::string(MeshName) ;
1528 while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) )
1530 std::ostringstream nom;
1531 nom << MeshName << monNum;
1532 NomIteration = nom.str();
1535 MESSAGE ( "CreateCas0 : ==> NomIteration = " << NomIteration );
1537 // D.2. Creation de l'iteration
1538 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1539 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1540 anIter->SetName(NomIteration.c_str());
1541 AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard");
1543 // D.4. Maillage correspondant
1544 if ( existeMeshFile != 0 )
1546 anIter->SetMeshFile(MeshFile);
1547 if ( Option % 2 == 0 ) { PublishResultInSmesh(MeshFile, 0); }
1549 anIter->SetMeshName(MeshName);
1551 // D.5. Numero d'iteration
1552 anIter->SetNumber(NumeIter);
1555 SetEtatIter(NomIteration.c_str(), -NumeIter);
1558 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1560 //=============================================================================
1561 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1563 MESSAGE ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1566 // Controle du nom :
1567 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1569 SALOME::ExceptionStruct es;
1570 es.type = SALOME::BAD_PARAM;
1571 es.text = "This hypothesis has already been defined.";
1572 throw SALOME::SALOME_Exception(es);
1576 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1577 myHypothesis->SetName(nomHypothesis);
1578 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1579 SALOMEDS::SObject_var aSO;
1580 PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1582 // Valeurs par defaut des options avancees
1583 myHypothesis->SetNivMax(-1);
1584 myHypothesis->SetDiamMin(-1.0);
1585 myHypothesis->SetAdapInit(0);
1586 myHypothesis->SetLevelOutput(0);
1588 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1591 //=============================================================================
1592 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1593 //=============================================================================
1595 MESSAGE ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1598 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1599 if (CORBA::is_nil(myIterationParent))
1601 SALOME::ExceptionStruct es;
1602 es.type = SALOME::BAD_PARAM;
1603 es.text = "The parent iteration is not defined.";
1604 throw SALOME::SALOME_Exception(es);
1608 const char* nomCas = myIterationParent->GetCaseName();
1609 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1610 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1611 if (CORBA::is_nil(myCase))
1613 SALOME::ExceptionStruct es;
1614 es.type = SALOME::BAD_PARAM;
1615 es.text = "Invalid case context";
1616 throw SALOME::SALOME_Exception(es);
1619 const char* nomDirCase = myCase->GetDirName();
1621 // Controle du nom :
1622 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1624 SALOME::ExceptionStruct es;
1625 es.type = SALOME::BAD_PARAM;
1626 es.text = "This iteration has already been defined.";
1627 throw SALOME::SALOME_Exception(es);
1631 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1632 if (CORBA::is_nil(myIteration))
1634 SALOME::ExceptionStruct es;
1635 es.type = SALOME::BAD_PARAM;
1636 es.text = "Unable to create the iteration";
1637 throw SALOME::SALOME_Exception(es);
1640 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1641 // Nom de l'iteration et du maillage
1642 myIteration->SetName(NomIteration);
1643 myIteration->SetMeshName(NomIteration);
1644 myIteration->SetState(1);
1646 int numero = myIterationParent->GetNumber() + 1;
1647 myIteration->SetNumber(numero);
1649 // Nombre d'iterations deja connues pour le cas, permettant
1650 // la creation d'un sous-repertoire unique
1651 int nbitercase = myCase->GetNumberofIter();
1652 char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase );
1653 myIteration->SetDirNameLoc(nomDirIter);
1655 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1656 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1657 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1658 // situation la plus frequente.
1659 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1660 // le nombre d'iterations du cas permet d'eviter les collisions.
1662 if ( nbitercase < 100 ) { jaux = 2 ; }
1663 else if ( nbitercase < 1000 ) { jaux = 3 ; }
1664 else if ( nbitercase < 10000 ) { jaux = 4 ; }
1665 else if ( nbitercase < 100000 ) { jaux = 5 ; }
1667 std::ostringstream iaux ;
1668 iaux << std::setw(jaux) << std::setfill('0') << nbitercase ;
1669 std::stringstream MeshFile;
1670 MeshFile << nomDirCase << "/maill." << iaux.str() << ".med";
1671 myIteration->SetMeshFile(MeshFile.str().c_str());
1673 // Association avec le cas
1674 std::string label = "IterationHomard_" + std::string(nomIterParent);
1675 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1676 // Lien avec l'iteration precedente
1677 myIterationParent->LinkNextIteration(NomIteration);
1678 myIteration->SetIterParentName(nomIterParent);
1680 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1682 //=============================================================================
1683 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1685 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1688 // Controle du nom :
1689 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1691 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1692 SALOME::ExceptionStruct es;
1693 es.type = SALOME::BAD_PARAM;
1694 es.text = "This boundary has already been defined";
1695 throw SALOME::SALOME_Exception(es);
1699 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1700 myBoundary->SetName(BoundaryName);
1701 myBoundary->SetType(BoundaryType);
1703 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1705 SALOMEDS::SObject_var aSO;
1706 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1708 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1710 //=============================================================================
1711 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1713 MESSAGE ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1714 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1715 myBoundary->SetMeshFile( MeshFile ) ;
1716 myBoundary->SetMeshName( MeshName ) ;
1718 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1720 //=============================================================================
1721 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1722 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1723 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1724 CORBA::Double Rayon)
1726 MESSAGE ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1728 SALOME::ExceptionStruct es;
1731 { es.text = "The radius must be positive." ;
1733 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1734 if ( daux < 0.0000001 )
1735 { es.text = "The axis must be a non 0 vector." ;
1739 es.type = SALOME::BAD_PARAM;
1740 throw SALOME::SALOME_Exception(es);
1744 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1745 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1747 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1749 //=============================================================================
1750 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1751 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1752 CORBA::Double Rayon)
1754 MESSAGE ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1756 SALOME::ExceptionStruct es;
1759 { es.text = "The radius must be positive." ;
1763 es.type = SALOME::BAD_PARAM;
1764 throw SALOME::SALOME_Exception(es);
1768 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1769 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1771 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1773 //=============================================================================
1774 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1775 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1776 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1778 MESSAGE ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1780 SALOME::ExceptionStruct es;
1782 if ( Angle <= 0.0 or Angle >= 90.0 )
1783 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1785 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1786 if ( daux < 0.0000001 )
1787 { es.text = "The axis must be a non 0 vector." ;
1791 es.type = SALOME::BAD_PARAM;
1792 throw SALOME::SALOME_Exception(es);
1796 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
1797 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
1799 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1801 //=============================================================================
1802 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
1803 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
1804 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
1806 MESSAGE ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
1808 SALOME::ExceptionStruct es;
1810 if ( Rayon1 < 0.0 or Rayon2 < 0.0 )
1811 { es.text = "The radius must be positive." ;
1813 double daux = fabs(Rayon2-Rayon1) ;
1814 if ( daux < 0.0000001 )
1815 { es.text = "The radius must be different." ;
1817 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
1818 if ( daux < 0.0000001 )
1819 { es.text = "The centers must be different." ;
1823 es.type = SALOME::BAD_PARAM;
1824 throw SALOME::SALOME_Exception(es);
1828 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
1829 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
1831 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1833 //=============================================================================
1834 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
1836 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
1839 // Controle du nom :
1840 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
1842 SALOME::ExceptionStruct es;
1843 es.type = SALOME::BAD_PARAM;
1844 es.text = "This zone has already been defined";
1845 throw SALOME::SALOME_Exception(es);
1849 HOMARD::HOMARD_Zone_var myZone = newZone();
1850 myZone->SetName(ZoneName);
1851 myZone->SetType(ZoneType);
1853 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
1855 SALOMEDS::SObject_var aSO;
1856 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
1858 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1860 //=============================================================================
1861 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
1862 CORBA::Double Xmini, CORBA::Double Xmaxi,
1863 CORBA::Double Ymini, CORBA::Double Ymaxi,
1864 CORBA::Double Zmini, CORBA::Double Zmaxi)
1866 MESSAGE ("CreateZoneBox : ZoneName = " << ZoneName ) ;
1868 SALOME::ExceptionStruct es;
1870 if ( Xmini > Xmaxi )
1871 { es.text = "The X coordinates are not coherent." ;
1873 if ( Ymini > Ymaxi )
1874 { es.text = "The Y coordinates are not coherent." ;
1876 if ( Zmini > Zmaxi )
1877 { es.text = "The Z coordinates are not coherent." ;
1881 es.type = SALOME::BAD_PARAM;
1882 throw SALOME::SALOME_Exception(es);
1886 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
1887 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
1889 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1891 //=============================================================================
1892 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
1893 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
1895 MESSAGE ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
1897 SALOME::ExceptionStruct es;
1900 { es.text = "The radius must be positive." ;
1904 es.type = SALOME::BAD_PARAM;
1905 throw SALOME::SALOME_Exception(es);
1909 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
1910 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1912 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1914 //=============================================================================
1915 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
1916 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1917 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1918 CORBA::Double Rayon, CORBA::Double Haut)
1920 MESSAGE ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
1922 SALOME::ExceptionStruct es;
1925 { es.text = "The radius must be positive." ;
1927 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1928 if ( daux < 0.0000001 )
1929 { es.text = "The axis must be a non 0 vector." ;
1932 { es.text = "The height must be positive." ;
1936 es.type = SALOME::BAD_PARAM;
1937 throw SALOME::SALOME_Exception(es);
1941 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
1942 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
1944 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1946 //=============================================================================
1947 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
1948 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1949 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1950 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
1952 MESSAGE ("CreateZonePipe : ZoneName = " << ZoneName ) ;
1954 SALOME::ExceptionStruct es;
1956 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
1957 { es.text = "The radius must be positive." ;
1959 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1960 if ( daux < 0.0000001 )
1961 { es.text = "The axis must be a non 0 vector." ;
1964 { es.text = "The height must be positive." ;
1966 if ( Rayon <= Rayonint )
1967 { es.text = "The external radius must be higher than the internal radius." ;
1971 es.type = SALOME::BAD_PARAM;
1972 throw SALOME::SALOME_Exception(es);
1976 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
1977 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
1979 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1981 //=============================================================================
1982 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
1983 CORBA::Double Umini, CORBA::Double Umaxi,
1984 CORBA::Double Vmini, CORBA::Double Vmaxi,
1987 MESSAGE ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
1988 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
1989 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
1990 // MESSAGE ("Orient = " << Orient ) ;
1992 SALOME::ExceptionStruct es;
1994 if ( Umini > Umaxi )
1995 { es.text = "The first coordinates are not coherent." ;
1997 if ( Vmini > Vmaxi )
1998 { es.text = "The second coordinates are not coherent." ;
2000 if ( Orient < 1 or Orient > 3 )
2001 { es.text = "The orientation must be 1, 2 or 3." ;
2005 es.type = SALOME::BAD_PARAM;
2006 throw SALOME::SALOME_Exception(es);
2010 double Xmini, Xmaxi ;
2011 double Ymini, Ymaxi ;
2012 double Zmini, Zmaxi ;
2020 else if ( Orient == 2 )
2027 else if ( Orient == 3 )
2034 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2036 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
2037 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
2039 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2041 //=============================================================================
2042 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
2043 CORBA::Double Ucentre, CORBA::Double Vcentre,
2044 CORBA::Double Rayon,
2047 MESSAGE ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
2049 SALOME::ExceptionStruct es;
2052 { es.text = "The radius must be positive." ;
2054 if ( Orient < 1 or Orient > 3 )
2055 { es.text = "The orientation must be 1, 2 or 3." ;
2059 es.type = SALOME::BAD_PARAM;
2060 throw SALOME::SALOME_Exception(es);
2068 { Xcentre = Ucentre ;
2071 else if ( Orient == 2 )
2074 Zcentre = Vcentre ; }
2075 else if ( Orient == 3 )
2076 { Xcentre = Vcentre ;
2078 Zcentre = Ucentre ; }
2079 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2081 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
2082 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
2084 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2086 //=============================================================================
2087 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
2088 CORBA::Double Ucentre, CORBA::Double Vcentre,
2089 CORBA::Double Rayon, CORBA::Double Rayonint,
2092 MESSAGE ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
2094 SALOME::ExceptionStruct es;
2096 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
2097 { es.text = "The radius must be positive." ;
2099 if ( Orient < 1 or Orient > 3 )
2100 { es.text = "The orientation must be 1, 2 or 3." ;
2102 if ( Rayon <= Rayonint )
2103 { es.text = "The external radius must be higher than the internal radius." ;
2107 es.type = SALOME::BAD_PARAM;
2108 throw SALOME::SALOME_Exception(es);
2116 { Xcentre = Ucentre ;
2119 else if ( Orient == 2 )
2122 Zcentre = Vcentre ; }
2123 else if ( Orient == 3 )
2124 { Xcentre = Vcentre ;
2126 Zcentre = Ucentre ; }
2127 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
2129 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
2130 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
2132 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
2134 //=============================================================================
2135 //=============================================================================
2140 //=============================================================================
2141 //=============================================================================
2142 // Traitement d'une iteration
2143 // etatMenage = 1 : destruction du repertoire d'execution
2144 // modeHOMARD = 1 : adaptation
2145 // != 1 : information avec les options modeHOMARD
2146 // Option1 >0 : appel depuis python
2147 // <0 : appel depuis GUI
2148 // Option2 : multiple de nombres premiers
2149 // 1 : aucune option
2150 // x2 : publication du maillage dans SMESH
2151 //=============================================================================
2152 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2)
2154 MESSAGE ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", avec Option1 = " << Option1 << ", avec Option2 = " << Option2 );
2159 // A.1. L'objet iteration
2160 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
2161 ASSERT(!CORBA::is_nil(myIteration));
2163 // A.2. Numero de l'iteration
2164 // siterp1 : numero de l'iteration a traiter
2166 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
2167 // Ou si information :
2169 int NumeIter = myIteration->GetNumber();
2170 std::string siterp1 ;
2171 std::stringstream saux1 ;
2173 siterp1 = saux1.str() ;
2174 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
2177 if ( modeHOMARD==1 )
2179 std::stringstream saux0 ;
2180 int iaux = max(0, NumeIter-1) ;
2182 siter = saux0.str() ;
2183 if (NumeIter < 11) { siter = "0" + siter ; }
2186 { siter = siterp1 ; }
2189 const char* nomCas = myIteration->GetCaseName();
2190 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
2191 ASSERT(!CORBA::is_nil(myCase));
2193 // B. Les repertoires
2194 // B.1. Le repertoire courant
2195 std::string nomDirWork = getenv("PWD") ;
2196 // B.2. Le sous-repertoire de l'iteration a traiter
2197 char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage);
2198 MESSAGE( ". DirCompute = " << DirCompute );
2200 // C. Le fichier des messages
2201 // C.1. Le deroulement de l'execution de HOMARD
2202 std::string LogFile = DirCompute ;
2203 LogFile += "/Liste" ;
2204 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
2206 MESSAGE (". LogFile = " << LogFile);
2207 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
2208 // C.2. Le bilan de l'analyse du maillage
2209 std::string FileInfo = DirCompute ;
2211 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
2213 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
2214 else { FileInfo += "info_ap" ; }
2216 FileInfo += "." + siterp1 + ".bilan" ;
2217 myIteration->SetFileInfo(FileInfo.c_str());
2219 // D. On passe dans le repertoire de l'iteration a calculer
2220 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
2223 // E. Les donnees de l'execution HOMARD
2224 // E.1. L'objet du texte du fichier de configuration
2225 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
2226 std::string Langue = "Francais" ;
2227 myDriver->TexteInit(DirCompute, LogFile, Langue);
2229 // E.2. Le maillage associe a l'iteration
2230 const char* NomMesh = myIteration->GetMeshName();
2231 MESSAGE ( ". NomMesh = " << NomMesh );
2232 const char* MeshFile = myIteration->GetMeshFile();
2233 MESSAGE ( ". MeshFile = " << MeshFile );
2235 // E.3. Les donnees du traitement HOMARD
2237 if ( modeHOMARD == 1 )
2240 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2241 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
2242 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option1, Option2) ;
2246 InvalideIterInfo(NomIteration);
2247 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
2249 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
2250 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
2251 myDriver->CreeFichierDonn();
2254 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
2255 DriverTexteBoundary(myCase, myDriver) ;
2257 // E.5. Ecriture du texte dans le fichier
2259 { myDriver->CreeFichier(); }
2263 int codretexec = 12 ;
2266 codretexec = myDriver->ExecuteHomard(Option1);
2268 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
2269 if ( modeHOMARD == 1 )
2271 if (codretexec == 0) { SetEtatIter(NomIteration,2); }
2272 else { SetEtatIter(NomIteration,1); }
2273 // GERALD -- QMESSAGE BOX
2277 // H. Gestion des resultats
2280 std::string Commentaire ;
2281 // H.1. Le fichier des messages, dans tous les cas
2282 Commentaire = "log" ;
2283 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2284 else { Commentaire += "Info" ; }
2285 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
2287 // H.2. Si tout s'est bien passe :
2288 if (codretexec == 0)
2290 // H.2.1. Le fichier de bilan
2291 Commentaire = "Summary" ;
2292 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
2293 else { Commentaire += "Info" ; }
2294 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
2295 // H.2.2. Le fichier de maillage obtenu
2296 if ( modeHOMARD == 1 )
2298 std::stringstream saux0 ;
2299 Commentaire = "Iteration" ;
2300 Commentaire += " " + siter ;
2301 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
2302 if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); }
2305 // H.3 Message d'erreur en cas de probleme
2308 SALOME::ExceptionStruct es;
2309 es.type = SALOME::BAD_PARAM;
2310 std::string text = "Error during the adaptation.\n" ;
2313 ifstream fichier(LogFile.c_str(), ios::in);
2315 while(getline(fichier, ligne) and (ligne != "===== HOMARD ===== STOP ====="));
2316 while (getline(fichier, ligne)) { text += ligne+ "\n";};
2319 text += "no log file ....";
2321 es.text = CORBA::string_dup(text.c_str());
2322 throw SALOME::SALOME_Exception(es);
2326 // I. Menage et retour dans le repertoire du cas
2330 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
2331 chdir(nomDirWork.c_str());
2336 //=============================================================================
2337 // Calcul d'une iteration : partie specifique a l'adaptation
2338 //=============================================================================
2339 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)
2341 MESSAGE ( "ComputeAdap" );
2346 // Etat de l'iteration
2347 int etat = myIteration->GetState();
2348 // Numero de l'iteration
2349 int NumeIter = myIteration->GetNumber();
2350 std::stringstream saux0 ;
2351 saux0 << NumeIter-1 ;
2352 std::string siter = saux0.str() ;
2353 if (NumeIter < 11) { siter = "0" + siter ; }
2355 // A.2. On ne calcule pas l iteration initiale
2358 MESSAGE ( "etat = "<<etat );
2359 SALOME::ExceptionStruct es;
2360 es.type = SALOME::BAD_PARAM;
2361 es.text = "This iteration is the first of the case and cannot be computed.";
2362 throw SALOME::SALOME_Exception(es);
2366 // A.3. On verifie qu il y a une hypothese (erreur improbable);
2367 const char* nomHypo = myIteration->GetHypoName();
2368 if (std::string(nomHypo) == std::string(""))
2370 SALOME::ExceptionStruct es;
2371 es.type = SALOME::BAD_PARAM;
2372 es.text = "This iteration does not have any associated hypothesis.";
2373 throw SALOME::SALOME_Exception(es);
2376 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
2377 ASSERT(!CORBA::is_nil(myHypo));
2379 // B. L'iteration parent
2380 const char* nomIterationParent = myIteration->GetIterParentName();
2381 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2382 ASSERT(!CORBA::is_nil(myIterationParent));
2383 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
2384 if ( myIterationParent->GetState() == 1 )
2387 int codret = Compute(nomIterationParent, etatMenage, iaux, Option1, Option2);
2390 // GERALD -- QMESSAGE BOX
2391 ASSERT("Pb au calcul de l'iteration precedente" == 0);
2395 // C. Le sous-repertoire de l'iteration precedente
2396 char* DirComputePa = ComputeDirPaManagement(myCase, myIteration);
2397 MESSAGE( ". DirComputePa = " << DirComputePa );
2399 // D. Les donnees de l'adaptation HOMARD
2400 // D.1. Le type de conformite
2401 int ConfType = myCase->GetConfType();
2402 MESSAGE ( ". ConfType = " << ConfType );
2404 // D.2. Le maillage de depart
2405 const char* NomMeshParent = myIterationParent->GetMeshName();
2406 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
2407 const char* MeshFileParent = myIterationParent->GetMeshFile();
2408 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
2410 // D.3. Le maillage associe a l'iteration
2411 const char* MeshFile = myIteration->GetMeshFile();
2412 MESSAGE ( ". MeshFile = " << MeshFile );
2413 FILE *file = fopen(MeshFile,"r");
2417 if (etatMenage == 0)
2419 SALOME::ExceptionStruct es;
2420 es.type = SALOME::BAD_PARAM;
2421 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2422 es.text = CORBA::string_dup(text.c_str());
2423 throw SALOME::SALOME_Exception(es);
2428 std::string commande = "rm -f " + std::string(MeshFile);
2429 codret = system(commande.c_str());
2432 SALOME::ExceptionStruct es;
2433 es.type = SALOME::BAD_PARAM;
2434 es.text = "The mesh file cannot be deleted.";
2435 throw SALOME::SALOME_Exception(es);
2441 // D.4. Les types de raffinement et de deraffinement
2442 // Les appels corba sont lourds, il vaut mieux les grouper
2443 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2444 ASSERT(ListTypes->length() == 3);
2445 int TypeAdap = (*ListTypes)[0];
2446 int TypeRaff = (*ListTypes)[1];
2447 int TypeDera = (*ListTypes)[2];
2449 // E. Texte du fichier de configuration
2450 // E.1. Incontournables du texte
2451 myDriver->TexteAdap();
2453 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2454 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2455 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2457 // E.2. Ajout des informations liees aux zones eventuelles
2458 if ( TypeAdap == 0 )
2459 { DriverTexteZone(myHypo, myDriver) ; }
2461 // E.3. Ajout des informations liees aux champs eventuels
2462 if ( TypeAdap == 1 )
2463 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2465 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2466 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2467 int numberOfGroups = listeGroupes->length();
2468 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2469 if (numberOfGroups > 0)
2471 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2473 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2474 MESSAGE( "... GroupName = " << GroupName );
2475 myDriver->TexteGroup(GroupName);
2479 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2480 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2482 // E.6. Ajout des options avancees
2483 int Pyram = myCase->GetPyram();
2484 MESSAGE ( ". Pyram = " << Pyram );
2485 int NivMax = myHypo->GetNivMax();
2486 MESSAGE ( ". NivMax = " << NivMax );
2487 double DiamMin = myHypo->GetDiamMin() ;
2488 MESSAGE ( ". DiamMin = " << DiamMin );
2489 int AdapInit = myHypo->GetAdapInit();
2490 MESSAGE ( ". AdapInit = " << AdapInit );
2491 int LevelOutput = myHypo->GetLevelOutput();
2492 MESSAGE ( ". LevelOutput = " << LevelOutput );
2493 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2497 //=============================================================================
2498 // Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent
2499 // nomrep : nom du repertoire parent
2500 // num : le nom du sous-repertoire est sous la forme 'In', n est >= num
2501 //=============================================================================
2502 char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num )
2504 MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<<num);
2505 // On verifie que le repertoire parent existe
2506 int codret = chdir(nomrep) ;
2509 SALOME::ExceptionStruct es;
2510 es.type = SALOME::BAD_PARAM;
2511 es.text = "The directory of the case does not exist.";
2512 throw SALOME::SALOME_Exception(es);
2515 std::string nomDirActuel = getenv("PWD") ;
2516 std::string DirName ;
2517 // On boucle sur tous les noms possibles jusqu'a trouver un nom correspondant a un repertoire inconnu
2518 bool a_chercher = true ;
2519 while ( a_chercher )
2521 // On passe dans le repertoire parent
2523 // On recherche un nom sous la forme Iabc, avec abc representant le numero
2525 if ( num < 100 ) { jaux = 2 ; }
2526 else if ( num < 1000 ) { jaux = 3 ; }
2527 else if ( num < 10000 ) { jaux = 4 ; }
2528 else if ( num < 100000 ) { jaux = 5 ; }
2530 std::ostringstream iaux ;
2531 iaux << std::setw(jaux) << std::setfill('0') << num ;
2532 std::ostringstream DirNameA ;
2533 DirNameA << "I" << iaux.str();
2534 // Si on ne pas peut entrer dans le repertoire, on doit verifier
2535 // que c'est bien un probleme d'absence
2536 if ( chdir(DirNameA.str().c_str()) != 0 )
2538 bool existe = false ;
2540 struct dirent *dirp;
2541 dp = opendir(nomrep);
2542 while ( (dirp = readdir(dp)) != NULL )
2544 std::string file_name(dirp->d_name);
2545 if ( file_name == DirNameA.str() ) { existe = true ; }
2550 DirName = DirNameA.str() ;
2551 a_chercher = false ;
2558 MESSAGE ( "==> DirName = " << DirName);
2559 MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel );
2560 chdir(nomDirActuel.c_str());
2562 return CORBA::string_dup( DirName.c_str() );
2564 //=============================================================================
2565 // Calcul d'une iteration : gestion du repertoire de calcul
2566 // Si le sous-repertoire existe :
2567 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2568 // etatMenage = 1 : on fait le menage du repertoire
2569 // etatMenage = -1 : on ne fait rien
2570 //=============================================================================
2571 char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2573 MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" );
2574 // B.2. Le repertoire du cas
2575 const char* nomDirCase = myCase->GetDirName();
2576 MESSAGE ( ". nomDirCase = " << nomDirCase );
2578 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2579 // B.3.1. Le nom du sous-repertoire
2580 const char* nomDirIt = myIteration->GetDirNameLoc();
2582 // B.3.2. Le nom complet du sous-repertoire
2583 std::stringstream DirCompute ;
2584 DirCompute << nomDirCase << "/" << nomDirIt;
2585 MESSAGE (". DirCompute = " << DirCompute.str() );
2587 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2588 if (chdir(DirCompute.str().c_str()) != 0)
2590 // Creation du repertoire car il n'existe pas :
2591 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2593 // GERALD -- QMESSAGE BOX
2594 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2595 ASSERT("Pb a la creation du repertoire" == 0);
2600 // Le repertoire existe
2601 // On demande de faire le menage de son contenu :
2602 if (etatMenage == 1)
2604 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2605 std::string commande= "rm -rf " + DirCompute.str()+"/*" ;
2606 int codret = system(commande.c_str());
2609 // GERALD -- QMESSAGE BOX
2610 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2611 ASSERT("Pb au menage du repertoire de calcul" == 0);
2614 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2617 if (etatMenage == 0)
2620 struct dirent *dirp;
2621 dp = opendir(DirCompute.str().c_str());
2623 while ((dirp = readdir(dp)) != NULL && result )
2625 std::string file_name(dirp->d_name);
2626 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2629 if ( result == false)
2631 SALOME::ExceptionStruct es;
2632 es.type = SALOME::BAD_PARAM;
2633 std::string text = "Directory : " + DirCompute.str() + "is not empty";
2634 es.text = CORBA::string_dup(text.c_str());
2635 throw SALOME::SALOME_Exception(es);
2636 ASSERT("Directory is not empty" == 0);
2642 return CORBA::string_dup( DirCompute.str().c_str() );
2644 //=============================================================================
2645 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2646 //=============================================================================
2647 char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2649 MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" );
2650 // Le repertoire du cas
2651 const char* nomDirCase = myCase->GetDirName();
2652 MESSAGE ( ". nomDirCase = " << nomDirCase );
2654 // Le sous-repertoire de l'iteration precedente
2656 const char* nomIterationParent = myIteration->GetIterParentName();
2657 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2658 const char* nomDirItPa = myIterationParent->GetDirNameLoc();
2659 std::stringstream DirComputePa ;
2660 DirComputePa << nomDirCase << "/" << nomDirItPa;
2661 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2662 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2664 return CORBA::string_dup( DirComputePa.str().c_str() );
2666 //=============================================================================
2667 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2668 //=============================================================================
2669 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2671 MESSAGE ( "... DriverTexteZone" );
2672 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2673 int numberOfZonesx2 = ListZone->length();
2676 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2678 std::string ZoneName = std::string((*ListZone)[iaux]);
2679 MESSAGE ( "... ZoneName = " << ZoneName);
2680 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
2681 ASSERT(!CORBA::is_nil(myZone));
2683 int ZoneType = myZone->GetType();
2684 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
2685 int TypeUse = atoi( TypeUsestr.c_str() );
2686 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
2687 NumZone = iaux/2 + 1 ;
2688 HOMARD::double_array* zone = myZone->GetCoords();
2689 if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
2691 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.);
2693 else if ( ZoneType == 4 ) // Cas d une sphere
2695 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.);
2697 else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
2699 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.);
2701 else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
2703 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]);
2705 else { ASSERT("ZoneType est incorrect." == 0) ; }
2710 //=============================================================================
2711 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
2712 //=============================================================================
2713 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2715 MESSAGE ( "... DriverTexteField" );
2716 // Le fichier du champ
2717 char* FieldFile = myIteration->GetFieldFile();
2718 MESSAGE ( ". FieldFile = " << FieldFile );
2719 if (strlen(FieldFile) == 0)
2721 // GERALD -- QMESSAGE BOX
2722 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2723 ASSERT("The file for the field is not given." == 0);
2725 // Les caracteristiques d'instants
2726 int TimeStep = myIteration->GetTimeStep();
2727 MESSAGE( ". TimeStep = " << TimeStep );
2728 int Rank = myIteration->GetRank();
2729 MESSAGE( ". Rank = " << Rank );
2730 // Les informations sur les champ
2731 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
2733 const char* FieldName = aInfosHypo->FieldName;
2735 int TypeThR = aInfosHypo->TypeThR;
2736 double ThreshR = aInfosHypo->ThreshR;
2737 int TypeThC = aInfosHypo->TypeThC;
2738 double ThreshC = aInfosHypo->ThreshC;
2739 // Saut entre mailles ou non ?
2740 int UsField = aInfosHypo->UsField;
2741 MESSAGE( ". UsField = " << UsField );
2742 // L'usage des composantes
2743 int UsCmpI = aInfosHypo->UsCmpI;
2744 MESSAGE( ". UsCmpI = " << UsCmpI );
2746 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
2749 HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp();
2750 int numberOfCompos = mescompo->length();
2751 MESSAGE( ". numberOfCompos = " << numberOfCompos );
2752 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
2754 std::string nomCompo = std::string((*mescompo)[NumeComp]);
2755 MESSAGE( "... nomCompo = " << nomCompo );
2756 myDriver->TexteCompo(NumeComp, nomCompo);
2760 //=============================================================================
2761 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
2762 //=============================================================================
2763 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
2765 MESSAGE ( "... DriverTexteBoundary" );
2766 // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
2767 std::list<std::string> ListeBoundaryTraitees ;
2768 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
2769 int numberOfitems = ListBoundaryGroupType->length();
2770 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
2771 int BoundaryOption = 1 ;
2772 int NumBoundaryAnalytical = 0 ;
2773 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2775 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2776 MESSAGE ( "... BoundaryName = " << BoundaryName);
2778 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
2779 while (it != ListeBoundaryTraitees.end())
2781 MESSAGE ( "... BoundaryNameTraitee = " << *it);
2782 if ( BoundaryName == *it ) { A_faire = 0 ; }
2787 // Caracteristiques de la frontiere
2788 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2789 ASSERT(!CORBA::is_nil(myBoundary));
2790 int BoundaryType = myBoundary->GetType();
2791 MESSAGE ( "... BoundaryType = " << BoundaryType );
2792 // Ecriture selon le type
2793 if (BoundaryType == 0) // Cas d une frontiere discrete
2795 const char* MeshName = myBoundary->GetMeshName() ;
2796 const char* MeshFile = myBoundary->GetMeshFile() ;
2797 myDriver->TexteBoundaryDi( MeshName, MeshFile);
2798 BoundaryOption = BoundaryOption*2 ;
2800 else // Cas d une frontiere analytique
2802 NumBoundaryAnalytical++ ;
2803 HOMARD::double_array* coor = myBoundary->GetCoords();
2804 if (BoundaryType == 1) // Cas d un cylindre
2806 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2807 BoundaryOption = BoundaryOption*3 ;
2809 else if (BoundaryType == 2) // Cas d une sphere
2811 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
2812 BoundaryOption = BoundaryOption*3 ;
2814 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
2816 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2817 BoundaryOption = BoundaryOption*3 ;
2819 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
2821 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
2822 BoundaryOption = BoundaryOption*3 ;
2825 // Memorisation du traitement
2826 ListeBoundaryTraitees.push_back( BoundaryName );
2829 NumBoundaryAnalytical = 0 ;
2830 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2832 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2833 MESSAGE ( "... BoundaryName = " << BoundaryName);
2834 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2835 ASSERT(!CORBA::is_nil(myBoundary));
2836 int BoundaryType = myBoundary->GetType();
2837 MESSAGE ( "... BoundaryType = " << BoundaryType );
2838 // Recuperation du nom du groupe
2839 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
2840 MESSAGE ( "... GroupName = " << GroupName);
2841 if (BoundaryType == 0) // Cas d une frontiere discrete
2843 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
2845 else // Cas d une frontiere analytique
2847 NumBoundaryAnalytical++ ;
2848 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
2851 myDriver->TexteBoundaryOption(BoundaryOption);
2854 //=============================================================================
2855 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
2856 //=============================================================================
2857 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2859 MESSAGE ( "... DriverTexteFieldInterp" );
2860 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
2861 if (TypeFieldInterp != 0)
2863 // Le fichier des champs
2864 char* FieldFile = myIteration->GetFieldFile();
2865 MESSAGE ( ". FieldFile = " << FieldFile );
2866 if (strlen(FieldFile) == 0)
2868 // GERALD -- QMESSAGE BOX
2869 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2870 ASSERT("The file for the field is not given." == 0);
2872 // Les caracteristiques d'instants
2873 int TimeStep = myIteration->GetTimeStep();
2874 MESSAGE( ". TimeStep = " << TimeStep );
2875 int Rank = myIteration->GetRank();
2876 MESSAGE( ". Rank = " << Rank );
2878 const char* MeshFile = myIteration->GetMeshFile();
2879 myDriver->TexteFieldInterp(TypeFieldInterp, FieldFile, MeshFile, TimeStep, Rank);
2881 if (TypeFieldInterp == 2)
2883 HOMARD::listFieldInterpHypo* meschamps = myHypo->GetListFieldInterp();
2884 int numberOfFields = meschamps->length();
2885 MESSAGE( ". numberOfFields = " << numberOfFields );
2886 for (int NumeChamp = 0; NumeChamp< numberOfFields; NumeChamp++)
2888 std::string nomChamp = std::string((*meschamps)[NumeChamp]);
2889 MESSAGE( "... nomChamp = " << nomChamp );
2890 myDriver->TexteFieldInterpName(NumeChamp, nomChamp);
2896 //===========================================================================
2897 //===========================================================================
2900 //===========================================================================
2901 //===========================================================================
2903 //===========================================================================
2904 //===========================================================================
2905 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
2906 SALOMEDS::SObject_ptr theSObject,
2907 CORBA::Object_ptr theObject,
2908 const char* theName)
2910 MESSAGE("PublishInStudy pour " << theName);
2911 SALOMEDS::SObject_var aResultSO;
2912 if (CORBA::is_nil(theStudy))
2914 SALOME::ExceptionStruct es;
2915 es.type = SALOME::BAD_PARAM;
2916 es.text = "Invalid study context";
2917 throw SALOME::SALOME_Exception(es);
2921 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
2922 // Rq : Iteration est publiee ailleurs
2923 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
2924 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
2925 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
2926 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
2928 addInStudy(theStudy);
2930 // Controle de la non publication d'un objet de meme nom
2931 if ((!aHypo->_is_nil()) or (!aZone->_is_nil()) or (!aBoundary->_is_nil()))
2933 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
2934 if (listSO->length() >= 1)
2936 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
2937 std::cerr <<"This name "<<theName<<" is already used "<<listSO->length()<<" time(s)" << std::endl;
2938 aResultSO = listSO[0];
2939 return aResultSO._retn();
2943 // Caracteristiques de l'etude
2944 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
2945 aStudyBuilder->NewCommand();
2946 if(!aCase->_is_nil())
2947 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
2948 else if(!aHypo->_is_nil())
2949 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
2950 else if(!aZone->_is_nil())
2951 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
2952 else if(!aBoundary->_is_nil())
2953 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
2955 aStudyBuilder->CommitCommand();
2956 return aResultSO._retn();
2958 //=============================================================================
2959 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
2960 SALOMEDS::StudyBuilder_var aStudyBuilder,
2961 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
2963 MESSAGE("PublishCaseInStudy pour "<<theName);
2964 SALOMEDS::SObject_var aResultSO;
2965 SALOMEDS::GenericAttribute_var anAttr;
2967 if (CORBA::is_nil(theObject)) {
2968 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
2969 return aResultSO._retn();
2971 if (theStudy->_is_nil()) {
2972 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
2973 return aResultSO._retn();
2976 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
2977 if (theFatherHomard->_is_nil())
2979 MESSAGE("theFatherHomard->_is_nil()");
2980 return aResultSO._retn();
2983 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
2984 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
2985 _orb->object_to_string(theObject) ) ;
2986 return aResultSO._retn();
2989 //=============================================================================
2990 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
2991 SALOMEDS::StudyBuilder_var aStudyBuilder,
2992 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
2994 MESSAGE("PublishZoneStudy pour "<<theName);
2995 SALOMEDS::SObject_var aResultSO;
2996 SALOMEDS::GenericAttribute_var anAttr;
2998 if (CORBA::is_nil(theObject))
3000 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
3001 return aResultSO._retn();
3003 if (theStudy->_is_nil())
3005 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
3006 return aResultSO._retn();
3008 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3009 if (theFatherHomard->_is_nil())
3011 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
3012 return aResultSO._retn();
3015 // Caracteristique de la zone
3016 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
3017 CORBA::Long ZoneType = myZone->GetType();
3019 // On ajoute la categorie des zones dans l etude si necessaire
3020 SALOMEDS::SObject_var aSOZone;
3021 if (!theFatherHomard->FindSubObject(100, aSOZone))
3023 MESSAGE("Ajout de la categorie des zones");
3024 aSOZone = aStudyBuilder->NewObjectToTag(theFatherHomard, 100);
3025 PublishInStudyAttr(aStudyBuilder, aSOZone, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
3027 else { MESSAGE("La categorie des zones existe deja."); }
3029 aResultSO = aStudyBuilder->NewObject(aSOZone);
3038 { icone = "boxdxy_2.png" ;
3042 { icone = "boxdxyz_2.png" ;
3050 { icone = "disk_2.png" ;
3054 { icone = "spherepoint_2.png" ;
3058 { icone = "cylinderpointvector_2.png" ;
3066 { icone = "diskwithhole_2.png" ;
3070 { icone = "pipe_2.png" ;
3074 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone.c_str(), _orb->object_to_string(theObject) ) ;
3076 return aResultSO._retn();
3078 //=============================================================================
3079 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
3080 SALOMEDS::StudyBuilder_var aStudyBuilder,
3081 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
3083 MESSAGE("PublishBoundaryStudy pour "<<theName);
3084 SALOMEDS::SObject_var aResultSO;
3085 SALOMEDS::GenericAttribute_var anAttr;
3087 // Caracteristique de la Boundary
3088 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
3090 // On recupere le module pere dans l etude
3091 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3092 if (theFatherHomard->_is_nil())
3094 MESSAGE("theFatherHomard->_is_nil()");
3095 return aResultSO._retn();
3098 // On ajoute la categorie des boundarys dans l etude si necessaire
3099 SALOMEDS::SObject_var aSOBoundary;
3100 if (!theFatherHomard->FindSubObject(101, aSOBoundary))
3102 MESSAGE("Ajout de la categorie des boundarys");
3103 aSOBoundary = aStudyBuilder->NewObjectToTag(theFatherHomard, 101);
3104 PublishInStudyAttr(aStudyBuilder, aSOBoundary, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
3106 else { MESSAGE("La categorie des boundarys existe deja."); }
3108 aResultSO = aStudyBuilder->NewObject(aSOBoundary);
3109 CORBA::Long BoundaryType = myBoundary->GetType();
3110 // MESSAGE("BoundaryType : "<<BoundaryType);
3113 switch (BoundaryType)
3116 { value = "BoundaryDiHomard" ;
3117 icone = "mesh_tree_mesh.png" ;
3121 { value = "BoundaryAnHomard" ;
3122 icone = "cylinderpointvector_2.png" ;
3126 { value = "BoundaryAnHomard" ;
3127 icone = "spherepoint_2.png" ;
3131 { value = "BoundaryAnHomard" ;
3132 icone = "conepointvector.png" ;
3136 { value = "BoundaryAnHomard" ;
3137 icone = "conedxyz.png" ;
3141 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject));
3142 return aResultSO._retn();
3145 //=============================================================================
3146 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
3147 SALOMEDS::StudyBuilder_var aStudyBuilder,
3148 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
3150 MESSAGE("PublishHypotheseInStudy pour "<<theName);
3151 SALOMEDS::SObject_var aResultSO;
3152 SALOMEDS::GenericAttribute_var anAttr;
3154 // On recupere le module pere dans l etude
3155 // On ajoute la categorie des hypotheses dans l etude si necessaire
3156 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
3157 if (theFatherHomard->_is_nil())
3159 MESSAGE("theFatherHomard->_is_nil()");
3160 return aResultSO._retn();
3162 SALOMEDS::SObject_var aSOHypothese;
3163 if (!theFatherHomard->FindSubObject(0, aSOHypothese))
3165 MESSAGE("Ajout de la categorie des hypotheses");
3166 aSOHypothese = aStudyBuilder->NewObjectToTag(theFatherHomard, 0);
3167 PublishInStudyAttr(aStudyBuilder, aSOHypothese, "Hypothesis", "HypoList","hypotheses.png", NULL);
3169 else { MESSAGE("La categorie des hypotheses existe deja."); }
3171 // Creation du resultat dans l'etude
3172 aResultSO = aStudyBuilder->NewObject(aSOHypothese);
3173 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
3175 return aResultSO._retn();
3177 //===========================================================================
3178 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
3179 SALOMEDS::SObject_var aResultSO,
3180 const char* name, const char* value, const char* icone, const char* ior)
3182 SALOMEDS::GenericAttribute_var anAttr ;
3186 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
3187 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
3188 aNameAttrib->SetValue(name);
3191 // Ajout du commentaire
3192 if ( value != NULL )
3194 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
3195 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
3196 aCommentAttrib->SetValue(value);
3200 if ( icone != NULL )
3202 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO,"AttributePixMap");
3203 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
3204 aPixmap->SetPixMap(icone);
3210 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
3211 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
3212 anIOR->SetValue(ior);
3216 //=====================================================================================
3217 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
3219 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
3221 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
3222 ASSERT(!CORBA::is_nil(myCase));
3223 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
3224 ASSERT(!CORBA::is_nil(aCaseSO));
3226 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
3227 ASSERT(!CORBA::is_nil(myBoundary));
3228 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
3229 ASSERT(!CORBA::is_nil(aBoundarySO));
3231 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3233 aStudyBuilder->NewCommand();
3235 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
3236 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
3238 aStudyBuilder->CommitCommand();
3241 //=============================================================================
3242 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
3243 // Option = 0 : fichier issu d'une importation
3244 // Option = 1 : fichier issu d'une execution HOMARD
3246 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
3247 if (CORBA::is_nil(myCurrentStudy))
3249 SALOME::ExceptionStruct es;
3250 es.type = SALOME::BAD_PARAM;
3251 es.text = "Invalid study context";
3252 throw SALOME::SALOME_Exception(es);
3256 // Le module SMESH est-il actif ?
3257 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3259 if (!CORBA::is_nil(aSmeshSO))
3261 // On verifie que le fichier n est pas deja publie
3262 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3263 for (; aIter->More(); aIter->Next())
3265 SALOMEDS::SObject_var aSO = aIter->Value();
3266 SALOMEDS::GenericAttribute_var aGAttr;
3267 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3269 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3270 CORBA::String_var value=anAttr->Value();
3271 if (strcmp((const char*)value,NomFich) == 0)
3273 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
3274 // Pour un fichier importe, on ne republie pas
3279 // Pour un fichier calcule, on commence par faire la depublication
3282 MESSAGE ( "PublishResultInSmesh : depublication" );
3283 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3284 CORBA::String_var value2=anAttr2->Value();
3285 const char* MeshName = value2 ;
3286 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
3287 DeleteResultInSmesh(NomFich, MeshName) ;
3294 // On enregistre le fichier
3295 MESSAGE( "Enregistrement du fichier");
3296 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
3297 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
3298 ASSERT(!CORBA::is_nil(aSmeshEngine));
3299 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
3300 SMESH::DriverMED_ReadStatus theStatus;
3301 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3303 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
3304 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
3305 for (int i = 0; i < mesMaillages->length(); i++)
3307 MESSAGE( ". Mise a jour des attributs du maillage");
3308 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
3309 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
3310 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3311 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
3312 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3313 anAttr->SetValue(NomFich);
3314 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
3315 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
3317 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
3318 else { icone = "mesh_tree_mesh.png" ; }
3319 anAttr2->SetPixMap( icone );
3323 //=============================================================================
3324 void HOMARD_Gen_i::DeleteResultInSmesh(const char* NomFich, const char* MeshName)
3326 MESSAGE (" DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
3327 if (CORBA::is_nil(myCurrentStudy))
3329 SALOME::ExceptionStruct es;
3330 es.type = SALOME::BAD_PARAM;
3331 es.text = "Invalid study context";
3332 throw SALOME::SALOME_Exception(es);
3336 // Le module SMESH est-il actif ?
3337 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
3339 if (CORBA::is_nil(aSmeshSO))
3343 // On verifie que le fichier est deja publie
3344 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
3345 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
3346 for (; aIter->More(); aIter->Next())
3348 SALOMEDS::SObject_var aSO = aIter->Value();
3349 SALOMEDS::GenericAttribute_var aGAttr;
3350 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
3352 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
3353 CORBA::String_var value=anAttr->Value();
3354 if (strcmp((const char*)value,NomFich) == 0)
3356 if (aSO->FindAttribute(aGAttr,"AttributeName"))
3358 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
3359 CORBA::String_var value2=anAttr2->Value();
3360 if (strcmp((const char*)value2,MeshName) == 0)
3362 myBuilder->RemoveObjectWithChildren( aSO ) ;
3370 //=============================================================================
3371 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
3373 // MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
3374 if (CORBA::is_nil(myCurrentStudy))
3376 SALOME::ExceptionStruct es;
3377 es.type = SALOME::BAD_PARAM;
3378 es.text = "Invalid study context";
3379 throw SALOME::SALOME_Exception(es);
3383 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
3384 if (CORBA::is_nil(myIteration))
3386 SALOME::ExceptionStruct es;
3387 es.type = SALOME::BAD_PARAM;
3388 es.text = "Invalid iteration";
3389 throw SALOME::SALOME_Exception(es);
3392 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
3393 if (CORBA::is_nil(myIteration))
3395 SALOME::ExceptionStruct es;
3396 es.type = SALOME::BAD_PARAM;
3397 es.text = "Invalid iterationStudy Object";
3398 throw SALOME::SALOME_Exception(es);
3402 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
3404 aStudyBuilder->NewCommand();
3406 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
3407 // Pour les fichiers med, on affiche une icone de maillage
3408 // Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte'
3409 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
3411 std::string ior = " " ;
3412 if ( Commentaire[0] == 'I' )
3413 { icone = "med.png" ; }
3415 { icone = "texte_2.png" ; }
3416 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ;
3418 aStudyBuilder->CommitCommand();
3420 //=============================================================================
3421 //=============================================================================
3423 //=============================================================================
3424 //=============================================================================
3425 // Next functions are inherited from SALOMEDS::Driver interface
3426 //=============================================================================
3427 //=============================================================================
3428 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
3430 CORBA::Boolean isMultiFile)
3432 MESSAGE (" Save for theURL = "<< theURL);
3433 SALOMEDS::TMPFile_var aStreamFile;
3435 // get temporary directory name
3436 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3438 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3439 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3441 // HOMARD data file name
3442 std::string aFileName = "";
3444 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3445 aFileName += "_HOMARD.dat";
3447 // initialize sequence of file names
3448 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
3449 aFileSeq->length(1);
3450 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
3452 // get full path to the data file
3453 aFileName = tmpDir + aFileName;
3457 std::ofstream f(aFileName.c_str());
3459 // clear temporary id map
3460 context._idmap.clear();
3465 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
3466 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
3467 HOMARD::HOMARD_Cas_var aCas = it_case->second;
3468 PortableServer::ServantBase_var aServant = GetServant(aCas);
3469 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3471 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
3472 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
3476 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3477 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
3478 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
3479 PortableServer::ServantBase_var aServant = GetServant(aZone);
3480 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3482 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
3483 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3486 // -> save hypotheses
3487 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3488 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
3489 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
3490 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3491 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3493 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
3494 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3497 // -> save iterations
3498 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3499 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
3500 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
3501 PortableServer::ServantBase_var aServant = GetServant(aIter);
3502 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3504 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
3505 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3508 // -> save boundaries
3509 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3510 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
3511 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
3512 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3513 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3514 if (aBoundaryServant) {
3515 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
3516 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3520 MESSAGE ("close file");
3523 // put temporary files to the stream
3524 MESSAGE ("put temporary files to the stream");
3525 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
3527 // remove temporary files
3528 MESSAGE ("remove temporary files");
3529 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3531 // return data stream
3532 MESSAGE ("return data stream");
3533 return aStreamFile._retn();
3536 //===========================================================================
3537 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
3539 CORBA::Boolean isMultiFile)
3541 // No specific ASCII persistence
3542 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
3543 return aStreamFile._retn();
3546 //===========================================================================
3547 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
3548 const SALOMEDS::TMPFile& theStream,
3550 CORBA::Boolean isMultiFile)
3552 MESSAGE (" Load pour theURL = "<< theURL);
3553 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3555 // set current study
3556 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
3557 SetCurrentStudy(aStudy);
3559 // get temporary directory name
3560 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3562 // Convert the stream into sequence of files to process
3563 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
3566 // HOMARD data file name
3567 std::string aFileName = "";
3569 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3570 aFileName = tmpDir + aFileName + "_HOMARD.dat";
3572 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3576 std::ifstream f(aFileName.c_str());
3579 context._mesCas.clear();
3580 context._mesHypotheses.clear();
3581 context._mesIterations.clear();
3582 context._mesZones.clear();
3583 context._mesBoundarys.clear();
3584 context._idmap.clear();
3590 std::getline(f, line);
3591 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
3592 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
3593 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
3594 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
3595 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
3596 if (line.substr(0, caseSignature.size()) == caseSignature) {
3598 MESSAGE (" Recreation du cas" );
3599 HOMARD::HOMARD_Cas_var aCase = newCase();
3600 PortableServer::ServantBase_var aServant = GetServant(aCase);
3601 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3602 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
3603 context._mesCas[aCase->GetName()] = aCase;
3604 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
3607 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
3608 MESSAGE (" Recreation de la zone" );
3610 HOMARD::HOMARD_Zone_var aZone = newZone();
3611 PortableServer::ServantBase_var aServant = GetServant(aZone);
3612 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3613 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
3614 context._mesZones[aZone->GetName()] = aZone;
3615 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3618 else if (line.substr(0, iterSignature.size()) == iterSignature) {
3619 // re-create iteration
3620 MESSAGE (" Recreation de l iteration" );
3621 HOMARD::HOMARD_Iteration_var aIter = newIteration();
3622 PortableServer::ServantBase_var aServant = GetServant(aIter);
3623 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3624 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
3625 context._mesIterations[aIter->GetName()] = aIter;
3626 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3629 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
3630 // re-create hypothesis
3631 MESSAGE (" Recreation de l hypothese" );
3632 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
3633 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3634 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3635 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
3636 context._mesHypotheses[aHypo->GetName()] = aHypo;
3637 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3640 else if (line.substr(0, bounSignature.size()) == bounSignature) {
3641 // re-create boundary
3642 MESSAGE (" Recreation de la frontiere" );
3643 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
3644 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3645 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3646 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
3647 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
3648 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3657 // Remove temporary files created from the stream
3659 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3664 //===========================================================================
3665 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
3666 const SALOMEDS::TMPFile& theStream,
3668 CORBA::Boolean isMultiFile)
3670 // No specific ASCII persistence
3671 return Load(theComponent, theStream, theURL, isMultiFile);
3674 //===========================================================================
3675 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
3677 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
3678 // clearing study context should be done here:
3679 // - destroy all servants and related CORBA objects
3681 // - remove context from myContextMap
3682 myContextMap.erase(theComponent->GetStudy()->StudyId());
3683 // - nullify myCurrentStudy
3684 myCurrentStudy = SALOMEDS::Study::_nil();
3688 //===========================================================================
3689 char* HOMARD_Gen_i::ComponentDataType()
3691 return CORBA::string_dup("HOMARD");
3694 //===========================================================================
3695 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
3696 const char* IORString,
3697 CORBA::Boolean isMultiFile,
3698 CORBA::Boolean isASCII)
3700 CORBA::String_var aString("");
3701 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
3702 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3703 CORBA::Object_var anObj = _orb->string_to_object(IORString);
3704 if (!CORBA::is_nil(anObj)) {
3705 PortableServer::ServantBase_var aServant = GetServant(anObj);
3706 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
3708 std::map<int, PortableServer::ServantBase*>::const_iterator it;
3709 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
3710 if (it->second == aStorable) {
3711 std::stringstream os;
3713 aString = CORBA::string_dup(os.str().c_str());
3719 return aString._retn();
3722 //===========================================================================
3723 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
3724 const char* aLocalPersistentID,
3725 CORBA::Boolean isMultiFile,
3726 CORBA::Boolean isASCII)
3728 CORBA::String_var aString("");
3729 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
3730 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3731 int id = atoi(aLocalPersistentID);
3732 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
3733 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
3734 if (!CORBA::is_nil(object)) {
3735 aString = _orb->object_to_string(object);
3739 return aString._retn();
3742 //===========================================================================
3743 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
3745 if(CORBA::is_nil(myCurrentStudy))
3748 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
3749 if(!aCas->_is_nil())
3752 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
3753 if(!aHypo->_is_nil())
3756 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
3757 if(!aZone->_is_nil())
3760 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
3761 if(!aBoundary->_is_nil())
3764 /* Iteration is not published directly
3765 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
3766 if(!aIter->_is_nil())
3772 //===========================================================================
3773 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
3775 // No Copy/Paste support
3779 //===========================================================================
3780 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
3781 CORBA::Long& theObjectID)
3783 // No Copy/Paste support
3784 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
3785 return aStreamFile._retn();
3788 //===========================================================================
3789 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
3790 CORBA::Long theObjectID)
3792 // No Copy/Paste support
3796 //===========================================================================
3797 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
3798 CORBA::Long theObjectID,
3799 SALOMEDS::SObject_ptr theSObject)
3801 // No Copy/Paste support
3802 SALOMEDS::SObject_var aResultSO;
3803 return aResultSO._retn();
3806 //===========================================================================
3807 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
3809 PortableServer::Servant aServant = 0;
3810 if (!CORBA::is_nil(theObject)) {
3812 aServant = _poa->reference_to_servant(theObject);
3820 //==========================================================================
3821 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
3822 CORBA::Boolean isPublished,
3823 CORBA::Boolean isMultiFile,
3824 CORBA::Boolean& isValidScript)
3826 MESSAGE ("Entree dans DumpPython");
3828 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
3829 if(CORBA::is_nil(aStudy))
3830 return new Engines::TMPFile(0);
3832 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
3833 if(CORBA::is_nil(aSO))
3834 return new Engines::TMPFile(0);
3836 std::string aScript = "\"\"\"\n";
3837 aScript += "Python script for HOMARD\n";
3838 aScript += "Copyright EDF-R&D 2013\n";
3839 aScript += "\"\"\"\n";
3840 aScript += "__revision__ = \"V1.2\"\n";
3841 aScript += "import HOMARD\n";
3843 aScript += "import salome\n";
3844 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
3846 aScript += "def RebuildData(theStudy):\n";
3847 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
3850 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
3851 MESSAGE (". Au depart \n"<<aScript);
3854 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
3856 MESSAGE (". Ecritures des frontieres");
3857 aScript += "#\n# Creation of the boundaries";
3858 aScript += "\n# ==========================";
3860 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3861 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
3862 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
3864 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
3865 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
3866 std::string dumpBoundary = dumpCorbaBoundary.in();
3867 MESSAGE (dumpBoundary<<"\n");
3868 aScript += dumpBoundary;
3872 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
3874 MESSAGE (". Ecritures des zones");
3875 aScript += "#\n# Creation of the zones";
3876 aScript += "\n# =====================";
3878 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3879 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
3880 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
3882 HOMARD::HOMARD_Zone_var maZone = (*it_zone).second;
3883 CORBA::String_var dumpCorbaZone = maZone->GetDumpPython();
3884 std::string dumpZone = dumpCorbaZone.in();
3885 MESSAGE (dumpZone<<"\n");
3886 aScript += dumpZone;
3890 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
3892 MESSAGE (". Ecritures des hypotheses");
3893 aScript += "#\n# Creation of the hypotheses";
3894 aScript += "\n# ==========================";
3896 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3897 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
3898 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
3900 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
3901 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
3902 std::string dumpHypo = dumpCorbaHypo.in();
3903 MESSAGE (dumpHypo<<"\n");
3904 aScript += dumpHypo;
3908 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
3910 MESSAGE (". Ecritures des cas");
3911 aScript += "#\n# Creation of the cases";
3912 aScript += "\n# =====================";
3914 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
3915 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
3916 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
3918 std::string nomCas = (*it_cas).first;
3919 std::string dumpCas = std::string("\n# Creation of the case ") ;
3920 dumpCas += nomCas + std::string("\n");
3921 dumpCas += std::string("\t") + nomCas;
3922 dumpCas += std::string(" = homard.CreateCase('") + nomCas + std::string("', '");
3924 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
3925 CORBA::String_var cIter0= myCase->GetIter0Name();
3926 std::string iter0 = cIter0.in();
3928 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
3929 CORBA::String_var cMesh0= myIteration->GetMeshFile();
3930 std::string mesh0 = cMesh0.in();
3931 CORBA::String_var cMeshName0= myIteration->GetMeshName();
3932 std::string meshName0 = cMeshName0.in();
3933 dumpCas += meshName0 + std::string("', '")+ mesh0 + std::string("')\n");
3934 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
3935 std::string dumpCas2= dumpCorbaCase.in();
3937 MESSAGE (dumpCas<<dumpCas2<<"\n");
3938 aScript += dumpCas + dumpCas2;
3942 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
3944 MESSAGE (". Ecritures des iterations");
3945 aScript += "#\n# Creation of the iterations" ;
3946 aScript += "\n# ==========================";
3948 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3949 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
3950 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
3952 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
3953 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
3954 std::string dumpIter = dumpCorbaIter.in();
3955 MESSAGE (dumpIter<<"\n");
3956 aScript += dumpIter;
3959 MESSAGE (". Ecritures finales");
3961 aScript += "\n\tpass";
3964 if( !isMultiFile ) // remove unnecessary tabulation
3965 aScript = RemoveTabulation( aScript );
3967 // MESSAGE ("A ecrire \n"<<aScript);
3968 const size_t aLen = strlen(aScript.c_str());
3969 char* aBuffer = new char[aLen+1];
3970 strcpy(aBuffer, aScript.c_str());
3972 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
3973 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
3975 MESSAGE ("Sortie de DumpPython");
3976 return aStreamFile._retn();
3980 //=============================================================================
3981 //=============================================================================
3983 //=============================================================================
3984 //=============================================================================
3985 void HOMARD_Gen_i::IsValidStudy( )
3987 // MESSAGE( "IsValidStudy" );
3988 if (CORBA::is_nil(myCurrentStudy))
3990 SALOME::ExceptionStruct es;
3991 es.type = SALOME::BAD_PARAM;
3992 es.text = "Invalid study context";
3993 throw SALOME::SALOME_Exception(es);
3998 //=============================================================================
3999 CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir)
4001 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
4002 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
4003 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
4005 if (std::string(nomDir) == std::string(it->second->GetDirName())) return false;
4009 /*//=============================================================================
4010 void SALOMEException( std::string message )
4012 SALOME::ExceptionStruct es;
4013 es.type = SALOME::BAD_PARAM;
4015 throw SALOME::SALOME_Exception(es);
4018 //=============================================================================
4019 char* HOMARD_Gen_i::getVersion()
4021 #if HOMARD_DEVELOPMENT
4022 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
4024 return CORBA::string_dup(HOMARD_VERSION_STR);
4028 //=============================================================================
4031 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
4032 PortableServer::POA_ptr poa,
4033 PortableServer::ObjectId* contId,
4034 const char* instanceName,
4035 const char* interfaceName)
4037 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
4038 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
4039 return myHOMARD_Gen->getId();