From: eap Date: Wed, 2 Oct 2019 14:33:03 +0000 (+0300) Subject: #17775 [CEA] SALOME 9.4.0a1: export a mesh with fields using Python API- SMESH::Expor... X-Git-Tag: V9_4_0a2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e64a06483ccf8b1ae29ea6b7407e94613021948b;p=modules%2Fsmesh.git #17775 [CEA] SALOME 9.4.0a1: export a mesh with fields using Python API- SMESH::ExportMED crash Add the version of MED_FILE with which SALOME is built into a list returned by MED::GetMEDVersionsAppendCompatible() --- diff --git a/src/DriverMED/DriverMED_W_Field.cxx b/src/DriverMED/DriverMED_W_Field.cxx index a631d88f6..618fa75d0 100644 --- a/src/DriverMED/DriverMED_W_Field.cxx +++ b/src/DriverMED/DriverMED_W_Field.cxx @@ -253,7 +253,11 @@ Driver_Mesh::Status DriverMED_W_Field::Perform() if ( !myMesh ) return addMessage("Supporting mesh not set", /*isFatal=*/true ); - MED::PWrapper medFile = MED::CrWrapperW( myFile ); + int version = -1, major, minor, release; + if ( MED::GetMEDVersion( myFile, major, minor, release )) + version = major * 10 + minor; + + MED::PWrapper medFile = MED::CrWrapperW( myFile, version ); MED::PMeshInfo meshInfo; if ( myMeshId > 0 ) { @@ -276,7 +280,7 @@ Driver_Mesh::Status DriverMED_W_Field::Perform() ( !myMeshName.empty() && meshInfo->GetName() != myMeshName )) { myMeshId = -1; - return addMessage("Specified mesh not found in the file", /*isFatal=*/true ); + return addMessage("DriverMED_W_Field: Specified mesh not found in the file", /*isFatal=*/true ); } // create a field diff --git a/src/DriverMED/DriverMED_W_Field.h b/src/DriverMED/DriverMED_W_Field.h index 51cbb32c2..878bbf294 100644 --- a/src/DriverMED/DriverMED_W_Field.h +++ b/src/DriverMED/DriverMED_W_Field.h @@ -57,7 +57,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_Field: public Driver_SMESHDS_Mesh void AddValue( int val ); /* - * Returns elements in the order they are written in MED file. Result can be NULL! + * Return elements in the order they are written in MED file. Result can be NULL! */ SMDS_ElemIteratorPtr GetOrderedElems(); diff --git a/src/MEDWrapper/MED_Factory.cxx b/src/MEDWrapper/MED_Factory.cxx index fa49039f7..5a34a963f 100644 --- a/src/MEDWrapper/MED_Factory.cxx +++ b/src/MEDWrapper/MED_Factory.cxx @@ -130,6 +130,9 @@ namespace MED { int mvok[] = MED_VERSIONS_APPEND_COMPATIBLE; std::vector MEDVersionsOK(mvok, mvok + sizeof(mvok)/sizeof(int)); + int curVersion = MED_MAJOR_NUM * 10 + MED_MINOR_NUM; + if ( MEDVersionsOK[0] != curVersion ) + MEDVersionsOK.insert( MEDVersionsOK.begin(), curVersion ); return MEDVersionsOK; } @@ -142,7 +145,7 @@ namespace MED bool CheckCompatibility(const std::string& fileName, bool isForAppend) { bool ok = false; - int medVersionsOK[] = MED_VERSIONS_APPEND_COMPATIBLE; + std::vector medVersionsOK = GetMEDVersionsAppendCompatible(); // check that file is accessible if ( exists(fileName) ) { // check HDF5 && MED compatibility @@ -161,7 +164,7 @@ namespace MED ok = true; else { int medVersion = 10*major + minor; - for (size_t ii=0; ii < sizeof(medVersionsOK)/sizeof(int); ii++) + for (size_t ii=0; ii < medVersionsOK.size(); ii++) if (medVersionsOK[ii] == medVersion) { ok =true; break;