Salome HOME
reintroduction of choice of MED minor version when exporting MED files
authorPaul RASCLE <paul.rascle@edf.fr>
Fri, 13 Jul 2018 13:35:34 +0000 (15:35 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Fri, 13 Jul 2018 14:23:54 +0000 (16:23 +0200)
15 files changed:
idl/SMESH_Mesh.idl
src/DriverMED/CMakeLists.txt
src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx
src/DriverMED/DriverMED_W_SMESHDS_Mesh.h
src/MEDWrapper/MED_Factory.cxx
src/MEDWrapper/MED_Factory.hxx
src/MEDWrapper/MED_Wrapper.cxx
src/MEDWrapper/MED_Wrapper.hxx
src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_SWIG/smeshBuilder.py

index b8cc0b3877cf3167efab9bf36a578f587a5e10b3..46f4a40b749a09092f4c66147db2258c1bf7cd40 100644 (file)
@@ -622,6 +622,10 @@ module SMESH
      *                 the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
      *                 the typical use is auto_groups=false.
      * - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
      *                 the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
      *                 the typical use is auto_groups=false.
      * - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
+     * - minor : define the minor version of MED file format.
+     *           The minor must be between 0 and the current minor version of MED file library.
+     *           If minor is equal to -1, the minor version is not changed (default).
+     *           The major version cannot be changed.
      * - autoDimension : if @c true, a space dimension of a MED mesh can be either
      *         - 1D if all mesh nodes lie on OX coordinate axis, or
      *         - 2D if all mesh nodes lie on XOY coordinate plane, or
      * - autoDimension : if @c true, a space dimension of a MED mesh can be either
      *         - 1D if all mesh nodes lie on OX coordinate axis, or
      *         - 2D if all mesh nodes lie on XOY coordinate plane, or
@@ -630,6 +634,7 @@ module SMESH
      */
     void ExportMED( in string      fileName, 
                    in boolean     auto_groups, 
      */
     void ExportMED( in string      fileName, 
                    in boolean     auto_groups, 
+                   in long        minor,
                    in boolean     overwrite,
                    in boolean     autoDimension) raises (SALOME::SALOME_Exception);
 
                    in boolean     overwrite,
                    in boolean     autoDimension) raises (SALOME::SALOME_Exception);
 
@@ -639,6 +644,10 @@ module SMESH
      * - meshPart : a part of mesh to store
      * - fileName : name of the MED file
      * - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
      * - meshPart : a part of mesh to store
      * - fileName : name of the MED file
      * - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists
+     * - minor : define the minor version (y, where version is x.y.z) of MED file format.
+     *           The minor must be between 0 and the current minor version of MED file library.
+     *           If minor is equal to -1, the minor version is not changed (default).
+     *           The major version (x, where version is x.y.z) cannot be changed.
      * - autoDimension : if @c True, a space dimension for export is defined by mesh 
      *                 configuration; for example a planar mesh lying on XOY plane
      *                 will be exported as a mesh in 2D space. 
      * - autoDimension : if @c True, a space dimension for export is defined by mesh 
      *                 configuration; for example a planar mesh lying on XOY plane
      *                 will be exported as a mesh in 2D space. 
@@ -654,6 +663,7 @@ module SMESH
     void ExportPartToMED( in SMESH_IDSource     meshPart,
                           in string             fileName,
                           in boolean            auto_groups,
     void ExportPartToMED( in SMESH_IDSource     meshPart,
                           in string             fileName,
                           in boolean            auto_groups,
+                          in long               minor,
                           in boolean            overwrite,
                           in boolean            autoDimension,
                           in GEOM::ListOfFields fields,
                           in boolean            overwrite,
                           in boolean            autoDimension,
                           in GEOM::ListOfFields fields,
@@ -665,6 +675,11 @@ module SMESH
      */
     void ExportSAUV( in string file, in boolean auto_groups )
       raises (SALOME::SALOME_Exception);
      */
     void ExportSAUV( in string file, in boolean auto_groups )
       raises (SALOME::SALOME_Exception);
+    
+    /*!
+     * Return string representation of a MED file version comprising nbDigits
+     */
+    string GetVersionString(in long minor, in short nbDigits);
 
     /*!
      * Export Mesh to different Formats
 
     /*!
      * Export Mesh to different Formats
index af3e0f22dddc334c70f31029018724824cbef584..797f0ed4afe8129e13443c503c609025b560287a 100644 (file)
@@ -20,6 +20,7 @@
 # --- options ---
 # additional include directories
 INCLUDE_DIRECTORIES(
 # --- options ---
 # additional include directories
 INCLUDE_DIRECTORIES(
+  ${MEDFILE_INCLUDE_DIRS}
   ${HDF5_INCLUDE_DIRS}
   ${KERNEL_INCLUDE_DIRS}
   ${OpenCASCADE_INCLUDE_DIR}
   ${HDF5_INCLUDE_DIRS}
   ${KERNEL_INCLUDE_DIRS}
   ${OpenCASCADE_INCLUDE_DIR}
index 6ac446156c3ad6954eba9cfc716b069e57b54db8..a1902daac8aafe9f4cfc43d9c83906a2e769242f 100644 (file)
@@ -35,6 +35,8 @@
 #include "SMDS_SetIterator.hxx"
 #include "SMESHDS_Mesh.hxx"
 
 #include "SMDS_SetIterator.hxx"
 #include "SMESHDS_Mesh.hxx"
 
+#include <med.h>
+
 #include <BRep_Tool.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <BRep_Tool.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
@@ -62,11 +64,41 @@ DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
   myDoAllInGroups(false)
 {}
 
   myDoAllInGroups(false)
 {}
 
-void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
+void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, int theMinor)
 {
 {
+  myMinor = theMinor;
   Driver_SMESHDS_Mesh::SetFile(theFileName);
 }
 
   Driver_SMESHDS_Mesh::SetFile(theFileName);
 }
 
+/*!
+ * MED version is either the latest available, or with an inferior minor,
+ * to ensure backward compatibility on writing med files.
+ */
+string DriverMED_W_SMESHDS_Mesh::GetVersionString(int theVersion, int theNbDigits)
+{
+  TInt majeur, mineur, release;
+  majeur=MED_MAJOR_NUM;
+  mineur=MED_MINOR_NUM;
+  release=MED_RELEASE_NUM;
+  TInt imposedMineur = mineur;
+
+  if (theVersion < 0)
+    imposedMineur = mineur;
+  else if (theVersion > MED_MINOR_NUM)
+    imposedMineur = mineur;
+  else
+    imposedMineur = theVersion;
+
+  ostringstream name;
+  if ( theNbDigits > 0 )
+    name << majeur;
+  if ( theNbDigits > 1 )
+    name << "." << imposedMineur;
+  if ( theNbDigits > 2 )
+    name << "." << release;
+  return name.str();
+}
+
 void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup)
 {
   myGroups.push_back(theGroup);
 void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup)
 {
   myGroups.push_back(theGroup);
@@ -425,7 +457,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
       }
     }
 
       }
     }
 
