From: Anthony Geay Date: Fri, 20 Jan 2017 09:17:32 +0000 (+0100) Subject: Refacto for integration into MEDFileFields X-Git-Tag: V8_3_0a2~38^2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5333bed206ae35b171662cf2a5651243c840c036;p=tools%2Fmedcoupling.git Refacto for integration into MEDFileFields --- diff --git a/src/MEDCoupling/MCAuto.hxx b/src/MEDCoupling/MCAuto.hxx index 913024e84..6614cbfdf 100644 --- a/src/MEDCoupling/MCAuto.hxx +++ b/src/MEDCoupling/MCAuto.hxx @@ -79,6 +79,33 @@ namespace MEDCoupling ptr->incrRef(); return ret; } + + template + class MCConstAuto + { + public: + MCConstAuto(const MCConstAuto& other):_ptr(0) { referPtr(other._ptr); } + MCConstAuto(const T *ptr=0):_ptr(ptr) { } + ~MCConstAuto() { destroyPtr(); } + bool isNull() const { return _ptr==0; } + bool isNotNull() const { return !isNull(); } + void nullify() { destroyPtr(); _ptr=0; } + bool operator==(const MCConstAuto& other) const { return _ptr==other._ptr; } + bool operator==(const T *other) const { return _ptr==other; } + MCConstAuto &operator=(const MCConstAuto& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; } + MCConstAuto &operator=(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; } + void takeRef(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; if(_ptr) _ptr->incrRef(); } } + const T *operator->() { return _ptr ; } + const T *operator->() const { return _ptr; } + const T& operator*() { return *_ptr; } + const T& operator*() const { return *_ptr; } + operator const T *() const { return _ptr; } + private: + void referPtr(T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); } + void destroyPtr() { if(_ptr) _ptr->decrRef(); } + private: + const T *_ptr; + }; } #endif diff --git a/src/MEDLoader/CMakeLists.txt b/src/MEDLoader/CMakeLists.txt index eb670a399..de68f97d8 100644 --- a/src/MEDLoader/CMakeLists.txt +++ b/src/MEDLoader/CMakeLists.txt @@ -71,6 +71,7 @@ SET(medloader_SOURCES MEDFileMeshReadSelector.cxx MEDFileMeshSupport.cxx MEDFileStructureElement.cxx + MEDFileEntities.cxx SauvMedConvertor.cxx SauvReader.cxx SauvWriter.cxx diff --git a/src/MEDLoader/MEDFileEntities.cxx b/src/MEDLoader/MEDFileEntities.cxx new file mode 100644 index 000000000..dee2c2e9f --- /dev/null +++ b/src/MEDLoader/MEDFileEntities.cxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2017 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 "MEDFileEntities.hxx" + +using namespace MEDCoupling; + +MEDFileEntities *MEDFileEntities::BuildFrom(const std::vector< std::pair > *entities) +{ + if(!entities) + return new MEDFileAllStaticEntites; + else + return new MEDFileStaticEntities(*entities); +} + +MEDFileEntities *MEDFileEntities::BuildFrom(const MEDFileStructureElements& se) +{ + if(se.getNumberOf()==0) + return new MEDFileAllStaticEntites; + else + return new MEDFileAllStaticEntitiesPlusDyn(&se); +} + +////////////// + +std::vector MEDFileStaticEntities::getDynGTAvail() const +{ + return std::vector(); +} + +bool MEDFileStaticEntities::areAllStaticTypesPresent() const +{ + return false; +} + +////////////// + + +std::vector MEDFileAllStaticEntites::getDynGTAvail() const +{ + return std::vector(); +} + +bool MEDFileAllStaticEntites::areAllStaticTypesPresent() const +{ + return true; +} + +////////////// + +MEDFileAllStaticEntitiesPlusDyn::MEDFileAllStaticEntitiesPlusDyn(const MEDFileStructureElements *se):_se(se) +{ + if(se) + se->incrRef(); +} + +std::vector MEDFileAllStaticEntitiesPlusDyn::getDynGTAvail() const +{ + return _se->getDynGTAvail(); +} + +bool MEDFileAllStaticEntitiesPlusDyn::areAllStaticTypesPresent() const +{ + return true; +} diff --git a/src/MEDLoader/MEDFileEntities.hxx b/src/MEDLoader/MEDFileEntities.hxx new file mode 100644 index 000000000..3371273d9 --- /dev/null +++ b/src/MEDLoader/MEDFileEntities.hxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2017 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 __MEDFILEENTITIES_HXX__ +#define __MEDFILEENTITIES_HXX__ + +#include "MEDLoaderDefines.hxx" + +#include "MEDFileStructureElement.hxx" + +#include "MEDCouplingRefCountObject.hxx" +#include "NormalizedGeometricTypes" + +namespace MEDCoupling +{ + class MEDFileEntities + { + public: + static MEDFileEntities *BuildFrom(const std::vector< std::pair > *entities); + static MEDFileEntities *BuildFrom(const MEDFileStructureElements& se); + virtual std::vector getDynGTAvail() const = 0; + virtual bool areAllStaticTypesPresent() const = 0; + }; + + class MEDFileStaticEntities : public MEDFileEntities + { + public: + MEDFileStaticEntities(const std::vector< std::pair >& entities):_entities(entities) { } + const std::vector< std::pair >& getEntries() const { return _entities; } + std::vector getDynGTAvail() const; + bool areAllStaticTypesPresent() const; + private: + std::vector< std::pair > _entities; + }; + + class MEDFileAllStaticEntites : public MEDFileEntities + { + public: + MEDFileAllStaticEntites() { } + std::vector getDynGTAvail() const; + bool areAllStaticTypesPresent() const; + }; + + class MEDFileAllStaticEntitiesPlusDyn : public MEDFileEntities + { + public: + MEDFileAllStaticEntitiesPlusDyn(const MEDFileStructureElements *se); + std::vector getDynGTAvail() const; + bool areAllStaticTypesPresent() const; + private: + MCConstAuto _se; + }; +} + +#endif diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 7676059d9..c00af683c 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -403,12 +403,12 @@ void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, con start=_end; } -MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd) +MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd) { return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd); } -MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId) +MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId) { return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string()); } @@ -430,14 +430,14 @@ std::vector MEDFileFieldPerMeshPerTypePerDisc::getDirec return ret; } -MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const +MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const { MCAuto ret=new MEDFileFieldPerMeshPerTypePerDisc(*this); ret->_father=father; return ret.retn(); } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd) +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd) try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast(pd)) { if(pd) @@ -448,7 +448,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId) +MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId) { } @@ -527,7 +527,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const } } -const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const +const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const { return _father; } @@ -542,7 +542,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_i INTERP_KERNEL::NormalizedCellType geoType(getGeoType()); int profilesize,nbi; med_geometry_type mgeoti; - med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti)); + med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti)); int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi)); _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE); _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE); @@ -579,7 +579,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileF TypeOfField type(getType()); INTERP_KERNEL::NormalizedCellType geoType(getGeoType()); med_geometry_type mgeoti; - med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti)); + med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti)); if(_start>_end) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !"); if(_start==_end) @@ -694,7 +694,7 @@ DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const { - const MEDFileFieldPerMeshPerType *fath=_father; + const MEDFileFieldPerMeshPerTypeCommon *fath=_father; return fath->getOrCreateAndGetArray(); } @@ -778,7 +778,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldN TypeOfField type=getType(); INTERP_KERNEL::NormalizedCellType geoType=getGeoType(); med_geometry_type mgeoti; - med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti); + med_entity_type menti=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti); const DataArray *arr=getOrCreateAndGetArray(); if(!arr) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !"); @@ -1047,22 +1047,29 @@ MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectO } -MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd) +//////////////////////////////////// + +void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father) { - return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd); + _father=father; } -MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) +void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements() { - return new MEDFileFieldPerMeshPerType(fath,geoType); + std::size_t i=0; + for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) + { + if((const MEDFileFieldPerMeshPerTypePerDisc *)*it) + _field_pm_pt_pd[i]=(*it)->deepCopy(this); + } } -std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const +std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const { return _field_pm_pt_pd.capacity()*sizeof(MCAuto); } -std::vector MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const +std::vector MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const { std::vector ret; for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) @@ -1070,20 +1077,7 @@ std::vector MEDFileFieldPerMeshPerType::getDirectChildr return ret; } -MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const -{ - MCAuto ret=new MEDFileFieldPerMeshPerType(*this); - ret->_father=father; - std::size_t i=0; - for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) - { - if((const MEDFileFieldPerMeshPerTypePerDisc *)*it) - ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret); - } - return ret.retn(); -} - -void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { std::vector pos=addNewEntryIfNecessary(field,offset,nbOfCells); for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) @@ -1099,31 +1093,31 @@ void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, in * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored. */ -void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { std::vector pos=addNewEntryIfNecessary(field,idsInPfl); for(std::vector::const_iterator it=pos.begin();it!=pos.end();it++) _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc); } -void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) +void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) { _field_pm_pt_pd.resize(1); _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3); _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob); } -void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) { MCAuto pfl2=pfl->deepCopy(); if(!arr || !arr->isAllocated()) - throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !"); + throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !"); _field_pm_pt_pd.resize(1); _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3); _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send. } -std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) { TypeOfField type=field->getTypeOfField(); if(type!=ON_GAUSS_PT) @@ -1178,7 +1172,7 @@ std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCou } } -std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) { const MEDCouplingFieldDiscretization *disc=field->getDiscretization(); const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast(disc); @@ -1195,7 +1189,7 @@ std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const M return ret; } -std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) { TypeOfField type=field->getTypeOfField(); if(type!=ON_GAUSS_PT) @@ -1250,7 +1244,7 @@ std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCou } } -std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) +std::vector MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) { const MEDCouplingFieldDiscretization *disc=field->getDiscretization(); const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast(disc); @@ -1267,19 +1261,19 @@ std::vector MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const M return ret; } -const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const +const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const { return _father; } -void MEDFileFieldPerMeshPerType::getDimension(int& dim) const +void MEDFileFieldPerMeshPerTypeCommon::getDimension(int& dim) const { const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type)); int curDim((int)cm.getDimension()); dim=std::max(dim,curDim); } -bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const +bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const { const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type)); int curDim((int)cm.getDimension()); @@ -1293,7 +1287,7 @@ bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const return true; } -void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set& types) const +void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set& types) const { for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) { @@ -1301,7 +1295,7 @@ void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set } } -void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair >& dads, std::vector& types, std::vector& pfls, std::vector& locs) const +void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair >& dads, std::vector& types, std::vector& pfls, std::vector& locs) const { int sz=_field_pm_pt_pd.size(); dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz); @@ -1311,27 +1305,27 @@ void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pairgetIteration(); } -int MEDFileFieldPerMeshPerType::getOrder() const +int MEDFileFieldPerMeshPerTypeCommon::getOrder() const { return _father->getOrder(); } -double MEDFileFieldPerMeshPerType::getTime() const +double MEDFileFieldPerMeshPerTypeCommon::getTime() const { return _father->getTime(); } -std::string MEDFileFieldPerMeshPerType::getMeshName() const +std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const { return _father->getMeshName(); } -void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const +void MEDFileFieldPerMeshPerTypeCommon::simpleRepr(int bkOffset, std::ostream& oss, int id) const { const char startLine[]=" ## "; std::string startLine2(bkOffset,' '); @@ -1358,7 +1352,7 @@ void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int } } -void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const +void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const { for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) { @@ -1367,18 +1361,18 @@ void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const nbOfEntries+=(int)_field_pm_pt_pd.size(); } -INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const +INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeCommon::getGeoType() const { return _geo_type; } -int MEDFileFieldPerMeshPerType::getNumberOfComponents() const +int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const { return _father->getNumberOfComponents(); } -bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const +bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const { std::size_t nb(0); for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) @@ -1390,23 +1384,23 @@ bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const return nb>1; } -DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() +DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() { return _father->getOrCreateAndGetArray(); } -const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const +const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const { const MEDFileFieldPerMesh *fath=_father; return fath->getOrCreateAndGetArray(); } -const std::vector& MEDFileFieldPerMeshPerType::getInfo() const +const std::vector& MEDFileFieldPerMeshPerTypeCommon::getInfo() const { return _father->getInfo(); } -std::vector MEDFileFieldPerMeshPerType::getPflsReallyUsed() const +std::vector MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const { std::vector ret; std::set ret2; @@ -1423,7 +1417,7 @@ std::vector MEDFileFieldPerMeshPerType::getPflsReallyUsed() const return ret; } -std::vector MEDFileFieldPerMeshPerType::getLocsReallyUsed() const +std::vector MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const { std::vector ret; std::set ret2; @@ -1440,7 +1434,7 @@ std::vector MEDFileFieldPerMeshPerType::getLocsReallyUsed() const return ret; } -std::vector MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const +std::vector MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const { std::vector ret; std::set ret2; @@ -1453,7 +1447,7 @@ std::vector MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() co return ret; } -std::vector MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const +std::vector MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const { std::vector ret; for(std::vector< MCAuto >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) @@ -1465,53 +1459,53 @@ std::vector MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() co return ret; } -void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) +void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { for(std::vector< MCAuto >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) (*it1)->changePflsRefsNamesGen(mapOfModif); } -void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) +void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) { for(std::vector< MCAuto >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++) (*it1)->changeLocsRefsNamesGen(mapOfModif); } -MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) +MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) { if(_field_pm_pt_pd.empty()) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type); - std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !"; + std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !"; throw INTERP_KERNEL::Exception(oss.str()); } if(locId>=0 && locId<(int)_field_pm_pt_pd.size()) return _field_pm_pt_pd[locId]; const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type); - std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId; + std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId; oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !"; throw INTERP_KERNEL::Exception(oss2.str().c_str()); return static_cast(0); } -const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const +const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const { if(_field_pm_pt_pd.empty()) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type); - std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !"; + std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !"; throw INTERP_KERNEL::Exception(oss.str()); } if(locId>=0 && locId<(int)_field_pm_pt_pd.size()) return _field_pm_pt_pd[locId]; const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type); - std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId; + std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId; oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !"; throw INTERP_KERNEL::Exception(oss2.str().c_str()); return static_cast(0); } -void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const +void MEDFileFieldPerMeshPerTypeCommon::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const { if(_geo_type!=INTERP_KERNEL::NORM_ERROR) { @@ -1523,7 +1517,7 @@ void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes); } -void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair,std::pair > >& entries) const +void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair,std::pair > >& entries) const { int i=0; for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++) @@ -1532,7 +1526,7 @@ void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std: } } -void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) +void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) { _field_pm_pt_pd=leaves; for(std::vector< MCAuto >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) @@ -1544,7 +1538,7 @@ void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFie * \param [out] its - list of pair (start,stop) kept * \return bool - false if the type of field \a tof is not contained in \a this. */ -bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair >& its) +bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair >& its) { bool ret(false); std::vector< MCAuto > newPmPtPd; @@ -1568,7 +1562,7 @@ bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, * \param [out] its - list of pair (start,stop) kept * \return bool - false if the type of field \a tof is not contained in \a this. */ -bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair >& its) +bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair >& its) { if(_field_pm_pt_pd.size()<=idOfDisc) return false; @@ -1582,7 +1576,7 @@ bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDis return true; } -MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType) +MEDFileFieldPerMeshPerTypeCommon::MEDFileFieldPerMeshPerTypeCommon(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType) { INTERP_KERNEL::AutoPtr pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); INTERP_KERNEL::AutoPtr locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); @@ -1602,19 +1596,19 @@ MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileField } } -void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) { for(std::vector< MCAuto >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc); } -void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) +void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) { for(std::vector< MCAuto >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) (*it)->loadBigArray(fid,nasc); } -void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const +void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const { for(std::vector< MCAuto >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++) { @@ -1623,7 +1617,7 @@ void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScop } } -med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType) +med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType) { switch(ikType) { @@ -1640,12 +1634,34 @@ med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField i medfGeoType=typmai3[(int)ikGeoType]; return MED_CELL; default: - throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error"); + throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error"); } return MED_UNDEF_ENTITY_TYPE; } -MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair > *entities) +////////////////////////////////////////////////// + +MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd) +{ + return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd); +} + +MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) +{ + return new MEDFileFieldPerMeshPerType(fath,geoType); +} + +MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const +{ + MCAuto ret=new MEDFileFieldPerMeshPerType(*this); + ret->setFather(father); + ret->deepCopyElements(); + return ret.retn(); +} + +////////////////////////////////////////////////// + +MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities) { return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities); } @@ -2385,7 +2401,7 @@ MCAuto MEDFileFieldPerMeshPerTypePerDisc::Agg return ret; } -MCAuto MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector >& pms, const std::vector< std::vector< std::pair > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector > >& extractInfo) +MCAuto MEDFileFieldPerMeshPerTypeCommon::Aggregate(int &start, const std::vector >& pms, const std::vector< std::vector< std::pair > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector > >& extractInfo) { MCAuto ret(new MEDFileFieldPerMeshPerType(father,gt)); std::map > > m; @@ -2418,7 +2434,7 @@ MCAuto MEDFileFieldPerMesh::Aggregate(int &start, const std } for(std::map > >::const_iterator it=m.begin();it!=m.end();it++) { - MCAuto agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo)); + MCAuto agg(MEDFileFieldPerMeshPerTypeCommon::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo)); ret->_field_pm_pt.push_back(agg); } return ret; @@ -2594,8 +2610,8 @@ DataArray *MEDFileFieldPerMesh::finishField4(const std::vector > *entities); - static bool IsPresenceOfNode(const std::vector< std::pair > *entities); + static MFFPMIter *NewCell(const MEDFileEntities *entities); + static bool IsPresenceOfNode(const MEDFileEntities *entities); virtual ~MFFPMIter() { } virtual void begin() = 0; virtual bool finished() const = 0; @@ -2628,32 +2644,46 @@ private: std::vector::const_iterator _it; }; -MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair > *entities) +MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities) { if(!entities) return new MFFPMIterSimple; else { - std::vector tmp; - for(std::vector< std::pair >::const_iterator it=(*entities).begin();it!=(*entities).end();it++) + const MEDFileStaticEntities *entities2(dynamic_cast(entities)); + if(entities2) { - if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT) - tmp.push_back((*it).second); + std::vector tmp; + const std::vector< std::pair >& myEnt(entities2->getEntries()); + for(std::vector< std::pair >::const_iterator it=myEnt.begin();it!=myEnt.end();it++) + { + if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT) + tmp.push_back((*it).second); + } + return new MFFPMIter2(tmp); } - return new MFFPMIter2(tmp); + else + throw INTERP_KERNEL::Exception("MFFPMIter::NewCell : not recognized type !"); } } -bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair > *entities) +bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities) { if(!entities) return true; else { - for(std::vector< std::pair >::const_iterator it=(*entities).begin();it!=(*entities).end();it++) - if((*it).first==ON_NODES) - return true; - return false; + const MEDFileStaticEntities *entities2(dynamic_cast(entities)); + if(entities2) + { + const std::vector< std::pair >& myEnt(entities2->getEntries()); + for(std::vector< std::pair >::const_iterator it=myEnt.begin();it!=myEnt.end();it++) + if((*it).first==ON_NODES) + return true; + return false; + } + else + throw INTERP_KERNEL::Exception("MFFPMIter::IsPresenceOfNode : not recognized type !"); } } @@ -2673,7 +2703,7 @@ MFFPMIter2::MFFPMIter2(const std::vector& cts /// @endcond -MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder), +MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder), _father(fath) { INTERP_KERNEL::AutoPtr meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)); @@ -4553,7 +4583,7 @@ bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFrom throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !"); } -void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities) { med_int numdt,numit; med_float dt; @@ -4595,7 +4625,7 @@ void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_i (*it)->loadBigArraysRecursively(fid,nasc); } -void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities) { loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities); loadBigArraysRecursively(fid,nasc); @@ -7133,7 +7163,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const /*! * \param [in] fieldId field id in C mode */ -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { med_field_type typcha; std::string dtunitOut; @@ -7142,7 +7172,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_i loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities); } -MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileFieldNameScope(fieldName),_infos(infos) { setDtUnit(dtunit.c_str()); @@ -7462,7 +7492,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() } } -void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { _time_steps.resize(nbPdt); for(int i=0;i& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); } @@ -8064,14 +8094,14 @@ MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& /*! * \param [in] fieldId field id in C mode */ -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } @@ -8157,7 +8187,7 @@ catch(INTERP_KERNEL::Exception& e) throw e; } -MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, 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 MEDFileEntities *entities) { med_field_type typcha; std::vector infos; @@ -8244,7 +8274,7 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont return ret; } -MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileFieldGlobsReal(fid) { _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities); @@ -8257,7 +8287,7 @@ catch(INTERP_KERNEL::Exception& e) //= MEDFileIntFieldMultiTSWithoutSDA -MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) { return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities); } @@ -8270,7 +8300,7 @@ MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::st { } -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } @@ -8280,7 +8310,7 @@ catch(INTERP_KERNEL::Exception& e) /*! * \param [in] fieldId field id in C mode */ -MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } @@ -9209,7 +9239,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) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - MCAuto ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,&entities)); + INTERP_KERNEL::AutoCppPtr ent(new MEDFileStaticEntities(entities)); + MCAuto ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -9565,7 +9596,7 @@ try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms) catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } @@ -9701,7 +9732,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) { MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - MCAuto ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,&entities)); + INTERP_KERNEL::AutoCppPtr ent(new MEDFileStaticEntities(entities)); + MCAuto ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent)); ret->contentNotNull();//to check that content type matches with \a this type. return ret.retn(); } @@ -10062,7 +10094,7 @@ try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms) catch(INTERP_KERNEL::Exception& e) { throw e; } -MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } @@ -10092,6 +10124,15 @@ MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll) return New(fid,loadAll); } +MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll) +{ + MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); + if(!se) + throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !"); + INTERP_KERNEL::AutoCppPtr entities(MEDFileEntities::BuildFrom(*se)); + return new MEDFileFields(fid,loadAll,0,entities); +} + MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll) { return new MEDFileFields(fid,loadAll,0,0); @@ -10106,8 +10147,9 @@ MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadA MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair >& entities, bool loadAll) { MEDFileUtilities::CheckFileForRead(fileName); + INTERP_KERNEL::AutoCppPtr ent(new MEDFileStaticEntities(entities)); MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName)); - return new MEDFileFields(fid,loadAll,0,&entities); + return new MEDFileFields(fid,loadAll,0,ent); } std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const @@ -10265,7 +10307,7 @@ MEDFileFields::MEDFileFields() { } -MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities) +MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities) try:MEDFileFieldGlobsReal(fid) { int nbFields(MEDnField(fid)); diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index de637f10f..4ccfc6ca3 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -25,6 +25,7 @@ #include "MEDFileFieldOverView.hxx" #include "MEDFileUtilities.txx" +#include "MEDFileEntities.hxx" #include "MCAuto.hxx" #include "MEDLoaderTraits.hxx" @@ -91,6 +92,7 @@ namespace MEDCoupling /// @cond INTERNAL class MEDFileAnyTypeField1TSWithoutSDA; + class MEDFileFieldPerMeshPerTypeCommon; class MEDFileFieldPerMeshPerType; class MEDFileField1TSWithoutSDA; class MEDFileFieldNameScope; @@ -101,18 +103,18 @@ namespace MEDCoupling class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable { public: - static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd); - static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId); + static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd); + static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId); static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other); std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildrenWithNull() const; - MEDFileFieldPerMeshPerTypePerDisc *deepCopy(MEDFileFieldPerMeshPerType *father) const; + MEDFileFieldPerMeshPerTypePerDisc *deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const; void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); void assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob); void getCoarseData(TypeOfField& type, std::pair& dad, std::string& pfl, std::string& loc) const; void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const; - const MEDFileFieldPerMeshPerType *getFather() const; + const MEDFileFieldPerMeshPerTypeCommon *getFather() const; void loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc); void loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc); void setNewStart(int newValueOfStart); @@ -139,7 +141,7 @@ namespace MEDCoupling void setLocalization(const std::string& newLocName); int getLocId() const { return _loc_id; } void setLocId(int newId) const { _loc_id=newId; } - void setFather(MEDFileFieldPerMeshPerType *newFather) { _father=newFather; } + void setFather(MEDFileFieldPerMeshPerTypeCommon *newFather) { _father=newFather; } void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); void getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, @@ -156,17 +158,17 @@ namespace MEDCoupling bool isPfl, int nbi, int offset, std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc, MEDFileFieldGlobsReal& glob, bool ¬InExisting); static MCAuto Aggregate(int &start, const std::vector >& pms, const std::vector< std::vector< std::pair > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector > >& extractInfo); - MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type):_type(type),_father(fath),_start(-1),_end(-1),_nval(-1),_loc_id(-5),_profile_it(-1) { } + MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type):_type(type),_father(fath),_start(-1),_end(-1),_nval(-1),_loc_id(-5),_profile_it(-1) { } private: - MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd); - MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const std::string& dummy); + MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd); + MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const std::string& dummy); MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other); MEDFileFieldPerMeshPerTypePerDisc(); private: void goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr); private: TypeOfField _type; - MEDFileFieldPerMeshPerType *_father; + MEDFileFieldPerMeshPerTypeCommon *_father; int _start; int _end; //! _nval is different than end-start in case of ON_GAUSS_PT and ON_GAUSS_NE ! (_nval=(_end-_start)/nbi) @@ -181,14 +183,11 @@ namespace MEDCoupling mutable int _tmp_work1; }; - class MEDFileFieldPerMeshPerType : public RefCountObject, public MEDFileWritable + class MEDFileFieldPerMeshPerTypeCommon : public RefCountObject, public MEDFileWritable { public: - static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType); - static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildrenWithNull() const; - MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const; void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); void assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); @@ -229,26 +228,39 @@ namespace MEDCoupling bool keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair >& its); static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType); static MCAuto Aggregate(int &start, const std::vector< std::pair >& pms, const std::vector< std::vector< std::pair > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector > >& extractInfo); - MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):_father(father),_geo_type(gt) { } - private: + MEDFileFieldPerMeshPerTypeCommon(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):_father(father),_geo_type(gt) { } + protected: + void setFather(MEDFileFieldPerMesh *father); + void deepCopyElements(); std::vector addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells); std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells); std::vector addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells); std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells); - MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); + MEDFileFieldPerMeshPerTypeCommon(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); private: MEDFileFieldPerMesh *_father; std::vector< MCAuto > _field_pm_pt_pd; INTERP_KERNEL::NormalizedCellType _geo_type; }; + class MEDFileFieldPerMeshPerType : public MEDFileFieldPerMeshPerTypeCommon + { + public: + static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType); + static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); + MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father,gt) { } + MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const; + private: + MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fid,fath,type,geoType,nasc,pd) { } + }; + class MEDFileMesh; class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable { public: static MEDFileFieldPerMesh *New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); - static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair > *entities); + static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities); std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildrenWithNull() const; MEDFileFieldPerMesh *deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const; @@ -309,7 +321,7 @@ namespace MEDCoupling const std::vector& geoTypes, const std::vector< std::pair >& dads, const std::vector& pfls, const std::vector& locs, std::vector& code, std::vector& notNullPfls); static int ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, const std::vector< std::pair >& dads, const std::vector& locs); - MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair > *entities); + MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities); MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const std::string& meshName, int meshIt, int meshOrd):_father(fath),_mesh_name(meshName),_mesh_iteration(meshIt),_mesh_order(meshOrd) { } private: @@ -544,10 +556,10 @@ namespace MEDCoupling public: MEDLOADER_EXPORT void allocNotFromFile(int newNbOfTuples); MEDLOADER_EXPORT bool allocIfNecessaryTheArrayToReceiveDataFromFile(); - MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities); MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc); MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc); - MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities); MEDLOADER_EXPORT void unloadArrays(); MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const; protected: @@ -832,8 +844,8 @@ namespace MEDCoupling protected: MEDFileAnyTypeFieldMultiTSWithoutSDA(); MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName); - MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); - MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); public: MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; @@ -878,7 +890,7 @@ namespace MEDCoupling MEDLOADER_EXPORT DataArray *getUndergroundDataArray(int iteration, int order) const; MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob); - MEDLOADER_EXPORT void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDLOADER_EXPORT void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts) const; MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc); MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc); @@ -909,8 +921,8 @@ namespace MEDCoupling class MEDFileFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA { public: - MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); - MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); MEDLOADER_EXPORT const char *getTypeStr() const; MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const; MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const; @@ -918,7 +930,7 @@ namespace MEDCoupling MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA *convertToInt() const; protected: MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName); - MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const; void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const; @@ -929,15 +941,15 @@ namespace MEDCoupling class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA { public: - MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); - MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); MEDLOADER_EXPORT const char *getTypeStr() const; MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const; MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const; MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA *convertToDouble() const; protected: MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName); - MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); med_field_type getMEDFileFieldType() const { return MED_INT32; } MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const; void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const; @@ -955,12 +967,12 @@ namespace MEDCoupling protected: MEDFileAnyTypeFieldMultiTS(); 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(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); 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); + static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *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); @@ -1086,7 +1098,7 @@ namespace MEDCoupling MEDFileFieldMultiTS(); MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); 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); + MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); }; /*! @@ -1130,7 +1142,7 @@ namespace MEDCoupling MEDFileIntFieldMultiTS(); MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); 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); + MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); }; class MEDFileAnyTypeFieldMultiTSIterator @@ -1146,7 +1158,8 @@ namespace MEDCoupling }; class MEDFileFieldsIterator; - + class MEDFileStructureElements; + /*! * Use class. */ @@ -1155,6 +1168,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 *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true); MEDLOADER_EXPORT static MEDFileFields *New(med_idt fid, bool loadAll=true); MEDLOADER_EXPORT static MEDFileFields *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } MEDLOADER_EXPORT static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0); @@ -1205,7 +1219,7 @@ namespace MEDCoupling private: ~MEDFileFields() { } MEDFileFields(); - MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair > *entities); + MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); private: std::vector< MCAuto > _fields; }; diff --git a/src/MEDLoader/MEDFileStructureElement.cxx b/src/MEDLoader/MEDFileStructureElement.cxx index 4ef945d15..c8d6466f5 100644 --- a/src/MEDLoader/MEDFileStructureElement.cxx +++ b/src/MEDLoader/MEDFileStructureElement.cxx @@ -90,7 +90,6 @@ MEDFileSEConstAtt::MEDFileSEConstAtt(med_idt fid, MEDFileStructureElement *fathe } if(constatttype==MED_ATT_NAME) pflSz++; - std::cerr << "******* " << pflSz << std::endl; _val->alloc(pflSz,nbCompo); MEDFILESAFECALLERRD0(MEDstructElementConstAttRd,(fid,modelName.c_str(),name.c_str(),_val->getVoidStarPointer())); if(constatttype==MED_ATT_NAME) @@ -251,6 +250,11 @@ int MEDFileStructureElement::EffectiveNbCompo(med_attribute_type mat, int nbComp } } +int MEDFileStructureElement::getDynGT() const +{ + return _id_type; +} + //////////////////// MEDFileStructureElements *MEDFileStructureElements::New(med_idt fid, const MEDFileMeshSupports *ms) @@ -296,3 +300,19 @@ MEDFileStructureElements::~MEDFileStructureElements() { } +int MEDFileStructureElements::getNumberOf() const +{ + return _elems.size(); +} + +std::vector MEDFileStructureElements::getDynGTAvail() const +{ + std::vector ret; + for(std::vector< MCAuto >::const_iterator it=_elems.begin();it!=_elems.end();it++) + { + const MEDFileStructureElement *elt(*it); + if(elt) + ret.push_back(elt->getDynGT()); + } + return ret; +} diff --git a/src/MEDLoader/MEDFileStructureElement.hxx b/src/MEDLoader/MEDFileStructureElement.hxx index 766c1129f..aadc28658 100644 --- a/src/MEDLoader/MEDFileStructureElement.hxx +++ b/src/MEDLoader/MEDFileStructureElement.hxx @@ -83,6 +83,7 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon public: MEDLOADER_EXPORT static MEDFileStructureElement *New(med_idt fid, int idSE, const MEDFileMeshSupports *ms); MEDLOADER_EXPORT std::string getName() const; + MEDLOADER_EXPORT int getDynGT() const; public: std::vector getDirectChildrenWithNull() const; std::size_t getHeapMemorySizeWithoutChildren() const; @@ -107,6 +108,8 @@ class MEDFileSEConstAtt : public RefCountObject, public MEDFileWritableStandAlon public: MEDLOADER_EXPORT static MEDFileStructureElements *New(med_idt fid, const MEDFileMeshSupports *ms); MEDLOADER_EXPORT static MEDFileStructureElements *New(); + MEDLOADER_EXPORT int getNumberOf() const; + MEDLOADER_EXPORT std::vector getDynGTAvail() const; public: std::vector getDirectChildrenWithNull() const; std::size_t getHeapMemorySizeWithoutChildren() const;