clipper.hpp | clipper.hpp | |||
---|---|---|---|---|
/************************************************************************** ***** | /************************************************************************** ***** | |||
* * | * * | |||
* Author : Angus Johnson * | * Author : Angus Johnson * | |||
* Version : 5.1.5 | * Version : 5.1.6 | |||
* | * | |||
* Date : 4 May 2013 | * Date : 23 May 2013 | |||
* | * | |||
* Website : http://www.angusj.com * | * Website : http://www.angusj.com * | |||
* Copyright : Angus Johnson 2010-2013 * | * Copyright : Angus Johnson 2010-2013 * | |||
* * | * * | |||
* License: * | * License: * | |||
* Use, modification & distribution is subject to Boost Software License Ver 1. * | * Use, modification & distribution is subject to Boost Software License Ver 1. * | |||
* http://www.boost.org/LICENSE_1_0.txt * | * http://www.boost.org/LICENSE_1_0.txt * | |||
* * | * * | |||
* Attributions: * | * Attributions: * | |||
* The code in this library is an extension of Bala Vatti's clipping algorit hm: * | * The code in this library is an extension of Bala Vatti's clipping algorit hm: * | |||
* "A generic solution to polygon clipping" * | * "A generic solution to polygon clipping" * | |||
skipping to change at line 103 | skipping to change at line 103 | |||
~PolyTree(){Clear();}; | ~PolyTree(){Clear();}; | |||
PolyNode* GetFirst() const; | PolyNode* GetFirst() const; | |||
void Clear(); | void Clear(); | |||
int Total() const; | int Total() const; | |||
private: | private: | |||
PolyNodes AllNodes; | PolyNodes AllNodes; | |||
friend class Clipper; //to access AllNodes | friend class Clipper; //to access AllNodes | |||
}; | }; | |||
enum JoinType { jtSquare, jtRound, jtMiter }; | enum JoinType { jtSquare, jtRound, jtMiter }; | |||
enum EndType { etClosed, etButt, etSquare, etRound}; | ||||
bool Orientation(const Polygon &poly); | bool Orientation(const Polygon &poly); | |||
double Area(const Polygon &poly); | double Area(const Polygon &poly); | |||
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, | void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, | |||
double delta, JoinType jointype = jtSquare, double limit = 0, bool autoFi x = true); | double delta, JoinType jointype = jtSquare, double limit = 0, bool autoFi x = true); | |||
void OffsetPolyLines(const Polygons &in_lines, Polygons &out_lines, | ||||
double delta, JoinType jointype = jtSquare, EndType endtype = etSquare, d | ||||
ouble limit = 0, bool autoFix = true); | ||||
void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillT ype fillType = pftEvenOdd); | void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillT ype fillType = pftEvenOdd); | |||
void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFi llType fillType = pftEvenOdd); | void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFi llType fillType = pftEvenOdd); | |||
void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd); | void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd); | |||
void CleanPolygon(Polygon& in_poly, Polygon& out_poly, double distance = 1. | void CleanPolygon(const Polygon& in_poly, Polygon& out_poly, double distanc | |||
415); | e = 1.415); | |||
void CleanPolygons(Polygons& in_polys, Polygons& out_polys, double distance | void CleanPolygons(const Polygons& in_polys, Polygons& out_polys, double di | |||
= 1.415); | stance = 1.415); | |||
void PolyTreeToPolygons(PolyTree& polytree, Polygons& polygons); | void PolyTreeToPolygons(const PolyTree& polytree, Polygons& polygons); | |||
void ReversePolygon(Polygon& p); | void ReversePolygon(Polygon& p); | |||
void ReversePolygons(Polygons& p); | void ReversePolygons(Polygons& p); | |||
//used internally ... | //used internally ... | |||
enum EdgeSide { esLeft = 1, esRight = 2}; | enum EdgeSide { esLeft = 1, esRight = 2}; | |||
enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 }; | enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 }; | |||
//inline IntersectProtects operator|(IntersectProtects a, IntersectProtects | ||||
b) | ||||
//{return static_cast<IntersectProtects>(static_cast<int>(a) | static_cast< | ||||
int>(b));} | ||||
struct TEdge { | struct TEdge { | |||
long64 xbot; | long64 xbot; | |||
long64 ybot; | long64 ybot; | |||
long64 xcurr; | long64 xcurr; | |||
long64 ycurr; | long64 ycurr; | |||
long64 xtop; | long64 xtop; | |||
long64 ytop; | long64 ytop; | |||
double dx; | double dx; | |||
long64 deltaX; | long64 deltaX; | |||
skipping to change at line 300 | skipping to change at line 306 | |||
void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); | void 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, | void IntersectEdges(TEdge *e1, TEdge *e2, | |||
const IntPoint &pt, const IntersectProtects protects); | const IntPoint &pt, const IntersectProtects protects); | |||
OutRec* CreateOutRec(); | OutRec* CreateOutRec(); | |||
void AddOutPt(TEdge *e, const IntPoint &pt); | void AddOutPt(TEdge *e, const IntPoint &pt); | |||
void DisposeAllPolyPts(); | void DisposeAllPolyPts(); | |||
void DisposeOutRec(PolyOutList::size_type index); | void DisposeOutRec(PolyOutList::size_type index); | |||
bool ProcessIntersections(const long64 botY, const long64 topY); | bool ProcessIntersections(const long64 botY, const long64 topY); | |||
void AddIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt); | void InsertIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt); | |||
void BuildIntersectList(const long64 botY, const long64 topY); | void BuildIntersectList(const long64 botY, const long64 topY); | |||
void ProcessIntersectList(); | void ProcessIntersectList(); | |||
void ProcessEdgesAtTopOfScanbeam(const long64 topY); | void ProcessEdgesAtTopOfScanbeam(const long64 topY); | |||
void BuildResult(Polygons& polys); | void BuildResult(Polygons& 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); | |||
bool IsHole(TEdge *e); | bool IsHole(TEdge *e); | |||
End of changes. 7 change blocks. | ||||
10 lines changed or deleted | 19 lines changed or added | |||