From 8abc975c070c9def754fac7a1aa828d55a6ec412 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Fri, 14 Aug 2026 14:20:54 +0100 Subject: [PATCH] Revert "Mesh - Fix iterator invalidation in Delaun triangle-kill cascade (#1450)" (#1459) This reverts commit 7d2efad9c8a9a57ea96c4c8587134b34dd503cd8. --- .../TKMesh/BRepMesh/BRepMesh_Delaun.cxx | 41 ++++--------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx index 816177178d..faaa1abff7 100644 --- a/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx +++ b/src/ModelingAlgorithms/TKMesh/BRepMesh/BRepMesh_Delaun.cxx @@ -142,19 +142,6 @@ public: private: NCollection_LinearVector myFrames; // Container of frames. }; - -//! Returns a snapshot of the neighbor link ids of the given node. -NCollection_Array1 getSnapshotsOfNeighborLinkIds( - const IMeshData::ListOfInteger& theNeighborLinkIds) -{ - NCollection_Array1 aNeighborLinkIdsArray(theNeighborLinkIds.Size()); - size_t anIndex = 0; - for (const auto& aLinkId : theNeighborLinkIds) - { - aNeighborLinkIdsArray.ChangeAt(anIndex++) = aLinkId; - } - return aNeighborLinkIdsArray; -} } // anonymous namespace //================================================================================================= @@ -1556,24 +1543,18 @@ void BRepMesh_Delaun::killTrianglesAroundVertex( IMeshData::MapOfIntegerInteger& theLoopEdges, IMeshData::VectorOfInteger& theVictimNodes) { - // Snapshot the neighbor link ids before iterating - const NCollection_Array1 aNeighborLinkIdsArray = - getSnapshotsOfNeighborLinkIds(myMeshData->LinksConnectedTo(theZombieNodeId)); + IMeshData::ListOfInteger::Iterator aNeighborsIt = myMeshData->LinksConnectedTo(theZombieNodeId); // Try to infect neighbor nodes - for (const int aNeighborLinkId : aNeighborLinkIdsArray) + for (; aNeighborsIt.More(); aNeighborsIt.Next()) { + const int& aNeighborLinkId = aNeighborsIt.Value(); if (theSurvivedLinks.Contains(aNeighborLinkId)) { continue; } const BRepMesh_Edge& aNeighborLink = GetEdge(aNeighborLinkId); - if (aNeighborLink.Movability() == BRepMesh_Deleted) - { - continue; - } - if (aNeighborLink.Movability() == BRepMesh_Frontier) { // Though, if it lies onto the polygon boundary - @@ -1702,19 +1683,13 @@ void BRepMesh_Delaun::killTrianglesOnIntersectingLinks( killLinkTriangles(theLinkToCheckId, theLoopEdges); - // Snapshot the neighbor link ids before iterating - const NCollection_Array1 aNeighborLinkIds = - getSnapshotsOfNeighborLinkIds(myMeshData->LinksConnectedTo(theEndPoint)); + IMeshData::ListOfInteger::Iterator aNeighborsIt(myMeshData->LinksConnectedTo(theEndPoint)); - for (const int aNeighborLinkId : aNeighborLinkIds) + for (; aNeighborsIt.More(); aNeighborsIt.Next()) { - const BRepMesh_Edge& aNeighborLink = GetEdge(aNeighborLinkId); - if (aNeighborLink.Movability() == BRepMesh_Deleted) - { - continue; - } - - int anOtherNode = aNeighborLink.FirstNode(); + const int& aNeighborLinkId = aNeighborsIt.Value(); + const BRepMesh_Edge& aNeighborLink = GetEdge(aNeighborLinkId); + int anOtherNode = aNeighborLink.FirstNode(); if (anOtherNode == theEndPoint) { anOtherNode = aNeighborLink.LastNode();