-    MED::PWrapper myMed = CrWrapperW(myFile);
+    MED::PWrapper myMed = CrWrapperW(myFile, myMinor);
     PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
     //MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
     myMed->SetMeshInfo(aMeshInfo);
     PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
     //MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
     myMed->SetMeshInfo(aMeshInfo);
index 4b63d3cc6e9518eb7d5dec105c0147301a027c79..60261dd628f79d2643c32e797fd884b84e5e965c 100644 (file)
@@ -48,9 +48,11 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
 
   DriverMED_W_SMESHDS_Mesh();
 
 
   DriverMED_W_SMESHDS_Mesh();
 
-  void SetFile(const std::string& theFileName);
+  void SetFile(const std::string& theFileName, int theMinor=-1);
   void SetAutoDimension(bool toFindOutDimension) { myAutoDimension = toFindOutDimension; }
 
   void SetAutoDimension(bool toFindOutDimension) { myAutoDimension = toFindOutDimension; }
 
+  static std::string GetVersionString(int theVersion, int theNbDigits=2);
+
   void AddGroupOfNodes();
   void AddGroupOfEdges();
   void AddGroupOfFaces();
   void AddGroupOfNodes();
   void AddGroupOfEdges();
   void AddGroupOfFaces();
@@ -87,6 +89,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
   bool myAutoDimension;
   bool myAddODOnVertices;
   bool myDoAllInGroups;
   bool myAutoDimension;
   bool myAddODOnVertices;
   bool myDoAllInGroups;
+  int myMinor;
 };
 
 #endif
 };
 
 #endif
index 02b7e866ee737e69f6029ec33970789626113043..52558d0f43c3e0210eda60ea00ec8a06ebfc11bc 100644 (file)
@@ -111,10 +111,10 @@ namespace MED
     return new MED::TWrapper(fileName);
   }
 
     return new MED::TWrapper(fileName);
   }
 
-  PWrapper CrWrapperW(const std::string& fileName)
+  PWrapper CrWrapperW(const std::string& fileName, int theMinor)
   {
     if (!CheckCompatibility(fileName))
       remove(fileName.c_str());
   {
     if (!CheckCompatibility(fileName))
       remove(fileName.c_str());
-    return new MED::TWrapper(fileName);
+    return new MED::TWrapper(fileName, theMinor);
   }
 }
   }
 }
index 3dea6247b324d5dd76871fd30e8f9b12c1f9303d..7313da7ec210ce7217ec2581dce697ff349bc14d 100644 (file)
@@ -43,7 +43,7 @@ namespace MED
   PWrapper CrWrapperR( const std::string& );
 
   MEDWRAPPER_EXPORT
   PWrapper CrWrapperR( const std::string& );
 
   MEDWRAPPER_EXPORT
-  PWrapper CrWrapperW( const std::string& );
+  PWrapper CrWrapperW( const std::string&, int theMinor=-1 );
 }
 
 #endif // MED_Factory_HeaderFile
 }
 
 #endif // MED_Factory_HeaderFile
index dbabc2a2d5a7c2c8d4114bd5bb06097dc2d7b2bf..cc0e21b636bb5ccd75038762a2b0b110557c5e03 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <med.h>
 #include <med_err.h>
 
 #include <med.h>
 #include <med_err.h>
+#include <med_proto.h>
 
 #include <boost/version.hpp>
 
 
 #include <boost/version.hpp>
 
@@ -77,11 +78,14 @@ namespace MED
     TFile(const TFile&);
 
   public:
     TFile(const TFile&);
 
   public:
-    TFile(const std::string& theFileName):
+    TFile(const std::string& theFileName, TInt theMinor=-1):
       myCount(0),
       myFid(0),
       myCount(0),
       myFid(0),
