diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index cbe54a064..9f1681007 100644 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -156,7 +156,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; @@ -169,7 +169,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; @@ -201,26 +201,26 @@ 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 && ((ipNext.X == pt.X) || (ip.Y == pt.Y && ((ipNext.X > pt.X) == (ip.X < pt.X))))) + if (ipNext.y() == pt.y() && ((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; } } } @@ -238,29 +238,29 @@ int PointInPolygon (const IntPoint &pt, OutPt *op) OutPt* startOp = op; do { - 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; } } } @@ -304,100 +304,100 @@ inline bool SlopesEqual(const cInt dx1, const cInt dy1, const cInt dx2, const cI #endif inline bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range) - { return SlopesEqual(e1.Delta.X, e1.Delta.Y, e2.Delta.X, e2.Delta.Y, UseFullInt64Range); } + { return SlopesEqual(e1.Delta.x(), e1.Delta.y(), e2.Delta.x(), e2.Delta.y(), UseFullInt64Range); } inline bool SlopesEqual(const IntPoint &pt1, const IntPoint &pt2, const IntPoint &pt3, bool UseFullInt64Range) - { return SlopesEqual(pt1.X-pt2.X, pt1.Y-pt2.Y, pt2.X-pt3.X, pt2.Y-pt3.Y, UseFullInt64Range); } + { return SlopesEqual(pt1.x()-pt2.x(), pt1.y()-pt2.y(), pt2.x()-pt3.x(), pt2.y()-pt3.y(), UseFullInt64Range); } inline bool SlopesEqual(const IntPoint &pt1, const IntPoint &pt2, const IntPoint &pt3, const IntPoint &pt4, bool UseFullInt64Range) - { return SlopesEqual(pt1.X-pt2.X, pt1.Y-pt2.Y, pt3.X-pt4.X, pt3.Y-pt4.Y, UseFullInt64Range); } + { return SlopesEqual(pt1.x()-pt2.x(), pt1.y()-pt2.y(), pt3.x()-pt4.x(), pt3.y()-pt4.y(), UseFullInt64Range); } //------------------------------------------------------------------------------ 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 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())); } //------------------------------------------------------------------------------ void IntersectPoint(TEdge &Edge1, TEdge &Edge2, IntPoint &ip) { #ifdef use_xyz - ip.Z = 0; + ip.z() = 0; #endif 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 = double(Edge1.Bot.X) - double(Edge1.Bot.Y) * Edge1.Dx; - b2 = double(Edge2.Bot.X) - double(Edge2.Bot.Y) * Edge2.Dx; + b1 = double(Edge1.Bot.x()) - double(Edge1.Bot.y()) * Edge1.Dx; + b2 = double(Edge2.Bot.x()) - double(Edge2.Bot.y()) * Edge2.Dx; double q = (b2-b1) / (Edge1.Dx - Edge2.Dx); - ip.Y = Round(q); - ip.X = (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx)) ? + ip.y() = Round(q); + ip.x() = (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx)) ? Round(Edge1.Dx * q + b1) : 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()); } } //------------------------------------------------------------------------------ @@ -429,7 +429,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; @@ -439,11 +439,11 @@ void InitEdge2(TEdge& e, PolyType Pt) e.Bot = e.Next->Curr; } - 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(); e.PolyTyp = Pt; } @@ -466,9 +466,9 @@ 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); + std::swap(e.Top.z(), e.Bot.z()); #endif } //------------------------------------------------------------------------------ @@ -477,20 +477,20 @@ bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a, IntPoint pt2b, IntPoint &pt1, IntPoint &pt2) { //precondition: segments are Collinear. - if (std::abs(pt1a.X - pt1b.X) > std::abs(pt1a.Y - pt1b.Y)) + if (std::abs(pt1a.x() - pt1b.x()) > std::abs(pt1a.y() - pt1b.y())) { - if (pt1a.X > pt1b.X) std::swap(pt1a, pt1b); - if (pt2a.X > pt2b.X) std::swap(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()) std::swap(pt1a, pt1b); + if (pt2a.x() > pt2b.x()) std::swap(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) std::swap(pt1a, pt1b); - if (pt2a.Y < pt2b.Y) std::swap(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()) std::swap(pt1a, pt1b); + if (pt2a.y() < pt2b.y()) std::swap(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(); } } //------------------------------------------------------------------------------ @@ -521,14 +521,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; @@ -558,10 +558,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()); } //------------------------------------------------------------------------------ @@ -582,10 +582,10 @@ inline 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 clipperException("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); @@ -605,8 +605,8 @@ inline 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; @@ -625,14 +625,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; } @@ -649,7 +649,7 @@ TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward) else E = Result->Prev; LocalMinimum locMin; - locMin.Y = E->Bot.Y; + locMin.Y = E->Bot.y(); locMin.LeftBound = 0; locMin.RightBound = E; E->WindDelta = 0; @@ -672,17 +672,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) { @@ -691,38 +691,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 } @@ -887,7 +887,7 @@ bool ClipperBase::AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, b { 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); @@ -903,14 +903,14 @@ bool ClipperBase::AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, b } E->Prev->OutIdx = Skip; LocalMinimum 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; @@ -937,7 +937,7 @@ bool ClipperBase::AddPathInternal(const Path &pg, int highI, PolyType PolyTyp, b //E and E.Prev now share a local minima (left aligned if horizontal). //Compare their slopes to find which starts which bound ... LocalMinimum locMin; - locMin.Y = E->Bot.Y; + locMin.Y = E->Bot.y(); if (E->Dx < E->Prev->Dx) { locMin.LeftBound = E->Prev; @@ -1028,27 +1028,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; } @@ -1454,7 +1454,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)) { @@ -1540,7 +1540,7 @@ void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) SetWindingCount(*lb); if (IsContributing(*lb)) Op1 = AddOutPt(lb, lb->Bot); - m_Scanbeam.push(lb->Top.Y); + m_Scanbeam.push(lb->Top.y()); } else { @@ -1551,13 +1551,13 @@ void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) rb->WindCnt2 = lb->WindCnt2; if (IsContributing(*lb)) Op1 = AddLocalMinPoly(lb, rb, lb->Bot); - m_Scanbeam.push(lb->Top.Y); + m_Scanbeam.push(lb->Top.y()); } if (rb) { if(IsHorizontal(*rb)) AddEdgeToSEL(rb); - else m_Scanbeam.push(rb->Top.Y); + else m_Scanbeam.push(rb->Top.y()); } if (!lb || !rb) continue; @@ -1569,12 +1569,12 @@ void Clipper::InsertLocalMinimaIntoAEL(const cInt botY) for (Join &jr : m_GhostJoins) //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())) m_Joins.emplace_back(Join(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)) @@ -1640,11 +1640,11 @@ void Clipper::DeleteFromSEL(TEdge *e) #ifdef use_xyz void Clipper::SetZ(IntPoint& pt, TEdge& e1, TEdge& e2) { - if (pt.Z != 0 || !m_ZFill) return; - else if (pt == e1.Bot) pt.Z = e1.Bot.Z; - else if (pt == e1.Top) pt.Z = e1.Top.Z; - else if (pt == e2.Bot) pt.Z = e2.Bot.Z; - else if (pt == e2.Top) pt.Z = e2.Top.Z; + if (pt.z() != 0 || !m_ZFill) return; + else if (pt == e1.Bot) pt.z() = e1.Bot.z(); + else if (pt == e1.Top) pt.z() = e1.Top.z(); + else if (pt == e2.Bot) pt.z() = e2.Bot.z(); + else if (pt == e2.Top) pt.z() = e2.Top.z(); else m_ZFill(e1.Bot, e1.Top, e2.Bot, e2.Top, pt); } //------------------------------------------------------------------------------ @@ -1872,10 +1872,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; @@ -2081,13 +2081,13 @@ void Clipper::ProcessHorizontals() 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; } //------------------------------------------------------------------------------ @@ -2202,15 +2202,15 @@ void Clipper::SwapPositionsInSEL(TEdge *Edge1, TEdge *Edge2) inline 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; } } @@ -2219,8 +2219,8 @@ inline void GetHorzDirection(TEdge& HorzEdge, Direction& Dir, cInt& Left, cInt& /******************************************************************************* * 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.x()s only [#] * +* (or they could intersect with Top.x()s only, ie EITHER Bot.x()s OR Top.x()s), * * 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. * @@ -2248,15 +2248,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(); } } @@ -2278,30 +2278,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 @@ -2311,8 +2311,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); m_Joins.emplace_back(Join(op2, op1, eNextHorz->Top)); @@ -2335,12 +2335,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 = (dir == dLeftToRight) ? e->NextInAEL : e->PrevInAEL; @@ -2364,8 +2364,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); m_Joins.emplace_back(Join(op2, op1, eNextHorz->Top)); @@ -2385,17 +2385,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); m_Joins.emplace_back(Join(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); @@ -2433,7 +2433,7 @@ void Clipper::UpdateEdgeIntoAEL(TEdge *&e) e->PrevInAEL = AelPrev; e->NextInAEL = AelNext; if (!IsHorizontal(*e)) - m_Scanbeam.push(e->Top.Y); + m_Scanbeam.push(e->Top.y()); } //------------------------------------------------------------------------------ @@ -2476,7 +2476,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; } @@ -2490,7 +2490,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); m_IntersectList.emplace_back(IntersectNode(e, eNext, Pt)); @@ -2522,7 +2522,7 @@ bool Clipper::FixupIntersectionOrder() //Now it's crucial that intersections are made only between adjacent edges, //so to ensure this the order of intersections may need adjusting ... CopyAELToSEL(); - std::sort(m_IntersectList.begin(), m_IntersectList.end(), [](const IntersectNode &node1, const IntersectNode &node2) { return node2.Pt.Y < node1.Pt.Y; }); + std::sort(m_IntersectList.begin(), m_IntersectList.end(), [](const IntersectNode &node1, const IntersectNode &node2) { return node2.Pt.y() < node1.Pt.y(); }); size_t cnt = m_IntersectList.size(); for (size_t i = 0; i < cnt; ++i) @@ -2610,7 +2610,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; @@ -2618,7 +2618,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); @@ -2628,8 +2628,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 @@ -2638,7 +2638,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 @@ -2673,18 +2673,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); m_Joins.emplace_back(Join(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)) { @@ -2861,13 +2861,13 @@ void Clipper::BuildResult2(PolyTree& polytree) 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(); } //------------------------------------------------------------------------------ @@ -2956,8 +2956,8 @@ OutPt* Clipper::DupOutPt(OutPt* outPt, bool InsertAfter) bool Clipper::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 @@ -2967,10 +2967,10 @@ bool Clipper::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 = this->DupOutPt(op1, !DiscardLeft); if (op1b->Pt != Pt) { @@ -2981,10 +2981,10 @@ bool Clipper::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 = this->DupOutPt(op1, DiscardLeft); if (op1b->Pt != Pt) { @@ -2996,10 +2996,10 @@ bool Clipper::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 = this->DupOutPt(op2, !DiscardLeft); if (op2b->Pt != Pt) { @@ -3009,10 +3009,10 @@ bool Clipper::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 = this->DupOutPt(op2, DiscardLeft); if (op2b->Pt != Pt) { @@ -3052,7 +3052,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)) @@ -3062,11 +3062,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) { @@ -3098,22 +3098,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 @@ -3121,51 +3121,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; } @@ -3334,11 +3334,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.0 / std::sqrt( Dx*Dx + dy*dy ); Dx *= f; dy *= f; @@ -3354,7 +3354,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; } //------------------------------------------------------------------------------ @@ -3373,8 +3373,8 @@ void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType for (; highI > 0; -- highI) { bool same = false; if (has_shortest_edge_length) { - double dx = double(path[highI].X - path[0].X); - double dy = double(path[highI].Y - path[0].Y); + double dx = double(path[highI].x() - path[0].x()); + double dy = double(path[highI].y() - path[0].y()); same = dx*dx + dy*dy < shortest_edge_length2; } else same = path[0] == path[highI]; @@ -3387,8 +3387,8 @@ void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType for (int i = 1; i <= highI; i++) { bool same = false; if (has_shortest_edge_length) { - double dx = double(path[i].X - newNode->Contour[j].X); - double dy = double(path[i].Y - newNode->Contour[j].Y); + double dx = double(path[i].x() - newNode->Contour[j].x()); + double dy = double(path[i].y() - newNode->Contour[j].y()); same = dx*dx + dy*dy < shortest_edge_length2; } else same = newNode->Contour[j] == path[i]; @@ -3396,9 +3396,9 @@ void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType continue; 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) { @@ -3409,14 +3409,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); } } @@ -3433,8 +3433,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) { @@ -3582,8 +3582,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; @@ -3595,8 +3595,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; @@ -3632,8 +3632,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); @@ -3649,9 +3649,9 @@ void ClipperOffset::DoOffset(double delta) if (node.m_endtype == etOpenButt) { int j = len - 1; - pt1 = IntPoint(Round(m_srcPoly[j].X + m_normals[j].X * delta), Round(m_srcPoly[j].Y + m_normals[j].Y * delta)); + pt1 = IntPoint(Round(m_srcPoly[j].x() + m_normals[j].x() * delta), Round(m_srcPoly[j].y() + m_normals[j].y() * delta)); m_destPoly.push_back(pt1); - pt1 = IntPoint(Round(m_srcPoly[j].X - m_normals[j].X * delta), Round(m_srcPoly[j].Y - m_normals[j].Y * delta)); + pt1 = IntPoint(Round(m_srcPoly[j].x() - m_normals[j].x() * delta), Round(m_srcPoly[j].y() - m_normals[j].y() * delta)); m_destPoly.push_back(pt1); } else @@ -3659,7 +3659,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 @@ -3668,17 +3668,17 @@ 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(Round(m_srcPoly[0].X - m_normals[0].X * delta), Round(m_srcPoly[0].Y - m_normals[0].Y * delta)); + pt1 = IntPoint(Round(m_srcPoly[0].x() - m_normals[0].x() * delta), Round(m_srcPoly[0].y() - m_normals[0].y() * delta)); m_destPoly.push_back(pt1); - pt1 = IntPoint(Round(m_srcPoly[0].X + m_normals[0].X * delta), Round(m_srcPoly[0].Y + m_normals[0].Y * delta)); + pt1 = IntPoint(Round(m_srcPoly[0].x() + m_normals[0].x() * delta), Round(m_srcPoly[0].y() + m_normals[0].y() * delta)); m_destPoly.push_back(pt1); } else @@ -3699,15 +3699,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 @@ -3717,19 +3717,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; } @@ -3743,43 +3743,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()); auto steps = std::max(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))); } //------------------------------------------------------------------------------ @@ -3897,8 +3897,8 @@ void SimplifyPolygons(Paths &polys, PolyFillType fillType) inline double DistanceSqrd(const IntPoint& pt1, const IntPoint& pt2) { - auto Dx = double(pt1.X - pt2.X); - auto dy = double(pt1.Y - pt2.Y); + auto Dx = double(pt1.x() - pt2.x()); + auto dy = double(pt1.y() - pt2.y()); return (Dx*Dx + dy*dy); } //------------------------------------------------------------------------------ @@ -3912,10 +3912,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); } //--------------------------------------------------------------------------- @@ -3926,20 +3926,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 (std::abs(pt1.X - pt2.X) > std::abs(pt1.Y - pt2.Y)) + if (std::abs(pt1.x() - pt2.x()) > std::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; @@ -3949,8 +3949,8 @@ bool SlopesNearCollinear(const IntPoint& pt1, bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd) { - auto Dx = double(pt1.X - pt2.X); - auto dy = double(pt1.Y - pt2.Y); + auto Dx = double(pt1.x() - pt2.x()); + auto dy = double(pt1.y() - pt2.y()); return ((Dx * Dx) + (dy * dy) <= distSqrd); } //------------------------------------------------------------------------------ @@ -4058,7 +4058,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 @@ -4067,7 +4067,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); } @@ -4102,7 +4102,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()); } //------------------------------------------------------------------------------ @@ -4178,7 +4178,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; } //------------------------------------------------------------------------------ @@ -4188,8 +4188,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/src/clipper/clipper.hpp b/src/clipper/clipper.hpp index 48e83d046..31919ce75 100644 --- a/src/clipper/clipper.hpp +++ b/src/clipper/clipper.hpp @@ -37,6 +37,8 @@ #include #include +#include + #define CLIPPER_VERSION "6.2.6" //use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance. @@ -88,6 +90,16 @@ enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }; static constexpr cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL; #endif // CLIPPERLIB_INT32 +#if 1 +using IntPoint = Eigen::Matrix; +using DoublePoint = Eigen::Matrix; +#else struct IntPoint { cInt X; cInt Y; @@ -107,10 +119,18 @@ struct IntPoint { return a.X != b.X || a.Y != b.Y; } }; +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()) {} +}; +#endif //------------------------------------------------------------------------------ -typedef std::vector< IntPoint > Path; -typedef std::vector< Path > Paths; +typedef std::vector Path; +typedef std::vector 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;} @@ -119,13 +139,6 @@ std::ostream& operator <<(std::ostream &s, const IntPoint &p); std::ostream& operator <<(std::ostream &s, const Path &p); std::ostream& operator <<(std::ostream &s, const 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 diff --git a/src/libnest2d/include/libnest2d/backends/clipper/clipper_polygon.hpp b/src/libnest2d/include/libnest2d/backends/clipper/clipper_polygon.hpp index 6511fbb72..d4fcd7af3 100644 --- a/src/libnest2d/include/libnest2d/backends/clipper/clipper_polygon.hpp +++ b/src/libnest2d/include/libnest2d/backends/clipper/clipper_polygon.hpp @@ -23,10 +23,12 @@ struct Polygon { Contour(std::move(cont)), Holes(std::move(holes)) {} }; +#if 0 inline IntPoint& operator +=(IntPoint& p, const IntPoint& pa ) { // This could be done with SIMD - p.X += pa.X; - p.Y += pa.Y; + + p.x() += pa.x(); + p.y() += pa.y(); return p; } @@ -37,15 +39,15 @@ inline IntPoint operator+(const IntPoint& p1, const IntPoint& p2) { } inline IntPoint& operator -=(IntPoint& p, const IntPoint& pa ) { - p.X -= pa.X; - p.Y -= pa.Y; + p.x() -= pa.x(); + p.y() -= pa.y(); return p; } inline IntPoint operator -(const IntPoint& p ) { IntPoint ret = p; - ret.X = -ret.X; - ret.Y = -ret.Y; + ret.x() = -ret.x(); + ret.y() = -ret.y(); return ret; } @@ -56,8 +58,8 @@ inline IntPoint operator-(const IntPoint& p1, const IntPoint& p2) { } inline IntPoint& operator *=(IntPoint& p, const IntPoint& pa ) { - p.X *= pa.X; - p.Y *= pa.Y; + p.x() *= pa.x(); + p.y() *= pa.y(); return p; } @@ -66,6 +68,7 @@ inline IntPoint operator*(const IntPoint& p1, const IntPoint& p2) { ret *= p2; return ret; } +#endif } diff --git a/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp b/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp index 9586db35c..5999ebf2a 100644 --- a/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp +++ b/src/libnest2d/include/libnest2d/backends/clipper/geometries.hpp @@ -46,25 +46,25 @@ namespace pointlike { // Tell libnest2d how to extract the X coord from a ClipperPoint object template<> inline ClipperLib::cInt x(const PointImpl& p) { - return p.X; + return p.x(); } // Tell libnest2d how to extract the Y coord from a ClipperPoint object template<> inline ClipperLib::cInt y(const PointImpl& p) { - return p.Y; + return p.y(); } // Tell libnest2d how to extract the X coord from a ClipperPoint object template<> inline ClipperLib::cInt& x(PointImpl& p) { - return p.X; + return p.x(); } // Tell libnest2d how to extract the Y coord from a ClipperPoint object template<> inline ClipperLib::cInt& y(PointImpl& p) { - return p.Y; + return p.y(); } } @@ -144,7 +144,7 @@ template<> inline std::string toString(const PolygonImpl& sh) ss << "Contour {\n"; for(auto p : sh.Contour) { - ss << "\t" << p.X << " " << p.Y << "\n"; + ss << "\t" << p.x() << " " << p.y() << "\n"; } ss << "}\n"; @@ -152,7 +152,7 @@ template<> inline std::string toString(const PolygonImpl& sh) ss << "Holes {\n"; for(auto p : h) { ss << "\t{\n"; - ss << "\t\t" << p.X << " " << p.Y << "\n"; + ss << "\t\t" << p.x() << " " << p.y() << "\n"; ss << "\t}\n"; } ss << "}\n"; @@ -238,14 +238,14 @@ inline void rotate(PolygonImpl& sh, const Radians& rads) for(auto& p : sh.Contour) { p = { - static_cast(p.X * cosa - p.Y * sina), - static_cast(p.X * sina + p.Y * cosa) + static_cast(p.x() * cosa - p.y() * sina), + static_cast(p.x() * sina + p.y() * cosa) }; } for(auto& hole : sh.Holes) for(auto& p : hole) { p = { - static_cast(p.X * cosa - p.Y * sina), - static_cast(p.X * sina + p.Y * cosa) + static_cast(p.x() * cosa - p.y() * sina), + static_cast(p.x() * sina + p.y() * cosa) }; } } @@ -277,7 +277,7 @@ inline TMultiShape clipper_execute( if(!poly.Contour.empty() ) { auto front_p = poly.Contour.front(); auto &back_p = poly.Contour.back(); - if(front_p.X != back_p.X || front_p.Y != back_p.X) + if(front_p.x() != back_p.x() || front_p.y() != back_p.x()) poly.Contour.emplace_back(front_p); } @@ -294,7 +294,7 @@ inline TMultiShape clipper_execute( if(!poly.Contour.empty() ) { auto front_p = poly.Contour.front(); auto &back_p = poly.Contour.back(); - if(front_p.X != back_p.X || front_p.Y != back_p.X) + if(front_p.x() != back_p.x() || front_p.y() != back_p.x()) poly.Contour.emplace_back(front_p); } diff --git a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp index bd9c60355..70168c85a 100644 --- a/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp +++ b/src/libnest2d/include/libnest2d/placers/nfpplacer.hpp @@ -250,8 +250,8 @@ template class EdgeCache { Vertex ret = edge.first(); // Get the point on the edge which lies in ed distance from the start - ret += { static_cast(std::round(ed*std::cos(angle))), - static_cast(std::round(ed*std::sin(angle))) }; + ret += Vertex(static_cast(std::round(ed*std::cos(angle))), + static_cast(std::round(ed*std::sin(angle)))); return ret; } @@ -344,7 +344,8 @@ inline void correctNfpPosition(nfp::NfpResult& nfp, auto dtouch = touch_sh - touch_other; auto top_other = orbiter.rightmostTopVertex() + dtouch; auto dnfp = top_other - nfp.second; // nfp.second is the nfp reference point - shapelike::translate(nfp.first, dnfp); + //FIXME the explicit type conversion ClipperLib::IntPoint() + shapelike::translate(nfp.first, ClipperLib::IntPoint(dnfp)); } template @@ -473,7 +474,8 @@ public: auto bbin = sl::boundingBox(bin); auto d = bbch.center() - bbin.center(); auto chullcpy = chull; - sl::translate(chullcpy, d); + //FIXME the explicit type conversion ClipperLib::IntPoint() + sl::translate(chullcpy, ClipperLib::IntPoint(d)); return sl::isInside(chullcpy, bin) ? -1.0 : 1.0; } @@ -724,8 +726,7 @@ private: auto rawobjfunc = [_objfunc, iv, startpos] (Vertex v, Item& itm) { - auto d = v - iv; - d += startpos; + auto d = (v - iv) + startpos; itm.translation(d); return _objfunc(itm); }; @@ -742,8 +743,7 @@ private: &item, &bin, &iv, &startpos] (const Optimum& o) { auto v = getNfpPoint(o); - auto d = v - iv; - d += startpos; + auto d = (v - iv) + startpos; item.translation(d); merged_pile.emplace_back(item.transformedShape()); @@ -877,8 +877,7 @@ private: } if( best_score < global_score ) { - auto d = getNfpPoint(optimum) - iv; - d += startpos; + auto d = (getNfpPoint(optimum) - iv) + startpos; final_tr = d; final_rot = initial_rot + rot; can_pack = true; diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index 3800d49e3..91f35f845 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -56,8 +56,8 @@ template, int...EigenArgs> inline constexpr Eigen::Matrix unscaled( const ClipperLib::IntPoint &v) noexcept { - return Eigen::Matrix{unscaled(v.X), - unscaled(v.Y)}; + return Eigen::Matrix{unscaled(v.x()), + unscaled(v.y())}; } namespace arrangement { @@ -644,7 +644,7 @@ void arrange(ArrangePolygons & arrangables, for(size_t i = 0; i < items.size(); ++i) { clppr::IntPoint tr = items[i].translation(); - arrangables[i].translation = {coord_t(tr.X), coord_t(tr.Y)}; + arrangables[i].translation = {coord_t(tr.x()), coord_t(tr.y())}; arrangables[i].rotation = items[i].rotation(); arrangables[i].bed_idx = items[i].binId(); } diff --git a/src/libslic3r/Brim.cpp b/src/libslic3r/Brim.cpp index 08bedc5c0..19f5ae82e 100644 --- a/src/libslic3r/Brim.cpp +++ b/src/libslic3r/Brim.cpp @@ -78,7 +78,7 @@ static ConstPrintObjectPtrs get_top_level_objects_with_brim(const Print &print) // Assign the maximum Z from four points. This values is valid index of the island clipper.ZFillFunction([](const ClipperLib_Z::IntPoint &e1bot, const ClipperLib_Z::IntPoint &e1top, const ClipperLib_Z::IntPoint &e2bot, const ClipperLib_Z::IntPoint &e2top, ClipperLib_Z::IntPoint &pt) { - pt.Z = std::max(std::max(e1bot.Z, e1top.Z), std::max(e2bot.Z, e2top.Z)); + pt.z() = std::max(std::max(e1bot.z(), e1top.z()), std::max(e2bot.z(), e2top.z())); }); // Add islands clipper.AddPaths(islands_clip, ClipperLib_Z::ptSubject, true); @@ -90,9 +90,9 @@ static ConstPrintObjectPtrs get_top_level_objects_with_brim(const Print &print) ConstPrintObjectPtrs top_level_objects_with_brim; for (int i = 0; i < islands_polytree.ChildCount(); ++i) { for (const ClipperLib_Z::IntPoint &point : islands_polytree.Childs[i]->Contour) { - if (point.Z != 0 && processed_objects_idx.find(island_to_object[point.Z - 1]->id().id) == processed_objects_idx.end()) { - top_level_objects_with_brim.emplace_back(island_to_object[point.Z - 1]); - processed_objects_idx.insert(island_to_object[point.Z - 1]->id().id); + if (point.z() != 0 && processed_objects_idx.find(island_to_object[point.z() - 1]->id().id) == processed_objects_idx.end()) { + top_level_objects_with_brim.emplace_back(island_to_object[point.z() - 1]); + processed_objects_idx.insert(island_to_object[point.z() - 1]->id().id); } } } @@ -456,7 +456,7 @@ ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cance clipper.ZFillFunction([](const ClipperLib_Z::IntPoint& e1bot, const ClipperLib_Z::IntPoint& e1top, const ClipperLib_Z::IntPoint& e2bot, const ClipperLib_Z::IntPoint& e2top, ClipperLib_Z::IntPoint& pt) { // Assign a valid input loop identifier. Such an identifier is strictly positive, the next line is safe even in case one side of a segment // hat the Z coordinate not set to the contour coordinate. - pt.Z = std::max(std::max(e1bot.Z, e1top.Z), std::max(e2bot.Z, e2top.Z)); + pt.z() = std::max(std::max(e1bot.z(), e1top.z()), std::max(e2bot.z(), e2top.z())); }); // add polygons clipper.AddPaths(input_clip, ClipperLib_Z::ptSubject, false); @@ -474,8 +474,8 @@ ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cance for (const ClipperLib_Z::Path &path : loops_trimmed) { size_t input_idx = 0; for (const ClipperLib_Z::IntPoint &pt : path) - if (pt.Z > 0) { - input_idx = (size_t)pt.Z; + if (pt.z() > 0) { + input_idx = (size_t)pt.z(); break; } assert(input_idx != 0); @@ -492,14 +492,14 @@ ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cance size_t j = i + 1; for (; j < loops_trimmed_order.size() && loops_trimmed_order[i].second == loops_trimmed_order[j].second; ++ j) ; const ClipperLib_Z::Path &first_path = *loops_trimmed_order[i].first; - if (i + 1 == j && first_path.size() > 3 && first_path.front().X == first_path.back().X && first_path.front().Y == first_path.back().Y) { + if (i + 1 == j && first_path.size() > 3 && first_path.front().x() == first_path.back().x() && first_path.front().y() == first_path.back().y()) { auto *loop = new ExtrusionLoop(); brim.entities.emplace_back(loop); loop->paths.emplace_back(erSkirt, float(flow.mm3_per_mm()), float(flow.width()), float(print.skirt_first_layer_height())); Points &points = loop->paths.front().polyline.points; points.reserve(first_path.size()); for (const ClipperLib_Z::IntPoint &pt : first_path) - points.emplace_back(coord_t(pt.X), coord_t(pt.Y)); + points.emplace_back(coord_t(pt.x()), coord_t(pt.y())); i = j; } else { //FIXME The path chaining here may not be optimal. @@ -511,7 +511,7 @@ ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cance Points &points = static_cast(this_loop_trimmed.entities.back())->polyline.points; points.reserve(path.size()); for (const ClipperLib_Z::IntPoint &pt : path) - points.emplace_back(coord_t(pt.X), coord_t(pt.Y)); + points.emplace_back(coord_t(pt.x()), coord_t(pt.y())); } chain_and_reorder_extrusion_entities(this_loop_trimmed.entities, &last_pt); brim.entities.reserve(brim.entities.size() + this_loop_trimmed.entities.size()); diff --git a/src/libslic3r/ClipperUtils.cpp b/src/libslic3r/ClipperUtils.cpp index cd243dfb1..477dbf6f1 100644 --- a/src/libslic3r/ClipperUtils.cpp +++ b/src/libslic3r/ClipperUtils.cpp @@ -131,7 +131,7 @@ Slic3r::Polygon ClipperPath_to_Slic3rPolygon(const ClipperLib::Path &input) { Polygon retval; for (ClipperLib::Path::const_iterator pit = input.begin(); pit != input.end(); ++pit) - retval.points.emplace_back(pit->X, pit->Y); + retval.points.emplace_back(pit->x(), pit->y()); return retval; } @@ -139,7 +139,7 @@ Slic3r::Polyline ClipperPath_to_Slic3rPolyline(const ClipperLib::Path &input) { Polyline retval; for (ClipperLib::Path::const_iterator pit = input.begin(); pit != input.end(); ++pit) - retval.points.emplace_back(pit->X, pit->Y); + retval.points.emplace_back(pit->x(), pit->y()); return retval; } @@ -752,7 +752,7 @@ ClipperLib::PolyNodes order_nodes(const ClipperLib::PolyNodes &nodes) for (const ClipperLib::PolyNode *node : nodes) ordering_points.emplace_back( - Point(node->Contour.front().X, node->Contour.front().Y)); + Point(node->Contour.front().x(), node->Contour.front().y())); // perform the ordering ClipperLib::PolyNodes ordered_nodes = @@ -777,7 +777,7 @@ static void traverse_pt_outside_in(const ClipperLib::PolyNodes &nodes, Polygons Points ordering_points; ordering_points.reserve(nodes.size()); for (const ClipperLib::PolyNode *node : nodes) - ordering_points.emplace_back(node->Contour.front().X, node->Contour.front().Y); + ordering_points.emplace_back(node->Contour.front().x(), node->Contour.front().y()); // Perform the ordering, push results recursively. //FIXME pass the last point to chain_clipper_polynodes? diff --git a/src/libslic3r/Point.hpp b/src/libslic3r/Point.hpp index f38a7066b..12870b713 100644 --- a/src/libslic3r/Point.hpp +++ b/src/libslic3r/Point.hpp @@ -17,42 +17,42 @@ class BoundingBox; class Line; class MultiPoint; class Point; -typedef Point Vector; +using Vector = Point; // Eigen types, to replace the Slic3r's own types in the future. // Vector types with a fixed point coordinate base type. -typedef Eigen::Matrix Vec2crd; -typedef Eigen::Matrix Vec3crd; -typedef Eigen::Matrix Vec2i; -typedef Eigen::Matrix Vec3i; -typedef Eigen::Matrix Vec2i32; -typedef Eigen::Matrix Vec2i64; -typedef Eigen::Matrix Vec3i32; -typedef Eigen::Matrix Vec3i64; +using Vec2crd = Eigen::Matrix; +using Vec3crd = Eigen::Matrix; +using Vec2i = Eigen::Matrix; +using Vec3i = Eigen::Matrix; +using Vec2i32 = Eigen::Matrix; +using Vec2i64 = Eigen::Matrix; +using Vec3i32 = Eigen::Matrix; +using Vec3i64 = Eigen::Matrix; // Vector types with a double coordinate base type. -typedef Eigen::Matrix Vec2f; -typedef Eigen::Matrix Vec3f; -typedef Eigen::Matrix Vec2d; -typedef Eigen::Matrix Vec3d; +using Vec2f = Eigen::Matrix; +using Vec3f = Eigen::Matrix; +using Vec2d = Eigen::Matrix; +using Vec3d = Eigen::Matrix; -typedef std::vector Points; -typedef std::vector PointPtrs; -typedef std::vector PointConstPtrs; -typedef std::vector Points3; -typedef std::vector Pointfs; -typedef std::vector Vec2ds; -typedef std::vector Pointf3s; +using Points = std::vector; +using PointPtrs = std::vector; +using PointConstPtrs = std::vector; +using Points3 = std::vector; +using Pointfs = std::vector; +using Vec2ds = std::vector; +using Pointf3s = std::vector; -typedef Eigen::Matrix Matrix2f; -typedef Eigen::Matrix Matrix2d; -typedef Eigen::Matrix Matrix3f; -typedef Eigen::Matrix Matrix3d; +using Matrix2f = Eigen::Matrix; +using Matrix2d = Eigen::Matrix; +using Matrix3f = Eigen::Matrix; +using Matrix3d = Eigen::Matrix; -typedef Eigen::Transform Transform2f; -typedef Eigen::Transform Transform2d; -typedef Eigen::Transform Transform3f; -typedef Eigen::Transform Transform3d; +using Transform2f = Eigen::Transform; +using Transform2d = Eigen::Transform; +using Transform3f = Eigen::Transform; +using Transform3d = Eigen::Transform; inline bool operator<(const Vec2d &lhs, const Vec2d &rhs) { return lhs(0) < rhs(0) || (lhs(0) == rhs(0) && lhs(1) < rhs(1)); } @@ -101,7 +101,7 @@ template using Vec = Eigen::Matrix map_type; + using map_type = typename std::unordered_multimap; PointAccessor m_point_accessor; map_type m_map; coord_t m_search_radius; @@ -439,11 +439,11 @@ inline Point align_to_grid(Point coord, Point spacing, Point base) #include namespace boost { namespace polygon { template <> - struct geometry_concept { typedef point_concept type; }; + struct geometry_concept { using type = point_concept; }; template <> struct point_traits { - typedef coord_t coordinate_type; + using coordinate_type = coord_t; static inline coordinate_type get(const Slic3r::Point& point, orientation_2d orient) { return static_cast(point((orient == HORIZONTAL) ? 0 : 1)); @@ -452,7 +452,7 @@ namespace boost { namespace polygon { template <> struct point_mutable_traits { - typedef coord_t coordinate_type; + using coordinate_type = coord_t; static inline void set(Slic3r::Point& point, orientation_2d orient, coord_t value) { point((orient == HORIZONTAL) ? 0 : 1) = value; } diff --git a/src/libslic3r/SLA/AGGRaster.hpp b/src/libslic3r/SLA/AGGRaster.hpp index 849cec30a..087903566 100644 --- a/src/libslic3r/SLA/AGGRaster.hpp +++ b/src/libslic3r/SLA/AGGRaster.hpp @@ -77,8 +77,8 @@ protected: double getPx(const Point &p) { return p(0) * m_pxdim_scaled.w_mm; } double getPy(const Point &p) { return p(1) * m_pxdim_scaled.h_mm; } agg::path_storage to_path(const Polygon &poly) { return to_path(poly.points); } - double getPx(const ClipperLib::IntPoint &p) { return p.X * m_pxdim_scaled.w_mm; } - double getPy(const ClipperLib::IntPoint& p) { return p.Y * m_pxdim_scaled.h_mm; } + double getPx(const ClipperLib::IntPoint &p) { return p.x() * m_pxdim_scaled.w_mm; } + double getPy(const ClipperLib::IntPoint& p) { return p.y() * m_pxdim_scaled.h_mm; } template agg::path_storage _to_path(const PointVec& v) { diff --git a/src/libslic3r/SLAPrintSteps.cpp b/src/libslic3r/SLAPrintSteps.cpp index c393eb295..6058fe192 100644 --- a/src/libslic3r/SLAPrintSteps.cpp +++ b/src/libslic3r/SLAPrintSteps.cpp @@ -806,8 +806,8 @@ static ClipperPolygons get_all_polygons(const SliceRecord& record, SliceOrigin o } if(is_lefthanded) { - for(auto& p : poly.Contour) p.X = -p.X; - for(auto& h : poly.Holes) for(auto& p : h) p.X = -p.X; + for(auto& p : poly.Contour) p.x() = -p.x(); + for(auto& h : poly.Holes) for(auto& p : h) p.x() = -p.x(); } sl::rotate(poly, double(instances[i].rotation)); diff --git a/src/libslic3r/SVG.cpp b/src/libslic3r/SVG.cpp index 7308d7e50..6bc334eec 100644 --- a/src/libslic3r/SVG.cpp +++ b/src/libslic3r/SVG.cpp @@ -273,8 +273,8 @@ std::string SVG::get_path_d(const ClipperLib::Path &path, double scale, bool clo std::ostringstream d; d << "M "; for (ClipperLib::Path::const_iterator p = path.begin(); p != path.end(); ++p) { - d << to_svg_x(scale * p->X - origin(0)) << " "; - d << to_svg_y(scale * p->Y - origin(1)) << " "; + d << to_svg_x(scale * p->x() - origin(0)) << " "; + d << to_svg_y(scale * p->y() - origin(1)) << " "; } if (closed) d << "z"; return d.str(); diff --git a/tests/libnest2d/libnest2d_tests_main.cpp b/tests/libnest2d/libnest2d_tests_main.cpp index a0f192460..11fdc6e9c 100644 --- a/tests/libnest2d/libnest2d_tests_main.cpp +++ b/tests/libnest2d/libnest2d_tests_main.cpp @@ -140,15 +140,15 @@ TEST_CASE("boundingCircle", "[Geometry]") { PolygonImpl p = {{{0, 10}, {10, 0}, {0, -10}, {0, 10}}, {}}; Circle c = boundingCircle(p); - REQUIRE(c.center().X == 0); - REQUIRE(c.center().Y == 0); + REQUIRE(c.center().x() == 0); + REQUIRE(c.center().y() == 0); REQUIRE(c.radius() == Approx(10)); shapelike::translate(p, PointImpl{10, 10}); c = boundingCircle(p); - REQUIRE(c.center().X == 10); - REQUIRE(c.center().Y == 10); + REQUIRE(c.center().x() == 10); + REQUIRE(c.center().y() == 10); REQUIRE(c.radius() == Approx(10)); auto parts = prusaParts(); @@ -616,7 +616,7 @@ TEST_CASE("EmptyItemShouldBeUntouched", "[Nesting]") { std::vector items; items.emplace_back(Item{}); // Emplace empty item - items.emplace_back(Item{0, 200, 0}); // Emplace zero area item + items.emplace_back(Item{ { 0, 0} , { 200, 0 }, { 0, 0 } }); // Emplace zero area item size_t bins = libnest2d::nest(items, bin); @@ -661,12 +661,12 @@ TEST_CASE("Items can be preloaded", "[Nesting]") { REQUIRE(bins == 1); REQUIRE(fixed_rect.binId() == 0); - REQUIRE(fixed_rect.translation().X == bin.center().X); - REQUIRE(fixed_rect.translation().Y == bin.center().Y); + REQUIRE(fixed_rect.translation().x() == bin.center().x()); + REQUIRE(fixed_rect.translation().y() == bin.center().y()); REQUIRE(movable_rect.binId() == 0); - REQUIRE(movable_rect.translation().X != bin.center().X); - REQUIRE(movable_rect.translation().Y != bin.center().Y); + REQUIRE(movable_rect.translation().x() != bin.center().x()); + REQUIRE(movable_rect.translation().y() != bin.center().y()); } SECTION("Preloaded Item should not affect free bins") { @@ -677,14 +677,14 @@ TEST_CASE("Items can be preloaded", "[Nesting]") { REQUIRE(bins == 2); REQUIRE(fixed_rect.binId() == 1); - REQUIRE(fixed_rect.translation().X == bin.center().X); - REQUIRE(fixed_rect.translation().Y == bin.center().Y); + REQUIRE(fixed_rect.translation().x() == bin.center().x()); + REQUIRE(fixed_rect.translation().y() == bin.center().y()); REQUIRE(movable_rect.binId() == 0); auto bb = movable_rect.boundingBox(); - REQUIRE(bb.center().X == bin.center().X); - REQUIRE(bb.center().Y == bin.center().Y); + REQUIRE(bb.center().x() == bin.center().x()); + REQUIRE(bb.center().y() == bin.center().y()); } } diff --git a/tests/libslic3r/test_elephant_foot_compensation.cpp b/tests/libslic3r/test_elephant_foot_compensation.cpp index 4e340c37a..a1c23f4a9 100644 --- a/tests/libslic3r/test_elephant_foot_compensation.cpp +++ b/tests/libslic3r/test_elephant_foot_compensation.cpp @@ -26,7 +26,7 @@ namespace Slic3r { pt.Y += CLIPPER_OFFSET_SCALE_ROUNDING_DELTA; pt.X >>= CLIPPER_OFFSET_POWER_OF_2; pt.Y >>= CLIPPER_OFFSET_POWER_OF_2; - out.emplace_back(coord_t(pt.X), coord_t(pt.Y)); + out.emplace_back(coord_t(pt.x()), coord_t(pt.y())); } return out; }