From: Christophe Bourcier Date: Wed, 22 Sep 2021 12:56:57 +0000 (+0200) Subject: MGAdapt: allow using float field. Fixes test 13. X-Git-Tag: V9_8_0a1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fcbr%2Fmgadapt_float_field;p=modules%2Fsmesh.git MGAdapt: allow using float field. Fixes test 13. --- diff --git a/doc/salome/examples/MGAdaptTests_without_session.py b/doc/salome/examples/MGAdaptTests_without_session.py index aa3f087a2..2f0621d70 100644 --- a/doc/salome/examples/MGAdaptTests_without_session.py +++ b/doc/salome/examples/MGAdaptTests_without_session.py @@ -450,7 +450,7 @@ if __name__ == "__main__" : L_OPTIONS.append("05") L_OPTIONS.append("06") L_OPTIONS.append("08") - #L_OPTIONS.append("13") + L_OPTIONS.append("13") # 2. Lancement de la classe diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index 8f2a36a44..6253f4975 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -1381,8 +1381,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);