From d1d2299f42f5966056080be321bbf8cf479fd124 Mon Sep 17 00:00:00 2001 From: ifv Date: Thu, 19 Aug 2021 15:05:53 +0300 Subject: [PATCH] 0030422: Random behaviour of BRepAdaptor_CompCurve BRepTools/BRepTools_WireExplorer.cxx - replace MapOfShape vmap by IndexedMapOfShape to avoid random behavior of algorithm --- src/BRepTools/BRepTools_WireExplorer.cxx | 30 +++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/BRepTools/BRepTools_WireExplorer.cxx b/src/BRepTools/BRepTools_WireExplorer.cxx index 4a71206512..ca2c028916 100644 --- a/src/BRepTools/BRepTools_WireExplorer.cxx +++ b/src/BRepTools/BRepTools_WireExplorer.cxx @@ -226,7 +226,8 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, } // map of vertices to know if the wire is open - TopTools_MapOfShape vmap; + //TopTools_MapOfShape vmap; + TopTools_IndexedMapOfShape vmap; // map of infinite edges TopTools_MapOfShape anInfEmap; @@ -255,14 +256,16 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, // add or remove in the vertex map V1.Orientation(TopAbs_FORWARD); if (!vmap.Add(V1)) - vmap.Remove(V1); + //vmap.Remove(V1); + vmap.RemoveKey(V1); } if (!V2.IsNull()) { V2.Orientation(TopAbs_REVERSED); if (!vmap.Add(V2)) - vmap.Remove(V2); + //vmap.Remove(V2); + vmap.RemoveKey(V2); } if (V1.IsNull() || V2.IsNull()) @@ -294,13 +297,24 @@ void BRepTools_WireExplorer::Init(const TopoDS_Wire& W, } // if vmap is not empty the wire is open, let us find the first vertex + V1.Nullify(); + V2.Nullify(); if (!vmap.IsEmpty()) { - TopTools_MapIteratorOfMapOfShape itt(vmap); - while (itt.Key().Orientation() != TopAbs_FORWARD) { - itt.Next(); - if (!itt.More()) break; + //TopTools_MapIteratorOfMapOfShape itt(vmap); + //while (itt.Key().Orientation() != TopAbs_FORWARD) { + // itt.Next(); + // if (!itt.More()) break; + //} + //if (itt.More()) V1 = TopoDS::Vertex(itt.Key()); + Standard_Integer ind = 0; + for (ind = 1; ind <= vmap.Extent(); ++ind) + { + if (vmap(ind).Orientation() == TopAbs_FORWARD) + { + V1 = TopoDS::Vertex(vmap(ind)); + break; + } } - if (itt.More()) V1 = TopoDS::Vertex(itt.Key()); } else { // The wire is infinite Try to find the first vertex. It may be NULL. -- 2.39.5