reintroduction of choice of MED minor version when exporting MED files

This commit is contained in:
Paul RASCLE 2018-07-13 15:35:34 +02:00
parent 1b80c8bc60
commit 49ff23c94f
15 changed files with 254 additions and 103 deletions

View File

@ -622,6 +622,10 @@ module SMESH
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; * the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false. * the typical use is auto_groups=false.
* - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists * - 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 * - 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 * - 1D if all mesh nodes lie on OX coordinate axis, or
* - 2D if all mesh nodes lie on XOY coordinate plane, or * - 2D if all mesh nodes lie on XOY coordinate plane, or
@ -630,6 +634,7 @@ module SMESH
*/ */
void ExportMED( in string fileName, void ExportMED( in string fileName,
in boolean auto_groups, in boolean auto_groups,
in long minor,
in boolean overwrite, in boolean overwrite,
in boolean autoDimension) raises (SALOME::SALOME_Exception); in boolean autoDimension) raises (SALOME::SALOME_Exception);
@ -639,6 +644,10 @@ module SMESH
* - meshPart : a part of mesh to store * - meshPart : a part of mesh to store
* - fileName : name of the MED file * - fileName : name of the MED file
* - overwrite : boolean parameter for overwriting/not overwriting the file, if it exists * - 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 * - autoDimension : if @c True, a space dimension for export is defined by mesh
* configuration; for example a planar mesh lying on XOY plane * configuration; for example a planar mesh lying on XOY plane
* will be exported as a mesh in 2D space. * will be exported as a mesh in 2D space.
@ -654,6 +663,7 @@ module SMESH
void ExportPartToMED( in SMESH_IDSource meshPart, void ExportPartToMED( in SMESH_IDSource meshPart,
in string fileName, in string fileName,
in boolean auto_groups, in boolean auto_groups,
in long minor,
in boolean overwrite, in boolean overwrite,
in boolean autoDimension, in boolean autoDimension,
in GEOM::ListOfFields fields, in GEOM::ListOfFields fields,
@ -666,6 +676,11 @@ module SMESH
void ExportSAUV( in string file, in boolean auto_groups ) void ExportSAUV( in string file, in boolean auto_groups )
raises (SALOME::SALOME_Exception); 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
* (UNV supported version is I-DEAS 10) * (UNV supported version is I-DEAS 10)

View File

@ -20,6 +20,7 @@
# --- options --- # --- options ---
# additional include directories # additional include directories
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${MEDFILE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS} ${HDF5_INCLUDE_DIRS}
${KERNEL_INCLUDE_DIRS} ${KERNEL_INCLUDE_DIRS}
${OpenCASCADE_INCLUDE_DIR} ${OpenCASCADE_INCLUDE_DIR}

View File

@ -35,6 +35,8 @@
#include "SMDS_SetIterator.hxx" #include "SMDS_SetIterator.hxx"
#include "SMESHDS_Mesh.hxx" #include "SMESHDS_Mesh.hxx"
#include <med.h>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopoDS.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) void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup)
{ {
myGroups.push_back(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); PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
//MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName()); //MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
myMed->SetMeshInfo(aMeshInfo); myMed->SetMeshInfo(aMeshInfo);

View 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 AddGroupOfNodes();
void AddGroupOfEdges(); void AddGroupOfEdges();
void AddGroupOfFaces(); void AddGroupOfFaces();
@ -87,6 +89,7 @@ class MESHDRIVERMED_EXPORT DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh
bool myAutoDimension; bool myAutoDimension;
bool myAddODOnVertices; bool myAddODOnVertices;
bool myDoAllInGroups; bool myDoAllInGroups;
int myMinor;
}; };
#endif #endif

View 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)) if (!CheckCompatibility(fileName))
remove(fileName.c_str()); remove(fileName.c_str());
return new MED::TWrapper(fileName); return new MED::TWrapper(fileName, theMinor);
} }
} }

View File

@ -43,7 +43,7 @@ namespace MED
PWrapper CrWrapperR( const std::string& ); PWrapper CrWrapperR( const std::string& );
MEDWRAPPER_EXPORT MEDWRAPPER_EXPORT
PWrapper CrWrapperW( const std::string& ); PWrapper CrWrapperW( const std::string&, int theMinor=-1 );
} }
#endif // MED_Factory_HeaderFile #endif // MED_Factory_HeaderFile

View File

