1
0
Fork 0

clipper 6.0x and supporting modifications

some debug fixes
This commit is contained in:
Peter Sadrozinski 2013-12-30 22:04:35 -05:00
parent ac334ecca4
commit 36e75560e6
17 changed files with 3178 additions and 2065 deletions

View file

@ -83,7 +83,8 @@ public:
} }
bool is_landmass_area( unsigned int p ) const { bool is_landmass_area( unsigned int p ) const {
if ( area_defs[p].GetCategory() == "landmass" ) { if (( area_defs[p].GetCategory() == "landmass" ) ||
( area_defs[p].GetCategory() == "other" )) {
return true; return true;
} else { } else {
return false; return false;

View file

@ -134,7 +134,7 @@ bool TGConstruct::ClipLandclassPolys( void ) {
tgShapefile::FromPolygon( tmp, ds_name, layer, name ); tgShapefile::FromPolygon( tmp, ds_name, layer, name );
sprintf(layer, "pre_clip_accum_%d_%d", accum_idx, polys_in.get_poly( i, j ).GetId() ); sprintf(layer, "pre_clip_accum_%d_%d", accum_idx, polys_in.get_poly( i, j ).GetId() );
accum.ToShapefiles( ds_name, layer, true ); accum.ToShapefiles( ds_name, layer, false );
} }
clipped = accum.Diff( tmp ); clipped = accum.Diff( tmp );
@ -172,7 +172,7 @@ bool TGConstruct::ClipLandclassPolys( void ) {
char layer[32]; char layer[32];
sprintf(layer, "post_clip_accum_%d_%d", accum_idx, polys_in.get_poly( i, j ).GetId() ); sprintf(layer, "post_clip_accum_%d_%d", accum_idx, polys_in.get_poly( i, j ).GetId() );
accum.ToShapefiles( ds_name, layer, true ); accum.ToShapefiles( ds_name, layer, false );
} }
accum_idx++; accum_idx++;
@ -202,9 +202,33 @@ bool TGConstruct::ClipLandclassPolys( void ) {
// finally, what ever is left over goes to ocean // finally, what ever is left over goes to ocean
remains = accum.Diff( safety_base ); remains = accum.Diff( safety_base );
if ( debug_shapes.size() )
{
char layer[32];
char name[32];
sprintf(layer, "remains_sb" );
sprintf(name, "shape");
tgShapefile::FromPolygon( remains, ds_name, layer, name );
}
remains = tgPolygon::RemoveDups( remains ); remains = tgPolygon::RemoveDups( remains );
remains = tgPolygon::RemoveCycles( remains ); remains = tgPolygon::RemoveCycles( remains );
if ( debug_shapes.size() )
{
char layer[32];
char name[32];
sprintf(layer, "remains_postclean" );
sprintf(name, "shape");
tgShapefile::FromPolygon( remains, ds_name, layer, name );
}
if ( remains.Contours() > 0 ) { if ( remains.Contours() > 0 ) {
// cout << "remains contours = " << remains.contours() << endl; // cout << "remains contours = " << remains.contours() << endl;
// move slivers from remains polygon to slivers polygon // move slivers from remains polygon to slivers polygon

View file

@ -63,7 +63,7 @@ void TGConstruct::get_debug( void )
while (ss >> i) while (ss >> i)
{ {
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug file " << i); SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug area " << i);
debug_areas.push_back(i); debug_areas.push_back(i);
@ -90,7 +90,7 @@ void TGConstruct::get_debug( void )
while (ss >> i) while (ss >> i)
{ {
SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug file " << i); SG_LOG(SG_GENERAL, SG_ALERT, "Adding debug shape " << i);
debug_shapes.push_back(i); debug_shapes.push_back(i);

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
/******************************************************************************* /*******************************************************************************
* * * *
* Author : Angus Johnson * * Author : Angus Johnson *
* Version : 5.1.4 * * Version : 6.1.2 *
* Date : 24 March 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 *
* * * *
@ -34,11 +34,29 @@
#ifndef clipper_hpp #ifndef clipper_hpp
#define clipper_hpp #define clipper_hpp
#define CLIPPER_VERSION "6.1.2"
//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
//improve performance but coordinate values are limited to the range +/- 46340
//#define use_int32
//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
//#define use_xyz
//use_lines: Enables line clipping. Adds a very minor cost to performance.
//#define use_lines
//use_deprecated: Enables support for the obsolete OffsetPaths() function
//which has been replace with the ClipperOffset class.
#define use_deprecated
#include <vector> #include <vector>
#include <set>
#include <stdexcept> #include <stdexcept>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <ostream> #include <ostream>
#include <functional>
namespace ClipperLib { namespace ClipperLib {
@ -50,23 +68,64 @@ enum PolyType { ptSubject, ptClip };
//see http://glprogramming.com/red/chapter11.html //see http://glprogramming.com/red/chapter11.html
enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
typedef signed long long long64; #ifdef use_int32
typedef unsigned long long ulong64; typedef int cInt;
typedef unsigned int cUInt;
#else
typedef signed long long cInt;
typedef unsigned long long cUInt;
#endif
struct IntPoint { struct IntPoint {
public: cInt X;
long64 X; cInt Y;
long64 Y; #ifdef use_xyz
IntPoint(long64 x = 0, long64 y = 0): X(x), Y(y) {}; cInt Z;
friend std::ostream& operator <<(std::ostream &s, IntPoint &p); IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {};
#else
IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {};
#endif
friend inline bool operator== (const IntPoint& a, const IntPoint& b)
{
return a.X == b.X && a.Y == b.Y;
}
friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
{
return a.X != b.X || a.Y != b.Y;
}
}; };
//------------------------------------------------------------------------------
typedef std::vector< IntPoint > Polygon; typedef std::vector< IntPoint > Path;
typedef std::vector< Polygon > Polygons; typedef std::vector< Path > Paths;
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;}
std::ostream& operator <<(std::ostream &s, Polygon &p); std::ostream& operator <<(std::ostream &s, const IntPoint &p);
std::ostream& operator <<(std::ostream &s, Polygons &p); std::ostream& operator <<(std::ostream &s, const Path &p);
std::ostream& operator <<(std::ostream &s, const Paths &p);
struct DoublePoint
{
double X;
double Y;
DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {}
DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {}
};
//------------------------------------------------------------------------------
#ifdef use_xyz
typedef void (*TZFillCallback)(IntPoint& z1, IntPoint& z2, IntPoint& pt);
#endif
enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
enum JoinType {jtSquare, jtRound, jtMiter};
enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
#ifdef use_deprecated
enum EndType_ {etClosed, etButt = 2, etSquare, etRound};
#endif
class PolyNode; class PolyNode;
typedef std::vector< PolyNode* > PolyNodes; typedef std::vector< PolyNode* > PolyNodes;
@ -75,17 +134,22 @@ class PolyNode
{ {
public: public:
PolyNode(); PolyNode();
Polygon 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;
int ChildCount() const; int ChildCount() const;
private: private:
PolyNode* GetNextSiblingUp() const;
unsigned Index; //node index in Parent.Childs unsigned Index; //node index in Parent.Childs
bool m_IsOpen;
JoinType m_jointype;
EndType m_endtype;
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;
}; };
class PolyTree: public PolyNode class PolyTree: public PolyNode
@ -100,112 +164,54 @@ private:
friend class Clipper; //to access AllNodes friend class Clipper; //to access AllNodes
}; };
enum JoinType { jtSquare, jtRound, jtMiter }; bool Orientation(const Path &poly);
double Area(const Path &poly);
bool Orientation(const Polygon &poly); #ifdef use_deprecated
double Area(const Polygon &poly); void OffsetPaths(const Paths &in_polys, Paths &out_polys,
double delta, JoinType jointype, EndType_ endtype, double limit = 0);
#endif
void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys, void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
double delta, JoinType jointype = jtSquare, double limit = 0, bool autoFix = true); void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillType fillType = pftEvenOdd); void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFillType fillType = pftEvenOdd); void CleanPolygon(Path& poly, double distance = 1.415);
void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd); void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
void CleanPolygons(Paths& polys, double distance = 1.415);
void CleanPolygon(Polygon& in_poly, Polygon& out_poly, double distance = 1.415); void MinkowskiSum(const Path& poly, const Path& path, Paths& solution, bool isClosed);
void CleanPolygons(Polygons& in_polys, Polygons& out_polys, double distance = 1.415); void MinkowskiDiff(const Path& poly, const Path& path, Paths& solution, bool isClosed);
void PolyTreeToPolygons(PolyTree& polytree, Polygons& polygons); void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths);
void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
void ReversePolygon(Polygon& p); void ReversePath(Path& p);
void ReversePolygons(Polygons& p); void ReversePaths(Paths& p);
//used internally ... struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
//enums that are used internally ...
enum EdgeSide { esLeft = 1, esRight = 2}; enum EdgeSide { esLeft = 1, esRight = 2};
enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 };
struct TEdge { //forward declarations (for stuff used internally) ...
long64 xbot; struct TEdge;
long64 ybot; struct IntersectNode;
long64 xcurr; struct LocalMinima;
long64 ycurr; struct Scanbeam;
long64 xtop; struct OutPt;
long64 ytop; struct OutRec;
double dx; struct Join;
long64 deltaX;
long64 deltaY;
PolyType polyType;
EdgeSide side;
int windDelta; //1 or -1 depending on winding direction
int windCnt;
int windCnt2; //winding count of the opposite polytype
int outIdx;
TEdge *next;
TEdge *prev;
TEdge *nextInLML;
TEdge *nextInAEL;
TEdge *prevInAEL;
TEdge *nextInSEL;
TEdge *prevInSEL;
};
struct IntersectNode {
TEdge *edge1;
TEdge *edge2;
IntPoint pt;
IntersectNode *next;
};
struct LocalMinima {
long64 Y;
TEdge *leftBound;
TEdge *rightBound;
LocalMinima *next;
};
struct Scanbeam {
long64 Y;
Scanbeam *next;
};
struct OutPt; //forward declaration
struct OutRec {
int idx;
bool isHole;
OutRec *FirstLeft; //see comments in clipper.pas
PolyNode *polyNode;
OutPt *pts;
OutPt *bottomPt;
};
struct OutPt {
int idx;
IntPoint pt;
OutPt *next;
OutPt *prev;
};
struct JoinRec {
IntPoint pt1a;
IntPoint pt1b;
int poly1Idx;
IntPoint pt2a;
IntPoint pt2b;
int poly2Idx;
};
struct HorzJoinRec {
TEdge *edge;
int savedIdx;
};
struct IntRect { long64 left; long64 top; long64 right; long64 bottom; };
typedef std::vector < OutRec* > PolyOutList; typedef std::vector < OutRec* > PolyOutList;
typedef std::vector < TEdge* > EdgeList; typedef std::vector < TEdge* > EdgeList;
typedef std::vector < JoinRec* > JoinList; typedef std::vector < Join* > JoinList;
typedef std::vector < HorzJoinRec* > HorzJoinList; 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
@ -215,29 +221,38 @@ class ClipperBase
public: public:
ClipperBase(); ClipperBase();
virtual ~ClipperBase(); virtual ~ClipperBase();
bool AddPolygon(const Polygon &pg, PolyType polyType); bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
bool AddPolygons( const Polygons &ppg, PolyType polyType); 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;};
protected: protected:
void DisposeLocalMinimaList(); void DisposeLocalMinimaList();
TEdge* AddBoundsToLML(TEdge *e); TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
void PopLocalMinima(); void PopLocalMinima();
virtual void Reset(); virtual void Reset();
TEdge* ProcessBound(TEdge* E, bool IsClockwise);
void InsertLocalMinima(LocalMinima *newLm); void InsertLocalMinima(LocalMinima *newLm);
void DoMinimaLML(TEdge* E1, TEdge* E2, bool IsClosed);
TEdge* DescendToMin(TEdge *&E);
void AscendToMax(TEdge *&E, bool Appending, bool IsClosed);
LocalMinima *m_CurrentLM; LocalMinima *m_CurrentLM;
LocalMinima *m_MinimaList; LocalMinima *m_MinimaList;
bool m_UseFullRange; bool m_UseFullRange;
EdgeList m_edges; EdgeList m_edges;
bool m_PreserveCollinear;
bool m_HasOpenPaths;
}; };
//------------------------------------------------------------------------------
class Clipper : public virtual ClipperBase class Clipper : public virtual ClipperBase
{ {
public: public:
Clipper(); Clipper(int initOptions = 0);
~Clipper(); ~Clipper();
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
Polygons &solution, Paths &solution,
PolyFillType subjFillType = pftEvenOdd, PolyFillType subjFillType = pftEvenOdd,
PolyFillType clipFillType = pftEvenOdd); PolyFillType clipFillType = pftEvenOdd);
bool Execute(ClipType clipType, bool Execute(ClipType clipType,
@ -247,31 +262,40 @@ public:
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;};
bool StrictlySimple() {return m_StrictSimple;};
void StrictlySimple(bool value) {m_StrictSimple = value;};
//set the callback function for z value filling on intersections (otherwise Z is 0)
#ifdef use_xyz
void ZFillFunction(TZFillCallback zFillFunc);
#endif
protected: protected:
void Reset(); void Reset();
virtual bool ExecuteInternal(); virtual bool ExecuteInternal();
private: private:
PolyOutList m_PolyOuts; PolyOutList m_PolyOuts;
JoinList m_Joins; JoinList m_Joins;
HorzJoinList m_HorizJoins; JoinList m_GhostJoins;
IntersectList m_IntersectList;
ClipType m_ClipType; ClipType m_ClipType;
Scanbeam *m_Scanbeam; std::set< cInt, std::greater<cInt> > m_Scanbeam;
TEdge *m_ActiveEdges; TEdge *m_ActiveEdges;
TEdge *m_SortedEdges; TEdge *m_SortedEdges;
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_UsingPolyTree; bool m_UsingPolyTree;
void DisposeScanbeamList(); bool m_StrictSimple;
#ifdef use_xyz
TZFillCallback m_ZFill; //custom callback
#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 InsertScanbeam(const long64 Y); void InsertScanbeam(const cInt Y);
long64 PopScanbeam(); cInt PopScanbeam();
void InsertLocalMinimaIntoAEL(const long64 botY); void InsertLocalMinimaIntoAEL(const cInt botY);
void InsertEdgeIntoAEL(TEdge *edge); void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
void AddEdgeToSEL(TEdge *edge); void AddEdgeToSEL(TEdge *edge);
void CopyAELToSEL(); void CopyAELToSEL();
void DeleteFromSEL(TEdge *e); void DeleteFromSEL(TEdge *e);
@ -279,48 +303,79 @@ private:
void UpdateEdgeIntoAEL(TEdge *&e); void UpdateEdgeIntoAEL(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 long64 XPos); bool IsTopHorz(const cInt XPos);
void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2); void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
void DoMaxima(TEdge *e, long64 topY); void DoMaxima(TEdge *e);
void ProcessHorizontals(); void PrepareHorzJoins(TEdge* horzEdge, bool isTopOfScanbeam);
void ProcessHorizontal(TEdge *horzEdge); void ProcessHorizontals(bool IsTopOfScanbeam);
void ProcessHorizontal(TEdge *horzEdge, bool isTopOfScanbeam);
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); OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
OutRec* GetOutRec(int idx);
void AppendPolygon(TEdge *e1, TEdge *e2); void AppendPolygon(TEdge *e1, TEdge *e2);
void DoEdge1(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 IntersectEdges(TEdge *e1, TEdge *e2, void IntersectEdges(TEdge *e1, TEdge *e2,
const IntPoint &pt, const IntersectProtects protects); const IntPoint &pt, bool protect = false);
OutRec* CreateOutRec(); OutRec* CreateOutRec();
void AddOutPt(TEdge *e, const IntPoint &pt); OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
void DisposeAllPolyPts(); void DisposeAllOutRecs();
void DisposeOutRec(PolyOutList::size_type index); void DisposeOutRec(PolyOutList::size_type index);
bool ProcessIntersections(const long64 botY, const long64 topY); bool ProcessIntersections(const cInt botY, const cInt topY);
void AddIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt); void BuildIntersectList(const cInt botY, const cInt topY);
void BuildIntersectList(const long64 botY, const long64 topY);
void ProcessIntersectList(); void ProcessIntersectList();
void ProcessEdgesAtTopOfScanbeam(const long64 topY); void ProcessEdgesAtTopOfScanbeam(const cInt topY);
void BuildResult(Polygons& 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);
bool IsHole(TEdge *e); bool IsHole(TEdge *e);
void FixHoleLinkage(OutRec &outRec); bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1); void FixHoleLinkage(OutRec &outrec);
void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
void ClearJoins(); void ClearJoins();
void AddHorzJoin(TEdge *e, int idx); void ClearGhostJoins();
void ClearHorzJoins(); void AddGhostJoin(OutPt *op, const IntPoint offPt);
bool JoinPoints(const JoinRec *j, OutPt *&p1, OutPt *&p2); bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2);
void FixupJoinRecs(JoinRec *j, OutPt *pt, unsigned startIdx);
void JoinCommonEdges(); void JoinCommonEdges();
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
void SetZ(IntPoint& pt, TEdge& e);
#endif
}; };
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
class ClipperOffset
{
public:
ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25);
~ClipperOffset();
void AddPath(const Path& path, JoinType joinType, EndType endType);
void AddPaths(const Paths& paths, JoinType joinType, EndType endType);
void Execute(Paths& solution, double delta);
void Execute(PolyTree& solution, double delta);
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();
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

View file

@ -21,13 +21,13 @@ tgPolygon tgAccumulator::Diff( const tgContour& subject )
unsigned int num_hits = 0; unsigned int num_hits = 0;
tgRectangle box1 = subject.GetBoundingBox(); tgRectangle box1 = subject.GetBoundingBox();
ClipperLib::Polygon clipper_subject = tgContour::ToClipper( subject ); ClipperLib::Path clipper_subject = tgContour::ToClipper( subject );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygon(clipper_subject, ClipperLib::ptSubject); c.AddPath(clipper_subject, ClipperLib::ptSubject, true);
// clip result against all polygons in the accum that intersect our bb // clip result against all polygons in the accum that intersect our bb
for (unsigned int i=0; i < accum.size(); i++) { for (unsigned int i=0; i < accum.size(); i++) {
@ -35,7 +35,7 @@ tgPolygon tgAccumulator::Diff( const tgContour& subject )
if ( box2.intersects(box1) ) if ( box2.intersects(box1) )
{ {
c.AddPolygons(accum[i], ClipperLib::ptClip); c.AddPaths(accum[i], ClipperLib::ptClip, true);
num_hits++; num_hits++;
} }
} }
@ -73,13 +73,13 @@ tgPolygon tgAccumulator::Diff( const tgPolygon& subject )
unsigned int num_hits = 0; unsigned int num_hits = 0;
tgRectangle box1 = subject.GetBoundingBox(); tgRectangle box1 = subject.GetBoundingBox();
ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Paths clipper_subject = tgPolygon::ToClipper( subject );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygons(clipper_subject, ClipperLib::ptSubject); c.AddPaths(clipper_subject, ClipperLib::ptSubject, true);
// clip result against all polygons in the accum that intersect our bb // clip result against all polygons in the accum that intersect our bb
for (unsigned int i=0; i < accum.size(); i++) { for (unsigned int i=0; i < accum.size(); i++) {
@ -87,7 +87,7 @@ tgPolygon tgAccumulator::Diff( const tgPolygon& subject )
if ( box2.intersects(box1) ) if ( box2.intersects(box1) )
{ {
c.AddPolygons(accum[i], ClipperLib::ptClip); c.AddPaths(accum[i], ClipperLib::ptClip, true);
num_hits++; num_hits++;
} }
} }
@ -122,7 +122,7 @@ void tgAccumulator::Add( const tgContour& subject )
poly.AddContour( subject ); poly.AddContour( subject );
ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( poly ); ClipperLib::Paths clipper_subject = tgPolygon::ToClipper( poly );
accum.push_back( clipper_subject ); accum.push_back( clipper_subject );
} }
@ -134,7 +134,7 @@ void tgAccumulator::Add( const tgPolygon& subject )
} }
} }
ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Paths clipper_subject = tgPolygon::ToClipper( subject );
accum.push_back( clipper_subject ); accum.push_back( clipper_subject );
} }
@ -150,12 +150,12 @@ void tgAccumulator::ToShapefiles( const std::string& path, const std::string& la
tgShapefile::FromClipper( accum[i], path, layer, std::string(shapefile) ); tgShapefile::FromClipper( accum[i], path, layer, std::string(shapefile) );
} }
} else { } else {
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
for ( unsigned int i=0; i<accum.size(); i++ ) { for ( unsigned int i=0; i<accum.size(); i++ ) {
c.AddPolygons(accum[i], ClipperLib::ptSubject); c.AddPaths(accum[i], ClipperLib::ptSubject, true);
} }
c.Execute( ClipperLib::ctUnion, clipper_result, ClipperLib::pftNonZero, ClipperLib::pftNonZero); c.Execute( ClipperLib::ctUnion, clipper_result, ClipperLib::pftNonZero, ClipperLib::pftNonZero);

View file

@ -17,7 +17,7 @@ public:
void ToShapefiles( const std::string& path, const std::string& layer, bool individual ); void ToShapefiles( const std::string& path, const std::string& layer, bool individual );
private: private:
typedef std::vector < ClipperLib::Polygons > clipper_polygons_list; typedef std::vector < ClipperLib::Paths > clipper_polygons_list;
clipper_polygons_list accum; clipper_polygons_list accum;
UniqueSGGeodSet nodes; UniqueSGGeodSet nodes;

View file

@ -373,9 +373,9 @@ tgContour tgContour::RemoveSpikes( const tgContour& subject )
return result; return result;
} }
ClipperLib::Polygon tgContour::ToClipper( const tgContour& subject ) ClipperLib::Path tgContour::ToClipper( const tgContour& subject )
{ {
ClipperLib::Polygon contour; ClipperLib::Path contour;
for ( unsigned int i=0; i<subject.GetSize(); i++) for ( unsigned int i=0; i<subject.GetSize(); i++)
{ {
@ -388,20 +388,20 @@ ClipperLib::Polygon tgContour::ToClipper( const tgContour& subject )
// holes need to be orientation: false // holes need to be orientation: false
if ( Orientation( contour ) ) { if ( Orientation( contour ) ) {
//SG_LOG(SG_GENERAL, SG_INFO, "Building clipper contour - hole contour needs to be reversed" ); //SG_LOG(SG_GENERAL, SG_INFO, "Building clipper contour - hole contour needs to be reversed" );
ReversePolygon( contour ); ReversePath( contour );
} }
} else { } else {
// boundaries need to be orientation: true // boundaries need to be orientation: true
if ( !Orientation( contour ) ) { if ( !Orientation( contour ) ) {
//SG_LOG(SG_GENERAL, SG_INFO, "Building clipper contour - boundary contour needs to be reversed" ); //SG_LOG(SG_GENERAL, SG_INFO, "Building clipper contour - boundary contour needs to be reversed" );
ReversePolygon( contour ); ReversePath( contour );
} }
} }
return contour; return contour;
} }
tgContour tgContour::FromClipper( const ClipperLib::Polygon& subject ) tgContour tgContour::FromClipper( const ClipperLib::Path& subject )
{ {
tgContour result; tgContour result;
@ -462,14 +462,14 @@ tgPolygon tgContour::Union( const tgContour& subject, tgPolygon& clip )
} }
} }
ClipperLib::Polygon clipper_subject = tgContour::ToClipper( subject ); ClipperLib::Path clipper_subject = tgContour::ToClipper( subject );
ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Paths clipper_clip = tgPolygon::ToClipper( clip );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygon(clipper_subject, ClipperLib::ptSubject); c.AddPath(clipper_subject, ClipperLib::ptSubject, true);
c.AddPolygons(clipper_clip, ClipperLib::ptClip); c.AddPaths(clipper_clip, ClipperLib::ptClip, true);
c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
result = tgPolygon::FromClipper( clipper_result ); result = tgPolygon::FromClipper( clipper_result );
@ -494,14 +494,14 @@ tgPolygon tgContour::Diff( const tgContour& subject, tgPolygon& clip )
} }
} }
ClipperLib::Polygon clipper_subject = tgContour::ToClipper( subject ); ClipperLib::Path clipper_subject = tgContour::ToClipper( subject );
ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Paths clipper_clip = tgPolygon::ToClipper( clip );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygon(clipper_subject, ClipperLib::ptSubject); c.AddPath(clipper_subject, ClipperLib::ptSubject, true);
c.AddPolygons(clipper_clip, ClipperLib::ptClip); c.AddPaths(clipper_clip, ClipperLib::ptClip, true);
c.Execute(ClipperLib::ctDifference, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); c.Execute(ClipperLib::ctDifference, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
result = tgPolygon::FromClipper( clipper_result ); result = tgPolygon::FromClipper( clipper_result );
@ -524,14 +524,14 @@ tgPolygon tgContour::Intersect( const tgContour& subject, const tgContour& clip
all_nodes.add( clip.GetNode(i) ); all_nodes.add( clip.GetNode(i) );
} }
ClipperLib::Polygon clipper_subject = tgContour::ToClipper( subject ); ClipperLib::Path clipper_subject = tgContour::ToClipper( subject );
ClipperLib::Polygon clipper_clip = tgContour::ToClipper( clip ); ClipperLib::Path clipper_clip = tgContour::ToClipper( clip );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygon(clipper_subject, ClipperLib::ptSubject); c.AddPath(clipper_subject, ClipperLib::ptSubject, true);
c.AddPolygon(clipper_clip, ClipperLib::ptClip); c.AddPath(clipper_clip, ClipperLib::ptClip, true);
c.Execute(ClipperLib::ctIntersection, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); c.Execute(ClipperLib::ctIntersection, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
result = tgPolygon::FromClipper( clipper_result ); result = tgPolygon::FromClipper( clipper_result );
@ -745,12 +745,13 @@ tgContour tgContour::Expand( const tgContour& subject, double offset )
tgContour result; tgContour result;
poly.AddContour( subject ); poly.AddContour( subject );
ClipperLib::Polygons clipper_src, clipper_dst; ClipperLib::Paths clipper_src, clipper_dst;
clipper_src = tgPolygon::ToClipper( poly ); clipper_src = tgPolygon::ToClipper( poly );
// convert delta from meters to clipper units ClipperLib::ClipperOffset co(2.0, 2.0);
OffsetPolygons( clipper_src, clipper_dst, Dist_ToClipper(offset) ); co.AddPaths(clipper_src, ClipperLib::jtSquare, ClipperLib::etClosedPolygon);
co.Execute(clipper_dst, Dist_ToClipper(offset) );
poly = tgPolygon::FromClipper( clipper_dst ); poly = tgPolygon::FromClipper( clipper_dst );

View file

@ -112,8 +112,8 @@ public:
static bool FindColinearLine( const tgContour& subject, const SGGeod& node, SGGeod& start, SGGeod& end ); static bool FindColinearLine( const tgContour& subject, const SGGeod& node, SGGeod& start, SGGeod& end );
// conversions // conversions
static ClipperLib::Polygon ToClipper( const tgContour& subject ); static ClipperLib::Path ToClipper( const tgContour& subject );
static tgContour FromClipper( const ClipperLib::Polygon& subject ); static tgContour FromClipper( const ClipperLib::Path& subject );
static tgContour Expand( const tgContour& subject, double offset ); static tgContour Expand( const tgContour& subject, double offset );
static tgpolygon_list ExpandToPolygons( const tgContour& subject, double width ); static tgpolygon_list ExpandToPolygons( const tgContour& subject, double width );

View file

@ -70,10 +70,10 @@ double CalculateTheta( const SGVec3d& dirCur, const SGVec3d& dirNext )
ClipperLib::IntPoint SGGeod_ToClipper( const SGGeod& p ) ClipperLib::IntPoint SGGeod_ToClipper( const SGGeod& p )
{ {
ClipperLib::long64 x, y; ClipperLib::cUInt x, y;
x = (ClipperLib::long64)( p.getLongitudeDeg() * CLIPPER_FIXEDPT ); x = (ClipperLib::cUInt)( p.getLongitudeDeg() * CLIPPER_FIXEDPT );
y = (ClipperLib::long64)( p.getLatitudeDeg() * CLIPPER_FIXEDPT ); y = (ClipperLib::cUInt)( p.getLatitudeDeg() * CLIPPER_FIXEDPT );
return ClipperLib::IntPoint( x, y ); return ClipperLib::IntPoint( x, y );
} }
@ -98,7 +98,7 @@ double Dist_ToClipper( double dist )
# define LONG_LONG_MIN LLONG_MIN # define LONG_LONG_MIN LLONG_MIN
#endif #endif
tgRectangle BoundingBox_FromClipper( const ClipperLib::Polygons& subject ) tgRectangle BoundingBox_FromClipper( const ClipperLib::Paths& subject )
{ {
ClipperLib::IntPoint min_pt, max_pt; ClipperLib::IntPoint min_pt, max_pt;
SGGeod min, max; SGGeod min, max;

View file

@ -27,7 +27,7 @@ double CalculateTheta( const SGVec3d& dirCur, const SGVec3d& dirNext );
double Dist_ToClipper( double dist ); double Dist_ToClipper( double dist );
// should be in rectangle // should be in rectangle
tgRectangle BoundingBox_FromClipper( const ClipperLib::Polygons& subject ); tgRectangle BoundingBox_FromClipper( const ClipperLib::Paths& subject );
bool intersection(const SGGeod &p0, const SGGeod &p1, const SGGeod& p2, const SGGeod& p3, SGGeod& intersection); bool intersection(const SGGeod &p0, const SGGeod &p1, const SGGeod& p2, const SGGeod& p3, SGGeod& intersection);

View file

@ -46,12 +46,13 @@ unsigned int tgPolygon::TotalNodes( void ) const
tgPolygon tgPolygon::Expand( const tgPolygon& subject, double offset ) tgPolygon tgPolygon::Expand( const tgPolygon& subject, double offset )
{ {
ClipperLib::Polygons clipper_src, clipper_dst; ClipperLib::Paths clipper_src, clipper_dst;
clipper_src = tgPolygon::ToClipper( subject ); clipper_src = tgPolygon::ToClipper( subject );
tgPolygon result; tgPolygon result;
// convert delta from meters to clipper units ClipperLib::ClipperOffset co(2.0, 2.0);
OffsetPolygons( clipper_src, clipper_dst, Dist_ToClipper(offset) ); co.AddPaths(clipper_src, ClipperLib::jtSquare, ClipperLib::etClosedPolygon);
co.Execute(clipper_dst, Dist_ToClipper(offset) );
result = tgPolygon::FromClipper( clipper_dst ); result = tgPolygon::FromClipper( clipper_dst );

View file

@ -79,7 +79,7 @@ void OffsetPointsLast( const SGGeod& prev, const SGGeod& cur, double offset_by,
// what abount this? // what abount this?
// Save clipper to shapefile // Save clipper to shapefile
void clipper_to_shapefile( ClipperLib::Polygons polys, char* datasource ); void clipper_to_shapefile( ClipperLib::Paths polys, char* datasource );
// forward declaration // forward declaration
@ -401,8 +401,8 @@ public:
static tgPolygon Expand( const SGGeod& subject, double offset ); static tgPolygon Expand( const SGGeod& subject, double offset );
// Conversions // Conversions
static ClipperLib::Polygons ToClipper( const tgPolygon& subject ); static ClipperLib::Paths ToClipper( const tgPolygon& subject );
static tgPolygon FromClipper( const ClipperLib::Polygons& subject ); static tgPolygon FromClipper( const ClipperLib::Paths& subject );
static void ToShapefile( const tgPolygon& subject, const std::string& datasource, const std::string& layer, const std::string& feature ); static void ToShapefile( const tgPolygon& subject, const std::string& datasource, const std::string& layer, const std::string& feature );

View file

@ -105,14 +105,14 @@ tgPolygon tgPolygon::StripHoles( const tgPolygon& subject )
} }
} }
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
for ( unsigned int i = 0; i < subject.Contours(); i++ ) { for ( unsigned int i = 0; i < subject.Contours(); i++ ) {
tgContour contour = subject.GetContour( i ); tgContour contour = subject.GetContour( i );
if ( !contour.GetHole() ) { if ( !contour.GetHole() ) {
c.AddPolygon( tgContour::ToClipper( contour ), ClipperLib::ptClip ); c.AddPath( tgContour::ToClipper( contour ), ClipperLib::ptClip, true );
} }
} }
c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
@ -139,7 +139,7 @@ tgPolygon tgPolygon::Simplify( const tgPolygon& subject )
} }
} }
ClipperLib::Polygons clipper_poly = tgPolygon::ToClipper( subject ); ClipperLib::Paths clipper_poly = tgPolygon::ToClipper( subject );
SimplifyPolygons( clipper_poly ); SimplifyPolygons( clipper_poly );
result = tgPolygon::FromClipper( clipper_poly ); result = tgPolygon::FromClipper( clipper_poly );

View file

@ -30,9 +30,9 @@ tgPolygon tgPolygon::Union( const tgPolygon& subject, tgPolygon& clip )
} }
} }
ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Paths clipper_subject = tgPolygon::ToClipper( subject );
ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Paths clipper_clip = tgPolygon::ToClipper( clip );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
if ( clipper_dump ) { if ( clipper_dump ) {
dmpfile.open ("subject.txt"); dmpfile.open ("subject.txt");
@ -46,8 +46,8 @@ tgPolygon tgPolygon::Union( const tgPolygon& subject, tgPolygon& clip )
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygons(clipper_subject, ClipperLib::ptSubject); c.AddPaths(clipper_subject, ClipperLib::ptSubject, true);
c.AddPolygons(clipper_clip, ClipperLib::ptClip); c.AddPaths(clipper_clip, ClipperLib::ptClip, true);
c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
if ( clipper_dump ) { if ( clipper_dump ) {
@ -67,7 +67,7 @@ tgPolygon tgPolygon::Union( const tgPolygon& subject, tgPolygon& clip )
tgPolygon tgPolygon::Union( const tgpolygon_list& polys ) tgPolygon tgPolygon::Union( const tgpolygon_list& polys )
{ {
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
UniqueSGGeodSet all_nodes; UniqueSGGeodSet all_nodes;
tgPolygon result; tgPolygon result;
@ -83,8 +83,8 @@ tgPolygon tgPolygon::Union( const tgpolygon_list& polys )
c.Clear(); c.Clear();
for (unsigned int i=0; i<polys.size(); i++) { for (unsigned int i=0; i<polys.size(); i++) {
ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( polys[i] ); ClipperLib::Paths clipper_clip = tgPolygon::ToClipper( polys[i] );
c.AddPolygons(clipper_clip, ClipperLib::ptSubject); c.AddPaths(clipper_clip, ClipperLib::ptSubject, true);
} }
c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftNonZero, ClipperLib::pftNonZero); c.Execute(ClipperLib::ctUnion, clipper_result, ClipperLib::pftNonZero, ClipperLib::pftNonZero);
@ -112,14 +112,14 @@ tgPolygon tgPolygon::Diff( const tgPolygon& subject, tgPolygon& clip )
} }
} }
ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Paths clipper_subject = tgPolygon::ToClipper( subject );
ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Paths clipper_clip = tgPolygon::ToClipper( clip );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygons(clipper_subject, ClipperLib::ptSubject); c.AddPaths(clipper_subject, ClipperLib::ptSubject, true);
c.AddPolygons(clipper_clip, ClipperLib::ptClip); c.AddPaths(clipper_clip, ClipperLib::ptClip, true);
c.Execute(ClipperLib::ctDifference, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); c.Execute(ClipperLib::ctDifference, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
result = tgPolygon::FromClipper( clipper_result ); result = tgPolygon::FromClipper( clipper_result );
@ -149,14 +149,14 @@ tgPolygon tgPolygon::Intersect( const tgPolygon& subject, const tgPolygon& clip
} }
} }
ClipperLib::Polygons clipper_subject = tgPolygon::ToClipper( subject ); ClipperLib::Paths clipper_subject = tgPolygon::ToClipper( subject );
ClipperLib::Polygons clipper_clip = tgPolygon::ToClipper( clip ); ClipperLib::Paths clipper_clip = tgPolygon::ToClipper( clip );
ClipperLib::Polygons clipper_result; ClipperLib::Paths clipper_result;
ClipperLib::Clipper c; ClipperLib::Clipper c;
c.Clear(); c.Clear();
c.AddPolygons(clipper_subject, ClipperLib::ptSubject); c.AddPaths(clipper_subject, ClipperLib::ptSubject, true);
c.AddPolygons(clipper_clip, ClipperLib::ptClip); c.AddPaths(clipper_clip, ClipperLib::ptClip, true);
c.Execute(ClipperLib::ctIntersection, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); c.Execute(ClipperLib::ctIntersection, clipper_result, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
result = tgPolygon::FromClipper( clipper_result ); result = tgPolygon::FromClipper( clipper_result );
@ -168,9 +168,9 @@ tgPolygon tgPolygon::Intersect( const tgPolygon& subject, const tgPolygon& clip
return result; return result;
} }
ClipperLib::Polygons tgPolygon::ToClipper( const tgPolygon& subject ) ClipperLib::Paths tgPolygon::ToClipper( const tgPolygon& subject )
{ {
ClipperLib::Polygons result; ClipperLib::Paths result;
for ( unsigned int i=0; i<subject.Contours(); i++ ) { for ( unsigned int i=0; i<subject.Contours(); i++ ) {
result.push_back( tgContour::ToClipper( subject.GetContour(i) ) ); result.push_back( tgContour::ToClipper( subject.GetContour(i) ) );
@ -179,7 +179,7 @@ ClipperLib::Polygons tgPolygon::ToClipper( const tgPolygon& subject )
return result; return result;
} }
tgPolygon tgPolygon::FromClipper( const ClipperLib::Polygons& subject ) tgPolygon tgPolygon::FromClipper( const ClipperLib::Paths& subject )
{ {
tgPolygon result; tgPolygon result;

View file

@ -73,7 +73,7 @@ void* tgShapefile::CloseDatasource( void* ds_id )
return (void *)-1; return (void *)-1;
} }
void tgShapefile::FromClipper( const ClipperLib::Polygons& subject, const std::string& datasource, const std::string& layer, const std::string& description ) void tgShapefile::FromClipper( const ClipperLib::Paths& subject, const std::string& datasource, const std::string& layer, const std::string& description )
{ {
void* ds_id = tgShapefile::OpenDatasource( datasource.c_str() ); void* ds_id = tgShapefile::OpenDatasource( datasource.c_str() );
SG_LOG(SG_GENERAL, SG_DEBUG, "tgShapefile::OpenDatasource returned " << (unsigned long)ds_id); SG_LOG(SG_GENERAL, SG_DEBUG, "tgShapefile::OpenDatasource returned " << (unsigned long)ds_id);
@ -85,7 +85,7 @@ void tgShapefile::FromClipper( const ClipperLib::Polygons& subject, const std::s
SG_LOG(SG_GENERAL, SG_DEBUG, "subject has " << subject.size() << " contours "); SG_LOG(SG_GENERAL, SG_DEBUG, "subject has " << subject.size() << " contours ");
for ( unsigned int i = 0; i < subject.size(); i++ ) { for ( unsigned int i = 0; i < subject.size(); i++ ) {
ClipperLib::Polygon const& contour = subject[i]; ClipperLib::Path const& contour = subject[i];
if (contour.size() < 3) { if (contour.size() < 3) {
SG_LOG(SG_GENERAL, SG_DEBUG, "Polygon with less than 3 points"); SG_LOG(SG_GENERAL, SG_DEBUG, "Polygon with less than 3 points");

View file

@ -10,7 +10,7 @@ public:
static void FromPolygon( const tgPolygon& subject, const std::string& datasource, const std::string& layer, const std::string& description ); static void FromPolygon( const tgPolygon& subject, const std::string& datasource, const std::string& layer, const std::string& description );
static tgPolygon ToPolygon( const void* subject ); static tgPolygon ToPolygon( const void* subject );
static void FromClipper( const ClipperLib::Polygons& subject, const std::string& datasource, const std::string& layer, const std::string& description ); static void FromClipper( const ClipperLib::Paths& subject, const std::string& datasource, const std::string& layer, const std::string& description );
private: private:
static bool initialized; static bool initialized;