#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()
This commit is contained in:
eap 2019-10-02 17:33:03 +03:00
parent 831c6999e8
commit e64a06483c
3 changed files with 12 additions and 5 deletions

View File

@ -253,7 +253,11 @@ Driver_Mesh::Status DriverMED_W_Field::Perform()
if ( !myMesh ) if ( !myMesh )
return addMessage("Supporting mesh not set", /*isFatal=*/true ); 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; MED::PMeshInfo meshInfo;
if ( myMeshId > 0 ) if ( myMeshId > 0 )
{ {
@ -276,7 +280,7 @@ Driver_Mesh::Status DriverMED_W_Field::Perform()
( !myMeshName.empty() && meshInfo->GetName() != myMeshName )) ( !myMeshName.empty() && meshInfo->GetName() != myMeshName ))
{ {
myMeshId = -1; 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 // create a field

View File

@ -57,7 +57,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_Field: public Driver_SMESHDS_Mesh
void AddValue( int val ); 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(); SMDS_ElemIteratorPtr GetOrderedElems();

View File

@ -130,6 +130,9 @@ namespace MED
{ {
int mvok[] = MED_VERSIONS_APPEND_COMPATIBLE; int mvok[] = MED_VERSIONS_APPEND_COMPATIBLE;
std::vector<int> MEDVersionsOK(mvok, mvok + sizeof(mvok)/sizeof(int)); std::vector<int> 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; return MEDVersionsOK;
} }
@ -142,7 +145,7 @@ namespace MED
bool CheckCompatibility(const std::string& fileName, bool isForAppend) bool CheckCompatibility(const std::string& fileName, bool isForAppend)
{ {
bool ok = false; bool ok = false;
int medVersionsOK[] = MED_VERSIONS_APPEND_COMPATIBLE; std::vector<int> medVersionsOK = GetMEDVersionsAppendCompatible();
// check that file is accessible // check that file is accessible
if ( exists(fileName) ) { if ( exists(fileName) ) {
// check HDF5 && MED compatibility // check HDF5 && MED compatibility
@ -161,7 +164,7 @@ namespace MED
ok = true; ok = true;
else { else {
int medVersion = 10*major + minor; 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) { if (medVersionsOK[ii] == medVersion) {
ok =true; ok =true;
break; break;