@ -26,6 +26,7 @@
#include <med.h> #include <med.h>
#include <med_err.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&); TFile(const TFile&);
public: public:
TFile(const std::string& theFileName): TFile(const std::string& theFileName, TInt theMinor=-1):
myCount(0), myCount(0),
myFid(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) { if (myCount++ == 0) {
const char* aFileName = myFileName.c_str(); 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) if (theErr)
*theErr = TErr(myFid); *theErr = TErr(myFid);
else if (myFid < 0) 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; TInt myCount;
TIdt myFid; TIdt myFid;
std::string myFileName; std::string myFileName;
TInt myMinor;
}; };
//--------------------------------------------------------------- //---------------------------------------------------------------
class TFileWrapper class TFileWrapper
{ {
PFile myFile; PFile myFile;
TInt myMinor;
public: public:
TFileWrapper(const PFile& theFile, TFileWrapper(const PFile& theFile,
EModeAcces theMode, EModeAcces theMode,
TErr* theErr = NULL): TErr* theErr = NULL,
myFile(theFile) 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): ::TWrapper(const std::string& theFileName, TInt theMinor):
myFile(new TFile(theFileName)) myMinor(theMinor),
myFile(new TFile(theFileName, theMinor))
{ {
TErr aRet; TErr aRet;
myFile->Open(eLECTURE_ECRITURE, &aRet); myFile->Open(eLECTURE_ECRITURE, &aRet);
@ -208,7 +218,7 @@ namespace MED
TWrapper TWrapper
::GetNbMeshes(TErr* theErr) ::GetNbMeshes(TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -223,7 +233,7 @@ namespace MED
MED::TMeshInfo& theInfo, MED::TMeshInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -284,7 +294,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -368,7 +378,7 @@ namespace MED
::GetNbFamilies(const MED::TMeshInfo& theInfo, ::GetNbFamilies(const MED::TMeshInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -385,7 +395,7 @@ namespace MED
const MED::TMeshInfo& theInfo, const MED::TMeshInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -404,7 +414,7 @@ namespace MED
const MED::TMeshInfo& theInfo, const MED::TMeshInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -423,7 +433,7 @@ namespace MED
MED::TFamilyInfo& theInfo, MED::TFamilyInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -481,7 +491,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -603,7 +613,7 @@ namespace MED
EGeometrieElement theGeom, EGeometrieElement theGeom,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -652,7 +662,7 @@ namespace MED
EGeometrieElement theGeom, EGeometrieElement theGeom,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -694,7 +704,7 @@ namespace MED
EGeometrieElement theGeom, EGeometrieElement theGeom,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -743,7 +753,7 @@ namespace MED
EGeometrieElement theGeom, EGeometrieElement theGeom,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -785,7 +795,7 @@ namespace MED
EGeometrieElement theGeom, EGeometrieElement theGeom,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -843,7 +853,7 @@ namespace MED
EGeometrieElement theGeom, EGeometrieElement theGeom,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -890,7 +900,7 @@ namespace MED
ETable theTable, ETable theTable,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -918,7 +928,7 @@ namespace MED
::GetNodeInfo(MED::TNodeInfo& theInfo, ::GetNodeInfo(MED::TNodeInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -1009,7 +1019,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -1320,7 +1330,7 @@ namespace MED
EConnectivite theConnMode, EConnectivite theConnMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return 0; return 0;
@ -1353,7 +1363,7 @@ namespace MED
::GetPolygoneInfo(MED::TPolygoneInfo& theInfo, ::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -1412,7 +1422,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -1564,7 +1574,7 @@ namespace MED
EConnectivite theConnMode, EConnectivite theConnMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)"); EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
@ -1610,7 +1620,7 @@ namespace MED
::GetPolyedreInfo(TPolyedreInfo& theInfo, ::GetPolyedreInfo(TPolyedreInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -1673,7 +1683,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; 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) if (theErr && *theErr < 0)
return anInfo; return anInfo;
@ -1981,7 +1991,7 @@ namespace MED
EConnectivite theConnMode, EConnectivite theConnMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -2030,7 +2040,7 @@ namespace MED
::GetCellInfo(MED::TCellInfo& theInfo, ::GetCellInfo(MED::TCellInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -2097,7 +2107,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -2275,7 +2285,8 @@ namespace MED
TWrapper TWrapper
::GetBallGeom(const TMeshInfo& theMeshInfo) ::GetBallGeom(const TMeshInfo& theMeshInfo)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE); TErr anError;
TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
// read med_geometry_type of "MED_BALL" element // read med_geometry_type of "MED_BALL" element
char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME; char geotypename[ MED_NAME_SIZE + 1] = MED_BALL_NAME;
@ -2287,7 +2298,8 @@ namespace MED
TWrapper TWrapper
::GetNbBalls(const TMeshInfo& theMeshInfo) ::GetNbBalls(const TMeshInfo& theMeshInfo)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE); TErr anError;
TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
EGeometrieElement ballType = GetBallGeom(theMeshInfo); EGeometrieElement ballType = GetBallGeom(theMeshInfo);
if (ballType < 0) if (ballType < 0)
@ -2302,7 +2314,7 @@ namespace MED
::GetBallInfo(TBallInfo& theInfo, ::GetBallInfo(TBallInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
// check geometry of MED_BALL // check geometry of MED_BALL
if (theInfo.myGeom == eBALL) if (theInfo.myGeom == eBALL)
@ -2352,7 +2364,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
TErr ret; TErr ret;
char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH"; char ballsupportname[MED_NAME_SIZE+1] = "BALL_SUPPORT_MESH";
@ -2480,7 +2492,7 @@ namespace MED
TWrapper TWrapper
::GetNbFields(TErr* theErr) ::GetNbFields(TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -2494,7 +2506,7 @@ namespace MED
::GetNbComp(TInt theFieldId, ::GetNbComp(TInt theFieldId,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -2509,7 +2521,7 @@ namespace MED
MED::TFieldInfo& theInfo, MED::TFieldInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -2574,7 +2586,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -2661,7 +2673,7 @@ namespace MED
TWrapper TWrapper
::GetNbGauss(TErr* theErr) ::GetNbGauss(TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -2675,7 +2687,7 @@ namespace MED
::GetGaussPreInfo(TInt theId, ::GetGaussPreInfo(TInt theId,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0); return TGaussInfo::TInfo(TGaussInfo::TKey(ePOINT1, ""), 0);
@ -2715,7 +2727,7 @@ namespace MED
TGaussInfo& theInfo, TGaussInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -2761,7 +2773,7 @@ namespace MED
TErr* theErr) TErr* theErr)
{ {
theEntity = EEntiteMaillage(-1); theEntity = EEntiteMaillage(-1);
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr) { if (theErr) {
if (theEntityInfo.empty()) if (theEntityInfo.empty())
@ -2884,7 +2896,7 @@ namespace MED
MED::TTimeStampInfo& theInfo, MED::TTimeStampInfo& theInfo,
TErr* theErr) 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 TWrapper
::GetNbProfiles(TErr* theErr) ::GetNbProfiles(TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return -1; return -1;
@ -3051,7 +3063,7 @@ namespace MED
::GetProfilePreInfo(TInt theId, ::GetProfilePreInfo(TInt theId,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return TProfileInfo::TInfo(); return TProfileInfo::TInfo();
@ -3079,7 +3091,7 @@ namespace MED
TProfileInfo& theInfo, TProfileInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -3124,7 +3136,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -3177,7 +3189,7 @@ namespace MED
const TKey2Gauss& theKey2Gauss, const TKey2Gauss& theKey2Gauss,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -3361,7 +3373,7 @@ namespace MED
EModeAcces theMode, EModeAcces theMode,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -3698,7 +3710,7 @@ namespace MED
::GetGrilleInfo(TGrilleInfo& theInfo, ::GetGrilleInfo(TGrilleInfo& theInfo,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -3868,7 +3880,7 @@ namespace MED
{ {
if (theInfo.myMeshInfo->myType != eSTRUCTURE) if (theInfo.myMeshInfo->myType != eSTRUCTURE)
return; return;
TFileWrapper aFileWrapper(myFile, theMode, theErr); TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;
@ -4003,7 +4015,7 @@ namespace MED
EGrilleType& theGridType, EGrilleType& theGridType,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)"); EXCEPTION(std::runtime_error, " GetGrilleType - aFileWrapper (...)");
@ -4029,7 +4041,7 @@ namespace MED
TIntVector& theStruct, TIntVector& theStruct,
TErr* theErr) TErr* theErr)
{ {
TFileWrapper aFileWrapper(myFile, eLECTURE, theErr); TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0) if (theErr && *theErr < 0)
return; return;

View File

@ -52,7 +52,7 @@ namespace MED
TWrapper& operator=(const TWrapper&); TWrapper& operator=(const TWrapper&);
public: public:
TWrapper(const std::string& theFileName); TWrapper(const std::string& theFileName, TInt theMinor=-1);
virtual virtual
~TWrapper(); ~TWrapper();
@ -939,6 +939,7 @@ namespace MED
protected: protected:
PFile myFile; PFile myFile;
TInt myMinor;
}; };
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -1402,6 +1402,10 @@ bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
* \param [in] theAutoGroups - boolean parameter for creating/not creating * \param [in] theAutoGroups - boolean parameter for creating/not creating
* the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; * the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
* the typical use is auto_groups=false. * 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] meshPart - mesh data to export
* \param [in] theAutoDimension - if \c true, a space dimension of a MED mesh can be either * \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 * - 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, void SMESH_Mesh::ExportMED(const char * file,
const char* theMeshName, const char* theMeshName,
bool theAutoGroups, bool theAutoGroups,
int theMinor,
const SMESHDS_Mesh* meshPart, const SMESHDS_Mesh* meshPart,
bool theAutoDimension, bool theAutoDimension,
bool theAddODOnVertices, bool theAddODOnVertices,
@ -1427,7 +1432,7 @@ void SMESH_Mesh::ExportMED(const char * file,
SMESH_TRY; SMESH_TRY;
DriverMED_W_SMESHDS_Mesh myWriter; DriverMED_W_SMESHDS_Mesh myWriter;
myWriter.SetFile ( file ); myWriter.SetFile ( file , theMinor);
myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS ); myWriter.SetMesh ( meshPart ? (SMESHDS_Mesh*) meshPart : _myMeshDS );
myWriter.SetAutoDimension( theAutoDimension ); myWriter.SetAutoDimension( theAutoDimension );
myWriter.AddODOnVertices ( theAddODOnVertices ); myWriter.AddODOnVertices ( theAddODOnVertices );

View File

@ -254,6 +254,7 @@ class SMESH_EXPORT SMESH_Mesh
void ExportMED(const char * theFile, void ExportMED(const char * theFile,
const char* theMeshName = NULL, const char* theMeshName = NULL,
bool theAutoGroups = true, bool theAutoGroups = true,
int TheMinor = -1,
const SMESHDS_Mesh* theMeshPart = 0, const SMESHDS_Mesh* theMeshPart = 0,
bool theAutoDimension = false, bool theAutoDimension = false,
bool theAddODOnVertices = false, bool theAddODOnVertices = false,

View File

@ -655,6 +655,8 @@ namespace
// Get parameters of export operation // Get parameters of export operation
QString aFilename; QString aFilename;
int aFormat =-1; // for MED minor versions
// Init the parameters with the default values // Init the parameters with the default values
bool aIsASCII_STL = true; bool aIsASCII_STL = true;
bool toCreateGroups = false; 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; QStringList checkBoxes;
checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM"); checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM");
@ -788,6 +816,8 @@ namespace
aFilename = QString::null; aFilename = QString::null;
break; break;
} }
aFormat = aFilterMap[fd->selectedNameFilter()];
MESSAGE("selected minor: " << aFormat);
toOverwrite = fv->isOverwrite(); toOverwrite = fv->isOverwrite();
is_ok = true; is_ok = true;
if ( !aFilename.isEmpty() ) { if ( !aFilename.isEmpty() ) {
@ -879,10 +909,10 @@ namespace
const QString& geoAssFields = aFieldList[ aMeshIndex ].second; const QString& geoAssFields = aFieldList[ aMeshIndex ].second;
const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() ); const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() );
if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem )) if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem ))
aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups, aMeshItem->ExportMED( aFilename.toUtf8().data(), toCreateGroups, aFormat,
toOverwrite && aMeshIndex == 0, toFindOutDim ); toOverwrite && aMeshIndex == 0, toFindOutDim );
else else
aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups, aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups, aFormat,
toOverwrite && aMeshIndex == 0, toFindOutDim, toOverwrite && aMeshIndex == 0, toFindOutDim,
fields, geoAssFields.toLatin1().data() ); fields, geoAssFields.toLatin1().data() );
} }

View File

@ -27,6 +27,10 @@
<source>TEXT_FILES_FILTER</source> <source>TEXT_FILES_FILTER</source>
<translation>TXT files</translation> <translation>TXT files</translation>
</message> </message>
<message>
<source>MED_VX_FILES_FILTER</source>
<translation>MED %1 files</translation>
</message>
<message> <message>
<source>STL_FILES_FILTER</source> <source>STL_FILES_FILTER</source>
<translation>STL files</translation> <translation>STL files</translation>

View 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, void SMESH_Mesh_i::ExportMED(const char* file,
CORBA::Boolean auto_groups, CORBA::Boolean auto_groups,
CORBA::Long minor,
CORBA::Boolean overwrite, CORBA::Boolean overwrite,
CORBA::Boolean autoDimension) CORBA::Boolean autoDimension)
throw(SALOME::SALOME_Exception) throw(SALOME::SALOME_Exception)
{ {
//MESSAGE("SMESH::MED_VERSION:"<< theVersion); MESSAGE("MED minor version: "<< minor);
SMESH_TRY; SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
string aMeshName = prepareMeshNameAndGroups(file, overwrite); 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 << ", " << file << "', "
<< overwrite << ", " << "auto_groups=" <<auto_groups << ", "
<< autoDimension << " )"; << "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, void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file, const char* file,
CORBA::Boolean auto_groups, CORBA::Boolean auto_groups,
CORBA::Long minor,
CORBA::Boolean overwrite, CORBA::Boolean overwrite,
CORBA::Boolean autoDimension, CORBA::Boolean autoDimension,
const GEOM::ListOfFields& fields, const GEOM::ListOfFields& fields,
const char* geomAssocFields) const char* geomAssocFields)
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
MESSAGE("MED minor version: "<< minor);
SMESH_TRY; SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
@ -3164,7 +3183,7 @@ void SMESH_Mesh_i::ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
SMESH::DownCast< SMESH_Mesh_i* >( meshPart )) SMESH::DownCast< SMESH_Mesh_i* >( meshPart ))
{ {
aMeshName = prepareMeshNameAndGroups(file, overwrite); 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); 0, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = _impl->GetMeshDS(); 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); partDS, autoDimension, /*addODOnVertices=*/have0dField);
meshDS = tmpDSDeleter._obj = partDS; 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] ); GEOM::GEOM_BaseObject_var gbo = GEOM::GEOM_BaseObject::_narrow( fields[i] );
goList[i] = gbo; goList[i] = gbo;
} }
TPythonDump() << _this() << ".ExportPartToMED( " TPythonDump() << _this() << ".ExportPartToMED( r'"
<< meshPart << ", r'" << file << "', " << file << "', "
<< auto_groups << ", " << overwrite << ", " << "auto_groups=" << auto_groups << ", "
<< autoDimension << ", " << goList << "minor=" << minor << ", "
<< ", '" << ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )"; << "overwrite=" << overwrite << ", "
<< "meshPart=" << meshPart << ", "
<< "autoDimension=" << autoDimension << ", "
<< "fields=" << goList << ", geomAssocFields='"
<< ( geomAssocFields ? geomAssocFields : "" ) << "'" << " )";
SMESH_CATCH( SMESH::throwCorbaException ); SMESH_CATCH( SMESH::throwCorbaException );
} }

