clipper.hpp | clipper.hpp | |||
---|---|---|---|---|
/************************************************************************** ***** | /************************************************************************** ***** | |||
* * | * * | |||
* Author : Angus Johnson * | * Author : Angus Johnson * | |||
* Version : 6.1.1 | * Version : 6.1.2 | |||
* | * | |||
* Date : 13 December 2013 | * Date : 15 December 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 37 | skipping to change at line 37 | |||
* ASME 2005 International Design Engineering Technical Conferences * | * ASME 2005 International Design Engineering Technical Conferences * | |||
* and Computers and Information in Engineering Conference (IDETC/CIE2005) * | * and Computers and Information in Engineering Conference (IDETC/CIE2005) * | |||
* September 24-28, 2005 , Long Beach, California, USA * | * September 24-28, 2005 , Long Beach, California, USA * | |||
* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * | * http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf * | |||
* * | * * | |||
*************************************************************************** ****/ | *************************************************************************** ****/ | |||
#ifndef clipper_hpp | #ifndef clipper_hpp | |||
#define clipper_hpp | #define clipper_hpp | |||
#define CLIPPER_VERSION "6.1.1" | #define CLIPPER_VERSION "6.1.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 +/- 46 340 | //improve performance but coordinate values are limited to the range +/- 46 340 | |||
//#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 | |||
//When enabled, code developed with earlier versions of Clipper | //use_deprecated: Enables support for the obsolete OffsetPaths() function | |||
//(ie prior to ver 6) should compile without changes. | //which has been replace with the ClipperOffset class. | |||
//In a future update, this compatability code will be removed. | ||||
#define use_deprecated | #define use_deprecated | |||
#include <vector> | #include <vector> | |||
#include <set> | #include <set> | |||
#include <stdexcept> | #include <stdexcept> | |||
#include <cstring> | #include <cstring> | |||
#include <cstdlib> | #include <cstdlib> | |||
#include <ostream> | #include <ostream> | |||
#include <functional> | #include <functional> | |||
skipping to change at line 111 | skipping to change at line 110 | |||
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) {poly.push_back(p); return poly;} | |||
inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;} | 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 IntPoint &p); | |||
std::ostream& operator <<(std::ostream &s, const Path &p); | std::ostream& operator <<(std::ostream &s, const Path &p); | |||
std::ostream& operator <<(std::ostream &s, const Paths &p); | std::ostream& operator <<(std::ostream &s, const Paths &p); | |||
#ifdef use_deprecated | ||||
typedef signed long long long64; //backward compatibility only | ||||
typedef Path Polygon; | ||||
typedef Paths Polygons; | ||||
#endif | ||||
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 | |||
skipping to change at line 232 | skipping to change at line 225 | |||
//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 li st. | //polygon coordinates into edge objects that are stored in a LocalMinima li st. | |||
class ClipperBase | class ClipperBase | |||
{ | { | |||
public: | public: | |||
ClipperBase(); | ClipperBase(); | |||
virtual ~ClipperBase(); | virtual ~ClipperBase(); | |||
bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed); | 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); | |||
#ifdef use_deprecated | ||||
bool AddPolygon(const Path &pg, PolyType PolyTyp); | ||||
bool AddPolygons(const Paths &ppg, PolyType PolyTyp); | ||||
#endif | ||||
virtual void Clear(); | virtual void Clear(); | |||
IntRect GetBounds(); | IntRect GetBounds(); | |||
bool PreserveCollinear() {return m_PreserveCollinear;}; | bool PreserveCollinear() {return m_PreserveCollinear;}; | |||
void PreserveCollinear(bool value) {m_PreserveCollinear = value;}; | 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); | |||
void PopLocalMinima(); | void PopLocalMinima(); | |||
virtual void Reset(); | virtual void Reset(); | |||
TEdge* ProcessBound(TEdge* E, bool IsClockwise); | TEdge* ProcessBound(TEdge* E, bool IsClockwise); | |||
skipping to change at line 351 | skipping to change at line 338 | |||
void DisposeIntersectNodes(); | void DisposeIntersectNodes(); | |||
bool FixupIntersectionOrder(); | bool FixupIntersectionOrder(); | |||
void FixupOutPolygon(OutRec &outrec); | void FixupOutPolygon(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(const Join *j, OutPt *&p1, OutPt *&p2); | 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* OldOutRec, OutRec* NewOutRec); | void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec); | |||
#ifdef use_xyz | #ifdef use_xyz | |||
void SetZ(IntPoint& pt, TEdge& e); | void SetZ(IntPoint& pt, TEdge& e); | |||
#endif | #endif | |||
}; | }; | |||
//------------------------------------------------------------------------- ----- | //------------------------------------------------------------------------- ----- | |||
End of changes. 6 change blocks. | ||||
21 lines changed or deleted | 8 lines changed or added | |||