From c30040b691ab788a68fa35fe542899861ecfa88e Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Tue, 22 Apr 2014 15:19:35 +0200 Subject: [PATCH] Apply bug fix from upstream clipper Clipper fix in commit [r463] for bug repport #92 (http://sourceforge.net/p/polyclipping/code/463/tree//trunk/cpp/clipper.cpp?diff=504b9404fd48f873331e913b:462) is applied here. --- xs/src/clipper.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xs/src/clipper.cpp b/xs/src/clipper.cpp index 76522ac08..4a720b71b 100755 --- a/xs/src/clipper.cpp +++ b/xs/src/clipper.cpp @@ -1030,10 +1030,20 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool IsClockwise) cInt StartX; if (IsHorizontal(*E)) { - //it's possible for adjacent overlapping horz edges to start heading left - //before finishing right, so ... - if (IsClockwise) StartX = E->Prev->Bot.X; - else StartX = E->Next->Bot.X; + //first we need to be careful here with open paths because this + //may not be a true local minima (ie may be following a skip edge). + //also, watch for adjacent horz edges to start heading left + //before finishing right ... + if (IsClockwise) + { + if (E->Prev->Bot.Y == E->Bot.Y) StartX = E->Prev->Bot.X; + else StartX = E->Prev->Top.X; + } + else + { + if (E->Next->Bot.Y == E->Bot.Y) StartX = E->Next->Bot.X; + else StartX = E->Next->Top.X; + } if (E->Bot.X != StartX) ReverseHorizontal(*E); }