View File

@ -225,9 +225,14 @@ public:
* Consider maximum group name length stored in MED file. * Consider maximum group name length stored in MED file.
*/ */
CORBA::Boolean HasDuplicatedGroupNamesMED(); 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, void ExportMED( const char* file,
CORBA::Boolean auto_groups, CORBA::Boolean auto_groups,
CORBA::Long minor,
CORBA::Boolean overwrite, CORBA::Boolean overwrite,
CORBA::Boolean autoDimension = true) throw (SALOME::SALOME_Exception); CORBA::Boolean autoDimension = true) throw (SALOME::SALOME_Exception);
@ -247,6 +252,7 @@ public:
void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart, void ExportPartToMED(SMESH::SMESH_IDSource_ptr meshPart,
const char* file, const char* file,
CORBA::Boolean auto_groups, CORBA::Boolean auto_groups,
CORBA::Long minor,
CORBA::Boolean overwrite, CORBA::Boolean overwrite,
CORBA::Boolean autoDim, CORBA::Boolean autoDim,
const GEOM::ListOfFields& fields, const GEOM::ListOfFields& fields,

View File

@ -25,8 +25,18 @@ from salome.geom import geomBuilder
import SMESH # This is necessary for back compatibility import SMESH # This is necessary for back compatibility
import omniORB # back compatibility import omniORB # back compatibility
SMESH.MED_V2_1 = omniORB.EnumItem("MED_V2_1", 0) # back compatibility SMESH.MED_V2_1 = 11 #omniORB.EnumItem("MED_V2_1", 11) # back compatibility: use number > MED minor version
SMESH.MED_V2_2 = omniORB.EnumItem("MED_V2_2", 1) # back compatibility 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 SMESH import *
from salome.smesh.smesh_algorithm import Mesh_Algorithm from salome.smesh.smesh_algorithm import Mesh_Algorithm
@ -2157,6 +2167,10 @@ class Mesh(metaclass = MeshMeta):
auto_groups (boolean): parameter for creating/not creating auto_groups (boolean): parameter for creating/not creating
the groups Group_On_All_Nodes, Group_On_All_Faces, ... ; the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
the typical use is auto_groups=False. 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 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 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 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. - 's' stands for "_solids _" field.
""" """
# process positional arguments # 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] fileName = args[0]
auto_groups = args[1] if len(args) > 1 else False auto_groups = args[1] if len(args) > 1 else False
overwrite = args[2] if len(args) > 2 else True minor = args[2] if len(args) > 2 else -1
meshPart = args[3] if len(args) > 3 else None overwrite = args[3] if len(args) > 3 else True
autoDimension = args[4] if len(args) > 4 else True meshPart = args[4] if len(args) > 4 else None
fields = args[5] if len(args) > 5 else [] autoDimension = args[5] if len(args) > 5 else True
geomAssocFields = args[6] if len(args) > 6 else '' fields = args[6] if len(args) > 6 else []
geomAssocFields = args[7] if len(args) > 7 else ''
# process keywords arguments # process keywords arguments
auto_groups = kwargs.get("auto_groups", auto_groups) auto_groups = kwargs.get("auto_groups", auto_groups)
minor = kwargs.get("minor", minor)
overwrite = kwargs.get("overwrite", overwrite) overwrite = kwargs.get("overwrite", overwrite)
meshPart = kwargs.get("meshPart", meshPart) meshPart = kwargs.get("meshPart", meshPart)
autoDimension = kwargs.get("autoDimension", autoDimension) autoDimension = kwargs.get("autoDimension", autoDimension)
@ -2196,10 +2212,10 @@ class Mesh(metaclass = MeshMeta):
if isinstance( meshPart, list ): if isinstance( meshPart, list ):
meshPart = self.GetIDSource( meshPart, SMESH.ALL ) meshPart = self.GetIDSource( meshPart, SMESH.ALL )
unRegister.set( meshPart ) unRegister.set( meshPart )
self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, overwrite, autoDimension, self.mesh.ExportPartToMED( meshPart, fileName, auto_groups, minor, overwrite, autoDimension,
fields, geomAssocFields) fields, geomAssocFields)
else: 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") print("WARNING: ExportToMED() is deprecated, use ExportMED() instead")
# process positional arguments # 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] fileName = args[0]
auto_groups = args[1] if len(args) > 1 else False auto_groups = args[1] if len(args) > 1 else False
overwrite = args[2] if len(args) > 2 else True 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 auto_groups = kwargs.get("auto_groups", auto_groups) # new keyword name
overwrite = kwargs.get("overwrite", overwrite) overwrite = kwargs.get("overwrite", overwrite)
autoDimension = kwargs.get("autoDimension", autoDimension) 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") print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead")
# process positional arguments # 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] fileName = args[0]
auto_groups = args[1] if len(args) > 1 else False auto_groups = args[1] if len(args) > 1 else False
overwrite = args[2] if len(args) > 2 else True 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) auto_groups = kwargs.get("auto_groups", auto_groups)
overwrite = kwargs.get("overwrite", overwrite) overwrite = kwargs.get("overwrite", overwrite)
autoDimension = kwargs.get("autoDimension", autoDimension) 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) return SMESH._objref_SMESH_Mesh.CreateDimGroup(self, *args)
def ExportToMEDX(self, *args): # function removed def ExportToMEDX(self, *args): # function removed
print("WARNING: ExportToMEDX() is deprecated, use ExportMED() instead") 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) SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
def ExportToMED(self, *args): # function removed def ExportToMED(self, *args): # function removed
print("WARNING: ExportToMED() is deprecated, use ExportMED() instead") 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 while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
args.append(True) args.append(True)
SMESH._objref_SMESH_Mesh.ExportMED(self, *args) SMESH._objref_SMESH_Mesh.ExportMED(self, *args)
def ExportPartToMED(self, *args): # 'version' parameter removed 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) SMESH._objref_SMESH_Mesh.ExportPartToMED(self, *args)
def ExportMED(self, *args): # signature of method changed 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 while len(args) < 4: # !!!! nb of parameters for ExportToMED IDL's method
args.append(True) args.append(True)
SMESH._objref_SMESH_Mesh.ExportMED(self, *args) SMESH._objref_SMESH_Mesh.ExportMED(self, *args)