From 0ec64c24477ac08929969c8a1192ea55afb5580a Mon Sep 17 00:00:00 2001 From: Adrian Baddeley Date: Sat, 2 Apr 2016 18:20:59 +0800 Subject: [PATCH] Fixed reverse iterator comparison --- DESCRIPTION | 4 ++-- src/clipper.cpp | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 059951b..87c697a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: polyclip -Version: 1.5-5 -Date: 2016-03-31 +Version: 1.5-6 +Date: 2016-04-02 Title: Polygon Clipping Authors@R: c(person("Angus", "Johnson", role = "aut", comment="C++ original, http://www.angusj.com/delphi/clipper.php"), diff --git a/src/clipper.cpp b/src/clipper.cpp index 1fa2eea..2e88943 100644 --- a/src/clipper.cpp +++ b/src/clipper.cpp @@ -2680,8 +2680,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) eMaxPair = GetMaximaPair(eLastHorz); MaximaList::const_iterator maxIt; - MaximaList::const_reverse_iterator maxRit, maxRend; - if (m_Maxima.size() > 0) + MaximaList::const_reverse_iterator maxRit; + if (!m_Maxima.empty()) { //get the first maxima in range (X) ... if (dir == dLeftToRight) @@ -2694,9 +2694,9 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) else { maxRit = m_Maxima.rbegin(); - maxRend = m_Maxima.rend(); - while (maxRit != maxRend && *maxRit > horzEdge->Bot.X) maxRit++; - if (maxRit != maxRend && *maxRit <= eLastHorz->Top.X) + // reverse "!=" to work around a defect in early compilers + while(m_Maxima.rend() != maxRit && *maxRit > horzEdge->Bot.X) maxRit++; + if (m_Maxima.rend() != maxRit && *maxRit <= eLastHorz->Top.X) maxRit = m_Maxima.rend(); } } @@ -2714,7 +2714,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) //this code block inserts extra coords into horizontal edges (in output //polygons) whereever maxima touch these horizontal edges. This helps //'simplifying' polygons (ie if the Simplify property is set). - if (m_Maxima.size() > 0) + if (!m_Maxima.empty()) { if (dir == dLeftToRight) { @@ -2727,8 +2727,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) } else { - maxRend = m_Maxima.rend(); - while (maxRit != maxRend && *maxRit > e->Curr.X) + // reverse "!=" to work around a defect in early compilers + while (m_Maxima.rend() != maxRit && *maxRit > e->Curr.X) { if (horzEdge->OutIdx >= 0 && !IsOpen) AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.Y));