From: Anthony Geay Date: Tue, 12 Jan 2016 08:53:37 +0000 (+0100) Subject: Generalization of some Fam/grp methods from MEDFileUMesh->MEDFileMesh. X-Git-Tag: V7_8_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=75dc52e400e895df4b04970fae6929d6d24fb39e;p=tools%2Fmedcoupling.git Generalization of some Fam/grp methods from MEDFileUMesh->MEDFileMesh. --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 0e1b5a321..6c388c796 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -528,6 +528,94 @@ std::vector MEDFileMesh::getFamiliesNamesWithFilePointOfView() cons return ret; } +/*! + * Returns names of groups that partly or fully appear on the level \a meshDimRelToMaxExt. + * \param [in] meshDimRelToMaxExt - a relative dimension of interest. + * \return std::vector - a sequence of group names at \a meshDimRelToMaxExt + * level. + */ +std::vector MEDFileMesh::getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const +{ + std::vector ret; + std::vector allGrps(getGroupsNames()); + for(std::vector::const_iterator it=allGrps.begin();it!=allGrps.end();it++) + { + std::vector levs(getGrpNonEmptyLevelsExt((*it))); + if(std::find(levs.begin(),levs.end(),meshDimRelToMaxExt)!=levs.end()) + ret.push_back(*it); + } + return ret; +} + +/*! + * Returns all relative mesh levels (including nodes) where a given group is defined. + * \param [in] grp - the name of the group of interest. + * \return std::vector - a sequence of the relative dimensions. + */ +std::vector MEDFileMesh::getGrpNonEmptyLevelsExt(const std::string& grp) const +{ + std::vector fams(getFamiliesOnGroup(grp)); + return getFamsNonEmptyLevelsExt(fams); +} + +/*! + * Returns all relative mesh levels (**excluding nodes**) where given groups are defined. + * To include nodes, call getGrpsNonEmptyLevelsExt() method. + * \param [in] grps - a sequence of names of the groups of interest. + * \return std::vector - a sequence of the relative dimensions. + */ +std::vector MEDFileMesh::getGrpsNonEmptyLevels(const std::vector& grps) const +{ + std::vector fams(getFamiliesOnGroups(grps)); + return getFamsNonEmptyLevels(fams); +} + +/*! + * Returns all relative mesh levels (including nodes) where given groups are defined. + * \param [in] grps - a sequence of names of the groups of interest. + * \return std::vector - a sequence of the relative dimensions. + */ +std::vector MEDFileMesh::getGrpsNonEmptyLevelsExt(const std::vector& grps) const +{ + std::vector fams(getFamiliesOnGroups(grps)); + return getFamsNonEmptyLevelsExt(fams); +} + +/*! + * Returns all relative mesh levels (**excluding nodes**) where a given group is defined. + * To include nodes, call getGrpNonEmptyLevelsExt() method. + * \param [in] grp - the name of the group of interest. + * \return std::vector - a sequence of the relative dimensions. + */ +std::vector MEDFileMesh::getGrpNonEmptyLevels(const std::string& grp) const +{ + std::vector fams(getFamiliesOnGroup(grp)); + return getFamsNonEmptyLevels(fams); +} + +/*! + * Returns all relative mesh levels (**excluding nodes**) where a given family is defined. + * To include nodes, call getFamNonEmptyLevelsExt() method. + * \param [in] fam - the name of the family of interest. + * \return std::vector - a sequence of the relative dimensions. + */ +std::vector MEDFileMesh::getFamNonEmptyLevels(const std::string& fam) const +{ + std::vector fams(1,std::string(fam)); + return getFamsNonEmptyLevels(fams); +} + +/*! + * Returns all relative mesh levels (including nodes) where a given family is defined. + * \param [in] fam - the name of the family of interest. + * \return std::vector - a sequence of the relative dimensions. + */ +std::vector MEDFileMesh::getFamNonEmptyLevelsExt(const std::string& fam) const +{ + std::vector fams(1,std::string(fam)); + return getFamsNonEmptyLevelsExt(fams); +} + std::string MEDFileMesh::GetMagicFamilyStr() { return std::string(MEDFileMeshL2::ZE_SEP_FOR_FAMILY_KILLERS); @@ -2749,75 +2837,6 @@ std::vector MEDFileUMesh::getNameArrNonEmptyLevelsExt() const return ret; } -/*! - * Returns all relative mesh levels (**excluding nodes**) where a given group is defined. - * To include nodes, call getGrpNonEmptyLevelsExt() method. - * \param [in] grp - the name of the group of interest. - * \return std::vector - a sequence of the relative dimensions. - */ -std::vector MEDFileUMesh::getGrpNonEmptyLevels(const std::string& grp) const -{ - std::vector fams=getFamiliesOnGroup(grp); - return getFamsNonEmptyLevels(fams); -} - -/*! - * Returns all relative mesh levels (including nodes) where a given group is defined. - * \param [in] grp - the name of the group of interest. - * \return std::vector - a sequence of the relative dimensions. - */ -std::vector MEDFileUMesh::getGrpNonEmptyLevelsExt(const std::string& grp) const -{ - std::vector fams=getFamiliesOnGroup(grp); - return getFamsNonEmptyLevelsExt(fams); -} - -/*! - * Returns all relative mesh levels (**excluding nodes**) where a given family is defined. - * To include nodes, call getFamNonEmptyLevelsExt() method. - * \param [in] fam - the name of the family of interest. - * \return std::vector - a sequence of the relative dimensions. - */ -std::vector MEDFileUMesh::getFamNonEmptyLevels(const std::string& fam) const -{ - std::vector fams(1,std::string(fam)); - return getFamsNonEmptyLevels(fams); -} - -/*! - * Returns all relative mesh levels (including nodes) where a given family is defined. - * \param [in] fam - the name of the family of interest. - * \return std::vector - a sequence of the relative dimensions. - */ -std::vector MEDFileUMesh::getFamNonEmptyLevelsExt(const std::string& fam) const -{ - std::vector fams(1,std::string(fam)); - return getFamsNonEmptyLevelsExt(fams); -} - -/*! - * Returns all relative mesh levels (**excluding nodes**) where given groups are defined. - * To include nodes, call getGrpsNonEmptyLevelsExt() method. - * \param [in] grps - a sequence of names of the groups of interest. - * \return std::vector - a sequence of the relative dimensions. - */ -std::vector MEDFileUMesh::getGrpsNonEmptyLevels(const std::vector& grps) const -{ - std::vector fams=getFamiliesOnGroups(grps); - return getFamsNonEmptyLevels(fams); -} - -/*! - * Returns all relative mesh levels (including nodes) where given groups are defined. - * \param [in] grps - a sequence of names of the groups of interest. - * \return std::vector - a sequence of the relative dimensions. - */ -std::vector MEDFileUMesh::getGrpsNonEmptyLevelsExt(const std::vector& grps) const -{ - std::vector fams=getFamiliesOnGroups(grps); - return getFamsNonEmptyLevelsExt(fams); -} - /*! * Returns all relative mesh levels (**excluding nodes**) where given families are defined. * To include nodes, call getFamsNonEmptyLevelsExt() method. @@ -2827,8 +2846,8 @@ std::vector MEDFileUMesh::getGrpsNonEmptyLevelsExt(const std::vector MEDFileUMesh::getFamsNonEmptyLevels(const std::vector& fams) const { std::vector ret; - std::vector levs=getNonEmptyLevels(); - std::vector famIds=getFamiliesIds(fams); + std::vector levs(getNonEmptyLevels()); + std::vector famIds(getFamiliesIds(fams)); for(std::vector::const_iterator it=levs.begin();it!=levs.end();it++) if(_ms[-(*it)]->presenceOfOneFams(famIds)) ret.push_back(*it); @@ -2842,11 +2861,11 @@ std::vector MEDFileUMesh::getFamsNonEmptyLevels(const std::vector MEDFileUMesh::getFamsNonEmptyLevelsExt(const std::vector& fams) const { - std::vector ret0=getFamsNonEmptyLevels(fams); - const DataArrayInt *famCoords=_fam_coords; + std::vector ret0(getFamsNonEmptyLevels(fams)); + const DataArrayInt *famCoords(_fam_coords); if(!famCoords) return ret0; - std::vector famIds=getFamiliesIds(fams); + std::vector famIds(getFamiliesIds(fams)); if(famCoords->presenceOfValue(famIds)) { std::vector ret(ret0.size()+1); @@ -2858,25 +2877,6 @@ std::vector MEDFileUMesh::getFamsNonEmptyLevelsExt(const std::vector - a sequence of group names at \a meshDimRelToMaxExt - * level. - */ -std::vector MEDFileUMesh::getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const -{ - std::vector ret; - std::vector allGrps=getGroupsNames(); - for(std::vector::const_iterator it=allGrps.begin();it!=allGrps.end();it++) - { - std::vector levs=getGrpNonEmptyLevelsExt((*it)); - if(std::find(levs.begin(),levs.end(),meshDimRelToMaxExt)!=levs.end()) - ret.push_back(*it); - } - return ret; -} - int MEDFileUMesh::getMaxAbsFamilyIdInArrays() const { int ret=-std::numeric_limits::max(),tmp=-1; @@ -5634,6 +5634,26 @@ MEDCouplingMesh *MEDFileStructuredMesh::getMeshAtLevel(int meshDimRelToMax, bool } } +std::vector MEDFileStructuredMesh::getFamsNonEmptyLevels(const std::vector& fams) const +{ + std::vector ret; + const DataArrayInt *famCells(_fam_cells),*famFaces(_fam_faces); + if(famCells && famCells->presenceOfValue(ret)) + ret.push_back(0); + if(famFaces && famFaces->presenceOfValue(ret)) + ret.push_back(-1); + return ret; +} + +std::vector MEDFileStructuredMesh::getFamsNonEmptyLevelsExt(const std::vector& fams) const +{ + std::vector ret(getFamsNonEmptyLevels(fams)); + const DataArrayInt *famNodes(_fam_nodes); + if(famNodes && famNodes->presenceOfValue(ret)) + ret.push_back(1); + return ret; +} + /*! * Returns number of mesh entities of a given relative dimension in \a this mesh. * \param [in] meshDimRelToMaxExt - the relative dimension of interest. diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index e52dafada..b29871d36 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -119,6 +119,15 @@ namespace ParaMEDMEM MEDLOADER_EXPORT void setGroupsOnFamily(const std::string& famName, const std::vector& grps); MEDLOADER_EXPORT std::vector getGroupsNames() const; MEDLOADER_EXPORT std::vector getFamiliesNames() const; + MEDLOADER_EXPORT std::vector getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const; + MEDLOADER_EXPORT std::vector getGrpNonEmptyLevelsExt(const std::string& grp) const; + MEDLOADER_EXPORT std::vector getGrpNonEmptyLevels(const std::string& grp) const; + MEDLOADER_EXPORT std::vector getGrpsNonEmptyLevels(const std::vector& grps) const; + MEDLOADER_EXPORT std::vector getGrpsNonEmptyLevelsExt(const std::vector& grps) const; + MEDLOADER_EXPORT virtual std::vector getFamsNonEmptyLevels(const std::vector& fams) const = 0; + MEDLOADER_EXPORT virtual std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const = 0; + MEDLOADER_EXPORT std::vector getFamNonEmptyLevels(const std::string& fam) const; + MEDLOADER_EXPORT std::vector getFamNonEmptyLevelsExt(const std::string& fam) const; MEDLOADER_EXPORT std::vector getFamiliesNamesWithFilePointOfView() const; MEDLOADER_EXPORT static std::string GetMagicFamilyStr(); MEDLOADER_EXPORT void assignFamilyNameWithGroupName(); @@ -277,15 +286,8 @@ namespace ParaMEDMEM MEDLOADER_EXPORT std::vector getFamArrNonEmptyLevelsExt() const; MEDLOADER_EXPORT std::vector getNumArrNonEmptyLevelsExt() const; MEDLOADER_EXPORT std::vector getNameArrNonEmptyLevelsExt() const; - MEDLOADER_EXPORT std::vector getGrpNonEmptyLevels(const std::string& grp) const; - MEDLOADER_EXPORT std::vector getGrpNonEmptyLevelsExt(const std::string& grp) const; - MEDLOADER_EXPORT std::vector getFamNonEmptyLevels(const std::string& fam) const; - MEDLOADER_EXPORT std::vector getFamNonEmptyLevelsExt(const std::string& fam) const; - MEDLOADER_EXPORT std::vector getGrpsNonEmptyLevels(const std::vector& grps) const; - MEDLOADER_EXPORT std::vector getGrpsNonEmptyLevelsExt(const std::vector& grps) const; MEDLOADER_EXPORT std::vector getFamsNonEmptyLevels(const std::vector& fams) const; MEDLOADER_EXPORT std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const; - MEDLOADER_EXPORT std::vector getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT DataArrayDouble *getCoords() const; MEDLOADER_EXPORT MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const; MEDLOADER_EXPORT MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector& grps, bool renum=false) const; @@ -387,6 +389,8 @@ namespace ParaMEDMEM MEDLOADER_EXPORT std::vector getNumArrNonEmptyLevelsExt() const; MEDLOADER_EXPORT std::vector getNameArrNonEmptyLevelsExt() const; MEDLOADER_EXPORT MEDCouplingMesh *getMeshAtLevel(int meshDimRelToMax, bool renum=false) const; + MEDLOADER_EXPORT std::vector getFamsNonEmptyLevels(const std::vector& fams) const; + MEDLOADER_EXPORT std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const; MEDLOADER_EXPORT int getSizeAtLevel(int meshDimRelToMaxExt) const; MEDLOADER_EXPORT int getNumberOfNodes() const; MEDLOADER_EXPORT int getNumberOfCellsAtLevel(int meshDimRelToMaxExt) const; diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 2dedfa744..8e0ef6a21 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -925,6 +925,15 @@ namespace ParaMEDMEM void setGroupsOnFamily(const std::string& famName, const std::vector& grps) throw(INTERP_KERNEL::Exception); std::vector getGroupsNames() const throw(INTERP_KERNEL::Exception); std::vector getFamiliesNames() const throw(INTERP_KERNEL::Exception); + std::vector getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception); + std::vector getGrpNonEmptyLevelsExt(const std::string& grp) const throw(INTERP_KERNEL::Exception); + std::vector getGrpNonEmptyLevels(const std::string& grp) const throw(INTERP_KERNEL::Exception); + std::vector getFamsNonEmptyLevels(const std::vector& fams) const throw(INTERP_KERNEL::Exception); + std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const throw(INTERP_KERNEL::Exception); + std::vector getGrpsNonEmptyLevels(const std::vector& grps) const throw(INTERP_KERNEL::Exception); + std::vector getGrpsNonEmptyLevelsExt(const std::vector& grps) const throw(INTERP_KERNEL::Exception); + std::vector getFamNonEmptyLevels(const std::string& fam) const throw(INTERP_KERNEL::Exception); + std::vector getFamNonEmptyLevelsExt(const std::string& fam) const throw(INTERP_KERNEL::Exception); std::vector getFamiliesNamesWithFilePointOfView() const throw(INTERP_KERNEL::Exception); static std::string GetMagicFamilyStr(); void assignFamilyNameWithGroupName() throw(INTERP_KERNEL::Exception); @@ -1171,15 +1180,6 @@ namespace ParaMEDMEM int getSpaceDimension() const throw(INTERP_KERNEL::Exception); int getRelativeLevOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); // - std::vector getGrpNonEmptyLevels(const std::string& grp) const throw(INTERP_KERNEL::Exception); - std::vector getGrpNonEmptyLevelsExt(const std::string& grp) const throw(INTERP_KERNEL::Exception); - std::vector getFamNonEmptyLevels(const std::string& fam) const throw(INTERP_KERNEL::Exception); - std::vector getFamNonEmptyLevelsExt(const std::string& fam) const throw(INTERP_KERNEL::Exception); - std::vector getGrpsNonEmptyLevels(const std::vector& grps) const throw(INTERP_KERNEL::Exception); - std::vector getGrpsNonEmptyLevelsExt(const std::vector& grps) const throw(INTERP_KERNEL::Exception); - std::vector getFamsNonEmptyLevels(const std::vector& fams) const throw(INTERP_KERNEL::Exception); - std::vector getFamsNonEmptyLevelsExt(const std::vector& fams) const throw(INTERP_KERNEL::Exception); - std::vector getGroupsOnSpecifiedLev(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getGroup(int meshDimRelToMaxExt, const std::string& grp, bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getGroups(int meshDimRelToMaxExt, const std::vector& grps, bool renum=false) const throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getFamily(int meshDimRelToMaxExt, const std::string& fam, bool renum=false) const throw(INTERP_KERNEL::Exception);