Upgrade to Clipper 6.4.2

This commit is contained in:
Gaute Lindkvist
2020-12-03 08:31:47 +01:00
parent c61329bf9a
commit 6a2baf9c45
2 changed files with 27 additions and 18 deletions

View File

@@ -1,10 +1,10 @@
/******************************************************************************* /*******************************************************************************
* * * *
* Author : Angus Johnson * * Author : Angus Johnson *
* Version : 6.4.0 * * Version : 6.4.2 *
* Date : 2 July 2015 * * Date : 27 February 2017 *
* Website : http://www.angusj.com * * Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2015 * * Copyright : Angus Johnson 2010-2017 *
* * * *
* License: * * License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. * * Use, modification & distribution is subject to Boost Software License Ver 1. *
@@ -179,7 +179,7 @@ int PolyTree::Total() const
// PolyNode methods ... // PolyNode methods ...
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
PolyNode::PolyNode(): Childs(), Parent(0), Index(0), m_IsOpen(false) PolyNode::PolyNode(): Parent(0), Index(0), m_IsOpen(false)
{ {
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -1866,7 +1866,7 @@ OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
prevE = e->PrevInAEL; prevE = e->PrevInAEL;
} }
if (prevE && prevE->OutIdx >= 0) if (prevE && prevE->OutIdx >= 0 && prevE->Top.Y < Pt.Y && e->Top.Y < Pt.Y)
{ {
cInt xPrev = TopX(*prevE, Pt.Y); cInt xPrev = TopX(*prevE, Pt.Y);
cInt xE = TopX(*e, Pt.Y); cInt xE = TopX(*e, Pt.Y);
@@ -2713,7 +2713,11 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge)
if (horzEdge->OutIdx >= 0 && !IsOpen) //note: may be done multiple times if (horzEdge->OutIdx >= 0 && !IsOpen) //note: may be done multiple times
{ {
op1 = AddOutPt(horzEdge, e->Curr); #ifdef use_xyz
if (dir == dLeftToRight) SetZ(e->Curr, *horzEdge, *e);
else SetZ(e->Curr, *e, *horzEdge);
#endif
op1 = AddOutPt(horzEdge, e->Curr);
TEdge* eNextHorz = m_SortedEdges; TEdge* eNextHorz = m_SortedEdges;
while (eNextHorz) while (eNextHorz)
{ {
@@ -3039,7 +3043,10 @@ void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY)
{ {
e->Curr.X = TopX( *e, topY ); e->Curr.X = TopX( *e, topY );
e->Curr.Y = topY; e->Curr.Y = topY;
} #ifdef use_xyz
e->Curr.Z = topY == e->Top.Y ? e->Top.Z : (topY == e->Bot.Y ? e->Bot.Z : 0);
#endif
}
//When StrictlySimple and 'e' is being touched by another edge, then //When StrictlySimple and 'e' is being touched by another edge, then
//make sure both edges have a vertex here ... //make sure both edges have a vertex here ...
@@ -3663,7 +3670,7 @@ void Clipper::FixupFirstLefts3(OutRec* OldOutRec, OutRec* NewOutRec)
{ {
OutRec* outRec = m_PolyOuts[i]; OutRec* outRec = m_PolyOuts[i];
OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft); OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft);
if (outRec->Pts && outRec->FirstLeft == OldOutRec) if (outRec->Pts && firstLeft == OldOutRec)
outRec->FirstLeft = NewOutRec; outRec->FirstLeft = NewOutRec;
} }
} }
@@ -4322,10 +4329,10 @@ double DistanceFromLineSqrd(
const IntPoint& pt, const IntPoint& ln1, const IntPoint& ln2) const IntPoint& pt, const IntPoint& ln1, const IntPoint& ln2)
{ {
//The equation of a line in general form (Ax + By + C = 0) //The equation of a line in general form (Ax + By + C = 0)
//given 2 points (x<>,y<>) & (x<>,y<>) is ... //given 2 points (x<>,y<>) & (x<>,y<>) is ...
//(y<> - y<>)x + (x<> - x<>)y + (y<> - y<>)x<> - (x<> - x<>)y<> = 0 //(y<> - y<>)x + (x<> - x<>)y + (y<> - y<>)x<> - (x<> - x<>)y<> = 0
//A = (y<> - y<>); B = (x<> - x<>); C = (y<> - y<>)x<> - (x<> - x<>)y<> //A = (y<> - y<>); B = (x<> - x<>); C = (y<> - y<>)x<> - (x<> - x<>)y<>
//perpendicular distance of point (x<>,y<>) = (Ax<41> + By<42> + C)/Sqrt(A<> + B<>) //perpendicular distance of point (x<>,y<>) = (Ax<41> + By<42> + C)/Sqrt(A<> + B<>)
//see http://en.wikipedia.org/wiki/Perpendicular_distance //see http://en.wikipedia.org/wiki/Perpendicular_distance
double A = double(ln1.Y - ln2.Y); double A = double(ln1.Y - ln2.Y);
double B = double(ln2.X - ln1.X); double B = double(ln2.X - ln1.X);

View File

@@ -1,10 +1,10 @@
/******************************************************************************* /*******************************************************************************
* * * *
* Author : Angus Johnson * * Author : Angus Johnson *
* Version : 6.4.0 * * Version : 6.4.2 *
* Date : 2 July 2015 * * Date : 27 February 2017 *
* Website : http://www.angusj.com * * Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2015 * * Copyright : Angus Johnson 2010-2017 *
* * * *
* License: * * License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. * * Use, modification & distribution is subject to Boost Software License Ver 1. *
@@ -34,7 +34,7 @@
#ifndef clipper_hpp #ifndef clipper_hpp
#define clipper_hpp #define clipper_hpp
#define CLIPPER_VERSION "6.2.6" #define CLIPPER_VERSION "6.4.2"
//use_int32: When enabled 32bit ints are used instead of 64bit ints. This //use_int32: When enabled 32bit ints are used instead of 64bit ints. This
//improve performance but coordinate values are limited to the range +/- 46340 //improve performance but coordinate values are limited to the range +/- 46340
@@ -146,6 +146,7 @@ public:
bool IsOpen() const; bool IsOpen() const;
int ChildCount() const; int ChildCount() const;
private: private:
//PolyNode& operator =(PolyNode& other);
unsigned Index; //node index in Parent.Childs unsigned Index; //node index in Parent.Childs
bool m_IsOpen; bool m_IsOpen;
JoinType m_jointype; JoinType m_jointype;
@@ -159,12 +160,13 @@ private:
class PolyTree: public PolyNode class PolyTree: public PolyNode
{ {
public: public:
~PolyTree(){Clear();}; ~PolyTree(){ Clear(); };
PolyNode* GetFirst() const; PolyNode* GetFirst() const;
void Clear(); void Clear();
int Total() const; int Total() const;
private: private:
PolyNodes AllNodes; //PolyTree& operator =(PolyTree& other);
PolyNodes AllNodes;
friend class Clipper; //to access AllNodes friend class Clipper; //to access AllNodes
}; };