X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHOMARD_I%2FHOMARD_Gen_i.cxx;h=63d70304335357ac524ab836fb67e71dccc3187c;hb=114be747f34dd617afb4a5e437c5d5f276d31b23;hp=344bf2ae26d6b3e687428bd5154d7f37a605d3be;hpb=3d988273687068a34cd617d830b44a403b4d44be;p=modules%2Fhomard.git diff --git a/src/HOMARD_I/HOMARD_Gen_i.cxx b/src/HOMARD_I/HOMARD_Gen_i.cxx old mode 100755 new mode 100644 index 344bf2ae..63d70304 --- a/src/HOMARD_I/HOMARD_Gen_i.cxx +++ b/src/HOMARD_I/HOMARD_Gen_i.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2011-2013 CEA/DEN, EDF R&D +// Copyright (C) 2011-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,21 +30,26 @@ #include "YACSDriver.hxx" #include "HOMARD.hxx" +#include "FrontTrack.hxx" + #include "HOMARD_version.h" #include "utilities.h" +#include "Basics_Utils.hxx" +#include "Basics_DirUtils.hxx" #include "Utils_SINGLETON.hxx" #include "Utils_CorbaException.hxx" #include "SALOMEDS_Tool.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "SALOMEconfig.h" -#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) -#include CORBA_CLIENT_HEADER(SMESH_Gen) +#include #include #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -54,6 +59,10 @@ #include #include +#ifdef WIN32 +#include +#endif + using namespace std; //============================================================================= @@ -81,25 +90,23 @@ HOMARD_Gen_i::HOMARD_Gen_i( CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId * contId, const char *instanceName, - const char *interfaceName) : -Engines_Component_i(orb, poa, contId, instanceName, interfaceName) + const char *interfaceName, + bool checkNS) : +Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, checkNS) { - MESSAGE("constructor"); + MESSAGE("constructor de HOMARD_Gen_i"); _thisObj = this; _id = _poa->activate_object(_thisObj); - myHomard = new ::HOMARD_Gen(); - _NS = SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - _NS->init_orb(_orb); + myHomard = new ::HOMARD_Gen; _tag_gene = 0 ; _tag_boun = 0 ; _tag_hypo = 0 ; _tag_yacs = 0 ; _tag_zone = 0 ; - _Langue = "Francais" ; - _LangueShort = "fr" ; + + SetPreferences( ) ; } //================================= /*! @@ -111,31 +118,28 @@ HOMARD_Gen_i::~HOMARD_Gen_i() } //============================================================================= //============================================================================= -// Utilitaires pour l'étude +// Utilitaires pour l'étude //============================================================================= //============================================================================= -void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy) +void HOMARD_Gen_i::UpdateStudy() { - ASSERT(!CORBA::is_nil(theStudy)); - MESSAGE("addInStudy: ajout eventuel du composant HOMARD dans current study ID = " << GetCurrentStudyID()) ; - SALOMEDS::StudyBuilder_var myBuilder = theStudy->NewBuilder(); + ASSERT(!CORBA::is_nil(myStudy)); + SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); // Create SComponent labelled 'homard' if it doesn't already exit - SALOMEDS::SComponent_var homardFather = theStudy->FindComponent(ComponentDataType()); + SALOMEDS::SComponent_var homardFather = myStudy->FindComponent(ComponentDataType()); if (CORBA::is_nil(homardFather)) { myBuilder->NewCommand(); MESSAGE("Add Component HOMARD"); - bool aLocked = theStudy->GetProperties()->IsLocked(); - if (aLocked) theStudy->GetProperties()->SetLocked(false); + bool aLocked = myStudy->GetProperties()->IsLocked(); + if (aLocked) myStudy->GetProperties()->SetLocked(false); homardFather = myBuilder->NewComponent(ComponentDataType()); SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName"); SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = this->getModuleCatalog(); SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType()); if (!Comp->_is_nil()) { @@ -147,32 +151,10 @@ void HOMARD_Gen_i::addInStudy(SALOMEDS::Study_ptr theStudy) aPixmap->SetPixMap("HOMARD_2.png"); myBuilder->DefineComponentInstance(homardFather, HOMARD_Gen::_this()); - if (aLocked) theStudy->GetProperties()->SetLocked(true); + if (aLocked) myStudy->GetProperties()->SetLocked(true); myBuilder->CommitCommand(); } } -//============================================================================= -void HOMARD_Gen_i::SetCurrentStudy(SALOMEDS::Study_ptr theStudy) -{ - MESSAGE("SetCurrentStudy: current study Id = " << GetCurrentStudyID()); - myCurrentStudy = SALOMEDS::Study::_duplicate(theStudy); - this->addInStudy(myCurrentStudy); -} -//============================================================================= -SALOMEDS::Study_ptr HOMARD_Gen_i::GetCurrentStudy() -//============================================================================= -{ - MESSAGE("GetCurrentStudy: study Id = " << GetCurrentStudyID()); - return SALOMEDS::Study::_duplicate(myCurrentStudy); -} -//============================================================================= -CORBA::Long HOMARD_Gen_i::GetCurrentStudyID() -//============================================================================= -{ - return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId(); -} -//============================================================================= -//============================================================================= //============================================================================= //============================================================================= @@ -183,7 +165,7 @@ void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat) //===================================================================================== { MESSAGE( "SetEtatIter : affectation de l'etat " << Etat << " a l'iteration " << nomIter ); - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; if (CORBA::is_nil(myIteration)) { SALOME::ExceptionStruct es; @@ -195,8 +177,8 @@ void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat) myIteration->SetState(Etat); - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); std::string icone ; if ( Etat <= 0 ) @@ -221,7 +203,7 @@ void HOMARD_Gen_i::SetEtatIter(const char* nomIter, const CORBA::Long Etat) CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName) { MESSAGE ( "DeleteBoundary : BoundaryName = " << BoundaryName ); - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName]; + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; if (CORBA::is_nil(myBoundary)) { SALOME::ExceptionStruct es; @@ -243,7 +225,7 @@ CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName) { CaseName = std::string((*maListe)[NumeCas]); MESSAGE ( "... Examen du cas = " << CaseName.c_str() ); - myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName]; + myCase = myStudyContext._mesCas[CaseName]; ASSERT(!CORBA::is_nil(myCase)); ListBoundaryGroupType = myCase->GetBoundaryGroup(); numberOfitems = ListBoundaryGroupType->length(); @@ -262,11 +244,11 @@ CORBA::Long HOMARD_Gen_i::DeleteBoundary(const char* BoundaryName) } // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete - myContextMap[GetCurrentStudyID()]._mesBoundarys.erase(BoundaryName); - SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(BoundaryName, ComponentDataType()); + myStudyContext._mesBoundarys.erase(BoundaryName); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(BoundaryName, ComponentDataType()); SALOMEDS::SObject_var aSO =listSO[0]; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); return 0 ; } @@ -275,7 +257,7 @@ CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option) { // Pour detruire un cas MESSAGE ( "DeleteCase : nomCas = " << nomCas << ", avec option = " << Option ); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; if (CORBA::is_nil(myCase)) { SALOME::ExceptionStruct es; @@ -293,11 +275,11 @@ CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option) }; // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete - myContextMap[GetCurrentStudyID()]._mesCas.erase(nomCas); - SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomCas, ComponentDataType()); + myStudyContext._mesCas.erase(nomCas); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomCas, ComponentDataType()); SALOMEDS::SObject_var aSO =listSO[0]; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); return 0 ; } @@ -305,7 +287,7 @@ CORBA::Long HOMARD_Gen_i::DeleteCase(const char* nomCas, CORBA::Long Option) CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo) { MESSAGE ( "DeleteHypo : nomHypo = " << nomHypo ); - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; if (CORBA::is_nil(myHypo)) { SALOME::ExceptionStruct es; @@ -340,11 +322,11 @@ CORBA::Long HOMARD_Gen_i::DeleteHypo(const char* nomHypo) } // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete - myContextMap[GetCurrentStudyID()]._mesHypotheses.erase(nomHypo); - SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomHypo, ComponentDataType()); + myStudyContext._mesHypotheses.erase(nomHypo); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomHypo, ComponentDataType()); SALOMEDS::SObject_var aSO =listSO[0]; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); return 0 ; } @@ -367,7 +349,7 @@ CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long // Option2 = 0 : On ne supprime pas le fichier du maillage associe // Option2 = 1 : On supprime le fichier du maillage associe MESSAGE ( "DeleteIterationOption : nomIter = " << nomIter << ", avec options = " << Option1<< ", " << Option2 ); - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; if (CORBA::is_nil(myIteration)) { SALOME::ExceptionStruct es; @@ -379,7 +361,7 @@ CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long int numero = myIteration->GetNumber(); MESSAGE ( "DeleteIterationOption : numero = " << numero ); - if ( numero == 0 and Option1 == 1 ) + if ( numero == 0 && Option1 == 1 ) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -412,7 +394,7 @@ CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long { std::string nomIterationParent = myIteration->GetIterParentName(); MESSAGE ( "Retrait dans la descendance de nomIterationParent " << nomIterationParent ); - HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent]; + HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent]; if (CORBA::is_nil(myIterationParent)) { SALOME::ExceptionStruct es; @@ -428,17 +410,17 @@ CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long if ( numero > 0 ) { std::string nomHypo = myIteration->GetHypoName(); - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; ASSERT(!CORBA::is_nil(myHypo)); myHypo->UnLinkIteration(nomIter); } // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete - myContextMap[GetCurrentStudyID()]._mesIterations.erase(nomIter); - SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomIter, ComponentDataType()); + myStudyContext._mesIterations.erase(nomIter); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomIter, ComponentDataType()); SALOMEDS::SObject_var aSO =listSO[0]; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); // on peut aussi faire RemoveObject // MESSAGE ( "Au final" ); // HOMARD::listeIterations* Liste = GetAllIterationsName() ; @@ -457,7 +439,7 @@ CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option) // Option = 0 : On ne supprime pas le fichier du schema associe // Option = 1 : On supprime le fichier du schema associe MESSAGE ( "DeleteYACS : nomYACS = " << nomYACS << ", avec option = " << Option ); - HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; if (CORBA::is_nil(myYACS)) { SALOME::ExceptionStruct es; @@ -482,11 +464,11 @@ CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option) } } // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete - myContextMap[GetCurrentStudyID()]._mesYACSs.erase(nomYACS); - SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomYACS, ComponentDataType()); + myStudyContext._mesYACSs.erase(nomYACS); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomYACS, ComponentDataType()); SALOMEDS::SObject_var aSO =listSO[0]; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); return 0 ; } @@ -494,7 +476,7 @@ CORBA::Long HOMARD_Gen_i::DeleteYACS(const char* nomYACS, CORBA::Long Option) CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone) { MESSAGE ( "DeleteZone : nomZone = " << nomZone ); - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[nomZone]; + HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[nomZone]; if (CORBA::is_nil(myZone)) { SALOME::ExceptionStruct es; @@ -512,17 +494,17 @@ CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; - es.text = "This zone is used in an hypothesis and cannot be deleted."; + es.text = "This zone is used in a hypothesis and cannot be deleted."; throw SALOME::SALOME_Exception(es); return 2 ; }; // // comme on a un _var comme pointeur CORBA, on ne se preoccupe pas du delete - myContextMap[GetCurrentStudyID()]._mesZones.erase(nomZone); - SALOMEDS::Study::ListOfSObject_var listSO = myCurrentStudy->FindObjectByName(nomZone, ComponentDataType()); + myStudyContext._mesZones.erase(nomZone); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(nomZone, ComponentDataType()); SALOMEDS::SObject_var aSO =listSO[0]; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + myStudy->NewBuilder()->RemoveObjectWithChildren(aSO); return 0 ; } @@ -537,7 +519,7 @@ CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone) void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName) { MESSAGE( "InvalideBoundary : BoundaryName = " << BoundaryName ); - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName]; + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; if (CORBA::is_nil(myBoundary)) { SALOME::ExceptionStruct es; @@ -559,7 +541,7 @@ void HOMARD_Gen_i::InvalideBoundary(const char* BoundaryName) void HOMARD_Gen_i::InvalideHypo(const char* nomHypo) { MESSAGE( "InvalideHypo : nomHypo = " << nomHypo ); - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; if (CORBA::is_nil(myHypo)) { SALOME::ExceptionStruct es; @@ -592,7 +574,7 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option) // Option = 0 : On ne supprime pas le fichier du maillage associe // Option = 1 : On supprime le fichier du maillage associe MESSAGE ( "InvalideIterOption : nomIter = " << nomIter << ", avec option = " << Option ); - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; if (CORBA::is_nil(myIteration)) { SALOME::ExceptionStruct es; @@ -613,8 +595,8 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option) // On arrive ici pour une iteration sans fille MESSAGE ( "Invalidation effective de " << nomIter ); - SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); - SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO); for (; aIter->More(); aIter->Next()) { SALOMEDS::SObject_var so = aIter->Value(); @@ -622,8 +604,9 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option) if (!so->FindAttribute(anAttr, "AttributeComment")) continue; SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr); std::string value (aCommentAttr->Value()); + if(value == std::string("IterationHomard")) continue; if(value == std::string("HypoHomard")) continue; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->RemoveObject(so); } @@ -632,7 +615,7 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option) { SetEtatIter(nomIter,1); const char * nomCas = myIteration->GetCaseName(); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; if (CORBA::is_nil(myCase)) { SALOME::ExceptionStruct es; @@ -664,7 +647,7 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option) void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter) { MESSAGE("InvalideIterInfo : nomIter = " << nomIter); - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; if (CORBA::is_nil(myIteration)) { SALOME::ExceptionStruct es; @@ -674,8 +657,8 @@ void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter) return ; }; - SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); - SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aIterSO); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aIterSO); for (; aIter->More(); aIter->Next()) { SALOMEDS::SObject_var so = aIter->Value(); @@ -684,15 +667,15 @@ void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter) SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr); std::string value (aCommentAttr->Value()); /* MESSAGE("... value = " << value);*/ - if( (value == std::string("logInfo")) or ( value == std::string("SummaryInfo")) ) + if( (value == std::string("logInfo")) || ( value == std::string("SummaryInfo")) ) { - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->RemoveObject(so); } } const char * nomCas = myIteration->GetCaseName(); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; if (CORBA::is_nil(myCase)) { SALOME::ExceptionStruct es; @@ -715,10 +698,51 @@ void HOMARD_Gen_i::InvalideIterInfo(const char* nomIter) } } //============================================================================= +void HOMARD_Gen_i::InvalideYACS(const char* YACSName) +{ + MESSAGE( "InvalideYACS : YACSName = " << YACSName ); + HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[YACSName]; + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid schema YACS"; + throw SALOME::SALOME_Exception(es); + return ; + }; + // + SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + SALOMEDS::ChildIterator_var aYACS = myStudy->NewChildIterator(aYACSSO); + for (; aYACS->More(); aYACS->Next()) + { + SALOMEDS::SObject_var so = aYACS->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (!so->FindAttribute(anAttr, "AttributeComment")) continue; + SALOMEDS::AttributeComment_var aCommentAttr = SALOMEDS::AttributeComment::_narrow(anAttr); + std::string value (aCommentAttr->Value()); + if( value == std::string("xml") ) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveObject(so); + } + } + std::string nomFichier = myYACS->GetXMLFile(); + std::string commande = "rm -rf " + std::string(nomFichier) ; + MESSAGE ( "commande = " << commande ); + if ((system(commande.c_str())) != 0) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "The XML file for the schema YACS cannot be removed." ; + throw SALOME::SALOME_Exception(es); + return ; + } +} +//============================================================================= void HOMARD_Gen_i::InvalideZone(const char* ZoneName) { MESSAGE( "InvalideZone : ZoneName = " << ZoneName ); - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName]; + HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; if (CORBA::is_nil(myZone)) { SALOME::ExceptionStruct es; @@ -749,7 +773,7 @@ void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, co { MESSAGE( "AssociateCaseIter : " << nomCas << ", " << nomIter << ", " << labelIter ); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; if (CORBA::is_nil(myCase)) { SALOME::ExceptionStruct es; @@ -759,7 +783,7 @@ void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, co return ; }; - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; if (CORBA::is_nil(myIteration)) { SALOME::ExceptionStruct es; @@ -769,8 +793,8 @@ void HOMARD_Gen_i::AssociateCaseIter(const char* nomCas, const char* nomIter, co return ; }; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase))); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::SObject_var aCasSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase))); if (CORBA::is_nil(aCasSO)) { SALOME::ExceptionStruct es; @@ -794,17 +818,17 @@ void HOMARD_Gen_i::AssociateHypoZone(const char* nomHypothesis, const char* Zone { MESSAGE ( "AssociateHypoZone : nomHypo = " << nomHypothesis << ", ZoneName= " << ZoneName << ", TypeUse = " << TypeUse); - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis]; ASSERT(!CORBA::is_nil(myHypo)); - SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo))); + SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo))); ASSERT(!CORBA::is_nil(aHypoSO)); - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName]; + HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; ASSERT(!CORBA::is_nil(myZone)); - SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone))); + SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone))); ASSERT(!CORBA::is_nil(aZoneSO)); - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); @@ -822,32 +846,29 @@ void HOMARD_Gen_i::AssociateIterHypo(const char* nomIter, const char* nomHypo) MESSAGE("AssociateIterHypo : nomHypo = " << nomHypo << " nomIter = " << nomIter); // Verification de l'existence de l'hypothese - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; ASSERT(!CORBA::is_nil(myHypo)); - SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo))); + SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo))); ASSERT(!CORBA::is_nil(aHypoSO)); // Verification de l'existence de l'iteration - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[nomIter]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[nomIter]; ASSERT(!CORBA::is_nil(myIteration)); - SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); ASSERT(!CORBA::is_nil(aIterSO)); - // Gestion de l'etude - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); - + // Gestion de l'arbre d'etudes + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); - SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); aStudyBuilder->Addreference(aSubSO, aHypoSO); - aStudyBuilder->CommitCommand(); // Liens reciproques myIteration->SetHypoName(nomHypo); myHypo->LinkIteration(nomIter); - // On stocke les noms des champ a interpoler pour le futur controle de la donnee des pas de temps + // On stocke les noms des champ a interpoler pour le futur controle de la donnée des pas de temps myIteration->SupprFieldInterps() ; HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps(); int numberOfFieldsx2 = ListField->length(); @@ -870,19 +891,19 @@ void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* Zon { MESSAGE ( "DissociateHypoZone : ZoneName= " << ZoneName << ", nomHypo = " << nomHypothesis); - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypothesis]; ASSERT(!CORBA::is_nil(myHypo)); - SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myHypo))); + SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myHypo))); ASSERT(!CORBA::is_nil(aHypoSO)); - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName]; + HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; ASSERT(!CORBA::is_nil(myZone)); - SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myZone))); + SALOMEDS::SObject_var aZoneSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myZone))); ASSERT(!CORBA::is_nil(aZoneSO)); - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); - SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator(aHypoSO); + SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(aHypoSO); for (; it->More(); it->Next()) { SALOMEDS::SObject_var aHypObj = it->Value(); @@ -917,11 +938,11 @@ HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName() IsValidStudy () ; HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys; - ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size()); + ret->length(myStudyContext._mesBoundarys.size()); std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin(); - it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++) + for (it = myStudyContext._mesBoundarys.begin(); + it != myStudyContext._mesBoundarys.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -935,11 +956,11 @@ HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName() IsValidStudy () ; HOMARD::listeCases_var ret = new HOMARD::listeCases; - ret->length(myContextMap[GetCurrentStudyID()]._mesCas.size()); + ret->length(myStudyContext._mesCas.size()); std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin(); - it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++) + for (it = myStudyContext._mesCas.begin(); + it != myStudyContext._mesCas.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -953,11 +974,11 @@ HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName() IsValidStudy () ; HOMARD::listeHypotheses_var ret = new HOMARD::listeHypotheses; - ret->length(myContextMap[GetCurrentStudyID()]._mesHypotheses.size()); + ret->length(myStudyContext._mesHypotheses.size()); std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin(); - it != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it++) + for (it = myStudyContext._mesHypotheses.begin(); + it != myStudyContext._mesHypotheses.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -971,11 +992,11 @@ HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName() IsValidStudy () ; HOMARD::listeIterations_var ret = new HOMARD::listeIterations; - ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size()); + ret->length(myStudyContext._mesIterations.size()); std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin(); - it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++) + for (it = myStudyContext._mesIterations.begin(); + it != myStudyContext._mesIterations.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -989,11 +1010,11 @@ HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName() IsValidStudy () ; HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs; - ret->length(myContextMap[GetCurrentStudyID()]._mesYACSs.size()); + ret->length(myStudyContext._mesYACSs.size()); std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesYACSs.begin(); - it != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); it++) + for (it = myStudyContext._mesYACSs.begin(); + it != myStudyContext._mesYACSs.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -1007,11 +1028,11 @@ HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName() IsValidStudy () ; HOMARD::listeZones_var ret = new HOMARD::listeZones; - ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size()); + ret->length(myStudyContext._mesZones.size()); std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin(); - it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++) + for (it = myStudyContext._mesZones.begin(); + it != myStudyContext._mesZones.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -1028,42 +1049,42 @@ HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName() //============================================================================= HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary) { - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary]; + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[nomBoundary]; ASSERT(!CORBA::is_nil(myBoundary)); return HOMARD::HOMARD_Boundary::_duplicate(myBoundary); } //============================================================================= HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas) { - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; ASSERT(!CORBA::is_nil(myCase)); return HOMARD::HOMARD_Cas::_duplicate(myCase); } //============================================================================= HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis) { - HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis]; + HOMARD::HOMARD_Hypothesis_var myHypothesis = myStudyContext._mesHypotheses[nomHypothesis]; ASSERT(!CORBA::is_nil(myHypothesis)); return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis); } //============================================================================= HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIterationation) { - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIterationation]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIterationation]; ASSERT(!CORBA::is_nil(myIteration)); return HOMARD::HOMARD_Iteration::_duplicate(myIteration); } //============================================================================= HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS) { - HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; ASSERT(!CORBA::is_nil(myYACS)); return HOMARD::HOMARD_YACS::_duplicate(myYACS); } //============================================================================= HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName) { - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName]; + HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; ASSERT(!CORBA::is_nil(myZone)); return HOMARD::HOMARD_Zone::_duplicate(myZone); } @@ -1077,12 +1098,14 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName) //============================================================================= 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) { - INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); - INFOS ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte ); + MESSAGE ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); + MESSAGE ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte ); IsValidStudy () ; // Creation du cas - HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, 1) ; + int option = 1 ; + if ( _PublisMeshIN != 0 ) option = 2 ; + HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, 0, option) ; myCase->SetDirName(DirName) ; // Analyse myCase->MeshInfo(Qual, Diam, Conn, Tail, Inte) ; @@ -1099,7 +1122,7 @@ void HOMARD_Gen_i::MeshInfo(const char* nomCas, const char* MeshName, const char //============================================================================= HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::LastIteration(const char* nomCas) { - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; ASSERT(!CORBA::is_nil(myCase)); // HOMARD::HOMARD_Iteration_var myIteration = myCase->LastIteration(); @@ -1179,8 +1202,9 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* { INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); - // Par defaut, on ne publie pas le maillage - HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, 1) ; + int option = 1 ; + if ( _PublisMeshIN != 0 ) option = 2 ; + HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, option) ; // Valeurs par defaut des filtrages myCase->SetPyram(0); @@ -1191,16 +1215,16 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, const char* DirNameStart) // // nomCas : nom du cas a creer -// DirNameStart : nom du repertoire contenant l'iteration de reprise +// DirNameStart : nom du répertoire contenant l'iteration de reprise // { - INFOS ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); + MESSAGE ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); std::string nomDirWork = getenv("PWD") ; int codret ; // A. Decodage du point de reprise - // A.1. Controle du repertoire de depart de l'iteration - codret = chdir(DirNameStart) ; + // A.1. Controle du répertoire de depart de l'iteration + codret = CHDIR(DirNameStart) ; if ( codret != 0 ) { SALOME::ExceptionStruct es; @@ -1209,10 +1233,11 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, throw SALOME::SALOME_Exception(es); return 0; }; - // A.2. Reperage des fichiers du repertoire de reprise + // A.2. Reperage des fichiers du répertoire de reprise std::string file_configuration = "" ; std::string file_maillage_homard = "" ; int bilan ; +#ifndef WIN32 DIR *dp; struct dirent *dirp; dp = opendir(DirNameStart); @@ -1230,10 +1255,30 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, } } closedir(dp); +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirNameStart, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name(ffd.cFileName); + bilan = file_name.find("HOMARD.Configuration.") ; + if ( bilan != string::npos ) { file_configuration = file_name ; } + bilan = file_name.find("maill.") ; + if ( bilan != string::npos ) + { + bilan = file_name.find(".hom.med") ; + if ( bilan != string::npos ) { file_maillage_homard = file_name ; } + } + } + FindClose(hFind); + } +#endif MESSAGE ( "==> file_configuration : " << file_configuration ) ; MESSAGE ( "==> file_maillage_homard : " << file_maillage_homard ) ; // A.3. Controle - if ( ( file_configuration == "" ) or ( file_maillage_homard == "" ) ) + if ( ( file_configuration == "" ) || ( file_maillage_homard == "" ) ) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -1247,19 +1292,20 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, // B. Lecture du fichier de configuration // ATTENTION : on doit veiller a la coherence entre HomardDriver et CreateCaseFromIteration int NumeIter ; + int TypeExt = 0 ; int TypeConf = 0 ; int Pyram = 0 ; char* MeshName ; char* MeshFile ; // le constructeur de ifstream permet d'ouvrir un fichier en lecture std::ifstream fichier( file_configuration.c_str() ); - if ( fichier ) // ce test échoue si le fichier n'est pas ouvert + if ( fichier ) // ce test échoue si le fichier n'est pas ouvert { std::string ligne; // variable contenant chaque ligne lue std::string mot_cle; std::string argument; int decalage; - // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient + // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient while ( std::getline( fichier, ligne ) ) { // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle @@ -1272,7 +1318,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, NumeIter += 1 ; } // B.3. Des valeurs caracteres brutes : le second bloc de la ligne est la valeur - else if ( ( mot_cle == "TypeConf" ) or ( mot_cle == "TypeElem" ) ) + else if ( ( mot_cle == "TypeConf" ) || ( mot_cle == "TypeElem" ) ) { ligne_bis >> argument ; @@ -1291,7 +1337,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, } // B.4. Des valeurs caracteres : le deuxieme bloc de la ligne peut etre encadre par des quotes : // il faut les supprimer - else if ( ( mot_cle == "CCNoMNP1" ) or ( mot_cle == "CCMaiNP1" ) ) + else if ( ( mot_cle == "CCNoMNP1" ) || ( mot_cle == "CCMaiNP1" ) ) { ligne_bis >> argument ; if ( argument[0] == '"' ) { decalage = 1 ; } @@ -1329,18 +1375,20 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, // C. Creation effective du cas - // Par defaut, on ne publie pas le maillage - HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, 1) ; + int option = 1 ; + if ( _PublisMeshIN != 0 ) option = 2 ; + HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, option) ; // D. Parametrages lus dans le fichier de configuration myCase->SetConfType (TypeConf) ; + myCase->SetExtType (TypeExt) ; myCase->SetPyram (Pyram) ; // E. Copie du fichier de maillage homard - // E.1. Repertoire associe au cas + // E.1. Répertoire associe au cas char* nomDirCase = myCase->GetDirName() ; - // E.2. Repertoire associe a l'iteration de ce cas + // E.2. Répertoire associe a l'iteration de ce cas char* IterName ; IterName = myCase->GetIter0Name() ; HOMARD::HOMARD_Iteration_var Iter = GetIteration(IterName) ; @@ -1348,7 +1396,11 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, Iter->SetDirNameLoc(nomDirIter); std::string nomDirIterTotal ; nomDirIterTotal = std::string(nomDirCase) + "/" + std::string(nomDirIter) ; +#ifndef WIN32 if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) +#else + if (_mkdir(nomDirIterTotal.c_str()) != 0) +#endif { MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ; SALOME::ExceptionStruct es; @@ -1358,7 +1410,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, throw SALOME::SALOME_Exception(es); } // E.3. Copie du maillage HOMARD au format MED - codret = chdir(DirNameStart) ; + codret = CHDIR(DirNameStart) ; std::string commande = "cp " + file_maillage_homard + " " + nomDirIterTotal ; MESSAGE ( "commande : " << commande ) ; codret = system(commande.c_str()) ; @@ -1377,18 +1429,17 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, delete[] MeshName ; delete[] MeshFile ; - chdir(nomDirWork.c_str()); - + CHDIR(nomDirWork.c_str()); return HOMARD::HOMARD_Cas::_duplicate(myCase); } //============================================================================= HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* nomCas, const char* DirNameStart) // // nomCas : nom du cas a creer -// DirNameStart : nom du repertoire du cas contenant l'iteration de reprise +// DirNameStart : nom du répertoire du cas contenant l'iteration de reprise // { - INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); + MESSAGE ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ; @@ -1401,11 +1452,11 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nomCas, const char* DirNameStart, CORBA::Long Number) // // nomCas : nom du cas a creer -// DirNameStart : nom du repertoire du cas contenant l'iteration de reprise +// DirNameStart : nom du répertoire du cas contenant l'iteration de reprise // Number : numero de l'iteration de depart // { - INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number ); + MESSAGE ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number ); if ( Number < 0 ) { SALOME::ExceptionStruct es; @@ -1425,8 +1476,8 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nom //============================================================================= std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Number) // -// Retourne le nom du repertoire ou se trouve l'iteration voulue. -// DirNameStart : nom du repertoire du cas contenant l'iteration de reprise +// Retourne le nom du répertoire ou se trouve l'iteration voulue. +// DirNameStart : nom du répertoire du cas contenant l'iteration de reprise // Number : numero de l'iteration de depart ou -1 si on cherche la derniere // { @@ -1436,8 +1487,8 @@ std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Numb int codret ; int NumeIterMax = -1 ; - // A.1. Controle du repertoire de depart du cas - codret = chdir(DirNameStart) ; + // A.1. Controle du répertoire de depart du cas + codret = CHDIR(DirNameStart) ; if ( codret != 0 ) { SALOME::ExceptionStruct es; @@ -1446,38 +1497,60 @@ std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Numb throw SALOME::SALOME_Exception(es); return 0; }; - // A.2. Reperage des sous-repertoire du repertoire de reprise + // A.2. Reperage des sous-répertoire du répertoire de reprise bool existe = false ; +#ifndef WIN32 DIR *dp; struct dirent *dirp; dp = opendir(DirNameStart); - while ( (dirp = readdir(dp)) != NULL ) - { + while ( (dirp = readdir(dp)) != NULL ) { std::string DirName_1(dirp->d_name); - if ( ( DirName_1 != "." ) and ( DirName_1 != ".." ) ) +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirNameStart, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + std::string DirName_1 = ""; + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + DirName_1 = std::string(ffd.cFileName); + } +#endif + if ( ( DirName_1 != "." ) && ( DirName_1 != ".." ) ) { - if ( chdir(DirName_1.c_str()) == 0 ) + if ( CHDIR(DirName_1.c_str()) == 0 ) { - // On cherche le fichier de configuration dans ce sous-repertoire - codret = chdir(DirNameStart) ; +// On cherche le fichier de configuration dans ce sous-répertoire + codret = CHDIR(DirNameStart); +#ifndef WIN32 DIR *dp_1; struct dirent *dirp_1; dp_1 = opendir(DirName_1.c_str()) ; while ( (dirp_1 = readdir(dp_1)) != NULL ) { std::string file_name_1(dirp_1->d_name); +#else + HANDLE hFind1 = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd1; + hFind1 = FindFirstFile(DirName_1.c_str(), &ffd1); + while (FindNextFile(hFind1, &ffd1) != 0) + { + if (ffd1.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name_1(ffd1.cFileName); +#endif int bilan = file_name_1.find("HOMARD.Configuration.") ; if ( bilan != string::npos ) { // Decodage du fichier pour trouver le numero d'iteration - chdir(DirName_1.c_str()) ; + CHDIR(DirName_1.c_str()) ; + std::ifstream fichier( file_name_1.c_str() ); - if ( fichier ) // ce test échoue si le fichier n'est pas ouvert + if ( fichier ) // ce test échoue si le fichier n'est pas ouvert { int NumeIter ; std::string ligne; // variable contenant chaque ligne lue std::string mot_cle; - // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient + // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient while ( std::getline( fichier, ligne ) ) { // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle @@ -1516,20 +1589,27 @@ std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Numb es.text = CORBA::string_dup(text.c_str()); throw SALOME::SALOME_Exception(es); } - chdir(DirNameStart) ; + CHDIR(DirNameStart) ; } if ( existe ) { break ; } } +#ifndef WIN32 closedir(dp_1); +#else + FindClose(hFind1); +#endif if ( existe ) { break ; } - } + } } } +#ifndef WIN32 closedir(dp); +#else + FindClose(hFind); +#endif + CHDIR(nomDirWork.c_str()); - chdir(nomDirWork.c_str()); - - if ( ( Number >= 0 and ( not existe ) ) or ( Number < 0 and ( NumeIterMax == -1 ) ) ) + if ( ( Number >= 0 && ( !existe ) ) || ( Number < 0 && ( NumeIterMax == -1 ) ) ) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -1562,7 +1642,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* IsValidStudy () ; // A.2. Controle du nom : - if ((myContextMap[GetCurrentStudyID()]._mesCas).find(nomCas)!=(myContextMap[GetCurrentStudyID()]._mesCas).end()) + if ((myStudyContext._mesCas).find(nomCas)!=(myStudyContext._mesCas).end()) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -1577,7 +1657,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* { existeMeshFile = MEDFileExist ( MeshFile ) ; MESSAGE ( "CreateCase0 : existeMeshFile = " << existeMeshFile ); - if ( ( existeMeshFile == 0 ) and ( MeshOption == 0 ) ) + if ( ( existeMeshFile == 0 ) && ( MeshOption == 0 ) ) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -1593,17 +1673,17 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* HOMARD::HOMARD_Cas_var myCase = newCase(); myCase->SetName(nomCas); SALOMEDS::SObject_var aSO; - SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myCase, nomCas); - myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase; + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myCase, nomCas); + myStudyContext._mesCas[nomCas] = myCase; // C. Caracteristiques du maillage if ( existeMeshFile != 0 ) { - // Les valeurs extremes des coordonnees -// MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnees" ); + // Les valeurs extremes des coordonnées +// MESSAGE ( "CreateCase0 : Les valeurs extremes des coordonnées" ); std::vector LesExtremes =GetBoundingBoxInMedFile(MeshFile) ; HOMARD::extrema_var aSeq = new HOMARD::extrema() ; - if (LesExtremes.size()!=10) { return false; } + if (LesExtremes.size()!=10) { return 0; } aSeq->length(10) ; for (int i =0 ; i< LesExtremes.size() ; i++) aSeq[i]=LesExtremes[i] ; @@ -1626,7 +1706,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* // Si ce nom d'iteration existe deja, on incremente avec 0, 1, 2, etc. int monNum = 0; std::string NomIteration = std::string(MeshName) ; - while ( (myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration) != (myContextMap[GetCurrentStudyID()]._mesIterations.end()) ) + while ( (myStudyContext._mesIterations).find(NomIteration) != (myStudyContext._mesIterations.end()) ) { std::ostringstream nom; nom << MeshName << monNum; @@ -1637,7 +1717,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* // D.2. Creation de l'iteration HOMARD::HOMARD_Iteration_var anIter = newIteration(); - myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration] = anIter; + myStudyContext._mesIterations[NomIteration] = anIter; anIter->SetName(NomIteration.c_str()); AssociateCaseIter (nomCas, NomIteration.c_str(), "IterationHomard"); @@ -1661,11 +1741,11 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* //============================================================================= HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis) { - INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis ); + MESSAGE ( "CreateHypothesis : nomHypothesis = " << nomHypothesis ); IsValidStudy () ; // A. Controle du nom : - if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end()) + if ((myStudyContext._mesHypotheses).find(nomHypothesis) != (myStudyContext._mesHypotheses).end()) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -1687,16 +1767,16 @@ HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypo myHypothesis->SetName(nomHypothesis); // C. Enregistrement - myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis; + myStudyContext._mesHypotheses[nomHypothesis] = myHypothesis; SALOMEDS::SObject_var aSO; - SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis); + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myHypothesis, nomHypothesis); // D. Valeurs par defaut des options avancees myHypothesis->SetNivMax(-1); myHypothesis->SetDiamMin(-1.0); myHypothesis->SetAdapInit(0); - myHypothesis->SetLevelOutput(0); + myHypothesis->SetExtraOutput(1); return HOMARD::HOMARD_Hypothesis::_duplicate(myHypothesis); } @@ -1705,10 +1785,10 @@ HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypo HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIteration, const char* nomIterParent) //============================================================================= { - INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent); + MESSAGE ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent); IsValidStudy () ; - HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent]; + HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterParent]; if (CORBA::is_nil(myIterationParent)) { SALOME::ExceptionStruct es; @@ -1720,7 +1800,7 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIterat const char* nomCas = myIterationParent->GetCaseName(); MESSAGE ("CreateIteration : nomCas = " << nomCas); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; if (CORBA::is_nil(myCase)) { SALOME::ExceptionStruct es; @@ -1732,7 +1812,7 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIterat const char* nomDirCase = myCase->GetDirName(); // Controle du nom : - if ((myContextMap[GetCurrentStudyID()]._mesIterations).find(NomIteration)!=(myContextMap[GetCurrentStudyID()]._mesIterations).end()) + if ((myStudyContext._mesIterations).find(NomIteration)!=(myStudyContext._mesIterations).end()) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -1750,7 +1830,7 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIterat throw SALOME::SALOME_Exception(es); return 0; }; - myContextMap[GetCurrentStudyID()]._mesIterations[std::string(NomIteration)] = myIteration; + myStudyContext._mesIterations[std::string(NomIteration)] = myIteration; // Nom de l'iteration et du maillage myIteration->SetName(NomIteration); myIteration->SetMeshName(NomIteration); @@ -1760,7 +1840,7 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIterat myIteration->SetNumber(numero); // Nombre d'iterations deja connues pour le cas, permettant -// la creation d'un sous-repertoire unique +// la creation d'un sous-répertoire unique int nbitercase = myCase->GetNumberofIter(); char* nomDirIter = CreateDirNameIter(nomDirCase, nbitercase ); myIteration->SetDirNameLoc(nomDirIter); @@ -1789,6 +1869,14 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::CreateIteration(const char* NomIterat // Lien avec l'iteration precedente myIterationParent->LinkNextIteration(NomIteration); myIteration->SetIterParentName(nomIterParent); + // Gestion de l'arbre d'etudes + SALOMEDS::SObject_var aIterSOParent = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIterationParent))); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->NewCommand(); + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); + aStudyBuilder->Addreference(aSubSO, aIterSOParent); + aStudyBuilder->CommitCommand(); return HOMARD::HOMARD_Iteration::_duplicate(myIteration); } @@ -1799,7 +1887,7 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryNam IsValidStudy () ; // Controle du nom : - if ((myContextMap[GetCurrentStudyID()]._mesBoundarys).find(BoundaryName)!=(myContextMap[GetCurrentStudyID()]._mesBoundarys).end()) + if ((myStudyContext._mesBoundarys).find(BoundaryName)!=(myStudyContext._mesBoundarys).end()) { MESSAGE ("CreateBoundary : la frontiere " << BoundaryName << " existe deja"); SALOME::ExceptionStruct es; @@ -1813,19 +1901,28 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryNam myBoundary->SetName(BoundaryName); myBoundary->SetType(BoundaryType); - myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName] = myBoundary; + myStudyContext._mesBoundarys[BoundaryName] = myBoundary; SALOMEDS::SObject_var aSO; - SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myBoundary, BoundaryName); + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myBoundary, BoundaryName); + + return HOMARD::HOMARD_Boundary::_duplicate(myBoundary); +} +//============================================================================= +HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCAO(const char* BoundaryName, const char* CAOFile) +{ + MESSAGE ("CreateBoundaryCAO : BoundaryName = " << BoundaryName << ", CAOFile = " << CAOFile ); + HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, -1); + myBoundary->SetDataFile( CAOFile ) ; return HOMARD::HOMARD_Boundary::_duplicate(myBoundary); } //============================================================================= HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile) { - INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName ); + MESSAGE ("CreateBoundaryDi : BoundaryName = " << BoundaryName << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0); - myBoundary->SetMeshFile( MeshFile ) ; + myBoundary->SetDataFile( MeshFile ) ; myBoundary->SetMeshName( MeshName ) ; return HOMARD::HOMARD_Boundary::_duplicate(myBoundary); @@ -1836,7 +1933,7 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* Bou CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Rayon) { - INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ; + MESSAGE ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -1864,7 +1961,7 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* Bound CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon) { - INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ; + MESSAGE ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -1888,11 +1985,11 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeA(const char* Bounda CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Angle, CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre) { - INFOS ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ; + MESSAGE ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ; // SALOME::ExceptionStruct es; int error = 0 ; - if ( Angle <= 0.0 or Angle >= 90.0 ) + if ( Angle <= 0.0 || Angle >= 90.0 ) { es.text = "The angle must be included higher than 0 degree and lower than 90 degrees." ; error = 1 ; } double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; @@ -1916,11 +2013,11 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* Bounda CORBA::Double Xcentre1, CORBA::Double Ycentre1, CORBA::Double Zcentre1, CORBA::Double Rayon1, CORBA::Double Xcentre2, CORBA::Double Ycentre2, CORBA::Double Zcentre2, CORBA::Double Rayon2) { - INFOS ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ; + MESSAGE ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ; // SALOME::ExceptionStruct es; int error = 0 ; - if ( Rayon1 < 0.0 or Rayon2 < 0.0 ) + if ( Rayon1 < 0.0 || Rayon2 < 0.0 ) { es.text = "The radius must be positive." ; error = 1 ; } double daux = fabs(Rayon2-Rayon1) ; @@ -1944,13 +2041,42 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryConeR(const char* Bounda return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ; } //============================================================================= +HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryTorus(const char* BoundaryName, + CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, + CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, + CORBA::Double RayonRev, CORBA::Double RayonPri) +{ + MESSAGE ("CreateBoundaryTorus : BoundaryName = " << BoundaryName ) ; +// + SALOME::ExceptionStruct es; + int error = 0 ; + if ( ( RayonRev <= 0.0 ) || ( RayonPri <= 0.0 ) ) + { es.text = "The radius must be positive." ; + error = 1 ; } + double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; + if ( daux < 0.0000001 ) + { es.text = "The axis must be a non 0 vector." ; + error = 2 ; } + if ( error != 0 ) + { + es.type = SALOME::BAD_PARAM; + throw SALOME::SALOME_Exception(es); + return 0; + }; +// + HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 5) ; + myBoundary->SetTorus( Xcentre, Ycentre, Zcentre, Xaxe, Yaxe, Zaxe, RayonRev, RayonPri ) ; + + return HOMARD::HOMARD_Boundary::_duplicate(myBoundary) ; +} +//============================================================================= HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Long ZoneType) { MESSAGE ("CreateZone : ZoneName = " << ZoneName << ", ZoneType = " << ZoneType); IsValidStudy () ; // Controle du nom : - if ((myContextMap[GetCurrentStudyID()]._mesZones).find(ZoneName)!=(myContextMap[GetCurrentStudyID()]._mesZones).end()) + if ((myStudyContext._mesZones).find(ZoneName)!=(myStudyContext._mesZones).end()) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -1963,10 +2089,10 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZone(const char* ZoneName, CORBA::Lo myZone->SetName(ZoneName); myZone->SetType(ZoneType); - myContextMap[GetCurrentStudyID()]._mesZones[ZoneName] = myZone; + myStudyContext._mesZones[ZoneName] = myZone; SALOMEDS::SObject_var aSO; - SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myZone, ZoneName); + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myZone, ZoneName); return HOMARD::HOMARD_Zone::_duplicate(myZone); } @@ -1976,7 +2102,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName, CORBA::Double Ymini, CORBA::Double Ymaxi, CORBA::Double Zmini, CORBA::Double Zmaxi) { - INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ; + MESSAGE ("CreateZoneBox : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -2005,7 +2131,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName, HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneSphere(const char* ZoneName, CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon) { - INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ; + MESSAGE ("CreateZoneSphere : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -2030,7 +2156,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneCylinder(const char* ZoneName, CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Rayon, CORBA::Double Haut) { - INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ; + MESSAGE ("CreateZoneCylinder : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -2062,11 +2188,11 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZonePipe(const char* ZoneName, CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Rayon, CORBA::Double Haut, CORBA::Double Rayonint) { - INFOS ("CreateZonePipe : ZoneName = " << ZoneName ) ; + MESSAGE ("CreateZonePipe : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; - if ( Rayon <= 0.0 or Rayonint <= 0.0 ) + if ( Rayon <= 0.0 || Rayonint <= 0.0 ) { es.text = "The radius must be positive." ; error = 1 ; } double daux = fabs(Xaxe) + fabs(Yaxe) + fabs(Zaxe) ; @@ -2097,7 +2223,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName, CORBA::Double Vmini, CORBA::Double Vmaxi, CORBA::Long Orient) { - INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ; + MESSAGE ("CreateZoneBox2D : ZoneName = " << ZoneName ) ; // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ; // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ; // MESSAGE ("Orient = " << Orient ) ; @@ -2110,7 +2236,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName, if ( Vmini > Vmaxi ) { es.text = "The second coordinates are not coherent." ; error = 2 ; } - if ( Orient < 1 or Orient > 3 ) + if ( Orient < 1 || Orient > 3 ) { es.text = "The orientation must be 1, 2 or 3." ; error = 3 ; } if ( error != 0 ) @@ -2144,7 +2270,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName, Ymaxi = 0. ; Zmini = Umini ; Zmaxi = Umaxi ; } - else { VERIFICATION( (Orient>=1) and (Orient<=3) ) ; } + else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; } HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 10+Orient) ; myZone->SetBox ( Xmini, Xmaxi, Ymini, Ymaxi, Zmini, Zmaxi) ; @@ -2157,14 +2283,14 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName, CORBA::Double Rayon, CORBA::Long Orient) { - INFOS ("CreateZoneDisk : ZoneName = " << ZoneName ) ; + MESSAGE ("CreateZoneDisk : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; if ( Rayon <= 0.0 ) { es.text = "The radius must be positive." ; error = 1 ; } - if ( Orient < 1 or Orient > 3 ) + if ( Orient < 1 || Orient > 3 ) { es.text = "The orientation must be 1, 2 or 3." ; error = 3 ; } if ( error != 0 ) @@ -2189,7 +2315,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName, { Xcentre = Vcentre ; Ycentre = 0. ; Zcentre = Ucentre ; } - else { VERIFICATION( (Orient>=1) and (Orient<=3) ) ; } + else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; } HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 30+Orient) ; myZone->SetCylinder( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1. ) ; @@ -2202,14 +2328,14 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneNam CORBA::Double Rayon, CORBA::Double Rayonint, CORBA::Long Orient) { - INFOS ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ; + MESSAGE ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; - if ( Rayon <= 0.0 or Rayonint <= 0.0 ) + if ( Rayon <= 0.0 || Rayonint <= 0.0 ) { es.text = "The radius must be positive." ; error = 1 ; } - if ( Orient < 1 or Orient > 3 ) + if ( Orient < 1 || Orient > 3 ) { es.text = "The orientation must be 1, 2 or 3." ; error = 3 ; } if ( Rayon <= Rayonint ) @@ -2237,7 +2363,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneNam { Xcentre = Vcentre ; Ycentre = 0. ; Zcentre = Ucentre ; } - else { VERIFICATION( (Orient>=1) and (Orient<=3) ) ; } + else { VERIFICATION( (Orient>=1) && (Orient<=3) ) ; } HOMARD::HOMARD_Zone_var myZone = CreateZone(ZoneName, 60+Orient) ; myZone->SetPipe( Xcentre, Ycentre, Zcentre, 0., 0., 1., Rayon, 1., Rayonint ) ; @@ -2253,7 +2379,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneNam //============================================================================= //============================================================================= // Traitement d'une iteration -// etatMenage = 1 : destruction du repertoire d'execution +// etatMenage = 1 : destruction du répertoire d'execution // modeHOMARD = 1 : adaptation // != 1 : information avec les options modeHOMARD // Option1 >0 : appel depuis python @@ -2270,10 +2396,47 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena int codret = 0; // A.1. L'objet iteration - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIteration]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIteration]; ASSERT(!CORBA::is_nil(myIteration)); - // A.2. Numero de l'iteration + // A.2. Controle de la possibilite d'agir + // A.2.1. Etat de l'iteration + int etat = myIteration->GetState(); + MESSAGE ( "etat = "<GetCaseName(); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; ASSERT(!CORBA::is_nil(myCase)); - // B. Les repertoires - // B.1. Le repertoire courant + // B. Les répertoires + // B.1. Le répertoire courant std::string nomDirWork = getenv("PWD") ; - // B.2. Le sous-repertoire de l'iteration a traiter + // B.2. Le sous-répertoire de l'iteration a traiter char* DirCompute = ComputeDirManagement(myCase, myIteration, etatMenage); MESSAGE( ". DirCompute = " << DirCompute ); @@ -2329,11 +2492,11 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena FileInfo += "." + siterp1 + ".bilan" ; myIteration->SetFileInfo(FileInfo.c_str()); - // D. On passe dans le repertoire de l'iteration a calculer + // D. On passe dans le répertoire de l'iteration a calculer MESSAGE ( ". On passe dans DirCompute = " << DirCompute ); - chdir(DirCompute) ; + CHDIR(DirCompute); - // E. Les donnees de l'execution HOMARD + // E. Les données de l'exécution HOMARD // E.1. L'objet du texte du fichier de configuration HomardDriver* myDriver = new HomardDriver(siter, siterp1); myDriver->TexteInit(DirCompute, LogFile, _Langue); @@ -2344,7 +2507,7 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena const char* MeshFile = myIteration->GetMeshFile(); MESSAGE ( ". MeshFile = " << MeshFile ); - // E.3. Les donnees du traitement HOMARD + // E.3. Les données du traitement HOMARD int iaux ; if ( modeHOMARD == 1 ) { @@ -2364,7 +2527,7 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena } // E.4. Ajout des informations liees a l'eventuel suivi de frontiere - DriverTexteBoundary(myCase, myDriver) ; + int BoundaryOption = DriverTexteBoundary(myCase, myDriver) ; // E.5. Ecriture du texte dans le fichier MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<ExecuteHomard(Option1); @@ -2419,14 +2582,14 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena // H.3 Message d'erreur if (codretexec != 0) { - std::string text ; + std::string text = "" ; // Message d'erreur en cas de probleme en adaptation if ( modeHOMARD == 1 ) { text = "Error during the adaptation.\n" ; bool stopvu = false ; std::ifstream fichier( LogFile.c_str() ); - if ( fichier ) // ce test échoue si le fichier n'est pas ouvert + if ( fichier ) // ce test échoue si le fichier n'est pas ouvert { std::string ligne; // variable contenant chaque ligne lue while ( std::getline( fichier, ligne ) ) @@ -2442,10 +2605,7 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena } } } - else - { - text = "Voir le fichier Liste.log.\n" ; - } + text += "\n\nSee the file " + LogFile + "\n" ; INFOS ( text ) ; SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -2457,28 +2617,41 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena } } - // I. Menage et retour dans le repertoire du cas + // I. Menage et retour dans le répertoire du cas if (codret == 0) { delete myDriver; MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork ); - chdir(nomDirWork.c_str()); + + CHDIR(nomDirWork.c_str()); + } + + // J. Suivi de la frontière CAO +// std::cout << "- codret : " << codret << std::endl; +// std::cout << "- modeHOMARD : " << modeHOMARD << std::endl; +// std::cout << "- BoundaryOption : " << BoundaryOption << std::endl; +// std::cout << "- codretexec : " << codretexec << std::endl; + if (codret == 0) + { + if ( ( modeHOMARD == 1 ) && ( BoundaryOption % 5 == 0 ) && (codretexec == 0) ) + { + MESSAGE ( "Suivi de frontière CAO" ); + codret = ComputeCAO(myCase, myIteration, Option1, Option2) ; + } } return codretexec ; } //============================================================================= -// Calcul d'une iteration : partie specifique a l'adaptation +// Calcul d'une iteration : partie spécifique à l'adaptation //============================================================================= CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage, HomardDriver* myDriver, CORBA::Long Option1, CORBA::Long Option2) { - MESSAGE ( "ComputeAdap" ); + MESSAGE ( "ComputeAdap avec Option1 = " << Option1 << ", Option2 = " << Option2 ); // A. Prealable // A.1. Bases int codret = 0; - // Etat de l'iteration - int etat = myIteration->GetState(); // Numero de l'iteration int NumeIter = myIteration->GetNumber(); std::stringstream saux0 ; @@ -2486,18 +2659,7 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM std::string siter = saux0.str() ; if (NumeIter < 11) { siter = "0" + siter ; } - // A.2. On ne calcule pas l iteration initiale - if ( etat <= 0 ) - { - MESSAGE ( "etat = "<GetHypoName(); if (std::string(nomHypo) == std::string("")) { @@ -2507,12 +2669,12 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM throw SALOME::SALOME_Exception(es); return 2; }; - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; ASSERT(!CORBA::is_nil(myHypo)); // B. L'iteration parent const char* nomIterationParent = myIteration->GetIterParentName(); - HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent]; + HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent]; ASSERT(!CORBA::is_nil(myIterationParent)); // Si l'iteration parent n'est pas calculee, on le fait (recursivite amont) if ( myIterationParent->GetState() == 1 ) @@ -2526,22 +2688,26 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM } }; - // C. Le sous-repertoire de l'iteration precedente + // C. Le sous-répertoire de l'iteration precedente char* DirComputePa = ComputeDirPaManagement(myCase, myIteration); MESSAGE( ". DirComputePa = " << DirComputePa ); - // D. Les donnees de l'adaptation HOMARD + // D. Les données de l'adaptation HOMARD // D.1. Le type de conformite int ConfType = myCase->GetConfType(); MESSAGE ( ". ConfType = " << ConfType ); - // D.2. Le maillage de depart + // D.1. Le type externe + int ExtType = myCase->GetExtType(); + MESSAGE ( ". ExtType = " << ExtType ); + + // D.3. Le maillage de depart const char* NomMeshParent = myIterationParent->GetMeshName(); MESSAGE ( ". NomMeshParent = " << NomMeshParent ); const char* MeshFileParent = myIterationParent->GetMeshFile(); MESSAGE ( ". MeshFileParent = " << MeshFileParent ); - // D.3. Le maillage associe a l'iteration + // D.4. Le maillage associe a l'iteration const char* MeshFile = myIteration->GetMeshFile(); MESSAGE ( ". MeshFile = " << MeshFile ); FILE *file = fopen(MeshFile,"r"); @@ -2572,17 +2738,18 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM } } - // D.4. Les types de raffinement et de deraffinement + // D.5. Les types de raffinement et de deraffinement // Les appels corba sont lourds, il vaut mieux les grouper HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef(); ASSERT(ListTypes->length() == 3); int TypeAdap = (*ListTypes)[0]; int TypeRaff = (*ListTypes)[1]; int TypeDera = (*ListTypes)[2]; +// MESSAGE ( ". TypeAdap = " << TypeAdap << ", TypeRaff = " << TypeRaff << ", TypeDera = " << TypeDera ); // E. Texte du fichier de configuration // E.1. Incontournables du texte - myDriver->TexteAdap(); + myDriver->TexteAdap(ExtType); int iaux = 0 ; myDriver->TexteMaillageHOMARD( DirComputePa, siter, iaux ) ; myDriver->TexteMaillage(NomMeshParent, MeshFileParent, 0); @@ -2622,9 +2789,9 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM MESSAGE ( ". DiamMin = " << DiamMin ); int AdapInit = myHypo->GetAdapInit(); MESSAGE ( ". AdapInit = " << AdapInit ); - int LevelOutput = myHypo->GetLevelOutput(); - MESSAGE ( ". LevelOutput = " << LevelOutput ); - myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, LevelOutput); + int ExtraOutput = myHypo->GetExtraOutput(); + MESSAGE ( ". ExtraOutput = " << ExtraOutput ); + myDriver->TexteAdvanced(Pyram, NivMax, DiamMin, AdapInit, ExtraOutput); // E.7. Ajout des informations sur le deroulement de l'execution int MessInfo = myIteration->GetInfoCompute(); @@ -2634,15 +2801,222 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM return codret ; } //============================================================================= -// Creation d'un nom de sous-repertoire pour l'iteration au sein d'un repertoire parent -// nomrep : nom du repertoire parent -// num : le nom du sous-repertoire est sous la forme 'In', n est >= num +// Calcul d'une iteration : partie spécifique au suivi de frontière CAO +//============================================================================= +CORBA::Long HOMARD_Gen_i::ComputeCAO(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2) +{ + MESSAGE ( "ComputeCAO avec Option1 = " << Option1 << ", Option2 = " << Option2 ); + + // A. Prealable + // A.1. Bases + int codret = 0; + // A.2. Le sous-répertoire de l'iteration en cours de traitement + char* DirCompute = myIteration->GetDirName(); + // A.3. Le maillage résultat de l'iteration en cours de traitement + char* MeshFile = myIteration->GetMeshFile(); + + // B. Les données pour FrontTrack + // B.1. Le maillage à modifier + const std::string theInputMedFile = MeshFile; + MESSAGE ( ". theInputMedFile = " << theInputMedFile ); + + // B.2. Le maillage après modification : fichier identique + const std::string theOutputMedFile = MeshFile ; + MESSAGE ( ". theOutputMedFile = " << theInputMedFile ); + + // B.3. La liste des fichiers contenant les numéros des noeuds à bouger + std::vector< std::string > theInputNodeFiles ; + MESSAGE ( ". DirCompute = " << DirCompute ); + int bilan ; + int icpt = 0 ; +#ifndef WIN32 + DIR *dp; + struct dirent *dirp; + dp = opendir(DirCompute); + while ( (dirp = readdir(dp)) != NULL ) + { + std::string file_name(dirp->d_name); + bilan = file_name.find("fr") ; + if ( bilan != string::npos ) + { + std::stringstream filename_total ; + filename_total << DirCompute << "/" << file_name ; + theInputNodeFiles.push_back(filename_total.str()) ; + icpt += 1 ; + } + } +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirNameStart, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + std::string file_name(ffd.cFileName); + bilan = file_name.find("fr") ; + if ( bilan != string::npos ) + { + std::stringstream filename_total ; + filename_total << DirCompute << "/" << file_name ; + theInputNodeFiles.push_back(filename_total.str()) ; + icpt += 1 ; + } + } + FindClose(hFind); + } +#endif + for ( int i = 0; i < icpt; i++ ) + { MESSAGE ( ". theInputNodeFiles["<< i << "] = " << theInputNodeFiles[i] ); } + + // B.4. Le fichier de la CAO + HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup(); + std::string BoundaryName = std::string((*ListBoundaryGroupType)[0]); + MESSAGE ( ". BoundaryName = " << BoundaryName ); + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; + const std::string theXaoFileName = myBoundary->GetDataFile(); + MESSAGE ( ". theXaoFileName = " << theXaoFileName ); + + // B.5. Parallélisme + bool theIsParallel = false; + + // C. Lancement des projections + MESSAGE ( ". Lancement des projections" ); + FrontTrack* myFrontTrack = new FrontTrack(); + myFrontTrack->track(theInputMedFile, theOutputMedFile, theInputNodeFiles, theXaoFileName, theIsParallel); + + // D. Transfert des coordonnées modifiées dans le fichier historique de HOMARD + // On lance une exécution spéciale de HOMARD en attendant de savoir le faire avec MEDCoupling + MESSAGE ( ". Transfert des coordonnées" ); + codret = ComputeCAObis(myIteration, Option1, Option2) ; + + return codret ; +} +//============================================================================= +//============================================================================= +// Transfert des coordonnées en suivi de frontière CAO +// Option1 >0 : appel depuis python +// <0 : appel depuis GUI +// Option2 : multiple de nombres premiers +// 1 : aucune option +// x2 : publication du maillage dans SMESH +//============================================================================= +CORBA::Long HOMARD_Gen_i::ComputeCAObis(HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long Option1, CORBA::Long Option2) +{ + MESSAGE ( "ComputeCAObis, avec Option1 = " << Option1 << ", Option2 = " << Option2 ); + + // A. Prealable + int codret = 0; + + // A.1. Controle de la possibilite d'agir + // A.1.1. Etat de l'iteration + int etat = myIteration->GetState(); + MESSAGE ( "etat = "<GetNumber(); + std::string siterp1 ; + std::stringstream saux1 ; + saux1 << NumeIter ; + siterp1 = saux1.str() ; + if (NumeIter < 10) { siterp1 = "0" + siterp1 ; } + MESSAGE ( "siterp1 = "<GetCaseName(); + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName]; + ASSERT(!CORBA::is_nil(myCase)); + + // A.4. Le sous-répertoire de l'iteration a traiter + char* DirCompute = myIteration->GetDirName(); + MESSAGE( ". DirCompute = " << DirCompute ); + + // C. Le fichier des messages + std::string LogFile = DirCompute ; + LogFile += "/Liste." + siterp1 + ".maj_coords.log" ; + MESSAGE (". LogFile = " << LogFile); + myIteration->SetFileInfo(LogFile.c_str()); + + // D. On passe dans le répertoire de l'iteration a calculer + MESSAGE ( ". On passe dans DirCompute = " << DirCompute ); + CHDIR(DirCompute); + + // E. Les données de l'exécution HOMARD + // E.1. L'objet du texte du fichier de configuration + HomardDriver* myDriver = new HomardDriver("", siterp1); + myDriver->TexteInit(DirCompute, LogFile, _Langue); + + // E.2. Le maillage associe a l'iteration + const char* NomMesh = myIteration->GetMeshName(); + MESSAGE ( ". NomMesh = " << NomMesh ); + const char* MeshFile = myIteration->GetMeshFile(); + MESSAGE ( ". MeshFile = " << MeshFile ); + + // E.3. Les données du traitement HOMARD + int iaux ; + myDriver->TexteMajCoords( NumeIter ) ; + iaux = 0 ; + myDriver->TexteMaillageHOMARD( DirCompute, siterp1, iaux ) ; + myDriver->TexteMaillage(NomMesh, MeshFile, 0); +// + // E.4. Ecriture du texte dans le fichier + MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<CreeFichier(); } + +// F. Execution +// + int codretexec = 1789 ; + if (codret == 0) + { + codretexec = myDriver->ExecuteHomard(Option1); + MESSAGE ( "Erreur en executant HOMARD : " << codretexec ); + } + + // G. Gestion des resultats + if (codret == 0) + { + // G.1. Le fichier des messages, dans tous les cas + const char* NomIteration = myIteration->GetName(); + std::string Commentaire = "logmaj_coords" ; + PublishFileUnderIteration(NomIteration, LogFile.c_str(), Commentaire.c_str()); + // G.2 Message d'erreur + if (codretexec != 0) + { + std::string text = "\n\nSee the file " + LogFile + "\n" ; + INFOS ( text ) ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + + // On force le succes pour pouvoir consulter le fichier log + codretexec = 0 ; + } + } + + // H. Menage et retour dans le répertoire du cas + if (codret == 0) { delete myDriver; } + + return codret ; +} +//============================================================================= +// Creation d'un nom de sous-répertoire pour l'iteration au sein d'un répertoire parent +// nomrep : nom du répertoire parent +// num : le nom du sous-répertoire est sous la forme 'In', n est >= num //============================================================================= char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num ) { MESSAGE ( "CreateDirNameIter : nomrep ="<< nomrep << ", num = "<d_name); +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(nomrep, &ffd); + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name(ffd.cFileName); +#endif if ( file_name == DirNameA.str() ) { existe = true ; } } +#ifndef WIN32 closedir(dp); - if ( not existe ) +#else + FindClose(hFind); +#endif + if ( !existe ) { DirName = DirNameA.str() ; a_chercher = false ; @@ -2696,58 +3085,60 @@ char* HOMARD_Gen_i::CreateDirNameIter(const char* nomrep, CORBA::Long num ) MESSAGE ( "==> DirName = " << DirName); MESSAGE ( ". On retourne dans nomDirActuel = " << nomDirActuel ); - chdir(nomDirActuel.c_str()); - + CHDIR(nomDirActuel.c_str()); return CORBA::string_dup( DirName.c_str() ); } //============================================================================= -// Calcul d'une iteration : gestion du repertoire de calcul -// Si le sous-repertoire existe : -// etatMenage = 0 : on sort en erreur si le repertoire n'est pas vide -// etatMenage = 1 : on fait le menage du repertoire +// Calcul d'une iteration : gestion du répertoire de calcul +// Si le sous-répertoire existe : +// etatMenage = 0 : on sort en erreur si le répertoire n'est pas vide +// etatMenage = 1 : on fait le menage du répertoire // etatMenage = -1 : on ne fait rien //============================================================================= char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration, CORBA::Long etatMenage) { - MESSAGE ( "ComputeDirManagement : repertoires pour le calcul" ); - // B.2. Le repertoire du cas + MESSAGE ( "ComputeDirManagement : répertoires pour le calcul" ); + // B.2. Le répertoire du cas const char* nomDirCase = myCase->GetDirName(); MESSAGE ( ". nomDirCase = " << nomDirCase ); - // B.3. Le sous-repertoire de l'iteration a calculer, puis le repertoire complet a creer - // B.3.1. Le nom du sous-repertoire + // B.3. Le sous-répertoire de l'iteration a calculer, puis le répertoire complet a creer + // B.3.1. Le nom du sous-répertoire const char* nomDirIt = myIteration->GetDirNameLoc(); - // B.3.2. Le nom complet du sous-repertoire + // B.3.2. Le nom complet du sous-répertoire std::stringstream DirCompute ; DirCompute << nomDirCase << "/" << nomDirIt; MESSAGE (". DirCompute = " << DirCompute.str() ); - // B.3.3. Si le sous-repertoire n'existe pas, on le cree - if (chdir(DirCompute.str().c_str()) != 0) + // B.3.3. Si le sous-répertoire n'existe pas, on le cree + if (CHDIR(DirCompute.str().c_str()) != 0) { -// Creation du repertoire car il n'existe pas : +#ifndef WIN32 if (mkdir(DirCompute.str().c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) +#else + if (_mkdir(DirCompute.str().c_str()) != 0) +#endif { // GERALD -- QMESSAGE BOX - std::cerr << "Pb Creation du repertoire DirCompute = " << DirCompute.str() << std::endl; - VERIFICATION("Pb a la creation du repertoire" == 0); + std::cerr << "Pb Creation du répertoire DirCompute = " << DirCompute.str() << std::endl; + VERIFICATION("Pb a la creation du répertoire" == 0); } } else { -// Le repertoire existe +// Le répertoire existe // On demande de faire le menage de son contenu : if (etatMenage == 1) { - MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str()); + MESSAGE (". Menage du répertoire DirCompute = " << DirCompute.str()); std::string commande = "rm -rf " + DirCompute.str()+"/*" ; int codret = system(commande.c_str()); if (codret != 0) { // GERALD -- QMESSAGE BOX - std::cerr << ". Menage du repertoire de calcul" << DirCompute.str() << std::endl; - VERIFICATION("Pb au menage du repertoire de calcul" == 0); + std::cerr << ". Menage du répertoire de calcul" << DirCompute.str() << std::endl; + VERIFICATION("Pb au menage du répertoire de calcul" == 0); } } // On n'a pas demande de faire le menage de son contenu : on sort en erreur : @@ -2755,6 +3146,7 @@ char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD:: { if (etatMenage == 0) { +#ifndef WIN32 DIR *dp; struct dirent *dirp; dp = opendir(DirCompute.str().c_str()); @@ -2765,11 +3157,25 @@ char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD:: result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false } closedir(dp); +#else + HANDLE hFind = INVALID_HANDLE_VALUE; + WIN32_FIND_DATA ffd; + hFind = FindFirstFile(DirCompute.str().c_str(), &ffd); + bool result = true; + if (INVALID_HANDLE_VALUE != hFind) { + while (FindNextFile(hFind, &ffd) != 0) { + if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; //skip directories + std::string file_name(ffd.cFileName); + result = file_name.empty() || file_name == "." || file_name == ".."; //if any file - break and return false + } + } + FindClose(hFind); +#endif if ( result == false) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; - std::string text = "Directory : " + DirCompute.str() + "is not empty"; + std::string text = "Directory : " + DirCompute.str() + " is not empty"; es.text = CORBA::string_dup(text.c_str()); throw SALOME::SALOME_Exception(es); VERIFICATION("Directory is not empty" == 0); @@ -2781,19 +3187,19 @@ char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD:: return CORBA::string_dup( DirCompute.str().c_str() ); } //============================================================================= -// Calcul d'une iteration : gestion du repertoire de calcul de l'iteration parent +// Calcul d'une iteration : gestion du répertoire de calcul de l'iteration parent //============================================================================= char* HOMARD_Gen_i::ComputeDirPaManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOMARD_Iteration_var myIteration) { - MESSAGE ( "ComputeDirPaManagement : repertoires pour le calcul" ); - // Le repertoire du cas + MESSAGE ( "ComputeDirPaManagement : répertoires pour le calcul" ); + // Le répertoire du cas const char* nomDirCase = myCase->GetDirName(); MESSAGE ( ". nomDirCase = " << nomDirCase ); - // Le sous-repertoire de l'iteration precedente + // Le sous-répertoire de l'iteration precedente const char* nomIterationParent = myIteration->GetIterParentName(); - HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterationParent]; + HOMARD::HOMARD_Iteration_var myIterationParent = myStudyContext._mesIterations[nomIterationParent]; const char* nomDirItPa = myIterationParent->GetDirNameLoc(); std::stringstream DirComputePa ; DirComputePa << nomDirCase << "/" << nomDirItPa; @@ -2816,7 +3222,7 @@ void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardD { std::string ZoneName = std::string((*ListZone)[iaux]); MESSAGE ( "... ZoneName = " << ZoneName); - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName]; + HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[ZoneName]; ASSERT(!CORBA::is_nil(myZone)); int ZoneType = myZone->GetType(); @@ -2825,13 +3231,13 @@ void HOMARD_Gen_i::DriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHypo, HomardD MESSAGE ( "... ZoneType = " << ZoneType << ", TypeUse = "<GetCoords(); - if ( ZoneType == 2 or ( ZoneType>=11 and ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle + if ( ZoneType == 2 || ( ZoneType>=11 && ZoneType <=13 ) ) // Cas d un parallelepipede ou d'un rectangle { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], 0., 0., 0.); } else if ( ZoneType == 4 ) // Cas d une sphere { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], 0., 0., 0., 0., 0.); } - else if ( ZoneType == 5 or ( ZoneType>=31 and ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque + else if ( ZoneType == 5 || ( ZoneType>=31 && ZoneType <=33 ) ) // Cas d un cylindre ou d'un disque { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], 0.); } - else if ( ZoneType == 7 or ( ZoneType>=61 and ZoneType <=63 ) ) // Cas d un tuyau ou disque perce + else if ( ZoneType == 7 || ( ZoneType>=61 && ZoneType <=63 ) ) // Cas d un tuyau ou disque perce { myDriver->TexteZone(NumZone, ZoneType, TypeUse, (*zone)[0], (*zone)[1], (*zone)[2], (*zone)[3], (*zone)[4], (*zone)[5], (*zone)[6], (*zone)[7], (*zone)[8]); } else { VERIFICATION("ZoneType est incorrect." == 0) ; } iaux += 1 ; @@ -2895,7 +3301,7 @@ void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HO // 2. les liens avec les groupes // 3. un entier resumant le type de comportement pour les frontieres //============================================================================= -void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver) +int HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriver* myDriver) { MESSAGE ( "... DriverTexteBoundary" ); // 1. Recuperation des frontieres @@ -2911,7 +3317,7 @@ void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriv std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]); MESSAGE ( "... BoundaryName = " << BoundaryName); // 2.1. La frontiere a-t-elle deja ete ecrite ? - // Cela arrive quand elle estliéé a plusieurs groupes. Il ne faut l'ecrire que la premiere fois + // Cela arrive quand elle est liee a plusieurs groupes. Il ne faut l'ecrire que la premiere fois int A_faire = 1 ; std::list::const_iterator it = ListeBoundaryTraitees.begin(); while (it != ListeBoundaryTraitees.end()) @@ -2924,20 +3330,29 @@ void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriv if ( A_faire == 1 ) { // 2.2.1. Caracteristiques de la frontiere - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName]; + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; ASSERT(!CORBA::is_nil(myBoundary)); int BoundaryType = myBoundary->GetType(); MESSAGE ( "... BoundaryType = " << BoundaryType ); // 2.2.2. Ecriture selon le type - // 2.2.2.1. Cas d une frontiere discrete - if (BoundaryType == 0) + // 2.2.2.1. Cas d une frontiere CAO + if (BoundaryType == -1) + { +// const char* CAOFile = myBoundary->GetDataFile() ; +// MESSAGE ( ". CAOFile = " << CAOFile ); + if ( BoundaryOption % 5 != 0 ) { BoundaryOption = BoundaryOption*5 ; } + } + // 2.2.2.2. Cas d une frontiere discrete + else if (BoundaryType == 0) { const char* MeshName = myBoundary->GetMeshName() ; - const char* MeshFile = myBoundary->GetMeshFile() ; + MESSAGE ( ". MeshName = " << MeshName ); + const char* MeshFile = myBoundary->GetDataFile() ; + MESSAGE ( ". MeshFile = " << MeshFile ); myDriver->TexteBoundaryDi( MeshName, MeshFile); if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; } } - // 2.2.2.1. Cas d une frontiere analytique + // 2.2.2.3. Cas d une frontiere analytique else { NumBoundaryAnalytical++ ; @@ -2962,6 +3377,11 @@ void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriv myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]); if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; } } + else if (BoundaryType == 5) // Cas d un tore + { + myDriver->TexteBoundaryAn(BoundaryName, NumBoundaryAnalytical, BoundaryType, (*coor)[0], (*coor)[1], (*coor)[2], (*coor)[3], (*coor)[4], (*coor)[5], (*coor)[6], (*coor)[7]); + if ( BoundaryOption % 3 != 0 ) { BoundaryOption = BoundaryOption*3 ; } + } } // 2.2.3. Memorisation du traitement ListeBoundaryTraitees.push_back( BoundaryName ); @@ -2973,19 +3393,24 @@ void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriv { std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]); MESSAGE ( "... BoundaryName = " << BoundaryName); - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName]; + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; ASSERT(!CORBA::is_nil(myBoundary)); int BoundaryType = myBoundary->GetType(); MESSAGE ( "... BoundaryType = " << BoundaryType ); // 3.1. Recuperation du nom du groupe std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]); MESSAGE ( "... GroupName = " << GroupName); - // 3.2. Cas d une frontiere discrete - if ( BoundaryType == 0 ) + // 3.2. Cas d une frontiere CAO + if ( BoundaryType == -1 ) + { + if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryCAOGr ( GroupName ) ; } + } + // 3.3. Cas d une frontiere discrete + else if ( BoundaryType == 0 ) { if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; } } - // 3.3. Cas d une frontiere analytique + // 3.4. Cas d une frontiere analytique else { NumBoundaryAnalytical++ ; @@ -2995,7 +3420,7 @@ void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriv // 4. Ecriture de l'option finale myDriver->TexteBoundaryOption(BoundaryOption); // - return ; + return BoundaryOption ; } //============================================================================= // Calcul d'une iteration : ecriture des interpolations dans le fichier de configuration @@ -3045,7 +3470,7 @@ void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIterati // Le type d'interpolation std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ; MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr ); - // On cherche à savoir si des instants ont été précisés pour cette itération + // On cherche ?? savoir si des instants ont ??t?? pr??cis??s pour cette it??ration int tsrvu = 0; for (int jaux = 0; jaux< numberOfFieldsx3; jaux++) { @@ -3068,7 +3493,7 @@ void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIterati } jaux += 2 ; } - // Si aucun instant n'a été défini + // Si aucun instant n'a été défini if ( tsrvu == 0 ) { NumField += 1 ; @@ -3089,14 +3514,13 @@ void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIterati // Publications //=========================================================================== //=========================================================================== -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject, +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr theSObject, CORBA::Object_ptr theObject, const char* theName) { MESSAGE("PublishInStudy pour " << theName); SALOMEDS::SObject_var aResultSO; - if (CORBA::is_nil(theStudy)) + if (CORBA::is_nil(myStudy)) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -3113,12 +3537,12 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject); HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject); - addInStudy(theStudy); + UpdateStudy(); // Controle de la non publication d'un objet de meme nom - if ( (!aBoundary->_is_nil()) or (!aHypo->_is_nil()) or (!aYACS->_is_nil()) or (!aZone->_is_nil()) ) + if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) ) { - SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType()); + SALOMEDS::Study::ListOfSObject_var listSO = myStudy->FindObjectByName(theName, ComponentDataType()); if (listSO->length() >= 1) { MESSAGE("This name "<length()<<" time(s)"); @@ -3128,36 +3552,35 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, } // Caracteristiques de l'etude - SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); if(!aBoundary->_is_nil()) - aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName); + aResultSO = PublishBoundaryInStudy(aStudyBuilder, aBoundary, theName); else if(!aCase->_is_nil()) - aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName); + aResultSO = PublishCaseInStudy(aStudyBuilder, aCase, theName); else if(!aHypo->_is_nil()) - aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName); + aResultSO = PublishHypotheseInStudy(aStudyBuilder, aHypo, theName); else if(!aYACS->_is_nil()) - aResultSO = PublishYACSInStudy(theStudy, aStudyBuilder, aYACS, theName); + aResultSO = PublishYACSInStudy(aStudyBuilder, aYACS, theName); else if(!aZone->_is_nil()) - aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName); + aResultSO = PublishZoneInStudy(aStudyBuilder, aZone, theName); aStudyBuilder->CommitCommand(); return aResultSO._retn(); }; //============================================================================= -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy( SALOMEDS::StudyBuilder_var aStudyBuilder, HOMARD::HOMARD_Boundary_ptr theObject, const char* theName) { MESSAGE("PublishBoundaryStudy pour "<FindComponent(ComponentDataType()); + SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType()); if (theFatherHomard->_is_nil()) { MESSAGE("theFatherHomard->_is_nil()"); @@ -3186,6 +3609,11 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr t std::string value ; switch (BoundaryType) { + case -1 : + { value = "BoundaryCAOHomard" ; + icone = "geometry.png" ; + break; + } case 0 : { value = "BoundaryDiHomard" ; icone = "mesh_tree_mesh.png" ; @@ -3211,14 +3639,18 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr t icone = "conedxyz.png" ; break; } + case 5 : + { value = "BoundaryAnHomard" ; + icone = "toruspointvector.png" ; + break; + } } aResultSO = aStudyBuilder->NewObject(aSObject); PublishInStudyAttr(aStudyBuilder, aResultSO, theName, value.c_str(), icone.c_str(), _orb->object_to_string(theObject)); return aResultSO._retn(); } //============================================================================= -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, HOMARD::HOMARD_Cas_ptr theObject, const char* theName) { MESSAGE("PublishCaseInStudy pour "<_is_nil()"); return aResultSO._retn(); } - if (theStudy->_is_nil()) { - MESSAGE("HOMARD_Gen_i::theStudy->_is_nil()"); + if (myStudy->_is_nil()) { + MESSAGE("HOMARD_Gen_i::myStudy->_is_nil()"); return aResultSO._retn(); } // On recupere le module pere dans l etude - SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType()); + SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType()); if (theFatherHomard->_is_nil()) { MESSAGE("theFatherHomard->_is_nil()"); @@ -3250,8 +3682,7 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theSt return aResultSO._retn(); } //============================================================================= -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName) { MESSAGE("PublishHypotheseInStudy pour "<FindComponent(ComponentDataType()); + SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType()); if (theFatherHomard->_is_nil()) { MESSAGE("theFatherHomard->_is_nil()"); @@ -3289,8 +3720,7 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr return aResultSO._retn(); } //============================================================================= -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, HOMARD::HOMARD_YACS_ptr theObject, const char* theName) { MESSAGE("PublishYACSInStudy pour "<FindComponent(ComponentDataType()); + SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType()); if (theFatherHomard->_is_nil()) { MESSAGE("theFatherHomard->_is_nil()"); @@ -3328,8 +3758,7 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theSt } //============================================================================= -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::StudyBuilder_var aStudyBuilder, HOMARD::HOMARD_Zone_ptr theObject, const char* theName) { MESSAGE("PublishZoneStudy pour "<_is_nil()"); return aResultSO._retn(); } - if (theStudy->_is_nil()) + if (myStudy->_is_nil()) { - MESSAGE("PublishZoneInStudy : theStudy->_is_nil()"); + MESSAGE("PublishZoneInStudy : myStudy->_is_nil()"); return aResultSO._retn(); } - SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType()); + SALOMEDS::SComponent_var theFatherHomard = myStudy->FindComponent(ComponentDataType()); if (theFatherHomard->_is_nil()) { MESSAGE("PublishZoneInStudy : theFatherHomard->_is_nil()"); @@ -3352,7 +3781,7 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theSt } // Caracteristique de la zone - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[theName]; + HOMARD::HOMARD_Zone_var myZone = myStudyContext._mesZones[theName]; CORBA::Long ZoneType = myZone->GetType(); // On ajoute la categorie des zones dans l etude si necessaire @@ -3467,22 +3896,23 @@ void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* Bo { MESSAGE ( "PublishBoundaryUnderCase : CaseName = " << CaseName << ", BoundaryName= " << BoundaryName ); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName]; ASSERT(!CORBA::is_nil(myCase)); - SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase))); + SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase))); ASSERT(!CORBA::is_nil(aCaseSO)); - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName]; + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; ASSERT(!CORBA::is_nil(myBoundary)); - SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myBoundary))); + SALOMEDS::SObject_var aBoundarySO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myBoundary))); ASSERT(!CORBA::is_nil(aBoundarySO)); - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO); aStudyBuilder->Addreference(aSubSO, aBoundarySO); +// aStudyBuilder->RemoveReference(aSubSO); aStudyBuilder->CommitCommand(); @@ -3492,17 +3922,17 @@ void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseNam { MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName ); - HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; ASSERT(!CORBA::is_nil(myYACS)); - SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS))); ASSERT(!CORBA::is_nil(aYACSSO)); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[CaseName]; ASSERT(!CORBA::is_nil(myCase)); - SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase))); + SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myCase))); ASSERT(!CORBA::is_nil(aCaseSO)); - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); @@ -3518,7 +3948,7 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) // Option = 1 : fichier issu d'une execution HOMARD { MESSAGE( "PublishResultInSmesh " << NomFich << ", avec Option = " << Option); - if (CORBA::is_nil(myCurrentStudy)) + if (CORBA::is_nil(myStudy)) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -3528,12 +3958,12 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) }; // Le module SMESH est-il actif ? - SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH"); + SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH"); // if (!CORBA::is_nil(aSmeshSO)) { // On verifie que le fichier n est pas deja publie - SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO); + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO); for (; aIter->More(); aIter->Next()) { SALOMEDS::SObject_var aSO = aIter->Value(); @@ -3546,10 +3976,7 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) { MESSAGE ( "PublishResultInSmesh : le fichier " << NomFich << " est deja publie." ); // Pour un fichier importe, on ne republie pas - if ( Option == 0 ) - { - return; - } + if ( Option == 0 ) { return; } // Pour un fichier calcule, on commence par faire la depublication else { @@ -3567,10 +3994,11 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) // On enregistre le fichier MESSAGE( "Enregistrement du fichier"); - SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS); - SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH")); + // + SMESH::SMESH_Gen_var aSmeshEngine = this->retrieveSMESHInst(); + // ASSERT(!CORBA::is_nil(aSmeshEngine)); - aSmeshEngine->SetCurrentStudy(myCurrentStudy); + aSmeshEngine->UpdateStudy(); SMESH::DriverMED_ReadStatus theStatus; //aSmeshEngine->CreateMeshesFromMED(NomFich, theStatus); @@ -3580,8 +4008,8 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) { MESSAGE( ". Mise a jour des attributs du maillage"); SMESH::SMESH_Mesh_var monMaillage= (*mesMaillages)[i]; - SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(monMaillage))); - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::SObject_var aSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(monMaillage))); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); SALOMEDS::GenericAttribute_var aGAttr = aStudyBuilder->FindOrCreateAttribute(aSO, "AttributeExternalFileDef"); SALOMEDS::AttributeExternalFileDef_var anAttr = SALOMEDS::AttributeExternalFileDef::_narrow(aGAttr); anAttr->SetValue(NomFich); @@ -3598,7 +4026,7 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option) void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName) { MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich ); - if (CORBA::is_nil(myCurrentStudy)) + if (CORBA::is_nil(myStudy)) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -3608,15 +4036,15 @@ void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName }; // Le module SMESH est-il actif ? - SALOMEDS::SObject_var aSmeshSO = myCurrentStudy->FindComponent("SMESH"); + SALOMEDS::SObject_var aSmeshSO = myStudy->FindComponent("SMESH"); // if (CORBA::is_nil(aSmeshSO)) { return ; }; // On verifie que le fichier est deja publie - SALOMEDS::StudyBuilder_var myBuilder = myCurrentStudy->NewBuilder(); - SALOMEDS::ChildIterator_var aIter = myCurrentStudy->NewChildIterator(aSmeshSO); + SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); + SALOMEDS::ChildIterator_var aIter = myStudy->NewChildIterator(aSmeshSO); for (; aIter->More(); aIter->Next()) { SALOMEDS::SObject_var aSO = aIter->Value(); @@ -3642,12 +4070,43 @@ void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName return ; } //============================================================================= +void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter) +{ + MESSAGE( "PublishMeshIterInSmesh " << NomIter); + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter]; + + SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + if (CORBA::is_nil(myIteration)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid iterationStudy Object"; + throw SALOME::SALOME_Exception(es); + return ; + }; + const char* MeshFile = myIteration->GetMeshFile() ; + const char* MeshName = myIteration->GetMeshName() ; + CORBA::Long Option = -1 ; + int etat = myIteration->GetState(); +// Iteration initiale + if ( etat <= 0 ) { Option = 0 ; } +// ou iteration calculee + else if ( etat == 2 ) { Option = 1 ; } +// Publication effective apres menage eventuel + if ( Option >= 0 ) + { + DeleteResultInSmesh(MeshFile, MeshName) ; + PublishResultInSmesh(MeshFile, Option) ; + } + +} +//============================================================================= void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire) { // MESSAGE ("PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire ); - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[NomIter]; - SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myIteration))); if (CORBA::is_nil(myIteration)) { SALOME::ExceptionStruct es; @@ -3657,7 +4116,7 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No return ; }; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); @@ -3667,7 +4126,7 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n std::string icone ; std::string ior = " " ; - if ( Commentaire[0] == 'I' ) + if ( Commentaire[0] == 'M' ) { icone = "med.png" ; } else { icone = "texte_2.png" ; } @@ -3680,9 +4139,9 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich, const char* Commentaire) { // MESSAGE ("PublishFileUnderYACS pour le schema " << nomYACS << " du fichier " << NomFich << " avec le commentaire " << Commentaire ); - HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; - SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myStudy->FindObjectIOR(_orb->object_to_string(myYACS))); if (CORBA::is_nil(myYACS)) { SALOME::ExceptionStruct es; @@ -3692,7 +4151,7 @@ void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich return ; }; - SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); aStudyBuilder->NewCommand(); @@ -3713,18 +4172,18 @@ void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich // Creation d'un schema YACS // nomCas : nom du cas a traiter // FileName : nom du fichier contenant le script de lancement du calcul -// DirName : le repertoire de lancement des calculs du schéma +// DirName : le répertoire de lancement des calculs du schéma //============================================================================= HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile) { - INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS ); - INFOS ( ". nomCas : " << nomCas); - INFOS ( ". ScriptFile : " << ScriptFile); - INFOS ( ". DirName : " << DirName); - INFOS ( ". MeshFile : " << MeshFile); + MESSAGE ( "CreateYACSSchema : Schema YACS " << nomYACS ); + MESSAGE ( ". nomCas : " << nomCas); + MESSAGE ( ". ScriptFile : " << ScriptFile); + MESSAGE ( ". DirName : " << DirName); + MESSAGE ( ". MeshFile : " << MeshFile); // A. Controle du nom : - if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(nomYACS) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end()) + if ((myStudyContext._mesYACSs).find(nomYACS) != (myStudyContext._mesYACSs).end()) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -3746,10 +4205,10 @@ HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, con myYACS->SetName( nomYACS ) ; // C. Enregistrement - myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS] = myYACS; + myStudyContext._mesYACSs[nomYACS] = myYACS; SALOMEDS::SObject_var aSO; - SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, nomYACS); + SALOMEDS::SObject_var aResultSO=PublishInStudy(aSO, myYACS, nomYACS); PublishCaseUnderYACS(nomYACS, nomCas); @@ -3760,9 +4219,17 @@ HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, con myYACS->SetScriptFile( ScriptFile ) ; myYACS->SetCaseName( nomCas ) ; // D.2. Defaut + int defaut_i ; // D.2.1. Type constant myYACS->SetType( 1 ) ; - // D.2.2. Fichier de sauvegarde dans le repertoire du cas + // D.2.2. Convergence + defaut_i = GetYACSMaxIter() ; + myYACS->SetMaxIter( defaut_i ) ; + defaut_i = GetYACSMaxNode() ; + myYACS->SetMaxNode( defaut_i ) ; + defaut_i = GetYACSMaxElem() ; + myYACS->SetMaxElem( defaut_i ) ; + // D.3. Fichier de sauvegarde dans le répertoire du cas HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ; std::string dirnamecase = caseyacs->GetDirName() ; std::string XMLFile ; @@ -3776,9 +4243,9 @@ HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, con //============================================================================= CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS) { - INFOS ( "YACSWrite : Ecriture de " << nomYACS ); -// Le repertoire du cas - HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + MESSAGE ( "YACSWrite : Ecriture de " << nomYACS ); +// Le répertoire du cas + HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; ASSERT(!CORBA::is_nil(myYACS)); // Le nom du fichier du schema std::string XMLFile ; @@ -3793,24 +4260,28 @@ CORBA::Long HOMARD_Gen_i::YACSWrite(const char* nomYACS) //============================================================================= CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile) { - INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile ); + MESSAGE ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile ); // A. Prealable int codret = 0; // B. L'objet YACS // B.1. L'objet - HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + HOMARD::HOMARD_YACS_var myYACS = myStudyContext._mesYACSs[nomYACS]; ASSERT(!CORBA::is_nil(myYACS)); // B.2. Les caracteristiques std::string DirName = myYACS->GetDirName() ; std::string MeshFile = myYACS->GetMeshFile() ; std::string ScriptFile = myYACS->GetScriptFile() ; + // B.3. Les caracteristiques de convergence + int MaxIter = myYACS->GetMaxIter() ; + int MaxNode = myYACS->GetMaxNode() ; + int MaxElem = myYACS->GetMaxElem() ; // C. Le cas // C.1. L'objet cas const char* nomCas = myYACS->GetCaseName(); - HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[nomCas]; + HOMARD::HOMARD_Cas_var myCase = myStudyContext._mesCas[nomCas]; ASSERT(!CORBA::is_nil(myCase)); // C.2. Les instructions python associees au cas CORBA::String_var dumpCorbaCase = myCase->GetDumpPython(); @@ -3849,7 +4320,7 @@ CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFi // E.1. La structure std::string nomHypo = Iter1->GetHypoName(); MESSAGE (". nomHypo = " << nomHypo); - HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo]; + HOMARD::HOMARD_Hypothesis_var myHypo = myStudyContext._mesHypotheses[nomHypo]; ASSERT(!CORBA::is_nil(myHypo)); // E.2. Les caracteristiques de l'adaptation HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef(); @@ -3863,7 +4334,7 @@ CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFi MESSAGE ("pythonHypo :\n"<Texte_Iter_1_Case_Options(pythonCas); } - // G.1.5. Execution de HOMARD : le repertoire du cas + // G.1.5. Execution de HOMARD : le répertoire du cas else if ( mot_cle == "HOMARD_Exec_DirName" ) { myDriver->Texte_HOMARD_Exec_DirName(); } // G.1.6. Execution de HOMARD : le nom du maillage else if ( mot_cle == "HOMARD_Exec_MeshName" ) { myDriver->Texte_HOMARD_Exec_MeshName(MeshName); - std::string node = "Boucle_de_convergence.Alternance_Calcul_HOMARD.Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ; + std::string node ; + if ( _LangueShort == "fr" ) { node = "Boucle_de_convergence.Alternance_Calcul_HOMARD" ; } + else { node = "Convergence_Loop.Alternation_Computation_HOMARD" ; } + node += ".Adaptation.p0_Adaptation_HOMARD.HOMARD_Initialisation.p1_Iter_1.CreateCase" ; myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ; } // G.1.7. Execution de HOMARD : les options de l'hypothese @@ -3917,15 +4391,20 @@ CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFi // G.1.8. Execution de HOMARD : les options de l'iteration else if ( mot_cle == "HOMARD_Exec_Iter_Options" ) { myDriver->Texte_python_2( pythonIter, "TimeStep", "Iter" ) ; } - // G.1.9. Zones et frontieres : les creations + // G.1.9. a. Creation eventuelles des zones et frontieres + // b. Enchainement else if ( mot_cle == "Iter_1" ) { - std::string texte_control = myDriver->Texte_Iter_1_control() ; + std::string texte_control = "" ; if ( TypeAdap == 0 ) { texte_control += YACSDriverTexteZone( myHypo, myDriver ) ; } texte_control += YACSDriverTexteBoundary( myCase, myDriver ) ; + texte_control += myDriver->Texte_Iter_1_control() ; myDriver->TexteAdd(texte_control); } - // G.1.10. Les parametres + // G.1.10. Les tests de convergence + else if ( mot_cle == "Analyse_Test_Convergence" ) + { myDriver->TexteAnalyse_Test_Convergence(MaxIter, MaxNode, MaxElem); } + // G.1.11. Les parametres else if ( mot_cle == "PARAMETRES" ) { myDriver->TexteAddParametres(); } // G.1.n. La ligne est recopiee telle quelle @@ -3970,7 +4449,7 @@ std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHy // 1. Reperage de la zone std::string ZoneName = std::string((*ListZone)[iaux]); MESSAGE ( "\n. ZoneName = " << ZoneName << " - " <Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName ); texte_control += texte_control_0 ; // 5. Decalage - iaux += 1 ; + iaux ++ ; } return texte_control ; @@ -4029,7 +4508,7 @@ std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, if ( A_faire == 1 ) { // 1. Caracteristiques de la frontiere - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName]; + HOMARD::HOMARD_Boundary_var myBoundary = myStudyContext._mesBoundarys[BoundaryName]; ASSERT(!CORBA::is_nil(myBoundary)); // 2. Les instructions python associees a la frontiere // La premiere ligne est un commentaire a eliminer @@ -4049,8 +4528,22 @@ std::string HOMARD_Gen_i::YACSDriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, // 4. Mise en place des instructions int BoundaryType = myBoundary->GetType(); MESSAGE ( "... BoundaryType = " << BoundaryType); + const char* MeshName ; + const char* DataFile ; + if (BoundaryType == -1) + { + DataFile = myBoundary->GetDataFile() ; + MESSAGE ( ". CAOFile = " << DataFile ); + } + else if (BoundaryType == 0) + { + MeshName = myBoundary->GetMeshName() ; + MESSAGE ( ". MeshName = " << MeshName ); + DataFile = myBoundary->GetDataFile() ; + MESSAGE ( ". MeshFile = " << DataFile ); + } std::string texte_control_0 ; - texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName ); + texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName, MeshName, DataFile ); texte_control += texte_control_0 ; // 5. Memorisation du traitement ListeBoundaryTraitees.push_back( BoundaryName ); @@ -4075,19 +4568,18 @@ SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, // get temporary directory name std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir(); - SALOMEDS::Study_var aStudy = theComponent->GetStudy(); - StudyContext& context = myContextMap[ aStudy->StudyId() ]; + StudyContext& context = myStudyContext; // HOMARD data file name std::string aFileName = ""; if (isMultiFile) - aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); + aFileName = SALOMEDS_Tool::GetNameFromPath(Kernel_Utils::encode(myStudy->URL())); aFileName += "_HOMARD.dat"; // initialize sequence of file names - SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames; - aFileSeq->length(1); - aFileSeq[0] = CORBA::string_dup(aFileName.c_str()) ; + SALOMEDS_Tool::ListOfFiles aFileSeq; + aFileSeq.reserve(1); + aFileSeq.push_back(CORBA::string_dup(aFileName.c_str())) ; // get full path to the data file aFileName = tmpDir + aFileName; @@ -4162,11 +4654,11 @@ SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, // put temporary files to the stream MESSAGE ("put temporary files to the stream"); - aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq.in(), isMultiFile); + aStreamFile = SALOMEDS_Tool::PutFilesToStream(tmpDir.c_str(), aFileSeq, isMultiFile); // remove temporary files MESSAGE ("remove temporary files"); - if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true); + if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true); // return data stream MESSAGE ("return data stream"); @@ -4190,26 +4682,25 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, CORBA::Boolean isMultiFile) { MESSAGE ("Load pour theURL = "<< theURL); - SALOMEDS::Study_var aStudy = theComponent->GetStudy(); // set current study - if (myCurrentStudy->_is_nil() || aStudy->StudyId() != myCurrentStudy->StudyId()) - SetCurrentStudy(aStudy); + if (myStudy->_is_nil()) + UpdateStudy(); // get temporary directory name std::string tmpDir = isMultiFile ? std::string(theURL) : SALOMEDS_Tool::GetTmpDir(); // Convert the stream into sequence of files to process - SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, - tmpDir.c_str(), - isMultiFile); + SALOMEDS_Tool::ListOfFiles aFileSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, + tmpDir.c_str(), + isMultiFile); // HOMARD data file name std::string aFileName = ""; if (isMultiFile) - aFileName = SALOMEDS_Tool::GetNameFromPath(aStudy->URL()); + aFileName = SALOMEDS_Tool::GetNameFromPath(Kernel_Utils::encode(myStudy->URL())); aFileName = tmpDir + aFileName + "_HOMARD.dat"; - StudyContext& context = myContextMap[ aStudy->StudyId() ]; + StudyContext& context = myStudyContext; // save data // -> create file @@ -4269,7 +4760,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, } else if (line.substr(0, iterSignature.size()) == iterSignature) { // re-create iteration - MESSAGE ("Recreation de l iteration" ); + MESSAGE ("Recreation de l'iteration" ); HOMARD::HOMARD_Iteration_var aIter = newIteration(); PortableServer::ServantBase_var aServant = GetServant(aIter); HOMARD_Iteration_i* aIterServant = dynamic_cast(aServant.in()); @@ -4308,7 +4799,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, // Remove temporary files created from the stream if (!isMultiFile) - SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq.in(), true); + SALOMEDS_Tool::RemoveTemporaryFiles(tmpDir.c_str(), aFileSeq, true); return true; }; @@ -4326,15 +4817,6 @@ CORBA::Boolean HOMARD_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent, //=========================================================================== void HOMARD_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent) { - if (theComponent->GetStudy()->StudyId() == GetCurrentStudyID()) { - // clearing study context should be done here: - // - destroy all servants and related CORBA objects - // ... (TODO) - // - remove context from myContextMap - myContextMap.erase(theComponent->GetStudy()->StudyId()); - // - nullify myCurrentStudy - myCurrentStudy = SALOMEDS::Study::_nil(); - } }; //=========================================================================== @@ -4351,7 +4833,7 @@ char* HOMARD_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, { CORBA::String_var aString(""); if (!CORBA::is_nil(theSObject) && strcmp(IORString, "") != 0) { - StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ]; + StudyContext context = myStudyContext; CORBA::Object_var anObj = _orb->string_to_object(IORString); if (!CORBA::is_nil(anObj)) { PortableServer::ServantBase_var aServant = GetServant(anObj); @@ -4379,7 +4861,7 @@ char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, { CORBA::String_var aString(""); if (!CORBA::is_nil(theSObject) && strcmp(aLocalPersistentID, "") != 0) { - StudyContext context = myContextMap[ theSObject->GetStudy()->StudyId() ]; + StudyContext context = myStudyContext; int id = atoi(aLocalPersistentID); if (id > 0 && context._idmap.find(id) != context._idmap.end()) { CORBA::Object_var object = _poa->servant_to_reference(context._idmap[ id ]); @@ -4394,7 +4876,7 @@ char* HOMARD_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, //=========================================================================== CORBA::Boolean HOMARD_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) { - if(CORBA::is_nil(myCurrentStudy)) + if(CORBA::is_nil(myStudy)) return false; HOMARD::HOMARD_Cas_var aCas = HOMARD::HOMARD_Cas::_narrow(theIOR); @@ -4470,48 +4952,39 @@ PortableServer::ServantBase_var HOMARD_Gen_i::GetServant(CORBA::Object_ptr theOb } //========================================================================== -Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, - CORBA::Boolean isPublished, - CORBA::Boolean isMultiFile, - CORBA::Boolean& isValidScript) +Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Boolean isPublished, + CORBA::Boolean isMultiFile, + CORBA::Boolean& isValidScript) { MESSAGE ("Entree dans DumpPython"); isValidScript=1; - SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy); - if(CORBA::is_nil(aStudy)) - return new Engines::TMPFile(0); - SALOMEDS::SObject_var aSO = aStudy->FindComponent("HOMARD"); + SALOMEDS::SObject_var aSO = myStudy->FindComponent("HOMARD"); if(CORBA::is_nil(aSO)) return new Engines::TMPFile(0); std::string aScript = "\"\"\"\n"; aScript += "Python script for HOMARD\n"; - aScript += "Copyright EDF-R&D 2013\n"; + aScript += "Copyright 1996, 2011, 2015 EDF\n"; aScript += "\"\"\"\n"; aScript += "__revision__ = \"V1.2\"\n"; aScript += "import HOMARD\n"; if( isMultiFile ) aScript += "import salome\n"; aScript += "homard = salome.lcc.FindOrLoadComponent('FactoryServer','HOMARD')\n"; - if( isMultiFile ) { - aScript += "def RebuildData(theStudy):\n"; - aScript += "\thomard.SetCurrentStudy(theStudy)\n"; - } - else - aScript += "\thomard.SetCurrentStudy(salome.myStudy)\n"; + aScript += "\thomard.UpdateStudy()\n"; MESSAGE (". Au depart \n"< 0) + if (myStudyContext._mesBoundarys.size() > 0) { MESSAGE (". Ecritures des frontieres"); aScript += "#\n# Creation of the boundaries"; aScript += "\n# =========================="; } std::map::const_iterator it_boundary; - for (it_boundary = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin(); - it_boundary != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); ++it_boundary) + for (it_boundary = myStudyContext._mesBoundarys.begin(); + it_boundary != myStudyContext._mesBoundarys.end(); ++it_boundary) { HOMARD::HOMARD_Boundary_var maBoundary = (*it_boundary).second; CORBA::String_var dumpCorbaBoundary = maBoundary->GetDumpPython(); @@ -4521,15 +4994,15 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, } - if (myContextMap[GetCurrentStudyID()]._mesZones.size() > 0) + if (myStudyContext._mesZones.size() > 0) { MESSAGE (". Ecritures des zones"); aScript += "#\n# Creation of the zones"; aScript += "\n# ====================="; } std::map::const_iterator it_zone; - for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin(); - it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone) + for ( it_zone = myStudyContext._mesZones.begin(); + it_zone != myStudyContext._mesZones.end(); ++it_zone) { HOMARD::HOMARD_Zone_var myZone = (*it_zone).second; CORBA::String_var dumpCorbaZone = myZone->GetDumpPython(); @@ -4539,15 +5012,15 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, } - if (myContextMap[GetCurrentStudyID()]._mesHypotheses.size() > 0) + if (myStudyContext._mesHypotheses.size() > 0) { MESSAGE (". Ecritures des hypotheses"); aScript += "#\n# Creation of the hypotheses"; aScript += "\n# =========================="; } std::map::const_iterator it_hypo; - for ( it_hypo = myContextMap[GetCurrentStudyID()]._mesHypotheses.begin(); - it_hypo != myContextMap[GetCurrentStudyID()]._mesHypotheses.end(); it_hypo++) + for ( it_hypo = myStudyContext._mesHypotheses.begin(); + it_hypo != myStudyContext._mesHypotheses.end(); it_hypo++) { HOMARD::HOMARD_Hypothesis_var monHypo = (*it_hypo).second; CORBA::String_var dumpCorbaHypo = monHypo->GetDumpPython(); @@ -4557,15 +5030,15 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, } - if (myContextMap[GetCurrentStudyID()]._mesCas.size() > 0) + if (myStudyContext._mesCas.size() > 0) { MESSAGE (". Ecritures des cas"); aScript += "#\n# Creation of the cases"; aScript += "\n# ====================="; } std::map::const_iterator it_cas; - for (it_cas = myContextMap[GetCurrentStudyID()]._mesCas.begin(); - it_cas != myContextMap[GetCurrentStudyID()]._mesCas.end(); it_cas++) + for (it_cas = myStudyContext._mesCas.begin(); + it_cas != myStudyContext._mesCas.end(); it_cas++) { std::string nomCas = (*it_cas).first; std::string dumpCas = std::string("\n# Creation of the case ") ; @@ -4577,7 +5050,7 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, CORBA::String_var cIter0= myCase->GetIter0Name(); std::string iter0 = cIter0.in(); - HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[iter0]; + HOMARD::HOMARD_Iteration_var myIteration = myStudyContext._mesIterations[iter0]; CORBA::String_var cMesh0= myIteration->GetMeshFile(); std::string mesh0 = cMesh0.in(); CORBA::String_var cMeshName0= myIteration->GetMeshName(); @@ -4591,15 +5064,15 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, }; - if (myContextMap[GetCurrentStudyID()]._mesIterations.size() > 0) + if (myStudyContext._mesIterations.size() > 0) { MESSAGE (". Ecritures des iterations"); aScript += "#\n# Creation of the iterations" ; aScript += "\n# =========================="; } std::map::const_iterator it_iter; - for (it_iter = myContextMap[GetCurrentStudyID()]._mesIterations.begin(); - it_iter != myContextMap[GetCurrentStudyID()]._mesIterations.end(); ++it_iter) + for (it_iter = myStudyContext._mesIterations.begin(); + it_iter != myStudyContext._mesIterations.end(); ++it_iter) { HOMARD::HOMARD_Iteration_var aIter = (*it_iter).second; CORBA::String_var dumpCorbaIter = aIter->GetDumpPython(); @@ -4609,15 +5082,15 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, } - if (myContextMap[GetCurrentStudyID()]._mesYACSs.size() > 0) + if (myStudyContext._mesYACSs.size() > 0) { MESSAGE (". Ecritures des schemas YACS"); aScript += "#\n# Creation of the schemas YACS"; aScript += "\n# ============================"; } std::map::const_iterator it_yacs; - for ( it_yacs = myContextMap[GetCurrentStudyID()]._mesYACSs.begin(); - it_yacs != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); ++it_yacs) + for ( it_yacs = myStudyContext._mesYACSs.begin(); + it_yacs != myStudyContext._mesYACSs.end(); ++it_yacs) { HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second; CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython(); @@ -4655,7 +5128,7 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, void HOMARD_Gen_i::IsValidStudy( ) { // MESSAGE( "IsValidStudy" ); - if (CORBA::is_nil(myCurrentStudy)) + if (CORBA::is_nil(myStudy)) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; @@ -4670,8 +5143,8 @@ char* HOMARD_Gen_i::VerifieDir(const char* nomDir) { std::string casename = std::string("") ; std::map::const_iterator it; - for (it = myContextMap[GetCurrentStudyID()]._mesCas.begin(); - it != myContextMap[GetCurrentStudyID()]._mesCas.end(); it++) + for (it = myStudyContext._mesCas.begin(); + it != myStudyContext._mesCas.end(); it++) { if (std::string(nomDir) == std::string(it->second->GetDirName())) { @@ -4700,30 +5173,179 @@ char* HOMARD_Gen_i::getVersion() #endif } //=============================================================================== -// Recuperation de la chaine de caracteres par rapport a l'apparition d'un texte +// Recuperation de la chaine de caracteres par rapport a l'apparition d'un caractere // ligne : la ligne a manipuler -// texte : le texte a reperer -// option : 0 : la chaine avant le texte -// 1 : la chaine apres le texte -// Si le texte est absent, on retourne la chaine totale +// caractere : le caractere a reperer +// option : 0 : la chaine avant la premiere apparition du caractere +// 1 : la chaine apres la premiere apparition du caractere +// 2 : la chaine avant la derniere apparition du caractere +// 3 : la chaine apres la derniere apparition du caractere +// Si le caractere est absent, on retourne la chaine totale //=============================================================================== -std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string texte, int option ) +std::string HOMARD_Gen_i::GetStringInTexte( const std::string ligne, const std::string caractere, int option ) { -// MESSAGE("GetStringInTexte, recherche de '"<> mot_cle ; + chaine = GetStringInTexte ( mot_cle, "\"", 1 ) ; + chaine = GetStringInTexte ( chaine, "\"", 0 ) ; + if ( chaine == "language" ) { section_langue = true ; } + if ( chaine == "HOMARD" ) { section_homard = true ; } + // MESSAGE ( "section_langue = "<" ) + { /*MESSAGE ( "Fin de la section : "<< ligne<<", section_langue = "<> PublisMeshIN ; } + if ( chaine2 == "publish_mesh_out" ) { chainebis >> PublisMeshOUT ; } + // 3.2.2. Les maximum pour YACS + if ( chaine2 == "yacs_max_iter" ) { chainebis >> YACSMaxIter ; } + if ( chaine2 == "yacs_max_node" ) { chainebis >> YACSMaxNode ; } + if ( chaine2 == "yacs_max_elem" ) { chainebis >> YACSMaxElem ; } + if ( chaine2 == "yacs_type_test" ) { YACSTypeTestchaine = chaine ; } + } + } + } + } + } + + // C. Enregistrements + MESSAGE ("Enregistrement de LanguageShort = " << LanguageShort ); + SetLanguageShort( LanguageShort.c_str() ) ; + + MESSAGE ("Enregistrement de PublisMeshIN = " << PublisMeshIN<<", PublisMeshOUT = "<< PublisMeshOUT); + SetPublisMesh(PublisMeshIN, PublisMeshOUT) ; + + MESSAGE ("Enregistrement de YACSMaxIter = " << YACSMaxIter<<", YACSMaxNode = "<< YACSMaxNode<<", YACSMaxElem = "<< YACSMaxElem); + SetYACSMaximum(YACSMaxIter, YACSMaxNode, YACSMaxElem) ; + + MESSAGE ("Enregistrement de TypeTest = " << YACSTypeTestchaine.c_str() ); + int YACSTypeTest ; + if ( ( YACSTypeTestchaine == "VTest > VRef" ) || ( YACSTypeTestchaine == "VTest > VRef" ) ) { YACSTypeTest = 1 ; } + else if ( ( YACSTypeTestchaine == "VTest < VRef" ) || ( YACSTypeTestchaine == "VTest < VRef" ) ) { YACSTypeTest = 2 ; } + else { YACSTypeTest = 0 ; } + MESSAGE ("==> TypeTest = " << YACSTypeTest ); + SetYACSConvergenceType( YACSTypeTest ) ; + + return ; +} +//=============================================================================== +// Langue de SALOME +//=============================================================================== void HOMARD_Gen_i::SetLanguageShort(const char* LanguageShort) { // MESSAGE ("SetLanguageShort pour LanguageShort = " << LanguageShort ); @@ -4737,18 +5359,52 @@ char* HOMARD_Gen_i::GetLanguageShort() // MESSAGE ("GetLanguageShort"); return CORBA::string_dup( _LangueShort.c_str() ); } - -//============================================================================= -extern "C" +//=============================================================================== +// Options de publications +//=============================================================================== +void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT) { - PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId* contId, - const char* instanceName, - const char* interfaceName) - { - MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()"); - HOMARD_Gen_i* myHOMARD_Gen = new HOMARD_Gen_i(orb, poa, contId, instanceName, interfaceName); - return myHOMARD_Gen->getId(); - } + _PublisMeshIN = PublisMeshIN ; + _PublisMeshOUT = PublisMeshOUT ; + return ; +} +CORBA::Long HOMARD_Gen_i::GetPublisMeshIN() +{ + return _PublisMeshIN ; +} +CORBA::Long HOMARD_Gen_i::GetPublisMeshOUT() +{ + return _PublisMeshOUT ; } +//=============================================================================== +// YACS - test de convergence +//=============================================================================== +void HOMARD_Gen_i::SetYACSMaximum(CORBA::Long YACSMaxIter, CORBA::Long YACSMaxNode, CORBA::Long YACSMaxElem) +{ + _YACSMaxIter = YACSMaxIter ; + _YACSMaxNode = YACSMaxNode ; + _YACSMaxElem = YACSMaxElem ; + return ; +} +CORBA::Long HOMARD_Gen_i::GetYACSMaxIter() +{ + return _YACSMaxIter ; +} +CORBA::Long HOMARD_Gen_i::GetYACSMaxNode() +{ + return _YACSMaxNode ; +} +CORBA::Long HOMARD_Gen_i::GetYACSMaxElem() +{ + return _YACSMaxElem ; +} +void HOMARD_Gen_i::SetYACSConvergenceType(CORBA::Long YACSTypeTest) +{ + _YACSTypeTest = YACSTypeTest ; + return ; +} +CORBA::Long HOMARD_Gen_i::GetYACSConvergenceType() +{ + return _YACSTypeTest ; +} +