choice of MED format, minor version, for backward compatibility

This commit is contained in:
Paul RASCLE 2017-09-25 18:23:37 +02:00 committed by vsr
parent 9d73526fbc
commit 51760fb76f
13 changed files with 209 additions and 111 deletions

View File

@ -238,11 +238,28 @@ module SMESH
/*!
* Enumeration for ExportToMED*()
* MED_V2_1 and MED_V2_2 are here for compatibility and mean respectively obsolete and MED_LATEST.
* MED_MINOR_0 to MED_MINOR_9 are use to specify the minor version used by MEDfichier
* to write MED files (major version cannot be changed).
* This allows backward compatibility from a newer version of SALOME to an older one:
* for instance, a MESH produced in SALOME 8.4 (med 3.3) can be written in med 3.2 format
* to be read in SALOME 8.3.
*/
enum MED_VERSION
{
MED_V2_1,
MED_V2_2
MED_V2_2,
MED_LATEST,
MED_MINOR_0,
MED_MINOR_1,
MED_MINOR_2,
MED_MINOR_3,
MED_MINOR_4,
MED_MINOR_5,
MED_MINOR_6,
MED_MINOR_7,
MED_MINOR_8,
MED_MINOR_9
};
/*!
@ -686,8 +703,8 @@ module SMESH
raises (SALOME::SALOME_Exception);
/*!
* Export Mesh to MED_V2_1 MED format
* Works, just the same as ExportToMEDX with MED_VERSION parameter equal to MED_V2_1
* Export Mesh to MED_LATEST MED format
* Works, just the same as ExportToMEDX with MED_VERSION parameter equal to MED_LATEST
* and overwrite parameter equal to true
* The method is kept in order to support old functionality
*/

View File

@ -70,6 +70,7 @@ void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName,
{
Driver_SMESHDS_Mesh::SetFile(theFileName);
myMedVersion = theId;
//MESSAGE("myMedVersion:"<<myMedVersion);
}
void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
@ -77,19 +78,39 @@ void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& 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(const MED::EVersion theVersion, int theNbDigits)
{
TInt majeur, mineur, release;
majeur = mineur = release = 0;
// if ( theVersion == eV2_1 )
// MED::GetVersionRelease<eV2_1>(majeur, mineur, release);
// else
MED::GetVersionRelease<eV2_2>(majeur, mineur, release);
MED::GetVersionRelease<eV2_2>(majeur, mineur, release);
TInt imposedMineur = mineur;
switch( theVersion ) {
case MED::eV2_1 :
case MED::eV2_2 :
case MED::eLATEST : break;
case MED::eMINOR_0 : imposedMineur = 0; break;
case MED::eMINOR_1 : imposedMineur = 1; break;
case MED::eMINOR_2 : imposedMineur = 2; break;
case MED::eMINOR_3 : imposedMineur = 3; break;
case MED::eMINOR_4 : imposedMineur = 4; break;
case MED::eMINOR_5 : imposedMineur = 5; break;
case MED::eMINOR_6 : imposedMineur = 6; break;
case MED::eMINOR_7 : imposedMineur = 7; break;
case MED::eMINOR_8 : imposedMineur = 8; break;
case MED::eMINOR_9 : imposedMineur = 9; break;
case MED::eVUnknown : imposedMineur = mineur; break;
}
if (imposedMineur > mineur)
imposedMineur = mineur;
ostringstream name;
if ( theNbDigits > 0 )
name << majeur;
if ( theNbDigits > 1 )
name << "." << mineur;
name << "." << imposedMineur;
if ( theNbDigits > 2 )
name << "." << release;
return name.str();
@ -456,7 +477,7 @@ Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
break;
}
}
//MESSAGE("myMedVersion:"<<myMedVersion);
MED::PWrapper myMed = CrWrapper(myFile,myMedVersion);
PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
//MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());

View File

