clipper.hpp | clipper.hpp | |||
---|---|---|---|---|
/************************************************************************** ***** | /************************************************************************** ***** | |||
* * | * * | |||
* Author : Angus Johnson * | * Author : Angus Johnson * | |||
* Version : 4.9.7 | * Version : 4.10.0 | |||
* | * | |||
* Date : 29 November 2012 | * Date : 25 December 2012 | |||
* | * | |||
* Website : http://www.angusj.com * | * Website : http://www.angusj.com * | |||
* Copyright : Angus Johnson 2010-2012 * | * Copyright : Angus Johnson 2010-2012 * | |||
* * | * * | |||
* 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 90 | skipping to change at line 90 | |||
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, | void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, | |||
double delta, JoinType jointype = jtSquare, double MiterLimit = 2, bool C heckInputs = true); | double delta, JoinType jointype = jtSquare, double MiterLimit = 2, bool C heckInputs = 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 ReversePolygon(Polygon& p); | void ReversePolygon(Polygon& p); | |||
void ReversePolygons(Polygons& p); | void ReversePolygons(Polygons& p); | |||
//used internally ... | //used internally ... | |||
enum EdgeSide { esNeither = 0, esLeft = 1, esRight = 2, esBoth = 3 }; | 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 }; | |||
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; | |||
skipping to change at line 147 | skipping to change at line 147 | |||
struct OutPt; //forward declaration | struct OutPt; //forward declaration | |||
struct OutRec { | struct OutRec { | |||
int idx; | int idx; | |||
bool isHole; | bool isHole; | |||
OutRec *FirstLeft; | OutRec *FirstLeft; | |||
OutRec *AppendLink; | OutRec *AppendLink; | |||
OutPt *pts; | OutPt *pts; | |||
OutPt *bottomPt; | OutPt *bottomPt; | |||
OutPt *bottomFlag; | ||||
EdgeSide sides; | ||||
}; | }; | |||
struct OutPt { | struct OutPt { | |||
int idx; | int idx; | |||
IntPoint pt; | IntPoint pt; | |||
OutPt *next; | OutPt *next; | |||
OutPt *prev; | OutPt *prev; | |||
}; | }; | |||
struct JoinRec { | struct JoinRec { | |||
skipping to change at line 221 | skipping to change at line 219 | |||
PolyFillType clipFillType = pftEvenOdd); | PolyFillType clipFillType = pftEvenOdd); | |||
bool Execute(ClipType clipType, | bool Execute(ClipType clipType, | |||
ExPolygons &solution, | ExPolygons &solution, | |||
PolyFillType subjFillType = pftEvenOdd, | PolyFillType subjFillType = pftEvenOdd, | |||
PolyFillType clipFillType = pftEvenOdd); | PolyFillType clipFillType = pftEvenOdd); | |||
void Clear(); | void Clear(); | |||
bool ReverseSolution() {return m_ReverseOutput;}; | bool ReverseSolution() {return m_ReverseOutput;}; | |||
void ReverseSolution(bool value) {m_ReverseOutput = value;}; | void ReverseSolution(bool value) {m_ReverseOutput = value;}; | |||
protected: | protected: | |||
void Reset(); | void Reset(); | |||
virtual bool ExecuteInternal(bool fixHoleLinkages); | virtual bool ExecuteInternal(); | |||
private: | private: | |||
PolyOutList m_PolyOuts; | PolyOutList m_PolyOuts; | |||
JoinList m_Joins; | JoinList m_Joins; | |||
HorzJoinList m_HorizJoins; | HorzJoinList m_HorizJoins; | |||
ClipType m_ClipType; | ClipType m_ClipType; | |||
Scanbeam *m_Scanbeam; | Scanbeam *m_Scanbeam; | |||
TEdge *m_ActiveEdges; | TEdge *m_ActiveEdges; | |||
TEdge *m_SortedEdges; | TEdge *m_SortedEdges; | |||
IntersectNode *m_IntersectNodes; | IntersectNode *m_IntersectNodes; | |||
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_UsingExPolygons; | ||||
void DisposeScanbeamList(); | void DisposeScanbeamList(); | |||
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 long64 Y); | void InsertScanbeam(const long64 Y); | |||
long64 PopScanbeam(); | long64 PopScanbeam(); | |||
void InsertLocalMinimaIntoAEL(const long64 botY); | void InsertLocalMinimaIntoAEL(const long64 botY); | |||
void InsertEdgeIntoAEL(TEdge *edge); | void InsertEdgeIntoAEL(TEdge *edge); | |||
void AddEdgeToSEL(TEdge *edge); | void AddEdgeToSEL(TEdge *edge); | |||
void CopyAELToSEL(); | void CopyAELToSEL(); | |||
skipping to change at line 265 | skipping to change at line 264 | |||
void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); | void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); | |||
void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); | void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt); | |||
void AppendPolygon(TEdge *e1, TEdge *e2); | void AppendPolygon(TEdge *e1, TEdge *e2); | |||
void DoEdge1(TEdge *edge1, TEdge *edge2, const IntPoint &pt); | void DoEdge1(TEdge *edge1, TEdge *edge2, const IntPoint &pt); | |||
void DoEdge2(TEdge *edge1, TEdge *edge2, const IntPoint &pt); | void DoEdge2(TEdge *edge1, TEdge *edge2, const IntPoint &pt); | |||
void DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt); | void DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt); | |||
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 DisposeBottomPt(OutRec &outRec); | ||||
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 AddIntersectNode(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 BuildResultEx(ExPolygons& polys); | void BuildResultEx(ExPolygons& polys); | |||
void SetHoleState(TEdge *e, OutRec *OutRec); | void SetHoleState(TEdge *e, OutRec *OutRec); | |||
skipping to change at line 287 | skipping to change at line 285 | |||
bool FixupIntersections(); | bool FixupIntersections(); | |||
void FixupOutPolygon(OutRec &outRec); | void FixupOutPolygon(OutRec &outRec); | |||
bool IsHole(TEdge *e); | bool IsHole(TEdge *e); | |||
void FixHoleLinkage(OutRec *outRec); | void FixHoleLinkage(OutRec *outRec); | |||
void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1); | void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1); | |||
void ClearJoins(); | void ClearJoins(); | |||
void AddHorzJoin(TEdge *e, int idx); | void AddHorzJoin(TEdge *e, int idx); | |||
void ClearHorzJoins(); | void ClearHorzJoins(); | |||
bool JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2); | bool JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2); | |||
void FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx); | void FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx); | |||
void JoinCommonEdges(bool fixHoleLinkages); | void JoinCommonEdges(); | |||
}; | }; | |||
//------------------------------------------------------------------------- ----- | //------------------------------------------------------------------------- ----- | |||
//------------------------------------------------------------------------- ----- | //------------------------------------------------------------------------- ----- | |||
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() {} | |||
End of changes. 7 change blocks. | ||||
10 lines changed or deleted | 8 lines changed or added | |||