clipper.hpp | clipper.hpp | |||
---|---|---|---|---|
/************************************************************************** ***** | /************************************************************************** ***** | |||
* * | * * | |||
* Author : Angus Johnson * | * Author : Angus Johnson * | |||
* Version : 5.1.0 | * Version : 5.1.2 | |||
* | * | |||
* Date : 1 February 2013 | * Date : 25 February 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 76 | skipping to change at line 76 | |||
std::ostream& operator <<(std::ostream &s, Polygon &p); | std::ostream& operator <<(std::ostream &s, Polygon &p); | |||
std::ostream& operator <<(std::ostream &s, Polygons &p); | std::ostream& operator <<(std::ostream &s, Polygons &p); | |||
class PolyNode; | class PolyNode; | |||
typedef std::vector< PolyNode* > PolyNodes; | typedef std::vector< PolyNode* > PolyNodes; | |||
class PolyNode | class PolyNode | |||
{ | { | |||
public: | public: | |||
PolyNode(); | ||||
Polygon Contour; | Polygon Contour; | |||
PolyNodes Childs; | PolyNodes Childs; | |||
PolyNode* Parent; | PolyNode* Parent; | |||
PolyNode* GetNext(); | PolyNode* GetNext() const; | |||
bool IsHole(); | bool IsHole() const; | |||
int ChildCount(); | int ChildCount() const; | |||
private: | private: | |||
PolyNode* GetNextSiblingUp(); | PolyNode* GetNextSiblingUp() const; | |||
unsigned Index; //node index in Parent.Childs | unsigned Index; //node index in Parent.Childs | |||
void AddChild(PolyNode& child); | void AddChild(PolyNode& child); | |||
friend class Clipper; //to access Index | friend class Clipper; //to access Index | |||
}; | }; | |||
class PolyTree: public PolyNode | class PolyTree: public PolyNode | |||
{ | { | |||
public: | public: | |||
~PolyTree(){Clear();}; | ~PolyTree(){Clear();}; | |||
PolyNode* GetFirst(); | PolyNode* GetFirst() const; | |||
void Clear(); | void Clear(); | |||
int Total(); | 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 }; | |||
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 MiterLimit = 2, bool A utoFix = true); | double delta, JoinType jointype = jtSquare, double limit = 0, bool autoFi x = 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. 415); | void CleanPolygon(Polygon& in_poly, Polygon& out_poly, double distance = 1. 415); | |||
void CleanPolygons(Polygons& in_polys, Polygons& out_polys, double distance = 1.415); | void CleanPolygons(Polygons& in_polys, Polygons& out_polys, double distance = 1.415); | |||
void PolyTreeToPolygons(PolyTree& polytree, Polygons& polygons); | void PolyTreeToPolygons(PolyTree& polytree, Polygons& polygons); | |||
skipping to change at line 306 | skipping to change at line 308 | |||
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 BuildResult2(PolyTree& polytree); | void BuildResult2(PolyTree& polytree); | |||
void SetHoleState(TEdge *e, OutRec *OutRec); | void SetHoleState(TEdge *e, OutRec *OutRec); | |||
void DisposeIntersectNodes(); | void DisposeIntersectNodes(); | |||
bool FixupIntersections(); | bool FixupIntersectionOrder(); | |||
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(); | void JoinCommonEdges(); | |||
End of changes. 9 change blocks. | ||||
12 lines changed or deleted | 14 lines changed or added | |||