From: GĂ©rald NICOLAS Date: Tue, 9 Feb 2021 16:05:33 +0000 (+0100) Subject: Message d'erreur en l'absence de fichier X-Git-Tag: V9_7_0a1~18^2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4c3cd911ff21491cc56420b5aab654e8c745e0e6;p=modules%2Fsmesh.git Message d'erreur en l'absence de fichier --- diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index 640305541..9a44b93d7 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -30,6 +30,9 @@ #include "MEDFileField.hxx" #include "MEDCouplingFieldDouble.hxx" +#include +#include + #include #include #include @@ -219,9 +222,25 @@ MgAdaptHypothesisData* MgAdapt::getData() const } void MgAdapt::setMedFileIn(std::string fileName) { - medFileIn = fileName; - if (medFileOut == "") // default MED file Out - medFileOut = remove_extension( fileName )+ ".adapt.med"; + if ( isFileExist(fileName) ) + { + medFileIn = fileName; + + if (medFileOut == "") // default MED file Out + medFileOut = remove_extension( fileName )+ ".adapt.med"; + } + else + { + std::cout << "\nThe file " + fileName + " does not exist.\n" << std::endl; +// SALOME::ExceptionStruct es; +// es.type = SALOME::BAD_PARAM; +// std::string text = "\nThe file " + fileName + " does not exist.\n" ; +// std::cout << text << std::endl; +// es.text = "The mesh file does not exist."; +// es.text = CORBA::string_dup(text.c_str()); +// throw SALOME::SALOME_Exception(es); + throw SALOME_Exception(("The file " + fileName + " does not exist." ).c_str() ); + } } std::string MgAdapt::getMedFileIn() @@ -233,7 +252,6 @@ void MgAdapt::setMedFileOut(std::string fileOut) { medFileOut = fileOut; } - std::string MgAdapt::getMedFileOut() { return medFileOut; @@ -363,7 +381,15 @@ bool MgAdapt::getRemoveOnSuccess() } void MgAdapt::setSizeMapFile(std::string mapFile) { - sizeMapFile = mapFile; + if ( mapFile == "" || isFileExist(mapFile) ) + { + sizeMapFile = mapFile; + } + else + { + std::cout << "\nThe file " + mapFile + " does not exist.\n" << std::endl; + throw SALOME_Exception(("The file " + mapFile + " does not exist." ).c_str() ); + } } std::string MgAdapt::getSizeMapFile() { @@ -428,7 +454,6 @@ bool MgAdapt::getPrintLogInFile() return printLogInFile; } - bool MgAdapt::setAll() { @@ -1315,8 +1340,13 @@ med_idt MgAdapt::openMedFile(const std::string aFile) med_idt medIdt = MEDfileOpen(aFile.c_str(),MED_ACC_RDONLY); if (medIdt <0) { - //~addMessage( ToComment(" error: Can't open ") << aFile, /*fatal=*/true ); - ; + SALOME::ExceptionStruct es; + es.type = SALOME::BAD_PARAM; + std::string text = "The med file " + aFile + " cannot be opened." ; +// es.text = "The mesh file does not exist."; + es.text = CORBA::string_dup(text.c_str()); + throw SALOME::SALOME_Exception(es); + return 0; } return medIdt; } diff --git a/src/SMESH_I/MG_ADAPT_i.cxx b/src/SMESH_I/MG_ADAPT_i.cxx index ec2c9d30d..fbe27fd47 100644 --- a/src/SMESH_I/MG_ADAPT_i.cxx +++ b/src/SMESH_I/MG_ADAPT_i.cxx @@ -18,14 +18,12 @@ // #include "MG_ADAPT_i.hxx" -//~#include "ADAPT_Gen_i.hxx" + #include "string.h" #include "SMESH_Gen_i.hxx" #include #include #include CORBA_CLIENT_HEADER(SALOMEDS) -//~#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) -//~#include CORBA_CLIENT_HEADER(SMESH_Gen) //=============================================================================