-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "SMDS_SetIterator.hxx"
#include "SMESHDS_Mesh.hxx"
+#include <med.h>
+
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
myDoGroupOfBalls(false),
myAutoDimension(false),
myAddODOnVertices(false),
- myDoAllInGroups(false)
+ myDoAllInGroups(false),
+ myVersion(-1),
+ myZTolerance(-1.)
{}
-void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName)
+void DriverMED_W_SMESHDS_Mesh::SetFile(const std::string& theFileName, int theVersion)
{
+ myVersion = theVersion;
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 theMinor, int theNbDigits)
+{
+ TInt majeur, mineur, release;
+ majeur=MED_MAJOR_NUM;
+ mineur=MED_MINOR_NUM;
+ release=MED_RELEASE_NUM;
+ TInt imposedMineur = mineur;
+
+ if (theMinor < 0)
+ imposedMineur = mineur;
+ else if (theMinor > MED_MINOR_NUM)
+ imposedMineur = mineur;
+ else
+ imposedMineur = theMinor;
+
+ 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);
anIsXDimension = (aBounds[1] - aBounds[0]) + abs(aBounds[1]) + abs(aBounds[0]) > EPS;
anIsYDimension = (aBounds[3] - aBounds[2]) + abs(aBounds[3]) + abs(aBounds[2]) > EPS;
anIsZDimension = (aBounds[5] - aBounds[4]) + abs(aBounds[5]) + abs(aBounds[4]) > EPS;
+ if ( myZTolerance > 0 && anIsZDimension )
+ anIsZDimension = (aBounds[5] > myZTolerance || aBounds[4] < -myZTolerance );
aSpaceDimension = Max( aMeshDimension, anIsXDimension + anIsYDimension + anIsZDimension );
if ( !aSpaceDimension )
aSpaceDimension = 3;
}
}
- MED::PWrapper myMed = CrWrapperW(myFile);
+ MED::PWrapper myMed = CrWrapperW(myFile, myVersion);
PMeshInfo aMeshInfo = myMed->CrMeshInfo(aMeshDimension,aSpaceDimension,aMeshName);
//MESSAGE("Add - aMeshName : "<<aMeshName<<"; "<<aMeshInfo->GetName());
myMed->SetMeshInfo(aMeshInfo);
for(TInt iCoord = 0; iCoord < aSpaceDimension; iCoord++){
aTCoordSlice[iCoord] = aCoordHelperPtr->GetCoord(iCoord);
}
+ if ( aSpaceDimension == 3 &&
+ -myZTolerance < aTCoordSlice[2] && aTCoordSlice[2] < myZTolerance )
+ aTCoordSlice[2] = 0.;
+
// node number
int aNodeID = aCoordHelperPtr->GetID();
aNodeInfo->SetElemNum( iNode, aNodeID );