X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHOMARD_I%2FHOMARD_Cas_i.cxx;h=91e7e5e6ba2165bdb1520878e71146c1f0d5b636;hb=e19f3c647ad20c3f1154abf85dd2f4d57e534239;hp=8e456ec36919fc497a87ba4a5e79c8ff896ea23f;hpb=77262fdb4bf42ef5a70a8918f6bb3c86b0f6f3b3;p=modules%2Fhomard.git diff --git a/src/HOMARD_I/HOMARD_Cas_i.cxx b/src/HOMARD_I/HOMARD_Cas_i.cxx index 8e456ec3..91e7e5e6 100755 --- a/src/HOMARD_I/HOMARD_Cas_i.cxx +++ b/src/HOMARD_I/HOMARD_Cas_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2012 CEA/DEN, EDF R&D +// Copyright (C) 2011-2013 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 @@ -33,6 +33,7 @@ #include "utilities.h" #include +#include //============================================================================= /*! @@ -85,12 +86,12 @@ char* HOMARD_Cas_i::GetName() return CORBA::string_dup( myHomardCas->GetName().c_str() ); } //============================================================================= -CORBA::Long HOMARD_Cas_i::Delete() +CORBA::Long HOMARD_Cas_i::Delete( CORBA::Long Option ) { ASSERT( myHomardCas ); char* CaseName = GetName() ; - MESSAGE ( "Delete : destruction du cas " << CaseName ); - return _gen_i->DeleteCase(CaseName) ; + MESSAGE ( "Delete : destruction du cas " << CaseName << ", Option = " << Option ); + return _gen_i->DeleteCase(CaseName, Option) ; } //============================================================================= char* HOMARD_Cas_i::GetDumpPython() @@ -116,7 +117,73 @@ bool HOMARD_Cas_i::Restore( const std::string& stream ) void HOMARD_Cas_i::SetDirName( const char* NomDir ) { ASSERT( myHomardCas ); - myHomardCas->SetDirName( NomDir ); + int codret ; + // A. recuperation du nom ; on ne fait rien si c'est le meme + char* oldrep = GetDirName() ; + MESSAGE ( "SetDirName : passage de oldrep = "<< oldrep << " a NomDir = "<SetDirName( NomDir ); + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text ; + if ( codret == 1 ) { text = "The directory for the case cannot be modified because some iterations are already defined." ; } + else { text = "The directory for the case cannot be reached." ; } + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // C. En cas de reprise, deplacement du point de depart + if ( GetState() != 0 ) + { + MESSAGE ( "etat : " << GetState() ) ; + // C.1. Nom local du repertoire de l'iteration de depart dans le repertoire actuel du cas + HOMARD::HOMARD_Iteration_ptr Iter = GetIter0() ; + char* DirNameIter = Iter->GetDirNameLoc() ; + MESSAGE ( "SetDirName : nom actuel pour le repertoire de l iteration, DirNameIter = "<< DirNameIter); + // C.2. Recherche d'un nom local pour l'iteration de depart dans le futur repertoire du cas + char* nomDirIter = _gen_i->CreateDirNameIter(NomDir, 0 ); + MESSAGE ( "SetDirName : nom futur pour le repertoire de l iteration, nomDirIter = "<< nomDirIter); + // C.3. Creation du futur repertoire local pour l'iteration de depart + std::string nomDirIterTotal ; + nomDirIterTotal = std::string(NomDir) + "/" + std::string(nomDirIter) ; + if (mkdir(nomDirIterTotal.c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0) + { + MESSAGE ( "nomDirIterTotal : " << nomDirIterTotal ) ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The directory for the starting iteration cannot be created." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // C.4. Deplacement du contenu du repertoire + std::string oldnomDirIterTotal ; + oldnomDirIterTotal = std::string(oldrep) + "/" + std::string(DirNameIter) ; + std::string commande = "mv " + std::string(oldnomDirIterTotal) + "/*" + " " + std::string(nomDirIterTotal) ; + codret = system(commande.c_str()) ; + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The starting point for the case cannot be moved into the new directory." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + commande = "rm -rf " + std::string(oldnomDirIterTotal) ; + codret = system(commande.c_str()) ; + if ( codret != 0 ) + { + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The starting point for the case cannot be deleted." ; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + } + // C.5. Memorisation du nom du repertoire de l'iteration + Iter->SetDirNameLoc(nomDirIter) ; + } + return ; } //============================================================================= char* HOMARD_Cas_i::GetDirName() @@ -125,10 +192,20 @@ char* HOMARD_Cas_i::GetDirName() return CORBA::string_dup( myHomardCas->GetDirName().c_str() ); } //============================================================================= -CORBA::Long HOMARD_Cas_i::GetNumber() +CORBA::Long HOMARD_Cas_i::GetState() +{ + ASSERT( myHomardCas ); +// Nom de l'iteration initiale + char* Iter0Name = GetIter0Name() ; + HOMARD::HOMARD_Iteration_ptr Iter = _gen_i->GetIteration(Iter0Name) ; + int state = Iter->GetNumber() ; + return state ; +} +//============================================================================= +CORBA::Long HOMARD_Cas_i::GetNumberofIter() { ASSERT( myHomardCas ); - return myHomardCas->GetNumber(); + return myHomardCas->GetNumberofIter(); } //============================================================================= void HOMARD_Cas_i::SetConfType( CORBA::Long ConfType ) @@ -153,7 +230,6 @@ void HOMARD_Cas_i::SetBoundingBox( const HOMARD::extrema& LesExtrema ) { VExtrema[i] = LesExtrema[i]; } - myHomardCas->SetBoundingBox( VExtrema ); } //============================================================================= @@ -185,7 +261,6 @@ void HOMARD_Cas_i::SetGroups( const HOMARD::ListGroupType& ListGroup ) { ListString.push_back(std::string(ListGroup[i])); } - myHomardCas->SetGroups( ListString ); } //============================================================================= @@ -259,6 +334,27 @@ CORBA::Long HOMARD_Cas_i::GetPyram() return myHomardCas->GetPyram(); } //============================================================================= +void HOMARD_Cas_i::MeshInfo(CORBA::Long Qual, CORBA::Long Diam, CORBA::Long Conn, CORBA::Long Tail, CORBA::Long Inte) +{ + MESSAGE ( "MeshInfo : information sur le maillage initial du cas" ); + ASSERT( myHomardCas ); +// +// Nom de l'iteration + char* IterName = GetIter0Name() ; + CORBA::Long etatMenage = -1 ; + CORBA::Long modeHOMARD = 7 ; + CORBA::Long Option1 = 1 ; + CORBA::Long Option2 = 1 ; + if ( Qual != 0 ) { modeHOMARD = modeHOMARD*5 ; } + if ( Diam != 0 ) { modeHOMARD = modeHOMARD*19 ; } + if ( Conn != 0 ) { modeHOMARD = modeHOMARD*11 ; } + if ( Tail != 0 ) { modeHOMARD = modeHOMARD*13 ; } + if ( Inte != 0 ) { modeHOMARD = modeHOMARD*3 ; } + CORBA::Long codret = _gen_i->Compute(IterName, etatMenage, modeHOMARD, Option1, Option2) ; + MESSAGE ( "MeshInfo : codret = " << codret ); + return ; +} +//============================================================================= //============================================================================= // Liens avec les autres structures //============================================================================= @@ -271,7 +367,7 @@ char* HOMARD_Cas_i::GetIter0Name() //============================================================================= HOMARD::HOMARD_Iteration_ptr HOMARD_Cas_i::GetIter0() { -// Nom de l'iteration parent +// Nom de l'iteration initiale char* Iter0Name = GetIter0Name() ; MESSAGE ( "GetIter0 : Iter0Name = " << Iter0Name ); return _gen_i->GetIteration(Iter0Name) ;