using namespace MED;
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+
DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh():
myAllSubMeshes (false),
myDoGroupOfNodes (false),
myAddODOnVertices(false),
myDoAllInGroups(false),
myVersion(-1),
- myZTolerance(-1.)
+ myZTolerance(-1.),
+ mySaveNumbers(true)
{}
+//================================================================================
+/*!
+ * \brief Set a file name and a version
+ * \param [in] theFileName - output file name
+ * \param [in] theVersion - desired MED file version == major * 10 + minor
+ */
+//================================================================================
+
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;
myDoGroupOfBalls = true;
}
-//================================================================================
-/*!
- * \brief Set up a flag to add all elements not belonging to any group to
- * some auxiliary group. This is needed for SMESH -> SAUVE -> SMESH conversion,
- * which since PAL0023285 reads only SAUVE elements belonging to any group,
- * and hence can lose some elements. That auxiliary group is ignored while
- * reading a MED file.
- */
-//================================================================================
-
-void DriverMED_W_SMESHDS_Mesh::AddAllToGroup()
-{
- myDoAllInGroups = true;
-}
-
namespace
{
+ //---------------------------------------------
+ /*!
+ * \brief Retrieving node coordinates utilities
+ */
+ //---------------------------------------------
+
typedef double (SMDS_MeshNode::* TGetCoord)() const;
typedef const char* TName;
typedef const char* TUnit;
}
}
+//================================================================================
+/*!
+ * \brief Write my mesh to a file
+ */
+//================================================================================
+
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform()
{
MED::PWrapper myMed = CrWrapperW(myFile, myVersion);
return this->PerformInternal<MED::PWrapper>(myMed);
}
+//================================================================================
+/*!
+ * \brief Write my mesh to a MEDCoupling DS
+ */
+//================================================================================
+
Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh_Mem::Perform()
{
void *ptr(nullptr);
std::size_t sz(0);
Driver_Mesh::Status status = Driver_Mesh::DRS_OK;
bool isClosed(false);
- TMemFile *tfileInst = nullptr;
{// let braces to flush (call of MED::PWrapper myMed destructor)
- tfileInst = new TMemFile(&isClosed);
+ TMemFile *tfileInst = new TMemFile(&ptr,&sz,&isClosed);// this new will be destroyed by destructor of myMed
MED::PWrapper myMed = CrWrapperW(myFile, -1, tfileInst);
status = this->PerformInternal<MED::PWrapper>(myMed);
}
- if(tfileInst)
- {
- ptr = tfileInst->getData(); sz = tfileInst->getSize();
- }
+ if(!isClosed)
+ EXCEPTION(std::runtime_error, "TFTMemFile destructor : on destruction file has not been closed properly -> chunk of memory data may be invalid !");
_data = MEDCoupling::DataArrayByte::New();
_data->useArray(reinterpret_cast<char *>(ptr),true,MEDCoupling::DeallocType::C_DEALLOC,sz,1);
if(!isClosed)
#endif
const EModeSwitch theMode = eFULL_INTERLACE;
const ERepere theSystem = eCART;
- const EBooleen theIsElemNum = eVRAI;
+ const EBooleen theIsElemNum = mySaveNumbers ? eVRAI : eFAUX;
const EBooleen theIsElemNames = eFAUX;
const EConnectivite theConnMode = eNOD;
theIsElemNames);
TInt aNbNodes = MED::GetNbNodes(aElemTypeData->_geomType);
+
elemIterator = myMesh->elementsIterator( aElemTypeData->_smdsType );
if ( aElemTypeData->_smdsType == SMDSAbs_0DElement && ! nodesOf0D.empty() )
elemIterator = iterVecIter;
+
while ( elemIterator->more() )
{
const SMDS_MeshElement* anElem = elemIterator->next();
if ( ++iElem == aCellInfo->GetNbElem() )
break;
}
+ // fix numbers of added SMDSAbs_0DElement
+ if ( aElemTypeData->_smdsType == SMDSAbs_0DElement && ! nodesOf0D.empty() )
+ {
+ iElem = myMesh->Nb0DElements();
+ TInt elem0DNum = FromSmIdType<TInt>( myMesh->MaxElementID() + 1 );
+ for ( size_t i = 0; i < nodesOf0D.size(); ++i )
+ aCellInfo->SetElemNum( iElem++, elem0DNum++);
+ }
+
// store data in a file
myMed->SetCellInfo(aCellInfo);
}