@ -44,8 +44,10 @@
#endif
namespace MED{
enum EVersion {eVUnknown = -1, eV2_1, eV2_2};
// enum EVersion sould be synchronized with enum MED_VERSION in SMESH_Mesh.idl (.hh)
// i.e. same positive values!
enum EVersion {eVUnknown = -1, eV2_1, eV2_2, eLATEST,
eMINOR_0, eMINOR_1, eMINOR_2, eMINOR_3, eMINOR_4, eMINOR_5, eMINOR_6, eMINOR_7, eMINOR_8, eMINOR_9};
typedef enum {eFAUX, eVRAI} EBooleen ;
typedef double TFloat;

View File

@ -23,7 +23,6 @@
#include "MED_Factory.hxx"
#include "MED_Utilities.hxx"
#include "MED_V2_2_Wrapper.hxx"
#include <stdio.h>
#include <errno.h>
#include <sstream>
@ -90,6 +89,7 @@ namespace MED
if(aMajor == 2 && aMinor == 1)
aVersion = eV2_1;
else
// TODO: check major is not superior to library and switch on minor
aVersion = eV2_2;
}
else {
@ -124,20 +124,19 @@ namespace MED
}
PWrapper CrWrapper(const std::string& theFileName,
bool theDoPreCheckInSeparateProcess)
bool theDoPreCheckInSeparateProcess,
int theMinor)
{
PWrapper aWrapper;
if (theMinor <0)
theMinor = MED_MINOR_NUM;
EVersion aVersion = GetVersionId(theFileName,theDoPreCheckInSeparateProcess);
switch(aVersion){
case eV2_2:
aWrapper.reset(new MED::V2_2::TVWrapper(theFileName));
break;
case eV2_1:
EXCEPTION(std::runtime_error,"Cannot open file '"<<theFileName<<"'. Med version 2.1 is not supported any more.");
//aWrapper.reset(new MED::V2_1::TVWrapper(theFileName));
break;
default:
EXCEPTION(std::runtime_error,"MED::CrWrapper - theFileName = '"<<theFileName<<"'");
aWrapper.reset(new MED::V2_2::TVWrapper(theFileName, theMinor));
}
return aWrapper;
}
@ -145,22 +144,29 @@ namespace MED
PWrapper CrWrapper(const std::string& theFileName, EVersion theId)
{
EVersion aVersion = GetVersionId(theFileName);
if (aVersion == eVUnknown) // no existing file
aVersion = theId;
if(aVersion != theId)
remove(theFileName.c_str());
PWrapper aWrapper;
switch(theId){
case eV2_2:
aWrapper.reset(new MED::V2_2::TVWrapper(theFileName));
break;
case eV2_1:
EXCEPTION(std::runtime_error,"Cannot open file '"<<theFileName<<"'. Med version 2.1 is not supported any more.");
//aWrapper.reset(new MED::V2_1::TVWrapper(theFileName));
break;
default:
aWrapper.reset(new MED::V2_2::TVWrapper(theFileName));
//remove(theFileName.c_str());
EXCEPTION(std::runtime_error,"Cannot open file for writing '"<<theFileName<<"'. existing file with another Med version.");
aVersion = theId;
int theMinor = -1; // not supported
switch (aVersion)
{
case eV2_1: break; // not supported
case eVUnknown:
case eV2_2:
case eLATEST: theMinor = MED_MINOR_NUM; break;
default: theMinor = aVersion - eMINOR_0;
}
if (theMinor < 0)
EXCEPTION(std::runtime_error,"Cannot open file '"<<theFileName<<"'. Med version 2.1 is not supported any more.");
PWrapper aWrapper;
aWrapper.reset(new MED::V2_2::TVWrapper(theFileName, theMinor));
return aWrapper;
}

View File

@ -39,7 +39,8 @@ namespace MED
MEDWRAPPER_FACTORY_EXPORT
PWrapper
CrWrapper(const std::string& theFileName,
bool theDoPreCheckInSeparateProcess = false);
bool theDoPreCheckInSeparateProcess = false,
int theMinor=-1);
MEDWRAPPER_FACTORY_EXPORT
PWrapper

View File

