From 8e10113f024cd7288ed3e6e8ab44d51cee64d854 Mon Sep 17 00:00:00 2001 From: Anida Khizar Date: Mon, 28 Mar 2022 18:04:46 +0200 Subject: [PATCH] Bug fix: infinite loop when ordering 1D cells of piecewise meshes made up of closed parts --- src/MEDCoupling/MEDCouplingUMesh.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index a9181f3e7..c68de91a6 100755 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -7975,9 +7975,16 @@ DataArrayIdType *MEDCouplingUMesh::orderConsecutiveCells1D() const ptId = direction ? (ptId1 == prevPointId ? ptId2 : ptId1) : (ptId2 == prevPointId ? ptId1 : ptId2); if (dsi[ptId] == 1) // hitting the end of the line break; + prevPointId = ptId; mcIdType seg1 = rD[rDI[ptId]], seg2 = rD[rDI[ptId]+1]; activeSeg = (seg1 == activeSeg) ? seg2 : seg1; + + //for piecewise meshes made up of closed parts + bool segmentAlreadyTreated = (std::find(linePiece.begin(), linePiece.end(), activeSeg) != linePiece.end()); + if(segmentAlreadyTreated) + break; + } } // Done, save final piece into DA: @@ -7987,6 +7994,7 @@ DataArrayIdType *MEDCouplingUMesh::orderConsecutiveCells1D() const // identify next valid start segment (one which is not consumed) if(!edgeSet.empty()) startSeg = *(edgeSet.begin()); + } while (!edgeSet.empty()); return result.retn(); -- 2.39.2