Salome HOME
#17775 [CEA] SALOME 9.4.0a1: export a mesh with fields using Python API- SMESH::Expor...
authoreap <eap@opencascade.com>
Wed, 2 Oct 2019 14:33:03 +0000 (17:33 +0300)
committereap <eap@opencascade.com>
Wed, 2 Oct 2019 14:33:03 +0000 (17:33 +0300)
 Add the version of MED_FILE with which SALOME is built into a list
 returned by MED::GetMEDVersionsAppendCompatible()

src/DriverMED/DriverMED_W_Field.cxx
src/DriverMED/DriverMED_W_Field.h
src/MEDWrapper/MED_Factory.cxx

index a631d88f6783845fcf3068985a00566bd7428a10..618fa75d0a416810c2604046c7e0393fcb9164c3 100644 (file)
@@ -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
index 51cbb32c20657cf36aec975cf20cd3cc9e211a9f..878bbf29426d3b38e854c161223f2eb96347941c 100644 (file)
@@ -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();
 
index fa49039f722597b10396f11823cc04262801fcf0..5a34a963f38e9120618705cf27cf635c8578d810 100644 (file)
@@ -130,6 +130,9 @@ namespace MED
   {
     int mvok[] = MED_VERSIONS_APPEND_COMPATIBLE;
     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;
   }
 
@@ -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<int> 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;