From: Anthony Geay Date: Mon, 10 Oct 2016 11:49:21 +0000 (+0200) Subject: End of refacto. Now ready for MEDFilemem implementation and for selection of MED... X-Git-Tag: V8_2_0a1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6ff0c473a6c62af57a92e7e23cc940ebd09a7311;p=tools%2Fmedcoupling.git End of refacto. Now ready for MEDFilemem implementation and for selection of MED file version on write. --- diff --git a/src/MEDLoader/CMakeLists.txt b/src/MEDLoader/CMakeLists.txt index 76dd3dd34..d1c2583b6 100644 --- a/src/MEDLoader/CMakeLists.txt +++ b/src/MEDLoader/CMakeLists.txt @@ -56,6 +56,7 @@ INCLUDE_DIRECTORIES( SET(medloader_SOURCES MEDLoader.cxx MEDLoaderBase.cxx + MEDLoaderTraits.cxx MEDFileUtilities.cxx MEDFileMesh.cxx MEDFileMeshElt.cxx diff --git a/src/MEDLoader/MEDFileData.cxx b/src/MEDLoader/MEDFileData.cxx index 5adb571fa..ab7b59e69 100644 --- a/src/MEDLoader/MEDFileData.cxx +++ b/src/MEDLoader/MEDFileData.cxx @@ -24,7 +24,13 @@ using namespace MEDCoupling; 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() @@ -291,12 +297,12 @@ MEDFileData::MEDFileData() { } -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) { diff --git a/src/MEDLoader/MEDFileData.hxx b/src/MEDLoader/MEDFileData.hxx index d483d08f0..6b31f2096 100644 --- a/src/MEDLoader/MEDFileData.hxx +++ b/src/MEDLoader/MEDFileData.hxx @@ -35,6 +35,7 @@ namespace MEDCoupling { 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; @@ -58,7 +59,7 @@ namespace MEDCoupling MEDLOADER_EXPORT void writeLL(med_idt fid) const; private: MEDFileData(); - MEDFileData(const std::string& fileName); + MEDFileData(med_idt fid); private: MCAuto _fields; MCAuto _meshes; diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 8949f50cc..810e06da6 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -6719,6 +6719,11 @@ MEDFileIntField1TS *MEDFileIntField1TS::New() 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 ret(new MEDFileIntField1TS(fid,loadAll,0)); ret->contentNotNull(); return ret.retn(); @@ -6727,6 +6732,11 @@ MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool lo 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 ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0)); ret->contentNotNull(); return ret.retn(); @@ -6735,6 +6745,11 @@ MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const s 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 ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0)); ret->contentNotNull(); return ret.retn(); @@ -8204,27 +8219,33 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr 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(c)) { MCAuto ret(MEDFileFieldMultiTS::New()); - ret->setFileName(fileName); ret->_content=c; c->incrRef(); return ret.retn(); } if(dynamic_cast(c)) { MCAuto 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 > *entities) try:MEDFileFieldGlobsReal(fid) { @@ -8330,8 +8351,13 @@ MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble 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 c(BuildContentFrom(fid,loadAll,0)); - MCAuto ret(BuildNewInstanceFromContent(c,fileName)); + MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); } @@ -8349,8 +8375,13 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& f 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 c(BuildContentFrom(fid,fieldName,loadAll,0,0)); - MCAuto ret=BuildNewInstanceFromContent(c,fileName); + MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); } @@ -9127,6 +9158,11 @@ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New() 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 ret(new MEDFileFieldMultiTS(fid,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); @@ -9145,6 +9181,11 @@ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool 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 ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); @@ -9207,7 +9248,7 @@ MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) c if(!contc) throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !"); MCAuto newc(contc->convertToInt()); - ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName())); + ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc)); } else ret=MEDFileIntFieldMultiTS::New(); @@ -9609,6 +9650,11 @@ MEDFileIntFieldMultiTS *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 ret(new MEDFileIntFieldMultiTS(fid,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); @@ -9627,6 +9673,11 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, 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 ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); @@ -9675,7 +9726,7 @@ MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs if(!contc) throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); MCAuto newc(contc->convertToDouble()); - ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName())); + ret=static_cast(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc)); } else ret=MEDFileFieldMultiTS::New(); @@ -10040,6 +10091,11 @@ MEDFileFields *MEDFileFields::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); } @@ -10073,8 +10129,8 @@ std::vector MEDFileFields::getDirectChildrenWithNull() MEDFileFields *MEDFileFields::deepCopy() const { - MCAuto ret=shallowCpy(); - std::size_t i=0; + MCAuto ret(shallowCpy()); + std::size_t i(0); for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++) { if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it) @@ -10133,7 +10189,7 @@ int MEDFileFields::getNumberOfFields() const std::vector MEDFileFields::getFieldsNames() const { std::vector ret(_fields.size()); - int i=0; + int i(0); for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++) { const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it); @@ -10172,7 +10228,7 @@ std::string MEDFileFields::simpleRepr() const 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; @@ -10358,7 +10414,7 @@ std::vector MEDFileFields::getLocsReallyUsed() const std::set ret2; for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++) { - std::vector tmp=(*it)->getLocsReallyUsed2(); + std::vector tmp((*it)->getLocsReallyUsed2()); for(std::vector::const_iterator it2=tmp.begin();it2!=tmp.end();it2++) if(ret2.find(*it2)==ret2.end()) { @@ -10374,7 +10430,7 @@ std::vector MEDFileFields::getPflsReallyUsedMulti() const std::vector ret; for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++) { - std::vector tmp=(*it)->getPflsReallyUsedMulti2(); + std::vector tmp((*it)->getPflsReallyUsedMulti2()); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -10385,7 +10441,7 @@ std::vector MEDFileFields::getLocsReallyUsedMulti() const std::vector ret; for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++) { - std::vector tmp=(*it)->getLocsReallyUsed2(); + std::vector tmp((*it)->getLocsReallyUsed2()); ret.insert(ret.end(),tmp.begin(),tmp.end()); } return ret; @@ -10460,7 +10516,7 @@ void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) 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 b(_fields.size(),true); int k=bg; for(int i=0;i > 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]; @@ -10482,7 +10538,7 @@ void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) bool MEDFileFields::changeMeshNames(const std::vector< std::pair >& modifTab) { - bool ret=false; + bool ret(false); for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) { MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); @@ -10503,7 +10559,7 @@ bool MEDFileFields::changeMeshNames(const std::vector< std::pair& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N) { - bool ret=false; + bool ret(false); for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) { MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it); @@ -10552,8 +10608,8 @@ MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const if(!fmts) return 0; MCAuto ret; - const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast(fmts); - const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast(fmts); + const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast(fmts)); + const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast(fmts)); if(fmtsC) ret=MEDFileFieldMultiTS::New(*fmtsC,false); else if(fmtsC2) @@ -10631,10 +10687,10 @@ bool MEDFileFields::removeFieldsWithoutAnyTimeStep() */ MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const { - MCAuto ret=MEDFileFields::New(); + MCAuto ret(MEDFileFields::New()); for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); if(!cur) continue; if(cur->getMeshName()==meshName) @@ -10663,10 +10719,10 @@ MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::stri */ MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const { - MCAuto ret=MEDFileFields::New(); + MCAuto ret(MEDFileFields::New()); for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); if(!cur) continue; MCAuto elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps); @@ -10684,7 +10740,7 @@ MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std:: MCAuto ret=MEDFileFields::New(); for(std::vector< MCAuto >::const_iterator it=_fields.begin();it!=_fields.end();it++) { - const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it); if(!cur) continue; MCAuto elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps); @@ -10706,7 +10762,7 @@ int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const std::vector 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()); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 51886a565..f201eed5a 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -786,8 +786,11 @@ namespace MEDCoupling 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; @@ -952,12 +955,15 @@ namespace MEDCoupling 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 > *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 > *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(); @@ -1041,7 +1047,9 @@ namespace MEDCoupling 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 >& entities, bool loadAll=true); MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; @@ -1086,7 +1094,9 @@ namespace MEDCoupling 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 >& entities, bool loadAll=true); MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; @@ -1141,6 +1151,7 @@ namespace MEDCoupling 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 >& entities, bool loadAll=true); MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index c88c69e3a..d001e5ce9 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -23,6 +23,7 @@ #include "MEDFileFieldOverView.hxx" #include "MEDFileField.hxx" #include "MEDLoader.hxx" +#include "MEDLoaderNS.hxx" #include "MEDFileSafeCaller.txx" #include "MEDLoaderBase.hxx" @@ -79,15 +80,19 @@ std::vector MEDFileMesh::getDirectChildrenWithNull() co */ MEDFileMesh *MEDFileMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - std::vector ms=MEDCoupling::GetMeshNames(fileName); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,mrs); +} + +MEDFileMesh *MEDFileMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs) +{ + std::vector 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; @@ -139,9 +144,13 @@ MEDFileMesh *MEDFileMesh::New(const std::string& fileName, MEDFileMeshReadSelect */ 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; @@ -2224,8 +2233,12 @@ void MEDFileMesh::getFamilyRepr(std::ostream& oss) const */ 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); } @@ -2241,20 +2254,30 @@ MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, const std::string& */ MEDFileUMesh *MEDFileUMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - std::vector ms(MEDCoupling::GetMeshNames(fileName)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,mrs); +} + +template +T *NewForTheFirstMeshInFile(med_idt fid, MEDFileMeshReadSelector *mrs) +{ + std::vector ms(MEDLoaderNS::getMeshNamesFid(fid)); if(ms.empty()) { - std::ostringstream oss; oss << "MEDFileUMesh::New : no meshes in file \"" << fileName << "\" !"; + std::ostringstream oss; oss << MLMeshTraits::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(fid,mrs); } /*! @@ -6400,20 +6423,13 @@ MEDFileCMesh *MEDFileCMesh::New() */ MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - std::vector 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(fid,mrs); } /*! @@ -6432,8 +6448,12 @@ MEDFileCMesh *MEDFileCMesh::New(const std::string& fileName, MEDFileMeshReadSele */ 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); } @@ -6696,28 +6716,25 @@ MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New() return new MEDFileCurveLinearMesh; } +MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(med_idt fid, MEDFileMeshReadSelector *mrs) +{ + return NewForTheFirstMeshInFile(fid,mrs); +} + MEDFileCurveLinearMesh *MEDFileCurveLinearMesh::New(const std::string& fileName, MEDFileMeshReadSelector *mrs) { - std::vector 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); } @@ -6940,21 +6957,33 @@ MEDFileMeshMultiTS *MEDFileMeshMultiTS::New() 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 ret=MEDFileMeshMultiTS::New(); + MCAuto ret(MEDFileMeshMultiTS::New()); std::vector< MCAuto > meshOneTs(_mesh_one_ts.size()); - std::size_t i=0; + std::size_t i(0); for(std::vector< MCAuto >::const_iterator it=_mesh_one_ts.begin();it!=_mesh_one_ts.end();it++,i++) if((const MEDFileMesh *)*it) meshOneTs[i]=(*it)->deepCopy(); @@ -7069,50 +7098,47 @@ void MEDFileMeshMultiTS::writeLL(med_idt fid) const (const_cast(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 ms(MEDCoupling::GetMeshNames(fileName)); + std::vector 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) { @@ -7124,9 +7150,15 @@ MEDFileMeshes *MEDFileMeshes::New() 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 @@ -7253,23 +7285,23 @@ void MEDFileMeshes::destroyMeshAtPos(int i) _meshes.erase(_meshes.begin()+i); } -void MEDFileMeshes::loadFromFile(const std::string& fileName) +void MEDFileMeshes::loadFromFile(med_idt fid) { - std::vector ms(MEDCoupling::GetMeshNames(fileName)); + std::vector ms(MEDLoaderNS::getMeshNamesFid(fid)); int i=0; _meshes.resize(ms.size()); for(std::vector::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*/) { @@ -7282,7 +7314,7 @@ MEDFileMeshes *MEDFileMeshes::deepCopy() const for(std::vector< MCAuto >::const_iterator it=_meshes.begin();it!=_meshes.end();it++,i++) if((const MEDFileMeshMultiTS *)*it) meshes[i]=(*it)->deepCopy(); - MCAuto ret=MEDFileMeshes::New(); + MCAuto ret(MEDFileMeshes::New()); ret->_meshes=meshes; return ret.retn(); } diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index b9dc110c0..4bd228285 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -41,7 +41,9 @@ namespace MEDCoupling { 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 getDirectChildrenWithNull() const; @@ -247,7 +249,9 @@ namespace MEDCoupling 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& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); @@ -454,7 +458,9 @@ namespace MEDCoupling 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 getDirectChildrenWithNull() const; MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const; @@ -487,7 +493,9 @@ namespace MEDCoupling 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 getDirectChildrenWithNull() const; MEDLOADER_EXPORT MEDFileMesh *createNewEmpty() const; @@ -517,7 +525,9 @@ namespace MEDCoupling { 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; @@ -533,10 +543,10 @@ namespace MEDCoupling 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 > _mesh_one_ts; }; @@ -547,6 +557,7 @@ namespace MEDCoupling { 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; @@ -569,9 +580,9 @@ namespace MEDCoupling 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 > _meshes; }; diff --git a/src/MEDLoader/MEDFileParameter.cxx b/src/MEDLoader/MEDFileParameter.cxx index 4186eea5b..335c158d0 100644 --- a/src/MEDLoader/MEDFileParameter.cxx +++ b/src/MEDLoader/MEDFileParameter.cxx @@ -371,12 +371,24 @@ MEDFileParameterMultiTS *MEDFileParameterMultiTS::New() 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() @@ -394,44 +406,40 @@ MEDFileParameterMultiTS::MEDFileParameterMultiTS(const 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 pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - INTERP_KERNEL::AutoPtr descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); - INTERP_KERNEL::AutoPtr unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE); + INTERP_KERNEL::AutoPtr pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); + INTERP_KERNEL::AutoPtr 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 pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - INTERP_KERNEL::AutoPtr descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); - INTERP_KERNEL::AutoPtr unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE); + INTERP_KERNEL::AutoPtr pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); + INTERP_KERNEL::AutoPtr unitName(MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE)); med_parameter_type paramType; for(int i=0;i0) @@ -539,7 +547,7 @@ void MEDFileParameterMultiTS::writeAdvanced(med_idt fid, const MEDFileWritable& 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 >::const_iterator it=_param_per_ts.begin();it!=_param_per_ts.end();it++) { @@ -706,25 +714,29 @@ MEDFileParameters *MEDFileParameters::New() 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 pName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); - INTERP_KERNEL::AutoPtr descName=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); - INTERP_KERNEL::AutoPtr unitName=MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE); + INTERP_KERNEL::AutoPtr pName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); + INTERP_KERNEL::AutoPtr descName(MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE)); + INTERP_KERNEL::AutoPtr unitName(MEDLoaderBase::buildEmptyString(MED_SNAME_SIZE)); med_parameter_type paramType; for(int i=0;i > _param_per_ts; @@ -156,6 +158,7 @@ namespace MEDCoupling { 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 getDirectChildrenWithNull() const; @@ -175,7 +178,7 @@ namespace MEDCoupling 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: diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index c6ad9872e..50009ad4a 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -21,6 +21,7 @@ #include "MEDLoader.hxx" #include "MEDLoaderBase.hxx" #include "MEDFileUtilities.hxx" +#include "MEDLoaderNS.hxx" #include "MEDFileSafeCaller.txx" #include "MEDFileMesh.hxx" #include "MEDFileField.hxx" @@ -139,20 +140,6 @@ int _TOO_LONG_STR=0; using namespace MEDCoupling; -/// @cond INTERNAL - -namespace MEDLoaderNS -{ - int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector& 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 getMeshNamesFid(med_idt fid); -} - -/// @endcond - - /// @cond INTERNAL /*! @@ -163,7 +150,7 @@ namespace MEDLoaderNS int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector& possibilities) { possibilities.clear(); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); int ret; std::set poss; char nommaa[MED_NAME_SIZE+1]; @@ -347,8 +334,7 @@ void MEDCoupling::SetTooLongStrPolicy(int val) */ std::vector< std::vector< std::pair > > 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 poss; char nommaa[MED_NAME_SIZE+1]; char maillage_description[MED_COMMENT_SIZE+1]; @@ -410,16 +396,13 @@ void MEDCoupling::CheckFileForRead(const std::string& fileName) std::vector MEDCoupling::GetMeshNames(const std::string& fileName) { - MEDCoupling::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - std::vector ret=MEDLoaderNS::getMeshNamesFid(fid); - return ret; + MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName)); + return MEDLoaderNS::getMeshNamesFid(fid); } std::vector< std::pair > 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 fields(nbFields); med_field_type typcha; @@ -454,10 +437,9 @@ std::vector< std::pair > MEDCoupling::GetComponentsName std::vector MEDCoupling::GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName) { - MEDCoupling::CheckFileForRead(fileName); std::vector 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; @@ -483,8 +465,7 @@ std::vector MEDCoupling::GetMeshNamesOnField(const std::string& fil std::vector 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 ret(nfam); char nomfam[MED_NAME_SIZE+1]; @@ -507,8 +488,7 @@ std::vector MEDCoupling::GetMeshFamiliesNames(const std::string& fi std::vector 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 ret; char nomfam[MED_NAME_SIZE+1]; @@ -535,9 +515,8 @@ std::vector MEDCoupling::GetMeshFamiliesNamesOnGroup(const std::str std::vector 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 ret; char nomfam[MED_NAME_SIZE+1]; med_int numfam; @@ -572,8 +551,7 @@ std::vector MEDCoupling::GetMeshGroupsNamesOnFamily(const std::stri std::vector 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 ret; char nomfam[MED_NAME_SIZE+1]; @@ -632,9 +610,8 @@ std::vector MEDCoupling::GetTypesOfField(const std::st std::vector MEDCoupling::GetAllFieldNames(const std::string& fileName) { - MEDCoupling::CheckFileForRead(fileName); std::vector 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 MEDCoupling::GetAllFieldNames(const std::string& fileNa std::vector MEDCoupling::GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) { - MEDCoupling::CheckFileForRead(fileName); std::vector 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; @@ -700,9 +676,8 @@ std::vector MEDCoupling::GetFieldNamesOnMesh(MEDCoupling::TypeOfFie std::vector MEDCoupling::GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) { - MEDCoupling::CheckFileForRead(fileName); std::vector 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; @@ -750,9 +725,8 @@ std::vector MEDCoupling::GetCellFieldNamesOnMesh(const std::string& std::vector MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName) { - MEDCoupling::CheckFileForRead(fileName); std::vector 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]=""; @@ -791,9 +765,8 @@ std::vector MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& std::vector< std::pair< std::pair, double> > MEDCoupling::GetAllFieldIterations(const std::string& fileName, const std::string& fieldName) { - MEDCoupling::CheckFileForRead(fileName); std::vector< std::pair< std::pair, 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; @@ -834,8 +807,7 @@ std::vector< std::pair< std::pair, double> > MEDCoupling::GetAllFieldIt 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; @@ -896,10 +868,9 @@ std::vector< std::pair > MEDCoupling::GetFieldIterations(MEDCoupling::T std::vector< std::pair > 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 > 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; @@ -968,10 +939,9 @@ std::vector< std::pair > MEDCoupling::GetCellFieldIterations(const std: std::vector< std::pair > 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 > 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; diff --git a/src/MEDLoader/MEDLoaderNS.hxx b/src/MEDLoader/MEDLoaderNS.hxx new file mode 100644 index 000000000..3db880f54 --- /dev/null +++ b/src/MEDLoader/MEDLoaderNS.hxx @@ -0,0 +1,43 @@ +// 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 +#include + +namespace MEDCoupling +{ + class MEDCouplingFieldDouble; +} + +#include "med.h" + +namespace MEDLoaderNS +{ + int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector& 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 getMeshNamesFid(med_idt fid); +} + +#endif diff --git a/src/MEDLoader/MEDLoaderTraits.cxx b/src/MEDLoader/MEDLoaderTraits.cxx new file mode 100644 index 000000000..4b1150ad7 --- /dev/null +++ b/src/MEDLoader/MEDLoaderTraits.cxx @@ -0,0 +1,25 @@ +// 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::ClassName[]="MEDFileUMesh"; +const char MEDCoupling::MLMeshTraits::ClassName[]="MEDFileCMesh"; +const char MEDCoupling::MLMeshTraits::ClassName[]="MEDFileCurveLinearMesh"; diff --git a/src/MEDLoader/MEDLoaderTraits.hxx b/src/MEDLoader/MEDLoaderTraits.hxx index 25cdfb3ee..03f246ac5 100644 --- a/src/MEDLoader/MEDLoaderTraits.hxx +++ b/src/MEDLoader/MEDLoaderTraits.hxx @@ -53,6 +53,33 @@ namespace MEDCoupling typedef MEDFileIntField1TS F1TSType; typedef MEDFileIntField1TSWithoutSDA F1TSWSDAType; }; + + template + struct MEDLOADER_EXPORT MLMeshTraits + { + }; + + class MEDFileUMesh; + class MEDFileCMesh; + class MEDFileCurveLinearMesh; + + template<> + struct MEDLOADER_EXPORT MLMeshTraits + { + static const char ClassName[]; + }; + + template<> + struct MEDLOADER_EXPORT MLMeshTraits + { + static const char ClassName[]; + }; + + template<> + struct MEDLOADER_EXPORT MLMeshTraits + { + static const char ClassName[]; + }; } #endif