* 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
*/
void ExportMED( in string fileName,
in boolean auto_groups,
+ in long minor,
in boolean overwrite,
in boolean autoDimension) raises (SALOME::SALOME_Exception);
* - 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.
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,
*/
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
# --- options ---
# additional include directories
INCLUDE_DIRECTORIES(
+ ${MEDFILE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${KERNEL_INCLUDE_DIRS}
${OpenCASCADE_INCLUDE_DIR}
#include "SMDS_SetIterator.hxx"
#include "SMESHDS_Mesh.hxx"
+#include <med.h>
+
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
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);
}
+/*!
+ * 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);
}
}
- 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);
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; }
+ static std::string GetVersionString(int theVersion, int theNbDigits=2);
+
void AddGroupOfNodes();
void AddGroupOfEdges();
void AddGroupOfFaces();
bool myAutoDimension;
bool myAddODOnVertices;
bool myDoAllInGroups;
+ int myMinor;
};
#endif
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());
- return new MED::TWrapper(fileName);
+ return new MED::TWrapper(fileName, theMinor);
}
}
PWrapper CrWrapperR( const std::string& );
MEDWRAPPER_EXPORT
- PWrapper CrWrapperW( const std::string& );
+ PWrapper CrWrapperW( const std::string&, int theMinor=-1 );
}
#endif // MED_Factory_HeaderFile
#include <med.h>
#include <med_err.h>
+#include <med_proto.h>
#include <boost/version.hpp>
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()
{
{
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&
TInt myCount;
TIdt myFid;
std::string myFileName;
+ TInt myMinor;
};
//---------------------------------------------------------------
class TFileWrapper
{
PFile myFile;
+ TInt myMinor;
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);
}
//---------------------------------------------------------------
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);
TWrapper
::GetNbMeshes(TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
MED::TMeshInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
::GetNbFamilies(const MED::TMeshInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
const MED::TMeshInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
const MED::TMeshInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
MED::TFamilyInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EGeometrieElement theGeom,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EGeometrieElement theGeom,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EGeometrieElement theGeom,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EGeometrieElement theGeom,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EGeometrieElement theGeom,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EGeometrieElement theGeom,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
ETable theTable,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
::GetNodeInfo(MED::TNodeInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EConnectivite theConnMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return 0;
::GetPolygoneInfo(MED::TPolygoneInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EConnectivite theConnMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
EXCEPTION(std::runtime_error, "GetPolyedreConnSize - (...)");
::GetPolyedreInfo(TPolyedreInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
{
TEntityInfo anInfo;
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return anInfo;
EConnectivite theConnMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
::GetCellInfo(MED::TCellInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
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;
TWrapper
::GetNbBalls(const TMeshInfo& theMeshInfo)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE);
+ TErr anError;
+ TFileWrapper aFileWrapper(myFile, eLECTURE, &anError, myMinor);
EGeometrieElement ballType = GetBallGeom(theMeshInfo);
if (ballType < 0)
::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)
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";
TWrapper
::GetNbFields(TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
::GetNbComp(TInt theFieldId,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
MED::TFieldInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
TWrapper
::GetNbGauss(TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
::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);
TGaussInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
TErr* theErr)
{
theEntity = EEntiteMaillage(-1);
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr) {
if (theEntityInfo.empty())
MED::TTimeStampInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
const TGeom2Size& aGeom2Size = theInfo.myGeom2Size;
TWrapper
::GetNbProfiles(TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return -1;
::GetProfilePreInfo(TInt theId,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return TProfileInfo::TInfo();
TProfileInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
const TKey2Gauss& theKey2Gauss,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
EModeAcces theMode,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
::GetGrilleInfo(TGrilleInfo& theInfo,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
{
if (theInfo.myMeshInfo->myType != eSTRUCTURE)
return;
- TFileWrapper aFileWrapper(myFile, theMode, theErr);
+ TFileWrapper aFileWrapper(myFile, theMode, theErr, myMinor);
if (theErr && *theErr < 0)
return;
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 (...)");
TIntVector& theStruct,
TErr* theErr)
{
- TFileWrapper aFileWrapper(myFile, eLECTURE, theErr);
+ TFileWrapper aFileWrapper(myFile, eLECTURE, theErr, myMinor);
if (theErr && *theErr < 0)
return;
TWrapper& operator=(const TWrapper&);
public:
- TWrapper(const std::string& theFileName);
+ TWrapper(const std::string& theFileName, TInt theMinor=-1);
virtual
~TWrapper();
protected:
PFile myFile;
+ TInt myMinor;
};
//----------------------------------------------------------------------------
* \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
void SMESH_Mesh::ExportMED(const char * file,
const char* theMeshName,
bool theAutoGroups,
+ int theMinor,
const SMESHDS_Mesh* meshPart,
bool theAutoDimension,
bool theAddODOnVertices,
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 );
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,
// 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;
}
else if ( isMED || isSAUV ) // Export to MED or SAUV
{
- QStringList filters;
+ QMap<QString, int> aFilterMap;
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
- 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");
aFilename = QString::null;
break;
}
+ aFormat = aFilterMap[fd->selectedNameFilter()];
+ MESSAGE("selected minor: " << aFormat);
toOverwrite = fv->isOverwrite();
is_ok = true;
if ( !aFilename.isEmpty() ) {
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
- aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups,
+ aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups, aFormat,
toOverwrite && aMeshIndex == 0, toFindOutDim,
fields, geoAssFields.toLatin1().data() );
}
<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>
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
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)
{
- //MESSAGE("SMESH::MED_VERSION:"<< theVersion);
+ MESSAGE("MED minor version: "<< minor);
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'"
- << file << "', " << auto_groups << ", "
- << overwrite << ", "
- << autoDimension << " )";
+ << file << "', "
+ << "auto_groups=" <<auto_groups << ", "
+ << "minor=" << minor << ", "
+ << "overwrite=" << overwrite << ", "
+ << "meshPart=None, "
+ << "autoDimension=" << autoDimension << " )";
SMESH_CATCH( SMESH::throwCorbaException );
}
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)
{
+ MESSAGE("MED minor version: "<< minor);
SMESH_TRY;
if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile();
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();
}
}
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;
}
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 );
}
* 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,
+ CORBA::Long minor,
CORBA::Boolean overwrite,
CORBA::Boolean autoDimension = true) throw (SALOME::SALOME_Exception);
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,
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
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
- '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
- 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)
+ minor = kwargs.get("minor", minor)
overwrite = kwargs.get("overwrite", overwrite)
meshPart = kwargs.get("meshPart", meshPart)
autoDimension = kwargs.get("autoDimension", autoDimension)
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:
- self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+ self.mesh.ExportMED(fileName, auto_groups, minor, overwrite, autoDimension)
def ExportSAUV(self, f, auto_groups=0):
"""
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
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
- self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+ self.mesh.ExportMED(fileName, auto_groups, minor, overwrite, autoDimension)
def ExportToMEDX(self, *args, **kwargs):
"""
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
auto_groups = kwargs.get("auto_groups", auto_groups)
overwrite = kwargs.get("overwrite", overwrite)
autoDimension = kwargs.get("autoDimension", autoDimension)
+ minor = -1
# invoke engine's function
- self.mesh.ExportMED(fileName, auto_groups, overwrite, autoDimension)
+ self.mesh.ExportMED(fileName, auto_groups, minor, overwrite, autoDimension)
# Operations with groups:
# ----------------------
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")
- 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
- 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
- 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)