]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Bug fix: findCellIdsOnBoundary() wrongly throwing if void mesh.
authorabn <adrien.bruneton@cea.fr>
Mon, 13 Mar 2023 12:12:25 +0000 (13:12 +0100)
committerabn <adrien.bruneton@cea.fr>
Mon, 13 Mar 2023 12:12:25 +0000 (13:12 +0100)
src/MEDCoupling/MEDCouplingUMesh.cxx

index ef1d2381ce3cd6e6efdb1758fc64fdabb424bc83..76d748bd3c789bbc45bfc9d87aa4038d70837ce7 100755 (executable)
@@ -2229,10 +2229,15 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const
 DataArrayIdType *MEDCouplingUMesh::findCellIdsOnBoundary() const
 {
   checkFullyDefined();
-  MCAuto<DataArrayIdType> desc=DataArrayIdType::New();
-  MCAuto<DataArrayIdType> descIndx=DataArrayIdType::New();
-  MCAuto<DataArrayIdType> revDesc=DataArrayIdType::New();
-  MCAuto<DataArrayIdType> revDescIndx=DataArrayIdType::New();
+  MCAuto<DataArrayIdType> ret2(DataArrayIdType::New());
+
+  if (getNumberOfCells() == 0)
+    {
+      ret2->alloc(0,1);
+      return ret2.retn();
+    }
+
+  MCAuto<DataArrayIdType> 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();
 }
 
 /*!