Forward medcoupling exception thrown in case of problem of conversion

This commit is contained in:
Anthony Geay 2021-02-17 22:22:22 +01:00
parent 4092d89107
commit ded5e634c9
5 changed files with 18 additions and 30 deletions

View File

@ -122,8 +122,7 @@ module SMESH{
void setSizeMapType(in string f);
boolean setAll();
string getCommandToRun() ;
//long compute(out string errStr);
long compute();
void compute() raises(SALOME::SALOME_Exception);
string getErrMsg();
string getFileName() ;
string getExeName();

View File

@ -1244,9 +1244,7 @@ void MgAdapt::checkTimeStepRank(std::string fileIn)
{
bool ret = false ;
MEDCoupling::MCAuto<MEDCoupling::MEDFileData> mfd = MEDCoupling::MEDFileData::New(fileIn);
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>( mfd->getFields()->getFieldWithName(fieldName) );
// std::cout << "--- timeStep " << timeStep << std::endl;
// std::cout << "--- rank " << rank << std::endl;
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( mfd->getFields()->getFieldWithName(fieldName) );
std::vector<double> timevalue;
std::vector< std::pair<int,int> > timesteprank = fts->getTimeSteps(timevalue);
std::size_t jaux(timesteprank.size());
@ -1299,7 +1297,7 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s
{
checkFieldName(medFileIn) ;
checkTimeStepRank(medFileIn) ;
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>( mfd->getFields()->getFieldWithName(fieldName) );
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( mfd->getFields()->getFieldWithName(fieldName) );
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts->getTimeStep(timeStep, rank);
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
tmFts->pushBackTimeStep(f);
@ -1438,8 +1436,8 @@ void MgAdapt::buildBackGroundMeshAndSolFiles(const std::vector<std::string>& fie
{
MEDCoupling::MCAuto<MEDCoupling::MEDFileData> tmpMfd = MEDCoupling::MEDFileData::New(sizeMapFile);
MEDCoupling::MEDFileFields* tmpFields = tmpMfd->getFields();
MEDCoupling::MEDFileAnyTypeFieldMultiTS* fts = tmpFields->getFieldWithName(fieldName);
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> fts1 = dynamic_cast<MEDCoupling::MEDFileFieldMultiTS *>(fts);
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeFieldMultiTS> fts( tmpFields->getFieldWithName(fieldName) );
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> fts1 = MEDCoupling::DynamicCastSafe<MEDCoupling::MEDFileAnyTypeFieldMultiTS,MEDCoupling::MEDFileFieldMultiTS>(fts);
MEDCoupling::MCAuto<MEDCoupling::MEDFileAnyTypeField1TS> f = fts1->getTimeStep(timeStep, rank);
MEDCoupling::MCAuto<MEDCoupling::MEDFileFieldMultiTS> tmFts = MEDCoupling::MEDFileFieldMultiTS::New();
tmFts->pushBackTimeStep(f);

View File

@ -385,12 +385,12 @@ bool SMESHGUI_MG_ADAPTDRIVER::PushOnApply()
bool SMESHGUI_MG_ADAPTDRIVER::execute()
{
int err;
//~std::string errStr;
int err = 1;
char* errStr;
try
{
err = getModel()->compute();
getModel()->compute();
err = 0;
errStr = getModel()->getErrMsg();
std::string msg = err == 0 ? " ok" : std::string("Not ok \n")+CORBA::string_dup(errStr) ;
}
@ -398,7 +398,7 @@ bool SMESHGUI_MG_ADAPTDRIVER::execute()
{
std::cerr<<e.what();
}
return err == 0? true: false;
return err == 0;
}
//=================================================================================

View File

@ -372,34 +372,25 @@ char* MG_ADAPT_i::getCommandToRun()
return CORBA::string_dup(myMgAdapt->getCommandToRun().c_str());
}
//~CORBA::Long MG_ADAPT_i::compute(::CORBA::String_out errStr)
//~{
//~std::string err("");
//~CORBA::Long ret = myMgAdapt->compute(err);
//~errStr = err.c_str();
//~return ret;
//~}
CORBA::Long MG_ADAPT_i::compute()
void MG_ADAPT_i::compute()
{
errStr = "";
CORBA::Long ret;
try
{
ret = myMgAdapt->compute(errStr);
myMgAdapt->compute(errStr);
}
catch (const std::exception& e)
{
std::cerr<<e.what();
ret = -1;
std::ostringstream oss; oss << "Exception thrown on MG_ADAPT_i::compute invocation with error message \"" << errStr
<< "\" with exception message \"" << e.what() << "\"";
THROW_SALOME_CORBA_EXCEPTION(oss.str().c_str(),SALOME::INTERNAL_ERROR);
}
if(ret!=-1 && myMgAdapt->getPublish())
if(myMgAdapt->getPublish())
{
SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
SMESH::DriverMED_ReadStatus theStatus;
smeshGen_i->CreateMeshesFromMED(myMgAdapt->getMedFileOut().c_str(), theStatus);
}
//~errStr = err.c_str();
return ret;
}
char* MG_ADAPT_i::getErrMsg()
{
@ -510,7 +501,8 @@ CORBA::Long MG_ADAPT_OBJECT_i::Compute(bool publish)
return -1;
}
hypothesis->setPublish(publish);
return hypothesis->compute();
hypothesis->compute();
return 0;
}
bool MG_ADAPT_OBJECT_i::checkMeshFileIn()

View File

@ -109,8 +109,7 @@ public:
bool setAll();
char* getCommandToRun() ;
//~CORBA::Long compute(::CORBA::String_out errStr);
CORBA::Long compute();
void compute();
char* getFileName();
char* getExeName();
void copyMgAdaptHypothesisData( const SMESH::MgAdaptHypothesisData& data ) ;