1 // Copyright (C) 2011-2012 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)
55 //=============================================================================
57 //=============================================================================
58 std::string RemoveTabulation( std::string theScript )
60 std::string::size_type aPos = 0;
61 while( aPos < theScript.length() )
63 aPos = theScript.find( "\n\t", aPos );
64 if( aPos == std::string::npos )
66 theScript.replace( aPos, 2, "\n" );
71 //=============================================================================
73 * standard constructor
75 //=============================================================================
76 HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb,
77 PortableServer::POA_ptr poa,
78 PortableServer::ObjectId * contId,
79 const char *instanceName,
80 const char *interfaceName) :
81 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
83 MESSAGE("constructor");
85 _id = _poa->activate_object(_thisObj);
87 myHomard = new ::HOMARD_Gen();
88 _NS = SINGLETON_<SALOME_NamingService>::Instance();
89 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
92 //=================================
96 //================================
97 HOMARD_Gen_i::~HOMARD_Gen_i()
100 //=============================================================================
101 //=============================================================================
102 // Utilitaires pour l'étude
103 //=============================================================================
104 //=============================================================================
105 void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy)
107 ASSERT(!CORBA::is_nil(theStudy));
108 MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ;
109 SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder();
111 // Create SComponent labelled 'homard' if it doesn't already exit
112 SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType());
113 if (CORBA::is_nil(homardFather))
115 myBuilder->NewCommand();
116 MESSAGE("Add Component HOMARD");
118 bool aLocked = theStudy->GetProperties()->IsLocked();
119 if (aLocked) theStudy->GetProperties()->SetLocked(false);
121 homardFather = myBuilder->NewComponent(ComponentDataType());
122 SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
123 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
124 CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
125 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
126 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
127 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
128 if (!Comp->_is_nil())
130 aName->SetValue(ComponentDataType());
133 anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributePixMap");
134 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
135 aPixmap->SetPixMap("HOMARD_2.png");
136 myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this());
138 if (aLocked) theStudy->GetProperties()->SetLocked(true);
139 myBuilder->CommitCommand();
142 //=============================================================================
143 void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
145 MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID());
146 myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy);
147 this->addInStudy(myCurrentStudy);
149 //=============================================================================
150 SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy()
151 //=============================================================================
153 MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID());
154 return SALOMEDS::Study::_duplicate(myCurrentStudy);
156 //=============================================================================
157 CORBA::Long HOMARD_Gen_i::GetCurrentStudyID()
158 //=============================================================================
160 return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId();
162 //=============================================================================
163 //=============================================================================
165 //=============================================================================
166 //=============================================================================
167 // Utilitaires pour l'iteration
168 //=============================================================================
169 //=============================================================================
170 void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Boolean EtatCalcul)
171 //=====================================================================================
173 MESSAGE( "SetEtatIter : affectation de l'etat '" << EtatCalcul << "' a l'iteration " << nomIter );
174 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
175 if (CORBA::is_nil(myIteration))
177 SALOME::ExceptionStruct es;
178 es.type = SALOME::BAD_PARAM;
179 es.text = "Invalid iteration";
180 throw SALOME::SALOME_Exception(es);
184 myIteration->SetEtat(EtatCalcul);
186 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
187 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
189 int number = myIteration->GetNumber() ;
192 icone = "iter0.png" ;
194 icone = "iter_calculee.png" ;
196 icone = "iter_non_calculee.png" ;
197 PublishInStudyAttr(aStudyBuilder, aIterSO, NULL , NULL, icone, 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 number = myIteration->GetNumber();
582 SetEtatIter(nomIter,false);
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* dirCase = myCase->GetDirName();
594 const char* nomDir = myIteration->GetDirName();
595 const char* nomFichier = myIteration->GetMeshFile();
596 std::string commande= "rm -rf " + std::string(dirCase) + "/" + std::string(nomDir);
597 if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; }
598 MESSAGE ( "commande = " << commande );
599 if ((system(commande.c_str())) != 0)
601 SALOME::ExceptionStruct es;
602 es.type = SALOME::BAD_PARAM;
603 es.text = "The directory for the calculation cannot be cleared." ;
604 throw SALOME::SALOME_Exception(es);
607 // Suppression du maillage publie dans SMESH
608 const char* MeshName = myIteration->GetMeshName() ;
609 DeleteResultInSmesh(nomFichier, MeshName) ;
613 //=============================================================================
614 void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter)
616 MESSAGE("InvalideIterInfo : nomIter = " << nomIter);
617 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
618 if (CORBA::is_nil(myIteration))
620 SALOME::ExceptionStruct es;
621 es.type = SALOME::BAD_PARAM;
622 es.text = "Invalid iteration";
623 throw SALOME::SALOME_Exception(es);
627 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
628 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO);
629 for (; aIter->More(); aIter->Next())
631 SALOMEDS::SObject_var so = aIter->Value();
632 SALOMEDS::GenericAttribute_var anAttr;
633 if (!so->FindAttribute(anAttr, "AttributeComment")) continue;
634 SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr);
635 std::string value (aCommentAttr->Value());
636 /* MESSAGE("... value = " << value);*/
637 if( (value == std::string("logInfo")) or ( value == std::string("SummaryInfo")) )
639 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
640 aStudyBuilder->RemoveObject(so);
644 const char * nomCas = myIteration->GetCaseName();
645 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
646 if (CORBA::is_nil(myCase))
648 SALOME::ExceptionStruct es;
649 es.type = SALOME::BAD_PARAM;
650 es.text = "Invalid case context";
651 throw SALOME::SALOME_Exception(es);
654 const char* dirCase = myCase->GetDirName();
655 const char* nomDir = myIteration->GetDirName();
656 std::string commande = "rm -f " + std::string(dirCase) + "/" + std::string(nomDir) + "/info* " ;
657 commande += std::string(dirCase) + "/" + std::string(nomDir) + "/Liste.*info" ;
658 /* MESSAGE ( "commande = " << commande );*/
659 if ((system(commande.c_str())) != 0)
661 SALOME::ExceptionStruct es;
662 es.type = SALOME::BAD_PARAM;
663 es.text = "The directory for the calculation cannot be cleared." ;
664 throw SALOME::SALOME_Exception(es);
669 //=============================================================================
670 void HOMARD_Gen_i::InvalideZone(const char* ZoneName)
672 MESSAGE( "InvalideZone : ZoneName = " << ZoneName );
673 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
674 if (CORBA::is_nil(myZone))
676 SALOME::ExceptionStruct es;
677 es.type = SALOME::BAD_PARAM;
678 es.text = "Invalid zone";
679 throw SALOME::SALOME_Exception(es);
682 HOMARD::listeHypo* maListe = myZone->GetHypo();
683 int numberOfHypo = maListe->length();
684 MESSAGE( ".. numberOfHypo = " << numberOfHypo );
685 for (int NumeHypo = 0; NumeHypo< numberOfHypo; NumeHypo++)
687 std::string nomHypo = std::string((*maListe)[NumeHypo]);
688 MESSAGE( ".. nomHypo = " << nomHypo );
689 InvalideHypo(nomHypo.c_str());
692 //=============================================================================
693 //=============================================================================
695 //=============================================================================
696 //=============================================================================
697 // Association de lien entre des structures identifiees par leurs noms
698 //=============================================================================
699 //=============================================================================
700 void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, const char* labelIter)
702 MESSAGE( "AssociateCaseIter : " << nomCas << " ," << nomIter << "," << labelIter );
704 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
705 if (CORBA::is_nil(myCase))
707 SALOME::ExceptionStruct es;
708 es.type = SALOME::BAD_PARAM;
709 es.text = "Invalid case";
710 throw SALOME::SALOME_Exception(es);
714 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
715 if (CORBA::is_nil(myIteration))
717 SALOME::ExceptionStruct es;
718 es.type = SALOME::BAD_PARAM;
719 es.text = "Invalid iteration";
720 throw SALOME::SALOME_Exception(es);
724 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
725 SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
726 if (CORBA::is_nil(aCasSO))
728 SALOME::ExceptionStruct es;
729 es.type = SALOME::BAD_PARAM;
730 es.text = "Invalid case";
731 throw SALOME::SALOME_Exception(es);
735 aStudyBuilder->NewCommand();
736 SALOMEDS::SObject_var newStudyIter = aStudyBuilder->NewObject(aCasSO);
737 PublishInStudyAttr(aStudyBuilder, newStudyIter, nomIter , labelIter,
738 "iter_non_calculee.png", _orb->object_to_string(myIteration)) ;
739 aStudyBuilder->CommitCommand();
741 myCase->AddIteration(nomIter);
742 myIteration->SetCaseName(nomCas);
744 //=====================================================================================
745 void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* ZoneName, CORBA::Long TypeUse)
747 MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse);
749 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
750 ASSERT(!CORBA::is_nil(myHypo));
751 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
752 ASSERT(!CORBA::is_nil(aHypoSO));
754 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
755 ASSERT(!CORBA::is_nil(myZone));
756 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
757 ASSERT(!CORBA::is_nil(aZoneSO));
759 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
761 aStudyBuilder->NewCommand();
763 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aHypoSO);
764 aStudyBuilder->Addreference(aSubSO, aZoneSO);
766 aStudyBuilder->CommitCommand();
768 myZone->AddHypo(nomHypothesis);
769 myHypo->AddZone0(ZoneName, TypeUse);
771 //=============================================================================
772 void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo)
774 MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter);
776 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
777 ASSERT(!CORBA::is_nil(myHypo));
778 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
779 ASSERT(!CORBA::is_nil(aHypoSO));
781 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter];
782 ASSERT(!CORBA::is_nil(myIteration));
783 SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
784 ASSERT(!CORBA::is_nil(aIterSO));
786 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
788 aStudyBuilder->NewCommand();
790 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
791 aStudyBuilder->Addreference(aSubSO, aHypoSO);
793 aStudyBuilder->CommitCommand();
795 myIteration->SetHypoName(nomHypo);
796 myHypo->LinkIteration(nomIter);
798 //=============================================================================
799 //=============================================================================
801 //=============================================================================
802 //=============================================================================
803 // Dissociation de lien entre des structures identifiees par leurs noms
804 //=============================================================================
805 //=============================================================================
806 void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* ZoneName)
808 MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis);
810 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
811 ASSERT(!CORBA::is_nil(myHypo));
812 SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo)));
813 ASSERT(!CORBA::is_nil(aHypoSO));
815 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
816 ASSERT(!CORBA::is_nil(myZone));
817 SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone)));
818 ASSERT(!CORBA::is_nil(aZoneSO));
820 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
822 SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO);
823 for (; it->More(); it->Next())
825 SALOMEDS::SObject_var aHypObj = it->Value();
826 SALOMEDS::SObject_var ptrObj;
827 if (aHypObj->ReferencedObject(ptrObj))
829 if (std::string(ptrObj->GetName()) == std::string(aZoneSO->GetName()))
831 aStudyBuilder->NewCommand();
832 aStudyBuilder->RemoveObject(aHypObj);
833 aStudyBuilder->CommitCommand();
839 myZone->SupprHypo(nomHypothesis);
840 myHypo->SupprZone(ZoneName);
842 //=============================================================================
843 //=============================================================================
846 //=============================================================================
847 //=============================================================================
848 // Recuperation des listes
849 //=============================================================================
850 //=============================================================================
851 HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName()
853 MESSAGE("GetAllCasesName");
856 HOMARD::listeCases_var ret = new HOMARD::listeCases;
857 ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size());
858 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
860 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
861 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
863 ret[i++] = CORBA::string_dup((*it).first.c_str());
868 //=============================================================================
869 HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName()
871 MESSAGE("GetAllHypothesesName");
874 HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses;
875 ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size());
876 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it;
878 for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
879 it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++)
881 ret[i++] = CORBA::string_dup((*it).first.c_str());
886 //=============================================================================
887 HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName()
889 MESSAGE("GetAllZonesName");
892 HOMARD::listeZones_var ret = new HOMARD::listeZones;
893 ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size());
894 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it;
896 for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin();
897 it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++)
899 ret[i++] = CORBA::string_dup((*it).first.c_str());
904 //=============================================================================
905 HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName()
907 MESSAGE("GetAllIterationsName");
910 HOMARD::listeIterations_var ret = new HOMARD::listeIterations;
911 ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size());
912 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it;
914 for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
915 it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++)
917 ret[i++] = CORBA::string_dup((*it).first.c_str());
922 //=============================================================================
923 HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName()
925 MESSAGE("GetAllBoundarysName");
928 HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys;
929 ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size());
930 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it;
932 for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
933 it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++)
935 ret[i++] = CORBA::string_dup((*it).first.c_str());
940 //=============================================================================
941 //=============================================================================
943 //=============================================================================
944 //=============================================================================
945 // Recuperation des structures identifiees par leurs noms
946 //=============================================================================
947 //=============================================================================
948 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas)
950 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
951 ASSERT(!CORBA::is_nil(myCase));
952 return HOMARD::HOMARD_Cas::_duplicate(myCase);
954 //=============================================================================
955 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName)
957 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
958 ASSERT(!CORBA::is_nil(myZone));
959 return HOMARD::HOMARD_Zone::_duplicate(myZone);
961 //=============================================================================
962 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis)
964 HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis];
965 ASSERT(!CORBA::is_nil(myHypothesis));
966 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
968 //=============================================================================
969 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation)
971 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation];
972 ASSERT(!CORBA::is_nil(myIteration));
973 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
975 //=============================================================================
976 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary)
978 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary];
979 ASSERT(!CORBA::is_nil(myBoundary));
980 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
982 //=============================================================================
983 //=============================================================================
985 //=============================================================================
986 //=============================================================================
988 //=============================================================================
989 //=============================================================================
990 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)
992 MESSAGE ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
993 MESSAGE ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte );
997 HOMARD::HOMARD_Cas_ptr myCase = CreateCase(nomCas, MeshName, MeshFile) ;
998 myCase->SetDirName(DirName) ;
1000 myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ;
1004 //=============================================================================
1005 //=============================================================================
1007 //=============================================================================
1008 //=============================================================================
1009 // Recuperation des structures par le contexte
1010 //=============================================================================
1011 //=============================================================================
1012 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas)
1014 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1015 ASSERT(!CORBA::is_nil(myCase));
1017 HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration();
1018 ASSERT(!CORBA::is_nil(myIteration));
1020 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1022 //=============================================================================
1023 //=============================================================================
1025 //=============================================================================
1026 //=============================================================================
1027 // Nouvelles structures
1028 //=============================================================================
1029 //=============================================================================
1030 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::newCase()
1032 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1033 HOMARD_Cas_i* aServant = new HOMARD_Cas_i(_orb, engine);
1034 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(aServant->_this());
1035 return aCase._retn();
1037 //=============================================================================
1038 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::newHypothesis()
1040 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1041 HOMARD_Hypothesis_i* aServant = new HOMARD_Hypothesis_i(_orb, engine);
1042 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(aServant->_this());
1043 return aHypo._retn();
1045 //=============================================================================
1046 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::newIteration()
1048 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1049 HOMARD_Iteration_i* aServant = new HOMARD_Iteration_i(_orb, engine);
1050 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(aServant->_this());
1051 return aIter._retn();
1053 //=============================================================================
1054 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::newBoundary()
1056 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1057 HOMARD_Boundary_i* aServant = new HOMARD_Boundary_i(_orb, engine);
1058 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(aServant->_this());
1059 return aBoundary._retn();
1061 //=============================================================================
1062 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone()
1064 HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this();
1065 HOMARD_Zone_i* aServant = new HOMARD_Zone_i(_orb, engine);
1066 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(aServant->_this());
1067 return aZone._retn();
1069 //=============================================================================
1070 //=============================================================================
1072 //=============================================================================
1073 //=============================================================================
1074 // Creation des structures identifiees par leurs noms
1075 //=============================================================================
1076 //=============================================================================
1077 HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* MeshName, const char* MeshFile)
1079 MESSAGE ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile );
1082 if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end())
1084 SALOME::ExceptionStruct es;
1085 es.type = SALOME::BAD_PARAM;
1086 es.text = "This case has already been defined.";
1087 throw SALOME::SALOME_Exception(es);
1091 int existe = MEDFileExist ( MeshFile ) ;
1094 SALOME::ExceptionStruct es;
1095 es.type = SALOME::BAD_PARAM;
1096 es.text = "The mesh file does not exist.";
1097 throw SALOME::SALOME_Exception(es);
1101 HOMARD::HOMARD_Cas_var myCase = newCase();
1102 myCase->SetName(nomCas);
1103 SALOMEDS::SObject_var aSO;
1104 PublishInStudy(myCurrentStudy, aSO, myCase, nomCas);
1105 myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase;
1107 std::vector<double> LesExtremes =GetBoundingBoxInMedFile(MeshFile);
1108 HOMARD::extrema_var aSeq = new HOMARD::extrema();
1109 if (LesExtremes.size()!=10) { return false; }
1111 for (int i =0; i< LesExtremes.size(); i++)
1112 aSeq[i]=LesExtremes[i];
1113 myCase->SetBoundingBox(aSeq);
1115 std::set<std::string> LesGroupes =GetListeGroupesInMedFile(MeshFile);
1116 HOMARD::ListGroupType_var aSeqGroupe = new HOMARD::ListGroupType;
1117 aSeqGroupe->length(LesGroupes.size());
1118 std::set<std::string>::const_iterator it;
1120 for (it=LesGroupes.begin() ; it != LesGroupes.end(); it++)
1121 aSeqGroupe[i++]=(*it).c_str();
1122 myCase->SetGroups(aSeqGroupe);
1124 // Recherche d'un nom pour l'iteration 0. Par defaut, on prend le nom
1125 // du maillage du cas. Si ce nom existe deja, on incremente avec 0, 1, 2, etc.
1127 std::string NomIteration = std::string(MeshName) ;
1128 while ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()))
1130 std::ostringstream nom;
1131 nom << MeshName << monNum;
1132 NomIteration=nom.str();
1135 MESSAGE ( "CreateCase : NomIteration = " << NomIteration );
1137 HOMARD::HOMARD_Iteration_var anIter = newIteration();
1138 myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter;
1139 std::ostringstream DirName;
1142 anIter->SetDirName(DirName.str().c_str());
1143 anIter->SetName(NomIteration.c_str());
1144 anIter->SetMeshFile(MeshFile);
1145 anIter->SetMeshName(MeshName);
1146 anIter->SetNumber(0);
1148 AssociateCaseIter (nomCas,NomIteration.c_str(),"IterationHomard");
1149 SetEtatIter(NomIteration.c_str(),true);
1151 PublishResultInSmesh(MeshFile, 0);
1153 // Valeurs par defaut des filtrages
1154 myCase->SetPyram(0);
1156 return HOMARD::HOMARD_Cas::_duplicate(myCase);
1158 //=============================================================================
1159 HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis)
1161 MESSAGE ( "CreateHypothesis : nomHypothesis = " << nomHypothesis );
1164 if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end())
1166 SALOME::ExceptionStruct es;
1167 es.type = SALOME::BAD_PARAM;
1168 es.text = "This hypothesis has already been defined.";
1169 throw SALOME::SALOME_Exception(es);
1173 HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis();
1174 myHypothesis->SetName(nomHypothesis);
1175 myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis;
1176 SALOMEDS::SObject_var aSO;
1177 PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis);
1179 // Valeurs par defaut des options avancees
1180 myHypothesis->SetNivMax(-1);
1181 myHypothesis->SetDiamMin(-1.0);
1182 myHypothesis->SetAdapInit(0);
1183 myHypothesis->SetLevelOutput(0);
1185 return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis);
1188 //=============================================================================
1189 HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent)
1190 //=============================================================================
1192 MESSAGE ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent);
1195 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent];
1196 if (CORBA::is_nil(myIterationParent))
1198 SALOME::ExceptionStruct es;
1199 es.type = SALOME::BAD_PARAM;
1200 es.text = "The parent iteration is not defined.";
1201 throw SALOME::SALOME_Exception(es);
1205 const char* nomCas = myIterationParent->GetCaseName();
1206 MESSAGE ("CreateIteration : nomCas = " << nomCas);
1207 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1208 if (CORBA::is_nil(myCase))
1210 SALOME::ExceptionStruct es;
1211 es.type = SALOME::BAD_PARAM;
1212 es.text = "Invalid case context";
1213 throw SALOME::SALOME_Exception(es);
1217 if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end())
1219 SALOME::ExceptionStruct es;
1220 es.type = SALOME::BAD_PARAM;
1221 es.text = "This iteration has already been defined.";
1222 throw SALOME::SALOME_Exception(es);
1226 HOMARD::HOMARD_Iteration_var myIteration = newIteration();
1227 if (CORBA::is_nil(myIteration))
1229 SALOME::ExceptionStruct es;
1230 es.type = SALOME::BAD_PARAM;
1231 es.text = "Unable to create the iteration";
1232 throw SALOME::SALOME_Exception(es);
1235 myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration;
1236 // Nom de l'iteration et du maillage
1237 myIteration->SetName(NomIteration);
1238 myIteration->SetMeshName(NomIteration);
1240 int numero = myIterationParent->GetNumber() + 1;
1241 myIteration->SetNumber(numero);
1243 // Nombre d'iterations deja connues pour le cas, permettant
1244 // la creation d'un sous-repertoire unique
1245 int nbitercase = myCase->GetNumber();
1246 std::ostringstream iaux ;
1247 iaux << std::setw(2) << std::setfill('0') << nbitercase ;
1248 std::stringstream DirName;
1249 DirName << "I" << iaux.str();
1250 myIteration->SetDirName(DirName.str().c_str());
1252 // Le nom du fichier du maillage MED est indice par le nombre d'iterations du cas.
1253 // Si on a une chaine unique depuis le depart, ce nombre est le meme que le
1254 // numero d'iteration dans la sucession : maill.01.med, maill.02.med, etc... C'est la
1255 // situation la plus frequente.
1256 // Si on a plusieurs branches, donc des iterations du meme niveau d'adaptation, utiliser
1257 // le nombre d'iterations du cas permet d'eviter les collisions.
1258 std::stringstream MeshFile;
1259 const char* nomDir = myCase->GetDirName();
1260 MeshFile << nomDir << "/maill." << iaux.str() << ".med";
1261 myIteration->SetMeshFile(MeshFile.str().c_str());
1263 // Association avec le cas
1264 std::string label = "IterationHomard_" + std::string(nomIterParent);
1265 AssociateCaseIter(nomCas, NomIteration, label.c_str());
1266 // Lien avec l'iteration precedente
1267 myIterationParent->LinkNextIteration(NomIteration);
1268 myIteration->SetIterParentName(nomIterParent);
1270 return HOMARD::HOMARD_Iteration::_duplicate(myIteration);
1272 //=============================================================================
1273 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryName, CORBA::Long BoundaryType)
1275 MESSAGE ("CreateBoundary : BoundaryName = " << BoundaryName << ", BoundaryType = " << BoundaryType);
1278 if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end())
1280 MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja");
1281 SALOME::ExceptionStruct es;
1282 es.type = SALOME::BAD_PARAM;
1283 es.text = "This boundary has already been defined";
1284 throw SALOME::SALOME_Exception(es);
1288 HOMARD::HOMARD_Boundary_var myBoundary = newBoundary();
1289 myBoundary->SetName(BoundaryName);
1290 myBoundary->SetType(BoundaryType);
1292 myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary;
1294 SALOMEDS::SObject_var aSO;
1295 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName);
1297 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1299 //=============================================================================
1300 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile)
1302 MESSAGE ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName );
1303 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0);
1304 myBoundary->SetMeshFile( MeshFile ) ;
1305 myBoundary->SetMeshName( MeshName ) ;
1307 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary);
1309 //=============================================================================
1310 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* BoundaryName,
1311 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1312 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1313 CORBA::Double Rayon)
1315 MESSAGE ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ;
1317 SALOME::ExceptionStruct es;
1320 { es.text = "The radius must be positive." ;
1322 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1323 if ( daux < 0.0000001 )
1324 { es.text = "The axis must be a non 0 vector." ;
1328 es.type = SALOME::BAD_PARAM;
1329 throw SALOME::SALOME_Exception(es);
1333 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 1) ;
1334 myBoundary->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon ) ;
1336 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1338 //=============================================================================
1339 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* BoundaryName,
1340 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1341 CORBA::Double Rayon)
1343 MESSAGE ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ;
1345 SALOME::ExceptionStruct es;
1348 { es.text = "The radius must be positive." ;
1352 es.type = SALOME::BAD_PARAM;
1353 throw SALOME::SALOME_Exception(es);
1357 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 2) ;
1358 myBoundary->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1360 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1362 //=============================================================================
1363 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* BoundaryName,
1364 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle,
1365 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre)
1367 MESSAGE ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ;
1369 SALOME::ExceptionStruct es;
1371 if ( Angle <= 0.0 or Angle >= 90.0 )
1372 { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ;
1374 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1375 if ( daux < 0.0000001 )
1376 { es.text = "The axis must be a non 0 vector." ;
1380 es.type = SALOME::BAD_PARAM;
1381 throw SALOME::SALOME_Exception(es);
1385 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 3) ;
1386 myBoundary->SetConeA( Xaxe, Yaxe, Zaxe, Angle, Xcentre, Ycentre, Zcentre ) ;
1388 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1390 //=============================================================================
1391 HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* BoundaryName,
1392 CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1,
1393 CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2)
1395 MESSAGE ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ;
1397 SALOME::ExceptionStruct es;
1399 if ( Rayon1 < 0.0 or Rayon2 < 0.0 )
1400 { es.text = "The radius must be positive." ;
1402 double daux = fabs(Rayon2-Rayon1) ;
1403 if ( daux < 0.0000001 )
1404 { es.text = "The radius must be different." ;
1406 daux = fabs(Xcentre2-Xcentre1) + fabs(Ycentre2-Ycentre1) + fabs(Zcentre2-Zcentre1) ;
1407 if ( daux < 0.0000001 )
1408 { es.text = "The centers must be different." ;
1412 es.type = SALOME::BAD_PARAM;
1413 throw SALOME::SALOME_Exception(es);
1417 HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 4) ;
1418 myBoundary->SetConeR( Xcentre1, Ycentre1, Zcentre1, Rayon1, Xcentre2, Ycentre2, Zcentre2, Rayon2 ) ;
1420 return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ;
1422 //=============================================================================
1423 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType)
1425 MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType);
1428 if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end())
1430 SALOME::ExceptionStruct es;
1431 es.type = SALOME::BAD_PARAM;
1432 es.text = "This zone has already been defined";
1433 throw SALOME::SALOME_Exception(es);
1437 HOMARD::HOMARD_Zone_var myZone = newZone();
1438 myZone->SetName(ZoneName);
1439 myZone->SetType(ZoneType);
1441 myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone;
1443 SALOMEDS::SObject_var aSO;
1444 SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName);
1446 return HOMARD::HOMARD_Zone::_duplicate(myZone);
1448 //=============================================================================
1449 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName,
1450 CORBA::Double Xmini, CORBA::Double Xmaxi,
1451 CORBA::Double Ymini, CORBA::Double Ymaxi,
1452 CORBA::Double Zmini, CORBA::Double Zmaxi)
1454 MESSAGE ("CreateZoneBox : ZoneName = " << ZoneName ) ;
1456 SALOME::ExceptionStruct es;
1458 if ( Xmini > Xmaxi )
1459 { es.text = "The X coordinates are not coherent." ;
1461 if ( Ymini > Ymaxi )
1462 { es.text = "The Y coordinates are not coherent." ;
1464 if ( Zmini > Zmaxi )
1465 { es.text = "The Z coordinates are not coherent." ;
1469 es.type = SALOME::BAD_PARAM;
1470 throw SALOME::SALOME_Exception(es);
1474 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 2) ;
1475 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
1477 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1479 //=============================================================================
1480 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName,
1481 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon)
1483 MESSAGE ("CreateZoneSphere : ZoneName = " << ZoneName ) ;
1485 SALOME::ExceptionStruct es;
1488 { es.text = "The radius must be positive." ;
1492 es.type = SALOME::BAD_PARAM;
1493 throw SALOME::SALOME_Exception(es);
1497 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 4) ;
1498 myZone->SetSphere( Xcentre, Ycentre, Zcentre, Rayon ) ;
1500 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1502 //=============================================================================
1503 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName,
1504 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1505 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1506 CORBA::Double Rayon, CORBA::Double Haut)
1508 MESSAGE ("CreateZoneCylinder : ZoneName = " << ZoneName ) ;
1510 SALOME::ExceptionStruct es;
1513 { es.text = "The radius must be positive." ;
1515 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1516 if ( daux < 0.0000001 )
1517 { es.text = "The axis must be a non 0 vector." ;
1520 { es.text = "The height must be positive." ;
1524 es.type = SALOME::BAD_PARAM;
1525 throw SALOME::SALOME_Exception(es);
1529 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 5) ;
1530 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut ) ;
1532 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1534 //=============================================================================
1535 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName,
1536 CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre,
1537 CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe,
1538 CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint)
1540 MESSAGE ("CreateZonePipe : ZoneName = " << ZoneName ) ;
1542 SALOME::ExceptionStruct es;
1544 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
1545 { es.text = "The radius must be positive." ;
1547 double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ;
1548 if ( daux < 0.0000001 )
1549 { es.text = "The axis must be a non 0 vector." ;
1552 { es.text = "The height must be positive." ;
1554 if ( Rayon <= Rayonint )
1555 { es.text = "The external radius must be higher than the internal radius." ;
1559 es.type = SALOME::BAD_PARAM;
1560 throw SALOME::SALOME_Exception(es);
1564 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 7) ;
1565 myZone->SetPipe( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, Rayon, Haut, Rayonint ) ;
1567 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1569 //=============================================================================
1570 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName,
1571 CORBA::Double Umini, CORBA::Double Umaxi,
1572 CORBA::Double Vmini, CORBA::Double Vmaxi,
1575 MESSAGE ("CreateZoneBox2D : ZoneName = " << ZoneName ) ;
1576 // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ;
1577 // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ;
1578 // MESSAGE ("Orient = " << Orient ) ;
1580 SALOME::ExceptionStruct es;
1582 if ( Umini > Umaxi )
1583 { es.text = "The first coordinates are not coherent." ;
1585 if ( Vmini > Vmaxi )
1586 { es.text = "The second coordinates are not coherent." ;
1588 if ( Orient < 1 or Orient > 3 )
1589 { es.text = "The orientation must be 1, 2 or 3." ;
1593 es.type = SALOME::BAD_PARAM;
1594 throw SALOME::SALOME_Exception(es);
1598 double Xmini, Xmaxi ;
1599 double Ymini, Ymaxi ;
1600 double Zmini, Zmaxi ;
1608 else if ( Orient == 2 )
1615 else if ( Orient == 3 )
1622 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
1624 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ;
1625 myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ;
1627 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1629 //=============================================================================
1630 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName,
1631 CORBA::Double Ucentre, CORBA::Double Vcentre,
1632 CORBA::Double Rayon,
1635 MESSAGE ("CreateZoneDisk : ZoneName = " << ZoneName ) ;
1637 SALOME::ExceptionStruct es;
1640 { es.text = "The radius must be positive." ;
1642 if ( Orient < 1 or Orient > 3 )
1643 { es.text = "The orientation must be 1, 2 or 3." ;
1647 es.type = SALOME::BAD_PARAM;
1648 throw SALOME::SALOME_Exception(es);
1656 { Xcentre = Ucentre ;
1659 else if ( Orient == 2 )
1662 Zcentre = Vcentre ; }
1663 else if ( Orient == 3 )
1664 { Xcentre = Vcentre ;
1666 Zcentre = Ucentre ; }
1667 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
1669 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ;
1670 myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ;
1672 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1674 //=============================================================================
1675 HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneName,
1676 CORBA::Double Ucentre, CORBA::Double Vcentre,
1677 CORBA::Double Rayon, CORBA::Double Rayonint,
1680 MESSAGE ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ;
1682 SALOME::ExceptionStruct es;
1684 if ( Rayon <= 0.0 or Rayonint <= 0.0 )
1685 { es.text = "The radius must be positive." ;
1687 if ( Orient < 1 or Orient > 3 )
1688 { es.text = "The orientation must be 1, 2 or 3." ;
1690 if ( Rayon <= Rayonint )
1691 { es.text = "The external radius must be higher than the internal radius." ;
1695 es.type = SALOME::BAD_PARAM;
1696 throw SALOME::SALOME_Exception(es);
1704 { Xcentre = Ucentre ;
1707 else if ( Orient == 2 )
1710 Zcentre = Vcentre ; }
1711 else if ( Orient == 3 )
1712 { Xcentre = Vcentre ;
1714 Zcentre = Ucentre ; }
1715 else { ASSERT( Orient >= 1 and Orient <= 3 ) ; }
1717 HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ;
1718 myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ;
1720 return HOMARD::HOMARD_Zone::_duplicate(myZone) ;
1722 //=============================================================================
1723 //=============================================================================
1728 //=============================================================================
1729 //=============================================================================
1730 // Traitement d'une iteration
1731 // etatMenage = 1 : destruction du repertoire d'execution
1732 // modeHOMARD = 1 : adaptation
1733 // != 1 : information avec les options modeHOMARD
1734 // Option >0 : appel depuis python
1735 // <0 : appel depuis GUI
1736 //=============================================================================
1737 //=============================================================================
1738 CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option)
1740 MESSAGE ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", avec Option = " << Option );
1745 // A.1. L'objet iteration
1746 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration];
1747 ASSERT(!CORBA::is_nil(myIteration));
1749 // A.2. Numero de l'iteration
1750 // siterp1 : numero de l'iteration a traiter
1752 // siter : numero de l'iteration parent, ou 0 si deja au debut mais cela ne servira pas !
1753 // Ou si information :
1755 int NumeIter = myIteration->GetNumber();
1756 std::string siterp1 ;
1757 std::stringstream saux1 ;
1759 siterp1 = saux1.str() ;
1760 if (NumeIter < 10) { siterp1 = "0" + siterp1 ; }
1763 if ( modeHOMARD==1 )
1765 std::stringstream saux0 ;
1766 int iaux = max(0, NumeIter-1) ;
1768 siter = saux0.str() ;
1769 if (NumeIter < 11) { siter = "0" + siter ; }
1772 { siter = siterp1 ; }
1775 const char* nomCas = myIteration->GetCaseName();
1776 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas];
1777 ASSERT(!CORBA::is_nil(myCase));
1779 // B. Les repertoires
1780 // B.1. Le repertoire courant
1781 char* nomDirWork = getenv("PWD") ;
1782 // B.2. Le sous-repertoire de l'iteration a traiter
1783 char* DirCompute = ComputeDir(myCase, myIteration, etatMenage);
1784 MESSAGE( ". DirCompute = " << DirCompute );
1786 // C. Le fichier des messages
1787 // C.1. Le deroulement de l'execution de HOMARD
1788 std::string LogFile = DirCompute ;
1789 LogFile += "/Liste" ;
1790 if ( modeHOMARD == 1 ) { LogFile += "." + siter + ".vers." + siterp1 ; }
1792 MESSAGE (". LogFile = " << LogFile);
1793 if ( modeHOMARD == 1 ) { myIteration->SetLogFile(LogFile.c_str()); }
1794 // C.2. Le bilan de l'analyse du maillage
1795 std::string FileInfo = DirCompute ;
1797 if ( modeHOMARD == 1 ) { FileInfo += "apad" ; }
1799 { if ( NumeIter == 0 ) { FileInfo += "info_av" ; }
1800 else { FileInfo += "info_ap" ; }
1802 FileInfo += "." + siterp1 + ".bilan" ;
1803 myIteration->SetFileInfo(FileInfo.c_str());
1805 // D. On passe dans le repertoire de l'iteration a calculer
1806 MESSAGE ( ". On passe dans DirCompute = " << DirCompute );
1809 // E. Les donnees de l'execution HOMARD
1810 // E.1. L'objet du texte du fichier de configuration
1811 HomardDriver* myDriver = new HomardDriver(siter, siterp1);
1812 myDriver->TexteInit(DirCompute, LogFile);
1814 // E.2. Le maillage associe a l'iteration
1815 const char* NomMesh = myIteration->GetMeshName();
1816 MESSAGE ( ". NomMesh = " << NomMesh );
1817 const char* MeshFile = myIteration->GetMeshFile();
1818 MESSAGE ( ". MeshFile = " << MeshFile );
1820 // E.3. Les donnees du traitement HOMARD
1822 if ( modeHOMARD == 1 )
1825 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
1826 myDriver->TexteMaillage(NomMesh, MeshFile, 1);
1827 codret = ComputeAdap(myCase, myIteration, etatMenage, myDriver, Option) ;
1831 InvalideIterInfo(NomIteration);
1832 myDriver->TexteInfo( modeHOMARD, NumeIter ) ;
1834 myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ;
1835 myDriver->TexteMaillage(NomMesh, MeshFile, 0);
1836 myDriver->CreeFichierDonn();
1839 // E.4. Ajout des informations liees a l'eventuel suivi de frontiere
1840 DriverTexteBoundary(myCase, myDriver) ;
1842 // E.5. Ecriture du texte dans le fichier
1844 { myDriver->CreeFichier(); }
1848 int codretexec = 12 ;
1851 codretexec = myDriver->ExecuteHomard(Option);
1853 MESSAGE ( "Erreur en executant HOMARD : " << codretexec );
1854 if ( modeHOMARD == 1 )
1856 if (codretexec == 0) { SetEtatIter(NomIteration,true); }
1857 else { SetEtatIter(NomIteration,false); }
1858 // GERALD -- QMESSAGE BOX
1862 // H. Gestion des resultats
1865 std::string Commentaire ;
1866 // H.1. Le fichier des messages, dans tous les cas
1867 Commentaire = "log" ;
1868 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
1869 else { Commentaire += "Info" ; }
1870 PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str());
1872 // H.2. Si tout s'est bien passe :
1873 if (codretexec == 0)
1875 // H.2.1. Le fichier de bilan
1876 Commentaire = "Summary" ;
1877 if ( modeHOMARD == 1 ) { Commentaire += " " + siterp1 ; }
1878 else { Commentaire += "Info" ; }
1879 PublishFileUnderIteration(NomIteration, FileInfo.c_str(), Commentaire.c_str());
1880 // H.2.2. Le fichier de maillage obtenu
1881 if ( modeHOMARD == 1 )
1883 std::stringstream saux0 ;
1884 Commentaire = "Iteration" ;
1885 Commentaire += " " + siter ;
1886 PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str());
1887 PublishResultInSmesh(MeshFile, 1);
1890 // H.3 Message d'erreur en cas de probleme
1893 SALOME::ExceptionStruct es;
1894 es.type = SALOME::BAD_PARAM;
1895 std::string text = "Error during the adaptation.\n" ;
1898 ifstream fichier(LogFile.c_str(), ios::in);
1900 while(getline(fichier, ligne) and (ligne != "===== HOMARD ===== STOP ====="));
1901 while (getline(fichier, ligne)) { text += ligne+ "\n";};
1904 text += "no log file ....";
1906 es.text = CORBA::string_dup(text.c_str());
1907 throw SALOME::SALOME_Exception(es);
1911 // I. Menage et retour dans le repertoire du cas
1915 MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork );
1921 //=============================================================================
1922 // Calcul d'une iteration : partie specifique a l'adaptation
1923 //=============================================================================
1924 CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option)
1926 MESSAGE ( "ComputeAdap" );
1931 // Numero de l'iteration
1932 int NumeIter = myIteration->GetNumber();
1933 std::stringstream saux0 ;
1934 saux0 << NumeIter-1 ;
1935 std::string siter = saux0.str() ;
1936 if (NumeIter < 11) { siter = "0" + siter ; }
1938 // A.2. On ne calcule pas l iteration 0
1939 if ( NumeIter == 0 )
1941 SALOME::ExceptionStruct es;
1942 es.type = SALOME::BAD_PARAM;
1943 es.text = "This iteration is the first of the case and cannot be computed.";
1944 throw SALOME::SALOME_Exception(es);
1948 // A.3. On verifie qu il y a une hypothese (erreur improbable);
1949 const char* nomHypo = myIteration->GetHypoName();
1950 if (std::string(nomHypo) == std::string(""))
1952 SALOME::ExceptionStruct es;
1953 es.type = SALOME::BAD_PARAM;
1954 es.text = "This iteration does not have any associated hypothesis.";
1955 throw SALOME::SALOME_Exception(es);
1958 HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo];
1959 ASSERT(!CORBA::is_nil(myHypo));
1961 // B. L'iteration parent
1962 const char* nomIterationParent = myIteration->GetIterParentName();
1963 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
1964 ASSERT(!CORBA::is_nil(myIterationParent));
1965 // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont)
1966 if ( ! myIterationParent->GetEtat() )
1969 int codret = Compute(nomIterationParent, etatMenage, iaux, Option);
1972 // GERALD -- QMESSAGE BOX
1973 ASSERT("Pb au calcul de l'iteration precedente" == 0);
1977 // C. Le sous-repertoire de l'iteration precedente
1978 char* DirComputePa = ComputeDirPa(myCase, myIteration);
1979 MESSAGE( ". DirComputePa = " << DirComputePa );
1981 // D. Les donnees de l'adaptation HOMARD
1982 // D.1. Le type de conformite
1983 int ConfType = myCase->GetConfType();
1984 MESSAGE ( ". ConfType = " << ConfType );
1986 // D.2. Le maillage de depart
1987 const char* NomMeshParent = myIterationParent->GetMeshName();
1988 MESSAGE ( ". NomMeshParent = " << NomMeshParent );
1989 const char* MeshFileParent = myIterationParent->GetMeshFile();
1990 MESSAGE ( ". MeshFileParent = " << MeshFileParent );
1992 // D.3. Le maillage associe a l'iteration
1993 const char* MeshFile = myIteration->GetMeshFile();
1994 MESSAGE ( ". MeshFile = " << MeshFile );
1995 FILE *file = fopen(MeshFile,"r");
1999 if (etatMenage == 0)
2001 SALOME::ExceptionStruct es;
2002 es.type = SALOME::BAD_PARAM;
2003 std::string text = "MeshFile : " + std::string(MeshFile) + " already exists ";
2004 es.text = CORBA::string_dup(text.c_str());
2005 throw SALOME::SALOME_Exception(es);
2010 std::string commande = "rm -f " + std::string(MeshFile);
2011 codret = system(commande.c_str());
2014 SALOME::ExceptionStruct es;
2015 es.type = SALOME::BAD_PARAM;
2016 es.text = "The mesh file cannot be deleted.";
2017 throw SALOME::SALOME_Exception(es);
2023 // D.4. Les types de raffinement et de deraffinement
2024 // Les appels corba sont lourds, il vaut mieux les grouper
2025 HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef();
2026 ASSERT(ListTypes->length() == 3);
2027 int TypeAdap = (*ListTypes)[0];
2028 int TypeRaff = (*ListTypes)[1];
2029 int TypeDera = (*ListTypes)[2];
2031 // E. Texte du fichier de configuration
2032 // E.1. Incontournables du texte
2033 myDriver->TexteAdap();
2035 myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ;
2036 myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0);
2037 myDriver->TexteConfRaffDera(ConfType, TypeAdap, TypeRaff, TypeDera);
2039 // E.2. Ajout des informations liees aux zones eventuelles
2040 if ( TypeAdap == 0 )
2041 { DriverTexteZone(myHypo, myDriver) ; }
2043 // E.3. Ajout des informations liees aux champs eventuels
2044 if ( TypeAdap == 1 )
2045 { DriverTexteField(myIteration, myHypo, myDriver) ; }
2047 // E.4. Ajout des informations liees au filtrage eventuel par les groupes
2048 HOMARD::ListGroupType* listeGroupes = myHypo->GetGroups();
2049 int numberOfGroups = listeGroupes->length();
2050 MESSAGE( ". Filtrage par " << numberOfGroups << " groupes");
2051 if (numberOfGroups > 0)
2053 for (int NumGroup = 0; NumGroup< numberOfGroups; NumGroup++)
2055 std::string GroupName = std::string((*listeGroupes)[NumGroup]);
2056 MESSAGE( "... GroupName = " << GroupName );
2057 myDriver->TexteGroup(GroupName);
2061 // E.5. Ajout des informations liees a l'eventuelle interpolation des champs
2062 DriverTexteFieldInterp(myIteration, myHypo, myDriver) ;
2064 // E.6. Ajout des options avancees
2065 int Pyram = myCase->GetPyram();
2066 MESSAGE ( ". Pyram = " << Pyram );
2067 int NivMax = myHypo->GetNivMax();
2068 MESSAGE ( ". NivMax = " << NivMax );
2069 double DiamMin = myHypo->GetDiamMin() ;
2070 MESSAGE ( ". DiamMin = " << DiamMin );
2071 int AdapInit = myHypo->GetAdapInit();
2072 MESSAGE ( ". AdapInit = " << AdapInit );
2073 int LevelOutput = myHypo->GetLevelOutput();
2074 MESSAGE ( ". LevelOutput = " << LevelOutput );
2075 myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput);
2079 //=============================================================================
2080 // Calcul d'une iteration : gestion du repertoire de calcul
2081 // Si le sous-repertoire existe :
2082 // etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide
2083 // etatMenage = 1 : on fait le menage du repertoire
2084 // etatMenage = -1 : on ne fait rien
2085 //=============================================================================
2086 char* HOMARD_Gen_i::ComputeDir(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage)
2088 MESSAGE ( "ComputeDir : repertoires pour le calcul" );
2089 // B.2. Le repertoire du cas
2090 const char* nomDirCase = myCase->GetDirName();
2091 MESSAGE ( ". nomDirCase = " << nomDirCase );
2093 // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer
2094 // B.3.1. Le nom du sous-repertoire
2095 const char* nomDirIt = myIteration->GetDirName();
2097 // B.3.2. Le nom complet du sous-repertoire
2098 std::stringstream DirCompute ;
2099 DirCompute << nomDirCase << "/" << nomDirIt;
2100 MESSAGE (". DirCompute = " << DirCompute.str() );
2102 // B.3.3. Si le sous-repertoire n'existe pas, on le cree
2103 if (chdir(DirCompute.str().c_str()) != 0)
2105 // Creation du repertoire car il n'existe pas :
2106 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
2108 // GERALD -- QMESSAGE BOX
2109 std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl;
2110 ASSERT("Pb a la creation du repertoire" == 0);
2115 // Le repertoire existe
2116 // On demande de faire le menage de son contenu :
2117 if (etatMenage == 1)
2119 MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str());
2120 std::string commande= "rm -rf " + DirCompute.str()+"/*" ;
2121 int codret = system(commande.c_str());
2124 // GERALD -- QMESSAGE BOX
2125 std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl;
2126 ASSERT("Pb au menage du repertoire de calcul" == 0);
2129 // On n'a pas demande de faire le menage de son contenu : on sort en erreur :
2132 if (etatMenage == 0)
2135 struct dirent *dirp;
2136 dp = opendir(DirCompute.str().c_str());
2138 while ((dirp = readdir(dp)) != NULL && result )
2140 std::string file_name(dirp->d_name);
2141 result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false
2144 if ( result == false)
2146 SALOME::ExceptionStruct es;
2147 es.type = SALOME::BAD_PARAM;
2148 std::string text = "Directory : " + DirCompute.str() + "is not empty";
2149 es.text = CORBA::string_dup(text.c_str());
2150 throw SALOME::SALOME_Exception(es);
2151 ASSERT("Directory is not empty" == 0);
2157 return CORBA::string_dup( DirCompute.str().c_str() );
2159 //=============================================================================
2160 // Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent
2161 //=============================================================================
2162 char* HOMARD_Gen_i::ComputeDirPa(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration)
2164 MESSAGE ( "ComputeDirPa : repertoires pour le calcul" );
2165 // Le repertoire du cas
2166 const char* nomDirCase = myCase->GetDirName();
2167 MESSAGE ( ". nomDirCase = " << nomDirCase );
2169 // Le sous-repertoire de l'iteration precedente
2171 const char* nomIterationParent = myIteration->GetIterParentName();
2172 HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent];
2173 const char* nomDirItPa = myIterationParent->GetDirName();
2174 std::stringstream DirComputePa ;
2175 DirComputePa << nomDirCase << "/" << nomDirItPa;
2176 MESSAGE( ". nomDirItPa = " << nomDirItPa);
2177 MESSAGE( ". DirComputePa = " << DirComputePa.str() );
2179 return CORBA::string_dup( DirComputePa.str().c_str() );
2181 //=============================================================================
2182 // Calcul d'une iteration : ecriture des zones dans le fichier de configuration
2183 //=============================================================================
2184 void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2186 MESSAGE ( "... DriverTexteZone" );
2187 HOMARD::listeZonesHypo* ListZone = myHypo->GetZones();
2188 int numberOfZonesx2 = ListZone->length();
2191 for (int iaux = 0; iaux< numberOfZonesx2; iaux++)
2193 std::string ZoneName = std::string((*ListZone)[iaux]);
2194 MESSAGE ( "... ZoneName = " << ZoneName);
2195 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName];
2196 ASSERT(!CORBA::is_nil(myZone));
2198 int ZoneType = myZone->GetType();
2199 std::string TypeUsestr = std::string((*ListZone)[iaux+1]);
2200 int TypeUse = atoi( TypeUsestr.c_str() );
2201 MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<<TypeUse);
2202 NumZone = iaux/2 + 1 ;
2203 HOMARD::double_array* zone = myZone->GetCoords();
2204 if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle
2206 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.);
2208 else if ( ZoneType == 4 ) // Cas d une sphere
2210 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.);
2212 else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque
2214 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.);
2216 else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce
2218 myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]);
2220 else { ASSERT("ZoneType est incorrect." == 0) ; }
2225 //=============================================================================
2226 // Calcul d'une iteration : ecriture des champs dans le fichier de configuration
2227 //=============================================================================
2228 void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2230 MESSAGE ( "... DriverTexteField" );
2231 // Le fichier du champ
2232 char* FieldFile = myIteration->GetFieldFile();
2233 MESSAGE ( ". FieldFile = " << FieldFile );
2234 if (strlen(FieldFile) == 0)
2236 // GERALD -- QMESSAGE BOX
2237 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2238 ASSERT("The file for the field is not given." == 0);
2240 // Les caracteristiques d'instants
2241 int TimeStep = myIteration->GetTimeStep();
2242 MESSAGE( ". TimeStep = " << TimeStep );
2243 int Rank = myIteration->GetRank();
2244 MESSAGE( ". Rank = " << Rank );
2245 // Les informations sur les champ
2246 HOMARD::InfosHypo* aInfosHypo = myHypo->GetField();
2248 const char* FieldName = aInfosHypo->FieldName;
2250 int TypeThR = aInfosHypo->TypeThR;
2251 double ThreshR = aInfosHypo->ThreshR;
2252 int TypeThC = aInfosHypo->TypeThC;
2253 double ThreshC = aInfosHypo->ThreshC;
2254 // Saut entre mailles ou non ?
2255 int UsField = aInfosHypo->UsField;
2256 MESSAGE( ". UsField = " << UsField );
2257 // L'usage des composantes
2258 int UsCmpI = aInfosHypo->UsCmpI;
2259 MESSAGE( ". UsCmpI = " << UsCmpI );
2261 myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI);
2264 HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp();
2265 int numberOfCompos = mescompo->length();
2266 MESSAGE( ". numberOfCompos = " << numberOfCompos );
2267 for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++)
2269 std::string nomCompo = std::string((*mescompo)[NumeComp]);
2270 MESSAGE( "... nomCompo = " << nomCompo );
2271 myDriver->TexteCompo(NumeComp, nomCompo);
2275 //=============================================================================
2276 // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration
2277 //=============================================================================
2278 void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver)
2280 MESSAGE ( "... DriverTexteBoundary" );
2281 // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes
2282 std::list<std::string> ListeBoundaryTraitees ;
2283 HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup();
2284 int numberOfitems = ListBoundaryGroupType->length();
2285 MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems);
2286 int BoundaryOption = 1 ;
2287 int NumBoundaryAnalytical = 0 ;
2288 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2290 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2291 MESSAGE ( "... BoundaryName = " << BoundaryName);
2293 std::list<std::string>::const_iterator it = ListeBoundaryTraitees.begin();
2294 while (it != ListeBoundaryTraitees.end())
2296 MESSAGE ( "... BoundaryNameTraitee = " << *it);
2297 if ( BoundaryName == *it ) { A_faire = 0 ; }
2302 // Caracteristiques de la frontiere
2303 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2304 ASSERT(!CORBA::is_nil(myBoundary));
2305 int BoundaryType = myBoundary->GetType();
2306 MESSAGE ( "... BoundaryType = " << BoundaryType );
2307 // Ecriture selon le type
2308 if (BoundaryType == 0) // Cas d une frontiere discrete
2310 const char* MeshName = myBoundary->GetMeshName() ;
2311 const char* MeshFile = myBoundary->GetMeshFile() ;
2312 myDriver->TexteBoundaryDi( MeshName, MeshFile);
2313 BoundaryOption = BoundaryOption*2 ;
2315 else // Cas d une frontiere analytique
2317 NumBoundaryAnalytical++ ;
2318 HOMARD::double_array* coor = myBoundary->GetCoords();
2319 if (BoundaryType == 1) // Cas d un cylindre
2321 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2322 BoundaryOption = BoundaryOption*3 ;
2324 else if (BoundaryType == 2) // Cas d une sphere
2326 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], 0., 0., 0., 0.);
2327 BoundaryOption = BoundaryOption*3 ;
2329 else if (BoundaryType == 3) // Cas d un cone defini par un axe et un angle
2331 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], 0.);
2332 BoundaryOption = BoundaryOption*3 ;
2334 else if (BoundaryType == 4) // Cas d un cone defini par les 2 rayons
2336 myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]);
2337 BoundaryOption = BoundaryOption*3 ;
2340 // Memorisation du traitement
2341 ListeBoundaryTraitees.push_back( BoundaryName );
2344 NumBoundaryAnalytical = 0 ;
2345 for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2)
2347 std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]);
2348 MESSAGE ( "... BoundaryName = " << BoundaryName);
2349 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2350 ASSERT(!CORBA::is_nil(myBoundary));
2351 int BoundaryType = myBoundary->GetType();
2352 MESSAGE ( "... BoundaryType = " << BoundaryType );
2353 // Recuperation du nom du groupe
2354 std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]);
2355 MESSAGE ( "... GroupName = " << GroupName);
2356 if (BoundaryType == 0) // Cas d une frontiere discrete
2358 if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; }
2360 else // Cas d une frontiere analytique
2362 NumBoundaryAnalytical++ ;
2363 myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ;
2366 myDriver->TexteBoundaryOption(BoundaryOption);
2369 //=============================================================================
2370 // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration
2371 //=============================================================================
2372 void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIteration, HOMARD::HOMARD_Hypothesis_var myHypo, HomardDriver* myDriver)
2374 MESSAGE ( "... DriverTexteFieldInterp" );
2375 int TypeFieldInterp = myHypo->GetTypeFieldInterp();
2376 if (TypeFieldInterp != 0)
2378 // Le fichier des champs
2379 char* FieldFile = myIteration->GetFieldFile();
2380 MESSAGE ( ". FieldFile = " << FieldFile );
2381 if (strlen(FieldFile) == 0)
2383 // GERALD -- QMESSAGE BOX
2384 std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl;
2385 ASSERT("The file for the field is not given." == 0);
2387 // Les caracteristiques d'instants
2388 int TimeStep = myIteration->GetTimeStep();
2389 MESSAGE( ". TimeStep = " << TimeStep );
2390 int Rank = myIteration->GetRank();
2391 MESSAGE( ". Rank = " << Rank );
2393 const char* MeshFile = myIteration->GetMeshFile();
2394 myDriver->TexteFieldInterp(TypeFieldInterp, FieldFile, MeshFile, TimeStep, Rank);
2396 if (TypeFieldInterp == 2)
2398 HOMARD::listFieldInterpHypo* meschamps = myHypo->GetListFieldInterp();
2399 int numberOfFields = meschamps->length();
2400 MESSAGE( ". numberOfFields = " << numberOfFields );
2401 for (int NumeChamp = 0; NumeChamp< numberOfFields; NumeChamp++)
2403 std::string nomChamp = std::string((*meschamps)[NumeChamp]);
2404 MESSAGE( "... nomChamp = " << nomChamp );
2405 myDriver->TexteFieldInterpName(NumeChamp, nomChamp);
2411 //===========================================================================
2412 //===========================================================================
2415 //===========================================================================
2416 //===========================================================================
2418 //===========================================================================
2419 //===========================================================================
2420 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
2421 SALOMEDS::SObject_ptr theSObject,
2422 CORBA::Object_ptr theObject,
2423 const char* theName)
2425 MESSAGE("PublishInStudy pour " << theName);
2426 SALOMEDS::SObject_var aResultSO;
2427 if (CORBA::is_nil(theStudy))
2429 SALOME::ExceptionStruct es;
2430 es.type = SALOME::BAD_PARAM;
2431 es.text = "Invalid study context";
2432 throw SALOME::SALOME_Exception(es);
2436 // Recuperation de l'objet correspondant, en essayant chacun des types possibles
2437 // Rq : Iteration est publiee ailleurs
2438 HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject);
2439 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject);
2440 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject);
2441 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject);
2443 addInStudy(theStudy);
2445 // Controle de la non publication d'un objet de meme nom
2446 if ((!aHypo->_is_nil()) or (!aZone->_is_nil()) or (!aBoundary->_is_nil()))
2448 SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType());
2449 if (listSO->length() >= 1)
2451 MESSAGE("This name "<<theName<<" is already used "<<listSO->length()<<" time(s)");
2452 std::cerr <<"This name "<<theName<<" is already used "<<listSO->length()<<" time(s)" << std::endl;
2453 aResultSO = listSO[0];
2454 return aResultSO._retn();
2458 // Caracteristiques de l'etude
2459 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
2460 aStudyBuilder->NewCommand();
2461 if(!aCase->_is_nil())
2462 aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName);
2463 else if(!aHypo->_is_nil())
2464 aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName);
2465 else if(!aZone->_is_nil())
2466 aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName);
2467 else if(!aBoundary->_is_nil())
2468 aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName);
2470 aStudyBuilder->CommitCommand();
2471 return aResultSO._retn();
2473 //=============================================================================
2474 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy,
2475 SALOMEDS::StudyBuilder_var aStudyBuilder,
2476 HOMARD::HOMARD_Cas_ptr theObject, const char* theName)
2478 MESSAGE("PublishCaseInStudy pour "<<theName);
2479 SALOMEDS::SObject_var aResultSO;
2480 SALOMEDS::GenericAttribute_var anAttr;
2482 if (CORBA::is_nil(theObject)) {
2483 MESSAGE("HOMARD_Gen_i::theObject->_is_nil()");
2484 return aResultSO._retn();
2486 if (theStudy->_is_nil()) {
2487 MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()");
2488 return aResultSO._retn();
2491 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
2492 if (theFatherHomard->_is_nil())
2494 MESSAGE("theFatherHomard->_is_nil()");
2495 return aResultSO._retn();
2498 aResultSO = aStudyBuilder->NewObject(theFatherHomard);
2499 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png",
2500 _orb->object_to_string(theObject) ) ;
2501 return aResultSO._retn();
2504 //=============================================================================
2505 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy,
2506 SALOMEDS::StudyBuilder_var aStudyBuilder,
2507 HOMARD::HOMARD_Zone_ptr theObject, const char* theName)
2509 MESSAGE("PublishZoneStudy pour "<<theName);
2510 SALOMEDS::SObject_var aResultSO;
2511 SALOMEDS::GenericAttribute_var anAttr;
2513 if (CORBA::is_nil(theObject))
2515 MESSAGE("PublishZoneInStudy : theObject->_is_nil()");
2516 return aResultSO._retn();
2518 if (theStudy->_is_nil())
2520 MESSAGE("PublishZoneInStudy : theStudy->_is_nil()");
2521 return aResultSO._retn();
2523 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
2524 if (theFatherHomard->_is_nil())
2526 MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()");
2527 return aResultSO._retn();
2530 // Caracteristique de la zone
2531 HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName];
2532 CORBA::Long ZoneType = myZone->GetType();
2534 // On ajoute la categorie des zones dans l etude si necessaire
2535 SALOMEDS::SObject_var aSOZone;
2536 if (!theFatherHomard->FindSubObject(100, aSOZone))
2538 MESSAGE("Ajout de la categorie des zones");
2539 aSOZone = aStudyBuilder->NewObjectToTag(theFatherHomard, 100);
2540 PublishInStudyAttr(aStudyBuilder, aSOZone, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ;
2542 else { MESSAGE("La categorie des zones existe deja."); }
2544 aResultSO = aStudyBuilder->NewObject(aSOZone);
2553 { icone = "boxdxy_2.png" ;
2557 { icone = "boxdxyz_2.png" ;
2565 { icone = "disk_2.png" ;
2569 { icone = "spherepoint_2.png" ;
2573 { icone = "cylinderpointvector_2.png" ;
2581 { icone = "diskwithhole_2.png" ;
2585 { icone = "pipe_2.png" ;
2589 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "ZoneHomard", icone, _orb->object_to_string(theObject) ) ;
2591 return aResultSO._retn();
2593 //=============================================================================
2594 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy,
2595 SALOMEDS::StudyBuilder_var aStudyBuilder,
2596 HOMARD::HOMARD_Boundary_ptr theObject, const char* theName)
2598 MESSAGE("PublishBoundaryStudy pour "<<theName);
2599 SALOMEDS::SObject_var aResultSO;
2600 SALOMEDS::GenericAttribute_var anAttr;
2602 // Caracteristique de la Boundary
2603 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[theName];
2605 // On recupere le module pere dans l etude
2606 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
2607 if (theFatherHomard->_is_nil())
2609 MESSAGE("theFatherHomard->_is_nil()");
2610 return aResultSO._retn();
2613 // On ajoute la categorie des boundarys dans l etude si necessaire
2614 SALOMEDS::SObject_var aSOBoundary;
2615 if (!theFatherHomard->FindSubObject(101, aSOBoundary))
2617 MESSAGE("Ajout de la categorie des boundarys");
2618 aSOBoundary = aStudyBuilder->NewObjectToTag(theFatherHomard, 101);
2619 PublishInStudyAttr(aStudyBuilder, aSOBoundary, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ;
2621 else { MESSAGE("La categorie des boundarys existe deja."); }
2623 aResultSO = aStudyBuilder->NewObject(aSOBoundary);
2624 CORBA::Long BoundaryType = myBoundary->GetType();
2625 // MESSAGE("BoundaryType : "<<BoundaryType);
2628 switch (BoundaryType)
2631 { value = "BoundaryDiHomard" ;
2632 icone = "mesh_tree_mesh.png" ;
2636 { value = "BoundaryAnHomard" ;
2637 icone = "cylinderpointvector_2.png" ;
2641 { value = "BoundaryAnHomard" ;
2642 icone = "spherepoint_2.png" ;
2646 { value = "BoundaryAnHomard" ;
2647 icone = "conepointvector.png" ;
2651 { value = "BoundaryAnHomard" ;
2652 icone = "conedxyz.png" ;
2656 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value, icone, _orb->object_to_string(theObject));
2657 return aResultSO._retn();
2660 //=============================================================================
2661 SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy,
2662 SALOMEDS::StudyBuilder_var aStudyBuilder,
2663 HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName)
2665 MESSAGE("PublishHypotheseInStudy pour "<<theName);
2666 SALOMEDS::SObject_var aResultSO;
2667 SALOMEDS::GenericAttribute_var anAttr;
2669 // On recupere le module pere dans l etude
2670 // On ajoute la categorie des hypotheses dans l etude si necessaire
2671 SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType());
2672 if (theFatherHomard->_is_nil())
2674 MESSAGE("theFatherHomard->_is_nil()");
2675 return aResultSO._retn();
2677 SALOMEDS::SObject_var aSOHypothese;
2678 if (!theFatherHomard->FindSubObject(0, aSOHypothese))
2680 MESSAGE("Ajout de la categorie des hypotheses");
2681 aSOHypothese = aStudyBuilder->NewObjectToTag(theFatherHomard, 0);
2682 PublishInStudyAttr(aStudyBuilder, aSOHypothese, "Hypothesis", "HypoList","hypotheses.png", NULL);
2684 else { MESSAGE("La categorie des hypotheses existe deja."); }
2686 // Creation du resultat dans l'etude
2687 aResultSO = aStudyBuilder->NewObject(aSOHypothese);
2688 PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ;
2690 return aResultSO._retn();
2692 //===========================================================================
2693 void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder,
2694 SALOMEDS::SObject_var aResultSO,
2695 const char* name, const char* value, const char* icone, const char* ior)
2697 SALOMEDS::GenericAttribute_var anAttr ;
2701 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeName");
2702 SALOMEDS::AttributeName_var aNameAttrib = SALOMEDS::AttributeName::_narrow(anAttr);
2703 aNameAttrib->SetValue(name);
2706 // Ajout du commentaire
2707 if ( value != NULL )
2709 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
2710 SALOMEDS::AttributeComment_var aCommentAttrib = SALOMEDS::AttributeComment::_narrow(anAttr);
2711 aCommentAttrib->SetValue(value);
2715 if ( icone != NULL )
2717 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO,"AttributePixMap");
2718 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
2719 aPixmap->SetPixMap(icone);
2725 anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
2726 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
2727 anIOR->SetValue(ior);
2731 //=====================================================================================
2732 void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* BoundaryName)
2734 MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName );
2736 HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName];
2737 ASSERT(!CORBA::is_nil(myCase));
2738 SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase)));
2739 ASSERT(!CORBA::is_nil(aCaseSO));
2741 HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName];
2742 ASSERT(!CORBA::is_nil(myBoundary));
2743 SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary)));
2744 ASSERT(!CORBA::is_nil(aBoundarySO));
2746 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
2748 aStudyBuilder->NewCommand();
2750 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO);
2751 aStudyBuilder->Addreference(aSubSO, aBoundarySO);
2753 aStudyBuilder->CommitCommand();
2756 //=============================================================================
2757 void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
2758 // Option = 0 : fichier issu d'une importation
2759 // Option = 1 : fichier issu d'une execution HOMARD
2761 MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option);
2762 if (CORBA::is_nil(myCurrentStudy))
2764 SALOME::ExceptionStruct es;
2765 es.type = SALOME::BAD_PARAM;
2766 es.text = "Invalid study context";
2767 throw SALOME::SALOME_Exception(es);
2771 // Le module SMESH est-il actif ?
2772 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
2774 if (!CORBA::is_nil(aSmeshSO))
2776 // On verifie que le fichier n est pas deja publie
2777 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
2778 for (; aIter->More(); aIter->Next())
2780 SALOMEDS::SObject_var aSO = aIter->Value();
2781 SALOMEDS::GenericAttribute_var aGAttr;
2782 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
2784 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
2785 CORBA::String_var value=anAttr->Value();
2786 if (strcmp((const char*)value,NomFich) == 0)
2788 MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." );
2789 // Pour un fichier importe, on ne republie pas
2794 // Pour un fichier calcule, on commence par faire la depublication
2797 MESSAGE ( "PublishResultInSmesh : depublication" );
2798 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
2799 CORBA::String_var value2=anAttr2->Value();
2800 const char* MeshName = value2 ;
2801 MESSAGE ( "PublishResultInSmesh : depublication de " << MeshName );
2802 DeleteResultInSmesh(NomFich, MeshName) ;
2809 // On enregistre le fichier
2810 MESSAGE( "Enregistrement du fichier");
2811 SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
2812 SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
2813 ASSERT(!CORBA::is_nil(aSmeshEngine));
2814 aSmeshEngine->SetCurrentStudy(myCurrentStudy);
2815 SMESH::DriverMED_ReadStatus theStatus;
2816 //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
2818 // On met a jour les attributs AttributeExternalFileDef et AttributePixMap
2819 SMESH::mesh_array* mesMaillages=aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus);
2820 for (int i = 0; i < mesMaillages->length(); i++)
2822 MESSAGE( ". Mise a jour des attributs du maillage");
2823 SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i];
2824 SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage)));
2825 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
2826 SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef");
2827 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
2828 anAttr->SetValue(NomFich);
2829 SALOMEDS::GenericAttribute_var aPixMap = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributePixMap" );
2830 SALOMEDS::AttributePixMap_var anAttr2 = SALOMEDS::AttributePixMap::_narrow(aPixMap);
2832 if ( Option == 0 ) { icone = "mesh_tree_importedmesh.png" ; }
2833 else { icone = "mesh_tree_mesh.png" ; }
2834 anAttr2->SetPixMap( icone );
2838 //=============================================================================
2839 void HOMARD_Gen_i::DeleteResultInSmesh(const char* NomFich, const char* MeshName)
2841 MESSAGE (" DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich );
2842 if (CORBA::is_nil(myCurrentStudy))
2844 SALOME::ExceptionStruct es;
2845 es.type = SALOME::BAD_PARAM;
2846 es.text = "Invalid study context";
2847 throw SALOME::SALOME_Exception(es);
2851 // Le module SMESH est-il actif ?
2852 SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH");
2854 if (CORBA::is_nil(aSmeshSO))
2858 // On verifie que le fichier est deja publie
2859 SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder();
2860 SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO);
2861 for (; aIter->More(); aIter->Next())
2863 SALOMEDS::SObject_var aSO = aIter->Value();
2864 SALOMEDS::GenericAttribute_var aGAttr;
2865 if (aSO->FindAttribute(aGAttr,"AttributeExternalFileDef"))
2867 SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr);
2868 CORBA::String_var value=anAttr->Value();
2869 if (strcmp((const char*)value,NomFich) == 0)
2871 if (aSO->FindAttribute(aGAttr,"AttributeName"))
2873 SALOMEDS::AttributeName_var anAttr2 = SALOMEDS::AttributeName::_narrow(aGAttr);
2874 CORBA::String_var value2=anAttr2->Value();
2875 if (strcmp((const char*)value2,MeshName) == 0)
2877 myBuilder->RemoveObjectWithChildren( aSO ) ;
2885 //=============================================================================
2886 void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire)
2888 // MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire );
2889 if (CORBA::is_nil(myCurrentStudy))
2891 SALOME::ExceptionStruct es;
2892 es.type = SALOME::BAD_PARAM;
2893 es.text = "Invalid study context";
2894 throw SALOME::SALOME_Exception(es);
2898 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter];
2899 if (CORBA::is_nil(myIteration))
2901 SALOME::ExceptionStruct es;
2902 es.type = SALOME::BAD_PARAM;
2903 es.text = "Invalid iteration";
2904 throw SALOME::SALOME_Exception(es);
2907 SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration)));
2908 if (CORBA::is_nil(myIteration))
2910 SALOME::ExceptionStruct es;
2911 es.type = SALOME::BAD_PARAM;
2912 es.text = "Invalid iterationStudy Object";
2913 throw SALOME::SALOME_Exception(es);
2917 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
2919 aStudyBuilder->NewCommand();
2921 SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO);
2922 // Pour les fichiers med, on affiche une icone de maillage
2923 // Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte'
2924 // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n
2926 const char* ior = " " ;
2927 if ( Commentaire[0] == 'I' )
2928 { icone = "med.png" ; }
2930 { icone = "texte_2.png" ; }
2931 PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone, ior ) ;
2933 aStudyBuilder->CommitCommand();
2935 //=============================================================================
2936 //=============================================================================
2938 //=============================================================================
2939 //=============================================================================
2940 // Next functions are inherited from SALOMEDS::Driver interface
2941 //=============================================================================
2942 //=============================================================================
2943 SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
2945 CORBA::Boolean isMultiFile)
2947 MESSAGE (" Save for theURL = "<< theURL);
2948 SALOMEDS::TMPFile_var aStreamFile;
2950 // get temporary directory name
2951 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
2953 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
2954 StudyContext& context = myContextMap[ aStudy->StudyId() ];
2956 // HOMARD data file name
2957 std::string aFileName = "";
2959 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
2960 aFileName += "_HOMARD.dat";
2962 // initialize sequence of file names
2963 SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames;
2964 aFileSeq->length(1);
2965 aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ;
2967 // get full path to the data file
2968 aFileName = tmpDir + aFileName;
2972 std::ofstream f(aFileName.c_str());
2974 // clear temporary id map
2975 context._idmap.clear();
2980 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_case;
2981 for (it_case = context._mesCas.begin(); it_case != context._mesCas.end(); ++it_case) {
2982 HOMARD::HOMARD_Cas_var aCas = it_case->second;
2983 PortableServer::ServantBase_var aServant = GetServant(aCas);
2984 HOMARD_Cas_i* aCasServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
2986 f << HOMARD::GetSignature(HOMARD::Case) << aCasServant->Dump() << std::endl;
2987 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aCasServant);
2991 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
2992 for (it_zone = context._mesZones.begin(); it_zone != context._mesZones.end(); ++it_zone) {
2993 HOMARD::HOMARD_Zone_var aZone = it_zone->second;
2994 PortableServer::ServantBase_var aServant = GetServant(aZone);
2995 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
2997 f << HOMARD::GetSignature(HOMARD::Zone) << aZoneServant->Dump() << std::endl;
2998 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3001 // -> save hypotheses
3002 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3003 for (it_hypo = context._mesHypotheses.begin(); it_hypo != context._mesHypotheses.end(); ++it_hypo) {
3004 HOMARD::HOMARD_Hypothesis_var aHypo = it_hypo->second;
3005 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3006 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3008 f << HOMARD::GetSignature(HOMARD::Hypothesis) << aHypoServant->Dump() << std::endl;
3009 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3012 // -> save iterations
3013 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3014 for (it_iter = context._mesIterations.begin(); it_iter != context._mesIterations.end(); ++it_iter) {
3015 HOMARD::HOMARD_Iteration_var aIter = it_iter->second;
3016 PortableServer::ServantBase_var aServant = GetServant(aIter);
3017 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3019 f << HOMARD::GetSignature(HOMARD::Iteration) << aIterServant->Dump() << std::endl;
3020 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3023 // -> save boundaries
3024 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3025 for (it_boundary = context._mesBoundarys.begin(); it_boundary != context._mesBoundarys.end(); ++it_boundary) {
3026 HOMARD::HOMARD_Boundary_var aBoundary = it_boundary->second;
3027 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3028 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3029 if (aBoundaryServant) {
3030 f << HOMARD::GetSignature(HOMARD::Boundary) << aBoundaryServant->Dump() << std::endl;
3031 context._idmap[id++] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3035 MESSAGE ("close file");
3038 // put temporary files to the stream
3039 MESSAGE ("put temporary files to the stream");
3040 aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile);
3042 // remove temporary files
3043 MESSAGE ("remove temporary files");
3044 if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3046 // return data stream
3047 MESSAGE ("return data stream");
3048 return aStreamFile._retn();
3051 //===========================================================================
3052 SALOMEDS::TMPFile* HOMARD_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
3054 CORBA::Boolean isMultiFile)
3056 // No specific ASCII persistence
3057 SALOMEDS::TMPFile_var aStreamFile = Save(theComponent, theURL, isMultiFile);
3058 return aStreamFile._retn();
3061 //===========================================================================
3062 CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
3063 const SALOMEDS::TMPFile& theStream,
3065 CORBA::Boolean isMultiFile)
3067 MESSAGE (" Load pour theURL = "<< theURL);
3068 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
3070 // set current study
3071 if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId())
3072 SetCurrentStudy(aStudy);
3074 // get temporary directory name
3075 std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir();
3077 // Convert the stream into sequence of files to process
3078 SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream,
3081 // HOMARD data file name
3082 std::string aFileName = "";
3084 aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL());
3085 aFileName = tmpDir + aFileName + "_HOMARD.dat";
3087 StudyContext& context = myContextMap[ aStudy->StudyId() ];
3091 std::ifstream f(aFileName.c_str());
3094 context._mesCas.clear();
3095 context._mesHypotheses.clear();
3096 context._mesIterations.clear();
3097 context._mesZones.clear();
3098 context._mesBoundarys.clear();
3099 context._idmap.clear();
3105 std::getline(f, line);
3106 std::string caseSignature = HOMARD::GetSignature(HOMARD::Case);
3107 std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone);
3108 std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration);
3109 std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis);
3110 std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary);
3111 if (line.substr(0, caseSignature.size()) == caseSignature) {
3113 MESSAGE (" Recreation du cas" );
3114 HOMARD::HOMARD_Cas_var aCase = newCase();
3115 PortableServer::ServantBase_var aServant = GetServant(aCase);
3116 HOMARD_Cas_i* aCaseServant = dynamic_cast<HOMARD_Cas_i*>(aServant.in());
3117 if (aCaseServant && aCaseServant->Restore(line.substr(caseSignature.size()))) {
3118 context._mesCas[aCase->GetName()] = aCase;
3119 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aCaseServant);
3122 else if (line.substr(0, zoneSignature.size()) == zoneSignature) {
3123 MESSAGE (" Recreation de la zone" );
3125 HOMARD::HOMARD_Zone_var aZone = newZone();
3126 PortableServer::ServantBase_var aServant = GetServant(aZone);
3127 HOMARD_Zone_i* aZoneServant = dynamic_cast<HOMARD_Zone_i*>(aServant.in());
3128 if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) {
3129 context._mesZones[aZone->GetName()] = aZone;
3130 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aZoneServant);
3133 else if (line.substr(0, iterSignature.size()) == iterSignature) {
3134 // re-create iteration
3135 MESSAGE (" Recreation de l iteration" );
3136 HOMARD::HOMARD_Iteration_var aIter = newIteration();
3137 PortableServer::ServantBase_var aServant = GetServant(aIter);
3138 HOMARD_Iteration_i* aIterServant = dynamic_cast<HOMARD_Iteration_i*>(aServant.in());
3139 if (aIterServant && aIterServant->Restore(line.substr(iterSignature.size()))) {
3140 context._mesIterations[aIter->GetName()] = aIter;
3141 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aIterServant);
3144 else if (line.substr(0, hypoSignature.size()) == hypoSignature) {
3145 // re-create hypothesis
3146 MESSAGE (" Recreation de l hypothese" );
3147 HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis();
3148 PortableServer::ServantBase_var aServant = GetServant(aHypo);
3149 HOMARD_Hypothesis_i* aHypoServant = dynamic_cast<HOMARD_Hypothesis_i*>(aServant.in());
3150 if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) {
3151 context._mesHypotheses[aHypo->GetName()] = aHypo;
3152 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aHypoServant);
3155 else if (line.substr(0, bounSignature.size()) == bounSignature) {
3156 // re-create boundary
3157 MESSAGE (" Recreation de la frontiere" );
3158 HOMARD::HOMARD_Boundary_var aBoundary = newBoundary();
3159 PortableServer::ServantBase_var aServant = GetServant(aBoundary);
3160 HOMARD_Boundary_i* aBoundaryServant = dynamic_cast<HOMARD_Boundary_i*>(aServant.in());
3161 if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) {
3162 context._mesBoundarys[aBoundary->GetName()] = aBoundary;
3163 context._idmap[id] = dynamic_cast<PortableServer::ServantBase*>(aBoundaryServant);
3172 // Remove temporary files created from the stream
3174 SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true);
3179 //===========================================================================
3180 CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
3181 const SALOMEDS::TMPFile& theStream,
3183 CORBA::Boolean isMultiFile)
3185 // No specific ASCII persistence
3186 return Load(theComponent, theStream, theURL, isMultiFile);
3189 //===========================================================================
3190 void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
3192 if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) {
3193 // clearing study context should be done here:
3194 // - destroy all servants and related CORBA objects
3196 // - remove context from myContextMap
3197 myContextMap.erase(theComponent->GetStudy()->StudyId());
3198 // - nullify myCurrentStudy
3199 myCurrentStudy = SALOMEDS::Study::_nil();
3203 //===========================================================================
3204 char* HOMARD_Gen_i::ComponentDataType()
3206 return CORBA::string_dup("HOMARD");
3209 //===========================================================================
3210 char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
3211 const char* IORString,
3212 CORBA::Boolean isMultiFile,
3213 CORBA::Boolean isASCII)
3215 CORBA::String_var aString("");
3216 if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) {
3217 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3218 CORBA::Object_var anObj = _orb->string_to_object(IORString);
3219 if (!CORBA::is_nil(anObj)) {
3220 PortableServer::ServantBase_var aServant = GetServant(anObj);
3221 PortableServer::ServantBase* aStorable = dynamic_cast<PortableServer::ServantBase*>(aServant.in());
3223 std::map<int, PortableServer::ServantBase*>::const_iterator it;
3224 for (it = context._idmap.begin(); it != context._idmap.end(); ++it) {
3225 if (it->second == aStorable) {
3226 std::stringstream os;
3228 aString = CORBA::string_dup(os.str().c_str());
3234 return aString._retn();
3237 //===========================================================================
3238 char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
3239 const char* aLocalPersistentID,
3240 CORBA::Boolean isMultiFile,
3241 CORBA::Boolean isASCII)
3243 CORBA::String_var aString("");
3244 if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) {
3245 StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ];
3246 int id = atoi(aLocalPersistentID);
3247 if (id > 0 && context._idmap.find(id) != context._idmap.end()) {
3248 CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]);
3249 if (!CORBA::is_nil(object)) {
3250 aString = _orb->object_to_string(object);
3254 return aString._retn();
3257 //===========================================================================
3258 CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
3260 if(CORBA::is_nil(myCurrentStudy))
3263 HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR);
3264 if(!aCas->_is_nil())
3267 HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theIOR);
3268 if(!aHypo->_is_nil())
3271 HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theIOR);
3272 if(!aZone->_is_nil())
3275 HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theIOR);
3276 if(!aBoundary->_is_nil())
3279 /* Iteration is not published directly
3280 HOMARD::HOMARD_Iteration_var aIter = HOMARD::HOMARD_Iteration::_narrow(theIOR);
3281 if(!aIter->_is_nil())
3287 //===========================================================================
3288 CORBA::Boolean HOMARD_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject)
3290 // No Copy/Paste support
3294 //===========================================================================
3295 SALOMEDS::TMPFile* HOMARD_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
3296 CORBA::Long& theObjectID)
3298 // No Copy/Paste support
3299 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
3300 return aStreamFile._retn();
3303 //===========================================================================
3304 CORBA::Boolean HOMARD_Gen_i::CanPaste(const char *theComponentName,
3305 CORBA::Long theObjectID)
3307 // No Copy/Paste support
3311 //===========================================================================
3312 SALOMEDS::SObject_ptr HOMARD_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
3313 CORBA::Long theObjectID,
3314 SALOMEDS::SObject_ptr theSObject)
3316 // No Copy/Paste support
3317 SALOMEDS::SObject_var aResultSO;
3318 return aResultSO._retn();
3321 //===========================================================================
3322 PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theObject)
3324 PortableServer::Servant aServant = 0;
3325 if (!CORBA::is_nil(theObject)) {
3327 aServant = _poa->reference_to_servant(theObject);
3335 //==========================================================================
3336 Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
3337 CORBA::Boolean isPublished,
3338 CORBA::Boolean isMultiFile,
3339 CORBA::Boolean& isValidScript)
3341 MESSAGE ("Entree dans DumpPython");
3343 SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
3344 if(CORBA::is_nil(aStudy))
3345 return new Engines::TMPFile(0);
3347 SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD");
3348 if(CORBA::is_nil(aSO))
3349 return new Engines::TMPFile(0);
3351 std::string aScript = "\"\"\"\n";
3352 aScript += "Python script for HOMARD\n";
3353 aScript += "Copyright EDF-R&D 2013\n";
3354 aScript += "\"\"\"\n";
3355 aScript += "__revision__ = \"V1.2\"\n";
3356 aScript += "import HOMARD\n";
3358 aScript += "import salome\n";
3359 aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n";
3361 aScript += "def RebuildData(theStudy):\n";
3362 aScript += "\thomard.SetCurrentStudy(theStudy)\n";
3365 aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n";
3366 MESSAGE (". Au depart \n"<<aScript);
3369 if (myContextMap[GetCurrentStudyID()]._mesBoundarys.size() > 0)
3371 MESSAGE (". Ecritures des frontieres");
3372 aScript += "#\n# Creation of the boundaries";
3373 aScript += "\n# ==========================";
3375 std::map<std::string, HOMARD::HOMARD_Boundary_var>::const_iterator it_boundary;
3376 for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin();
3377 it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary)
3379 HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second;
3380 CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython();
3381 std::string dumpBoundary = dumpCorbaBoundary.in();
3382 MESSAGE (dumpBoundary<<"\n");
3383 aScript += dumpBoundary;
3387 if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0)
3389 MESSAGE (". Ecritures des zones");
3390 aScript += "#\n# Creation of the zones";
3391 aScript += "\n# =====================";
3393 std::map<std::string, HOMARD::HOMARD_Zone_var>::const_iterator it_zone;
3394 for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin();
3395 it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone)
3397 HOMARD::HOMARD_Zone_var maZone = (*it_zone).second;
3398 CORBA::String_var dumpCorbaZone = maZone->GetDumpPython();
3399 std::string dumpZone = dumpCorbaZone.in();
3400 MESSAGE (dumpZone<<"\n");
3401 aScript += dumpZone;
3405 if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0)
3407 MESSAGE (". Ecritures des hypotheses");
3408 aScript += "#\n# Creation of the hypotheses";
3409 aScript += "\n# ==========================";
3411 std::map<std::string, HOMARD::HOMARD_Hypothesis_var>::const_iterator it_hypo;
3412 for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin();
3413 it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++)
3415 HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second;
3416 CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython();
3417 std::string dumpHypo = dumpCorbaHypo.in();
3418 MESSAGE (dumpHypo<<"\n");
3419 aScript += dumpHypo;
3423 if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0)
3425 MESSAGE (". Ecritures des cas");
3426 aScript += "#\n# Creation of the cases";
3427 aScript += "\n# =====================";
3429 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it_cas;
3430 for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin();
3431 it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++)
3433 std::string nomCas = (*it_cas).first;
3434 std::string dumpCas = std::string("\n# Creation of the case ") ;
3435 dumpCas += nomCas + std::string("\n");
3436 dumpCas += std::string("\t") + nomCas;
3437 dumpCas += std::string(" = homard.CreateCase('") + nomCas + std::string("', '");
3439 HOMARD::HOMARD_Cas_var myCase = (*it_cas).second;
3440 CORBA::String_var cIter0= myCase->GetIter0Name();
3441 std::string iter0 = cIter0.in();
3443 HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0];
3444 CORBA::String_var cMesh0= myIteration->GetMeshFile();
3445 std::string mesh0 = cMesh0.in();
3446 CORBA::String_var cMeshName0= myIteration->GetMeshName();
3447 std::string meshName0 = cMeshName0.in();
3448 dumpCas += meshName0 + std::string("', '")+ mesh0 + std::string("')\n");
3449 CORBA::String_var dumpCorbaCase = myCase->GetDumpPython();
3450 std::string dumpCas2= dumpCorbaCase.in();
3452 MESSAGE (dumpCas<<dumpCas2<<"\n");
3453 aScript += dumpCas + dumpCas2;
3457 if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0)
3459 MESSAGE (". Ecritures des iterations");
3460 aScript += "#\n# Creation of the iterations" ;
3461 aScript += "\n# ==========================";
3463 std::map<std::string, HOMARD::HOMARD_Iteration_var>::const_iterator it_iter;
3464 for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin();
3465 it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter)
3467 HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second;
3468 CORBA::String_var dumpCorbaIter = aIter->GetDumpPython();
3469 std::string dumpIter = dumpCorbaIter.in();
3470 MESSAGE (dumpIter<<"\n");
3471 aScript += dumpIter;
3474 MESSAGE (". Ecritures finales");
3476 aScript += "\n\tpass";
3479 if( !isMultiFile ) // remove unnecessary tabulation
3480 aScript = RemoveTabulation( aScript );
3482 // MESSAGE ("A ecrire \n"<<aScript);
3483 const size_t aLen = strlen(aScript.c_str());
3484 char* aBuffer = new char[aLen+1];
3485 strcpy(aBuffer, aScript.c_str());
3487 CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
3488 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
3490 MESSAGE ("Sortie de DumpPython");
3491 return aStreamFile._retn();
3495 //=============================================================================
3496 //=============================================================================
3498 //=============================================================================
3499 //=============================================================================
3500 void HOMARD_Gen_i::IsValidStudy( )
3502 // MESSAGE( "IsValidStudy" );
3503 if (CORBA::is_nil(myCurrentStudy))
3505 SALOME::ExceptionStruct es;
3506 es.type = SALOME::BAD_PARAM;
3507 es.text = "Invalid study context";
3508 throw SALOME::SALOME_Exception(es);
3513 //=============================================================================
3514 CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir)
3516 std::map<std::string, HOMARD::HOMARD_Cas_var>::const_iterator it;
3517 for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin();
3518 it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++)
3520 if (std::string(nomDir) == std::string(it->second->GetDirName())) return false;
3524 /*//=============================================================================
3525 void SALOMEException( std::string message )
3527 SALOME::ExceptionStruct es;
3528 es.type = SALOME::BAD_PARAM;
3530 throw SALOME::SALOME_Exception(es);
3533 //=============================================================================
3534 char* HOMARD_Gen_i::getVersion()
3536 #if HOMARD_DEVELOPMENT
3537 return CORBA::string_dup(HOMARD_VERSION_STR"dev");
3539 return CORBA::string_dup(HOMARD_VERSION_STR);
3543 //=============================================================================
3546 PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb,
3547 PortableServer::POA_ptr poa,
3548 PortableServer::ObjectId* contId,
3549 const char* instanceName,
3550 const char* interfaceName)
3552 MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
3553 HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName);
3554 return myHOMARD_Gen->getId();