void MEDFileData::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
const MEDFileMeshes *ms=_meshes;
if(ms)
- ms->write(fileName,mode);
- int mode2=mode==2?0:mode;
+ ms->write(fid);
const MEDFileFields *fs=_fields;
if(fs)
- fs->write(fileName,mode2);
+ fs->writeLL(fid);
}
return new MEDFileField1TS;
}
-void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
- med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
int nbComp=_infos.size();
INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
MEDfieldCr(fid,_name.c_str(),MED_FLOAT64,nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
writeGlobals(fid,*this);
+ MEDFileField1TSWithoutDAS::writeLL(fid);
+}
+
+void MEDFileField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
writeLL(fid);
}
return oss.str();
}
+void MEDFileFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
+{
+ writeGlobals(fid,*this);
+ MEDFileFieldMultiTSWithoutDAS::writeLL(fid);
+}
+
void MEDFileFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
{
med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
- writeGlobals(fid,*this);
writeLL(fid);
}
throw e;
}
-void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
int i=0;
- med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
writeGlobals(fid,*this);
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutDAS> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
}
}
+void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ writeLL(fid);
+}
+
std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
{
std::vector<std::string> ret;
//
static MEDFileField1TSWithoutDAS *New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
- void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ virtual void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPflsReallyUsed2() const;
std::vector<std::string> getLocsReallyUsed2() const;
static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
private:
+ void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPflsReallyUsed() const;
std::vector<std::string> getLocsReallyUsed() const;
MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
std::vector< std::pair<int,int> > getIterations() const;
std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<const DataArrayDouble *> > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
- void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
+ virtual void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
std::string getName() const;
std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutDAS& other);
std::string simpleRepr() const;
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
static MEDFileFields *New();
static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
int getNumberOfFields() const;
std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
}
}
+void MEDFileMesh::write(med_idt fid) const throw(INTERP_KERNEL::Exception)
+{
+ if(!existsFamily(0))
+ const_cast<MEDFileMesh *>(this)->addFamily(DFT_FAM_NAME,0);
+ if(_name.empty())
+ throw INTERP_KERNEL::Exception("MEDFileMesh : name is empty. MED file ask for a NON EMPTY name !");
+ writeLL(fid);
+}
+
+void MEDFileMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ write(fid);
+}
+
bool MEDFileMesh::isEqual(const MEDFileMesh *other, double eps, std::string& what) const
{
if(_order!=other->_order)
{
}
-void MEDFileUMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileUMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
- if(_name.empty())
- throw INTERP_KERNEL::Exception("MEDFileUMesh : name is empty. MED file ask for a NON EMPTY name !");
- if(!existsFamily(0))
- (const_cast<MEDFileUMesh *>(this))->addFamily(DFT_FAM_NAME,0);
- med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
- std::ostringstream oss; oss << "MEDFileUMesh : error on attempt to write in file : \"" << fileName << "\"";
- MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
const DataArrayDouble *coo=_coords;
INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
_cmesh=m;
}
-void MEDFileCMesh::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileCMesh::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
- if(_name.empty())
- throw INTERP_KERNEL::Exception("MEDFileCMesh : name is empty. MED file ask for a NON EMPTY name !");
- if(!existsFamily(0))
- (const_cast<MEDFileCMesh *>(this))->addFamily(DFT_FAM_NAME,0);
- med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
- std::ostringstream oss; oss << "MEDFileCMesh : error on attempt to write in file : \"" << fileName << "\"";
- MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
INTERP_KERNEL::AutoPtr<char> maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
_mesh_one_ts[0]=mesh1TimeStep;
}
-void MEDFileMeshMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileMeshMultiTS::write(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++)
{
(*it)->copyOptionsFrom(*this);
- (*it)->write(fileName,mode);
+ (*it)->write(fid);
}
}
+void MEDFileMeshMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ write(fid);
+}
+
void MEDFileMeshMultiTS::loadFromFile(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception)
{//for the moment to be improved
_mesh_one_ts.resize(1);
return new MEDFileMeshes(fileName);
}
-void MEDFileMeshes::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+void MEDFileMeshes::write(med_idt fid) const throw(INTERP_KERNEL::Exception)
{
checkCoherency();
- int i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++,i++)
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++)
{
- int mode2=mode;
- if(mode==2 && i>0)
- mode2=0;
(*it)->copyOptionsFrom(*this);
- (*it)->write(fileName,mode2);
+ (*it)->write(fid);
}
}
+void MEDFileMeshes::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
+{
+ med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
+ MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
+ std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\"";
+ MEDFileUtilities::CheckMEDCode(fid,fid,oss.str().c_str());
+ checkCoherency();
+ write(fid);
+}
+
int MEDFileMeshes::getNumberOfMeshes() const throw(INTERP_KERNEL::Exception)
{
return _meshes.size();
const char *getTimeUnit() const { return _dt_unit.c_str(); }
virtual std::vector<int> getNonEmptyLevels() const = 0;
virtual std::vector<int> getNonEmptyLevelsExt() const = 0;
- virtual void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception) = 0;
+ virtual void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ virtual void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
virtual int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception) = 0;
//
bool existsFamily(int famId) const;
bool existsFamily(const char *familyName) const;
void setFamilyId(const char *familyName, int id);
- void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
+ virtual void addFamily(const char *familyName, int id) throw(INTERP_KERNEL::Exception);
void addGrpOnFamily(const char *grpName, const char *famName) throw(INTERP_KERNEL::Exception);
void setFamilyInfo(const std::map<std::string,int>& info);
void setGroupInfo(const std::map<std::string, std::vector<std::string> >&info);
virtual DataArrayInt *getNodeFamiliesArr(const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
protected:
MEDFileMesh();
+ virtual void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception) = 0;
void dealWithTinyInfo(const MEDCouplingMesh *m) throw(INTERP_KERNEL::Exception);
virtual void synchronizeTinyInfoOnLeaves() const = 0;
void getFamilyRepr(std::ostream& oss) const;
void clearNonDiscrAttributes() const;
~MEDFileUMesh();
//
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getMeshDimension() const throw(INTERP_KERNEL::Exception);
int getSpaceDimension() const throw(INTERP_KERNEL::Exception);
std::string simpleRepr() const;
void setGroupsOnSetMesh(int meshDimRelToMax, const std::vector<const MEDCouplingUMesh *>& ms, bool renum) throw(INTERP_KERNEL::Exception);
void optimizeFamilies() throw(INTERP_KERNEL::Exception);
private:
+ void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
MEDFileUMesh();
MEDFileUMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
void loadUMeshFromFile(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
const MEDCouplingCMesh *getMesh() const;
MEDCouplingMesh *getGenMeshAtLevel(int meshDimRelToMax, bool renum=false) const throw(INTERP_KERNEL::Exception);
void setMesh(MEDCouplingCMesh *m) throw(INTERP_KERNEL::Exception);
- void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
DataArrayInt *getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum=false) const throw(INTERP_KERNEL::Exception);
void setFamilyFieldArr(int meshDimRelToMaxExt, DataArrayInt *famArr) throw(INTERP_KERNEL::Exception);
const DataArrayInt *getNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
const DataArrayInt *getRevNumberFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception);
private:
+ void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
MEDFileCMesh();
void synchronizeTinyInfoOnLeaves() const;
MEDFileCMesh(med_idt fid, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception);
static MEDFileMeshMultiTS *New(const char *fileName, const char *mName) throw(INTERP_KERNEL::Exception);
const char *getName() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *getOneTimeStep() const throw(INTERP_KERNEL::Exception);
+ void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception);
private:
std::string simpleRepr() const;
void simpleReprWithoutHeader(std::ostream& oss) const;
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
+ void write(med_idt fid) const throw(INTERP_KERNEL::Exception);
int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception);
MEDFileMesh *getMeshAtPos(int i) const throw(INTERP_KERNEL::Exception);
MEDFileMesh *getMeshWithName(const char *mname) const throw(INTERP_KERNEL::Exception);