From 65c3792cc2c76a564813b257aee832eefd918d76 Mon Sep 17 00:00:00 2001 From: "Zheng, Lei" Date: Wed, 5 Jul 2017 16:36:35 +0800 Subject: [PATCH] Path.Area: fix sortWires sortWires was broken on open wires. The bug was introduced when open wire direction feature is added. --- src/Mod/Path/App/Area.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index b3f242cfac..104c62b953 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -2065,13 +2065,14 @@ TopoDS_Shape Area::toShape(const CArea &area, bool fill, const gp_Trsf *trsf, in struct WireInfo { TopoDS_Wire wire; std::deque points; + gp_Pnt pt_end; bool isClosed; inline const gp_Pnt &pstart() const{ return points.front(); } inline const gp_Pnt &pend() const{ - return isClosed?pstart():points.back(); + return isClosed?pstart():pt_end; } }; @@ -2161,8 +2162,9 @@ struct GetWires { // We don't add in-between vertices of an open wire, because we // haven't implemented open wire breaking yet. info.points.push_back(p1); - if(params.direction!=Area::DirectionNone) + if(!info.isClosed && params.direction==Area::DirectionNone) info.points.push_back(p2); + info.pt_end = p2; } else { // For closed wires, we are can easily rebase the wire, so we // discretize the wires to spatial index it in order to accelerate @@ -2193,7 +2195,7 @@ struct GetWires { } auto it = wires.end(); --it; - for(size_t i=0,count=info.points.size();ipoints.size();ipstart()); - if(myParams.direction==Area::DirectionNone) { + if(myParams.direction!=Area::DirectionNone) { d = d1; p = it->pstart(); is_start = true; @@ -2437,7 +2439,8 @@ struct ShapeInfo{ std::list sortWires(const gp_Pnt &pstart, gp_Pnt &pend,double min_dist, gp_Pnt *pentry) { - if(pstart.SquareDistance(myStartPt)>Precision::SquareConfusion()) + if(myWires.empty() || + pstart.SquareDistance(myStartPt)>Precision::SquareConfusion()) nearest(pstart); if(pentry) *pentry = myBestPt;