Update Clipper to 6.4.2

This commit is contained in:
jean-pierre charras 2017-03-01 14:54:32 +01:00
parent 9dff85f0dc
commit 9f1e154753
2 changed files with 5423 additions and 4045 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 6.4.0 *
* Date : 2 July 2015 *
* Version : 6.4.2 *
* Date : 27 February 2017 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2015 *
* Copyright : Angus Johnson 2010-2017 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
@ -34,7 +34,7 @@
#ifndef 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
// improve performance but coordinate values are limited to the range +/- 46340
@ -60,14 +60,22 @@
#include <queue>
namespace ClipperLib {
enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
enum PolyType { ptSubject, ptClip };
enum ClipType
{
ctIntersection, ctUnion, ctDifference, ctXor
};
enum PolyType
{
ptSubject, ptClip
};
// By far the most widely used winding rules for polygon filling are
// EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32)
// Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL)
// see http://glprogramming.com/red/chapter11.html
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
enum PolyFillType
{
pftEvenOdd, pftNonZero, pftPositive, pftNegative
};
#ifdef use_int32
typedef int cInt;
@ -82,7 +90,8 @@ enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
#endif
struct IntPoint {
struct IntPoint
{
cInt X;
cInt Y;
#ifdef use_xyz
@ -96,6 +105,7 @@ struct IntPoint {
{
return a.X == b.X && a.Y == b.Y;
}
friend inline bool operator!=( const IntPoint& a, const IntPoint& b )
{
return a.X != b.X || a.Y != b.Y;
@ -106,8 +116,17 @@ struct IntPoint {
typedef std::vector<IntPoint> Path;
typedef std::vector<Path> Paths;
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 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;
}
std::ostream& operator <<( std::ostream& s, const IntPoint& p );
std::ostream& operator <<( std::ostream& s, const Path& p );
@ -123,12 +142,22 @@ struct DoublePoint
// ------------------------------------------------------------------------------
#ifdef use_xyz
typedef void (*ZFillCallback)(IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top, IntPoint& pt);
typedef void (* ZFillCallback)( IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top,
IntPoint& pt );
#endif
enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
enum JoinType {jtSquare, jtRound, jtMiter};
enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
enum InitOptions
{
ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4
};
enum JoinType
{
jtSquare, jtRound, jtMiter
};
enum EndType
{
etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound
};
class PolyNode;
typedef std::vector<PolyNode*> PolyNodes;
@ -145,13 +174,16 @@ public:
bool IsHole() const;
bool IsOpen() const;
int ChildCount() const;
private:
// PolyNode& operator =(PolyNode& other);
unsigned Index; // node index in Parent.Childs
bool m_IsOpen;
JoinType m_jointype;
EndType m_endtype;
PolyNode* GetNextSiblingUp() const;
void AddChild( PolyNode& child );
friend class Clipper; // to access Index
friend class ClipperOffset;
};
@ -163,7 +195,9 @@ public:
PolyNode* GetFirst() const;
void Clear();
int Total() const;
private:
// PolyTree& operator =(PolyTree& other);
PolyNodes AllNodes;
friend class Clipper; // to access AllNodes
};
@ -172,8 +206,11 @@ bool Orientation(const Path &poly);
double Area( const Path& poly );
int PointInPolygon( const IntPoint& pt, const Path& path );
void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygon( const Path& in_poly, Paths& out_polys,
PolyFillType fillType = pftEvenOdd );
void SimplifyPolygons( const Paths& in_polys,
Paths& out_polys,
PolyFillType fillType = pftEvenOdd );
void SimplifyPolygons( Paths& polys, PolyFillType fillType = pftEvenOdd );
void CleanPolygon( const Path& in_poly, Path& out_poly, double distance = 1.415 );
@ -192,10 +229,16 @@ void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
void ReversePath( Path& p );
void ReversePaths( Paths& p );
struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
struct IntRect
{
cInt left; cInt top; cInt right; cInt bottom;
};
// enums that are used internally ...
enum EdgeSide { esLeft = 1, esRight = 2};
enum EdgeSide
{
esLeft = 1, esRight = 2
};
// forward declarations (for stuff used internally) ...
struct TEdge;
@ -224,8 +267,10 @@ public:
bool AddPaths( const Paths& ppg, PolyType PolyTyp, bool Closed );
virtual void Clear();
IntRect GetBounds();
bool PreserveCollinear() { return m_PreserveCollinear; };
void PreserveCollinear( bool value ) { m_PreserveCollinear = value; };
protected:
void DisposeLocalMinimaList();
TEdge* AddBoundsToLML( TEdge* e, bool IsClosed );
@ -276,6 +321,7 @@ public:
PolyTree& polytree,
PolyFillType subjFillType,
PolyFillType clipFillType );
bool ReverseSolution() { return m_ReverseOutput; };
void ReverseSolution( bool value ) { m_ReverseOutput = value; };
bool StrictlySimple() { return m_StrictSimple; };
@ -283,9 +329,12 @@ public:
// set the callback function for z value filling on intersections (otherwise Z is 0)
#ifdef use_xyz
void ZFillFunction( ZFillCallback zFillFunc );
#endif
protected:
virtual bool ExecuteInternal();
private:
JoinList m_Joins;
JoinList m_GhostJoins;
@ -349,8 +398,10 @@ private:
void FixupFirstLefts1( OutRec* OldOutRec, OutRec* NewOutRec );
void FixupFirstLefts2( OutRec* InnerOutRec, OutRec* OuterOutRec );
void FixupFirstLefts3( OutRec* OldOutRec, OutRec* NewOutRec );
#ifdef use_xyz
void SetZ( IntPoint& pt, TEdge& e1, TEdge& e2 );
#endif
};
// ------------------------------------------------------------------------------
@ -365,8 +416,10 @@ public:
void Execute( Paths& solution, double delta );
void Execute( PolyTree& solution, double delta );
void Clear();
double MiterLimit;
double ArcTolerance;
private:
Paths m_destPolys;
Path m_srcPoly;
@ -392,13 +445,11 @@ class clipperException : public std::exception
clipperException( const char* description ) : m_descr( description ) {}
virtual ~clipperException() throw() {}
virtual const char* what() const throw()override { return m_descr.c_str(); }
private:
std::string m_descr;
};
// ------------------------------------------------------------------------------
} // ClipperLib namespace
#endif // clipper_hpp