Merge pull request #173 from mapbox/clipper-upgrade

Incorporate Mapnik's Clipper upgrades for consistent results between Mac and Linux
This commit is contained in:
Eric Fischer
2016-02-17 13:43:09 -08:00
9 changed files with 1493 additions and 431 deletions
+4
View File
@@ -1,3 +1,7 @@
## 1.9.1
* Incorporate Mapnik's Clipper upgrades for consistent results between Mac and Linux
## 1.9.0 ## 1.9.0
* Claim vector tile version 2 in mbtiles * Claim vector tile version 2 in mbtiles
+539 -374
View File
File diff suppressed because it is too large Load Diff
+80 -40
View File
@@ -1,10 +1,10 @@
/******************************************************************************* /*******************************************************************************
* * * *
* Author : Angus Johnson * * Author : Angus Johnson *
* Version : 6.2.1 * * Version : 6.4.0 *
* Date : 31 October 2014 * * Date : 2 July 2015 *
* Website : http://www.angusj.com * * Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2014 * * Copyright : Angus Johnson 2010-2015 *
* * * *
* 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.0" #define CLIPPER_VERSION "6.2.6"
//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
@@ -50,6 +50,7 @@
//#define use_deprecated //#define use_deprecated
#include <vector> #include <vector>
#include <list>
#include <set> #include <set>
#include <stdexcept> #include <stdexcept>
#include <cstring> #include <cstring>
@@ -57,6 +58,9 @@
#include <ostream> #include <ostream>
#include <functional> #include <functional>
#include <queue> #include <queue>
#if defined(CLIPPER_IMPL_INCLUDE)
#include CLIPPER_IMPL_INCLUDE
#endif
namespace ClipperLib { namespace ClipperLib {
@@ -81,6 +85,12 @@ enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
#endif #endif
#if defined(CLIPPER_INTPOINT_IMPL)
typedef CLIPPER_INTPOINT_IMPL IntPoint;
#else
struct IntPoint { struct IntPoint {
cInt X; cInt X;
cInt Y; cInt Y;
@@ -100,11 +110,33 @@ struct IntPoint {
return a.X != b.X || a.Y != b.Y; return a.X != b.X || a.Y != b.Y;
} }
}; };
#endif
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if defined(CLIPPER_PATH_IMPL)
typedef CLIPPER_PATH_IMPL Path;
#else
typedef std::vector< IntPoint > Path; typedef std::vector< IntPoint > Path;
#endif
#if defined(CLIPPER_PATHS_IMPL)
typedef CLIPPER_PATHS_IMPL Paths;
#else
typedef std::vector< Path > Paths; typedef std::vector< Path > Paths;
#endif
inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;} inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;}
inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;} inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;}
@@ -200,7 +232,6 @@ enum EdgeSide { esLeft = 1, esRight = 2};
struct TEdge; struct TEdge;
struct IntersectNode; struct IntersectNode;
struct LocalMinimum; struct LocalMinimum;
struct Scanbeam;
struct OutPt; struct OutPt;
struct OutRec; struct OutRec;
struct Join; struct Join;
@@ -220,7 +251,7 @@ class ClipperBase
public: public:
ClipperBase(); ClipperBase();
virtual ~ClipperBase(); virtual ~ClipperBase();
bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed); virtual bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed); bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
virtual void Clear(); virtual void Clear();
IntRect GetBounds(); IntRect GetBounds();
@@ -229,12 +260,18 @@ public:
protected: protected:
void DisposeLocalMinimaList(); void DisposeLocalMinimaList();
TEdge* AddBoundsToLML(TEdge *e, bool IsClosed); TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
void PopLocalMinima();
virtual void Reset(); virtual void Reset();
TEdge* ProcessBound(TEdge* E, bool IsClockwise); TEdge* ProcessBound(TEdge* E, bool IsClockwise);
void DoMinimaLML(TEdge* E1, TEdge* E2, bool IsClosed); void InsertScanbeam(const cInt Y);
TEdge* DescendToMin(TEdge *&E); bool PopScanbeam(cInt &Y);
void AscendToMax(TEdge *&E, bool Appending, bool IsClosed); bool LocalMinimaPending();
bool PopLocalMinima(cInt Y, const LocalMinimum *&locMin);
OutRec* CreateOutRec();
void DisposeAllOutRecs();
void DisposeOutRec(PolyOutList::size_type index);
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
void DeleteFromAEL(TEdge *e);
void UpdateEdgeIntoAEL(TEdge *&e);
typedef std::vector<LocalMinimum> MinimaList; typedef std::vector<LocalMinimum> MinimaList;
MinimaList::iterator m_CurrentLM; MinimaList::iterator m_CurrentLM;
@@ -242,8 +279,13 @@ protected:
bool m_UseFullRange; bool m_UseFullRange;
EdgeList m_edges; EdgeList m_edges;
bool m_PreserveCollinear; bool m_PreserveCollinear;
bool m_HasOpenPaths; bool m_HasOpenPaths;
PolyOutList m_PolyOuts;
TEdge *m_ActiveEdges;
typedef std::priority_queue<cInt> ScanbeamList;
ScanbeamList m_Scanbeam;
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -251,16 +293,21 @@ class Clipper : public virtual ClipperBase
{ {
public: public:
Clipper(int initOptions = 0); Clipper(int initOptions = 0);
~Clipper();
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
Paths &solution, Paths &solution,
PolyFillType subjFillType = pftEvenOdd, PolyFillType fillType = pftEvenOdd);
PolyFillType clipFillType = pftEvenOdd);
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
PolyTree &polytree, Paths &solution,
PolyFillType subjFillType = pftEvenOdd, PolyFillType subjFillType,
PolyFillType clipFillType = pftEvenOdd); PolyFillType clipFillType);
bool ReverseSolution() {return m_ReverseOutput;}; bool Execute(ClipType clipType,
PolyTree &polytree,
PolyFillType fillType = pftEvenOdd);
bool Execute(ClipType clipType,
PolyTree &polytree,
PolyFillType subjFillType,
PolyFillType clipFillType);
bool ReverseSolution() { return m_ReverseOutput; };
void ReverseSolution(bool value) {m_ReverseOutput = value;}; void ReverseSolution(bool value) {m_ReverseOutput = value;};
bool StrictlySimple() {return m_StrictSimple;}; bool StrictlySimple() {return m_StrictSimple;};
void StrictlySimple(bool value) {m_StrictSimple = value;}; void StrictlySimple(bool value) {m_StrictSimple = value;};
@@ -269,17 +316,14 @@ public:
void ZFillFunction(ZFillCallback zFillFunc); void ZFillFunction(ZFillCallback zFillFunc);
#endif #endif
protected: protected:
void Reset();
virtual bool ExecuteInternal(); virtual bool ExecuteInternal();
private: private:
PolyOutList m_PolyOuts; JoinList m_Joins;
JoinList m_Joins; JoinList m_GhostJoins;
JoinList m_GhostJoins; IntersectList m_IntersectList;
IntersectList m_IntersectList; ClipType m_ClipType;
ClipType m_ClipType; typedef std::list<cInt> MaximaList;
typedef std::priority_queue<cInt> ScanbeamList; MaximaList m_Maxima;
ScanbeamList m_Scanbeam;
TEdge *m_ActiveEdges;
TEdge *m_SortedEdges; TEdge *m_SortedEdges;
bool m_ExecuteLocked; bool m_ExecuteLocked;
PolyFillType m_ClipFillType; PolyFillType m_ClipFillType;
@@ -293,31 +337,25 @@ private:
void SetWindingCount(TEdge& edge); void SetWindingCount(TEdge& edge);
bool IsEvenOddFillType(const TEdge& edge) const; bool IsEvenOddFillType(const TEdge& edge) const;
bool IsEvenOddAltFillType(const TEdge& edge) const; bool IsEvenOddAltFillType(const TEdge& edge) const;
void InsertScanbeam(const cInt Y);
cInt PopScanbeam();
void InsertLocalMinimaIntoAEL(const cInt botY); void InsertLocalMinimaIntoAEL(const cInt botY);
void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge); void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
void AddEdgeToSEL(TEdge *edge); void AddEdgeToSEL(TEdge *edge);
bool PopEdgeFromSEL(TEdge *&edge);
void CopyAELToSEL(); void CopyAELToSEL();
void DeleteFromSEL(TEdge *e); void DeleteFromSEL(TEdge *e);
void DeleteFromAEL(TEdge *e);
void UpdateEdgeIntoAEL(TEdge *&e);
void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2); void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
bool IsContributing(const TEdge& edge) const; bool IsContributing(const TEdge& edge) const;
bool IsTopHorz(const cInt XPos); bool IsTopHorz(const cInt XPos);
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
void DoMaxima(TEdge *e); void DoMaxima(TEdge *e);
void ProcessHorizontals(bool IsTopOfScanbeam); void ProcessHorizontals();
void ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam); void ProcessHorizontal(TEdge *horzEdge);
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
OutRec* GetOutRec(int idx); OutRec* GetOutRec(int idx);
void AppendPolygon(TEdge *e1, TEdge *e2); void AppendPolygon(TEdge *e1, TEdge *e2);
void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt); void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt);
OutRec* CreateOutRec();
OutPt* AddOutPt(TEdge *e, const IntPoint &pt); OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
void DisposeAllOutRecs(); OutPt* GetLastOutPt(TEdge *e);
void DisposeOutRec(PolyOutList::size_type index);
bool ProcessIntersections(const cInt topY); bool ProcessIntersections(const cInt topY);
void BuildIntersectList(const cInt topY); void BuildIntersectList(const cInt topY);
void ProcessIntersectList(); void ProcessIntersectList();
@@ -328,6 +366,7 @@ private:
void DisposeIntersectNodes(); void DisposeIntersectNodes();
bool FixupIntersectionOrder(); bool FixupIntersectionOrder();
void FixupOutPolygon(OutRec &outrec); void FixupOutPolygon(OutRec &outrec);
void FixupOutPolyline(OutRec &outrec);
bool IsHole(TEdge *e); bool IsHole(TEdge *e);
bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl); bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
void FixHoleLinkage(OutRec &outrec); void FixHoleLinkage(OutRec &outrec);
@@ -339,7 +378,8 @@ private:
void JoinCommonEdges(); void JoinCommonEdges();
void DoSimplePolygons(); void DoSimplePolygons();
void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec); void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec); void FixupFirstLefts2(OutRec* InnerOutRec, OutRec* OuterOutRec);
void FixupFirstLefts3(OutRec* OldOutRec, OutRec* NewOutRec);
#ifdef use_xyz #ifdef use_xyz
void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2); void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2);
#endif #endif
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
#define VERSION "tippecanoe v1.9.0\n" #define VERSION "tippecanoe v1.9.1\n"