From e8d31bee9acf09437bdde654114b628de8242811 Mon Sep 17 00:00:00 2001 From: abn Date: Mon, 26 Oct 2020 14:27:41 +0100 Subject: [PATCH] MEDFileCMesh: bug fix: getFamsNonEmptyLevels{Ext} was buggy --- src/MEDLoader/MEDFileMesh.cxx | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 10a17bc42..404e40cb5 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -6416,24 +6416,37 @@ MEDCouplingMesh *MEDFileStructuredMesh::getMeshAtLevel(int meshDimRelToMax, bool } } +/*! + * Returns all relative mesh levels (**excluding nodes**) where given families are defined. + * To include nodes, call getFamsNonEmptyLevelsExt() method. + * \param [in] fams - the name of the family of interest. + * \return std::vector - a sequence of the relative dimensions. + */ std::vector MEDFileStructuredMesh::getFamsNonEmptyLevels(const std::vector& fams) const { - std::vector ret; + std::vector lvls; + std::vector famIds(getFamiliesIds(fams)); const DataArrayIdType *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; + if(famCells && famCells->presenceOfValue(famIds)) + lvls.push_back(0); + if(famFaces && famFaces->presenceOfValue(famIds)) + lvls.push_back(-1); + return lvls; } +/*! + * Returns all relative mesh levels (including nodes) where given families are defined. + * \param [in] fams - the names of the families of interest. + * \return std::vector - a sequence of the relative dimensions. + */ std::vector MEDFileStructuredMesh::getFamsNonEmptyLevelsExt(const std::vector& fams) const { - std::vector ret(getFamsNonEmptyLevels(fams)); + std::vector lvls(getFamsNonEmptyLevels(fams)); + std::vector famIds(getFamiliesIds(fams)); const DataArrayIdType *famNodes(_fam_nodes); - if(famNodes && famNodes->presenceOfValue(ret)) - ret.push_back(1); - return ret; + if(famNodes && famNodes->presenceOfValue(famIds)) + lvls.push_back(1); + return lvls; } /*! -- 2.39.2