-      myFileName(theFileName)
-    {}
+      myFileName(theFileName),
+      myMinor(theMinor)
+    {
+      if ((myMinor < 0) || (myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM;
+    }
 
     ~TFile()
     {
 
     ~TFile()
     {
@@ -94,12 +98,12 @@ namespace MED
     {
       if (myCount++ == 0) {
         const char* aFileName = myFileName.c_str();
     {
       if (myCount++ == 0) {
         const char* aFileName = myFileName.c_str();
-        myFid = MEDfileOpen(aFileName, med_access_mode(theMode));
+        myFid = MEDfileVersionOpen(aFileName,med_access_mode(theMode), MED_MAJOR_NUM, myMinor, MED_RELEASE_NUM);
       }
       if (theErr)
         *theErr = TErr(myFid);
       else if (myFid < 0)
       }
       if (theErr)
         *theErr = TErr(myFid);
       else if (myFid < 0)
-        EXCEPTION(std::runtime_error, "TFile - MEDfileOpen('"<<myFileName<<"',"<<theMode<<")");
+        EXCEPTION(std::runtime_error,"TFile - MEDfileVersionOpen('"<<myFileName<<"',"<<theMode<<"',"<< MED_MAJOR_NUM<<"',"<< myMinor<<"',"<< MED_RELEASE_NUM<<")");
     }
 
     const TIdt&
     }
 
     const TIdt&
@@ -121,19 +125,24 @@ namespace MED
     TInt myCount;
     TIdt myFid;
     std::string myFileName;
     TInt myCount;
     TIdt myFid;
     std::string myFileName;
+    TInt myMinor;
   };
 
   //---------------------------------------------------------------
   class TFileWrapper
   {
     PFile myFile;
   };
 
   //---------------------------------------------------------------
   class TFileWrapper
   {
     PFile myFile;
+    TInt myMinor;
 
   public:
     TFileWrapper(const PFile& theFile,
                  EModeAcces theMode,
 
   public:
     TFileWrapper(const PFile& theFile,
                  EModeAcces theMode,
-                 TErr* theErr = NULL):
-      myFile(theFile)
+                 TErr* theErr = NULL,
+                 TInt theMinor=-1):
+      myFile(theFile),
+      myMinor(theMinor)
     {
     {
+      if (myMinor < 0) myMinor = MED_MINOR_NUM;
       myFile->Open(theMode, theErr);
     }
 
       myFile->Open(theMode, theErr);
     }
 
@@ -178,8 +187,9 @@ namespace MED
 
   //---------------------------------------------------------------
   TWrapper
 
   //---------------------------------------------------------------
   TWrapper
-  ::TWrapper(const std::string& theFileName):
-    myFile(new TFile(theFileName))
+  ::TWrapper(const std::string& theFileName, TInt theMinor):
+    myMinor(theMinor),
+    myFile(new TFile(theFileName, theMinor))
   {
     TErr aRet;
     myFile->Open(eLECTURE_ECRITURE, &aRet);
   {
     TErr aRet;
     myFile->Open(eLECTURE_ECRITURE, &aRet);
@@ -208,7 +218,7 @@ namespace MED
   TWrapper
   ::GetNbMeshes(TErr* theErr)
   {
   TWrapper
   ::GetNbMeshes(TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -223,7 +233,7 @@ namespace MED
                 MED::TMeshInfo& theInfo,
                 TErr* theErr)
   {
                 MED::TMeshInfo& theInfo,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -284,7 +294,7 @@ namespace MED
                 EModeAcces theMode,
                 TErr* theErr)
   {
                 EModeAcces theMode,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -368,7 +378,7 @@ namespace MED
   ::GetNbFamilies(const MED::TMeshInfo& theInfo,
                   TErr* theErr)
   {
   ::GetNbFamilies(const MED::TMeshInfo& theInfo,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -385,7 +395,7 @@ namespace MED
                  const MED::TMeshInfo& theInfo,
                  TErr* theErr)
   {
                  const MED::TMeshInfo& theInfo,
                  TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -404,7 +414,7 @@ namespace MED
                   const MED::TMeshInfo& theInfo,
                   TErr* theErr)
   {
                   const MED::TMeshInfo& theInfo,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -423,7 +433,7 @@ namespace MED
                   MED::TFamilyInfo& theInfo,
                   TErr* theErr)
   {
                   MED::TFamilyInfo& theInfo,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -481,7 +491,7 @@ namespace MED
                   EModeAcces theMode,
                   TErr* theErr)
   {
                   EModeAcces theMode,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -603,7 +613,7 @@ namespace MED
              EGeometrieElement theGeom,
              TErr* theErr)
   {
              EGeometrieElement theGeom,
              TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -652,7 +662,7 @@ namespace MED
              EGeometrieElement theGeom,
              TErr* theErr)
   {
              EGeometrieElement theGeom,
              TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -694,7 +704,7 @@ namespace MED
                   EGeometrieElement theGeom,
                   TErr* theErr)
   {
                   EGeometrieElement theGeom,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -743,7 +753,7 @@ namespace MED
                   EGeometrieElement theGeom,
                   TErr* theErr)
   {
                   EGeometrieElement theGeom,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -785,7 +795,7 @@ namespace MED
                 EGeometrieElement theGeom,
                 TErr* theErr)
   {
                 EGeometrieElement theGeom,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -843,7 +853,7 @@ namespace MED
                 EGeometrieElement theGeom,
                 TErr* theErr)
   {
                 EGeometrieElement theGeom,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -890,7 +900,7 @@ namespace MED
                ETable theTable,
                TErr* theErr)
   {
                ETable theTable,
                TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -918,7 +928,7 @@ namespace MED
   ::GetNodeInfo(MED::TNodeInfo& theInfo,
                 TErr* theErr)
   {
   ::GetNodeInfo(MED::TNodeInfo& theInfo,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -1009,7 +1019,7 @@ namespace MED
                 EModeAcces theMode,
                 TErr* theErr)
   {
                 EModeAcces theMode,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -1320,7 +1330,7 @@ namespace MED
                         EConnectivite theConnMode,
                         TErr* theErr)
   {
                         EConnectivite theConnMode,
                         TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return 0;
 
     if (theErr && *theErr < 0)
       return 0;
@@ -1353,7 +1363,7 @@ namespace MED
   ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
                     TErr* theErr)
   {
   ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
                     TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -1412,7 +1422,7 @@ namespace MED
                     EModeAcces theMode,
                     TErr* theErr)
   {
                     EModeAcces theMode,
                     TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -1564,7 +1574,7 @@ namespace MED
                         EConnectivite theConnMode,
                         TErr* theErr)
   {
                         EConnectivite theConnMode,
                         TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
 
     if (theErr && *theErr < 0)
       EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
@@ -1610,7 +1620,7 @@ namespace MED
   ::GetPolyedreInfo(TPolyedreInfo& theInfo,
                     TErr* theErr)
   {
   ::GetPolyedreInfo(TPolyedreInfo& theInfo,
                     TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -1673,7 +1683,7 @@ namespace MED
                     EModeAcces theMode,
                     TErr* theErr)
   {
                     EModeAcces theMode,
                     TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -1869,7 +1879,7 @@ namespace MED
   {
     TEntityInfo anInfo;
 
   {
     TEntityInfo anInfo;
 
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return anInfo;
 
     if (theErr && *theErr < 0)
       return anInfo;
@@ -1981,7 +1991,7 @@ namespace MED
                EConnectivite theConnMode,
                TErr* theErr)
   {
                EConnectivite theConnMode,
                TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -2030,7 +2040,7 @@ namespace MED
   ::GetCellInfo(MED::TCellInfo& theInfo,
                 TErr* theErr)
   {
   ::GetCellInfo(MED::TCellInfo& theInfo,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -2097,7 +2107,7 @@ namespace MED
                 EModeAcces theMode,
                 TErr* theErr)
   {
                 EModeAcces theMode,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -2275,7 +2285,8 @@ namespace MED
   TWrapper
   ::GetBallGeom(const TMeshInfo& theMeshInfo)
   {
   TWrapper
   ::GetBallGeom(const TMeshInfo& theMeshInfo)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE);
+    TErr anError;
+    TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
 
     // read med_geometry_type of "MED_BALL" element
     char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
 
     // read med_geometry_type of "MED_BALL" element
     char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
@@ -2287,7 +2298,8 @@ namespace MED
   TWrapper
   ::GetNbBalls(const TMeshInfo& theMeshInfo)
   {
   TWrapper
   ::GetNbBalls(const TMeshInfo& theMeshInfo)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE);
+    TErr anError;
+    TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
 
     EGeometrieElement ballType = GetBallGeom(theMeshInfo);
     if (ballType < 0)
 
     EGeometrieElement ballType = GetBallGeom(theMeshInfo);
     if (ballType < 0)
@@ -2302,7 +2314,7 @@ namespace MED
   ::GetBallInfo(TBallInfo& theInfo,
                 TErr* theErr)
   {
   ::GetBallInfo(TBallInfo& theInfo,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     // check geometry of MED_BALL
     if (theInfo.myGeom == eBALL)
 
     // check geometry of MED_BALL
     if (theInfo.myGeom == eBALL)
@@ -2352,7 +2364,7 @@ namespace MED
                 EModeAcces theMode,
                 TErr* theErr)
   {
                 EModeAcces theMode,
                 TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     TErr ret;
     char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
 
     TErr ret;
     char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
@@ -2480,7 +2492,7 @@ namespace MED
   TWrapper
   ::GetNbFields(TErr* theErr)
   {
   TWrapper
   ::GetNbFields(TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -2494,7 +2506,7 @@ namespace MED
   ::GetNbComp(TInt theFieldId,
               TErr* theErr)
   {
   ::GetNbComp(TInt theFieldId,
               TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -2509,7 +2521,7 @@ namespace MED
                  MED::TFieldInfo& theInfo,
                  TErr* theErr)
   {
                  MED::TFieldInfo& theInfo,
                  TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -2574,7 +2586,7 @@ namespace MED
                  EModeAcces theMode,
                  TErr* theErr)
   {
                  EModeAcces theMode,
                  TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -2661,7 +2673,7 @@ namespace MED
   TWrapper
   ::GetNbGauss(TErr* theErr)
   {
   TWrapper
   ::GetNbGauss(TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -2675,7 +2687,7 @@ namespace MED
   ::GetGaussPreInfo(TInt theId,
                     TErr* theErr)
   {
   ::GetGaussPreInfo(TInt theId,
                     TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
 
     if (theErr && *theErr < 0)
       return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
@@ -2715,7 +2727,7 @@ namespace MED
                  TGaussInfo& theInfo,
                  TErr* theErr)
   {
                  TGaussInfo& theInfo,
                  TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -2761,7 +2773,7 @@ namespace MED
                     TErr* theErr)
   {
     theEntity = EEntiteMaillage(-1);
                     TErr* theErr)
   {
     theEntity = EEntiteMaillage(-1);
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr) {
       if (theEntityInfo.empty())
 
     if (theErr) {
       if (theEntityInfo.empty())
@@ -2884,7 +2896,7 @@ namespace MED
                      MED::TTimeStampInfo& theInfo,
                      TErr* theErr)
   {
                      MED::TTimeStampInfo& theInfo,
                      TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
 
 
     const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
 
@@ -3037,7 +3049,7 @@ namespace MED
   TWrapper
   ::GetNbProfiles(TErr* theErr)
   {
   TWrapper
   ::GetNbProfiles(TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return -1;
 
     if (theErr && *theErr < 0)
       return -1;
@@ -3051,7 +3063,7 @@ namespace MED
   ::GetProfilePreInfo(TInt theId,
                       TErr* theErr)
   {
   ::GetProfilePreInfo(TInt theId,
                       TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return TProfileInfo::TInfo();
 
     if (theErr && *theErr < 0)
       return TProfileInfo::TInfo();
@@ -3079,7 +3091,7 @@ namespace MED
                    TProfileInfo& theInfo,
                    TErr* theErr)
   {
                    TProfileInfo& theInfo,
                    TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -3124,7 +3136,7 @@ namespace MED
                    EModeAcces theMode,
                    TErr* theErr)
   {
                    EModeAcces theMode,
                    TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -3177,7 +3189,7 @@ namespace MED
                       const TKey2Gauss& theKey2Gauss,
                       TErr* theErr)
   {
                       const TKey2Gauss& theKey2Gauss,
                       TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -3361,7 +3373,7 @@ namespace MED
                       EModeAcces theMode,
                       TErr* theErr)
   {
                       EModeAcces theMode,
                       TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -3698,7 +3710,7 @@ namespace MED
   ::GetGrilleInfo(TGrilleInfo& theInfo,
                   TErr* theErr)
   {
   ::GetGrilleInfo(TGrilleInfo& theInfo,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -3868,7 +3880,7 @@ namespace MED
   {
     if (theInfo.myMeshInfo->myType != eSTRUCTURE)
       return;
   {
     if (theInfo.myMeshInfo->myType != eSTRUCTURE)
       return;
-    TFileWrapper aFileWrapper(myFile, theMode, theErr);
+    TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
@@ -4003,7 +4015,7 @@ namespace MED
                   EGrilleType& theGridType,
                   TErr* theErr)
   {
                   EGrilleType& theGridType,
                   TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
 
     if (theErr && *theErr < 0)
       EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
@@ -4029,7 +4041,7 @@ namespace MED
                     TIntVector& theStruct,
                     TErr* theErr)
   {
                     TIntVector& theStruct,
                     TErr* theErr)
   {
-    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+    TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
 
     if (theErr && *theErr < 0)
       return;
 
     if (theErr && *theErr < 0)
       return;
index 841eb4eca0b1eb3df1d5f348c9112bb010a7a819..05b0496c28554fdf7c23800441fcbca76d69da82 100644 (file)
@@ -52,7 +52,7 @@ namespace MED
     TWrapper& operator=(const TWrapper&);
 
   public:
     TWrapper& operator=(const TWrapper&);
 
   public:
-    TWrapper(const std::string& theFileName);
+    TWrapper(const std::string& theFileName, TInt theMinor=-1);
 
     virtual
     ~TWrapper();
 
     virtual
     ~TWrapper();
@@ -939,6 +939,7 @@ namespace MED
 
   protected:
     PFile myFile;
 
   protected:
     PFile myFile;
+    TInt myMinor;
   };
 
   //----------------------------------------------------------------------------
   };
 
   //----------------------------------------------------------------------------
index afefed35a9f660365e0443e00de9c2d45c66bbbe..3f16ab7dd58be1869e0428e07ca8e675e4cb8a9b 100644 (file)
@@ -1402,6 +1402,10 @@ bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
  *  \param [in] theAutoGroups - boolean parameter for creating/not creating
  *              the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
  *              the typical use is auto_groups=false.
  *  \param [in] theAutoGroups - boolean parameter for creating/not creating
  *              the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
  *              the typical use is auto_groups=false.
+ *  \param [in] theMinor - define the minor version (y, where version is x.y.z) of MED file format.
+ *              The theMinor must be between 0 and the current minor version of MED file library.
+ *              If theMinor is equal to -1, the minor version is not changed (default).
+ *              The major version (x, where version is x.y.z) cannot be changed.
  *  \param [in] meshPart - mesh data to export
  *  \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either
      *         - 1D if all mesh nodes lie on OX coordinate axis, or
  *  \param [in] meshPart - mesh data to export
  *  \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either
      *         - 1D if all mesh nodes lie on OX coordinate axis, or
@@ -1417,6 +1421,7 @@ bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
 void SMESH_Mesh::ExportMED(const char *        file, 
                            const char*         theMeshName, 
                            bool                theAutoGroups,
 void SMESH_Mesh::ExportMED(const char *        file, 
                            const char*         theMeshName, 
                            bool                theAutoGroups,
+                           int                 theMinor,
                            const SMESHDS_Mesh* meshPart,
                            bool                theAutoDimension,
                            bool                theAddODOnVertices,
                            const SMESHDS_Mesh* meshPart,
                            bool                theAutoDimension,
                            bool                theAddODOnVertices,
@@ -1427,7 +1432,7 @@ void SMESH_Mesh::ExportMED(const char *        file,
   SMESH_TRY;
 
   DriverMED_W_SMESHDS_Mesh myWriter;
   SMESH_TRY;
 
   DriverMED_W_SMESHDS_Mesh myWriter;
-  myWriter.SetFile         ( file );
+  myWriter.SetFile         ( file , theMinor);
   myWriter.SetMesh         ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS   );
   myWriter.SetAutoDimension( theAutoDimension );
   myWriter.AddODOnVertices ( theAddODOnVertices );
   myWriter.SetMesh         ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS   );
   myWriter.SetAutoDimension( theAutoDimension );
   myWriter.AddODOnVertices ( theAddODOnVertices );
index 57c26d63a6f5485c9b8005447491887bc4055c6a..c52b5ef2ef8705b0e4f522fa205c9fdd73c9b10c 100644 (file)
@@ -254,6 +254,7 @@ class SMESH_EXPORT SMESH_Mesh
   void ExportMED(const char *        theFile, 
                  const char*         theMeshName = NULL, 
                  bool                theAutoGroups = true, 
   void ExportMED(const char *        theFile, 
                  const char*         theMeshName = NULL, 
                  bool                theAutoGroups = true, 
+                 int                 TheMinor = -1,
                  const SMESHDS_Mesh* theMeshPart = 0,
                  bool                theAutoDimension = false,
                  bool                theAddODOnVertices = false,
                  const SMESHDS_Mesh* theMeshPart = 0,
                  bool                theAutoDimension = false,
                  bool                theAddODOnVertices = false,
index 82aaf6581b499911a53051168011a0d8a97a52c6..25977a776107cdba7778dd5282133e89d001bae3 100644 (file)
@@ -655,6 +655,8 @@ namespace
     // Get parameters of export operation
 
     QString aFilename;
     // Get parameters of export operation
 
     QString aFilename;
+    int aFormat =-1; // for MED minor versions
+
     // Init the parameters with the default values
     bool aIsASCII_STL   = true;
     bool toCreateGroups = false;
     // Init the parameters with the default values
     bool aIsASCII_STL   = true;
     bool toCreateGroups = false;
@@ -741,14 +743,40 @@ namespace
     }
     else if ( isMED || isSAUV ) // Export to MED or SAUV
     {
     }
     else if ( isMED || isSAUV ) // Export to MED or SAUV
     {
-      QStringList filters;
+      QMap<QString, int> aFilterMap;
       if ( isMED ) {
       if ( isMED ) {
-        filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
+        //filters << QObject::tr( "MED_FILES_FILTER" ) + " (*.med)";
+        QString vmed (aMesh->GetVersionString(-1, 2));
+        MESSAGE("MED version: " << vmed.toStdString());
+        int minor = vmed.split(".").last().toInt();
+        MESSAGE("MED version minor: "<< minor);
+        minor +=3; // TODO test, to remove
+        aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vmed ) + " (*.med)", minor );
+        for (int ii=0; ii<minor; ii++)
+          {
+            QString vs = aMesh->GetVersionString(ii, 2);
+            std::ostringstream vss; // TODO test, to remove
+            vss << "4.";            //
+            vss << ii;              //
+            vs = vss.str().c_str(); // TODO test, to remove
+            MESSAGE("MED version: " << vs.toStdString());
+            aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)",  ii);
+          }
       }
       else { // isSAUV
       }
       else { // isSAUV
-        filters << QObject::tr( "SAUV_FILES_FILTER" ) + " (*.sauv *.sauve)";
+        aFilterMap.insert("All files (*)", -1 );
+        aFilterMap.insert("SAUV files (*.sauv)", -1 );
+        aFilterMap.insert("SAUV files (*.sauve)", -1 );
       }
 
       }
 
+      QStringList filters;
+      QString aDefaultFilter;
+      QMap<QString, int>::const_iterator it = aFilterMap.begin();
+      for ( ; it != aFilterMap.end(); ++it ) {
+        filters.push_back( it.key() );
+        if (it.key() == 0)
+          aDefaultFilter = it.key();
+      }
       QStringList checkBoxes;
       checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
 
       QStringList checkBoxes;
       checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
 
@@ -788,6 +816,8 @@ namespace
           aFilename = QString::null;
           break;
         }
           aFilename = QString::null;
           break;
         }
+        aFormat = aFilterMap[fd->selectedNameFilter()];
+        MESSAGE("selected minor: " << aFormat);
         toOverwrite = fv->isOverwrite();
         is_ok = true;
         if ( !aFilename.isEmpty() ) {
         toOverwrite = fv->isOverwrite();
         is_ok = true;
         if ( !aFilename.isEmpty() ) {
@@ -879,10 +909,10 @@ namespace
             const QString&            geoAssFields = aFieldList[ aMeshIndex ].second;
             const bool                   hasFields = ( fields.length() || !geoAssFields.isEmpty() );
             if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
             const QString&            geoAssFields = aFieldList[ aMeshIndex ].second;
             const bool                   hasFields = ( fields.length() || !geoAssFields.isEmpty() );
             if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
-              aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups,
+              aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups, aFormat,
                                     toOverwrite && aMeshIndex == 0, toFindOutDim );
             else
                                     toOverwrite && aMeshIndex == 0, toFindOutDim );
             else
-              aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
+              aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups, aFormat,
                                           toOverwrite && aMeshIndex == 0, toFindOutDim,
                                           fields, geoAssFields.toLatin1().data() );
           }
                                           toOverwrite && aMeshIndex == 0, toFindOutDim,
                                           fields, geoAssFields.toLatin1().data() );
           }
index 8af2e2d7c7618fae7dafcd522fa2516c987a1e77..af398866079d0f9516b20c2147b2920856c3a481 100644 (file)
         <source>TEXT_FILES_FILTER</source>
         <translation>TXT files</translation>
     </message>
         <source>TEXT_FILES_FILTER</source>
         <translation>TXT files</translation>
     </message>
+    <message>
+        <source>MED_VX_FILES_FILTER</source>
+        <translation>MED %1 files</translation>
+    </message>
     <message>
         <source>STL_FILES_FILTER</source>
         <translation>STL files</translation>
     <message>
         <source>STL_FILES_FILTER</source>
         <translation>STL files</translation>
index c7c3f54eb8afbf3141ccf486d8393ad359b51c5c..dbf9013d5621f75bbbf8b6cdd6771ab42012662a 100644 (file)
@@ -448,6 +448,19 @@ SMESH::DriverMED_ReadStatus SMESH_Mesh_i::ImportCGNSFile( const char*  theFileNa
   return ConvertDriverMEDReadStatus(status);
 }
 
   return ConvertDriverMEDReadStatus(status);
 }
 
+//================================================================================
+/*!
+ * \brief Return string representation of a MED file version comprising nbDigits
+ */
+//================================================================================
+
+char* SMESH_Mesh_i::GetVersionString(CORBA::Long minor, CORBA::Short nbDigits)
+{
+  string ver = DriverMED_W_SMESHDS_Mesh::GetVersionString(minor,
+                                                          nbDigits);
+  return CORBA::string_dup( ver.c_str() );
+}
+
 //=============================================================================
 /*!
  *  ImportUNVFile
 //=============================================================================
 /*!
  *  ImportUNVFile
@@ -2987,22 +3000,26 @@ string SMESH_Mesh_i::prepareMeshNameAndGroups(const char*    file,
 
 void SMESH_Mesh_i::ExportMED(const char*        file,
                              CORBA::Boolean     auto_groups,
 
 void SMESH_Mesh_i::ExportMED(const char*        file,
                              CORBA::Boolean     auto_groups,
+                             CORBA::Long        minor,
                              CORBA::Boolean     overwrite,
                              CORBA::Boolean     autoDimension)
   throw(SALOME::SALOME_Exception)
 {
                              CORBA::Boolean     overwrite,
                              CORBA::Boolean     autoDimension)
   throw(SALOME::SALOME_Exception)
 {
-  //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
+  MESSAGE("MED minor version: "<< minor);
   SMESH_TRY;
   if ( _preMeshInfo )
     _preMeshInfo->FullLoadFromFile();
 
   string aMeshName = prepareMeshNameAndGroups(file, overwrite);
   SMESH_TRY;
   if ( _preMeshInfo )
     _preMeshInfo->FullLoadFromFile();
 
   string aMeshName = prepareMeshNameAndGroups(file, overwrite);
-  _impl->ExportMED( file, aMeshName.c_str(), auto_groups, 0, autoDimension );
+  _impl->ExportMED( file, aMeshName.c_str(), auto_groups, minor, 0, autoDimension );
 
   TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
 
   TPythonDump() << SMESH::SMESH_Mesh_var(_this()) << ".ExportMED( r'"
-                << file << "', " << auto_groups << ", "
-                << overwrite << ", "
-                << autoDimension << " )";
+                << file << "', "
+                << "auto_groups=" <<auto_groups << ", "
+                << "minor=" << minor <<  ", "
+                << "overwrite=" << overwrite << ", "
+                << "meshPart=None, "
+                << "autoDimension=" << autoDimension << " )";
 
   SMESH_CATCH( SMESH::throwCorbaException );
 }
 
   SMESH_CATCH( SMESH::throwCorbaException );
 }
@@ -3112,12 +3129,14 @@ void SMESH_Mesh_i::ExportSTL (const char *file, const bool isascii)
 void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
                                    const char*               file,
                                    CORBA::Boolean            auto_groups,
 void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
                                    const char*               file,
                                    CORBA::Boolean            auto_groups,
+                                   CORBA::Long               minor,
                                    CORBA::Boolean            overwrite,
                                    CORBA::Boolean            autoDimension,
                                    const GEOM::ListOfFields& fields,
                                    const char*               geomAssocFields)
   throw (SALOME::SALOME_Exception)
 {
                                    CORBA::Boolean            overwrite,
                                    CORBA::Boolean            autoDimension,
                                    const GEOM::ListOfFields& fields,
                                    const char*               geomAssocFields)
   throw (SALOME::SALOME_Exception)
 {
+  MESSAGE("MED minor version: "<< minor);
   SMESH_TRY;
   if ( _preMeshInfo )
     _preMeshInfo->FullLoadFromFile();
   SMESH_TRY;
   if ( _preMeshInfo )
     _preMeshInfo->FullLoadFromFile();
@@ -3164,7 +3183,7 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
        SMESH::DownCast< SMESH_Mesh_i* >( meshPart ))
   {
     aMeshName = prepareMeshNameAndGroups(file, overwrite);
        SMESH::DownCast< SMESH_Mesh_i* >( meshPart ))
   {
     aMeshName = prepareMeshNameAndGroups(file, overwrite);
-    _impl->ExportMED( file, aMeshName.c_str(), auto_groups,
+    _impl->ExportMED( file, aMeshName.c_str(), auto_groups, minor,
                       0, autoDimension, /*addODOnVertices=*/have0dField);
     meshDS = _impl->GetMeshDS();
   }
                       0, autoDimension, /*addODOnVertices=*/have0dField);
     meshDS = _impl->GetMeshDS();
   }
@@ -3182,7 +3201,7 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
     }
 
     SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
     }
 
     SMESH_MeshPartDS* partDS = new SMESH_MeshPartDS( meshPart );
-    _impl->ExportMED( file, aMeshName.c_str(), auto_groups,
+    _impl->ExportMED( file, aMeshName.c_str(), auto_groups, minor,
                       partDS, autoDimension, /*addODOnVertices=*/have0dField);
     meshDS = tmpDSDeleter._obj = partDS;
   }
                       partDS, autoDimension, /*addODOnVertices=*/have0dField);
     meshDS = tmpDSDeleter._obj = partDS;
   }
@@ -3207,11 +3226,15 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
     GEOM::GEOM_BaseObject_var gbo = GEOM::GEOM_BaseObject::_narrow( fields[i] );
     goList[i] = gbo;
   }
     GEOM::GEOM_BaseObject_var gbo = GEOM::GEOM_BaseObject::_narrow( fields[i] );
     goList[i] = gbo;
   }
-  TPythonDump() << _this() << ".ExportPartToMED( "
-                << meshPart << ", r'" << file << "', "
-                << auto_groups << ", " << overwrite << ", "
-                << autoDimension << ", " << goList
-                << ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
+  TPythonDump() << _this() << ".ExportPartToMED( r'"
+                << file << "', "
+                << "auto_groups=" << auto_groups << ", "
+                << "minor=" << minor <<  ", "
+                << "overwrite=" << overwrite << ", "
+                << "meshPart=" << meshPart << ", "
+                << "autoDimension=" << autoDimension << ", "
+                << "fields=" << goList << ", geomAssocFields='"
+                << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
 
   SMESH_CATCH( SMESH::throwCorbaException );
 }
 
   SMESH_CATCH( SMESH::throwCorbaException );
 }
index 9fdde438ccfa330a8b0a52b0b128c6d7bdad421c..ece281760cff7e7e4916eaea2b9bee73066108d5 100644 (file)
@@ -225,9 +225,14 @@ public:
    *  Consider maximum group name length stored in MED file.
    */
   CORBA::Boolean HasDuplicatedGroupNamesMED();
    *  Consider maximum group name length stored in MED file.
    */
   CORBA::Boolean HasDuplicatedGroupNamesMED();
+  /*!
+   * Return string representation of a MED file version comprising nbDigits
+   */
+  char* GetVersionString(CORBA::Long minor, CORBA::Short nbDigits);
 
   void ExportMED( const char*        file,
                   CORBA::Boolean     auto_groups,
 
   void ExportMED( const char*        file,
                   CORBA::Boolean     auto_groups,
+                  CORBA::Long        minor,
                   CORBA::Boolean     overwrite,
                   CORBA::Boolean     autoDimension = true) throw (SALOME::SALOME_Exception);
 
                   CORBA::Boolean     overwrite,
                   CORBA::Boolean     autoDimension = true) throw (SALOME::SALOME_Exception);
 
@@ -247,6 +252,7 @@ public:
   void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
                        const char*               file,
                        CORBA::Boolean            auto_groups,
   void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
                        const char*               file,
                        CORBA::Boolean            auto_groups,
+                       CORBA::Long               minor,
                        CORBA::Boolean            overwrite,
                        CORBA::Boolean            autoDim,
                        const GEOM::ListOfFields& fields,
                        CORBA::Boolean            overwrite,
                        CORBA::Boolean            autoDim,
                        const GEOM::ListOfFields& fields,
index 8706efa1b39ab8500192c7de92ba09a80b3ff338..d0dfc53dc7bbeb057a307894be0d373c88e3214c 100644 (file)
@@ -24,9 +24,19 @@ import salome
 from salome.geom import geomBuilder
 
 import SMESH # This is necessary for back compatibility
 from salome.geom import geomBuilder
 
 import SMESH # This is necessary for back compatibility
-import omniORB                                   # back compatibility
-SMESH.MED_V2_1 = omniORB.EnumItem("MED_V2_1", 0) # back compatibility
-SMESH.MED_V2_2 = omniORB.EnumItem("MED_V2_2", 1) # back compatibility
+import omniORB                                       # back compatibility
+SMESH.MED_V2_1    = 11 #omniORB.EnumItem("MED_V2_1", 11) # back compatibility: use number > MED minor version
+SMESH.MED_V2_2    = 12 #omniORB.EnumItem("MED_V2_2", 12) # back compatibility: latest minor will be used
+SMESH.MED_MINOR_0 = 20 # back compatibility
+SMESH.MED_MINOR_1 = 21 # back compatibility
+SMESH.MED_MINOR_2 = 22 # back compatibility
+SMESH.MED_MINOR_3 = 23 # back compatibility
+SMESH.MED_MINOR_4 = 24 # back compatibility
+SMESH.MED_MINOR_5 = 25 # back compatibility
+SMESH.MED_MINOR_6 = 26 # back compatibility
+SMESH.MED_MINOR_7 = 27 # back compatibility
+SMESH.MED_MINOR_8 = 28 # back compatibility
+SMESH.MED_MINOR_9 = 29 # back compatibility
 
 from   SMESH import *
 from   salome.smesh.smesh_algorithm import Mesh_Algorithm
 
 from   SMESH import *
 from   salome.smesh.smesh_algorithm import Mesh_Algorithm
@@ -2157,6 +2167,10 @@ class Mesh(metaclass = MeshMeta):
                 auto_groups (boolean): parameter for creating/not creating
                         the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
                         the typical use is auto_groups=False.
                 auto_groups (boolean): parameter for creating/not creating
                         the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
                         the typical use is auto_groups=False.
+                minor (int): define the minor version (y, where version is x.y.z) of MED file format.
+                        The minor must be between 0 and the current minor version of MED file library.
+                        If minor is equal to -1, the minor version is not changed (default).
+                        The major version (x, where version is x.y.z) cannot be changed.
                 overwrite (boolean): parameter for overwriting/not overwriting the file
                 meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`) to export instead of the mesh
                 autoDimension: if *True* (default), a space dimension of a MED mesh can be either
                 overwrite (boolean): parameter for overwriting/not overwriting the file
                 meshPart: a part of mesh (:class:`sub-mesh, group or filter <SMESH.SMESH_IDSource>`) to export instead of the mesh
                 autoDimension: if *True* (default), a space dimension of a MED mesh can be either
@@ -2175,16 +2189,18 @@ class Mesh(metaclass = MeshMeta):
                         - 's' stands for "_solids _" field.
         """
         # process positional arguments
                         - 's' stands for "_solids _" field.
         """
         # process positional arguments
-        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+        #args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
         fileName        = args[0]
         auto_groups     = args[1] if len(args) > 1 else False
         fileName        = args[0]
         auto_groups     = args[1] if len(args) > 1 else False
-        overwrite       = args[2] if len(args) > 2 else True
-        meshPart        = args[3] if len(args) > 3 else None
-        autoDimension   = args[4] if len(args) > 4 else True
-        fields          = args[5] if len(args) > 5 else []
-        geomAssocFields = args[6] if len(args) > 6 else ''
+        minor           = args[2] if len(args) > 2 else -1
+        overwrite       = args[3] if len(args) > 3 else True
+        meshPart        = args[4] if len(args) > 4 else None
+        autoDimension   = args[5] if len(args) > 5 else True
+        fields          = args[6] if len(args) > 6 else []
+        geomAssocFields = args[7] if len(args) > 7 else ''
         # process keywords arguments
         auto_groups     = kwargs.get("auto_groups", auto_groups)
         # process keywords arguments
         auto_groups     = kwargs.get("auto_groups", auto_groups)
+        minor           = kwargs.get("minor", minor)
         overwrite       = kwargs.get("overwrite", overwrite)
         meshPart        = kwargs.get("meshPart", meshPart)
         autoDimension   = kwargs.get("autoDimension", autoDimension)
         overwrite       = kwargs.get("overwrite", overwrite)
         meshPart        = kwargs.get("meshPart", meshPart)
         autoDimension   = kwargs.get("autoDimension", autoDimension)
@@ -2196,10 +2212,10 @@ class Mesh(metaclass = MeshMeta):
             if isinstance( meshPart, list ):
                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
                 unRegister.set( meshPart )
             if isinstance( meshPart, list ):
                 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
                 unRegister.set( meshPart )
-            self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, overwrite, autoDimension,
+            self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, minor, overwrite, autoDimension,
                                        fields, geomAssocFields)
         else:
                                        fields, geomAssocFields)
         else:
-            self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+            self.mesh.ExportMED(fileName, auto_groups, minor, overwrite, autoDimension)
 
     def ExportSAUV(self, f, auto_groups=0):
         """
 
     def ExportSAUV(self, f, auto_groups=0):
         """
@@ -2336,7 +2352,7 @@ class Mesh(metaclass = MeshMeta):
     
         print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
         # process positional arguments
     
         print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
         # process positional arguments
-        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+        #args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
         fileName      = args[0]
         auto_groups   = args[1] if len(args) > 1 else False
         overwrite     = args[2] if len(args) > 2 else True
         fileName      = args[0]
         auto_groups   = args[1] if len(args) > 1 else False
         overwrite     = args[2] if len(args) > 2 else True
@@ -2346,8 +2362,9 @@ class Mesh(metaclass = MeshMeta):
         auto_groups   = kwargs.get("auto_groups", auto_groups) # new keyword name
         overwrite     = kwargs.get("overwrite", overwrite)
         autoDimension = kwargs.get("autoDimension", autoDimension)
         auto_groups   = kwargs.get("auto_groups", auto_groups) # new keyword name
         overwrite     = kwargs.get("overwrite", overwrite)
         autoDimension = kwargs.get("autoDimension", autoDimension)
+        minor = -1
         # invoke engine's function
         # invoke engine's function
-        self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+        self.mesh.ExportMED(fileName, auto_groups, minor, overwrite, autoDimension)
 
     def ExportToMEDX(self, *args, **kwargs):
         """
 
     def ExportToMEDX(self, *args, **kwargs):
         """
@@ -2370,7 +2387,7 @@ class Mesh(metaclass = MeshMeta):
 
         print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
         # process positional arguments
 
         print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
         # process positional arguments
-        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
+        #args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]] # backward compatibility
         fileName      = args[0]
         auto_groups   = args[1] if len(args) > 1 else False
         overwrite     = args[2] if len(args) > 2 else True
         fileName      = args[0]
         auto_groups   = args[1] if len(args) > 1 else False
         overwrite     = args[2] if len(args) > 2 else True
@@ -2379,8 +2396,9 @@ class Mesh(metaclass = MeshMeta):
         auto_groups   = kwargs.get("auto_groups", auto_groups)
         overwrite     = kwargs.get("overwrite", overwrite)
         autoDimension = kwargs.get("autoDimension", autoDimension)
         auto_groups   = kwargs.get("auto_groups", auto_groups)
         overwrite     = kwargs.get("overwrite", overwrite)
         autoDimension = kwargs.get("autoDimension", autoDimension)
+        minor = -1
         # invoke engine's function
         # invoke engine's function
-        self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+        self.mesh.ExportMED(fileName, auto_groups, minor, overwrite, autoDimension)
 
     # Operations with groups:
     # ----------------------
 
     # Operations with groups:
     # ----------------------
@@ -6842,19 +6860,19 @@ class meshProxy(SMESH._objref_SMESH_Mesh):
         return SMESH._objref_SMESH_Mesh.CreateDimGroup(self, *args)
     def ExportToMEDX(self, *args): # function removed
         print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
         return SMESH._objref_SMESH_Mesh.CreateDimGroup(self, *args)
     def ExportToMEDX(self, *args): # function removed
         print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
-        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+        #args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
         SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
     def ExportToMED(self, *args): # function removed
         print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
         SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
     def ExportToMED(self, *args): # function removed
         print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
-        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+        #args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
         while len(args) < 4:  # !!!! nb of parameters for ExportToMED IDL's method
             args.append(True)
         SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
     def ExportPartToMED(self, *args): # 'version' parameter removed
         while len(args) < 4:  # !!!! nb of parameters for ExportToMED IDL's method
             args.append(True)
         SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
     def ExportPartToMED(self, *args): # 'version' parameter removed
-        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+        #args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
         SMESH._objref_SMESH_Mesh.ExportPartToMED(self, *args)
     def ExportMED(self, *args): # signature of method changed
         SMESH._objref_SMESH_Mesh.ExportPartToMED(self, *args)
     def ExportMED(self, *args): # signature of method changed
-        args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
+        #args = [i for i in args if i not in [SMESH.MED_V2_1, SMESH.MED_V2_2]]
         while len(args) < 4:  # !!!! nb of parameters for ExportToMED IDL's method
             args.append(True)
         SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
         while len(args) < 4:  # !!!! nb of parameters for ExportToMED IDL's method
             args.append(True)
         SMESH._objref_SMESH_Mesh.ExportMED(self, *args)