SET(medloader_SOURCES
MEDLoader.cxx
MEDLoaderBase.cxx
+ MEDLoaderTraits.cxx
MEDFileUtilities.cxx
MEDFileMesh.cxx
MEDFileMeshElt.cxx
MEDFileData *MEDFileData::New(const std::string& fileName)
{
- return new MEDFileData(fileName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid);
+}
+
+MEDFileData *MEDFileData::New(med_idt fid)
+{
+ return new MEDFileData(fid);
}
MEDFileData *MEDFileData::New()
{
}
-MEDFileData::MEDFileData(const std::string& fileName)
+MEDFileData::MEDFileData(med_idt fid)
try
{
- _fields=MEDFileFields::New(fileName);
- _meshes=MEDFileMeshes::New(fileName);
- _params=MEDFileParameters::New(fileName);
+ _fields=MEDFileFields::New(fid);
+ _meshes=MEDFileMeshes::New(fid);
+ _params=MEDFileParameters::New(fid);
}
catch(INTERP_KERNEL::Exception& e)
{
{
public:
MEDLOADER_EXPORT static MEDFileData *New(const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileData *New(med_idt fid);
MEDLOADER_EXPORT static MEDFileData *New();
MEDLOADER_EXPORT MEDFileData *deepCopy() const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
private:
MEDFileData();
- MEDFileData(const std::string& fileName);
+ MEDFileData(med_idt fid);
private:
MCAuto<MEDFileFields> _fields;
MCAuto<MEDFileMeshes> _meshes;
MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return MEDFileIntField1TS::New(fid,loadAll);
+}
+
+MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
+{
MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
ret->contentNotNull();
return ret.retn();
MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return MEDFileIntField1TS::New(fid,fieldName,loadAll);
+}
+
+MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
+{
MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
ret->contentNotNull();
return ret.retn();
MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
+}
+
+MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
+{
MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
ret->contentNotNull();
return ret.retn();
return ret.retn();
}
-MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
{
if(!c)
throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
{
MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
- ret->setFileName(fileName);
ret->_content=c; c->incrRef();
return ret.retn();
}
if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
{
MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
- ret->setFileName(fileName);
ret->_content=c; c->incrRef();
return ret.retn();
}
throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
}
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
+{
+ MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
+ std::string fileName(FileNameFromFID(fid));
+ ret->setFileName(fileName);
+ return ret;
+}
+
MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
try:MEDFileFieldGlobsReal(fid)
{
MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,loadAll);
+}
+
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
+{
MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
- MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fileName));
+ MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
ret->loadGlobals(fid);
return ret.retn();
}
MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,fieldName,loadAll);
+}
+
+MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
+{
MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
- MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
+ MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
ret->loadGlobals(fid);
return ret.retn();
}
MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,loadAll);
+}
+
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
+{
MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
ret->contentNotNull();//to check that content type matches with \a this type.
return ret.retn();
MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,fieldName,loadAll);
+}
+
+MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
+{
MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
ret->contentNotNull();//to check that content type matches with \a this type.
return ret.retn();
if(!contc)
throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
- ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
+ ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
}
else
ret=MEDFileIntFieldMultiTS::New();
MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,loadAll);
+}
+
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
+{
MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
ret->contentNotNull();//to check that content type matches with \a this type.
return ret.retn();
MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,fieldName,loadAll);
+}
+
+MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
+{
MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
ret->contentNotNull();//to check that content type matches with \a this type.
return ret.retn();
if(!contc)
throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
- ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
+ ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
}
else
ret=MEDFileFieldMultiTS::New();
MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
{
MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,loadAll);
+}
+
+MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
+{
return new MEDFileFields(fid,loadAll,0,0);
}
MEDFileFields *MEDFileFields::deepCopy() const
{
- MCAuto<MEDFileFields> ret=shallowCpy();
- std::size_t i=0;
+ MCAuto<MEDFileFields> ret(shallowCpy());
+ std::size_t i(0);
for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
std::vector<std::string> MEDFileFields::getFieldsNames() const
{
std::vector<std::string> ret(_fields.size());
- int i=0;
+ int i(0);
for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
{
const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
{
- int nbOfFields=getNumberOfFields();
+ int nbOfFields(getNumberOfFields());
std::string startLine(bkOffset,' ');
oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
int i=0;
std::set<std::string> ret2;
for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
- std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
+ std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
if(ret2.find(*it2)==ret2.end())
{
std::vector<std::string> ret;
for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
- std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
+ std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
ret.insert(ret.end(),tmp.begin(),tmp.end());
}
return ret;
std::vector<std::string> ret;
for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
- std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
+ std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
ret.insert(ret.end(),tmp.begin(),tmp.end());
}
return ret;
void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
{
static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
- int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
+ int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
std::vector<bool> b(_fields.size(),true);
int k=bg;
for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
b[k]=false;
}
std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
- std::size_t j=0;
+ std::size_t j(0);
for(std::size_t i=0;i<_fields.size();i++)
if(b[i])
fields[j++]=_fields[i];
bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
{
- bool ret=false;
+ bool ret(false);
for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
{
MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
*/
bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
{
- bool ret=false;
+ bool ret(false);
for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
{
MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
if(!fmts)
return 0;
MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
- const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
- const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
+ const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
+ const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
if(fmtsC)
ret=MEDFileFieldMultiTS::New(*fmtsC,false);
else if(fmtsC2)
*/
MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
{
- MCAuto<MEDFileFields> ret=MEDFileFields::New();
+ MCAuto<MEDFileFields> ret(MEDFileFields::New());
for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
- const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
if(!cur)
continue;
if(cur->getMeshName()==meshName)
*/
MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
{
- MCAuto<MEDFileFields> ret=MEDFileFields::New();
+ MCAuto<MEDFileFields> ret(MEDFileFields::New());
for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
- const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
if(!cur)
continue;
MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
MCAuto<MEDFileFields> ret=MEDFileFields::New();
for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
{
- const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
if(!cur)
continue;
MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
std::vector<std::string> poss;
for(std::size_t i=0;i<_fields.size();i++)
{
- const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
+ const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
if(f)
{
std::string fname(f->getName());
public:
MEDLOADER_EXPORT static MEDFileIntField1TS *New();
MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntField1TS *New(med_idt fid, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntField1TS *New(med_idt fid, const std::string& fieldName, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntField1TS *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntField1TS *New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms);
MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities=0);
MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
- static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName);
+ static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c);
+ static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid);
static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms);
static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
public:
MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(med_idt fid, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(med_idt fid, const std::string& fieldName, bool loadAll=true);
MEDLOADER_EXPORT void loadArrays();
MEDLOADER_EXPORT void loadArraysIfNecessary();
MEDLOADER_EXPORT void unloadArrays();
public:
MEDLOADER_EXPORT static MEDFileFieldMultiTS *New();
MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(med_idt fid, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(med_idt fid, const std::string& fieldName, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT static MEDFileFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll=true);
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
public:
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New();
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(med_idt fid, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(med_idt fid, const std::string& fieldName, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll=true);
MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
public:
MEDLOADER_EXPORT static MEDFileFields *New();
MEDLOADER_EXPORT static MEDFileFields *New(const std::string& fileName, bool loadAll=true);
+ MEDLOADER_EXPORT static MEDFileFields *New(med_idt fid, bool loadAll=true);
MEDLOADER_EXPORT static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0);
MEDLOADER_EXPORT static MEDFileFields *LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll=true);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
#include "MEDFileFieldOverView.hxx"
#include "MEDFileField.hxx"
#include "MEDLoader.hxx"
+#include "MEDLoaderNS.hxx"
#include "MEDFileSafeCaller.txx"
#include "MEDLoaderBase.hxx"
*/
MEDFileMesh *MEDFileMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
- std::vector<std::string> ms=MEDCoupling::GetMeshNames(fileName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mrs);
+}
+
+MEDFileMesh *MEDFileMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs)
+{
+ std::vector<std::string> ms(MEDLoaderNS::getMeshNamesFid(fid));
if(ms.empty())
{
- std::ostringstream oss; oss << "MEDFileMesh::New : no meshes in file \"" << fileName << "\" !";
+ std::ostringstream oss; oss << "MEDFileMesh::New : no meshes in file \"" << FileNameFromFID(fid) << "\" !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDFileUtilities::CheckFileForRead(fileName);
MEDCoupling::MEDCouplingMeshType meshType;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
std::string dummy2;
MEDCoupling::MEDCouplingAxisType dummy3;
*/
MEDFileMesh *MEDFileMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs, MEDFileJoints* joints)
{
- MEDFileUtilities::CheckFileForRead(fileName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mName,dt,it,mrs,joints);
+}
+
+MEDFileMesh *MEDFileMesh::New(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs, MEDFileJoints* joints)
+{
MEDCoupling::MEDCouplingMeshType meshType;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dummy0,dummy1;
std::string dummy2;
MEDCoupling::MEDCouplingAxisType dummy3;
*/
MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mName,dt,it,mrs);
+}
+
+MEDFileUMesh *MEDFileUMesh::New(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+{
return new MEDFileUMesh(fid,mName,dt,it,mrs);
}
*/
MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
- std::vector<std::string> ms(MEDCoupling::GetMeshNames(fileName));
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mrs);
+}
+
+template<class T>
+T *NewForTheFirstMeshInFile(med_idt fid, MEDFileMeshReadSelector *mrs)
+{
+ std::vector<std::string> ms(MEDLoaderNS::getMeshNamesFid(fid));
if(ms.empty())
{
- std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ std::ostringstream oss; oss << MLMeshTraits<T>::ClassName << "::New : no meshes in file \"" << MEDFileWritable::FileNameFromFID(fid) << "\" !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
MEDCoupling::MEDCouplingMeshType meshType;
std::string dummy2;
MEDCoupling::MEDCouplingAxisType dummy3;
MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
- return new MEDFileUMesh(fid,ms.front(),dt,it,mrs);
+ return T::New(fid,ms.front(),dt,it,mrs);
+}
+
+MEDFileUMesh *MEDFileUMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs)
+{
+ return NewForTheFirstMeshInFile<MEDFileUMesh>(fid,mrs);
}
/*!
*/
MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
- std::vector<std::string> ms(MEDCoupling::GetMeshNames(fileName));
- if(ms.empty())
- {
- std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- int dt,it;
- MEDCoupling::MEDCouplingMeshType meshType;
- std::string dummy2;
- MEDCoupling::MEDCouplingAxisType dummy3;
- MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
- return new MEDFileCMesh(fid,ms.front(),dt,it,mrs);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mrs);
+}
+
+MEDFileCMesh *MEDFileCMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs)
+{
+ return NewForTheFirstMeshInFile<MEDFileCMesh>(fid,mrs);
}
/*!
*/
MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mName,dt,it,mrs);
+}
+
+MEDFileCMesh *MEDFileCMesh::New(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+{
return new MEDFileCMesh(fid,mName,dt,it,mrs);
}
return new MEDFileCurveLinearMesh;
}
+MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs)
+{
+ return NewForTheFirstMeshInFile<MEDFileCurveLinearMesh>(fid,mrs);
+}
+
MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs)
{
- std::vector<std::string> ms(MEDCoupling::GetMeshNames(fileName));
- if(ms.empty())
- {
- std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- int dt,it;
- MEDCoupling::MEDCouplingMeshType meshType;
- MEDCoupling::MEDCouplingAxisType dummy3;
- std::string dummy2;
- MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
- return new MEDFileCurveLinearMesh(fid,ms.front(),dt,it,mrs);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mrs);
}
MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mName,dt,it,mrs);
+}
+
+MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+{
return new MEDFileCurveLinearMesh(fid,mName,dt,it,mrs);
}
return new MEDFileMeshMultiTS;
}
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(med_idt fid)
+{
+ return new MEDFileMeshMultiTS(fid);
+}
+
MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const std::string& fileName)
{
- return new MEDFileMeshMultiTS(fileName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid);
+}
+
+MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(med_idt fid, const std::string& mName)
+{
+ return new MEDFileMeshMultiTS(fid,mName);
}
MEDFileMeshMultiTS *MEDFileMeshMultiTS::New(const std::string& fileName, const std::string& mName)
{
- return new MEDFileMeshMultiTS(fileName,mName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,mName);
}
MEDFileMeshMultiTS *MEDFileMeshMultiTS::deepCopy() const
{
- MCAuto<MEDFileMeshMultiTS> ret=MEDFileMeshMultiTS::New();
+ MCAuto<MEDFileMeshMultiTS> ret(MEDFileMeshMultiTS::New());
std::vector< MCAuto<MEDFileMesh> > meshOneTs(_mesh_one_ts.size());
- std::size_t i=0;
+ std::size_t i(0);
for(std::vector< MCAuto<MEDFileMesh> >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++,i++)
if((const MEDFileMesh *)*it)
meshOneTs[i]=(*it)->deepCopy();
(const_cast<MEDFileMeshMultiTS*>(this))->setJoints( joints ); // restore joints
}
-void MEDFileMeshMultiTS::loadFromFile(const std::string& fileName, const std::string& mName)
+void MEDFileMeshMultiTS::loadFromFile(med_idt fid, const std::string& mName)
{
- MEDFileJoints* joints = 0;
+ MEDFileJoints *joints(0);
if ( !_mesh_one_ts.empty() && getOneTimeStep() )
{
// joints of mName already read, pass them to MEDFileMesh::New() to prevent repeated reading
joints = getOneTimeStep()->getJoints();
}
-
_mesh_one_ts.clear(); //for the moment to be improved
- _mesh_one_ts.push_back( MEDFileMesh::New(fileName,mName,-1,-1,0, joints ));
+ _mesh_one_ts.push_back( MEDFileMesh::New(fid,mName,-1,-1,0, joints ));
}
MEDFileMeshMultiTS::MEDFileMeshMultiTS()
{
}
-MEDFileMeshMultiTS::MEDFileMeshMultiTS(const std::string& fileName)
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(med_idt fid)
try
{
- std::vector<std::string> ms(MEDCoupling::GetMeshNames(fileName));
+ std::vector<std::string> ms(MEDLoaderNS::getMeshNamesFid(fid));
if(ms.empty())
{
- std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !";
+ std::ostringstream oss; oss << "MEDFileMeshMultiTS : no meshes in file \"" << FileNameFromFID(fid) << "\" !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int dt,it;
MEDCoupling::MEDCouplingMeshType meshType;
std::string dummy2;
MEDCoupling::MEDCouplingAxisType dummy3;
MEDFileMeshL2::GetMeshIdFromName(fid,ms.front(),meshType,dummy3,dt,it,dummy2);
- loadFromFile(fileName,ms.front());
+ loadFromFile(fid,ms.front());
}
catch(INTERP_KERNEL::Exception& e)
{
throw e;
}
-MEDFileMeshMultiTS::MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName)
+MEDFileMeshMultiTS::MEDFileMeshMultiTS(med_idt fid, const std::string& mName)
try
{
- loadFromFile(fileName,mName);
+ loadFromFile(fid,mName);
}
catch(INTERP_KERNEL::Exception& e)
{
return new MEDFileMeshes;
}
+MEDFileMeshes *MEDFileMeshes::New(med_idt fid)
+{
+ return new MEDFileMeshes(fid);
+}
+
MEDFileMeshes *MEDFileMeshes::New(const std::string& fileName)
{
- return new MEDFileMeshes(fileName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid);
}
void MEDFileMeshes::writeLL(med_idt fid) const
_meshes.erase(_meshes.begin()+i);
}
-void MEDFileMeshes::loadFromFile(const std::string& fileName)
+void MEDFileMeshes::loadFromFile(med_idt fid)
{
- std::vector<std::string> ms(MEDCoupling::GetMeshNames(fileName));
+ std::vector<std::string> ms(MEDLoaderNS::getMeshNamesFid(fid));
int i=0;
_meshes.resize(ms.size());
for(std::vector<std::string>::const_iterator it=ms.begin();it!=ms.end();it++,i++)
- _meshes[i]=MEDFileMeshMultiTS::New(fileName,(*it));
+ _meshes[i]=MEDFileMeshMultiTS::New(fid,(*it));
}
MEDFileMeshes::MEDFileMeshes()
{
}
-MEDFileMeshes::MEDFileMeshes(const std::string& fileName)
+MEDFileMeshes::MEDFileMeshes(med_idt fid)
try
{
- loadFromFile(fileName);
+ loadFromFile(fid);
}
catch(INTERP_KERNEL::Exception& /*e*/)
{
for(std::vector< MCAuto<MEDFileMeshMultiTS> >::const_iterator it=_meshes.begin();it!=_meshes.end();it++,i++)
if((const MEDFileMeshMultiTS *)*it)
meshes[i]=(*it)->deepCopy();
- MCAuto<MEDFileMeshes> ret=MEDFileMeshes::New();
+ MCAuto<MEDFileMeshes> ret(MEDFileMeshes::New());
ret->_meshes=meshes;
return ret.retn();
}
{
public:
MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0);
+ MEDLOADER_EXPORT static MEDFileMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0, MEDFileJoints* joints=0);
MEDLOADER_EXPORT void writeLL(med_idt fid) const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
friend class MEDFileMesh;
public:
MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT static MEDFileUMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileUMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT static MEDFileUMesh *New(const MEDCouplingMappedExtrudedMesh *mem);
MEDLOADER_EXPORT static MEDFileUMesh *New();
MEDLOADER_EXPORT static MEDFileUMesh *LoadPartOf(const std::string& fileName, const std::string& mName, const std::vector<INTERP_KERNEL::NormalizedCellType>& types, const std::vector<int>& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
public:
MEDLOADER_EXPORT static MEDFileCMesh *New();
MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT static MEDFileCMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
public:
MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New();
MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(const std::string& fileName, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
+ MEDLOADER_EXPORT static MEDFileCurveLinearMesh *New(med_idt fid, const std::string& mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const;
{
public:
MEDLOADER_EXPORT static MEDFileMeshMultiTS *New();
+ MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(med_idt fid);
MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(med_idt fid, const std::string& mName);
MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName);
MEDLOADER_EXPORT MEDFileMeshMultiTS *deepCopy() const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints);
private:
~MEDFileMeshMultiTS() { }
- void loadFromFile(const std::string& fileName, const std::string& mName);
+ void loadFromFile(med_idt fid, const std::string& mName);
MEDFileMeshMultiTS();
- MEDFileMeshMultiTS(const std::string& fileName);
- MEDFileMeshMultiTS(const std::string& fileName, const std::string& mName);
+ MEDFileMeshMultiTS(med_idt fid);
+ MEDFileMeshMultiTS(med_idt fid, const std::string& mName);
private:
std::vector< MCAuto<MEDFileMesh> > _mesh_one_ts;
};
{
public:
MEDLOADER_EXPORT static MEDFileMeshes *New();
+ MEDLOADER_EXPORT static MEDFileMeshes *New(med_idt fid);
MEDLOADER_EXPORT static MEDFileMeshes *New(const std::string& fileName);
MEDLOADER_EXPORT MEDFileMeshes *deepCopy() const;
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
private:
~MEDFileMeshes() { }
void checkConsistencyLight() const;
- void loadFromFile(const std::string& fileName);
+ void loadFromFile(med_idt fid);
MEDFileMeshes();
- MEDFileMeshes(const std::string& fileName);
+ MEDFileMeshes(med_idt fid);
private:
std::vector< MCAuto<MEDFileMeshMultiTS> > _meshes;
};
MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const std::string& fileName)
{
- return new MEDFileParameterMultiTS(fileName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid);
+}
+
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(med_idt fid)
+{
+ return new MEDFileParameterMultiTS(fid);
}
MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(const std::string& fileName, const std::string& paramName)
{
- return new MEDFileParameterMultiTS(fileName,paramName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid,paramName);
+}
+
+MEDFileParameterMultiTS *MEDFileParameterMultiTS::New(med_idt fid, const std::string& paramName)
+{
+ return new MEDFileParameterMultiTS(fid,paramName);
}
MEDFileParameterMultiTS::MEDFileParameterMultiTS()
}
}
-MEDFileParameterMultiTS::MEDFileParameterMultiTS(const std::string& fileName)
+MEDFileParameterMultiTS::MEDFileParameterMultiTS(med_idt fid)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- int nbPar=MEDnParameter(fid);
+ int nbPar(MEDnParameter(fid));
if(nbPar<1)
{
- std::ostringstream oss; oss << "MEDFileParameterMultiTS : no parameter in file \"" << fileName << "\" !" ;
+ std::ostringstream oss; oss << "MEDFileParameterMultiTS : no parameter in file \"" << FileNameFromFID(fid) << "\" !" ;
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
- INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
+ INTERP_KERNEL::AutoPtr<char> unitName(MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE));
med_parameter_type paramType;
int nbOfSteps;
MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,1,pName,¶mType,descName,unitName,&nbOfSteps));
- std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ std::string paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE));
_dt_unit=MEDLoaderBase::buildStringFromFortran(unitName,MED_SNAME_SIZE);
_name=paramNameCpp;
_desc_name=MEDLoaderBase::buildStringFromFortran(descName,MED_COMMENT_SIZE);
finishLoading(fid,paramType,nbOfSteps);
}
-MEDFileParameterMultiTS::MEDFileParameterMultiTS(const std::string& fileName, const std::string& paramName)
+MEDFileParameterMultiTS::MEDFileParameterMultiTS(med_idt fid, const std::string& paramName)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- int nbPar=MEDnParameter(fid);
+ int nbPar(MEDnParameter(fid));
std::ostringstream oss; oss << "MEDFileParameterDouble1TS : no double param name \"" << paramName << "\" ! Double Parameters available are : ";
- INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
- INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
+ INTERP_KERNEL::AutoPtr<char> unitName(MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE));
med_parameter_type paramType;
for(int i=0;i<nbPar;i++)
{
int nbOfSteps;
MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps));
- std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
+ std::string paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE));
if(paramNameCpp==paramName)
{
if(nbOfSteps>0)
throw INTERP_KERNEL::Exception("MEDFileParameterMultiTS::writeAdvanced : impossible to mix type of data in parameters in MED file ! Only float64 or only int32 ...");
if(diffType.empty())
return;
- med_parameter_type typ=*diffType.begin();
+ med_parameter_type typ(*diffType.begin());
MEDFileParameterTinyInfo::writeLLHeader(fid,typ);
for(std::vector< MCAuto<MEDFileParameter1TS> >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++)
{
MEDFileParameters *MEDFileParameters::New(const std::string& fileName)
{
- return new MEDFileParameters(fileName);
+ MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
+ return New(fid);
}
-MEDFileParameters::MEDFileParameters(const std::string& fileName)
+MEDFileParameters *MEDFileParameters::New(med_idt fid)
+{
+ return new MEDFileParameters(fid);
+}
+
+MEDFileParameters::MEDFileParameters(med_idt fid)
{
- MEDFileUtilities::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
int nbPar=MEDnParameter(fid);
_params.resize(nbPar);
- INTERP_KERNEL::AutoPtr<char> pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
- INTERP_KERNEL::AutoPtr<char> descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE);
- INTERP_KERNEL::AutoPtr<char> unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE);
+ INTERP_KERNEL::AutoPtr<char> pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ INTERP_KERNEL::AutoPtr<char> descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE));
+ INTERP_KERNEL::AutoPtr<char> unitName(MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE));
med_parameter_type paramType;
for(int i=0;i<nbPar;i++)
{
int nbOfSteps;
MEDFILESAFECALLERRD0(MEDparameterInfo,(fid,i+1,pName,¶mType,descName,unitName,&nbOfSteps));
- std::string paramNameCpp=MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE);
- _params[i]=MEDFileParameterMultiTS::New(fileName,paramNameCpp);
+ std::string paramNameCpp(MEDLoaderBase::buildStringFromFortran(pName,MED_NAME_SIZE));
+ _params[i]=MEDFileParameterMultiTS::New(fid,paramNameCpp);
}
}
public:
MEDLOADER_EXPORT static MEDFileParameterMultiTS *New();
MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const std::string& fileName);
+ MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(med_idt fid);
MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(const std::string& fileName, const std::string& paramName);
+ MEDLOADER_EXPORT static MEDFileParameterMultiTS *New(med_idt fid, const std::string& paramName);
MEDLOADER_EXPORT std::string getName() const { return _name; }
MEDLOADER_EXPORT void setName(const std::string& name) { _name=name; }
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
protected:
MEDFileParameterMultiTS();
MEDFileParameterMultiTS(const MEDFileParameterMultiTS& other, bool deepCopy);
- MEDFileParameterMultiTS(const std::string& fileName);
- MEDFileParameterMultiTS(const std::string& fileName, const std::string& paramName);
+ MEDFileParameterMultiTS(med_idt fid);
+ MEDFileParameterMultiTS(med_idt fid, const std::string& paramName);
void finishLoading(med_idt fid, med_parameter_type typ, int nbOfSteps);
protected:
std::vector< MCAuto<MEDFileParameter1TS> > _param_per_ts;
{
public:
MEDLOADER_EXPORT static MEDFileParameters *New();
+ MEDLOADER_EXPORT static MEDFileParameters *New(med_idt fid);
MEDLOADER_EXPORT static MEDFileParameters *New(const std::string& fileName);
MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
MEDLOADER_EXPORT int getNumberOfParams() const;
protected:
void simpleRepr2(int bkOffset, std::ostream& oss) const;
- MEDFileParameters(const std::string& fileName);
+ MEDFileParameters(med_idt fid);
MEDFileParameters(const MEDFileParameters& other, bool deepCopy);
MEDFileParameters();
protected:
#include "MEDLoader.hxx"
#include "MEDLoaderBase.hxx"
#include "MEDFileUtilities.hxx"
+#include "MEDLoaderNS.hxx"
#include "MEDFileSafeCaller.txx"
#include "MEDFileMesh.hxx"
#include "MEDFileField.hxx"
using namespace MEDCoupling;
-/// @cond INTERNAL
-
-namespace MEDLoaderNS
-{
- int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities);
- void dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity);
- void writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch);
- med_int getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName);
- std::vector<std::string> getMeshNamesFid(med_idt fid);
-}
-
-/// @endcond
-
-
/// @cond INTERNAL
/*!
int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities)
{
possibilities.clear();
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
int ret;
std::set<int> poss;
char nommaa[MED_NAME_SIZE+1];
*/
std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > MEDCoupling::GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName, int &meshDim, int& spaceDim, int& numberOfNodes)
{
- CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
std::set<int> poss;
char nommaa[MED_NAME_SIZE+1];
char maillage_description[MED_COMMENT_SIZE+1];
std::vector<std::string> MEDCoupling::GetMeshNames(const std::string& fileName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- std::vector<std::string> ret=MEDLoaderNS::getMeshNamesFid(fid);
- return ret;
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
+ return MEDLoaderNS::getMeshNamesFid(fid);
}
std::vector< std::pair<std::string,std::string> > MEDCoupling::GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields(MEDnField(fid));
std::vector<std::string> fields(nbFields);
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
//
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret(nfam);
char nomfam[MED_NAME_SIZE+1];
std::vector<std::string> MEDCoupling::GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
std::vector<std::string> MEDCoupling::GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- med_int nfam=MEDnFamily(fid,meshName.c_str());
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
+ med_int nfam(MEDnFamily(fid,meshName.c_str()));
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
std::vector<std::string> MEDCoupling::GetMeshGroupsNames(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
std::vector<std::string> MEDCoupling::GetAllFieldNames(const std::string& fileName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
med_field_type typcha;
for(int i=0;i<nbFields;i++)
std::vector<std::string> MEDCoupling::GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
char pflname[MED_NAME_SIZE+1]="";
char locname[MED_NAME_SIZE+1]="";
std::vector< std::pair< std::pair<int,int>, double> > MEDCoupling::GetAllFieldIterations(const std::string& fileName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector< std::pair< std::pair<int,int>, double > > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
double MEDCoupling::GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector< std::pair<int,int> > MEDCoupling::GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::string meshNameCpp(meshName);
std::vector< std::pair<int,int> > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector< std::pair<int,int> > MEDCoupling::GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::string meshNameCpp(meshName);
std::vector< std::pair<int,int> > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __MEDLOADERNS_HXX__
+#define __MEDLOADERNS_HXX__
+
+#include <vector>
+#include <string>
+
+namespace MEDCoupling
+{
+ class MEDCouplingFieldDouble;
+}
+
+#include "med.h"
+
+namespace MEDLoaderNS
+{
+ int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities);
+ void dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity);
+ void writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch);
+ med_int getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName);
+ std::vector<std::string> getMeshNamesFid(med_idt fid);
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#include "MEDLoaderTraits.hxx"
+
+const char MEDCoupling::MLMeshTraits<MEDCoupling::MEDFileUMesh>::ClassName[]="MEDFileUMesh";
+const char MEDCoupling::MLMeshTraits<MEDCoupling::MEDFileCMesh>::ClassName[]="MEDFileCMesh";
+const char MEDCoupling::MLMeshTraits<MEDCoupling::MEDFileCurveLinearMesh>::ClassName[]="MEDFileCurveLinearMesh";
typedef MEDFileIntField1TS F1TSType;
typedef MEDFileIntField1TSWithoutSDA F1TSWSDAType;
};
+
+ template<class T>
+ struct MEDLOADER_EXPORT MLMeshTraits
+ {
+ };
+
+ class MEDFileUMesh;
+ class MEDFileCMesh;
+ class MEDFileCurveLinearMesh;
+
+ template<>
+ struct MEDLOADER_EXPORT MLMeshTraits<MEDFileUMesh>
+ {
+ static const char ClassName[];
+ };
+
+ template<>
+ struct MEDLOADER_EXPORT MLMeshTraits<MEDFileCMesh>
+ {
+ static const char ClassName[];
+ };
+
+ template<>
+ struct MEDLOADER_EXPORT MLMeshTraits<MEDFileCurveLinearMesh>
+ {
+ static const char ClassName[];
+ };
}
#endif