From: Anthony Geay Date: Thu, 6 Oct 2016 12:43:50 +0000 (+0200) Subject: Some factorization before usage of new MED file API X-Git-Tag: V8_2_0a1~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=638889f1fe147dffd1e61ba40431f31a7a1a9b20;p=tools%2Fmedcoupling.git Some factorization before usage of new MED file API --- diff --git a/src/MEDLoader/MEDFileData.cxx b/src/MEDLoader/MEDFileData.cxx index 72606a8d8..5adb571fa 100644 --- a/src/MEDLoader/MEDFileData.cxx +++ b/src/MEDLoader/MEDFileData.cxx @@ -303,17 +303,15 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -void MEDFileData::write(const std::string& fileName, int mode) const +void MEDFileData::writeLL(med_idt fid) const { - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - const MEDFileMeshes *ms=_meshes; + const MEDFileMeshes *ms(_meshes); if(ms) - ms->write(fid); - const MEDFileFields *fs=_fields; + ms->writeLL(fid); + const MEDFileFields *fs(_fields); if(fs) fs->writeLL(fid); - const MEDFileParameters *ps=_params; + const MEDFileParameters *ps(_params); if(ps) ps->writeLL(fid); } diff --git a/src/MEDLoader/MEDFileData.hxx b/src/MEDLoader/MEDFileData.hxx index bdb21eb97..d483d08f0 100644 --- a/src/MEDLoader/MEDFileData.hxx +++ b/src/MEDLoader/MEDFileData.hxx @@ -31,7 +31,7 @@ namespace MEDCoupling /*! * User class. */ - class MEDFileData : public RefCountObject, public MEDFileWritable + class MEDFileData : public RefCountObject, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileData *New(const std::string& fileName); @@ -55,7 +55,7 @@ namespace MEDCoupling MEDLOADER_EXPORT bool unPolyzeMeshes(); MEDLOADER_EXPORT static MCAuto Aggregate(const std::vector& mfds); // - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const; private: MEDFileData(); MEDFileData(const std::string& fileName); diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index a4af139d2..ebd39d043 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -2031,10 +2031,10 @@ bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshNam std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept; std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries; getUndergroundDataArrayExt(entries); - DataArray *arr0=getOrCreateAndGetArray();//tony + DataArray *arr0(getOrCreateAndGetArray());//tony if(!arr0) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !"); - DataArrayDouble *arr=dynamic_cast(arr0);//tony + DataArrayDouble *arr(dynamic_cast(arr0));//tony if(!arr0) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !"); int sz=0; @@ -2843,9 +2843,9 @@ void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) } } -MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname) +MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid) { - return new MEDFileFieldGlobs(fname); + return new MEDFileFieldGlobs(fid); } MEDFileFieldGlobs *MEDFileFieldGlobs::New() @@ -2942,7 +2942,7 @@ MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector return ret.retn(); } -MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname) +MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid)) { } @@ -2980,11 +2980,6 @@ void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const } } -void MEDFileFieldGlobs::setFileName(const std::string& fileName) -{ - _file_name=fileName; -} - void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) { for(std::vector< MCAuto >::iterator it=_pfls.begin();it!=_pfls.end();it++) @@ -3305,7 +3300,7 @@ std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, con * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here. * \param [in] fname - the file name. */ -MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname)) +MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid)) { } @@ -5435,11 +5430,9 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileFieldGlobsReal(fileName) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileFieldGlobsReal(fid) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); _content=BuildContentFrom(fid,loadAll,ms); loadGlobals(fid); } @@ -5495,11 +5488,9 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileFieldGlobsReal(fileName) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileFieldGlobsReal(fid) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); _content=BuildContentFrom(fid,fieldName,loadAll,ms); loadGlobals(fid); } @@ -5531,8 +5522,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDF MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); MCAuto c(BuildContentFrom(fid,loadAll,0)); MCAuto ret(BuildNewInstanceFromContent(c,fileName)); ret->loadGlobals(fid); @@ -5541,8 +5531,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); MCAuto c(BuildContentFrom(fid,fieldName,loadAll,0)); MCAuto ret(BuildNewInstanceFromContent(c,fileName)); ret->loadGlobals(fid); @@ -5551,8 +5540,7 @@ MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid=OpenMEDFileForRead(fileName); MCAuto c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0)); MCAuto ret(BuildNewInstanceFromContent(c,fileName)); ret->loadGlobals(fid); @@ -5617,11 +5605,9 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i return ret.retn(); } -MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileFieldGlobsReal(fileName) +MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileFieldGlobsReal(fid) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms); loadGlobals(fid); } @@ -5800,24 +5786,6 @@ const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBa return ret; } -/*! - * Writes \a this field into a MED file specified by its name. - * \param [in] fileName - the MED file name. - * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics. - * - 2 - erase; an existing file is removed. - * - 1 - append; same data should not be present in an existing file. - * - 0 - overwrite; same data present in an existing file is overwritten. - * \throw If the field name is not set. - * \throw If no field data is set. - * \throw If \a mode == 1 and the same data is present in an existing file. - */ -void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod(MEDFileUtilities::TraduceWriteMode(mode)); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod)); - writeLL(fid); -} - /*! * This method alloc the arrays and load potentially huge arrays contained in this field. * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter. @@ -5830,7 +5798,7 @@ void MEDFileAnyTypeField1TS::loadArrays() { if(getFileName().empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !"); - MEDFileUtilities::AutoFid fid(MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase()); } @@ -5845,7 +5813,7 @@ void MEDFileAnyTypeField1TS::loadArraysIfNecessary() { if(!getFileName().empty()) { - MEDFileUtilities::AutoFid fid(MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase()); } } @@ -6198,7 +6166,8 @@ int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field */ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll) { - MCAuto ret(new MEDFileField1TS(fileName,loadAll,0)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileField1TS(fid,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -6215,7 +6184,8 @@ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll) */ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MCAuto ret(new MEDFileField1TS(fileName,fieldName,loadAll,0)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileField1TS(fid,fieldName,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -6235,7 +6205,8 @@ 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) { - MCAuto ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -6397,22 +6368,22 @@ MEDFileField1TS *MEDFileField1TS::extractPart(const std::map > MEDFileField1TS::getFieldSplitedBy MEDFileIntField1TS *MEDFileIntField1TS::New() { - MCAuto ret=new MEDFileIntField1TS; + MCAuto ret(new MEDFileIntField1TS); ret->contentNotNull(); return ret.retn(); } MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll) { - MCAuto ret(new MEDFileIntField1TS(fileName,loadAll,0)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileIntField1TS(fid,loadAll,0)); ret->contentNotNull(); return ret.retn(); } MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MCAuto ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto 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) { - MCAuto ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0)); ret->contentNotNull(); return ret.retn(); } @@ -6743,22 +6717,22 @@ MEDFileIntField1TS::MEDFileIntField1TS() _content=new MEDFileIntField1TSWithoutSDA; } -MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileAnyTypeField1TS(fileName,loadAll,ms) +MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fid,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms) +MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms) +MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) @@ -8124,12 +8098,10 @@ MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS() { } -MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileFieldGlobsReal(fileName) +MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileFieldGlobsReal(fid) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - _content=BuildContentFrom(fid,fileName,loadAll,ms); + _content=BuildContentFrom(fid,loadAll,ms); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -8137,7 +8109,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) { med_field_type typcha; std::vector infos; @@ -8159,7 +8131,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -8167,7 +8139,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr return ret.retn(); } -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) +MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms) { med_field_type typcha; // @@ -8189,7 +8161,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFr } default: { - std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -8218,12 +8190,10 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont 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(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) -try:MEDFileFieldGlobsReal(fileName) +MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileFieldGlobsReal(fid) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities); + _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities); loadGlobals(fid); } catch(INTERP_KERNEL::Exception& e) @@ -8324,10 +8294,9 @@ MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble */ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - MCAuto c=BuildContentFrom(fid,fileName,loadAll,0); - MCAuto ret=BuildNewInstanceFromContent(c,fileName); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto c(BuildContentFrom(fid,loadAll,0)); + MCAuto ret(BuildNewInstanceFromContent(c,fileName)); ret->loadGlobals(fid); return ret.retn(); } @@ -8344,9 +8313,8 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& f */ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY); - MCAuto c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto c(BuildContentFrom(fid,fieldName,loadAll,0,0)); MCAuto ret=BuildNewInstanceFromContent(c,fileName); ret->loadGlobals(fid); return ret.retn(); @@ -8595,24 +8563,6 @@ void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const contentNotNullBase()->writeLL(fid,*this); } -/*! - * Writes \a this field into a MED file specified by its name. - * \param [in] fileName - the MED file name. - * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics. - * - 2 - erase; an existing file is removed. - * - 1 - append; same data should not be present in an existing file. - * - 0 - overwrite; same data present in an existing file is overwritten. - * \throw If the field name is not set. - * \throw If no field data is set. - * \throw If \a mode == 1 and the same data is present in an existing file. - */ -void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - writeLL(fid); -} - /*! * This method alloc the arrays and load potentially huge arrays contained in this field. * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter. @@ -8624,7 +8574,7 @@ void MEDFileAnyTypeFieldMultiTS::loadArrays() { if(getFileName().empty()) throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !"); - MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase()); } @@ -8639,7 +8589,7 @@ void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() { if(!getFileName().empty()) { - MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase()); } } @@ -9141,7 +9091,8 @@ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New() */ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll) { - MCAuto ret=new MEDFileFieldMultiTS(fileName,loadAll,0); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileFieldMultiTS(fid,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9158,7 +9109,8 @@ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool */ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MCAuto ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9182,7 +9134,8 @@ MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSD MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll) { - MCAuto ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities)); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,&entities)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9531,15 +9484,15 @@ MEDFileFieldMultiTS::MEDFileFieldMultiTS() _content=new MEDFileFieldMultiTSWithoutSDA; } -MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms) +MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) -try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities) +MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) @@ -9620,7 +9573,8 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New() */ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll) { - MCAuto ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileIntFieldMultiTS(fid,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9637,7 +9591,8 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, */ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll) { - MCAuto ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9661,7 +9616,8 @@ MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTS MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll) { - MCAuto ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + MCAuto ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,&entities)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -10015,15 +9971,15 @@ MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWitho { } -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) -try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms) +MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms) +try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) -try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities) +MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) @@ -10048,17 +10004,21 @@ MEDFileFields *MEDFileFields::New() MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll) { - return new MEDFileFields(fileName,loadAll,0,0); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return new MEDFileFields(fid,loadAll,0,0); } MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms) { - return new MEDFileFields(fileName,loadAll,ms,0); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return new MEDFileFields(fid,loadAll,ms,0); } MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair >& entities, bool loadAll) { - return new MEDFileFields(fileName,loadAll,0,&entities); + MEDFileUtilities::CheckFileForRead(fileName); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + return new MEDFileFields(fid,loadAll,0,&entities); } std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const @@ -10216,11 +10176,9 @@ MEDFileFields::MEDFileFields() { } -MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) -try:MEDFileFieldGlobsReal(fileName) +MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +try:MEDFileFieldGlobsReal(fid) { - MEDFileUtilities::CheckFileForRead(fileName); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); int nbFields(MEDnField(fid)); _fields.resize(nbFields); med_field_type typcha; @@ -10243,7 +10201,7 @@ try:MEDFileFieldGlobsReal(fileName) } default: { - std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; + std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !"; throw INTERP_KERNEL::Exception(oss.str()); } } @@ -10271,13 +10229,6 @@ void MEDFileFields::writeLL(med_idt fid) const } } -void MEDFileFields::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod)); - writeLL(fid); -} - /*! * This method alloc the arrays and load potentially huge arrays contained in this field. * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter. @@ -10289,7 +10240,7 @@ void MEDFileFields::loadArrays() { if(getFileName().empty()) throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !"); - MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) { MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); @@ -10309,7 +10260,7 @@ void MEDFileFields::loadArraysIfNecessary() { if(!getFileName().empty()) { - MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY); + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName())); for(std::vector< MCAuto >::iterator it=_fields.begin();it!=_fields.end();it++) { MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 684f08a96..a884070c2 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -325,7 +325,7 @@ namespace MEDCoupling class MEDFileFieldGlobs : public RefCountObject { public: - static MEDFileFieldGlobs *New(const std::string& fname); + static MEDFileFieldGlobs *New(med_idt fid); static MEDFileFieldGlobs *New(); std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildrenWithNull() const; @@ -349,7 +349,7 @@ namespace MEDCoupling std::string createNewNameOfLoc() const; std::vector< std::vector > whichAreEqualProfiles() const; std::vector< std::vector > whichAreEqualLocs(double eps) const; - void setFileName(const std::string& fileName); + void setFileName(const std::string& fileName) { _file_name=fileName; } void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif); void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif); int getNbOfGaussPtPerCell(int locId) const; @@ -371,7 +371,7 @@ namespace MEDCoupling // static std::string CreateNewNameNotIn(const std::string& prefix, const std::vector& namesToAvoid); protected: - MEDFileFieldGlobs(const std::string& fname); + MEDFileFieldGlobs(med_idt fid); MEDFileFieldGlobs(); ~MEDFileFieldGlobs(); protected: @@ -385,7 +385,7 @@ namespace MEDCoupling class MEDFileFieldGlobsReal { public: - MEDLOADER_EXPORT MEDFileFieldGlobsReal(const std::string& fname); + MEDLOADER_EXPORT MEDFileFieldGlobsReal(med_idt fid); MEDLOADER_EXPORT MEDFileFieldGlobsReal(); MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; @@ -637,13 +637,13 @@ namespace MEDCoupling /*! * User class. */ - class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal + class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileFieldGlobsReal { protected: MEDLOADER_EXPORT MEDFileAnyTypeField1TS(); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + 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 MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms); @@ -687,7 +687,6 @@ namespace MEDCoupling MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const; MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector& levs) const; public: - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; MEDLOADER_EXPORT void loadArrays(); MEDLOADER_EXPORT void loadArraysIfNecessary(); MEDLOADER_EXPORT void unloadArrays(); @@ -768,9 +767,9 @@ namespace MEDCoupling MEDFileField1TSWithoutSDA *contentNotNull(); private: ~MEDFileField1TS() { } - MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms); - MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); + MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); + MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent); MEDFileField1TS(); }; @@ -810,9 +809,9 @@ namespace MEDCoupling private: ~MEDFileIntField1TS() { } MEDFileIntField1TS(); - MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); + MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent); }; @@ -939,16 +938,16 @@ namespace MEDCoupling /*! * User class. */ - class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal + class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileFieldGlobsReal { protected: MEDFileAnyTypeFieldMultiTS(); - MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms); - MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities=0); + 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 MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms); - static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + 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(const std::string& fileName, const std::string& fieldName, bool loadAll=true); @@ -956,7 +955,6 @@ namespace MEDCoupling MEDLOADER_EXPORT void loadArraysIfNecessary(); MEDLOADER_EXPORT void unloadArrays(); MEDLOADER_EXPORT void unloadArraysWithoutDataLoss(); - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; @@ -1069,8 +1067,8 @@ namespace MEDCoupling ~MEDFileFieldMultiTS() { } MEDFileFieldMultiTS(); MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); - MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms); - MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities=0); + MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities=0); }; /*! @@ -1110,8 +1108,8 @@ namespace MEDCoupling ~MEDFileIntFieldMultiTS() { } MEDFileIntFieldMultiTS(); MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); - MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms); - MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities=0); + MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities=0); }; class MEDFileAnyTypeFieldMultiTSIterator @@ -1131,7 +1129,7 @@ namespace MEDCoupling /*! * Use class. */ - class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileFields *New(); @@ -1142,7 +1140,6 @@ namespace MEDCoupling MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; MEDLOADER_EXPORT MEDFileFields *deepCopy() const; MEDLOADER_EXPORT MEDFileFields *shallowCpy() const; - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT void loadArrays(); MEDLOADER_EXPORT void loadArraysIfNecessary(); @@ -1185,7 +1182,7 @@ namespace MEDCoupling private: ~MEDFileFields() { } MEDFileFields(); - MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); private: std::vector< MCAuto > _fields; }; diff --git a/src/MEDLoader/MEDFileJoint.cxx b/src/MEDLoader/MEDFileJoint.cxx index 94660c7f3..0895ba94b 100644 --- a/src/MEDLoader/MEDFileJoint.cxx +++ b/src/MEDLoader/MEDFileJoint.cxx @@ -495,33 +495,13 @@ MEDFileJoint::MEDFileJoint(med_idt fid, const std::string& mName, int curJoint) } } -/*! - * Writes \a this joint into a MED file specified by its name. - * \param [in] fileName - the MED file name. - * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics. - * - 2 - erase; an existing file is removed. - * - 1 - append; same data should not be present in an existing file. - * - 0 - overwrite; same data present in an existing file is overwritten. - * \throw If the mesh name is not set. - * \throw If \a mode == 1 and the same data is present in an existing file. - */ -void MEDFileJoint::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - std::ostringstream oss; oss << "MEDFileJoint : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); - write(fid); -} - -void MEDFileJoint::write(med_idt fid) const +void MEDFileJoint::writeLL(med_idt fid) const { // if ( _loc_mesh_name.empty() ) // throw INTERP_KERNEL::Exception("MEDFileJoint::write : name of a local mesh not defined!"); MEDFILESAFECALLERWR0(MEDsubdomainJointCr,(fid,getLocalMeshName().c_str(),getJointName().c_str(),getDescription().c_str(),getDomainNumber(),getRemoteMeshName().c_str())); - for(std::vector< MCAuto >::const_iterator it=_joint.begin();it!=_joint.end();it++) { + for(std::vector< MCAuto >::const_iterator it=_joint.begin();it!=_joint.end();it++) (*it)->writeLL(fid, getLocalMeshName(),getJointName()); - } } void MEDFileJoint::pushStep(MEDFileJointOneStep* step) @@ -654,21 +634,10 @@ MEDFileJoints *MEDFileJoints::New(med_idt fid, const std::string& meshName) return new MEDFileJoints( fid, meshName ); } -void MEDFileJoints::write(med_idt fid) const +void MEDFileJoints::writeLL(med_idt fid) const { for(std::vector< MCAuto >::const_iterator it=_joints.begin();it!=_joints.end();it++) - { - (*it)->write(fid); - } -} - -void MEDFileJoints::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - std::ostringstream oss; oss << "MEDFileJoints : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); - write(fid); + (*it)->writeLL(fid); } std::string MEDFileJoints::getMeshName() const diff --git a/src/MEDLoader/MEDFileJoint.hxx b/src/MEDLoader/MEDFileJoint.hxx index 81ab0698f..bba126ccc 100644 --- a/src/MEDLoader/MEDFileJoint.hxx +++ b/src/MEDLoader/MEDFileJoint.hxx @@ -112,7 +112,7 @@ private: * \brief Joint holds a sequence of joints of different iterations relating to * a pair of mesh domains: a local one and a distant one */ -class MEDFileJoint : public RefCountObject, public MEDFileWritable +class MEDFileJoint : public RefCountObject, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileJoint *New(); @@ -139,8 +139,7 @@ public: MEDLOADER_EXPORT int getNumberOfSteps() const; MEDLOADER_EXPORT MEDFileJointOneStep *getStepAtPos(int i) const; - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; - MEDLOADER_EXPORT void write(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT std::string simpleRepr() const; private: @@ -158,7 +157,7 @@ public: /*! * \brief Joints of a mesh domain relating to all other mesh domains */ - class MEDFileJoints : public RefCountObject, public MEDFileWritable + class MEDFileJoints : public RefCountObject, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileJoints *New(); @@ -169,8 +168,7 @@ public: MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; MEDLOADER_EXPORT std::string simpleRepr() const; MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const; - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; - MEDLOADER_EXPORT void write(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT std::string getMeshName() const; MEDLOADER_EXPORT int getNumberOfJoints() const; MEDLOADER_EXPORT MEDFileJoint *getJointAtPos(int i) const; diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 6c2cd2f71..1f9292da7 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -181,38 +181,19 @@ MEDFileMesh *MEDFileMesh::New(const std::string& fileName, const std::string& mN * \throw If the file is open for reading only. * \throw If the writing mode == 1 and the same data is present in an existing file. */ -void MEDFileMesh::write(med_idt fid) const +void MEDFileMesh::writeLL(med_idt fid) const { if(!existsFamily(0)) const_cast(this)->addFamily(DFT_FAM_NAME,0); if(_name.empty()) throw INTERP_KERNEL::Exception("MEDFileMesh : name is empty. MED file ask for a NON EMPTY name !"); - writeLL(fid); + writeMeshLL(fid); writeJoints(fid); const MEDFileEquivalences *eqs(_equiv); if(eqs) eqs->write(fid); } -/*! - * Writes \a this mesh into a MED file specified by its name. - * \param [in] fileName - the MED file name. - * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics. - * - 2 - erase; an existing file is removed. - * - 1 - append; same data should not be present in an existing file. - * - 0 - overwrite; same data present in an existing file is overwritten. - * \throw If the mesh name is not set. - * \throw If \a mode == 1 and the same data is present in an existing file. - */ -void MEDFileMesh::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); - write(fid); -} - /*! * Checks if \a this and another mesh are equal. * \param [in] other - the mesh to compare with. @@ -2679,8 +2660,8 @@ void MEDFileUMesh::loadPartUMeshFromFile(med_idt fid, const std::string& mName, */ void MEDFileMesh::writeJoints(med_idt fid) const { - if ( (const MEDFileJoints*) _joints ) - _joints->write(fid); + if ( _joints.isNotNull() ) + _joints->writeLL(fid); } /*! @@ -2837,7 +2818,7 @@ MEDFileUMesh::~MEDFileUMesh() { } -void MEDFileUMesh::writeLL(med_idt fid) const +void MEDFileUMesh::writeMeshLL(med_idt fid) const { const DataArrayDouble *coo=_coords; INTERP_KERNEL::AutoPtr maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -6666,7 +6647,7 @@ MEDFileMesh *MEDFileCMesh::cartesianize() const } } -void MEDFileCMesh::writeLL(med_idt fid) const +void MEDFileCMesh::writeMeshLL(med_idt fid) const { INTERP_KERNEL::AutoPtr maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); @@ -6897,7 +6878,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -void MEDFileCurveLinearMesh::writeLL(med_idt fid) const +void MEDFileCurveLinearMesh::writeMeshLL(med_idt fid) const { INTERP_KERNEL::AutoPtr maa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr desc=MEDLoaderBase::buildEmptyString(MED_COMMENT_SIZE); @@ -6911,7 +6892,7 @@ void MEDFileCurveLinearMesh::writeLL(med_idt fid) const INTERP_KERNEL::AutoPtr unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_SNAME_SIZE); const DataArrayDouble *coords=_clmesh->getCoords(); if(!coords) - throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::writeLL : no coordinates set !"); + throw INTERP_KERNEL::Exception("MEDFileCurveLinearMesh::writeMeshLL : no coordinates set !"); for(int i=0;igetCoords()->getInfoOnComponent(i)); @@ -7069,7 +7050,7 @@ void MEDFileMeshMultiTS::setJoints( MEDFileJoints* joints ) } } -void MEDFileMeshMultiTS::write(med_idt fid) const +void MEDFileMeshMultiTS::writeLL(med_idt fid) const { MEDFileJoints *joints(getJoints()); bool jointsWritten(false); @@ -7082,21 +7063,12 @@ void MEDFileMeshMultiTS::write(med_idt fid) const jointsWritten = true; (*it)->copyOptionsFrom(*this); - (*it)->write(fid); + (*it)->writeLL(fid); } (const_cast(this))->setJoints( joints ); // restore joints } -void MEDFileMeshMultiTS::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); - write(fid); -} - void MEDFileMeshMultiTS::loadFromFile(const std::string& fileName, const std::string& mName) { MEDFileJoints* joints = 0; @@ -7157,25 +7129,17 @@ MEDFileMeshes *MEDFileMeshes::New(const std::string& fileName) return new MEDFileMeshes(fileName); } -void MEDFileMeshes::write(med_idt fid) const +void MEDFileMeshes::writeLL(med_idt fid) const { checkConsistencyLight(); for(std::vector< MCAuto >::const_iterator it=_meshes.begin();it!=_meshes.end();it++) { (*it)->copyOptionsFrom(*this); - (*it)->write(fid); + (*it)->writeLL(fid); } } -void MEDFileMeshes::write(const std::string& fileName, int mode) const -{ - med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode); - MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod); - std::ostringstream oss; oss << "MEDFileMesh : error on attempt to write in file : \"" << fileName << "\""; - MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); - checkConsistencyLight(); - write(fid); -} +// MEDFileMeshes::writ checkConsistencyLight(); int MEDFileMeshes::getNumberOfMeshes() const { diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index ac0b6fd3e..b9dc110c0 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -37,11 +37,12 @@ namespace MEDCoupling class MEDFileFieldGlobsReal; class MEDFileField1TSStructItem; - class MEDFileMesh : public RefCountObject, public MEDFileWritable + class MEDFileMesh : public RefCountObject, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileMesh *New(const std::string& fileName, 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 void writeLL(med_idt fid) const; MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; MEDLOADER_EXPORT virtual MEDFileMesh *createNewEmpty() const = 0; @@ -82,8 +83,6 @@ namespace MEDCoupling MEDLOADER_EXPORT virtual std::vector getFamArrNonEmptyLevelsExt() const = 0; MEDLOADER_EXPORT virtual std::vector getNumArrNonEmptyLevelsExt() const = 0; MEDLOADER_EXPORT virtual std::vector getNameArrNonEmptyLevelsExt() const = 0; - MEDLOADER_EXPORT virtual void write(const std::string& fileName, int mode) const; - MEDLOADER_EXPORT virtual void write(med_idt fid) const; MEDLOADER_EXPORT virtual int getSizeAtLevel(int meshDimRelToMaxExt) const = 0; MEDLOADER_EXPORT virtual MEDCouplingMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const = 0; MEDLOADER_EXPORT virtual std::vector getDistributionOfTypes(int meshDimRelToMax) const; @@ -198,7 +197,6 @@ namespace MEDCoupling //! protected because no way in MED file API to specify this name void setUnivName(const std::string& name) { _univ_name=name; } void addFamilyOnAllGroupsHaving(const std::string& famName, const std::string& otherFamName); - virtual void writeLL(med_idt fid) const = 0; void dealWithTinyInfo(const MEDCouplingMesh *m); virtual void synchronizeTinyInfoOnLeaves() const = 0; void getFamilyRepr(std::ostream& oss) const; @@ -220,6 +218,8 @@ namespace MEDCoupling bool areEquivalencesEqual(const MEDFileMesh *other, std::string& what) const; void getEquivalencesRepr(std::ostream& oss) const; void checkCartesian() const; + private: + virtual void writeMeshLL(med_idt fid) const = 0; protected: int _order; int _iteration; @@ -350,7 +350,7 @@ namespace MEDCoupling std::vector< MCAuto >& bigArraysI, MCAuto& bigArrayD); private: MEDLOADER_EXPORT ~MEDFileUMesh(); - void writeLL(med_idt fid) const; + void writeMeshLL(med_idt fid) const; MEDFileUMesh(); MEDFileUMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); void loadPartUMeshFromFile(med_idt fid, const std::string& mName, const std::vector& types, const std::vector& slicPerTyp, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0); @@ -472,7 +472,7 @@ namespace MEDCoupling private: ~MEDFileCMesh() { } const MEDCouplingStructuredMesh *getStructuredMesh() const; - void writeLL(med_idt fid) const; + void writeMeshLL(med_idt fid) const; MEDFileCMesh(); void synchronizeTinyInfoOnLeaves() const; MEDFileCMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); @@ -507,13 +507,13 @@ namespace MEDCoupling MEDFileCurveLinearMesh(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs); const MEDCouplingStructuredMesh *getStructuredMesh() const; void synchronizeTinyInfoOnLeaves() const; - void writeLL(med_idt fid) const; + void writeMeshLL(med_idt fid) const; void loadLL(med_idt fid, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs);//to imp private: MCAuto _clmesh; }; - class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable + class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileMeshMultiTS *New(); @@ -527,8 +527,7 @@ namespace MEDCoupling MEDLOADER_EXPORT bool changeNames(const std::vector< std::pair >& modifTab); MEDLOADER_EXPORT void cartesianizeMe(); MEDLOADER_EXPORT MEDFileMesh *getOneTimeStep() const; - MEDLOADER_EXPORT void write(med_idt fid) const; - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT void setOneTimeStep(MEDFileMesh *mesh1TimeStep); MEDLOADER_EXPORT MEDFileJoints *getJoints() const; MEDLOADER_EXPORT void setJoints(MEDFileJoints* joints); @@ -544,7 +543,7 @@ namespace MEDCoupling class MEDFileMeshesIterator; - class MEDFileMeshes : public RefCountObject, public MEDFileWritable + class MEDFileMeshes : public RefCountObject, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileMeshes *New(); @@ -554,8 +553,7 @@ namespace MEDCoupling MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; MEDLOADER_EXPORT std::string simpleRepr() const; MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const; - MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const; - MEDLOADER_EXPORT void write(med_idt fid) const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const; MEDLOADER_EXPORT int getNumberOfMeshes() const; MEDLOADER_EXPORT MEDFileMeshesIterator *iterator(); MEDLOADER_EXPORT MEDFileMesh *getMeshAtPos(int i) const; diff --git a/src/MEDLoader/MEDFileParameter.cxx b/src/MEDLoader/MEDFileParameter.cxx index be6ee90ce..85b32aa4d 100644 --- a/src/MEDLoader/MEDFileParameter.cxx +++ b/src/MEDLoader/MEDFileParameter.cxx @@ -771,7 +771,7 @@ bool MEDFileParameters::isEqual(const MEDFileParameters *other, double eps, std: return true; } -MEDFileParameters::MEDFileParameters(const MEDFileParameters& other, bool deepCopy):MEDFileWritable(other),_params(other._params) +MEDFileParameters::MEDFileParameters(const MEDFileParameters& other, bool deepCopy):MEDFileWritableStandAlone(other),_params(other._params) { if(deepCopy) for(std::size_t i=0;i<_params.size();i++) diff --git a/src/MEDLoader/MEDFileParameter.hxx b/src/MEDLoader/MEDFileParameter.hxx index 32ec8426f..594129260 100644 --- a/src/MEDLoader/MEDFileParameter.hxx +++ b/src/MEDLoader/MEDFileParameter.hxx @@ -152,7 +152,7 @@ namespace MEDCoupling std::vector< MCAuto > _param_per_ts; }; - class MEDFileParameters : public RefCountObject, public MEDFileWritable + class MEDFileParameters : public RefCountObject, public MEDFileWritableStandAlone { public: MEDLOADER_EXPORT static MEDFileParameters *New(); diff --git a/src/MEDLoader/MEDFileUtilities.cxx b/src/MEDLoader/MEDFileUtilities.cxx index 2d70be183..e697d8135 100644 --- a/src/MEDLoader/MEDFileUtilities.cxx +++ b/src/MEDLoader/MEDFileUtilities.cxx @@ -158,3 +158,28 @@ std::string MEDCoupling::MEDFileWritable::FileNameFromFID(med_idt fid) throw INTERP_KERNEL::Exception("MEDFileWritable::FileNameFromFID : Return code of MEDFile call \"MEDfileName\" is not >=0 as expected !"); return std::string(tmp); } + +MEDFileUtilities::AutoFid MEDCoupling::OpenMEDFileForRead(const std::string& fileName) +{ + MEDFileUtilities::CheckFileForRead(fileName); + return MEDFileUtilities::AutoFid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY)); +} + +/*! + * Writes \a this mesh into a MED file specified by its name. + * \param [in] fileName - the MED file name. + * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics. + * - 2 - erase; an existing file is removed. + * - 1 - append; same data should not be present in an existing file. + * - 0 - overwrite; same data present in an existing file is overwritten. + * \throw If the mesh name is not set. + * \throw If \a mode == 1 and the same data is present in an existing file. + */ +void MEDCoupling::MEDFileWritableStandAlone::write(const std::string& fileName, int mode) const +{ + med_access_mode medmod(MEDFileUtilities::TraduceWriteMode(mode)); + MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod)); + std::ostringstream oss; oss << "MEDFileWritableStandAlone : error on attempt to write in file : \"" << fileName << "\""; + MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); + writeLL(fid); +} diff --git a/src/MEDLoader/MEDFileUtilities.hxx b/src/MEDLoader/MEDFileUtilities.hxx index 24eab985a..8116d7e5c 100644 --- a/src/MEDLoader/MEDFileUtilities.hxx +++ b/src/MEDLoader/MEDFileUtilities.hxx @@ -60,6 +60,15 @@ namespace MEDCoupling mutable int _too_long_str; mutable int _zipconn_pol; }; + + class MEDFileWritableStandAlone : public MEDFileWritable + { + public: + MEDLOADER_EXPORT virtual void writeLL(med_idt fid) const = 0; + MEDLOADER_EXPORT virtual void write(const std::string& fileName, int mode) const; + }; + + MEDFileUtilities::AutoFid OpenMEDFileForRead(const std::string& fileName); } #endif diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 788d419ec..3602338fb 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -531,7 +531,13 @@ namespace MEDCoupling int getZipConnPolicy() throw(INTERP_KERNEL::Exception); void setZipConnPolicy(int newVal) throw(INTERP_KERNEL::Exception); }; - + + class MEDFileWritableStandAlone : public MEDFileWritable + { + public: + void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); + }; + class MEDFileMeshReadSelector { public: @@ -652,7 +658,7 @@ namespace MEDCoupling } }; - class MEDFileJoint : public RefCountObject, public MEDFileWritable + class MEDFileJoint : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileJoint *New() throw(INTERP_KERNEL::Exception); @@ -675,7 +681,6 @@ namespace MEDCoupling void pushStep(MEDFileJointOneStep* step); int getNumberOfSteps() const; MEDFileJointOneStep *getStepAtPos(int i) const; - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); std::string simpleRepr() const; %extend { @@ -696,14 +701,13 @@ namespace MEDCoupling } }; - class MEDFileJoints : public RefCountObject, public MEDFileWritable + class MEDFileJoints : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileJoints *New() throw(INTERP_KERNEL::Exception); static MEDFileJoints *New(const std::string& fileName, const std::string& meshName) throw(INTERP_KERNEL::Exception); MEDFileJoints *deepCopy() const; std::string simpleRepr() const; - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); std::string getMeshName() const; int getNumberOfJoints() const; std::vector getJointsNames() const; @@ -907,7 +911,7 @@ namespace MEDCoupling } }; - class MEDFileMesh : public RefCountObject, public MEDFileWritable + class MEDFileMesh : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileMesh *New(const std::string& fileName, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception); @@ -947,7 +951,6 @@ namespace MEDCoupling virtual MEDFileMesh *cartesianize() const throw(INTERP_KERNEL::Exception); std::vector getNonEmptyLevels() const throw(INTERP_KERNEL::Exception); std::vector getNonEmptyLevelsExt() const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); int getSizeAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception); // bool existsGroup(const std::string& groupName) const throw(INTERP_KERNEL::Exception); @@ -1605,7 +1608,7 @@ namespace MEDCoupling } }; - class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritable + class MEDFileMeshMultiTS : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileMeshMultiTS *New(); @@ -1613,7 +1616,6 @@ namespace MEDCoupling static MEDFileMeshMultiTS *New(const std::string& fileName, const std::string& mName) throw(INTERP_KERNEL::Exception); MEDFileMeshMultiTS *deepCopy() const throw(INTERP_KERNEL::Exception); std::string getName() const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); void setOneTimeStep(MEDFileMesh *mesh1TimeStep) throw(INTERP_KERNEL::Exception); void cartesianizeMe() throw(INTERP_KERNEL::Exception); %extend @@ -1665,13 +1667,12 @@ namespace MEDCoupling } }; - class MEDFileMeshes : public RefCountObject, public MEDFileWritable + class MEDFileMeshes : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileMeshes *New(); static MEDFileMeshes *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); MEDFileMeshes *deepCopy() const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); int getNumberOfMeshes() const throw(INTERP_KERNEL::Exception); std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); // @@ -1891,13 +1892,12 @@ namespace MEDCoupling } }; - class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); void loadArrays() throw(INTERP_KERNEL::Exception); void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); void unloadArrays() throw(INTERP_KERNEL::Exception); @@ -2270,7 +2270,7 @@ namespace MEDCoupling } }; - class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); @@ -2290,7 +2290,6 @@ namespace MEDCoupling void eraseEmptyTS() throw(INTERP_KERNEL::Exception); int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); void loadArrays() throw(INTERP_KERNEL::Exception); void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); void unloadArrays() throw(INTERP_KERNEL::Exception); @@ -2864,7 +2863,7 @@ namespace MEDCoupling } }; - class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable + class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone { public: static MEDFileFields *New() throw(INTERP_KERNEL::Exception); @@ -2876,7 +2875,6 @@ namespace MEDCoupling void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); void unloadArrays() throw(INTERP_KERNEL::Exception); void unloadArraysWithoutDataLoss() throw(INTERP_KERNEL::Exception); - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); int getNumberOfFields() const; std::vector getFieldsNames() const throw(INTERP_KERNEL::Exception); std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); @@ -3342,7 +3340,7 @@ namespace MEDCoupling } }; - class MEDFileParameters : public RefCountObject, public MEDFileWritable + class MEDFileParameters : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileParameters *New(); @@ -3429,7 +3427,7 @@ namespace MEDCoupling } }; - class MEDFileData : public RefCountObject, public MEDFileWritable + class MEDFileData : public RefCountObject, public MEDFileWritableStandAlone { public: static MEDFileData *New(const std::string& fileName) throw(INTERP_KERNEL::Exception); @@ -3445,7 +3443,6 @@ namespace MEDCoupling bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName) throw(INTERP_KERNEL::Exception); bool unPolyzeMeshes() throw(INTERP_KERNEL::Exception); // - void write(const std::string& fileName, int mode) const throw(INTERP_KERNEL::Exception); %extend { MEDFileData(const std::string& fileName) throw(INTERP_KERNEL::Exception)