From: Anthony Geay Date: Fri, 7 Oct 2016 15:19:23 +0000 (+0200) Subject: Last med_idt API before serialization X-Git-Tag: V8_2_0a1~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5405ff37e5479d1ec308a6e6045f28f6b539bc5f;p=tools%2Fmedcoupling.git Last med_idt API before serialization --- diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index ebd39d043..8949f50cc 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -5499,32 +5499,42 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName) +MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c) { if(!c) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !"); if(dynamic_cast(c)) { MCAuto ret(MEDFileField1TS::New()); - ret->setFileName(fileName); ret->_content=c; c->incrRef(); return ret.retn(); } if(dynamic_cast(c)) { MCAuto ret(MEDFileIntField1TS::New()); - ret->setFileName(fileName); ret->_content=c; c->incrRef(); return ret.retn(); } throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !"); } +MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid) +{ + MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c)); + ret->setFileName(FileNameFromFID(fid)); + return ret; +} + MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,loadAll); +} + +MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::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(); } @@ -5532,17 +5542,27 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,fieldName,loadAll); +} + +MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll) +{ MCAuto c(BuildContentFrom(fid,fieldName,loadAll,0)); - MCAuto ret(BuildNewInstanceFromContent(c,fileName)); + MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); } MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) { - MEDFileUtilities::AutoFid fid=OpenMEDFileForRead(fileName); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,fieldName,iteration,order,loadAll); +} + +MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll) +{ MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0)); - MCAuto ret(BuildNewInstanceFromContent(c,fileName)); + MCAuto ret(BuildNewInstanceFromContent(c,fid)); ret->loadGlobals(fid); return ret.retn(); } @@ -6167,6 +6187,11 @@ int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,loadAll); +} + +MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll) +{ MCAuto ret(new MEDFileField1TS(fid,loadAll,0)); ret->contentNotNull(); return ret.retn(); @@ -6185,6 +6210,11 @@ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll) MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,fieldName,loadAll); +} + +MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll) +{ MCAuto ret(new MEDFileField1TS(fid,fieldName,loadAll,0)); ret->contentNotNull(); return ret.retn(); @@ -6206,6 +6236,11 @@ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::st MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return New(fid,fieldName,iteration,order,loadAll); +} + +MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll) +{ MCAuto ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0)); ret->contentNotNull(); return ret.retn(); @@ -6260,7 +6295,7 @@ MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const if(!contc) throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !"); MCAuto newc(contc->convertToInt()); - ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName())); + ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc)); } else ret=MEDFileIntField1TS::New(); @@ -6771,7 +6806,7 @@ MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const if(!contc) throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !"); MCAuto newc(contc->convertToDouble()); - ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName())); + ret=static_cast(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc)); } else ret=MEDFileField1TS::New(); @@ -8175,14 +8210,14 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !"); if(dynamic_cast(c)) { - MCAuto ret=MEDFileFieldMultiTS::New(); + MCAuto ret(MEDFileFieldMultiTS::New()); ret->setFileName(fileName); ret->_content=c; c->incrRef(); return ret.retn(); } if(dynamic_cast(c)) { - MCAuto ret=MEDFileIntFieldMultiTS::New(); + MCAuto ret(MEDFileIntFieldMultiTS::New()); ret->setFileName(fileName); ret->_content=c; c->incrRef(); return ret.retn(); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index a884070c2..51886a565 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -645,7 +645,8 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent); - MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid); MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms); MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); @@ -653,8 +654,11 @@ namespace MEDCoupling // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content public: MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, bool loadAll=true); MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, bool loadAll=true); MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true); MEDLOADER_EXPORT int getDimension() const; MEDLOADER_EXPORT int getIteration() const; MEDLOADER_EXPORT int getOrder() const; @@ -732,8 +736,11 @@ namespace MEDCoupling { public: MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileField1TS *New(med_idt fid, bool loadAll=true); MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileField1TS *New(med_idt fid, const std::string& fieldName, bool loadAll=true); MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileField1TS *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true); MEDLOADER_EXPORT static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent); MEDLOADER_EXPORT static MEDFileField1TS *New(); MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const;