@ -26,6 +26,7 @@
#include <med.h>
#include <med_err.h>
#include <med_proto.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
@ -99,11 +100,14 @@ namespace MED
TFile(const TFile&);
public:
TFile(const std::string& theFileName):
TFile(const std::string& theFileName, TInt theMinor=-1):
myCount(0),
myFid(0),
myFileName(theFileName)
{}
myFileName(theFileName),
myMinor(theMinor)
{
if ((myMinor < 0) || (myMinor > MED_MINOR_NUM)) myMinor = MED_MINOR_NUM;
}
~TFile()
{
@ -115,12 +119,12 @@ namespace MED
{
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)
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& Id() const
@ -140,6 +144,7 @@ namespace MED
TInt myCount;
TIdt myFid;
std::string myFileName;
TInt myMinor;
};
@ -147,11 +152,14 @@ namespace MED
class TFileWrapper
{
PFile myFile;
TInt myMinor;
public:
TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL):
myFile(theFile)
TFileWrapper(const PFile& theFile, EModeAcces theMode, TErr* theErr = NULL, TInt theMinor=-1):
myFile(theFile),
myMinor(theMinor)
{
if (myMinor < 0) myMinor = MED_MINOR_NUM;
myFile->Open(theMode,theErr);
}
@ -163,15 +171,12 @@ namespace MED
//---------------------------------------------------------------
TVWrapper::TVWrapper(const std::string& theFileName):
myFile(new TFile(theFileName))
TVWrapper::TVWrapper(const std::string& theFileName, TInt theMinor):
myMinor(theMinor),
myFile(new TFile(theFileName, theMinor))
{
TErr aRet;
myFile->Open( eLECTURE_ECRITURE, &aRet );
// if(aRet < 0)
// myFile->Close();
// myFile->Open( eLECTURE_AJOUT, &aRet );
// }
if(aRet < 0) {
myFile->Close();
myFile->Open( eLECTURE, &aRet );
@ -188,7 +193,7 @@ namespace MED
TVWrapper
::GetNbMeshes(TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -204,7 +209,7 @@ namespace MED
MED::TMeshInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -247,7 +252,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -316,7 +321,7 @@ namespace MED
::GetNbFamilies(const MED::TMeshInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -334,7 +339,7 @@ namespace MED
const MED::TMeshInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -354,7 +359,7 @@ namespace MED
const MED::TMeshInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -374,7 +379,7 @@ namespace MED
MED::TFamilyInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -417,7 +422,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -476,7 +481,7 @@ namespace MED
EGeometrieElement theGeom,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -514,7 +519,7 @@ namespace MED
EGeometrieElement theGeom,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -552,7 +557,7 @@ namespace MED
EGeometrieElement theGeom,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -613,7 +618,7 @@ namespace MED
EGeometrieElement theGeom,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -669,7 +674,7 @@ namespace MED
EGeometrieElement theGeom,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -723,7 +728,7 @@ namespace MED
EGeometrieElement theGeom,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -761,7 +766,7 @@ namespace MED
ETable theTable,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -790,7 +795,7 @@ namespace MED
::GetNodeInfo(MED::TNodeInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -867,7 +872,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -953,7 +958,7 @@ namespace MED
::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1012,7 +1017,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1071,7 +1076,7 @@ namespace MED
EConnectivite theConnMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return 0;
@ -1105,7 +1110,7 @@ namespace MED
::GetPolyedreInfo(TPolyedreInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1168,7 +1173,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1272,7 +1277,7 @@ namespace MED
EConnectivite theConnMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
EXCEPTION(std::runtime_error,"GetPolyedreConnSize - (...)");
@ -1321,7 +1326,7 @@ namespace MED
{
TEntityInfo anInfo;
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return anInfo;
@ -1431,7 +1436,7 @@ namespace MED
EConnectivite theConnMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -1478,7 +1483,7 @@ namespace MED
//----------------------------------------------------------------------------
void TVWrapper::GetCellInfo(MED::TCellInfo& theInfo, TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1537,7 +1542,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1618,7 +1623,8 @@ namespace MED
//! Read geom type of MED_BALL structural element
EGeometrieElement TVWrapper::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;
@ -1629,7 +1635,8 @@ namespace MED
//! Read number of balls in the Mesh
TInt TVWrapper::GetNbBalls(const TMeshInfo& theMeshInfo)
{
TFileWrapper aFileWrapper(myFile,eLECTURE);
TErr anError;
TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
EGeometrieElement ballType = GetBallGeom( theMeshInfo );
if ( ballType < 0 )
@ -1642,7 +1649,7 @@ namespace MED
//! Read a MEDWrapped representation of MED_BALL from the MED file
void TVWrapper::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 )
@ -1681,7 +1688,7 @@ namespace MED
//! Write a MEDWrapped representation of MED_BALL to the MED file
void TVWrapper::SetBallInfo(const TBallInfo& theInfo, 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";
@ -1769,7 +1776,7 @@ namespace MED
TVWrapper
::GetNbFields(TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -1784,7 +1791,7 @@ namespace MED
::GetNbComp(TInt theFieldId,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -1800,7 +1807,7 @@ namespace MED
MED::TFieldInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1850,7 +1857,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1902,7 +1909,7 @@ namespace MED
TVWrapper
::GetNbGauss(TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -1917,7 +1924,7 @@ namespace MED
::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 );
@ -1958,7 +1965,7 @@ namespace MED
TGaussInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -1989,7 +1996,7 @@ namespace MED
TVWrapper
::GetNbProfiles(TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return -1;
@ -2002,7 +2009,7 @@ namespace MED
::GetProfilePreInfo(TInt theId,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return TProfileInfo::TInfo();
@ -2029,7 +2036,7 @@ namespace MED
TProfileInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -2054,7 +2061,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -2102,7 +2109,7 @@ namespace MED
TErr* theErr)
{
theEntity = EEntiteMaillage(-1);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr){
if(theEntityInfo.empty())
@ -2225,7 +2232,7 @@ namespace MED
MED::TTimeStampInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
@ -2320,7 +2327,7 @@ namespace MED
const TKey2Gauss& theKey2Gauss,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -2488,7 +2495,7 @@ namespace MED
EModeAcces theMode,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -2598,7 +2605,7 @@ namespace MED
{
if(theInfo.myMeshInfo->myType != eSTRUCTURE)
return;
TFileWrapper aFileWrapper(myFile,theMode,theErr);
TFileWrapper aFileWrapper(myFile,theMode,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -2675,7 +2682,7 @@ namespace MED
::GetGrilleInfo(TGrilleInfo& theInfo,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;
@ -2831,7 +2838,7 @@ namespace MED
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 (...)");
@ -2856,7 +2863,7 @@ namespace MED
TIntVector& theStruct,
TErr* theErr)
{
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr);
TFileWrapper aFileWrapper(myFile,eLECTURE,theErr, myMinor);
if(theErr && *theErr < 0)
return;

View File

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

View File

@ -1402,6 +1402,7 @@ void SMESH_Mesh::ExportMED(const char * file,
bool theAllElemsToGroup)
throw(SALOME_Exception)
{
//MESSAGE("MED_VERSION:"<< theVersion);
SMESH_TRY;
DriverMED_W_SMESHDS_Mesh myWriter;

View File

@ -143,6 +143,7 @@
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
#include CORBA_CLIENT_HEADER(SMESH_MeshEditor)
#include CORBA_CLIENT_HEADER(SMESH_Measurements)
#include CORBA_CLIENT_HEADER(SMESH_Mesh)
// Qt includes
// #define INCLUDE_MENUITEM_DEF // VSR commented ????????
@ -653,7 +654,7 @@ namespace
// Get parameters of export operation
QString aFilename;
SMESH::MED_VERSION aFormat = SMESH::MED_V2_2;
SMESH::MED_VERSION aFormat = SMESH::MED_LATEST;
// Init the parameters with the default values
bool aIsASCII_STL = true;
bool toCreateGroups = false;
@ -741,11 +742,17 @@ namespace
else if ( isMED || isSAUV ) // Export to MED or SAUV
{
QMap<QString, SMESH::MED_VERSION> aFilterMap;
//QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
if ( isMED ) {
QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
//aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
int minor = v22.split(".").last().toInt();
int vv= int(SMESH::MED_MINOR_0); // add all minor from 0 to current
for (int ii=0; ii<minor; ii++)
{
QString vs = aMesh->GetVersionString(SMESH::MED_VERSION(vv), 2);
aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( vs ) + " (*.med)", SMESH::MED_VERSION(vv));
vv = vv +1;
}
}
else { // isSAUV
aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
@ -826,7 +833,7 @@ namespace
}
if( !toOverwrite ) {
// can't append to an existing using other format
SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
SMESH::MED_VERSION aVersion = aFormat; //SMESH::MED_V2_1;
bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toUtf8().constData(), aVersion );
if( !isVersionOk || aVersion != aFormat ) {
int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),

View File

@ -495,6 +495,17 @@ namespace SMESH
switch (theVersion) {
case SMESH::MED_V2_1: myStream << "SMESH.MED_V2_1"; break;
case SMESH::MED_V2_2: myStream << "SMESH.MED_V2_2"; break;
case SMESH::MED_LATEST: myStream << "SMESH.MED_LATEST"; break;
case SMESH::MED_MINOR_0: myStream << "SMESH.MED_MINOR_0"; break;
case SMESH::MED_MINOR_1: myStream << "SMESH.MED_MINOR_1"; break;
case SMESH::MED_MINOR_2: myStream << "SMESH.MED_MINOR_2"; break;
case SMESH::MED_MINOR_3: myStream << "SMESH.MED_MINOR_3"; break;
case SMESH::MED_MINOR_4: myStream << "SMESH.MED_MINOR_4"; break;
case SMESH::MED_MINOR_5: myStream << "SMESH.MED_MINOR_5"; break;
case SMESH::MED_MINOR_6: myStream << "SMESH.MED_MINOR_6"; break;
case SMESH::MED_MINOR_7: myStream << "SMESH.MED_MINOR_7"; break;
case SMESH::MED_MINOR_8: myStream << "SMESH.MED_MINOR_8"; break;
case SMESH::MED_MINOR_9: myStream << "SMESH.MED_MINOR_9"; break;
default: myStream << theVersion;
}
return *this;

View File

@ -2968,8 +2968,19 @@ CORBA::Boolean SMESH_Gen_i::GetMEDVersion(const char* theFileName,
theVersion = SMESH::MED_V2_1;
MED::EVersion aVersion = MED::GetVersionId( theFileName );
switch( aVersion ) {
case MED::eV2_1 : theVersion = SMESH::MED_V2_1; return true;
case MED::eV2_2 : theVersion = SMESH::MED_V2_2; return true;
case MED::eV2_1 : theVersion = SMESH::MED_V2_1; return true;
case MED::eV2_2 : theVersion = SMESH::MED_V2_2; return true;
case MED::eLATEST : theVersion = SMESH::MED_LATEST; return true;
case MED::eMINOR_0 : theVersion = SMESH::MED_MINOR_0; return true;
case MED::eMINOR_1 : theVersion = SMESH::MED_MINOR_1; return true;
case MED::eMINOR_2 : theVersion = SMESH::MED_MINOR_2; return true;
case MED::eMINOR_3 : theVersion = SMESH::MED_MINOR_3; return true;
case MED::eMINOR_4 : theVersion = SMESH::MED_MINOR_4; return true;
case MED::eMINOR_5 : theVersion = SMESH::MED_MINOR_5; return true;
case MED::eMINOR_6 : theVersion = SMESH::MED_MINOR_6; return true;
case MED::eMINOR_7 : theVersion = SMESH::MED_MINOR_7; return true;
case MED::eMINOR_8 : theVersion = SMESH::MED_MINOR_8; return true;
case MED::eMINOR_9 : theVersion = SMESH::MED_MINOR_9; return true;
case MED::eVUnknown : return false;
}
return false;

View File

@ -3022,6 +3022,7 @@ void SMESH_Mesh_i::ExportToMEDX (const char* file,
CORBA::Boolean autoDimension)
throw(SALOME::SALOME_Exception)
{
//MESSAGE("SMESH::MED_VERSION:"<< theVersion);
SMESH_TRY;
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
@ -3048,6 +3049,7 @@ void SMESH_Mesh_i::ExportToMED (const char* file,
SMESH::MED_VERSION theVersion)
throw(SALOME::SALOME_Exception)
{
//MESSAGE("SMESH::MED_VERSION:"<< theVersion);
ExportToMEDX(file,auto_groups,theVersion,true);
}
@ -3061,7 +3063,8 @@ void SMESH_Mesh_i::ExportMED (const char* file,
CORBA::Boolean auto_groups)
throw(SALOME::SALOME_Exception)
{
ExportToMEDX(file,auto_groups,SMESH::MED_V2_2,true);
//MESSAGE("SMESH::MED_VERSION:"<< SMESH::MED_LATEST);
ExportToMEDX(file,auto_groups,SMESH::MED_LATEST,true);
}
//================================================================================

View File

@ -1793,9 +1793,14 @@ class Mesh:
# @param 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.
# @param version MED format version (MED_V2_1 or MED_V2_2,
# the latter meaning any current version). The parameter is
# obsolete since MED_V2_1 is no longer supported.
# @param version MED format version
# - MED_V2_1 is obsolete.
# - MED_V2_2 means current version (kept for compatibility reasons)
# - MED_LATEST means current version.
# - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
# to use for writing MED files, for backward compatibility :
# for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
# to allow the file to be read with SALOME 8.3.
# @param overwrite boolean parameter for overwriting/not overwriting the file
# @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
# @param autoDimension if @c True (default), a space dimension of a MED mesh can be either
@ -1811,7 +1816,7 @@ class Mesh:
# - 'f' stands for "_faces _" field;
# - 's' stands for "_solids _" field.
# @ingroup l2_impexp
def ExportMED(self, f, auto_groups=0, version=MED_V2_2,
def ExportMED(self, f, auto_groups=0, version=MED_LATEST,
overwrite=1, meshPart=None, autoDimension=True, fields=[], geomAssocFields=''):
if meshPart or fields or geomAssocFields:
unRegister = genObjUnRegister()
@ -1915,9 +1920,14 @@ class Mesh:
# Export the mesh in a file in MED format
# allowing to overwrite the file if it exists or add the exported data to its contents
# @param f the file name
# @param version MED format version (MED_V2_1 or MED_V2_2,
# the latter meaning any current version). The parameter is
# obsolete since MED_V2_1 is no longer supported.
# @param version MED format version:
# - MED_V2_1 is obsolete.
# - MED_V2_2 means current version (kept for compatibility reasons)
# - MED_LATEST means current version.
# - MED_MINOR_x where x from 0 to 9 indicates the minor version of MED
# to use for writing MED files, for backward compatibility :
# for instance, with SALOME 8.4 use MED 3.2 (minor=2) instead of 3.3,
# to allow the file to be read with SALOME 8.3.
# @param opt boolean parameter for creating/not creating
# the groups Group_On_All_Nodes, Group_On_All_Faces, ...
# @param overwrite boolean parameter for overwriting/not overwriting the file
@ -1927,7 +1937,7 @@ class Mesh:
# - 3D in the rest cases.<br>
# If @a autoDimension is @c False, the space dimension is always 3.
# @ingroup l2_impexp
def ExportToMED(self, f, version=MED_V2_2, opt=0, overwrite=1, autoDimension=True):
def ExportToMED(self, f, version=MED_LATEST, opt=0, overwrite=1, autoDimension=True):
self.mesh.ExportToMEDX(f, opt, version, overwrite, autoDimension)
# Operations with groups: