X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHOMARD_I%2FHOMARD_Gen_i.cxx;h=6683369435315cf51105911da7724feec111820d;hb=259960aae337825d77ff62b057f0a0d9773f5eb2;hp=0e161e0873f49b883e1aa96f4dd9b8d70c37a6fe;hpb=aaa87f7e842a16ea5390beadceea50282feac559;p=modules%2Fhomard.git diff --git a/src/HOMARD_I/HOMARD_Gen_i.cxx b/src/HOMARD_I/HOMARD_Gen_i.cxx index 0e161e08..66833694 100755 --- 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-2014 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 @@ -23,10 +23,12 @@ #include "HOMARD_Iteration_i.hxx" #include "HOMARD_Boundary_i.hxx" #include "HOMARD_Zone_i.hxx" +#include "HOMARD_YACS_i.hxx" #include "HomardDriver.hxx" #include "HOMARD_DriverTools.hxx" #include "HomardMedCommun.h" #include "YACSDriver.hxx" +#include "HOMARD.hxx" #include "HOMARD_version.h" @@ -42,7 +44,9 @@ #include #include #include +#ifndef WIN32 #include +#endif #include #include #include @@ -52,6 +56,10 @@ #include #include +#ifdef WIN32 +#include +#endif + using namespace std; //============================================================================= @@ -90,6 +98,14 @@ Engines_Component_i(orb, poa, contId, instanceName, interfaceName) _NS = SINGLETON_::Instance(); ASSERT(SINGLETON_::IsAlreadyExisting()); _NS->init_orb(_orb); + + _tag_gene = 0 ; + _tag_boun = 0 ; + _tag_hypo = 0 ; + _tag_yacs = 0 ; + _tag_zone = 0 ; + + SetPreferences( ) ; } //================================= /*! @@ -369,7 +385,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; @@ -442,6 +458,45 @@ CORBA::Long HOMARD_Gen_i::DeleteIterationOption(const char* nomIter, CORBA::Long return 0 ; } //============================================================================= +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]; + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid schema YACS"; + throw SALOME::SALOME_Exception(es); + return 1 ; + }; + // Suppression eventuelle du fichier XML + if ( Option == 1 ) + { + std::string nomFichier = myYACS->GetXMLFile(); + std::string commande = "rm -rf " + 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 2 ; + } + } + // 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()); + SALOMEDS::SObject_var aSO =listSO[0]; + SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + myCurrentStudy->NewBuilder()->RemoveObjectWithChildren(aSO); + + return 0 ; +} +//============================================================================= CORBA::Long HOMARD_Gen_i::DeleteZone(const char* nomZone) { MESSAGE ( "DeleteZone : nomZone = " << nomZone ); @@ -573,6 +628,7 @@ 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(); aStudyBuilder->RemoveObject(so); @@ -594,7 +650,7 @@ void HOMARD_Gen_i::InvalideIterOption(const char* nomIter, CORBA::Long Option) }; std::string nomDir = myIteration->GetDirName(); std::string nomFichier = myIteration->GetMeshFile(); - std::string commande= "rm -rf " + std::string(nomDir); + std::string commande = "rm -rf " + std::string(nomDir); if ( Option == 1 ) { commande = commande + ";rm -rf " + std::string(nomFichier) ; } MESSAGE ( "commande = " << commande ); if ((system(commande.c_str())) != 0) @@ -635,7 +691,7 @@ 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(); aStudyBuilder->RemoveObject(so); @@ -666,6 +722,47 @@ 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 = myContextMap[GetCurrentStudyID()]._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(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + SALOMEDS::ChildIterator_var aYACS = myCurrentStudy->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 = myCurrentStudy->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 ); @@ -772,27 +869,39 @@ 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]; ASSERT(!CORBA::is_nil(myHypo)); SALOMEDS::SObject_var aHypoSO = SALOMEDS::SObject::_narrow(myCurrentStudy->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]; ASSERT(!CORBA::is_nil(myIteration)); SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); ASSERT(!CORBA::is_nil(aIterSO)); + // Gestion de l'arbre d'etudes SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->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 + myIteration->SupprFieldInterps() ; + HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps(); + int numberOfFieldsx2 = ListField->length(); + for (int iaux = 0; iaux< numberOfFieldsx2; iaux++) + { + std::string FieldName = std::string((*ListField)[iaux]) ; + myIteration->SetFieldInterp(FieldName.c_str()) ; + iaux++ ; + } }; //============================================================================= //============================================================================= @@ -847,6 +956,24 @@ void HOMARD_Gen_i::DissociateHypoZone(const char* nomHypothesis, const char* Zon // Recuperation des listes //============================================================================= //============================================================================= +HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName() +{ + MESSAGE("GetAllBoundarysName"); + IsValidStudy () ; + + HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys; + ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size()); + std::map::const_iterator it; + int i = 0; + for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin(); + it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++) + { + ret[i++] = CORBA::string_dup((*it).first.c_str()); + } + + return ret._retn(); +} +//============================================================================= HOMARD::listeCases* HOMARD_Gen_i::GetAllCasesName() { MESSAGE("GetAllCasesName"); @@ -883,17 +1010,17 @@ HOMARD::listeHypotheses* HOMARD_Gen_i::GetAllHypothesesName() return ret._retn(); } //============================================================================= -HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName() +HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName() { - MESSAGE("GetAllZonesName"); + MESSAGE("GetAllIterationsName"); IsValidStudy () ; - HOMARD::listeZones_var ret = new HOMARD::listeZones; - ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size()); - std::map::const_iterator it; + HOMARD::listeIterations_var ret = new HOMARD::listeIterations; + ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size()); + std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin(); - it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++) + for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin(); + it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -901,17 +1028,17 @@ HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName() return ret._retn(); } //============================================================================= -HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName() +HOMARD::listeYACSs* HOMARD_Gen_i::GetAllYACSsName() { - MESSAGE("GetAllIterationsName"); + MESSAGE("GetAllYACSsName"); IsValidStudy () ; - HOMARD::listeIterations_var ret = new HOMARD::listeIterations; - ret->length(myContextMap[GetCurrentStudyID()]._mesIterations.size()); - std::map::const_iterator it; + HOMARD::listeYACSs_var ret = new HOMARD::listeYACSs; + ret->length(myContextMap[GetCurrentStudyID()]._mesYACSs.size()); + std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesIterations.begin(); - it != myContextMap[GetCurrentStudyID()]._mesIterations.end(); it++) + for (it = myContextMap[GetCurrentStudyID()]._mesYACSs.begin(); + it != myContextMap[GetCurrentStudyID()]._mesYACSs.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -919,17 +1046,17 @@ HOMARD::listeIterations* HOMARD_Gen_i::GetAllIterationsName() return ret._retn(); } //============================================================================= -HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName() +HOMARD::listeZones* HOMARD_Gen_i::GetAllZonesName() { - MESSAGE("GetAllBoundarysName"); + MESSAGE("GetAllZonesName"); IsValidStudy () ; - HOMARD::listeBoundarys_var ret = new HOMARD::listeBoundarys; - ret->length(myContextMap[GetCurrentStudyID()]._mesBoundarys.size()); - std::map::const_iterator it; + HOMARD::listeZones_var ret = new HOMARD::listeZones; + ret->length(myContextMap[GetCurrentStudyID()]._mesZones.size()); + std::map::const_iterator it; int i = 0; - for (it = myContextMap[GetCurrentStudyID()]._mesBoundarys.begin(); - it != myContextMap[GetCurrentStudyID()]._mesBoundarys.end(); it++) + for (it = myContextMap[GetCurrentStudyID()]._mesZones.begin(); + it != myContextMap[GetCurrentStudyID()]._mesZones.end(); it++) { ret[i++] = CORBA::string_dup((*it).first.c_str()); } @@ -944,6 +1071,13 @@ HOMARD::listeBoundarys* HOMARD_Gen_i::GetAllBoundarysName() // Recuperation des structures identifiees par leurs noms //============================================================================= //============================================================================= +HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary) +{ + HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._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]; @@ -951,13 +1085,6 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::GetCase(const char* nomCas) return HOMARD::HOMARD_Cas::_duplicate(myCase); } //============================================================================= -HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::GetZone(const char* ZoneName) -{ - HOMARD::HOMARD_Zone_var myZone = myContextMap[GetCurrentStudyID()]._mesZones[ZoneName]; - ASSERT(!CORBA::is_nil(myZone)); - return HOMARD::HOMARD_Zone::_duplicate(myZone); -} -//============================================================================= HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::GetHypothesis(const char* nomHypothesis) { HOMARD::HOMARD_Hypothesis_var myHypothesis = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis]; @@ -972,11 +1099,18 @@ HOMARD::HOMARD_Iteration_ptr HOMARD_Gen_i::GetIteration(const char* NomIteratio return HOMARD::HOMARD_Iteration::_duplicate(myIteration); } //============================================================================= -HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary) +HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::GetYACS(const char* nomYACS) { - HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[nomBoundary]; - ASSERT(!CORBA::is_nil(myBoundary)); - return HOMARD::HOMARD_Boundary::_duplicate(myBoundary); + HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._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]; + ASSERT(!CORBA::is_nil(myZone)); + return HOMARD::HOMARD_Zone::_duplicate(myZone); } //============================================================================= //============================================================================= @@ -988,12 +1122,14 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::GetBoundary(const char* nomBoundary) //============================================================================= 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) { - MESSAGE ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); - MESSAGE ( "Qual = " << Qual << ", Diam = " << Diam << ", Conn = " << Conn << ", Tail = " << Tail << ", Inte = " << Inte ); + INFOS ( "MeshInfo : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); + INFOS ( "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) ; @@ -1066,6 +1202,14 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::newZone() return aZone._retn(); } //============================================================================= +HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::newYACS() +{ + HOMARD::HOMARD_Gen_var engine = POA_HOMARD::HOMARD_Gen::_this(); + HOMARD_YACS_i* aServant = new HOMARD_YACS_i(_orb, engine); + HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(aServant->_this()); + return aYACS._retn(); +} +//============================================================================= //============================================================================= //============================================================================= @@ -1080,9 +1224,11 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase(const char* nomCas, const char* // MeshName, MeshFile : nom et fichier du maillage correspondant // { - MESSAGE ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); + INFOS ( "CreateCase : nomCas = " << nomCas << ", MeshName = " << MeshName << ", MeshFile = " << MeshFile ); - HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 0, 0, 2) ; + 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); @@ -1096,13 +1242,13 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, // DirNameStart : nom du repertoire contenant l'iteration de reprise // { - MESSAGE ( "CreateCaseFromIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); + INFOS ( "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) ; + codret = CHDIR(DirNameStart) ; if ( codret != 0 ) { SALOME::ExceptionStruct es; @@ -1115,6 +1261,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, std::string file_configuration = "" ; std::string file_maillage_homard = "" ; int bilan ; +#ifndef WIN32 DIR *dp; struct dirent *dirp; dp = opendir(DirNameStart); @@ -1132,10 +1279,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; @@ -1174,7 +1341,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 ; @@ -1193,7 +1360,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 ; } @@ -1231,7 +1398,9 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas, // C. Creation effective du cas - HOMARD::HOMARD_Cas_ptr myCase = CreateCase0(nomCas, MeshName, MeshFile, 1, NumeIter, 2) ; + 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 @@ -1249,7 +1418,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; @@ -1259,7 +1432,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()) ; @@ -1278,8 +1451,7 @@ 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); } //============================================================================= @@ -1289,7 +1461,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseLastIteration(const char* // DirNameStart : nom du repertoire du cas contenant l'iteration de reprise // { - MESSAGE ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); + INFOS ( "CreateCaseFromCaseLastIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart ); std::string DirNameStartIter = CreateCase1(DirNameStart, -1) ; @@ -1306,7 +1478,7 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromCaseIteration(const char* nom // Number : numero de l'iteration de depart // { - MESSAGE ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number ); + INFOS ( "CreateCaseFromCaseIteration : nomCas = " << nomCas << ", DirNameStart = " << DirNameStart << ", Number = " << Number ); if ( Number < 0 ) { SALOME::ExceptionStruct es; @@ -1338,7 +1510,7 @@ std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Numb int NumeIterMax = -1 ; // A.1. Controle du repertoire de depart du cas - codret = chdir(DirNameStart) ; + codret = CHDIR(DirNameStart) ; if ( codret != 0 ) { SALOME::ExceptionStruct es; @@ -1349,29 +1521,51 @@ std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Numb }; // A.2. Reperage des sous-repertoire du repertoire 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-repertoire + 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 { @@ -1417,20 +1611,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; @@ -1478,7 +1679,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; @@ -1494,7 +1695,7 @@ 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; - PublishInStudy(myCurrentStudy, aSO, myCase, nomCas); + SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myCase, nomCas); myContextMap[GetCurrentStudyID()]._mesCas[nomCas] = myCase; // C. Caracteristiques du maillage @@ -1562,10 +1763,10 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCase0(const char* nomCas, const char* //============================================================================= HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypothesis) { - MESSAGE ( "CreateHypothesis : nomHypothesis = " << nomHypothesis ); + INFOS ( "CreateHypothesis : nomHypothesis = " << nomHypothesis ); IsValidStudy () ; - // Controle du nom : + // A. Controle du nom : if ((myContextMap[GetCurrentStudyID()]._mesHypotheses).find(nomHypothesis) != (myContextMap[GetCurrentStudyID()]._mesHypotheses).end()) { SALOME::ExceptionStruct es; @@ -1575,17 +1776,29 @@ HOMARD::HOMARD_Hypothesis_ptr HOMARD_Gen_i::CreateHypothesis(const char* nomHypo return 0; } + // B. Creation de l'objet HOMARD::HOMARD_Hypothesis_var myHypothesis = newHypothesis(); + if (CORBA::is_nil(myHypothesis)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Unable to create the hypothesis"; + throw SALOME::SALOME_Exception(es); + return 0; + }; myHypothesis->SetName(nomHypothesis); + + // C. Enregistrement myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypothesis] = myHypothesis; + SALOMEDS::SObject_var aSO; - PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis); + SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myHypothesis, nomHypothesis); -// Valeurs par defaut des options avancees + // 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); } @@ -1594,7 +1807,7 @@ 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) //============================================================================= { - MESSAGE ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent); + INFOS ("CreateIteration : NomIteration = " << NomIteration << ", nomIterParent = " << nomIterParent); IsValidStudy () ; HOMARD::HOMARD_Iteration_var myIterationParent = myContextMap[GetCurrentStudyID()]._mesIterations[nomIterParent]; @@ -1678,6 +1891,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(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIterationParent))); + SALOMEDS::SObject_var aIterSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); + SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + aStudyBuilder->NewCommand(); + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); + aStudyBuilder->Addreference(aSubSO, aIterSOParent); + aStudyBuilder->CommitCommand(); return HOMARD::HOMARD_Iteration::_duplicate(myIteration); } @@ -1712,7 +1933,7 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundary(const char* BoundaryNam //============================================================================= HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryDi(const char* BoundaryName, const char* MeshName, const char* MeshFile) { - MESSAGE ("CreateBoundaryDi : BoundaryName = " << BoundaryName << "MeshName = " << MeshName ); + INFOS ("CreateBoundaryDi : BoundaryName = " << BoundaryName << ", MeshName = " << MeshName ); HOMARD::HOMARD_Boundary_var myBoundary = CreateBoundary(BoundaryName, 0); myBoundary->SetMeshFile( MeshFile ) ; myBoundary->SetMeshName( MeshName ) ; @@ -1725,7 +1946,7 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundaryCylinder(const char* Bou CORBA::Double Xaxe, CORBA::Double Yaxe, CORBA::Double Zaxe, CORBA::Double Rayon) { - MESSAGE ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ; + INFOS ("CreateBoundaryCylinder : BoundaryName = " << BoundaryName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -1753,7 +1974,7 @@ HOMARD::HOMARD_Boundary_ptr HOMARD_Gen_i::CreateBoundarySphere(const char* Bound CORBA::Double Xcentre, CORBA::Double Ycentre, CORBA::Double Zcentre, CORBA::Double Rayon) { - MESSAGE ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ; + INFOS ("CreateBoundarySphere : BoundaryName = " << BoundaryName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -1777,11 +1998,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) { - MESSAGE ("CreateBoundaryConeA : BoundaryName = " << BoundaryName ) ; + INFOS ("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) ; @@ -1805,11 +2026,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) { - MESSAGE ("CreateBoundaryConeR : BoundaryName = " << BoundaryName ) ; + INFOS ("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) ; @@ -1833,6 +2054,35 @@ 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) +{ + INFOS ("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); @@ -1865,7 +2115,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox(const char* ZoneName, CORBA::Double Ymini, CORBA::Double Ymaxi, CORBA::Double Zmini, CORBA::Double Zmaxi) { - MESSAGE ("CreateZoneBox : ZoneName = " << ZoneName ) ; + INFOS ("CreateZoneBox : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -1894,7 +2144,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) { - MESSAGE ("CreateZoneSphere : ZoneName = " << ZoneName ) ; + INFOS ("CreateZoneSphere : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -1919,7 +2169,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) { - MESSAGE ("CreateZoneCylinder : ZoneName = " << ZoneName ) ; + INFOS ("CreateZoneCylinder : ZoneName = " << ZoneName ) ; // SALOME::ExceptionStruct es; int error = 0 ; @@ -1951,11 +2201,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) { - MESSAGE ("CreateZonePipe : ZoneName = " << ZoneName ) ; + INFOS ("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) ; @@ -1986,7 +2236,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName, CORBA::Double Vmini, CORBA::Double Vmaxi, CORBA::Long Orient) { - MESSAGE ("CreateZoneBox2D : ZoneName = " << ZoneName ) ; + INFOS ("CreateZoneBox2D : ZoneName = " << ZoneName ) ; // MESSAGE ("Umini = " << Umini << ", Umaxi =" << Umaxi ) ; // MESSAGE ("Vmini = " << Vmini << ", Vmaxi =" << Vmaxi ) ; // MESSAGE ("Orient = " << Orient ) ; @@ -1999,7 +2249,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 ) @@ -2033,7 +2283,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneBox2D(const char* ZoneName, Ymaxi = 0. ; Zmini = Umini ; Zmaxi = Umaxi ; } - else { ASSERT( 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) ; @@ -2046,14 +2296,14 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName, CORBA::Double Rayon, CORBA::Long Orient) { - MESSAGE ("CreateZoneDisk : ZoneName = " << ZoneName ) ; + INFOS ("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 ) @@ -2078,7 +2328,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDisk(const char* ZoneName, { Xcentre = Vcentre ; Ycentre = 0. ; Zcentre = Ucentre ; } - else { ASSERT( 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. ) ; @@ -2091,14 +2341,14 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneNam CORBA::Double Rayon, CORBA::Double Rayonint, CORBA::Long Orient) { - MESSAGE ("CreateZoneDiskWithHole : ZoneName = " << ZoneName ) ; + INFOS ("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 ) @@ -2126,7 +2376,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneNam { Xcentre = Vcentre ; Ycentre = 0. ; Zcentre = Ucentre ; } - else { ASSERT( 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 ) ; @@ -2153,7 +2403,7 @@ HOMARD::HOMARD_Zone_ptr HOMARD_Gen_i::CreateZoneDiskWithHole(const char* ZoneNam //============================================================================= CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMenage, CORBA::Long modeHOMARD, CORBA::Long Option1, CORBA::Long Option2) { - MESSAGE ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", avec Option1 = " << Option1 << ", avec Option2 = " << Option2 ); + INFOS ( "Compute : traitement de " << NomIteration << ", avec modeHOMARD = " << modeHOMARD << ", Option1 = " << Option1 << ", Option2 = " << Option2 ); // A. Prealable int codret = 0; @@ -2162,7 +2412,44 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._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]; ASSERT(!CORBA::is_nil(myCase)); @@ -2220,13 +2507,12 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena // D. On passe dans le repertoire de l'iteration a calculer MESSAGE ( ". On passe dans DirCompute = " << DirCompute ); - chdir(DirCompute) ; + CHDIR(DirCompute); // E. Les donnees de l'execution HOMARD // E.1. L'objet du texte du fichier de configuration HomardDriver* myDriver = new HomardDriver(siter, siterp1); - std::string Langue = "Francais" ; - myDriver->TexteInit(DirCompute, LogFile, Langue); + myDriver->TexteInit(DirCompute, LogFile, _Langue); // E.2. Le maillage associe a l'iteration const char* NomMesh = myIteration->GetMeshName(); @@ -2257,6 +2543,7 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena DriverTexteBoundary(myCase, myDriver) ; // E.5. Ecriture du texte dans le fichier + MESSAGE ( ". Ecriture du texte dans le fichier de configuration ; codret = "<CreeFichier(); } @@ -2268,6 +2555,7 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena codretexec = myDriver->ExecuteHomard(Option1); // MESSAGE ( "Erreur en executant HOMARD : " << codretexec ); + // En mode adaptation, on ajuste l'etat de l'iteration if ( modeHOMARD == 1 ) { if (codretexec == 0) { SetEtatIter(NomIteration,2); } @@ -2298,30 +2586,47 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena if ( modeHOMARD == 1 ) { std::stringstream saux0 ; - Commentaire = "Iteration" ; - Commentaire += " " + siter ; + Commentaire = "Mesh" ; + Commentaire += " " + siterp1 ; PublishFileUnderIteration(NomIteration, MeshFile, Commentaire.c_str()); if ( Option2 % 2 == 0 ) { PublishResultInSmesh(MeshFile, 1); } } } - // H.3 Message d'erreur en cas de probleme - else + // H.3 Message d'erreur + if (codretexec != 0) { - SALOME::ExceptionStruct es; - es.type = SALOME::BAD_PARAM; - std::string text = "Error during the adaptation.\n" ; - try + std::string text = "" ; + // Message d'erreur en cas de probleme en adaptation + if ( modeHOMARD == 1 ) { - ifstream fichier(LogFile.c_str(), ios::in); - string ligne; - while(getline(fichier, ligne) and (ligne != "===== HOMARD ===== STOP =====")); - while (getline(fichier, ligne)) { text += ligne+ "\n";}; - } - catch (...) { - text += "no log file ...."; + 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 + { + std::string ligne; // variable contenant chaque ligne lue + while ( std::getline( fichier, ligne ) ) + { +// INFOS(ligne); + if ( stopvu ) + { text += ligne+ "\n"; } + else + { + int position = ligne.find( "===== HOMARD ===== STOP =====" ) ; + if ( position > 0 ) { stopvu = true ; } + } + } + } } + 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); +// + // En mode information, on force le succes pour pouvoir consulter le fichier log + if ( modeHOMARD != 1 ) { codretexec = 0 ; } } } @@ -2330,7 +2635,8 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena { delete myDriver; MESSAGE ( ". On retourne dans nomDirWork = " << nomDirWork ); - chdir(nomDirWork.c_str()); + + CHDIR(nomDirWork.c_str()); } return codretexec ; @@ -2345,8 +2651,6 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM // 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 ; @@ -2354,18 +2658,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("")) { @@ -2390,7 +2683,7 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM if (codret != 0) { // GERALD -- QMESSAGE BOX - ASSERT("Pb au calcul de l'iteration precedente" == 0); + VERIFICATION("Pb au calcul de l'iteration precedente" == 0); } }; @@ -2447,6 +2740,7 @@ CORBA::Long HOMARD_Gen_i::ComputeAdap(HOMARD::HOMARD_Cas_var myCase, HOMARD::HOM 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 @@ -2490,9 +2784,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(); @@ -2510,7 +2804,7 @@ 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 ; @@ -2564,8 +2873,7 @@ 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() ); } //============================================================================= @@ -2592,14 +2900,17 @@ char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD:: MESSAGE (". DirCompute = " << DirCompute.str() ); // B.3.3. Si le sous-repertoire n'existe pas, on le cree - if (chdir(DirCompute.str().c_str()) != 0) + 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; - ASSERT("Pb a la creation du repertoire" == 0); + VERIFICATION("Pb a la creation du repertoire" == 0); } } else @@ -2609,13 +2920,13 @@ char* HOMARD_Gen_i::ComputeDirManagement(HOMARD::HOMARD_Cas_var myCase, HOMARD:: if (etatMenage == 1) { MESSAGE (". Menage du repertoire DirCompute = " << DirCompute.str()); - std::string commande= "rm -rf " + 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; - ASSERT("Pb au menage du repertoire de calcul" == 0); + VERIFICATION("Pb au menage du repertoire de calcul" == 0); } } // On n'a pas demande de faire le menage de son contenu : on sort en erreur : @@ -2623,6 +2934,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()); @@ -2633,14 +2945,28 @@ 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); - ASSERT("Directory is not empty" == 0); + VERIFICATION("Directory is not empty" == 0); } } } @@ -2693,15 +3019,15 @@ 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 { ASSERT("ZoneType est incorrect." == 0) ; } + else { VERIFICATION("ZoneType est incorrect." == 0) ; } iaux += 1 ; } return ; @@ -2719,9 +3045,9 @@ void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HO { // GERALD -- QMESSAGE BOX std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl; - ASSERT("The file for the field is not given." == 0); + VERIFICATION("The file for the field is not given." == 0); } -// Les caracteristiques d'instants +// Les caracteristiques d'instants du champ de pilotage int TimeStep = myIteration->GetTimeStep(); MESSAGE( ". TimeStep = " << TimeStep ); int Rank = myIteration->GetRank(); @@ -2745,7 +3071,7 @@ void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HO myDriver->TexteField(FieldName, FieldFile, TimeStep, Rank, TypeThR, ThreshR, TypeThC, ThreshC, UsField, UsCmpI); // // Les composantes - HOMARD::listeComposantsHypo* mescompo = myHypo->GetListComp(); + HOMARD::listeComposantsHypo* mescompo = myHypo->GetComps(); int numberOfCompos = mescompo->length(); MESSAGE( ". numberOfCompos = " << numberOfCompos ); for (int NumeComp = 0; NumeComp< numberOfCompos; NumeComp++) @@ -2758,21 +3084,28 @@ void HOMARD_Gen_i::DriverTexteField(HOMARD::HOMARD_Iteration_var myIteration, HO } //============================================================================= // Calcul d'une iteration : ecriture des frontieres dans le fichier de configuration +// On ecrit dans l'ordre : +// 1. la definition des frontieres +// 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) { MESSAGE ( "... DriverTexteBoundary" ); - // On ecrit d'abord la definition des frontieres, puis les liens avec les groupes + // 1. Recuperation des frontieres std::list ListeBoundaryTraitees ; HOMARD::ListBoundaryGroupType* ListBoundaryGroupType = myCase->GetBoundaryGroup(); int numberOfitems = ListBoundaryGroupType->length(); MESSAGE ( "... number of string for Boundary+Group = " << numberOfitems); int BoundaryOption = 1 ; + // 2. Parcours des frontieres pour ecrire leur description int NumBoundaryAnalytical = 0 ; for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2) { std::string BoundaryName = std::string((*ListBoundaryGroupType)[NumBoundary]); MESSAGE ( "... BoundaryName = " << BoundaryName); + // 2.1. La frontiere a-t-elle deja ete ecrite ? + // 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()) @@ -2781,22 +3114,27 @@ void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriv if ( BoundaryName == *it ) { A_faire = 0 ; } it++; } + // 2.2. Ecriture de la frontiere if ( A_faire == 1 ) { -// Caracteristiques de la frontiere + // 2.2.1. Caracteristiques de la frontiere HOMARD::HOMARD_Boundary_var myBoundary = myContextMap[GetCurrentStudyID()]._mesBoundarys[BoundaryName]; ASSERT(!CORBA::is_nil(myBoundary)); int BoundaryType = myBoundary->GetType(); MESSAGE ( "... BoundaryType = " << BoundaryType ); -// Ecriture selon le type - if (BoundaryType == 0) // Cas d une frontiere discrete + // 2.2.2. Ecriture selon le type + // 2.2.2.1. Cas d une frontiere discrete + if (BoundaryType == 0) { const char* MeshName = myBoundary->GetMeshName() ; + MESSAGE ( ". MeshName = " << MeshName ); const char* MeshFile = myBoundary->GetMeshFile() ; + MESSAGE ( ". MeshFile = " << MeshFile ); myDriver->TexteBoundaryDi( MeshName, MeshFile); if ( BoundaryOption % 2 != 0 ) { BoundaryOption = BoundaryOption*2 ; } } - else // Cas d une frontiere analytique + // 2.2.2.1. Cas d une frontiere analytique + else { NumBoundaryAnalytical++ ; HOMARD::double_array* coor = myBoundary->GetCoords(); @@ -2820,11 +3158,17 @@ 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 ; } + } } -// Memorisation du traitement + // 2.2.3. Memorisation du traitement ListeBoundaryTraitees.push_back( BoundaryName ); } } + // 3. Parcours des frontieres pour ecrire les liens avec les groupes NumBoundaryAnalytical = 0 ; for (int NumBoundary = 0; NumBoundary< numberOfitems; NumBoundary=NumBoundary+2) { @@ -2834,20 +3178,24 @@ void HOMARD_Gen_i::DriverTexteBoundary(HOMARD::HOMARD_Cas_var myCase, HomardDriv ASSERT(!CORBA::is_nil(myBoundary)); int BoundaryType = myBoundary->GetType(); MESSAGE ( "... BoundaryType = " << BoundaryType ); -// Recuperation du nom du groupe + // 3.1. Recuperation du nom du groupe std::string GroupName = std::string((*ListBoundaryGroupType)[NumBoundary+1]); MESSAGE ( "... GroupName = " << GroupName); - if (BoundaryType == 0) // Cas d une frontiere discrete + // 3.2. Cas d une frontiere discrete + if ( BoundaryType == 0 ) { if ( GroupName.size() > 0 ) { myDriver->TexteBoundaryDiGr ( GroupName ) ; } } - else // Cas d une frontiere analytique + // 3.3. Cas d une frontiere analytique + else { NumBoundaryAnalytical++ ; myDriver->TexteBoundaryAnGr ( BoundaryName, NumBoundaryAnalytical, GroupName ) ; } } + // 4. Ecriture de l'option finale myDriver->TexteBoundaryOption(BoundaryOption); +// return ; } //============================================================================= @@ -2857,6 +3205,7 @@ void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIterati { MESSAGE ( "... DriverTexteFieldInterp" ); int TypeFieldInterp = myHypo->GetTypeFieldInterp(); + MESSAGE ( "... TypeFieldInterp = " << TypeFieldInterp); if (TypeFieldInterp != 0) { // Le fichier des champs @@ -2865,28 +3214,68 @@ void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIterati if (strlen(FieldFile) == 0) { // GERALD -- QMESSAGE BOX - std::cerr << "Le fichier du champ n'a pas ete fourni." << std::endl; - ASSERT("The file for the field is not given." == 0); + VERIFICATION("The file for the field is not given." == 0); } - // Les caracteristiques d'instants - int TimeStep = myIteration->GetTimeStep(); - MESSAGE( ". TimeStep = " << TimeStep ); - int Rank = myIteration->GetRank(); - MESSAGE( ". Rank = " << Rank ); // const char* MeshFile = myIteration->GetMeshFile(); - myDriver->TexteFieldInterp(TypeFieldInterp, FieldFile, MeshFile, TimeStep, Rank); - // Les champs - if (TypeFieldInterp == 2) + myDriver->TexteFieldInterp(FieldFile, MeshFile); + + // Les champs + // Interpolation de tous les champs + if ( TypeFieldInterp == 1 ) + { + myDriver->TexteFieldInterpAll(); + } + // Interpolation de certains champs + else if (TypeFieldInterp == 2) { - HOMARD::listFieldInterpHypo* meschamps = myHypo->GetListFieldInterp(); - int numberOfFields = meschamps->length(); - MESSAGE( ". numberOfFields = " << numberOfFields ); - for (int NumeChamp = 0; NumeChamp< numberOfFields; NumeChamp++) + // Les champs et leurs instants pour l'iteration + HOMARD::listeFieldInterpTSRsIter* ListFieldTSR = myIteration->GetFieldInterpsTimeStepRank(); + int numberOfFieldsx3 = ListFieldTSR->length(); + MESSAGE( ". pour iteration, numberOfFields = " << numberOfFieldsx3/3 ); + // Les champs pour l'hypothese + HOMARD::listeFieldInterpsHypo* ListField = myHypo->GetFieldInterps(); + int numberOfFieldsx2 = ListField->length(); + MESSAGE( ". pour hypothese, numberOfFields = " << numberOfFieldsx2/2 ); + // On parcourt tous les champs de l'hypothese + int NumField = 0 ; + for (int iaux = 0; iaux< numberOfFieldsx2; iaux++) { - std::string nomChamp = std::string((*meschamps)[NumeChamp]); - MESSAGE( "... nomChamp = " << nomChamp ); - myDriver->TexteFieldInterpName(NumeChamp, nomChamp); + // Le nom du champ + std::string FieldName = std::string((*ListField)[iaux]) ; + // 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 + int tsrvu = 0; + for (int jaux = 0; jaux< numberOfFieldsx3; jaux++) + { + // Le nom du champ + std::string FieldName2 = std::string((*ListFieldTSR)[jaux]) ; + MESSAGE( "..... FieldName2 = " << FieldName2 ); + // Quand c'est le bon champ, on ecrit le pas de temps + if ( FieldName == FieldName2 ) + { + tsrvu = 1 ; + // Le pas de temps + std::string TimeStepstr = std::string((*ListFieldTSR)[jaux+1]) ; + // Le numero d'ordre + std::string Rankstr = std::string((*ListFieldTSR)[jaux+2]) ; + MESSAGE( "..... TimeStepstr = " << TimeStepstr <<", Rankstr = "<TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, TimeStep, Rank); + } + jaux += 2 ; + } + // Si aucun instant n'a été défini + if ( tsrvu == 0 ) + { + NumField += 1 ; + myDriver->TexteFieldInterpNameType(NumField, FieldName, TypeInterpstr, -1, -1); + } + iaux++ ; } } } @@ -2919,21 +3308,21 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, // Recuperation de l'objet correspondant, en essayant chacun des types possibles // Rq : Iteration est publiee ailleurs + HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject); HOMARD::HOMARD_Cas_var aCase = HOMARD::HOMARD_Cas::_narrow(theObject); HOMARD::HOMARD_Hypothesis_var aHypo = HOMARD::HOMARD_Hypothesis::_narrow(theObject); + HOMARD::HOMARD_YACS_var aYACS = HOMARD::HOMARD_YACS::_narrow(theObject); HOMARD::HOMARD_Zone_var aZone = HOMARD::HOMARD_Zone::_narrow(theObject); - HOMARD::HOMARD_Boundary_var aBoundary = HOMARD::HOMARD_Boundary::_narrow(theObject); addInStudy(theStudy); // Controle de la non publication d'un objet de meme nom - if ((!aHypo->_is_nil()) or (!aZone->_is_nil()) or (!aBoundary->_is_nil())) + if ( (!aBoundary->_is_nil()) || (!aHypo->_is_nil()) || (!aYACS->_is_nil()) || (!aZone->_is_nil()) ) { SALOMEDS::Study::ListOfSObject_var listSO = theStudy->FindObjectByName(theName, ComponentDataType()); if (listSO->length() >= 1) { MESSAGE("This name "<length()<<" time(s)"); - std::cerr <<"This name "<length()<<" time(s)" << std::endl; aResultSO = listSO[0]; return aResultSO._retn(); } @@ -2942,26 +3331,104 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, // Caracteristiques de l'etude SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); aStudyBuilder->NewCommand(); - if(!aCase->_is_nil()) + if(!aBoundary->_is_nil()) + aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName); + else if(!aCase->_is_nil()) aResultSO = PublishCaseInStudy(theStudy, aStudyBuilder, aCase, theName); else if(!aHypo->_is_nil()) aResultSO = PublishHypotheseInStudy(theStudy, aStudyBuilder, aHypo, theName); + else if(!aYACS->_is_nil()) + aResultSO = PublishYACSInStudy(theStudy, aStudyBuilder, aYACS, theName); else if(!aZone->_is_nil()) aResultSO = PublishZoneInStudy(theStudy, aStudyBuilder, aZone, theName); - else if(!aBoundary->_is_nil()) - aResultSO = PublishBoundaryInStudy(theStudy, aStudyBuilder, aBoundary, theName); - aStudyBuilder->CommitCommand(); + aStudyBuilder->CommitCommand(); + return aResultSO._retn(); }; //============================================================================= +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::StudyBuilder_var aStudyBuilder, + HOMARD::HOMARD_Boundary_ptr theObject, const char* theName) +{ + MESSAGE("PublishBoundaryStudy pour "<FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + + // On ajoute la categorie des boundarys dans l etude si necessaire + if ( _tag_boun == 0 ) + { + _tag_gene += 1 ; + _tag_boun = _tag_gene ; + } + MESSAGE("PublishBoundaryInStudy _tag_gene = "<<_tag_gene << ", _tag_boun = "<<_tag_boun ); + SALOMEDS::SObject_var aSObject; + if (!theFatherHomard->FindSubObject(_tag_boun, aSObject)) + { + MESSAGE("Ajout de la categorie des boundarys"); + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_boun); + PublishInStudyAttr(aStudyBuilder, aSObject, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ; + } + else { MESSAGE("La categorie des boundarys existe deja."); } + + CORBA::Long BoundaryType = myBoundary->GetType(); +// MESSAGE("BoundaryType : "<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, HOMARD::HOMARD_Cas_ptr theObject, const char* theName) { MESSAGE("PublishCaseInStudy pour "<_is_nil()"); @@ -2972,6 +3439,7 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theSt return aResultSO._retn(); } + // On recupere le module pere dans l etude SALOMEDS::SComponent_var theFatherHomard = theStudy->FindComponent(ComponentDataType()); if (theFatherHomard->_is_nil()) { @@ -2979,21 +3447,99 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishCaseInStudy(SALOMEDS::Study_ptr theSt return aResultSO._retn(); } + _tag_gene += 1 ; + MESSAGE("PublishCaseInStudy _tag_gene = "<<_tag_gene ); aResultSO = aStudyBuilder->NewObject(theFatherHomard); PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "CasHomard", "cas_calcule.png", _orb->object_to_string(theObject) ) ; + + return aResultSO._retn(); +} +//============================================================================= +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::StudyBuilder_var aStudyBuilder, + HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName) +{ + MESSAGE("PublishHypotheseInStudy pour "<FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + + // On ajoute la categorie des hypotheses dans l etude si necessaire + SALOMEDS::SObject_var aSObject; + if ( _tag_hypo == 0 ) + { + _tag_gene += 1 ; + _tag_hypo = _tag_gene ; + } + MESSAGE("PublishHypotheseInStudy _tag_gene = "<<_tag_gene << ", _tag_hypo = "<<_tag_hypo ); + if (!theFatherHomard->FindSubObject(_tag_hypo, aSObject)) + { + MESSAGE("Ajout de la categorie des hypotheses"); + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_hypo); + PublishInStudyAttr(aStudyBuilder, aSObject, "Hypothesis", "HypoList", "hypotheses.png", NULL); + } + else { MESSAGE("La categorie des hypotheses existe deja."); } + +// Creation du resultat dans l'etude + aResultSO = aStudyBuilder->NewObject(aSObject); + PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ; + + return aResultSO._retn(); +} +//============================================================================= +SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishYACSInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::StudyBuilder_var aStudyBuilder, + HOMARD::HOMARD_YACS_ptr theObject, const char* theName) +{ + MESSAGE("PublishYACSInStudy pour "<FindComponent(ComponentDataType()); + if (theFatherHomard->_is_nil()) + { + MESSAGE("theFatherHomard->_is_nil()"); + return aResultSO._retn(); + } + // On ajoute la categorie des schemas YACS dans l etude si necessaire + if ( _tag_yacs == 0 ) + { + _tag_gene += 1 ; + _tag_yacs = _tag_gene ; + } + MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_yacs = "<<_tag_yacs ); + SALOMEDS::SObject_var aSObject; + if (!theFatherHomard->FindSubObject(_tag_yacs, aSObject)) + { + MESSAGE("Ajout de la categorie des schemas YACS"); + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_yacs); + PublishInStudyAttr(aStudyBuilder, aSObject, "YACS", "YACSList", "full_view.png", NULL); + } + else { MESSAGE("La categorie des schemas YACS existe deja."); } + +// Creation du resultat dans l'etude + aResultSO = aStudyBuilder->NewObject(aSObject); + PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "YACSHomard", "schema.png", _orb->object_to_string(theObject) ) ; + return aResultSO._retn(); } //============================================================================= SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, + SALOMEDS::StudyBuilder_var aStudyBuilder, HOMARD::HOMARD_Zone_ptr theObject, const char* theName) { MESSAGE("PublishZoneStudy pour "<_is_nil()"); @@ -3016,16 +3562,22 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theSt CORBA::Long ZoneType = myZone->GetType(); // On ajoute la categorie des zones dans l etude si necessaire - SALOMEDS::SObject_var aSOZone; - if (!theFatherHomard->FindSubObject(100, aSOZone)) + if ( _tag_zone == 0 ) + { + _tag_gene += 1 ; + _tag_zone = _tag_gene ; + } + MESSAGE("PublishZoneStudy _tag_gene = "<<_tag_gene << ", _tag_zone = "<<_tag_zone ); + SALOMEDS::SObject_var aSObject; + if (!theFatherHomard->FindSubObject(_tag_zone, aSObject)) { MESSAGE("Ajout de la categorie des zones"); - aSOZone = aStudyBuilder->NewObjectToTag(theFatherHomard, 100); - PublishInStudyAttr(aStudyBuilder, aSOZone, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ; + aSObject = aStudyBuilder->NewObjectToTag(theFatherHomard, _tag_zone); + PublishInStudyAttr(aStudyBuilder, aSObject, "Zones", "ZoneList", "zone_icone_2.png", NULL ) ; } else { MESSAGE("La categorie des zones existe deja."); } - aResultSO = aStudyBuilder->NewObject(aSOZone); + aResultSO = aStudyBuilder->NewObject(aSObject); std::string icone ; switch (ZoneType) { @@ -3074,110 +3626,14 @@ SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishZoneInStudy(SALOMEDS::Study_ptr theSt return aResultSO._retn(); } -//============================================================================= -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishBoundaryInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, - HOMARD::HOMARD_Boundary_ptr theObject, const char* theName) -{ - MESSAGE("PublishBoundaryStudy pour "<FindComponent(ComponentDataType()); - if (theFatherHomard->_is_nil()) - { - MESSAGE("theFatherHomard->_is_nil()"); - return aResultSO._retn(); - } - - // On ajoute la categorie des boundarys dans l etude si necessaire - SALOMEDS::SObject_var aSOBoundary; - if (!theFatherHomard->FindSubObject(101, aSOBoundary)) - { - MESSAGE("Ajout de la categorie des boundarys"); - aSOBoundary = aStudyBuilder->NewObjectToTag(theFatherHomard, 101); - PublishInStudyAttr(aStudyBuilder, aSOBoundary, "Boundaries", "BoundList", "zone_icone_2.png", NULL ) ; - } - else { MESSAGE("La categorie des boundarys existe deja."); } - - aResultSO = aStudyBuilder->NewObject(aSOBoundary); - CORBA::Long BoundaryType = myBoundary->GetType(); -// MESSAGE("BoundaryType : "<object_to_string(theObject)); - return aResultSO._retn(); -} - -//============================================================================= -SALOMEDS::SObject_ptr HOMARD_Gen_i::PublishHypotheseInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::StudyBuilder_var aStudyBuilder, - HOMARD::HOMARD_Hypothesis_ptr theObject, const char* theName) -{ - MESSAGE("PublishHypotheseInStudy pour "<FindComponent(ComponentDataType()); - if (theFatherHomard->_is_nil()) - { - MESSAGE("theFatherHomard->_is_nil()"); - return aResultSO._retn(); - } - SALOMEDS::SObject_var aSOHypothese; - if (!theFatherHomard->FindSubObject(0, aSOHypothese)) - { - MESSAGE("Ajout de la categorie des hypotheses"); - aSOHypothese = aStudyBuilder->NewObjectToTag(theFatherHomard, 0); - PublishInStudyAttr(aStudyBuilder, aSOHypothese, "Hypothesis", "HypoList","hypotheses.png", NULL); - } - else { MESSAGE("La categorie des hypotheses existe deja."); } - -// Creation du resultat dans l'etude - aResultSO = aStudyBuilder->NewObject(aSOHypothese); - PublishInStudyAttr(aStudyBuilder, aResultSO, theName, "HypoHomard", NULL, _orb->object_to_string(theObject) ) ; - - return aResultSO._retn(); -} //=========================================================================== void HOMARD_Gen_i::PublishInStudyAttr(SALOMEDS::StudyBuilder_var aStudyBuilder, SALOMEDS::SObject_var aResultSO, - const char* name, const char* value, const char* icone, const char* ior) + const char* name, const char* comment, const char* icone, const char* ior) { + MESSAGE("PublishInStudyAttr pour name = "<SetValue(value); + aCommentAttrib->SetValue(comment); } // Ajout de l'icone if ( icone != NULL ) { - anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO,"AttributePixMap"); + anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributePixMap"); SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap(icone); } @@ -3233,6 +3689,32 @@ void HOMARD_Gen_i::PublishBoundaryUnderCase(const char* CaseName, const char* Bo SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aCaseSO); aStudyBuilder->Addreference(aSubSO, aBoundarySO); +// aStudyBuilder->RemoveReference(aSubSO); + + aStudyBuilder->CommitCommand(); + +}; +//===================================================================================== +void HOMARD_Gen_i::PublishCaseUnderYACS(const char* nomYACS, const char* CaseName) +{ + MESSAGE ( "PublishCaseUnderYACS : nomYACS = " << nomYACS << ", CaseName= " << CaseName ); + + HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS]; + ASSERT(!CORBA::is_nil(myYACS)); + SALOMEDS::SObject_var aYACSSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + ASSERT(!CORBA::is_nil(aYACSSO)); + + HOMARD::HOMARD_Cas_var myCase = myContextMap[GetCurrentStudyID()]._mesCas[CaseName]; + ASSERT(!CORBA::is_nil(myCase)); + SALOMEDS::SObject_var aCaseSO = SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myCase))); + ASSERT(!CORBA::is_nil(aCaseSO)); + + SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO); + aStudyBuilder->Addreference(aSubSO, aCaseSO); aStudyBuilder->CommitCommand(); @@ -3271,10 +3753,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 { @@ -3322,7 +3801,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 ); + MESSAGE ("DeleteResultInSmesh pour le maillage " << MeshName << " dans le fichier " << NomFich ); if (CORBA::is_nil(myCurrentStudy)) { SALOME::ExceptionStruct es; @@ -3364,30 +3843,45 @@ void HOMARD_Gen_i::DeleteResultInSmesh(std::string NomFich, std::string MeshName } } } - + return ; } //============================================================================= -void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* NomFich, const char* Commentaire) +void HOMARD_Gen_i::PublishMeshIterInSmesh(const char* NomIter) { -// MESSAGE (" PublishFileUnderIteration pour l'iteration " << NomIter << " du fichier " << NomFich << " avec le commentaire " << Commentaire ); - if (CORBA::is_nil(myCurrentStudy)) - { - SALOME::ExceptionStruct es; - es.type = SALOME::BAD_PARAM; - es.text = "Invalid study context"; - throw SALOME::SALOME_Exception(es); - return ; - }; - + MESSAGE( "PublishMeshIterInSmesh " << NomIter); HOMARD::HOMARD_Iteration_var myIteration = myContextMap[GetCurrentStudyID()]._mesIterations[NomIter]; + + SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); if (CORBA::is_nil(myIteration)) { SALOME::ExceptionStruct es; es.type = SALOME::BAD_PARAM; - es.text = "Invalid iteration"; + 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]; + SALOMEDS::SObject_var aIterSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myIteration))); if (CORBA::is_nil(myIteration)) { @@ -3404,7 +3898,7 @@ void HOMARD_Gen_i::PublishFileUnderIteration(const char* NomIter, const char* No SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aIterSO); // Pour les fichiers med, on affiche une icone de maillage -// Pour les fichiers qui sont texte, on affiche une icone de fichier texte 'texte' +// Pour les fichiers qui sont du texte, on affiche une icone de fichier texte 'texte' // Le reperage se fait par la 1ere lettre du commentaire : I pour Iteration n std::string icone ; std::string ior = " " ; @@ -3418,33 +3912,154 @@ 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]; + + SALOMEDS::SObject_var aYACSSO=SALOMEDS::SObject::_narrow(myCurrentStudy->FindObjectIOR(_orb->object_to_string(myYACS))); + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Invalid YACSStudy Object"; + throw SALOME::SALOME_Exception(es); + return ; + }; + + SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder(); + + aStudyBuilder->NewCommand(); + + SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aYACSSO); + std::string icone = "texte_2.png" ; + std::string ior = " " ; + PublishInStudyAttr(aStudyBuilder, aSubSO, NomFich, Commentaire, icone.c_str(), ior.c_str() ) ; + + aStudyBuilder->CommitCommand(); +} +// +//============================================================================= //============================================================================= // YACS //============================================================================= //============================================================================= //============================================================================= -// Ecriture d'un schema YACS +// 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 //============================================================================= -CORBA::Long HOMARD_Gen_i::WriteYACSSchema (const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile) +HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile) { - MESSAGE ( "WriteYACSSchema : Schema YACS pour le cas " << nomCas); - MESSAGE ( "ScriptFile : " << ScriptFile); - MESSAGE ( "DirName : " << DirName); - MESSAGE ( "MeshFile : " << MeshFile); + INFOS ( "CreateYACSSchema : Schema YACS " << nomYACS ); + INFOS ( ". nomCas : " << nomCas); + INFOS ( ". ScriptFile : " << ScriptFile); + INFOS ( ". DirName : " << DirName); + INFOS ( ". MeshFile : " << MeshFile); + // A. Controle du nom : + if ((myContextMap[GetCurrentStudyID()]._mesYACSs).find(nomYACS) != (myContextMap[GetCurrentStudyID()]._mesYACSs).end()) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "This schema YACS has already been defined."; + throw SALOME::SALOME_Exception(es); + return 0; + } + + // B. Creation de l'objet + HOMARD::HOMARD_YACS_var myYACS = newYACS(); + if (CORBA::is_nil(myYACS)) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + es.text = "Unable to create the schema YACS"; + throw SALOME::SALOME_Exception(es); + return 0; + }; + myYACS->SetName( nomYACS ) ; + + // C. Enregistrement + myContextMap[GetCurrentStudyID()]._mesYACSs[nomYACS] = myYACS; + + SALOMEDS::SObject_var aSO; + SALOMEDS::SObject_var aResultSO=PublishInStudy(myCurrentStudy, aSO, myYACS, nomYACS); + + PublishCaseUnderYACS(nomYACS, nomCas); + + // D. Caracterisation + // D.1. Options + myYACS->SetDirName( DirName ) ; + myYACS->SetMeshFile( MeshFile ) ; + myYACS->SetScriptFile( ScriptFile ) ; + myYACS->SetCaseName( nomCas ) ; + // D.2. Defaut + int defaut_i ; + // D.2.1. Type constant + myYACS->SetType( 1 ) ; + // 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 repertoire du cas + HOMARD::HOMARD_Cas_ptr caseyacs = GetCase(nomCas) ; + std::string dirnamecase = caseyacs->GetDirName() ; + std::string XMLFile ; + XMLFile = dirnamecase + "/schema.xml" ; + myYACS->SetXMLFile( XMLFile.c_str() ) ; + + return HOMARD::HOMARD_YACS::_duplicate(myYACS); +} +//============================================================================= +// Ecriture d'un schema YACS +//============================================================================= +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]; + ASSERT(!CORBA::is_nil(myYACS)); +// Le nom du fichier du schema + std::string XMLFile ; + XMLFile = myYACS->GetXMLFile() ; + + int codret = YACSWriteOnFile(nomYACS, XMLFile.c_str()) ; + + return codret ; +} +//============================================================================= +// Ecriture d'un schema YACS sur un fichier donne +//============================================================================= +CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFile) +{ + INFOS ( "YACSWriteOnFile : Ecriture de " << nomYACS << " sur " << XMLFile ); + + // A. Prealable int codret = 0; - // A. Le cas - // A.1. L'objet cas + // B. L'objet YACS + // B.1. L'objet + HOMARD::HOMARD_YACS_var myYACS = myContextMap[GetCurrentStudyID()]._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]; ASSERT(!CORBA::is_nil(myCase)); - // A.2. Le repertoire du cas - std::string nomDirCase = myCase->GetDirName(); - MESSAGE ( ". nomDirCase = " << nomDirCase ); - // A.3. Les instructions python associees au cas + // C.2. Les instructions python associees au cas CORBA::String_var dumpCorbaCase = myCase->GetDumpPython(); std::string pythonCas = dumpCorbaCase.in(); MESSAGE ("pythonCas :\n"<GetIter0() ; std::string Iter0Name = myCase->GetIter0Name() ; MESSAGE (". Iter0Name = " << Iter0Name); + std::string MeshName = Iter0->GetMeshName(); + MESSAGE (". MeshName = " << MeshName); // D.2. L'iteration numero 1 HOMARD::listeIterFilles* maListe = Iter0->GetIterations(); int numberOfIter = maListe->length(); @@ -3470,97 +4087,103 @@ CORBA::Long HOMARD_Gen_i::WriteYACSSchema (const char* nomCas, const char* Scrip std::string Iter1Name = std::string((*maListe)[0]); MESSAGE ("... Iter1Name = " << Iter1Name); HOMARD::HOMARD_Iteration_var Iter1 = GetIteration(Iter1Name.c_str()) ; - MESSAGE (". Iter1 = " << Iter1); + // D.3. Les instructions python associees a l'iteration + CORBA::String_var dumpCorbaIter = Iter1->GetDumpPython(); + std::string pythonIter = dumpCorbaIter.in(); + MESSAGE ("pythonIter :\n"<GetHypoName(); MESSAGE (". nomHypo = " << nomHypo); HOMARD::HOMARD_Hypothesis_var myHypo = myContextMap[GetCurrentStudyID()]._mesHypotheses[nomHypo]; ASSERT(!CORBA::is_nil(myHypo)); - // C.2. Les caracteristiques de l'adaptation + // E.2. Les caracteristiques de l'adaptation HOMARD::listeTypes* ListTypes = myHypo->GetAdapRefinUnRef(); ASSERT(ListTypes->length() == 3); int TypeAdap = (*ListTypes)[0]; // int TypeRaff = (*ListTypes)[1]; // int TypeDera = (*ListTypes)[2]; - // C.3. Les instructions python associees a l'hypothese + // E.3. Les instructions python associees a l'hypothese CORBA::String_var dumpCorbaHypo = myHypo->GetDumpPython(); std::string pythonHypo = dumpCorbaHypo.in(); MESSAGE ("pythonHypo :\n"<Texte_DataInit_MeshFile(MeshFile); - } - // F.1.3. Le script de lancement + { myDriver->Texte_DataInit_MeshFile(MeshFile); } + // G.1.3. Le script de lancement else if ( mot_cle == "Alternance_Calcul_HOMARD_Calcul" ) - { - myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); - } - // F.1.4. Les options du cas - else if ( mot_cle == "HOMARD_Init_au_debut_Case_Options" ) - { - myDriver->Texte_HOMARD_Init_au_debut_Case_Options(pythonCas); - } - // F.1.5. Execution de HOMARD : le repertoire du cas + { myDriver->Texte_Alternance_Calcul_HOMARD_Calcul(ScriptFile); } + // G.1.4. Les options du cas + else if ( mot_cle == "Iter_1_Case_Options" ) + { myDriver->Texte_Iter_1_Case_Options(pythonCas); } + // G.1.5. Execution de HOMARD : le repertoire 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_DirName(); + 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" ; + myDriver->TexteParametre( node, "MeshName", "string", MeshName ) ; } - // F.1.6. Execution de HOMARD : les options de l'hypothese + // G.1.7. Execution de HOMARD : les options de l'hypothese else if ( mot_cle == "HOMARD_Exec_Hypo_Options" ) + { myDriver->Texte_python_1( pythonHypo, 3, "Hypo" ) ; } + // 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. a. Creation eventuelles des zones et frontieres + // b. Enchainement + else if ( mot_cle == "Iter_1" ) { - myDriver->Texte_python( pythonHypo, 3, "Hypo" ) ; - } - // F.1.7. Zones et frontieres : les creations - else if ( mot_cle == "HOMARD_Init_au_debut" ) - { - std::string texte_control = myDriver->Texte_HOMARD_Init_au_debut_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); } - // F.1.8. Zones : 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" ) - { - if ( TypeAdap == 0 ) - { myDriver->TexteAddParametres(); } - } - // F.1.n. La ligne est recopiee telle quelle - else - { - myDriver->TexteAdd(ligne); - } + { myDriver->TexteAddParametres(); } + // G.1.n. La ligne est recopiee telle quelle + else { myDriver->TexteAdd(ligne); } } - // F.2. Ecriture du texte dans le fichier + // G.2. Ecriture du texte dans le fichier if ( codret == 0 ) { myDriver->CreeFichier(); } } @@ -3575,6 +4198,11 @@ CORBA::Long HOMARD_Gen_i::WriteYACSSchema (const char* nomCas, const char* Scrip delete myDriver; + // H. Publication du fichier dans l'arbre + + std::string Commentaire = "xml" ; + PublishFileUnderYACS(nomYACS, XMLFile, Commentaire.c_str()); + return codret ; } //============================================================================= @@ -3615,10 +4243,10 @@ std::string HOMARD_Gen_i::YACSDriverTexteZone(HOMARD::HOMARD_Hypothesis_var myHy int ZoneType = myZone->GetType(); MESSAGE ( "... ZoneType = " << ZoneType); std::string texte_control_0 ; - texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Zone(ZoneType, pythonStructure, methode, ZoneName ); + texte_control_0 = myDriver->Texte_Iter_1_Zone(ZoneType, pythonStructure, methode, ZoneName ); texte_control += texte_control_0 ; // 5. Decalage - iaux += 1 ; + iaux ++ ; } return texte_control ; @@ -3673,8 +4301,17 @@ 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* MeshFile ; + if (BoundaryType == 0) + { + MeshName = myBoundary->GetMeshName() ; + MESSAGE ( ". MeshName = " << MeshName ); + MeshFile = myBoundary->GetMeshFile() ; + MESSAGE ( ". MeshFile = " << MeshFile ); + } std::string texte_control_0 ; - texte_control_0 = myDriver->Texte_HOMARD_Init_au_debut_Boundary(BoundaryType, pythonStructure, methode, BoundaryName ); + texte_control_0 = myDriver->Texte_Iter_1_Boundary(BoundaryType, pythonStructure, methode, BoundaryName, MeshName, MeshFile ); texte_control += texte_control_0 ; // 5. Memorisation du traitement ListeBoundaryTraitees.push_back( BoundaryName ); @@ -3693,7 +4330,7 @@ SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, CORBA::Boolean isMultiFile) { - MESSAGE (" Save for theURL = "<< theURL); + MESSAGE ("Save for theURL = "<< theURL); SALOMEDS::TMPFile_var aStreamFile; // get temporary directory name @@ -3813,7 +4450,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, const char* theURL, CORBA::Boolean isMultiFile) { - MESSAGE (" Load pour theURL = "<< theURL); + MESSAGE ("Load pour theURL = "<< theURL); SALOMEDS::Study_var aStudy = theComponent->GetStudy(); // set current study @@ -3852,14 +4489,26 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, while (f) { std::getline(f, line); + std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary); std::string caseSignature = HOMARD::GetSignature(HOMARD::Case); - std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone); - std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration); std::string hypoSignature = HOMARD::GetSignature(HOMARD::Hypothesis); - std::string bounSignature = HOMARD::GetSignature(HOMARD::Boundary); - if (line.substr(0, caseSignature.size()) == caseSignature) { + std::string iterSignature = HOMARD::GetSignature(HOMARD::Iteration); + std::string zoneSignature = HOMARD::GetSignature(HOMARD::Zone); + std::string yacsSignature = HOMARD::GetSignature(HOMARD::YACS); + if (line.substr(0, bounSignature.size()) == bounSignature) { + // re-create boundary + MESSAGE ("Recreation de la frontiere" ); + HOMARD::HOMARD_Boundary_var aBoundary = newBoundary(); + PortableServer::ServantBase_var aServant = GetServant(aBoundary); + HOMARD_Boundary_i* aBoundaryServant = dynamic_cast(aServant.in()); + if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) { + context._mesBoundarys[aBoundary->GetName()] = aBoundary; + context._idmap[id] = dynamic_cast(aBoundaryServant); + } + } + else if (line.substr(0, caseSignature.size()) == caseSignature) { // re-create case - MESSAGE (" Recreation du cas" ); + MESSAGE ("Recreation du cas" ); HOMARD::HOMARD_Cas_var aCase = newCase(); PortableServer::ServantBase_var aServant = GetServant(aCase); HOMARD_Cas_i* aCaseServant = dynamic_cast(aServant.in()); @@ -3868,20 +4517,20 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, context._idmap[id] = dynamic_cast(aCaseServant); } } - else if (line.substr(0, zoneSignature.size()) == zoneSignature) { - MESSAGE (" Recreation de la zone" ); - // re-create zone - HOMARD::HOMARD_Zone_var aZone = newZone(); - PortableServer::ServantBase_var aServant = GetServant(aZone); - HOMARD_Zone_i* aZoneServant = dynamic_cast(aServant.in()); - if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) { - context._mesZones[aZone->GetName()] = aZone; - context._idmap[id] = dynamic_cast(aZoneServant); + else if (line.substr(0, hypoSignature.size()) == hypoSignature) { + // re-create hypothesis + MESSAGE ("Recreation de l hypothese" ); + HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis(); + PortableServer::ServantBase_var aServant = GetServant(aHypo); + HOMARD_Hypothesis_i* aHypoServant = dynamic_cast(aServant.in()); + if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) { + context._mesHypotheses[aHypo->GetName()] = aHypo; + context._idmap[id] = dynamic_cast(aHypoServant); } } 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()); @@ -3890,26 +4539,26 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent, context._idmap[id] = dynamic_cast(aIterServant); } } - else if (line.substr(0, hypoSignature.size()) == hypoSignature) { - // re-create hypothesis - MESSAGE (" Recreation de l hypothese" ); - HOMARD::HOMARD_Hypothesis_var aHypo = newHypothesis(); - PortableServer::ServantBase_var aServant = GetServant(aHypo); - HOMARD_Hypothesis_i* aHypoServant = dynamic_cast(aServant.in()); - if (aHypoServant && aHypoServant->Restore(line.substr(hypoSignature.size()))) { - context._mesHypotheses[aHypo->GetName()] = aHypo; - context._idmap[id] = dynamic_cast(aHypoServant); + else if (line.substr(0, zoneSignature.size()) == zoneSignature) { + MESSAGE ("Recreation de la zone" ); + // re-create zone + HOMARD::HOMARD_Zone_var aZone = newZone(); + PortableServer::ServantBase_var aServant = GetServant(aZone); + HOMARD_Zone_i* aZoneServant = dynamic_cast(aServant.in()); + if (aZoneServant && aZoneServant->Restore(line.substr(zoneSignature.size()))) { + context._mesZones[aZone->GetName()] = aZone; + context._idmap[id] = dynamic_cast(aZoneServant); } } - else if (line.substr(0, bounSignature.size()) == bounSignature) { - // re-create boundary - MESSAGE (" Recreation de la frontiere" ); - HOMARD::HOMARD_Boundary_var aBoundary = newBoundary(); - PortableServer::ServantBase_var aServant = GetServant(aBoundary); - HOMARD_Boundary_i* aBoundaryServant = dynamic_cast(aServant.in()); - if (aBoundaryServant && aBoundaryServant->Restore(line.substr(bounSignature.size()))) { - context._mesBoundarys[aBoundary->GetName()] = aBoundary; - context._idmap[id] = dynamic_cast(aBoundaryServant); + else if (line.substr(0, zoneSignature.size()) == yacsSignature) { + MESSAGE ("Recreation du schema YACS" ); + // re-create YACS + HOMARD::HOMARD_YACS_var aYACS = newYACS(); + PortableServer::ServantBase_var aServant = GetServant(aYACS); + HOMARD_YACS_i* aYACSServant = dynamic_cast(aServant.in()); + if (aYACSServant && aYACSServant->Restore(line.substr(yacsSignature.size()))) { + context._mesYACSs[aYACS->GetName()] = aYACS; + context._idmap[id] = dynamic_cast(aYACSServant); } } id++; @@ -4099,7 +4748,7 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, std::string aScript = "\"\"\"\n"; aScript += "Python script for HOMARD\n"; - aScript += "Copyright EDF-R&D 2013\n"; + aScript += "Copyright EDF-R&D 1996, 2011, 2014\n"; aScript += "\"\"\"\n"; aScript += "__revision__ = \"V1.2\"\n"; aScript += "import HOMARD\n"; @@ -4143,8 +4792,8 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, for ( it_zone = myContextMap[GetCurrentStudyID()]._mesZones.begin(); it_zone != myContextMap[GetCurrentStudyID()]._mesZones.end(); ++it_zone) { - HOMARD::HOMARD_Zone_var maZone = (*it_zone).second; - CORBA::String_var dumpCorbaZone = maZone->GetDumpPython(); + HOMARD::HOMARD_Zone_var myZone = (*it_zone).second; + CORBA::String_var dumpCorbaZone = myZone->GetDumpPython(); std::string dumpZone = dumpCorbaZone.in(); MESSAGE (dumpZone<<"\n"); aScript += dumpZone; @@ -4220,6 +4869,24 @@ Engines::TMPFile* HOMARD_Gen_i::DumpPython(CORBA::Object_ptr theStudy, aScript += dumpIter; } + + if (myContextMap[GetCurrentStudyID()]._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) + { + HOMARD::HOMARD_YACS_var myYACS = (*it_yacs).second; + CORBA::String_var dumpCorbaYACS = myYACS->GetDumpPython(); + std::string dumpYACS = dumpCorbaYACS.in(); + MESSAGE (dumpYACS<<"\n"); + aScript += dumpYACS; + } + MESSAGE (". Ecritures finales"); if( isMultiFile ) aScript += "\n\tpass"; @@ -4260,15 +4927,20 @@ void HOMARD_Gen_i::IsValidStudy( ) } //============================================================================= -CORBA::Boolean HOMARD_Gen_i::VerifieDir(const char* nomDir) +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++) { - if (std::string(nomDir) == std::string(it->second->GetDirName())) return false; + if (std::string(nomDir) == std::string(it->second->GetDirName())) + { + casename = std::string(it->second->GetName()) ; + break ; + } } - return true; + return CORBA::string_dup( casename.c_str() ); } /*//============================================================================= void SALOMEException( std::string message ) @@ -4289,32 +4961,245 @@ char* HOMARD_Gen_i::getVersion() #endif } //=============================================================================== -// Recuperation de la chaine de caracteres par rapport 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 ); + _LangueShort = LanguageShort ; + if ( _LangueShort == "fr" ) { _Langue = "Francais" ; } + else { _Langue = "English" ; } + return ; +} +char* HOMARD_Gen_i::GetLanguageShort() +{ +// MESSAGE ("GetLanguageShort"); + return CORBA::string_dup( _LangueShort.c_str() ); +} +//=============================================================================== +// Options de publications +//=============================================================================== +void HOMARD_Gen_i::SetPublisMesh(CORBA::Long PublisMeshIN, CORBA::Long PublisMeshOUT) +{ + _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 ; +} //============================================================================= extern "C" { + HOMARDENGINE_EXPORT PortableServer::ObjectId* HOMARDEngine_factory(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId* contId,