X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FMG_ADAPT.cxx;h=27a57c894cc24edb5544fa21a0d1b1b1807641dc;hb=c9deeb65356c923f6129f363982dd8da8d6e32a5;hp=8f2a36a44f25b9be1fbb7a83dd88ed959cf6ce5f;hpb=3d563f79648e74ba577341cee8b1a874fbd13c49;p=modules%2Fsmesh.git diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index 8f2a36a44..27a57c894 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -19,8 +19,11 @@ #include "MG_ADAPT.hxx" -#include "SMESH_File.hxx" -#include "SMESH_Comment.hxx" +#include +#include +#include +#include +#include #include #include @@ -320,7 +323,7 @@ MgAdaptHypothesisData* MgAdapt::getData() const } void MgAdapt::setMedFileIn(std::string fileName) { - if ( isFileExist(fileName) ) + if ( isFileExist( fileName )) { medFileIn = fileName; @@ -1006,7 +1009,7 @@ std::string MgAdapt::getCommandToRun() cmd += " --"; else cmd += " "; -// std::cout << "--- option: '" << option << ", value: '" << value <<"'"<< std::endl; + // std::cout << "--- option: '" << option << ", value: '" << value <<"'"<< std::endl; cmd += option + " " + value; } } @@ -1016,13 +1019,31 @@ std::string MgAdapt::getCommandToRun() { cmd+= " --verbose "+ ToComment(verbosityLevel); } - //~} -//~cmd+= " >" + // get license key + { + smIdType nbVertex, nbEdge, nbFace, nbVol; + DriverGMF_Read gmfReader; + gmfReader.SetFile( meshIn ); + gmfReader.GetMeshInfo( nbVertex, nbEdge, nbFace, nbVol ); + + std::string errorTxt; + std::string key = SMESHUtils_MGLicenseKeyGen::GetKey( meshIn, + FromSmIdType( nbVertex ), + FromSmIdType( nbEdge ), + FromSmIdType( nbFace ), + FromSmIdType( nbVol ), + errorTxt ); + if ( key.empty() ) + return ToComment( "Problem with library SalomeMeshGemsKeyGenerator: " + errorTxt ); + + cmd += " --key " + key; + } + #ifdef WIN32 - cmd += " < NUL"; + cmd += " < NUL"; #endif -// std::cout << "--- cmd :"<< std::endl; -// std::cout << cmd << std::endl; + // std::cout << "--- cmd :"<< std::endl; + // std::cout << cmd << std::endl; return cmd; } @@ -1074,7 +1095,9 @@ std::string MgAdapt::defaultWorkingDirectory() { aTmpDir = Tmp_dir; } - else { + + if ( ! isFileExist( aTmpDir )) + { #ifdef WIN32 aTmpDir = "C:\\"; #else @@ -1381,8 +1404,17 @@ void MgAdapt::convertMedFile(std::string& meshFormatMeshFileName, std::string& s checkTimeStepRank(medFileIn) ; MEDCoupling::MCAuto fts( mfd->getFields()->getFieldWithName(fieldName) ); MEDCoupling::MCAuto f = fts->getTimeStep(timeStep, rank); - MEDCoupling::MCAuto tmFts = MEDCoupling::MEDFileFieldMultiTS::New(); - tmFts->pushBackTimeStep(f); + MEDCoupling::MCAuto tmFts = MEDCoupling::DynamicCast(fts); + + // if not able to cast to double field, try float field + if (!tmFts) + { + MEDCoupling::MCAuto tmFtsFloat = MEDCoupling::DynamicCast(fts); + if (!tmFtsFloat) + THROW_SALOME_EXCEPTION("\nUnexpected field type.\n"); + // convert float field to double + tmFts = tmFtsFloat->convertToDouble(); + } fields->pushField(tmFts);