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 * * 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,20 +34,20 @@
#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
//#define use_int32 // #define use_int32
//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance. // use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
//#define use_xyz // #define use_xyz
//use_lines: Enables line clipping. Adds a very minor cost to performance. // use_lines: Enables line clipping. Adds a very minor cost to performance.
#define use_lines #define use_lines
//use_deprecated: Enables temporary support for the obsolete functions // use_deprecated: Enables temporary support for the obsolete functions
//#define use_deprecated // #define use_deprecated
#include <vector> #include <vector>
#include <list> #include <list>
@ -60,144 +60,187 @@
#include <queue> #include <queue>
namespace ClipperLib { namespace ClipperLib {
enum ClipType
enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; {
enum PolyType { ptSubject, ptClip }; ctIntersection, ctUnion, ctDifference, ctXor
//By far the most widely used winding rules for polygon filling are };
//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32) enum PolyType
//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL) {
//see http://glprogramming.com/red/chapter11.html ptSubject, ptClip
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; };
// 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
};
#ifdef use_int32 #ifdef use_int32
typedef int cInt; typedef int cInt;
static cInt const loRange = 0x7FFF; static cInt const loRange = 0x7FFF;
static cInt const hiRange = 0x7FFF; static cInt const hiRange = 0x7FFF;
#else #else
typedef signed long long cInt; typedef signed long long cInt;
static cInt const loRange = 0x3FFFFFFF; static cInt const loRange = 0x3FFFFFFF;
static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL; static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
typedef signed long long long64; //used by Int128 class typedef signed long long long64; // used by Int128 class
typedef unsigned long long ulong64; typedef unsigned long long ulong64;
#endif #endif
struct IntPoint { struct IntPoint
cInt X; {
cInt Y; cInt X;
cInt Y;
#ifdef use_xyz #ifdef use_xyz
cInt Z; cInt Z;
IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {}; IntPoint( cInt x = 0, cInt y = 0, cInt z = 0 ) : X( x ), Y( y ), Z( z ) {};
#else #else
IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {}; IntPoint( cInt x = 0, cInt y = 0 ) : X( x ), Y( y ) {};
#endif #endif
friend inline bool operator== (const IntPoint& a, const IntPoint& b) friend inline bool operator==( const IntPoint& a, const IntPoint& b )
{ {
return a.X == b.X && a.Y == b.Y; return a.X == b.X && a.Y == b.Y;
} }
friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
{ friend inline bool operator!=( const IntPoint& a, const IntPoint& b )
return a.X != b.X || a.Y != b.Y; {
} return a.X != b.X || a.Y != b.Y;
}
}; };
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
typedef std::vector< IntPoint > Path; typedef std::vector<IntPoint> Path;
typedef std::vector< Path > Paths; typedef std::vector<Path> Paths;
inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;} inline Path& operator <<( Path& poly, const IntPoint& p )
inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;} {
poly.push_back( p ); return poly;
}
std::ostream& operator <<(std::ostream &s, const IntPoint &p);
std::ostream& operator <<(std::ostream &s, const Path &p); inline Paths& operator <<( Paths& polys, const Path& p )
std::ostream& operator <<(std::ostream &s, const Paths &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 );
std::ostream& operator <<( std::ostream& s, const Paths& p );
struct DoublePoint struct DoublePoint
{ {
double X; double X;
double Y; double Y;
DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {} DoublePoint( double x = 0, double y = 0 ) : X( x ), Y( y ) {}
DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {} DoublePoint( IntPoint ip ) : X( (double) ip.X ), Y( (double) ip.Y ) {}
}; };
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
#ifdef use_xyz #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 #endif
enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4}; enum InitOptions
enum JoinType {jtSquare, jtRound, jtMiter}; {
enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound}; ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4
};
enum JoinType
{
jtSquare, jtRound, jtMiter
};
enum EndType
{
etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound
};
class PolyNode; class PolyNode;
typedef std::vector< PolyNode* > PolyNodes; typedef std::vector<PolyNode*> PolyNodes;
class PolyNode class PolyNode
{ {
public: public:
PolyNode(); PolyNode();
virtual ~PolyNode(){}; virtual ~PolyNode() {};
Path Contour; Path Contour;
PolyNodes Childs; PolyNodes Childs;
PolyNode* Parent; PolyNode* Parent;
PolyNode* GetNext() const; PolyNode* GetNext() const;
bool IsHole() const; bool IsHole() const;
bool IsOpen() const; bool IsOpen() const;
int ChildCount() const; int ChildCount() const;
private: private:
unsigned Index; //node index in Parent.Childs // PolyNode& operator =(PolyNode& other);
unsigned Index; // node index in Parent.Childs
bool m_IsOpen; bool m_IsOpen;
JoinType m_jointype; JoinType m_jointype;
EndType m_endtype; EndType m_endtype;
PolyNode* GetNextSiblingUp() const; PolyNode* GetNextSiblingUp() const;
void AddChild(PolyNode& child); void AddChild( PolyNode& child );
friend class Clipper; //to access Index
friend class Clipper; // to access Index
friend class ClipperOffset; friend class ClipperOffset;
}; };
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:
// PolyTree& operator =(PolyTree& other);
PolyNodes AllNodes; PolyNodes AllNodes;
friend class Clipper; //to access AllNodes friend class Clipper; // to access AllNodes
}; };
bool Orientation(const Path &poly); bool Orientation( const Path& poly );
double Area(const Path &poly); double Area( const Path& poly );
int PointInPolygon(const IntPoint &pt, const Path &path); int PointInPolygon( const IntPoint& pt, const Path& path );
void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd); void SimplifyPolygon( const Path& in_poly, Paths& out_polys,
void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd); PolyFillType fillType = pftEvenOdd );
void SimplifyPolygons(Paths &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); void CleanPolygon( const Path& in_poly, Path& out_poly, double distance = 1.415 );
void CleanPolygon(Path& poly, double distance = 1.415); void CleanPolygon( Path& poly, double distance = 1.415 );
void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415); void CleanPolygons( const Paths& in_polys, Paths& out_polys, double distance = 1.415 );
void CleanPolygons(Paths& polys, double distance = 1.415); void CleanPolygons( Paths& polys, double distance = 1.415 );
void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed); void MinkowskiSum( const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed );
void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed); void MinkowskiSum( const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed );
void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution); void MinkowskiDiff( const Path& poly1, const Path& poly2, Paths& solution );
void PolyTreeToPaths(const PolyTree& polytree, Paths& paths); void PolyTreeToPaths( const PolyTree& polytree, Paths& paths );
void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths); void ClosedPathsFromPolyTree( const PolyTree& polytree, Paths& paths );
void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths); void OpenPathsFromPolyTree( PolyTree& polytree, Paths& paths );
void ReversePath(Path& p); void ReversePath( Path& p );
void ReversePaths(Paths& 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 ... // enums that are used internally ...
enum EdgeSide { esLeft = 1, esRight = 2}; enum EdgeSide
{
esLeft = 1, esRight = 2
};
//forward declarations (for stuff used internally) ... // forward declarations (for stuff used internally) ...
struct TEdge; struct TEdge;
struct IntersectNode; struct IntersectNode;
struct LocalMinimum; struct LocalMinimum;
@ -205,200 +248,208 @@ struct OutPt;
struct OutRec; struct OutRec;
struct Join; struct Join;
typedef std::vector < OutRec* > PolyOutList; typedef std::vector <OutRec*> PolyOutList;
typedef std::vector < TEdge* > EdgeList; typedef std::vector <TEdge*> EdgeList;
typedef std::vector < Join* > JoinList; typedef std::vector <Join*> JoinList;
typedef std::vector < IntersectNode* > IntersectList; typedef std::vector <IntersectNode*> IntersectList;
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
//ClipperBase is the ancestor to the Clipper class. It should not be // ClipperBase is the ancestor to the Clipper class. It should not be
//instantiated directly. This class simply abstracts the conversion of sets of // instantiated directly. This class simply abstracts the conversion of sets of
//polygon coordinates into edge objects that are stored in a LocalMinima list. // polygon coordinates into edge objects that are stored in a LocalMinima list.
class ClipperBase class ClipperBase
{ {
public: public:
ClipperBase(); ClipperBase();
virtual ~ClipperBase(); virtual ~ClipperBase();
virtual 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();
bool PreserveCollinear() {return m_PreserveCollinear;};
void PreserveCollinear(bool value) {m_PreserveCollinear = value;}; bool PreserveCollinear() { return m_PreserveCollinear; };
void PreserveCollinear( bool value ) { m_PreserveCollinear = value; };
protected: protected:
void DisposeLocalMinimaList(); void DisposeLocalMinimaList();
TEdge* AddBoundsToLML(TEdge *e, bool IsClosed); TEdge* AddBoundsToLML( TEdge* e, bool IsClosed );
virtual void Reset(); virtual void Reset();
TEdge* ProcessBound(TEdge* E, bool IsClockwise); TEdge* ProcessBound( TEdge* E, bool IsClockwise );
void InsertScanbeam(const cInt Y); void InsertScanbeam( const cInt Y );
bool PopScanbeam(cInt &Y); bool PopScanbeam( cInt& Y );
bool LocalMinimaPending(); bool LocalMinimaPending();
bool PopLocalMinima(cInt Y, const LocalMinimum *&locMin); bool PopLocalMinima( cInt Y, const LocalMinimum*& locMin );
OutRec* CreateOutRec(); OutRec* CreateOutRec();
void DisposeAllOutRecs(); void DisposeAllOutRecs();
void DisposeOutRec(PolyOutList::size_type index); void DisposeOutRec( PolyOutList::size_type index );
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2); void SwapPositionsInAEL( TEdge* edge1, TEdge* edge2 );
void DeleteFromAEL(TEdge *e); void DeleteFromAEL( TEdge* e );
void UpdateEdgeIntoAEL(TEdge *&e); void UpdateEdgeIntoAEL( TEdge*& e );
typedef std::vector<LocalMinimum> MinimaList; typedef std::vector<LocalMinimum> MinimaList;
MinimaList::iterator m_CurrentLM; MinimaList::iterator m_CurrentLM;
MinimaList m_MinimaList; MinimaList m_MinimaList;
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; PolyOutList m_PolyOuts;
TEdge *m_ActiveEdges; TEdge* m_ActiveEdges;
typedef std::priority_queue<cInt> ScanbeamList; typedef std::priority_queue<cInt> ScanbeamList;
ScanbeamList m_Scanbeam; ScanbeamList m_Scanbeam;
}; };
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
class Clipper : public virtual ClipperBase class Clipper : public virtual ClipperBase
{ {
public: public:
Clipper(int initOptions = 0); Clipper( int initOptions = 0 );
bool Execute(ClipType clipType, bool Execute( ClipType clipType,
Paths &solution, Paths& solution,
PolyFillType fillType = pftEvenOdd); PolyFillType fillType = pftEvenOdd );
bool Execute(ClipType clipType, bool Execute( ClipType clipType,
Paths &solution, Paths& solution,
PolyFillType subjFillType, PolyFillType subjFillType,
PolyFillType clipFillType); PolyFillType clipFillType );
bool Execute(ClipType clipType, bool Execute( ClipType clipType,
PolyTree &polytree, PolyTree& polytree,
PolyFillType fillType = pftEvenOdd); PolyFillType fillType = pftEvenOdd );
bool Execute(ClipType clipType, bool Execute( ClipType clipType,
PolyTree &polytree, PolyTree& polytree,
PolyFillType subjFillType, PolyFillType subjFillType,
PolyFillType clipFillType); PolyFillType clipFillType );
bool ReverseSolution() { return m_ReverseOutput; };
void ReverseSolution(bool value) {m_ReverseOutput = value;}; bool ReverseSolution() { return m_ReverseOutput; };
bool StrictlySimple() {return m_StrictSimple;}; void ReverseSolution( bool value ) { m_ReverseOutput = value; };
void StrictlySimple(bool value) {m_StrictSimple = value;}; bool StrictlySimple() { return m_StrictSimple; };
//set the callback function for z value filling on intersections (otherwise Z is 0) void StrictlySimple( bool value ) { m_StrictSimple = value; };
// set the callback function for z value filling on intersections (otherwise Z is 0)
#ifdef use_xyz #ifdef use_xyz
void ZFillFunction(ZFillCallback zFillFunc); void ZFillFunction( ZFillCallback zFillFunc );
#endif #endif
protected: protected:
virtual bool ExecuteInternal(); virtual bool ExecuteInternal();
private: private:
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::list<cInt> MaximaList;
MaximaList m_Maxima; MaximaList m_Maxima;
TEdge *m_SortedEdges; TEdge* m_SortedEdges;
bool m_ExecuteLocked; bool m_ExecuteLocked;
PolyFillType m_ClipFillType; PolyFillType m_ClipFillType;
PolyFillType m_SubjFillType; PolyFillType m_SubjFillType;
bool m_ReverseOutput; bool m_ReverseOutput;
bool m_UsingPolyTree; bool m_UsingPolyTree;
bool m_StrictSimple; bool m_StrictSimple;
#ifdef use_xyz #ifdef use_xyz
ZFillCallback m_ZFill; //custom callback ZFillCallback m_ZFill; // custom callback
#endif #endif
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 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); bool PopEdgeFromSEL( TEdge*& edge );
void CopyAELToSEL(); void CopyAELToSEL();
void DeleteFromSEL(TEdge *e); void DeleteFromSEL( 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 DoMaxima(TEdge *e); void DoMaxima( TEdge* e );
void ProcessHorizontals(); void ProcessHorizontals();
void ProcessHorizontal(TEdge *horzEdge); 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 );
OutPt* AddOutPt(TEdge *e, const IntPoint &pt); OutPt* AddOutPt( TEdge* e, const IntPoint& pt );
OutPt* GetLastOutPt(TEdge *e); OutPt* GetLastOutPt( TEdge* e );
bool ProcessIntersections(const cInt topY); bool ProcessIntersections( const cInt topY );
void BuildIntersectList(const cInt topY); void BuildIntersectList( const cInt topY );
void ProcessIntersectList(); void ProcessIntersectList();
void ProcessEdgesAtTopOfScanbeam(const cInt topY); void ProcessEdgesAtTopOfScanbeam( const cInt topY );
void BuildResult(Paths& polys); void BuildResult( Paths& polys );
void BuildResult2(PolyTree& polytree); void BuildResult2( PolyTree& polytree );
void SetHoleState(TEdge *e, OutRec *outrec); void SetHoleState( TEdge* e, OutRec* outrec );
void DisposeIntersectNodes(); void DisposeIntersectNodes();
bool FixupIntersectionOrder(); bool FixupIntersectionOrder();
void FixupOutPolygon(OutRec &outrec); void FixupOutPolygon( OutRec& outrec );
void FixupOutPolyline(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 );
void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt); void AddJoin( OutPt* op1, OutPt* op2, const IntPoint offPt );
void ClearJoins(); void ClearJoins();
void ClearGhostJoins(); void ClearGhostJoins();
void AddGhostJoin(OutPt *op, const IntPoint offPt); void AddGhostJoin( OutPt* op, const IntPoint offPt );
bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2); bool JoinPoints( Join* j, OutRec* outRec1, OutRec* outRec2 );
void JoinCommonEdges(); void JoinCommonEdges();
void DoSimplePolygons(); void DoSimplePolygons();
void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec); void FixupFirstLefts1( OutRec* OldOutRec, OutRec* NewOutRec );
void FixupFirstLefts2(OutRec* InnerOutRec, OutRec* OuterOutRec); void FixupFirstLefts2( OutRec* InnerOutRec, OutRec* OuterOutRec );
void FixupFirstLefts3(OutRec* OldOutRec, OutRec* NewOutRec); 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
}; };
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
class ClipperOffset class ClipperOffset
{ {
public: public:
ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25); ClipperOffset( double miterLimit = 2.0, double roundPrecision = 0.25 );
~ClipperOffset(); ~ClipperOffset();
void AddPath(const Path& path, JoinType joinType, EndType endType); void AddPath( const Path& path, JoinType joinType, EndType endType );
void AddPaths(const Paths& paths, JoinType joinType, EndType endType); void AddPaths( const Paths& paths, JoinType joinType, EndType endType );
void Execute(Paths& solution, double delta); void Execute( Paths& solution, double delta );
void Execute(PolyTree& solution, double delta); void Execute( PolyTree& solution, double delta );
void Clear(); void Clear();
double MiterLimit;
double ArcTolerance;
private:
Paths m_destPolys;
Path m_srcPoly;
Path m_destPoly;
std::vector<DoublePoint> m_normals;
double m_delta, m_sinA, m_sin, m_cos;
double m_miterLim, m_StepsPerRad;
IntPoint m_lowest;
PolyNode m_polyNodes;
void FixOrientations(); double MiterLimit;
void DoOffset(double delta); double ArcTolerance;
void OffsetPoint(int j, int& k, JoinType jointype);
void DoSquare(int j, int k); private:
void DoMiter(int j, int k, double r); Paths m_destPolys;
void DoRound(int j, int k); Path m_srcPoly;
Path m_destPoly;
std::vector<DoublePoint> m_normals;
double m_delta, m_sinA, m_sin, m_cos;
double m_miterLim, m_StepsPerRad;
IntPoint m_lowest;
PolyNode m_polyNodes;
void FixOrientations();
void DoOffset( double delta );
void OffsetPoint( int j, int& k, JoinType jointype );
void DoSquare( int j, int k );
void DoMiter( int j, int k, double r );
void DoRound( int j, int k );
}; };
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
class clipperException : public std::exception class clipperException : public std::exception
{ {
public: public:
clipperException(const char* description): m_descr(description) {} clipperException( const char* description ) : m_descr( description ) {}
virtual ~clipperException() throw() {} virtual ~clipperException() throw() {}
virtual const char* what() const throw() override { return m_descr.c_str(); } virtual const char* what() const throw()override { return m_descr.c_str(); }
private:
private:
std::string m_descr; std::string m_descr;
}; };
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
} // ClipperLib namespace
} //ClipperLib namespace
#endif //clipper_hpp
#endif // clipper_hpp