From: abn Date: Mon, 13 Mar 2023 12:12:25 +0000 (+0100) Subject: Bug fix: findCellIdsOnBoundary() wrongly throwing if void mesh. X-Git-Tag: V9_11_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=21fb549d4414d2d84a7d875bfecb797c54ea7ef9;p=tools%2Fmedcoupling.git Bug fix: findCellIdsOnBoundary() wrongly throwing if void mesh. --- 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(); } /*!