From 21fb549d4414d2d84a7d875bfecb797c54ea7ef9 Mon Sep 17 00:00:00 2001 From: abn Date: Mon, 13 Mar 2023 13:12:25 +0100 Subject: [PATCH] Bug fix: findCellIdsOnBoundary() wrongly throwing if void mesh. --- src/MEDCoupling/MEDCouplingUMesh.cxx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index ef1d2381c..76d748bd3 100755 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -2229,10 +2229,15 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const DataArrayIdType *MEDCouplingUMesh::findCellIdsOnBoundary() const { checkFullyDefined(); - MCAuto desc=DataArrayIdType::New(); - MCAuto descIndx=DataArrayIdType::New(); - MCAuto revDesc=DataArrayIdType::New(); - MCAuto revDescIndx=DataArrayIdType::New(); + MCAuto ret2(DataArrayIdType::New()); + + if (getNumberOfCells() == 0) + { + ret2->alloc(0,1); + return ret2.retn(); + } + + MCAuto desc(DataArrayIdType::New()), descIndx(DataArrayIdType::New()), revDesc(DataArrayIdType::New()), revDescIndx(DataArrayIdType::New()); // buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx)->decrRef(); desc=(DataArrayIdType*)0; descIndx=(DataArrayIdType*)0; @@ -2248,7 +2253,6 @@ DataArrayIdType *MEDCouplingUMesh::findCellIdsOnBoundary() const if(!ret1[revDescPtr[revDescIndxPtr[*pt]]]) { ret1[revDescPtr[revDescIndxPtr[*pt]]]=true; sz++; } // - DataArrayIdType *ret2=DataArrayIdType::New(); ret2->alloc(sz,1); mcIdType *ret2Ptr=ret2->getPointer(); sz=0; @@ -2256,7 +2260,7 @@ DataArrayIdType *MEDCouplingUMesh::findCellIdsOnBoundary() const if(*it) *ret2Ptr++=sz; ret2->setName("BoundaryCells"); - return ret2; + return ret2.retn(); } /*! -- 2.39.2