diff --git a/deps/clipper/include/clipper.hpp b/deps/clipper/include/clipper.hpp index c1cb4a15f..3b0398814 100755 --- a/deps/clipper/include/clipper.hpp +++ b/deps/clipper/include/clipper.hpp @@ -35,6 +35,7 @@ #define clipper_hpp #include +#include #define CLIPPER_VERSION "6.2.6" @@ -46,7 +47,7 @@ //#define use_xyz //use_lines: Enables line clipping. Adds a very minor cost to performance. -//#define use_lines +#define use_lines //use_deprecated: Enables temporary support for the obsolete functions //#define use_deprecated @@ -76,37 +77,41 @@ enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; static cInt const loRange = 0x7FFF; static cInt const hiRange = 0x7FFF; #else - typedef signed long long cInt; + typedef std::int64_t cInt; static cInt const loRange = 0x3FFFFFFF; static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL; - typedef signed long long long64; //used by Int128 class - typedef unsigned long long ulong64; + typedef std::int64_t long64; //used by Int128 class + typedef std::uint64_t ulong64; #endif - +/* struct IntPoint { - cInt X; - cInt Y; + cInt x; + cInt y; #ifdef use_xyz - cInt Z; + cInt z; 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) {}; + 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; + 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; + return a.x != b.x || a.y != b.y; } -}; +};*/ + +typedef mapnik::geometry::point IntPoint; + //------------------------------------------------------------------------------ -typedef std::vector< IntPoint > Path; -typedef std::vector< Path > Paths; +//typedef std::vector< IntPoint > Path; +typedef mapnik::geometry::line_string Path; +typedef mapnik::geometry::multi_line_string 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;} @@ -117,10 +122,10 @@ 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) {} + 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) {} }; //------------------------------------------------------------------------------ @@ -189,7 +194,7 @@ void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution); void PolyTreeToPaths(const PolyTree& polytree, Paths& paths); void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths); -void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths); +MAPNIK_DECL void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths); void ReversePath(Path& p); void ReversePaths(Paths& p); diff --git a/deps/clipper/src/clipper.cpp b/deps/clipper/src/clipper.cpp index bc53d9159..b9727c6bf 100755 --- a/deps/clipper/src/clipper.cpp +++ b/deps/clipper/src/clipper.cpp @@ -91,7 +91,7 @@ struct IntersectNode { }; struct LocalMinimum { - cInt Y; + cInt y; TEdge *LeftBound; TEdge *RightBound; }; @@ -125,7 +125,7 @@ struct LocMinSorter { inline bool operator()(const LocalMinimum& locMin1, const LocalMinimum& locMin2) { - return locMin2.Y < locMin1.Y; + return locMin2.y < locMin1.y; } }; @@ -395,7 +395,7 @@ double Area(const Path &poly) double a = 0; for (int i = 0, j = size -1; i < size; ++i) { - a += ((double)poly[j].X + poly[i].X) * ((double)poly[j].Y - poly[i].Y); + a += ((double)poly[j].x + poly[i].x) * ((double)poly[j].y - poly[i].y); j = i; } return -a * 0.5; @@ -408,7 +408,7 @@ double Area(const OutRec &outRec) if (!op) return 0; double a = 0; do { - a += (double)(op->Prev->Pt.X + op->Pt.X) * (double)(op->Prev->Pt.Y - op->Pt.Y); + a += (double)(op->Prev->Pt.x + op->Pt.x) * (double)(op->Prev->Pt.y - op->Pt.y); op = op->Next; } while (op != outRec.Pts); return a * 0.5; @@ -440,31 +440,31 @@ int PointInPolygon(const IntPoint &pt, const Path &path) for(size_t i = 1; i <= cnt; ++i) { IntPoint ipNext = (i == cnt ? path[0] : path[i]); - if (ipNext.Y == pt.Y) + if (ipNext.y == pt.y) { - if ((ipNext.X == pt.X) || (ip.Y == pt.Y && - ((ipNext.X > pt.X) == (ip.X < pt.X)))) return -1; + if ((ipNext.x == pt.x) || (ip.y == pt.y && + ((ipNext.x > pt.x) == (ip.x < pt.x)))) return -1; } - if ((ip.Y < pt.Y) != (ipNext.Y < pt.Y)) + if ((ip.y < pt.y) != (ipNext.y < pt.y)) { - if (ip.X >= pt.X) + if (ip.x >= pt.x) { - if (ipNext.X > pt.X) result = 1 - result; + if (ipNext.x > pt.x) result = 1 - result; else { - double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - - (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); + double d = (double)(ip.x - pt.x) * (ipNext.y - pt.y) - + (double)(ipNext.x - pt.x) * (ip.y - pt.y); if (!d) return -1; - if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; + if ((d > 0) == (ipNext.y > ip.y)) result = 1 - result; } } else { - if (ipNext.X > pt.X) + if (ipNext.x > pt.x) { - double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) - - (double)(ipNext.X - pt.X) * (ip.Y - pt.Y); + double d = (double)(ip.x - pt.x) * (ipNext.y - pt.y) - + (double)(ipNext.x - pt.x) * (ip.y - pt.y); if (!d) return -1; - if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result; + if ((d > 0) == (ipNext.y > ip.y)) result = 1 - result; } } } @@ -481,31 +481,31 @@ int PointInPolygon (const IntPoint &pt, OutPt *op) OutPt* startOp = op; for(;;) { - if (op->Next->Pt.Y == pt.Y) + if (op->Next->Pt.y == pt.y) { - if ((op->Next->Pt.X == pt.X) || (op->Pt.Y == pt.Y && - ((op->Next->Pt.X > pt.X) == (op->Pt.X < pt.X)))) return -1; + if ((op->Next->Pt.x == pt.x) || (op->Pt.y == pt.y && + ((op->Next->Pt.x > pt.x) == (op->Pt.x < pt.x)))) return -1; } - if ((op->Pt.Y < pt.Y) != (op->Next->Pt.Y < pt.Y)) + if ((op->Pt.y < pt.y) != (op->Next->Pt.y < pt.y)) { - if (op->Pt.X >= pt.X) + if (op->Pt.x >= pt.x) { - if (op->Next->Pt.X > pt.X) result = 1 - result; + if (op->Next->Pt.x > pt.x) result = 1 - result; else { - double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) - - (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y); + double d = (double)(op->Pt.x - pt.x) * (op->Next->Pt.y - pt.y) - + (double)(op->Next->Pt.x - pt.x) * (op->Pt.y - pt.y); if (!d) return -1; - if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result; + if ((d > 0) == (op->Next->Pt.y > op->Pt.y)) result = 1 - result; } } else { - if (op->Next->Pt.X > pt.X) + if (op->Next->Pt.x > pt.x) { - double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) - - (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y); + double d = (double)(op->Pt.x - pt.x) * (op->Next->Pt.y - pt.y) - + (double)(op->Next->Pt.x - pt.x) * (op->Pt.y - pt.y); if (!d) return -1; - if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result; + if ((d > 0) == (op->Next->Pt.y > op->Pt.y)) result = 1 - result; } } } @@ -535,10 +535,10 @@ bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range) { #ifndef use_int32 if (UseFullInt64Range) - return Int128Mul(e1.Delta.Y, e2.Delta.X) == Int128Mul(e1.Delta.X, e2.Delta.Y); + return Int128Mul(e1.Delta.y, e2.Delta.x) == Int128Mul(e1.Delta.x, e2.Delta.y); else #endif - return e1.Delta.Y * e2.Delta.X == e1.Delta.X * e2.Delta.Y; + return e1.Delta.y * e2.Delta.x == e1.Delta.x * e2.Delta.y; } //------------------------------------------------------------------------------ @@ -547,10 +547,10 @@ bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, { #ifndef use_int32 if (UseFullInt64Range) - return Int128Mul(pt1.Y-pt2.Y, pt2.X-pt3.X) == Int128Mul(pt1.X-pt2.X, pt2.Y-pt3.Y); + return Int128Mul(pt1.y-pt2.y, pt2.x-pt3.x) == Int128Mul(pt1.x-pt2.x, pt2.y-pt3.y); else #endif - return (pt1.Y-pt2.Y)*(pt2.X-pt3.X) == (pt1.X-pt2.X)*(pt2.Y-pt3.Y); + return (pt1.y-pt2.y)*(pt2.x-pt3.x) == (pt1.x-pt2.x)*(pt2.y-pt3.y); } //------------------------------------------------------------------------------ @@ -559,33 +559,33 @@ bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, { #ifndef use_int32 if (UseFullInt64Range) - return Int128Mul(pt1.Y-pt2.Y, pt3.X-pt4.X) == Int128Mul(pt1.X-pt2.X, pt3.Y-pt4.Y); + return Int128Mul(pt1.y-pt2.y, pt3.x-pt4.x) == Int128Mul(pt1.x-pt2.x, pt3.y-pt4.y); else #endif - return (pt1.Y-pt2.Y)*(pt3.X-pt4.X) == (pt1.X-pt2.X)*(pt3.Y-pt4.Y); + return (pt1.y-pt2.y)*(pt3.x-pt4.x) == (pt1.x-pt2.x)*(pt3.y-pt4.y); } //------------------------------------------------------------------------------ inline bool IsHorizontal(TEdge &e) { - return e.Delta.Y == 0; + return e.Delta.y == 0; } //------------------------------------------------------------------------------ inline double GetDx(const IntPoint pt1, const IntPoint pt2) { - return (pt1.Y == pt2.Y) ? - HORIZONTAL : (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y); + return (pt1.y == pt2.y) ? + HORIZONTAL : (double)(pt2.x - pt1.x) / (pt2.y - pt1.y); } //--------------------------------------------------------------------------- inline void SetDx(TEdge &e) { - e.Delta.X = (e.Top.X - e.Bot.X); - e.Delta.Y = (e.Top.Y - e.Bot.Y); + e.Delta.x = (e.Top.x - e.Bot.x); + e.Delta.y = (e.Top.y - e.Bot.y); - if (e.Delta.Y == 0) e.Dx = HORIZONTAL; - else e.Dx = (double)(e.Delta.X) / e.Delta.Y; + if (e.Delta.y == 0) e.Dx = HORIZONTAL; + else e.Dx = (double)(e.Delta.x) / e.Delta.y; } //--------------------------------------------------------------------------- @@ -607,8 +607,8 @@ inline void SwapPolyIndexes(TEdge &Edge1, TEdge &Edge2) inline cInt TopX(TEdge &edge, const cInt currentY) { - return ( currentY == edge.Top.Y ) ? - edge.Top.X : edge.Bot.X + Round(edge.Dx *(currentY - edge.Bot.Y)); + return ( currentY == edge.Top.y ) ? + edge.Top.x : edge.Bot.x + Round(edge.Dx *(currentY - edge.Bot.y)); } //------------------------------------------------------------------------------ @@ -621,63 +621,63 @@ void IntersectPoint(TEdge &Edge1, TEdge &Edge2, IntPoint &ip) double b1, b2; if (Edge1.Dx == Edge2.Dx) { - ip.Y = Edge1.Curr.Y; - ip.X = TopX(Edge1, ip.Y); + ip.y = Edge1.Curr.y; + ip.x = TopX(Edge1, ip.y); return; } - else if (Edge1.Delta.X == 0) + else if (Edge1.Delta.x == 0) { - ip.X = Edge1.Bot.X; + ip.x = Edge1.Bot.x; if (IsHorizontal(Edge2)) - ip.Y = Edge2.Bot.Y; + ip.y = Edge2.Bot.y; else { - b2 = Edge2.Bot.Y - (Edge2.Bot.X / Edge2.Dx); - ip.Y = Round(ip.X / Edge2.Dx + b2); + b2 = Edge2.Bot.y - (Edge2.Bot.x / Edge2.Dx); + ip.y = Round(ip.x / Edge2.Dx + b2); } } - else if (Edge2.Delta.X == 0) + else if (Edge2.Delta.x == 0) { - ip.X = Edge2.Bot.X; + ip.x = Edge2.Bot.x; if (IsHorizontal(Edge1)) - ip.Y = Edge1.Bot.Y; + ip.y = Edge1.Bot.y; else { - b1 = Edge1.Bot.Y - (Edge1.Bot.X / Edge1.Dx); - ip.Y = Round(ip.X / Edge1.Dx + b1); + b1 = Edge1.Bot.y - (Edge1.Bot.x / Edge1.Dx); + ip.y = Round(ip.x / Edge1.Dx + b1); } } else { - b1 = Edge1.Bot.X - Edge1.Bot.Y * Edge1.Dx; - b2 = Edge2.Bot.X - Edge2.Bot.Y * Edge2.Dx; + b1 = Edge1.Bot.x - Edge1.Bot.y * Edge1.Dx; + b2 = Edge2.Bot.x - Edge2.Bot.y * Edge2.Dx; double q = (b2-b1) / (Edge1.Dx - Edge2.Dx); - ip.Y = Round(q); + ip.y = Round(q); if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx)) - ip.X = Round(Edge1.Dx * q + b1); + ip.x = Round(Edge1.Dx * q + b1); else - ip.X = Round(Edge2.Dx * q + b2); + ip.x = Round(Edge2.Dx * q + b2); } - if (ip.Y < Edge1.Top.Y || ip.Y < Edge2.Top.Y) + if (ip.y < Edge1.Top.y || ip.y < Edge2.Top.y) { - if (Edge1.Top.Y > Edge2.Top.Y) - ip.Y = Edge1.Top.Y; + if (Edge1.Top.y > Edge2.Top.y) + ip.y = Edge1.Top.y; else - ip.Y = Edge2.Top.Y; + ip.y = Edge2.Top.y; if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx)) - ip.X = TopX(Edge1, ip.Y); + ip.x = TopX(Edge1, ip.y); else - ip.X = TopX(Edge2, ip.Y); + ip.x = TopX(Edge2, ip.y); } - //finally, don't allow 'ip' to be BELOW curr.Y (ie bottom of scanbeam) ... - if (ip.Y > Edge1.Curr.Y) + //finally, don't allow 'ip' to be BELOW curr.y (ie bottom of scanbeam) ... + if (ip.y > Edge1.Curr.y) { - ip.Y = Edge1.Curr.Y; + ip.y = Edge1.Curr.y; //use the more vertical edge to derive X ... if (std::fabs(Edge1.Dx) > std::fabs(Edge2.Dx)) - ip.X = TopX(Edge2, ip.Y); else - ip.X = TopX(Edge1, ip.Y); + ip.x = TopX(Edge2, ip.y); else + ip.x = TopX(Edge1, ip.y); } } //------------------------------------------------------------------------------ @@ -721,7 +721,7 @@ inline void InitEdge(TEdge* e, TEdge* eNext, TEdge* ePrev, const IntPoint& Pt) void InitEdge2(TEdge& e, PolyType Pt) { - if (e.Curr.Y >= e.Next->Curr.Y) + if (e.Curr.y >= e.Next->Curr.y) { e.Bot = e.Curr; e.Top = e.Next->Curr; @@ -751,7 +751,7 @@ inline void ReverseHorizontal(TEdge &e) //swap horizontal edges' Top and Bottom x's so they follow the natural //progression of the bounds - ie so their xbots will align with the //adjoining lower edge. [Helpful in the ProcessHorizontal() method.] - std::swap(e.Top.X, e.Bot.X); + std::swap(e.Top.x, e.Bot.x); #ifdef use_xyz std::swap(e.Top.Z, e.Bot.Z); #endif @@ -770,20 +770,20 @@ bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a, IntPoint pt2b, IntPoint &pt1, IntPoint &pt2) { //precondition: segments are Collinear. - if (Abs(pt1a.X - pt1b.X) > Abs(pt1a.Y - pt1b.Y)) + if (Abs(pt1a.x - pt1b.x) > Abs(pt1a.y - pt1b.y)) { - if (pt1a.X > pt1b.X) SwapPoints(pt1a, pt1b); - if (pt2a.X > pt2b.X) SwapPoints(pt2a, pt2b); - if (pt1a.X > pt2a.X) pt1 = pt1a; else pt1 = pt2a; - if (pt1b.X < pt2b.X) pt2 = pt1b; else pt2 = pt2b; - return pt1.X < pt2.X; + if (pt1a.x > pt1b.x) SwapPoints(pt1a, pt1b); + if (pt2a.x > pt2b.x) SwapPoints(pt2a, pt2b); + if (pt1a.x > pt2a.x) pt1 = pt1a; else pt1 = pt2a; + if (pt1b.x < pt2b.x) pt2 = pt1b; else pt2 = pt2b; + return pt1.x < pt2.x; } else { - if (pt1a.Y < pt1b.Y) SwapPoints(pt1a, pt1b); - if (pt2a.Y < pt2b.Y) SwapPoints(pt2a, pt2b); - if (pt1a.Y < pt2a.Y) pt1 = pt1a; else pt1 = pt2a; - if (pt1b.Y > pt2b.Y) pt2 = pt1b; else pt2 = pt2b; - return pt1.Y > pt2.Y; + if (pt1a.y < pt1b.y) SwapPoints(pt1a, pt1b); + if (pt2a.y < pt2b.y) SwapPoints(pt2a, pt2b); + if (pt1a.y < pt2a.y) pt1 = pt1a; else pt1 = pt2a; + if (pt1b.y > pt2b.y) pt2 = pt1b; else pt2 = pt2b; + return pt1.y > pt2.y; } } //------------------------------------------------------------------------------ @@ -813,14 +813,14 @@ OutPt* GetBottomPt(OutPt *pp) OutPt* p = pp->Next; while (p != pp) { - if (p->Pt.Y > pp->Pt.Y) + if (p->Pt.y > pp->Pt.y) { pp = p; dups = 0; } - else if (p->Pt.Y == pp->Pt.Y && p->Pt.X <= pp->Pt.X) + else if (p->Pt.y == pp->Pt.y && p->Pt.x <= pp->Pt.x) { - if (p->Pt.X < pp->Pt.X) + if (p->Pt.x < pp->Pt.x) { dups = 0; pp = p; @@ -850,10 +850,10 @@ bool Pt2IsBetweenPt1AndPt3(const IntPoint pt1, { if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2)) return false; - else if (pt1.X != pt3.X) - return (pt2.X > pt1.X) == (pt2.X < pt3.X); + else if (pt1.x != pt3.x) + return (pt2.x > pt1.x) == (pt2.x < pt3.x); else - return (pt2.Y > pt1.Y) == (pt2.Y < pt3.Y); + return (pt2.y > pt1.y) == (pt2.y < pt3.y); } //------------------------------------------------------------------------------ @@ -885,10 +885,10 @@ void RangeTest(const IntPoint& Pt, bool& useFullRange) { if (useFullRange) { - if (Pt.X > hiRange || Pt.Y > hiRange || -Pt.X > hiRange || -Pt.Y > hiRange) + if (Pt.x > hiRange || Pt.y > hiRange || -Pt.x > hiRange || -Pt.y > hiRange) throw "Coordinate outside allowed range"; } - else if (Pt.X > loRange|| Pt.Y > loRange || -Pt.X > loRange || -Pt.Y > loRange) + else if (Pt.x > loRange|| Pt.y > loRange || -Pt.x > loRange || -Pt.y > loRange) { useFullRange = true; RangeTest(Pt, useFullRange); @@ -905,8 +905,8 @@ TEdge* FindNextLocMin(TEdge* E) while (IsHorizontal(*E->Prev)) E = E->Prev; TEdge* E2 = E; while (IsHorizontal(*E)) E = E->Next; - if (E->Top.Y == E->Prev->Bot.Y) continue; //ie just an intermediate horz. - if (E2->Prev->Bot.X < E->Bot.X) E = E2; + if (E->Top.y == E->Prev->Bot.y) continue; //ie just an intermediate horz. + if (E2->Prev->Bot.x < E->Bot.x) E = E2; break; } return E; @@ -924,14 +924,14 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward) //create another LocMin and call ProcessBound once more if (NextIsForward) { - while (E->Top.Y == E->Next->Bot.Y) E = E->Next; + while (E->Top.y == E->Next->Bot.y) E = E->Next; //don't include top horizontals when parsing a bound a second time, //they will be contained in the opposite bound ... while (E != Result && IsHorizontal(*E)) E = E->Prev; } else { - while (E->Top.Y == E->Prev->Bot.Y) E = E->Prev; + while (E->Top.y == E->Prev->Bot.y) E = E->Prev; while (E != Result && IsHorizontal(*E)) E = E->Next; } @@ -948,7 +948,7 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward) else E = Result->Prev; MinimaList::value_type locMin; - locMin.Y = E->Bot.Y; + locMin.y = E->Bot.y; locMin.LeftBound = 0; locMin.RightBound = E; E->WindDelta = 0; @@ -971,17 +971,17 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward) EStart = E->Next; if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge { - if (EStart->Bot.X != E->Bot.X && EStart->Top.X != E->Bot.X) + if (EStart->Bot.x != E->Bot.x && EStart->Top.x != E->Bot.x) ReverseHorizontal(*E); } - else if (EStart->Bot.X != E->Bot.X) + else if (EStart->Bot.x != E->Bot.x) ReverseHorizontal(*E); } EStart = E; if (NextIsForward) { - while (Result->Top.Y == Result->Next->Bot.Y && Result->Next->OutIdx != Skip) + while (Result->Top.y == Result->Next->Bot.y && Result->Next->OutIdx != Skip) Result = Result->Next; if (IsHorizontal(*Result) && Result->Next->OutIdx != Skip) { @@ -990,38 +990,38 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward) //unless a Skip edge is encountered when that becomes the top divide Horz = Result; while (IsHorizontal(*Horz->Prev)) Horz = Horz->Prev; - if (Horz->Prev->Top.X > Result->Next->Top.X) Result = Horz->Prev; + if (Horz->Prev->Top.x > Result->Next->Top.x) Result = Horz->Prev; } while (E != Result) { E->NextInLML = E->Next; if (IsHorizontal(*E) && E != EStart && - E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E); + E->Bot.x != E->Prev->Top.x) ReverseHorizontal(*E); E = E->Next; } - if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Prev->Top.X) + if (IsHorizontal(*E) && E != EStart && E->Bot.x != E->Prev->Top.x) ReverseHorizontal(*E); Result = Result->Next; //move to the edge just beyond current bound } else { - while (Result->Top.Y == Result->Prev->Bot.Y && Result->Prev->OutIdx != Skip) + while (Result->Top.y == Result->Prev->Bot.y && Result->Prev->OutIdx != Skip) Result = Result->Prev; if (IsHorizontal(*Result) && Result->Prev->OutIdx != Skip) { Horz = Result; while (IsHorizontal(*Horz->Next)) Horz = Horz->Next; - if (Horz->Next->Top.X == Result->Prev->Top.X || - Horz->Next->Top.X > Result->Prev->Top.X) Result = Horz->Next; + if (Horz->Next->Top.x == Result->Prev->Top.x || + Horz->Next->Top.x > Result->Prev->Top.x) Result = Horz->Next; } while (E != Result) { E->NextInLML = E->Prev; - if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X) + if (IsHorizontal(*E) && E != EStart && E->Bot.x != E->Next->Top.x) ReverseHorizontal(*E); E = E->Prev; } - if (IsHorizontal(*E) && E != EStart && E->Bot.X != E->Next->Top.X) + if (IsHorizontal(*E) && E != EStart && E->Bot.x != E->Next->Top.x) ReverseHorizontal(*E); Result = Result->Prev; //move to the edge just beyond current bound } @@ -1122,7 +1122,7 @@ bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) { InitEdge2(*E, PolyTyp); E = E->Next; - if (IsFlat && E->Curr.Y != eStart->Curr.Y) IsFlat = false; + if (IsFlat && E->Curr.y != eStart->Curr.y) IsFlat = false; } while (E != eStart); @@ -1139,14 +1139,14 @@ bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) } E->Prev->OutIdx = Skip; MinimaList::value_type locMin; - locMin.Y = E->Bot.Y; + locMin.y = E->Bot.y; locMin.LeftBound = 0; locMin.RightBound = E; locMin.RightBound->Side = esRight; locMin.RightBound->WindDelta = 0; for (;;) { - if (E->Bot.X != E->Prev->Top.X) ReverseHorizontal(*E); + if (E->Bot.x != E->Prev->Top.x) ReverseHorizontal(*E); if (E->Next->OutIdx == Skip) break; E->NextInLML = E->Next; E = E->Next; @@ -1173,7 +1173,7 @@ bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed) //E and E.Prev now share a local minima (left aligned if horizontal). //Compare their slopes to find which starts which bound ... MinimaList::value_type locMin; - locMin.Y = E->Bot.Y; + locMin.y = E->Bot.y; if (E->Dx < E->Prev->Dx) { locMin.LeftBound = E->Prev; @@ -1287,27 +1287,27 @@ IntRect ClipperBase::GetBounds() result.left = result.top = result.right = result.bottom = 0; return result; } - result.left = lm->LeftBound->Bot.X; - result.top = lm->LeftBound->Bot.Y; - result.right = lm->LeftBound->Bot.X; - result.bottom = lm->LeftBound->Bot.Y; + result.left = lm->LeftBound->Bot.x; + result.top = lm->LeftBound->Bot.y; + result.right = lm->LeftBound->Bot.x; + result.bottom = lm->LeftBound->Bot.y; while (lm != m_MinimaList.end()) { - result.bottom = std::max(result.bottom, lm->LeftBound->Bot.Y); + result.bottom = std::max(result.bottom, lm->LeftBound->Bot.y); TEdge* e = lm->LeftBound; for (;;) { TEdge* bottomE = e; while (e->NextInLML) { - if (e->Bot.X < result.left) result.left = e->Bot.X; - if (e->Bot.X > result.right) result.right = e->Bot.X; + if (e->Bot.x < result.left) result.left = e->Bot.x; + if (e->Bot.x > result.right) result.right = e->Bot.x; e = e->NextInLML; } - result.left = std::min(result.left, e->Bot.X); - result.right = std::max(result.right, e->Bot.X); - result.left = std::min(result.left, e->Top.X); - result.right = std::max(result.right, e->Top.X); - result.top = std::min(result.top, e->Top.Y); + result.left = std::min(result.left, e->Bot.x); + result.right = std::max(result.right, e->Bot.x); + result.left = std::min(result.left, e->Top.x); + result.right = std::max(result.right, e->Top.x); + result.top = std::min(result.top, e->Top.y); if (bottomE == lm->LeftBound) e = lm->RightBound; else break; } @@ -1358,7 +1358,7 @@ void Clipper::Reset() m_ActiveEdges = 0; m_SortedEdges = 0; for (MinimaList::iterator lm = m_MinimaList.begin(); lm != m_MinimaList.end(); ++lm) - InsertScanbeam(lm->Y); + InsertScanbeam(lm->y); } //------------------------------------------------------------------------------ @@ -1754,7 +1754,7 @@ OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt) } if (prevE && prevE->OutIdx >= 0 && - (TopX(*prevE, Pt.Y) == TopX(*e, Pt.Y)) && + (TopX(*prevE, Pt.y) == TopX(*e, Pt.y)) && SlopesEqual(*e, *prevE, m_UseFullRange) && (e->WindDelta != 0) && (prevE->WindDelta != 0)) { @@ -1852,7 +1852,7 @@ void Clipper::AddGhostJoin(OutPt *op, const IntPoint OffPt) void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) { - while (m_CurrentLM != m_MinimaList.end() && (m_CurrentLM->Y == botY)) + while (m_CurrentLM != m_MinimaList.end() && (m_CurrentLM->y == botY)) { TEdge* lb = m_CurrentLM->LeftBound; TEdge* rb = m_CurrentLM->RightBound; @@ -1872,7 +1872,7 @@ void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) SetWindingCount(*lb); if (IsContributing(*lb)) Op1 = AddOutPt(lb, lb->Bot); - InsertScanbeam(lb->Top.Y); + InsertScanbeam(lb->Top.y); } else { @@ -1883,13 +1883,13 @@ void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) rb->WindCnt2 = lb->WindCnt2; if (IsContributing(*lb)) Op1 = AddLocalMinPoly(lb, rb, lb->Bot); - InsertScanbeam(lb->Top.Y); + InsertScanbeam(lb->Top.y); } if (rb) { if(IsHorizontal(*rb)) AddEdgeToSEL(rb); - else InsertScanbeam( rb->Top.Y ); + else InsertScanbeam( rb->Top.y ); } if (!lb || !rb) continue; @@ -1903,13 +1903,13 @@ void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) Join* jr = m_GhostJoins[i]; //if the horizontal Rb and a 'ghost' horizontal overlap, then convert //the 'ghost' join to a real join ready for later ... - if (HorzSegmentsOverlap(jr->OutPt1->Pt.X, jr->OffPt.X, rb->Bot.X, rb->Top.X)) + if (HorzSegmentsOverlap(jr->OutPt1->Pt.x, jr->OffPt.x, rb->Bot.x, rb->Top.x)) AddJoin(jr->OutPt1, Op1, jr->OffPt); } } if (lb->OutIdx >= 0 && lb->PrevInAEL && - lb->PrevInAEL->Curr.X == lb->Bot.X && + lb->PrevInAEL->Curr.x == lb->Bot.x && lb->PrevInAEL->OutIdx >= 0 && SlopesEqual(*lb->PrevInAEL, *lb, m_UseFullRange) && (lb->WindDelta != 0) && (lb->PrevInAEL->WindDelta != 0)) @@ -2207,10 +2207,10 @@ OutRec* GetLowermostRec(OutRec *outRec1, OutRec *outRec2) outRec2->BottomPt = GetBottomPt(outRec2->Pts); OutPt *OutPt1 = outRec1->BottomPt; OutPt *OutPt2 = outRec2->BottomPt; - if (OutPt1->Pt.Y > OutPt2->Pt.Y) return outRec1; - else if (OutPt1->Pt.Y < OutPt2->Pt.Y) return outRec2; - else if (OutPt1->Pt.X < OutPt2->Pt.X) return outRec1; - else if (OutPt1->Pt.X > OutPt2->Pt.X) return outRec2; + if (OutPt1->Pt.y > OutPt2->Pt.y) return outRec1; + else if (OutPt1->Pt.y < OutPt2->Pt.y) return outRec2; + else if (OutPt1->Pt.x < OutPt2->Pt.x) return outRec1; + else if (OutPt1->Pt.x > OutPt2->Pt.x) return outRec2; else if (OutPt1->Next == OutPt1) return outRec2; else if (OutPt2->Next == OutPt2) return outRec1; else if (FirstIsBottomPt(OutPt1, OutPt2)) return outRec1; @@ -2421,13 +2421,13 @@ inline bool IsMinima(TEdge *e) inline bool IsMaxima(TEdge *e, const cInt Y) { - return e && e->Top.Y == Y && !e->NextInLML; + return e && e->Top.y == Y && !e->NextInLML; } //------------------------------------------------------------------------------ inline bool IsIntermediate(TEdge *e, const cInt Y) { - return e->Top.Y == Y && e->NextInLML; + return e->Top.y == Y && e->NextInLML; } //------------------------------------------------------------------------------ @@ -2548,15 +2548,15 @@ TEdge* GetNextInAEL(TEdge *e, Direction dir) void GetHorzDirection(TEdge& HorzEdge, Direction& Dir, cInt& Left, cInt& Right) { - if (HorzEdge.Bot.X < HorzEdge.Top.X) + if (HorzEdge.Bot.x < HorzEdge.Top.x) { - Left = HorzEdge.Bot.X; - Right = HorzEdge.Top.X; + Left = HorzEdge.Bot.x; + Right = HorzEdge.Top.x; Dir = dLeftToRight; } else { - Left = HorzEdge.Top.X; - Right = HorzEdge.Bot.X; + Left = HorzEdge.Top.x; + Right = HorzEdge.Bot.x; Dir = dRightToLeft; } } @@ -2565,8 +2565,8 @@ void GetHorzDirection(TEdge& HorzEdge, Direction& Dir, cInt& Left, cInt& Right) /******************************************************************************* * Notes: Horizontal edges (HEs) at scanline intersections (ie at the Top or * * Bottom of a scanbeam) are processed as if layered. The order in which HEs * -* are processed doesn't matter. HEs intersect with other HE Bot.Xs only [#] * -* (or they could intersect with Top.Xs only, ie EITHER Bot.Xs OR Top.Xs), * +* are processed doesn't matter. HEs intersect with other HE Bot.xs only [#] * +* (or they could intersect with Top.xs only, ie EITHER Bot.xs OR Top.xs), * * and with other non-horizontal edges [*]. Once these intersections are * * processed, intermediate HEs then 'promote' the Edge above (NextInLML) into * * the AEL. These 'promoted' edges may in turn intersect [%] with other HEs. * @@ -2594,15 +2594,15 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) if (dir == dLeftToRight) { maxIt = m_Maxima.begin(); - while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) maxIt++; - if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.X) + while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.x) maxIt++; + if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.x) maxIt = m_Maxima.end(); } else { maxRit = m_Maxima.rbegin(); - while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.X) maxRit++; - if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.X) + while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.x) maxRit++; + if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.x) maxRit = m_Maxima.rend(); } } @@ -2624,30 +2624,30 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) { if (dir == dLeftToRight) { - while (maxIt != m_Maxima.end() && *maxIt < e->Curr.X) + while (maxIt != m_Maxima.end() && *maxIt < e->Curr.x) { if (horzEdge->OutIdx >= 0 && !IsOpen) - AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.Y)); + AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.y)); maxIt++; } } else { - while (maxRit != m_Maxima.rend() && *maxRit > e->Curr.X) + while (maxRit != m_Maxima.rend() && *maxRit > e->Curr.x) { if (horzEdge->OutIdx >= 0 && !IsOpen) - AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.Y)); + AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.y)); maxRit++; } } }; - if ((dir == dLeftToRight && e->Curr.X > horzRight) || - (dir == dRightToLeft && e->Curr.X < horzLeft)) break; + if ((dir == dLeftToRight && e->Curr.x > horzRight) || + (dir == dRightToLeft && e->Curr.x < horzLeft)) break; //Also break if we've got to the end of an intermediate horizontal edge ... //nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal. - if (e->Curr.X == horzEdge->Top.X && horzEdge->NextInLML && + if (e->Curr.x == horzEdge->Top.x && horzEdge->NextInLML && e->Dx < horzEdge->NextInLML->Dx) break; if (horzEdge->OutIdx >= 0 && !IsOpen) //note: may be done multiple times @@ -2657,8 +2657,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) while (eNextHorz) { if (eNextHorz->OutIdx >= 0 && - HorzSegmentsOverlap(horzEdge->Bot.X, - horzEdge->Top.X, eNextHorz->Bot.X, eNextHorz->Top.X)) + HorzSegmentsOverlap(horzEdge->Bot.x, + horzEdge->Top.x, eNextHorz->Bot.x, eNextHorz->Top.x)) { OutPt* op2 = GetLastOutPt(eNextHorz); AddJoin(op2, op1, eNextHorz->Top); @@ -2681,12 +2681,12 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) if(dir == dLeftToRight) { - IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y); + IntPoint Pt = IntPoint(e->Curr.x, horzEdge->Curr.y); IntersectEdges(horzEdge, e, Pt); } else { - IntPoint Pt = IntPoint(e->Curr.X, horzEdge->Curr.Y); + IntPoint Pt = IntPoint(e->Curr.x, horzEdge->Curr.y); IntersectEdges( e, horzEdge, Pt); } TEdge* eNext = GetNextInAEL(e, dir); @@ -2710,8 +2710,8 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) while (eNextHorz) { if (eNextHorz->OutIdx >= 0 && - HorzSegmentsOverlap(horzEdge->Bot.X, - horzEdge->Top.X, eNextHorz->Bot.X, eNextHorz->Top.X)) + HorzSegmentsOverlap(horzEdge->Bot.x, + horzEdge->Top.x, eNextHorz->Bot.x, eNextHorz->Top.x)) { OutPt* op2 = GetLastOutPt(eNextHorz); AddJoin(op2, op1, eNextHorz->Top); @@ -2731,17 +2731,17 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) //nb: HorzEdge is no longer horizontal here TEdge* ePrev = horzEdge->PrevInAEL; TEdge* eNext = horzEdge->NextInAEL; - if (ePrev && ePrev->Curr.X == horzEdge->Bot.X && - ePrev->Curr.Y == horzEdge->Bot.Y && ePrev->WindDelta != 0 && - (ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y && + if (ePrev && ePrev->Curr.x == horzEdge->Bot.x && + ePrev->Curr.y == horzEdge->Bot.y && ePrev->WindDelta != 0 && + (ePrev->OutIdx >= 0 && ePrev->Curr.y > ePrev->Top.y && SlopesEqual(*horzEdge, *ePrev, m_UseFullRange))) { OutPt* op2 = AddOutPt(ePrev, horzEdge->Bot); AddJoin(op1, op2, horzEdge->Top); } - else if (eNext && eNext->Curr.X == horzEdge->Bot.X && - eNext->Curr.Y == horzEdge->Bot.Y && eNext->WindDelta != 0 && - eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y && + else if (eNext && eNext->Curr.x == horzEdge->Bot.x && + eNext->Curr.y == horzEdge->Bot.y && eNext->WindDelta != 0 && + eNext->OutIdx >= 0 && eNext->Curr.y > eNext->Top.y && SlopesEqual(*horzEdge, *eNext, m_UseFullRange)) { OutPt* op2 = AddOutPt(eNext, horzEdge->Bot); @@ -2778,7 +2778,7 @@ void Clipper::UpdateEdgeIntoAEL(TEdge *&e) e->Curr = e->Bot; e->PrevInAEL = AelPrev; e->NextInAEL = AelNext; - if (!IsHorizontal(*e)) InsertScanbeam(e->Top.Y); + if (!IsHorizontal(*e)) InsertScanbeam(e->Top.y); } //------------------------------------------------------------------------------ @@ -2822,7 +2822,7 @@ void Clipper::BuildIntersectList(const cInt topY) { e->PrevInSEL = e->PrevInAEL; e->NextInSEL = e->NextInAEL; - e->Curr.X = TopX( *e, topY ); + e->Curr.x = TopX( *e, topY ); e = e->NextInAEL; } @@ -2836,7 +2836,7 @@ void Clipper::BuildIntersectList(const cInt topY) { TEdge *eNext = e->NextInSEL; IntPoint Pt; - if(e->Curr.X > eNext->Curr.X) + if(e->Curr.x > eNext->Curr.x) { IntersectPoint(*e, *eNext, Pt); IntersectNode * newNode = new IntersectNode; @@ -2877,7 +2877,7 @@ void Clipper::ProcessIntersectList() bool IntersectListSort(IntersectNode* node1, IntersectNode* node2) { - return node2->Pt.Y < node1->Pt.Y; + return node2->Pt.y < node1->Pt.y; } //------------------------------------------------------------------------------ @@ -2980,7 +2980,7 @@ void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY) if(IsMaximaEdge) { - if (m_StrictSimple) m_Maxima.push_back(e->Top.X); + if (m_StrictSimple) m_Maxima.push_back(e->Top.x); TEdge* ePrev = e->PrevInAEL; DoMaxima(e); if( !ePrev ) e = m_ActiveEdges; @@ -2988,7 +2988,7 @@ void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY) } else { - //2. promote horizontal edges, otherwise update Curr.X and Curr.Y ... + //2. promote horizontal edges, otherwise update Curr.x and Curr.y ... if (IsIntermediate(e, topY) && IsHorizontal(*e->NextInLML)) { UpdateEdgeIntoAEL(e); @@ -2998,8 +2998,8 @@ void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY) } else { - e->Curr.X = TopX( *e, topY ); - e->Curr.Y = topY; + e->Curr.x = TopX( *e, topY ); + e->Curr.y = topY; } //When StrictlySimple and 'e' is being touched by another edge, then @@ -3008,7 +3008,7 @@ void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY) { TEdge* ePrev = e->PrevInAEL; if ((e->OutIdx >= 0) && (e->WindDelta != 0) && ePrev && (ePrev->OutIdx >= 0) && - (ePrev->Curr.X == e->Curr.X) && (ePrev->WindDelta != 0)) + (ePrev->Curr.x == e->Curr.x) && (ePrev->WindDelta != 0)) { IntPoint pt = e->Curr; #ifdef use_xyz @@ -3043,18 +3043,18 @@ void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY) //if output polygons share an edge, they'll need joining later ... TEdge* ePrev = e->PrevInAEL; TEdge* eNext = e->NextInAEL; - if (ePrev && ePrev->Curr.X == e->Bot.X && - ePrev->Curr.Y == e->Bot.Y && op && - ePrev->OutIdx >= 0 && ePrev->Curr.Y > ePrev->Top.Y && + if (ePrev && ePrev->Curr.x == e->Bot.x && + ePrev->Curr.y == e->Bot.y && op && + ePrev->OutIdx >= 0 && ePrev->Curr.y > ePrev->Top.y && SlopesEqual(*e, *ePrev, m_UseFullRange) && (e->WindDelta != 0) && (ePrev->WindDelta != 0)) { OutPt* op2 = AddOutPt(ePrev, e->Bot); AddJoin(op, op2, e->Top); } - else if (eNext && eNext->Curr.X == e->Bot.X && - eNext->Curr.Y == e->Bot.Y && op && - eNext->OutIdx >= 0 && eNext->Curr.Y > eNext->Top.Y && + else if (eNext && eNext->Curr.x == e->Bot.x && + eNext->Curr.y == e->Bot.y && op && + eNext->OutIdx >= 0 && eNext->Curr.y > eNext->Top.y && SlopesEqual(*e, *eNext, m_UseFullRange) && (e->WindDelta != 0) && (eNext->WindDelta != 0)) { @@ -3231,13 +3231,13 @@ void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2) inline bool E2InsertsBeforeE1(TEdge &e1, TEdge &e2) { - if (e2.Curr.X == e1.Curr.X) + if (e2.Curr.x == e1.Curr.x) { - if (e2.Top.Y > e1.Top.Y) - return e2.Top.X < TopX(e1, e2.Top.Y); - else return e1.Top.X > TopX(e2, e1.Top.Y); + if (e2.Top.y > e1.Top.y) + return e2.Top.x < TopX(e1, e2.Top.y); + else return e1.Top.x > TopX(e2, e1.Top.y); } - else return e2.Curr.X < e1.Curr.X; + else return e2.Curr.x < e1.Curr.x; } //------------------------------------------------------------------------------ @@ -3325,8 +3325,8 @@ OutPt* DupOutPt(OutPt* outPt, bool InsertAfter) bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, const IntPoint Pt, bool DiscardLeft) { - Direction Dir1 = (op1->Pt.X > op1b->Pt.X ? dRightToLeft : dLeftToRight); - Direction Dir2 = (op2->Pt.X > op2b->Pt.X ? dRightToLeft : dLeftToRight); + Direction Dir1 = (op1->Pt.x > op1b->Pt.x ? dRightToLeft : dLeftToRight); + Direction Dir2 = (op2->Pt.x > op2b->Pt.x ? dRightToLeft : dLeftToRight); if (Dir1 == Dir2) return false; //When DiscardLeft, we want Op1b to be on the Left of Op1, otherwise we @@ -3336,10 +3336,10 @@ bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, //otherwise make sure we're AT or LEFT of Pt. (Likewise with Op2b.) if (Dir1 == dLeftToRight) { - while (op1->Next->Pt.X <= Pt.X && - op1->Next->Pt.X >= op1->Pt.X && op1->Next->Pt.Y == Pt.Y) + while (op1->Next->Pt.x <= Pt.x && + op1->Next->Pt.x >= op1->Pt.x && op1->Next->Pt.y == Pt.y) op1 = op1->Next; - if (DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next; + if (DiscardLeft && (op1->Pt.x != Pt.x)) op1 = op1->Next; op1b = DupOutPt(op1, !DiscardLeft); if (op1b->Pt != Pt) { @@ -3350,10 +3350,10 @@ bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, } else { - while (op1->Next->Pt.X >= Pt.X && - op1->Next->Pt.X <= op1->Pt.X && op1->Next->Pt.Y == Pt.Y) + while (op1->Next->Pt.x >= Pt.x && + op1->Next->Pt.x <= op1->Pt.x && op1->Next->Pt.y == Pt.y) op1 = op1->Next; - if (!DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next; + if (!DiscardLeft && (op1->Pt.x != Pt.x)) op1 = op1->Next; op1b = DupOutPt(op1, DiscardLeft); if (op1b->Pt != Pt) { @@ -3365,10 +3365,10 @@ bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, if (Dir2 == dLeftToRight) { - while (op2->Next->Pt.X <= Pt.X && - op2->Next->Pt.X >= op2->Pt.X && op2->Next->Pt.Y == Pt.Y) + while (op2->Next->Pt.x <= Pt.x && + op2->Next->Pt.x >= op2->Pt.x && op2->Next->Pt.y == Pt.y) op2 = op2->Next; - if (DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next; + if (DiscardLeft && (op2->Pt.x != Pt.x)) op2 = op2->Next; op2b = DupOutPt(op2, !DiscardLeft); if (op2b->Pt != Pt) { @@ -3378,10 +3378,10 @@ bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b, }; } else { - while (op2->Next->Pt.X >= Pt.X && - op2->Next->Pt.X <= op2->Pt.X && op2->Next->Pt.Y == Pt.Y) + while (op2->Next->Pt.x >= Pt.x && + op2->Next->Pt.x <= op2->Pt.x && op2->Next->Pt.y == Pt.y) op2 = op2->Next; - if (!DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next; + if (!DiscardLeft && (op2->Pt.x != Pt.x)) op2 = op2->Next; op2b = DupOutPt(op2, DiscardLeft); if (op2b->Pt != Pt) { @@ -3421,7 +3421,7 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) //location at the Bottom of the overlapping segment (& Join.OffPt is above). //3. StrictSimple joins where edges touch but are not collinear and where //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point. - bool isHorizontal = (j->OutPt1->Pt.Y == j->OffPt.Y); + bool isHorizontal = (j->OutPt1->Pt.y == j->OffPt.y); if (isHorizontal && (j->OffPt == j->OutPt1->Pt) && (j->OffPt == j->OutPt2->Pt)) @@ -3431,11 +3431,11 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) op1b = j->OutPt1->Next; while (op1b != op1 && (op1b->Pt == j->OffPt)) op1b = op1b->Next; - bool reverse1 = (op1b->Pt.Y > j->OffPt.Y); + bool reverse1 = (op1b->Pt.y > j->OffPt.y); op2b = j->OutPt2->Next; while (op2b != op2 && (op2b->Pt == j->OffPt)) op2b = op2b->Next; - bool reverse2 = (op2b->Pt.Y > j->OffPt.Y); + bool reverse2 = (op2b->Pt.y > j->OffPt.y); if (reverse1 == reverse2) return false; if (reverse1) { @@ -3467,22 +3467,22 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) //them we're not yet sure where the overlapping is. OutPt1.Pt & OutPt2.Pt //may be anywhere along the horizontal edge. op1b = op1; - while (op1->Prev->Pt.Y == op1->Pt.Y && op1->Prev != op1b && op1->Prev != op2) + while (op1->Prev->Pt.y == op1->Pt.y && op1->Prev != op1b && op1->Prev != op2) op1 = op1->Prev; - while (op1b->Next->Pt.Y == op1b->Pt.Y && op1b->Next != op1 && op1b->Next != op2) + while (op1b->Next->Pt.y == op1b->Pt.y && op1b->Next != op1 && op1b->Next != op2) op1b = op1b->Next; if (op1b->Next == op1 || op1b->Next == op2) return false; //a flat 'polygon' op2b = op2; - while (op2->Prev->Pt.Y == op2->Pt.Y && op2->Prev != op2b && op2->Prev != op1b) + while (op2->Prev->Pt.y == op2->Pt.y && op2->Prev != op2b && op2->Prev != op1b) op2 = op2->Prev; - while (op2b->Next->Pt.Y == op2b->Pt.Y && op2b->Next != op2 && op2b->Next != op1) + while (op2b->Next->Pt.y == op2b->Pt.y && op2b->Next != op2 && op2b->Next != op1) op2b = op2b->Next; if (op2b->Next == op2 || op2b->Next == op1) return false; //a flat 'polygon' cInt Left, Right; //Op1 --> Op1b & Op2 --> Op2b are the extremites of the horizontal edges - if (!GetOverlap(op1->Pt.X, op1b->Pt.X, op2->Pt.X, op2b->Pt.X, Left, Right)) + if (!GetOverlap(op1->Pt.x, op1b->Pt.x, op2->Pt.x, op2b->Pt.x, Left, Right)) return false; //DiscardLeftSide: when overlapping edges are joined, a spike will created @@ -3490,51 +3490,51 @@ bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2) //on the discard Side as either may still be needed for other joins ... IntPoint Pt; bool DiscardLeftSide; - if (op1->Pt.X >= Left && op1->Pt.X <= Right) + if (op1->Pt.x >= Left && op1->Pt.x <= Right) { - Pt = op1->Pt; DiscardLeftSide = (op1->Pt.X > op1b->Pt.X); + Pt = op1->Pt; DiscardLeftSide = (op1->Pt.x > op1b->Pt.x); } - else if (op2->Pt.X >= Left&& op2->Pt.X <= Right) + else if (op2->Pt.x >= Left&& op2->Pt.x <= Right) { - Pt = op2->Pt; DiscardLeftSide = (op2->Pt.X > op2b->Pt.X); + Pt = op2->Pt; DiscardLeftSide = (op2->Pt.x > op2b->Pt.x); } - else if (op1b->Pt.X >= Left && op1b->Pt.X <= Right) + else if (op1b->Pt.x >= Left && op1b->Pt.x <= Right) { - Pt = op1b->Pt; DiscardLeftSide = op1b->Pt.X > op1->Pt.X; + Pt = op1b->Pt; DiscardLeftSide = op1b->Pt.x > op1->Pt.x; } else { - Pt = op2b->Pt; DiscardLeftSide = (op2b->Pt.X > op2->Pt.X); + Pt = op2b->Pt; DiscardLeftSide = (op2b->Pt.x > op2->Pt.x); } j->OutPt1 = op1; j->OutPt2 = op2; return JoinHorz(op1, op1b, op2, op2b, Pt, DiscardLeftSide); } else { //nb: For non-horizontal joins ... - // 1. Jr.OutPt1.Pt.Y == Jr.OutPt2.Pt.Y - // 2. Jr.OutPt1.Pt > Jr.OffPt.Y + // 1. Jr.OutPt1.Pt.y == Jr.OutPt2.Pt.y + // 2. Jr.OutPt1.Pt > Jr.OffPt.y //make sure the polygons are correctly oriented ... op1b = op1->Next; while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Next; - bool Reverse1 = ((op1b->Pt.Y > op1->Pt.Y) || + bool Reverse1 = ((op1b->Pt.y > op1->Pt.y) || !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange)); if (Reverse1) { op1b = op1->Prev; while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Prev; - if ((op1b->Pt.Y > op1->Pt.Y) || + if ((op1b->Pt.y > op1->Pt.y) || !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange)) return false; }; op2b = op2->Next; while ((op2b->Pt == op2->Pt) && (op2b != op2))op2b = op2b->Next; - bool Reverse2 = ((op2b->Pt.Y > op2->Pt.Y) || + bool Reverse2 = ((op2b->Pt.y > op2->Pt.y) || !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange)); if (Reverse2) { op2b = op2->Prev; while ((op2b->Pt == op2->Pt) && (op2b != op2)) op2b = op2b->Prev; - if ((op2b->Pt.Y > op2->Pt.Y) || + if ((op2b->Pt.y > op2->Pt.y) || !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange)) return false; } @@ -3711,11 +3711,11 @@ void Clipper::JoinCommonEdges() DoublePoint GetUnitNormal(const IntPoint &pt1, const IntPoint &pt2) { - if(pt2.X == pt1.X && pt2.Y == pt1.Y) + if(pt2.x == pt1.x && pt2.y == pt1.y) return DoublePoint(0, 0); - double Dx = (double)(pt2.X - pt1.X); - double dy = (double)(pt2.Y - pt1.Y); + double Dx = (double)(pt2.x - pt1.x); + double dy = (double)(pt2.y - pt1.y); double f = 1 *1.0/ std::sqrt( Dx*Dx + dy*dy ); Dx *= f; dy *= f; @@ -3730,7 +3730,7 @@ ClipperOffset::ClipperOffset(double miterLimit, double arcTolerance) { this->MiterLimit = miterLimit; this->ArcTolerance = arcTolerance; - m_lowest.X = -1; + m_lowest.x = -1; } //------------------------------------------------------------------------------ @@ -3745,7 +3745,7 @@ void ClipperOffset::Clear() for (int i = 0; i < m_polyNodes.ChildCount(); ++i) delete m_polyNodes.Childs[i]; m_polyNodes.Childs.clear(); - m_lowest.X = -1; + m_lowest.x = -1; } //------------------------------------------------------------------------------ @@ -3768,9 +3768,9 @@ void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType { j++; newNode->Contour.push_back(path[i]); - if (path[i].Y > newNode->Contour[k].Y || - (path[i].Y == newNode->Contour[k].Y && - path[i].X < newNode->Contour[k].X)) k = j; + if (path[i].y > newNode->Contour[k].y || + (path[i].y == newNode->Contour[k].y && + path[i].x < newNode->Contour[k].x)) k = j; } if (endType == etClosedPolygon && j < 2) { @@ -3781,14 +3781,14 @@ void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType //if this path's lowest pt is lower than all the others then update m_lowest if (endType != etClosedPolygon) return; - if (m_lowest.X < 0) + if (m_lowest.x < 0) m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k); else { - IntPoint ip = m_polyNodes.Childs[(int)m_lowest.X]->Contour[(int)m_lowest.Y]; - if (newNode->Contour[k].Y > ip.Y || - (newNode->Contour[k].Y == ip.Y && - newNode->Contour[k].X < ip.X)) + IntPoint ip = m_polyNodes.Childs[(int)m_lowest.x]->Contour[(int)m_lowest.y]; + if (newNode->Contour[k].y > ip.y || + (newNode->Contour[k].y == ip.y && + newNode->Contour[k].x < ip.x)) m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k); } } @@ -3805,8 +3805,8 @@ void ClipperOffset::FixOrientations() { //fixup orientations of all closed paths if the orientation of the //closed path with the lowermost vertex is wrong ... - if (m_lowest.X >= 0 && - !Orientation(m_polyNodes.Childs[(int)m_lowest.X]->Contour)) + if (m_lowest.x >= 0 && + !Orientation(m_polyNodes.Childs[(int)m_lowest.x]->Contour)) { for (int i = 0; i < m_polyNodes.ChildCount(); ++i) { @@ -3953,8 +3953,8 @@ void ClipperOffset::DoOffset(double delta) for (cInt j = 1; j <= steps; j++) { m_destPoly.push_back(IntPoint( - Round(m_srcPoly[0].X + X * delta), - Round(m_srcPoly[0].Y + Y * delta))); + Round(m_srcPoly[0].x + X * delta), + Round(m_srcPoly[0].y + Y * delta))); double X2 = X; X = X * m_cos - m_sin * Y; Y = X2 * m_sin + Y * m_cos; @@ -3966,8 +3966,8 @@ void ClipperOffset::DoOffset(double delta) for (int j = 0; j < 4; ++j) { m_destPoly.push_back(IntPoint( - Round(m_srcPoly[0].X + X * delta), - Round(m_srcPoly[0].Y + Y * delta))); + Round(m_srcPoly[0].x + X * delta), + Round(m_srcPoly[0].y + Y * delta))); if (X < 0) X = 1; else if (Y < 0) Y = 1; else X = -1; @@ -4003,8 +4003,8 @@ void ClipperOffset::DoOffset(double delta) //re-build m_normals ... DoublePoint n = m_normals[len -1]; for (int j = len - 1; j > 0; j--) - m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y); - m_normals[0] = DoublePoint(-n.X, -n.Y); + m_normals[j] = DoublePoint(-m_normals[j - 1].x, -m_normals[j - 1].y); + m_normals[0] = DoublePoint(-n.x, -n.y); k = 0; for (int j = len - 1; j >= 0; j--) OffsetPoint(j, k, node.m_jointype); @@ -4020,11 +4020,11 @@ void ClipperOffset::DoOffset(double delta) if (node.m_endtype == etOpenButt) { int j = len - 1; - pt1 = IntPoint((cInt)Round(m_srcPoly[j].X + m_normals[j].X * - delta), (cInt)Round(m_srcPoly[j].Y + m_normals[j].Y * delta)); + pt1 = IntPoint((cInt)Round(m_srcPoly[j].x + m_normals[j].x * + delta), (cInt)Round(m_srcPoly[j].y + m_normals[j].y * delta)); m_destPoly.push_back(pt1); - pt1 = IntPoint((cInt)Round(m_srcPoly[j].X - m_normals[j].X * - delta), (cInt)Round(m_srcPoly[j].Y - m_normals[j].Y * delta)); + pt1 = IntPoint((cInt)Round(m_srcPoly[j].x - m_normals[j].x * + delta), (cInt)Round(m_srcPoly[j].y - m_normals[j].y * delta)); m_destPoly.push_back(pt1); } else @@ -4032,7 +4032,7 @@ void ClipperOffset::DoOffset(double delta) int j = len - 1; k = len - 2; m_sinA = 0; - m_normals[j] = DoublePoint(-m_normals[j].X, -m_normals[j].Y); + m_normals[j] = DoublePoint(-m_normals[j].x, -m_normals[j].y); if (node.m_endtype == etOpenSquare) DoSquare(j, k); else @@ -4041,19 +4041,19 @@ void ClipperOffset::DoOffset(double delta) //re-build m_normals ... for (int j = len - 1; j > 0; j--) - m_normals[j] = DoublePoint(-m_normals[j - 1].X, -m_normals[j - 1].Y); - m_normals[0] = DoublePoint(-m_normals[1].X, -m_normals[1].Y); + m_normals[j] = DoublePoint(-m_normals[j - 1].x, -m_normals[j - 1].y); + m_normals[0] = DoublePoint(-m_normals[1].x, -m_normals[1].y); k = len - 1; for (int j = k - 1; j > 0; --j) OffsetPoint(j, k, node.m_jointype); if (node.m_endtype == etOpenButt) { - pt1 = IntPoint((cInt)Round(m_srcPoly[0].X - m_normals[0].X * delta), - (cInt)Round(m_srcPoly[0].Y - m_normals[0].Y * delta)); + pt1 = IntPoint((cInt)Round(m_srcPoly[0].x - m_normals[0].x * delta), + (cInt)Round(m_srcPoly[0].y - m_normals[0].y * delta)); m_destPoly.push_back(pt1); - pt1 = IntPoint((cInt)Round(m_srcPoly[0].X + m_normals[0].X * delta), - (cInt)Round(m_srcPoly[0].Y + m_normals[0].Y * delta)); + pt1 = IntPoint((cInt)Round(m_srcPoly[0].x + m_normals[0].x * delta), + (cInt)Round(m_srcPoly[0].y + m_normals[0].y * delta)); m_destPoly.push_back(pt1); } else @@ -4074,15 +4074,15 @@ void ClipperOffset::DoOffset(double delta) void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype) { //cross product ... - m_sinA = (m_normals[k].X * m_normals[j].Y - m_normals[j].X * m_normals[k].Y); + m_sinA = (m_normals[k].x * m_normals[j].y - m_normals[j].x * m_normals[k].y); if (std::fabs(m_sinA * m_delta) < 1.0) { //dot product ... - double cosA = (m_normals[k].X * m_normals[j].X + m_normals[j].Y * m_normals[k].Y ); + double cosA = (m_normals[k].x * m_normals[j].x + m_normals[j].y * m_normals[k].y ); if (cosA > 0) // angle => 0 degrees { - m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta), - Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta))); + m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + m_normals[k].x * m_delta), + Round(m_srcPoly[j].y + m_normals[k].y * m_delta))); return; } //else angle => 180 degrees @@ -4092,19 +4092,19 @@ void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype) if (m_sinA * m_delta < 0) { - m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[k].X * m_delta), - Round(m_srcPoly[j].Y + m_normals[k].Y * m_delta))); + m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + m_normals[k].x * m_delta), + Round(m_srcPoly[j].y + m_normals[k].y * m_delta))); m_destPoly.push_back(m_srcPoly[j]); - m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * m_delta), - Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta))); + m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + m_normals[j].x * m_delta), + Round(m_srcPoly[j].y + m_normals[j].y * m_delta))); } else switch (jointype) { case jtMiter: { - double r = 1 + (m_normals[j].X * m_normals[k].X + - m_normals[j].Y * m_normals[k].Y); + double r = 1 + (m_normals[j].x * m_normals[k].x + + m_normals[j].y * m_normals[k].y); if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k); break; } @@ -4118,43 +4118,43 @@ void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype) void ClipperOffset::DoSquare(int j, int k) { double dx = std::tan(std::atan2(m_sinA, - m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y) / 4); + m_normals[k].x * m_normals[j].x + m_normals[k].y * m_normals[j].y) / 4); m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + m_delta * (m_normals[k].X - m_normals[k].Y * dx)), - Round(m_srcPoly[j].Y + m_delta * (m_normals[k].Y + m_normals[k].X * dx)))); + Round(m_srcPoly[j].x + m_delta * (m_normals[k].x - m_normals[k].y * dx)), + Round(m_srcPoly[j].y + m_delta * (m_normals[k].y + m_normals[k].x * dx)))); m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + m_delta * (m_normals[j].X + m_normals[j].Y * dx)), - Round(m_srcPoly[j].Y + m_delta * (m_normals[j].Y - m_normals[j].X * dx)))); + Round(m_srcPoly[j].x + m_delta * (m_normals[j].x + m_normals[j].y * dx)), + Round(m_srcPoly[j].y + m_delta * (m_normals[j].y - m_normals[j].x * dx)))); } //------------------------------------------------------------------------------ void ClipperOffset::DoMiter(int j, int k, double r) { double q = m_delta / r; - m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].X + (m_normals[k].X + m_normals[j].X) * q), - Round(m_srcPoly[j].Y + (m_normals[k].Y + m_normals[j].Y) * q))); + m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + (m_normals[k].x + m_normals[j].x) * q), + Round(m_srcPoly[j].y + (m_normals[k].y + m_normals[j].y) * q))); } //------------------------------------------------------------------------------ void ClipperOffset::DoRound(int j, int k) { double a = std::atan2(m_sinA, - m_normals[k].X * m_normals[j].X + m_normals[k].Y * m_normals[j].Y); + m_normals[k].x * m_normals[j].x + m_normals[k].y * m_normals[j].y); int steps = std::max((int)Round(m_StepsPerRad * std::fabs(a)), 1); - double X = m_normals[k].X, Y = m_normals[k].Y, X2; + double X = m_normals[k].x, Y = m_normals[k].y, X2; for (int i = 0; i < steps; ++i) { m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + X * m_delta), - Round(m_srcPoly[j].Y + Y * m_delta))); + Round(m_srcPoly[j].x + X * m_delta), + Round(m_srcPoly[j].y + Y * m_delta))); X2 = X; X = X * m_cos - m_sin * Y; Y = X2 * m_sin + Y * m_cos; } m_destPoly.push_back(IntPoint( - Round(m_srcPoly[j].X + m_normals[j].X * m_delta), - Round(m_srcPoly[j].Y + m_normals[j].Y * m_delta))); + Round(m_srcPoly[j].x + m_normals[j].x * m_delta), + Round(m_srcPoly[j].y + m_normals[j].y * m_delta))); } //------------------------------------------------------------------------------ @@ -4262,8 +4262,8 @@ void SimplifyPolygons(Paths &polys, PolyFillType fillType) inline double DistanceSqrd(const IntPoint& pt1, const IntPoint& pt2) { - double Dx = ((double)pt1.X - pt2.X); - double dy = ((double)pt1.Y - pt2.Y); + double Dx = ((double)pt1.x - pt2.x); + double dy = ((double)pt1.y - pt2.y); return (Dx*Dx + dy*dy); } //------------------------------------------------------------------------------ @@ -4277,10 +4277,10 @@ double DistanceFromLineSqrd( //A = (y¹ - y²); B = (x² - x¹); C = (y² - y¹)x¹ - (x² - x¹)y¹ //perpendicular distance of point (x³,y³) = (Ax³ + By³ + C)/Sqrt(A² + B²) //see http://en.wikipedia.org/wiki/Perpendicular_distance - double A = double(ln1.Y - ln2.Y); - double B = double(ln2.X - ln1.X); - double C = A * ln1.X + B * ln1.Y; - C = A * pt.X + B * pt.Y - C; + double A = double(ln1.y - ln2.y); + double B = double(ln2.x - ln1.x); + double C = A * ln1.x + B * ln1.y; + C = A * pt.x + B * pt.y - C; return (C * C) / (A * A + B * B); } //--------------------------------------------------------------------------- @@ -4291,20 +4291,20 @@ bool SlopesNearCollinear(const IntPoint& pt1, //this function is more accurate when the point that's geometrically //between the other 2 points is the one that's tested for distance. //ie makes it more likely to pick up 'spikes' ... - if (Abs(pt1.X - pt2.X) > Abs(pt1.Y - pt2.Y)) + if (Abs(pt1.x - pt2.x) > Abs(pt1.y - pt2.y)) { - if ((pt1.X > pt2.X) == (pt1.X < pt3.X)) + if ((pt1.x > pt2.x) == (pt1.x < pt3.x)) return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd; - else if ((pt2.X > pt1.X) == (pt2.X < pt3.X)) + else if ((pt2.x > pt1.x) == (pt2.x < pt3.x)) return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd; else return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd; } else { - if ((pt1.Y > pt2.Y) == (pt1.Y < pt3.Y)) + if ((pt1.y > pt2.y) == (pt1.y < pt3.y)) return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd; - else if ((pt2.Y > pt1.Y) == (pt2.Y < pt3.Y)) + else if ((pt2.y > pt1.y) == (pt2.y < pt3.y)) return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd; else return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd; @@ -4314,8 +4314,8 @@ bool SlopesNearCollinear(const IntPoint& pt1, bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd) { - double Dx = (double)pt1.X - pt2.X; - double dy = (double)pt1.Y - pt2.Y; + double Dx = (double)pt1.x - pt2.x; + double dy = (double)pt1.y - pt2.y; return ((Dx * Dx) + (dy * dy) <= distSqrd); } //------------------------------------------------------------------------------ @@ -4423,7 +4423,7 @@ void Minkowski(const Path& poly, const Path& path, Path p; p.reserve(polyCnt); for (size_t j = 0; j < poly.size(); ++j) - p.push_back(IntPoint(path[i].X + poly[j].X, path[i].Y + poly[j].Y)); + p.push_back(IntPoint(path[i].x + poly[j].x, path[i].y + poly[j].y)); pp.push_back(p); } else @@ -4432,7 +4432,7 @@ void Minkowski(const Path& poly, const Path& path, Path p; p.reserve(polyCnt); for (size_t j = 0; j < poly.size(); ++j) - p.push_back(IntPoint(path[i].X - poly[j].X, path[i].Y - poly[j].Y)); + p.push_back(IntPoint(path[i].x - poly[j].x, path[i].y - poly[j].y)); pp.push_back(p); } @@ -4467,7 +4467,7 @@ void TranslatePath(const Path& input, Path& output, const IntPoint delta) //precondition: input != output output.resize(input.size()); for (size_t i = 0; i < input.size(); ++i) - output[i] = IntPoint(input[i].X + delta.X, input[i].Y + delta.Y); + output[i] = IntPoint(input[i].x + delta.x, input[i].y + delta.y); } //------------------------------------------------------------------------------ @@ -4543,7 +4543,7 @@ void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths) std::ostream& operator <<(std::ostream &s, const IntPoint &p) { - s << "(" << p.X << "," << p.Y << ")"; + s << "(" << p.x << "," << p.y << ")"; return s; } //------------------------------------------------------------------------------ @@ -4553,8 +4553,8 @@ std::ostream& operator <<(std::ostream &s, const Path &p) if (p.empty()) return s; Path::size_type last = p.size() -1; for (Path::size_type i = 0; i < last; i++) - s << "(" << p[i].X << "," << p[i].Y << "), "; - s << "(" << p[last].X << "," << p[last].Y << ")\n"; + s << "(" << p[i].x << "," << p[i].y << "), "; + s << "(" << p[last].x << "," << p[last].y << ")\n"; return s; } //------------------------------------------------------------------------------ diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index a9082246c..718871633 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -46,6 +46,14 @@ struct point point(point const& other) = default; point(point && other) noexcept = default; point & operator=(point const& other) = default; + friend inline bool operator== (point const& a, point const& b) + { + return a.x == b.x && a.y == b.y; + } + friend inline bool operator!= (point const& a, point const& b) + { + return a.x != b.x || a.y != b.y; + } value_type x; value_type y; }; @@ -55,6 +63,8 @@ template struct line_string : std::vector > { line_string() = default; + line_string (std::size_t size) + : std::vector >(size) {} line_string (line_string && other) = default ; line_string& operator=(line_string &&) = default; line_string (line_string const& ) = default; @@ -64,7 +74,21 @@ struct line_string : std::vector > }; template -struct linear_ring : line_string {}; +struct linear_ring : line_string +{ + linear_ring() = default; + linear_ring(std::size_t size) + : line_string(size) {} + linear_ring (linear_ring && other) = default ; + linear_ring& operator=(linear_ring &&) = default; + linear_ring(line_string && other) + : line_string(other) {} + linear_ring (linear_ring const& ) = default; + linear_ring(line_string const& other) + : line_string(other) {} + linear_ring& operator=(linear_ring const&) = default; + +}; template struct polygon diff --git a/include/mapnik/geometry_adapters.hpp b/include/mapnik/geometry_adapters.hpp index aebb21db3..fc0c9bb57 100644 --- a/include/mapnik/geometry_adapters.hpp +++ b/include/mapnik/geometry_adapters.hpp @@ -35,14 +35,15 @@ #include #include // +#include #include // register point BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, double, cs::cartesian, x, y) -BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, int, cs::cartesian, x, y) +BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, std::int64_t, cs::cartesian, x, y) // ring BOOST_GEOMETRY_REGISTER_RING(mapnik::geometry::linear_ring) -BOOST_GEOMETRY_REGISTER_RING(mapnik::geometry::linear_ring) +BOOST_GEOMETRY_REGISTER_RING(mapnik::geometry::linear_ring) // needed by box2d BOOST_GEOMETRY_REGISTER_POINT_2D(mapnik::coord2d, double, cs::cartesian, x, y) @@ -56,9 +57,9 @@ struct range_iterator > }; template <> -struct range_iterator > +struct range_iterator > { - using type = mapnik::geometry::line_string::iterator; + using type = mapnik::geometry::line_string::iterator; }; template <> @@ -68,9 +69,9 @@ struct range_const_iterator > }; template <> -struct range_const_iterator > +struct range_const_iterator > { - using type = mapnik::geometry::line_string::const_iterator; + using type = mapnik::geometry::line_string::const_iterator; }; inline mapnik::geometry::line_string::iterator @@ -85,17 +86,17 @@ range_begin(mapnik::geometry::line_string const& line) {return line.begi inline mapnik::geometry::line_string::const_iterator range_end(mapnik::geometry::line_string const& line) {return line.end();} -inline mapnik::geometry::line_string::iterator -range_begin(mapnik::geometry::line_string & line) {return line.begin();} +inline mapnik::geometry::line_string::iterator +range_begin(mapnik::geometry::line_string & line) {return line.begin();} -inline mapnik::geometry::line_string::iterator -range_end(mapnik::geometry::line_string & line) {return line.end();} +inline mapnik::geometry::line_string::iterator +range_end(mapnik::geometry::line_string & line) {return line.end();} -inline mapnik::geometry::line_string::const_iterator -range_begin(mapnik::geometry::line_string const& line) {return line.begin();} +inline mapnik::geometry::line_string::const_iterator +range_begin(mapnik::geometry::line_string const& line) {return line.begin();} -inline mapnik::geometry::line_string::const_iterator -range_end(mapnik::geometry::line_string const& line) {return line.end();} +inline mapnik::geometry::line_string::const_iterator +range_end(mapnik::geometry::line_string const& line) {return line.end();} namespace geometry { namespace traits { @@ -145,7 +146,7 @@ struct tag > }; template<> -struct tag > +struct tag > { using type = linestring_tag; }; @@ -158,7 +159,7 @@ struct tag > }; template<> -struct tag > +struct tag > { using type = polygon_tag; }; @@ -170,7 +171,7 @@ struct point_order > }; template <> -struct point_order > +struct point_order > { static const order_selector value = counterclockwise; }; @@ -182,7 +183,7 @@ struct tag > }; template<> -struct tag > +struct tag > { using type = multi_point_tag; }; @@ -194,7 +195,7 @@ struct tag > }; template<> -struct tag > +struct tag > { using type = multi_linestring_tag; }; @@ -204,7 +205,7 @@ template<> struct tag > using type = multi_polygon_tag; }; -template<> struct tag > +template<> struct tag > { using type = multi_polygon_tag; }; @@ -215,9 +216,9 @@ template<> struct ring_const_type > using type = mapnik::geometry::linear_ring const&; }; -template<> struct ring_const_type > +template<> struct ring_const_type > { - using type = mapnik::geometry::linear_ring const&; + using type = mapnik::geometry::linear_ring const&; }; template<> struct ring_mutable_type > @@ -225,9 +226,9 @@ template<> struct ring_mutable_type > using type = mapnik::geometry::linear_ring&; }; -template<> struct ring_mutable_type > +template<> struct ring_mutable_type > { - using type = mapnik::geometry::linear_ring&; + using type = mapnik::geometry::linear_ring&; }; // interior @@ -241,14 +242,14 @@ template<> struct interior_mutable_type > using type = std::vector >&; }; -template<> struct interior_const_type > +template<> struct interior_const_type > { - using type = std::vector > const&; + using type = std::vector > const&; }; -template<> struct interior_mutable_type > +template<> struct interior_mutable_type > { - using type = std::vector >&; + using type = std::vector >&; }; // exterior @@ -282,29 +283,29 @@ struct interior_rings > }; template<> -struct exterior_ring > +struct exterior_ring > { - static mapnik::geometry::linear_ring & get(mapnik::geometry::polygon & p) + static mapnik::geometry::linear_ring & get(mapnik::geometry::polygon & p) { return p.exterior_ring; } - static mapnik::geometry::linear_ring const& get(mapnik::geometry::polygon const& p) + static mapnik::geometry::linear_ring const& get(mapnik::geometry::polygon const& p) { return p.exterior_ring; } }; template<> -struct interior_rings > +struct interior_rings > { - using holes_type = std::vector >; - static holes_type& get(mapnik::geometry::polygon & p) + using holes_type = std::vector >; + static holes_type& get(mapnik::geometry::polygon & p) { return p.interior_rings; } - static holes_type const& get(mapnik::geometry::polygon const& p) + static holes_type const& get(mapnik::geometry::polygon const& p) { return p.interior_rings; } diff --git a/include/mapnik/geometry_envelope_impl.hpp b/include/mapnik/geometry_envelope_impl.hpp index c4a2e6abe..dbed6aa47 100644 --- a/include/mapnik/geometry_envelope_impl.hpp +++ b/include/mapnik/geometry_envelope_impl.hpp @@ -44,7 +44,8 @@ struct geometry_envelope void operator() (mapnik::geometry::geometry_empty const&) const {} - void operator() (mapnik::geometry::point const& pt) const + template + void operator() (mapnik::geometry::point const& pt) const { if (!bbox.valid()) { @@ -53,7 +54,8 @@ struct geometry_envelope bbox.expand_to_include(pt.x, pt.y); } - void operator() (mapnik::geometry::line_string const& line) const + template + void operator() (mapnik::geometry::line_string const& line) const { bool first = true; for (auto const& pt : line) @@ -70,7 +72,8 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::polygon const& poly) const + template + void operator() (mapnik::geometry::polygon const& poly) const { bool first = true; for (auto const& pt : poly.exterior_ring) @@ -87,7 +90,8 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::multi_point const& multi_point) const + template + void operator() (mapnik::geometry::multi_point const& multi_point) const { bool first = true; for (auto const& pt : multi_point) @@ -104,7 +108,8 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::multi_line_string const& multi_line) const + template + void operator() (mapnik::geometry::multi_line_string const& multi_line) const { for (auto const& line : multi_line) { @@ -112,7 +117,8 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::multi_polygon const& multi_poly) const + template + void operator() (mapnik::geometry::multi_polygon const& multi_poly) const { for (auto const& poly : multi_poly) { @@ -120,7 +126,8 @@ struct geometry_envelope } } - void operator() (mapnik::geometry::geometry_collection const& collection) const + template + void operator() (mapnik::geometry::geometry_collection const& collection) const { for (auto const& geom : collection) { diff --git a/include/mapnik/geometry_fusion_adapted.hpp b/include/mapnik/geometry_fusion_adapted.hpp index 4dad27e7d..6889de61f 100644 --- a/include/mapnik/geometry_fusion_adapted.hpp +++ b/include/mapnik/geometry_fusion_adapted.hpp @@ -34,9 +34,20 @@ BOOST_FUSION_ADAPT_STRUCT( (double, y) ) +BOOST_FUSION_ADAPT_STRUCT( + mapnik::geometry::point, + (std::int64_t, x) + (std::int64_t, y) +) + BOOST_FUSION_ADAPT_STRUCT( mapnik::geometry::polygon, (mapnik::geometry::linear_ring const&, exterior_ring) (std::vector > const& , interior_rings)) +BOOST_FUSION_ADAPT_STRUCT( + mapnik::geometry::polygon, + (mapnik::geometry::linear_ring const&, exterior_ring) + (std::vector > const& , interior_rings)) + #endif // MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP diff --git a/include/mapnik/geometry_strategy.hpp b/include/mapnik/geometry_strategy.hpp index 13a70e171..209292792 100644 --- a/include/mapnik/geometry_strategy.hpp +++ b/include/mapnik/geometry_strategy.hpp @@ -23,6 +23,8 @@ #ifndef MAPNIK_GEOMETRY_STRATEGY_HPP #define MAPNIK_GEOMETRY_STRATEGY_HPP +#include + namespace mapnik { namespace geometry { diff --git a/include/mapnik/geometry_transform.hpp b/include/mapnik/geometry_transform.hpp index 6bb320404..5a0c263d8 100644 --- a/include/mapnik/geometry_transform.hpp +++ b/include/mapnik/geometry_transform.hpp @@ -29,6 +29,72 @@ namespace mapnik { namespace geometry { namespace detail { +template +inline point transform_geometry(point const& geom, Transformer const& transformer) +{ + point geom_transformed; + if (!boost::geometry::transform(geom, geom_transformed, transformer)) + { + throw std::runtime_error("Can't transformm geometry"); + } + return geom_transformed; +} + +template +inline multi_point transform_geometry(multi_point const& geom, Transformer const& transformer) +{ + multi_point geom_transformed; + if (!boost::geometry::transform(geom, geom_transformed, transformer)) + { + throw std::runtime_error("Can't transformm geometry"); + } + return geom_transformed; +} + +template +inline line_string transform_geometry(line_string const& geom, Transformer const& transformer) +{ + line_string geom_transformed; + if (!boost::geometry::transform(geom, geom_transformed, transformer)) + { + throw std::runtime_error("Can't transformm geometry"); + } + return geom_transformed; +} + +template +inline multi_line_string transform_geometry(multi_line_string const& geom, Transformer const& transformer) +{ + multi_line_string geom_transformed; + if (!boost::geometry::transform(geom, geom_transformed, transformer)) + { + throw std::runtime_error("Can't transformm geometry"); + } + return geom_transformed; +} + +template +inline polygon transform_geometry(polygon const& geom, Transformer const& transformer) +{ + polygon geom_transformed; + if (!boost::geometry::transform(geom, geom_transformed, transformer)) + { + throw std::runtime_error("Can't transformm geometry"); + } + return geom_transformed; +} + +template +inline multi_polygon transform_geometry(multi_polygon const& geom, Transformer const& transformer) +{ + multi_polygon geom_transformed; + if (!boost::geometry::transform(geom, geom_transformed, transformer)) + { + throw std::runtime_error("Can't transformm geometry"); + } + return geom_transformed; +} + template struct geometry_transform { @@ -62,91 +128,93 @@ struct geometry_transform template geometry operator() (point const& geom) const { - point geom_transformed; - if (!boost::geometry::transform(geom, geom_transformed, transformer_)) - { - throw std::runtime_error("Can't transformm geometry"); - } - return geom_transformed; + return std::move(transform_geometry(geom, transformer_)); } template geometry operator() (line_string const& geom) const { - line_string geom_transformed; - if (!boost::geometry::transform(geom, geom_transformed, transformer_)) - { - throw std::runtime_error("Can't transformm geometry"); - } - return geom_transformed; + return std::move(transform_geometry(geom, transformer_)); } template geometry operator() (polygon const& geom) const { - polygon geom_transformed; - if (!boost::geometry::transform(geom, geom_transformed, transformer_)) - { - throw std::runtime_error("Can't transformm geometry"); - } - return geom_transformed; + return std::move(transform_geometry(geom, transformer_)); } template geometry operator() (multi_point const& geom) const { - multi_point geom_transformed; - if (!boost::geometry::transform(geom, geom_transformed, transformer_)) - { - throw std::runtime_error("Can't transformm geometry"); - } - return geom_transformed; + return std::move(transform_geometry(geom, transformer_)); } template geometry operator() (multi_line_string const& geom) const { - multi_line_string geom_transformed; - if (!boost::geometry::transform(geom, geom_transformed, transformer_)) - { - throw std::runtime_error("Can't transformm geometry"); - } - return geom_transformed; + return std::move(transform_geometry(geom, transformer_)); } template geometry operator() (multi_polygon const& geom) const { - multi_polygon geom_transformed; - if (!boost::geometry::transform(geom, geom_transformed, transformer_)) - { - throw std::runtime_error("Can't transformm geometry"); - } - return geom_transformed; + return std::move(transform_geometry(geom, transformer_)); } - /*template - geometry operator() (T const& geom) const - { - using geometry_type = T; - geometry_type geom_transformed; - if (!boost::geometry::transform(geom, geom_transformed, transformer_)) - { - throw std::runtime_error("Can't transformm geometry"); - } - return geom_transformed; - }*/ Transformer const& transformer_; }; } // ns detail template -geometry transform(T1 const& geom, T2 const& transformer) +geometry transform(geometry const& geom, T2 const& transformer) { return detail::geometry_transform(transformer)(geom); } +template +geometry transform(geometry_collection const& geom, T2 const& transformer) +{ + return detail::geometry_transform(transformer)(geom); +} + +template +point transform(point const& geom, T2 const& transformer) +{ + return detail::transform_geometry(geom, transformer); +} + +template +multi_point transform(multi_point const& geom, T2 const& transformer) +{ + return detail::transform_geometry(geom, transformer); +} + +template +line_string transform(line_string const& geom, T2 const& transformer) +{ + return detail::transform_geometry(geom, transformer); +} + +template +multi_line_string transform(multi_line_string const& geom, T2 const& transformer) +{ + return detail::transform_geometry(geom, transformer); +} + +template +polygon transform(polygon const& geom, T2 const& transformer) +{ + return detail::transform_geometry(geom, transformer); +} + +template +multi_polygon transform(multi_polygon const& geom, T2 const& transformer) +{ + return detail::transform_geometry(geom, transformer); +} + + }} #endif // MAPNIK_GEOMETRY_TRANSFORM_HPP diff --git a/include/mapnik/geometry_type.hpp b/include/mapnik/geometry_type.hpp index 823fa3925..b052446cd 100644 --- a/include/mapnik/geometry_type.hpp +++ b/include/mapnik/geometry_type.hpp @@ -42,37 +42,44 @@ struct geometry_type return mapnik::geometry::geometry_types::Unknown; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::point const&) const + template + mapnik::geometry::geometry_types operator () (mapnik::geometry::point const&) const { return mapnik::geometry::geometry_types::Point; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::line_string const&) const + template + mapnik::geometry::geometry_types operator () (mapnik::geometry::line_string const&) const { return mapnik::geometry::geometry_types::LineString; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::polygon const&) const + template + mapnik::geometry::geometry_types operator () (mapnik::geometry::polygon const&) const { return mapnik::geometry::geometry_types::Polygon; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_point const&) const + template + mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_point const&) const { return mapnik::geometry::geometry_types::MultiPoint; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_line_string const&) const + template + mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_line_string const&) const { return mapnik::geometry::geometry_types::MultiLineString; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_polygon const&) const + template + mapnik::geometry::geometry_types operator () (mapnik::geometry::multi_polygon const&) const { return mapnik::geometry::geometry_types::MultiPolygon; } - mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry_collection const&) const + template + mapnik::geometry::geometry_types operator () (mapnik::geometry::geometry_collection const&) const { return mapnik::geometry::geometry_types::GeometryCollection; } diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp index e9ff5a54b..2c1b06da9 100644 --- a/include/mapnik/proj_transform.hpp +++ b/include/mapnik/proj_transform.hpp @@ -26,9 +26,7 @@ // mapnik #include #include - -// boost -#include +#include namespace mapnik { @@ -121,6 +119,55 @@ struct proj_strategy proj_transform const& prj_trans_; }; +struct proj_backward_strategy +{ + proj_backward_strategy(proj_transform const& prj_trans) + : prj_trans_(prj_trans) {} + + template + inline bool apply(P1 const& p1, P2 & p2) const + { + using p2_type = typename boost::geometry::coordinate_type::type; + double x = boost::geometry::get<0>(p1); + double y = boost::geometry::get<1>(p1); + double z = 0.0; + if (!prj_trans_.backward(x, y, z)) return false; + try { + boost::geometry::set<0>(p2, boost::numeric_cast(x)); + } + catch(boost::numeric::negative_overflow&) + { + boost::geometry::set<0>(p2, std::numeric_limits::min()); + } + catch(boost::numeric::positive_overflow&) + { + boost::geometry::set<0>(p2, std::numeric_limits::max()); + } + try { + boost::geometry::set<1>(p2, boost::numeric_cast(y)); + } + catch(boost::numeric::negative_overflow&) + { + boost::geometry::set<1>(p2, std::numeric_limits::min()); + } + catch(boost::numeric::positive_overflow&) + { + boost::geometry::set<1>(p2, std::numeric_limits::max()); + } + return true; + } + + template + inline P2 execute(P1 const& p1, bool & status) const + { + P2 p2; + status = apply(p1, p2); + return p2; + } + + proj_transform const& prj_trans_; +}; + } #endif // MAPNIK_PROJ_TRANSFORM_HPP diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index cca17e1dc..0e65d7c1b 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -35,7 +35,15 @@ namespace mapnik { namespace util { inline bool to_wkt(std::string & wkt, mapnik::geometry::geometry const& geom) { using sink_type = std::back_insert_iterator; - static const mapnik::wkt::wkt_generator_grammar > generator; + static const mapnik::wkt::wkt_generator_grammar, double > generator; + sink_type sink(wkt); + return boost::spirit::karma::generate(sink, generator, geom); +} + +inline bool to_wkt(std::string & wkt, mapnik::geometry::geometry const& geom) +{ + using sink_type = std::back_insert_iterator; + static const mapnik::wkt::wkt_generator_grammar_int, std::int64_t > generator; sink_type sink(wkt); return boost::spirit::karma::generate(sink, generator, geom); } diff --git a/include/mapnik/util/spirit_transform_attribute.hpp b/include/mapnik/util/spirit_transform_attribute.hpp index c613774c1..1c0bdac54 100644 --- a/include/mapnik/util/spirit_transform_attribute.hpp +++ b/include/mapnik/util/spirit_transform_attribute.hpp @@ -115,6 +115,94 @@ namespace boost { namespace spirit { namespace traits { } }; + template <> + struct transform_attribute const, + mapnik::geometry::point const&, karma::domain> + { + using type = mapnik::geometry::point const&; + static type pre(mapnik::geometry::geometry const& geom) + { + return mapnik::util::get >(geom); + } + }; + + template <> + struct transform_attribute const, + mapnik::geometry::line_string const&, karma::domain> + { + using type = mapnik::geometry::line_string const&; + static type pre(mapnik::geometry::geometry const& geom) + { + return mapnik::util::get >(geom); + } + }; + + template <> + struct transform_attribute const, + mapnik::geometry::polygon const&, karma::domain> + { + using type = mapnik::geometry::polygon const&; + static type pre(mapnik::geometry::geometry const& geom) + { + return mapnik::util::get >(geom); + } + }; + + template <> + struct transform_attribute const, + std::vector > const&, karma::domain> + { + using type = std::vector > const&; + static type pre(mapnik::geometry::polygon const& poly) + { + return poly.interior_rings; + } + }; + + template <> + struct transform_attribute const, + mapnik::geometry::multi_point const&, karma::domain> + { + using type = mapnik::geometry::multi_point const&; + static type pre(mapnik::geometry::geometry const& geom) + { + return mapnik::util::get >(geom); + } + }; + + template <> + struct transform_attribute const, + mapnik::geometry::multi_line_string const&, karma::domain> + { + using type = mapnik::geometry::multi_line_string const&; + static type pre(mapnik::geometry::geometry const& geom) + { + return mapnik::util::get >(geom); + } + }; + + template <> + struct transform_attribute const, + mapnik::geometry::multi_polygon const&, karma::domain> + { + using type = mapnik::geometry::multi_polygon const&; + static type pre(mapnik::geometry::geometry const& geom) + { + return mapnik::util::get >(geom); + } + }; + + template <> + struct transform_attribute const, + mapnik::geometry::geometry_collection const&, karma::domain> + { + using type = mapnik::geometry::geometry_collection const&; + static type pre(mapnik::geometry::geometry const& geom) + { + return mapnik::util::get >(geom); + } + }; + }}} #endif // MAPNIK_UTIL_SPIRIT_TRANSFORM_ATTRIBUTE_HPP diff --git a/include/mapnik/wkt/wkt_generator_grammar.hpp b/include/mapnik/wkt/wkt_generator_grammar.hpp index 1138a3ad4..fc8e7003a 100644 --- a/include/mapnik/wkt/wkt_generator_grammar.hpp +++ b/include/mapnik/wkt/wkt_generator_grammar.hpp @@ -85,9 +85,10 @@ struct wkt_coordinate_policy : karma::real_policies return base_type::fraction_part(sink, n, adjprec, precision); } }; + } -template +template struct wkt_generator_grammar : karma::grammar { @@ -95,26 +96,56 @@ struct wkt_generator_grammar : // rules karma::rule geometry; karma::rule, Geometry const&() > geometry_dispatch; - karma::rule const&()> point; - karma::rule const&()> point_coord; - karma::rule const&()> linestring; - karma::rule const&()> linestring_coord; - karma::rule const&()> polygon; - karma::rule const&()> polygon_coord; - karma::rule const&()> exterior_ring_coord; - karma::rule > const&()> interior_ring_coord; - karma::rule const& ()> multi_point; - karma::rule const& ()> multi_point_coord; - karma::rule const& ()> multi_linestring; - karma::rule const& ()> multi_linestring_coord; - karma::rule const& ()> multi_polygon; - karma::rule const& ()> multi_polygon_coord; - karma::rule const& ()> geometry_collection; - karma::rule const& ()> geometries; + karma::rule const&()> point; + karma::rule const&()> point_coord; + karma::rule const&()> linestring; + karma::rule const&()> linestring_coord; + karma::rule const&()> polygon; + karma::rule const&()> polygon_coord; + karma::rule const&()> exterior_ring_coord; + karma::rule > const&()> interior_ring_coord; + karma::rule const& ()> multi_point; + karma::rule const& ()> multi_point_coord; + karma::rule const& ()> multi_linestring; + karma::rule const& ()> multi_linestring_coord; + karma::rule const& ()> multi_polygon; + karma::rule const& ()> multi_polygon_coord; + karma::rule const& ()> geometry_collection; + karma::rule const& ()> geometries; boost::phoenix::function > geometry_type; karma::symbols empty; // - karma::real_generator > coordinate; + karma::real_generator > coordinate; +}; + +template +struct wkt_generator_grammar_int : + karma::grammar +{ + wkt_generator_grammar_int(); + // rules + karma::rule geometry; + karma::rule, Geometry const&() > geometry_dispatch; + karma::rule const&()> point; + karma::rule const&()> point_coord; + karma::rule const&()> linestring; + karma::rule const&()> linestring_coord; + karma::rule const&()> polygon; + karma::rule const&()> polygon_coord; + karma::rule const&()> exterior_ring_coord; + karma::rule > const&()> interior_ring_coord; + karma::rule const& ()> multi_point; + karma::rule const& ()> multi_point_coord; + karma::rule const& ()> multi_linestring; + karma::rule const& ()> multi_linestring_coord; + karma::rule const& ()> multi_polygon; + karma::rule const& ()> multi_polygon_coord; + karma::rule const& ()> geometry_collection; + karma::rule const& ()> geometries; + boost::phoenix::function > geometry_type; + karma::symbols empty; + // + karma::int_generator coordinate; }; }} diff --git a/include/mapnik/wkt/wkt_generator_grammar_impl.hpp b/include/mapnik/wkt/wkt_generator_grammar_impl.hpp index 7205db6d8..64624b29e 100644 --- a/include/mapnik/wkt/wkt_generator_grammar_impl.hpp +++ b/include/mapnik/wkt/wkt_generator_grammar_impl.hpp @@ -28,8 +28,8 @@ namespace mapnik { namespace wkt { -template -wkt_generator_grammar::wkt_generator_grammar() +template +wkt_generator_grammar::wkt_generator_grammar() : wkt_generator_grammar::base_type(geometry) { boost::spirit::karma::_val_type _val; @@ -113,4 +113,89 @@ wkt_generator_grammar::wkt_generator_grammar() } +template +wkt_generator_grammar_int::wkt_generator_grammar_int() + : wkt_generator_grammar_int::base_type(geometry) +{ + boost::spirit::karma::_val_type _val; + boost::spirit::karma::_1_type _1; + boost::spirit::karma::_a_type _a; + boost::spirit::karma::lit_type lit; + boost::spirit::karma::uint_type uint_; + boost::spirit::karma::eps_type eps; + + empty.add + (geometry::geometry_types::Point, "POINT EMPTY") + (geometry::geometry_types::LineString, "LINESTRING EMPTY") + (geometry::geometry_types::Polygon, "POLYGON EMPTY") + (geometry::geometry_types::MultiPoint, "MULTIPOINT EMPTY") + (geometry::geometry_types::MultiLineString, "MULTILINESTRING EMPTY") + (geometry::geometry_types::MultiPolygon, "MULTIPOLYGON EMPTY") + (geometry::geometry_types::GeometryCollection, "GEOMETRYCOLLECTION EMPTY") + ; + + geometry = geometry_dispatch.alias() + ; + + geometry_dispatch = eps[_a = geometry_type(_val)] << + (&uint_(geometry::geometry_types::Point)[_1 = _a] + << point) + | + (&uint_(geometry::geometry_types::LineString)[_1 = _a] + << (linestring | empty[_1 = _a])) + | + (&uint_(geometry::geometry_types::Polygon)[_1 = _a] + << (polygon | empty[_1 = _a])) + | + (&uint_(geometry::geometry_types::MultiPoint)[_1 = _a] + << ( multi_point | empty[_1 = _a])) + | + (&uint_(geometry::geometry_types::MultiLineString)[_1 = _a] + << (multi_linestring | empty[_1 = _a])) + | + (&uint_(geometry::geometry_types::MultiPolygon)[_1 = _a] + << (multi_polygon | empty[_1 = _a])) + | + (&uint_(geometry::geometry_types::GeometryCollection)[_1 = _a] + << (geometry_collection | empty[_1 = _a])) + | + (&uint_(geometry::geometry_types::Unknown)[_1 = _a] + << lit("POINT EMPTY")) // special case for geometry_empty as mapnik::geometry::point can't be empty + ; + + point = lit("POINT(") << point_coord << lit(")") + ; + linestring = lit("LINESTRING(") << linestring_coord << lit(")") + ; + polygon = lit("POLYGON(") << polygon_coord << lit(")") + ; + multi_point = lit("MULTIPOINT(") << multi_point_coord << lit(")") + ; + multi_linestring = lit("MULTILINESTRING(") << multi_linestring_coord << lit(")") + ; + multi_polygon = lit("MULTIPOLYGON(") << multi_polygon_coord << lit(")") + ; + geometry_collection = lit("GEOMETRYCOLLECTION(") << geometries << lit(")") + ; + point_coord = coordinate << lit(' ') << coordinate + ; + linestring_coord = point_coord % lit(',') + ; + polygon_coord = lit('(') << exterior_ring_coord << lit(')') << interior_ring_coord + ; + exterior_ring_coord = linestring_coord.alias() + ; + interior_ring_coord = *(lit(",(") << exterior_ring_coord << lit(')')) + ; + multi_point_coord = linestring_coord.alias() + ; + multi_linestring_coord = (lit('(') << linestring_coord << lit(')')) % lit(',') + ; + multi_polygon_coord = (lit('(') << polygon_coord << lit(')')) % lit(',') + ; + geometries = geometry % lit(',') + ; + +} + }} diff --git a/src/geometry_envelope.cpp b/src/geometry_envelope.cpp index 0b7b61c6b..0aa3466f1 100644 --- a/src/geometry_envelope.cpp +++ b/src/geometry_envelope.cpp @@ -37,5 +37,14 @@ template MAPNIK_DECL mapnik::box2d envelope(multi_line_string co template MAPNIK_DECL mapnik::box2d envelope(multi_polygon const& geom); template MAPNIK_DECL mapnik::box2d envelope(geometry_collection const& geom); +template MAPNIK_DECL mapnik::box2d envelope(geometry const& geom); +template MAPNIK_DECL mapnik::box2d envelope(point const& geom); +template MAPNIK_DECL mapnik::box2d envelope(line_string const& geom); +template MAPNIK_DECL mapnik::box2d envelope(polygon const& geom); +template MAPNIK_DECL mapnik::box2d envelope(multi_point const& geom); +template MAPNIK_DECL mapnik::box2d envelope(multi_line_string const& geom); +template MAPNIK_DECL mapnik::box2d envelope(multi_polygon const& geom); +template MAPNIK_DECL mapnik::box2d envelope(geometry_collection const& geom); + } // end ns geometry } // end ns mapnik diff --git a/src/wkt/mapnik_wkt_generator_grammar.cpp b/src/wkt/mapnik_wkt_generator_grammar.cpp index 15606d5eb..780c08a85 100644 --- a/src/wkt/mapnik_wkt_generator_grammar.cpp +++ b/src/wkt/mapnik_wkt_generator_grammar.cpp @@ -27,6 +27,7 @@ namespace mapnik { namespace wkt { using sink_type = std::back_insert_iterator; -template struct wkt_generator_grammar >; +template struct wkt_generator_grammar, double >; +template struct wkt_generator_grammar_int, std::int64_t >; }} diff --git a/tests/cxx/geometry_strategy_test.cpp b/tests/cxx/geometry_strategy_test.cpp index f13c335e8..f59a72f1d 100644 --- a/tests/cxx/geometry_strategy_test.cpp +++ b/tests/cxx/geometry_strategy_test.cpp @@ -26,9 +26,7 @@ SECTION("proj and view strategy") { // Test first that proj strategy works properly point p1(-97.553098,35.523105); point r1(-1.08596e+07, 4.2352e+06); - geometry p2 = transform(p1, ps); - REQUIRE(p2.is >()); - point p3 = mapnik::util::get >(p2); + point p3 = transform(p1, ps); //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } @@ -36,9 +34,7 @@ SECTION("proj and view strategy") { // Test next that view_strategy works point p1(-1.08596e+07, 4.2352e+06); point r1(58.6287 , 100.945); - geometry p2 = transform(p1, vs); - REQUIRE(p2.is >()); - point p3 = mapnik::util::get >(p2); + point p3 = transform(p1, vs); //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); @@ -49,9 +45,7 @@ SECTION("proj and view strategy") { point r1(58.6287 , 100.945); using sg_type = strategy_group; sg_type sg(vs); - geometry p2 = transform(p1, sg); - REQUIRE(p2.is >()); - point p3 = mapnik::util::get >(p2); + point p3 = transform(p1, sg); //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); @@ -62,9 +56,7 @@ SECTION("proj and view strategy") { sg_type sg(ps, vs); point p1(-97.553098,35.523105); point r1(58.6287 , 100.945); - geometry p2 = transform(p1, sg); - REQUIRE(p2.is >()); - point p3 = mapnik::util::get >(p2); + point p3 = transform(p1, sg); //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } @@ -85,10 +77,10 @@ SECTION("proj and view strategy") { using sg_type = strategy_group; sg_type sg(ps, vs); geometry p1(std::move(point(-97.553098,35.523105))); - point r1(58 , 100); - geometry p2 = transform(p1, sg); - REQUIRE(p2.is >()); - point p3 = mapnik::util::get >(p2); + point r1(58 , 100); + geometry p2 = transform(p1, sg); + REQUIRE(p2.is >()); + point p3 = mapnik::util::get >(p2); //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } @@ -98,10 +90,10 @@ SECTION("proj and view strategy") { using sg_type = strategy_group; sg_type sg(ps, vs, ss); geometry p1(std::move(point(-97.553098,35.523105))); - point r1(938 , 1615); - geometry p2 = transform(p1, sg); - REQUIRE(p2.is >()); - point p3 = mapnik::util::get >(p2); + point r1(938 , 1615); + geometry p2 = transform(p1, sg); + REQUIRE(p2.is >()); + point p3 = mapnik::util::get >(p2); //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); } @@ -110,12 +102,12 @@ SECTION("proj and view strategy") { mapnik::geometry::scale_strategy ss(1.0/16.0); using sg_type = strategy_group_first; sg_type sg(ss, uvs, ps_rev); - geometry p1(std::move(point(938 , 1615))); + geometry p1(std::move(point(938 , 1615))); point r1(-97.5586 , 35.5322); geometry p2 = transform(p1, sg); REQUIRE(p2.is >()); point p3 = mapnik::util::get >(p2); - std::cout << p3.x << " , " << p3.y << std::endl; + //std::cout << p3.x << " , " << p3.y << std::endl; assert_g_equal(r1, p3); }