From 2ddd1669c0d779fa1e78823cffc330c5ed8ffa32 Mon Sep 17 00:00:00 2001 From: Michael Carleton Date: Mon, 9 Mar 2026 11:13:29 +0000 Subject: [PATCH 1/3] 2.0.1 changes --- pom.xml | 2 +- src/main/java/clipper2/Clipper.java | 1 - .../java/clipper2/core/InternalClipper.java | 88 ++++++++++++++----- src/main/java/clipper2/core/Path64.java | 10 +-- src/main/java/clipper2/core/PathD.java | 10 +-- src/main/java/clipper2/core/Paths64.java | 7 +- src/main/java/clipper2/core/PathsD.java | 7 +- .../java/clipper2/engine/ClipperBase.java | 26 +++--- .../java/clipper2/offset/ClipperOffset.java | 33 +------ .../java/clipper2/rectclip/RectClip64.java | 12 +-- src/test/java/clipper2/TestPolygons.java | 4 +- src/test/java/clipper2/TestPolytree.java | 80 +++++++++++++++++ .../java/clipper2/TestToStringOutput.java | 8 +- 13 files changed, 199 insertions(+), 89 deletions(-) diff --git a/pom.xml b/pom.xml index 6315649..67ddba3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 micycle clipper2 - 1.5.4 + 2.0.1 Clipper2 1.36 diff --git a/src/main/java/clipper2/Clipper.java b/src/main/java/clipper2/Clipper.java index bdfbe68..59064fb 100644 --- a/src/main/java/clipper2/Clipper.java +++ b/src/main/java/clipper2/Clipper.java @@ -1,7 +1,6 @@ package clipper2; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; diff --git a/src/main/java/clipper2/core/InternalClipper.java b/src/main/java/clipper2/core/InternalClipper.java index 9c1f3d1..786655f 100644 --- a/src/main/java/clipper2/core/InternalClipper.java +++ b/src/main/java/clipper2/core/InternalClipper.java @@ -31,6 +31,31 @@ public static double CrossProduct(Point64 pt1, Point64 pt2, Point64 pt3) { return ((double) (pt2.x - pt1.x) * (pt3.y - pt2.y) - (double) (pt2.y - pt1.y) * (pt3.x - pt2.x)); } + public static int CrossProductSign(Point64 pt1, Point64 pt2, Point64 pt3) { + long a = pt2.x - pt1.x; + long b = pt3.y - pt2.y; + long c = pt2.y - pt1.y; + long d = pt3.x - pt2.x; + UInt128Struct ab = multiplyUInt64(Math.abs(a), Math.abs(b)); + UInt128Struct cd = multiplyUInt64(Math.abs(c), Math.abs(d)); + int signAB = triSign(a) * triSign(b); + int signCD = triSign(c) * triSign(d); + + if (signAB == signCD) { + int result; + if (ab.hi64 == cd.hi64) { + if (ab.lo64 == cd.lo64) { + return 0; + } + result = Long.compareUnsigned(ab.lo64, cd.lo64); + } else { + result = Long.compareUnsigned(ab.hi64, cd.hi64); + } + return signAB > 0 ? result : -result; + } + return signAB > signCD ? 1 : -1; + } + public static double DotProduct(Point64 pt1, Point64 pt2, Point64 pt3) { // typecast to double to avoid potential int overflow return ((double) (pt2.x - pt1.x) * (pt3.x - pt2.x) + (double) (pt2.y - pt1.y) * (pt3.y - pt2.y)); @@ -51,7 +76,7 @@ public static long CheckCastInt64(double val) { return (long) Math.rint(val); } - public static boolean GetSegmentIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { + public static boolean GetLineIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { double dy1 = (ln1b.y - ln1a.y); double dx1 = (ln1b.x - ln1a.x); double dy2 = (ln2b.y - ln2a.y); @@ -85,9 +110,40 @@ public static boolean GetSegmentIntersectPt(Point64 ln1a, Point64 ln1b, Point64 return true; } + public static boolean GetLineIntersectPt(PointD ln1a, PointD ln1b, PointD ln2a, PointD ln2b, /* out */ PointD ip) { + double dy1 = (ln1b.y - ln1a.y); + double dx1 = (ln1b.x - ln1a.x); + double dy2 = (ln2b.y - ln2a.y); + double dx2 = (ln2b.x - ln2a.x); + + double det = dy1 * dx2 - dy2 * dx1; + if (det == 0.0) { + ip.x = 0; + ip.y = 0; + return false; + } + + double t = ((ln1a.x - ln2a.x) * dy2 - (ln1a.y - ln2a.y) * dx2) / det; + if (t <= 0.0) { + ip.x = ln1a.x; + ip.y = ln1a.y; + } else if (t >= 1.0) { + ip.x = ln1b.x; + ip.y = ln1b.y; + } else { + ip.x = ln1a.x + t * dx1; + ip.y = ln1a.y + t * dy1; + } + return true; + } + + public static boolean GetSegmentIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { + return GetLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip); + } + @Deprecated public static boolean GetIntersectPoint(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { - return GetSegmentIntersectPt(ln1a, ln1b, ln2a, ln2b, ip); + return GetLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip); } public static boolean SegsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b) { @@ -106,12 +162,10 @@ public static boolean SegsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, if (res3 * res4 > 0) { return false; } - // ensure NOT collinear return (res1 != 0 || res2 != 0 || res3 != 0 || res4 != 0); - } else { - return (CrossProduct(seg1a, seg2a, seg2b) * CrossProduct(seg1b, seg2a, seg2b) < 0) - && (CrossProduct(seg2a, seg1a, seg1b) * CrossProduct(seg2b, seg1a, seg1b) < 0); } + return (CrossProduct(seg1a, seg2a, seg2b) * CrossProduct(seg1b, seg2a, seg2b) < 0) + && (CrossProduct(seg2a, seg1a, seg1b) * CrossProduct(seg2b, seg1a, seg1b) < 0); } public static Point64 GetClosestPtOnSegment(Point64 offPt, Point64 seg1, Point64 seg2) { @@ -142,7 +196,6 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { return PointInPolygonResult.IsOutside; } - double d; boolean isAbove = polygon.get(start).y < pt.y, startingAbove = isAbove; int val = 0, i = start + 1, end = len; while (true) { @@ -193,11 +246,11 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { } else if (pt.x > prev.x && pt.x > curr.x) { val = 1 - val; // toggle val } else { - d = CrossProduct(prev, curr, pt); - if (d == 0) { + int cps = CrossProductSign(prev, curr, pt); + if (cps == 0) { return PointInPolygonResult.IsOn; } - if ((d < 0) == isAbove) { + if ((cps < 0) == isAbove) { val = 1 - val; } } @@ -209,15 +262,11 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { if (i == len) { i = 0; } - if (i == 0) { - d = CrossProduct(polygon.get(len - 1), polygon.get(0), pt); - } else { - d = CrossProduct(polygon.get(i - 1), polygon.get(i), pt); - } - if (d == 0) { + int cps = (i == 0) ? CrossProductSign(polygon.get(len - 1), polygon.get(0), pt) : CrossProductSign(polygon.get(i - 1), polygon.get(i), pt); + if (cps == 0) { return PointInPolygonResult.IsOn; } - if ((d < 0) == isAbove) { + if ((cps < 0) == isAbove) { val = 1 - val; } } @@ -296,10 +345,7 @@ private static boolean productsAreEqual(long a, long b, long c, long d) { } private static int triSign(long x) { - if (x < 0) { - return -1; - } - return x > 1 ? 1 : 0; + return x < 0 ? -1 : (x > 0 ? 1 : 0); } public static Rect64 GetBounds(Path64 path) { diff --git a/src/main/java/clipper2/core/Path64.java b/src/main/java/clipper2/core/Path64.java index cee6901..c780d95 100644 --- a/src/main/java/clipper2/core/Path64.java +++ b/src/main/java/clipper2/core/Path64.java @@ -35,11 +35,11 @@ public Path64(Point64... path) { @Override public String toString() { StringBuilder s = new StringBuilder(); - for (Point64 p : this) { - s.append(p.toString()).append(", "); - } - if (!s.isEmpty()) { - s.setLength(s.length() - 2); + for (int i = 0; i < size(); i++) { + if (i > 0) { + s.append(", "); + } + s.append(get(i).toString().trim()); } return s.toString(); } diff --git a/src/main/java/clipper2/core/PathD.java b/src/main/java/clipper2/core/PathD.java index dd56ff0..d1b1df3 100644 --- a/src/main/java/clipper2/core/PathD.java +++ b/src/main/java/clipper2/core/PathD.java @@ -30,11 +30,11 @@ public PathD(List path) { @Override public String toString() { StringBuilder s = new StringBuilder(); - for (PointD p : this) { - s.append(p.toString()).append(", "); - } - if (!s.isEmpty()) { - s.setLength(s.length() - 2); + for (int i = 0; i < size(); i++) { + if (i > 0) { + s.append(", "); + } + s.append(get(i).toString().trim()); } return s.toString(); } diff --git a/src/main/java/clipper2/core/Paths64.java b/src/main/java/clipper2/core/Paths64.java index e0d58d8..47b0a66 100644 --- a/src/main/java/clipper2/core/Paths64.java +++ b/src/main/java/clipper2/core/Paths64.java @@ -31,8 +31,11 @@ public Paths64(Path64... paths) { @Override public String toString() { StringBuilder s = new StringBuilder(); - for (Path64 p : this) { - s.append(p).append("\n"); + for (int i = 0; i < size(); i++) { + if (i > 0) { + s.append(System.lineSeparator()); + } + s.append(get(i).toString()); } return s.toString(); } diff --git a/src/main/java/clipper2/core/PathsD.java b/src/main/java/clipper2/core/PathsD.java index cd598d4..3244f29 100644 --- a/src/main/java/clipper2/core/PathsD.java +++ b/src/main/java/clipper2/core/PathsD.java @@ -26,8 +26,11 @@ public PathsD(List paths) { @Override public String toString() { StringBuilder s = new StringBuilder(); - for (PathD p : this) { - s.append(p.toString()).append("\n"); + for (int i = 0; i < size(); i++) { + if (i > 0) { + s.append(System.lineSeparator()); + } + s.append(get(i).toString()); } return s.toString(); } diff --git a/src/main/java/clipper2/engine/ClipperBase.java b/src/main/java/clipper2/engine/ClipperBase.java index d1b4f21..7fd315b 100644 --- a/src/main/java/clipper2/engine/ClipperBase.java +++ b/src/main/java/clipper2/engine/ClipperBase.java @@ -971,7 +971,7 @@ private static boolean IsValidAelOrder(Active resident, Active newcomer) { } // get the turning direction a1.top, a2.bot, a2.top - double d = InternalClipper.CrossProduct(resident.top, newcomer.bot, newcomer.top); + int d = InternalClipper.CrossProductSign(resident.top, newcomer.bot, newcomer.top); if (d != 0) { return (d < 0); } @@ -981,11 +981,11 @@ private static boolean IsValidAelOrder(Active resident, Active newcomer) { // for starting open paths, place them according to // the direction they're about to turn if (!IsMaxima(resident) && (resident.top.y > newcomer.top.y)) { - return InternalClipper.CrossProduct(newcomer.bot, resident.top, NextVertex(resident).pt) <= 0; + return InternalClipper.CrossProductSign(newcomer.bot, resident.top, NextVertex(resident).pt) <= 0; } if (!IsMaxima(newcomer) && (newcomer.top.y > resident.top.y)) { - return InternalClipper.CrossProduct(newcomer.bot, newcomer.top, NextVertex(newcomer).pt) >= 0; + return InternalClipper.CrossProductSign(newcomer.bot, newcomer.top, NextVertex(newcomer).pt) >= 0; } long y = newcomer.bot.y; @@ -1002,7 +1002,7 @@ private static boolean IsValidAelOrder(Active resident, Active newcomer) { return true; } // compare turning direction of the alternate bound - return (InternalClipper.CrossProduct(PrevPrevVertex(resident).pt, newcomer.bot, PrevPrevVertex(newcomer).pt) > 0) == newcomerIsLeft; + return (InternalClipper.CrossProductSign(PrevPrevVertex(resident).pt, newcomer.bot, PrevPrevVertex(newcomer).pt) > 0) == newcomerIsLeft; } private void InsertLeftEdge(Active ae) { @@ -1718,7 +1718,7 @@ private void DisposeIntersectNodes() { private void AddNewIntersectNode(Active ae1, Active ae2, long topY) { Point64 ip = new Point64(); - if (!InternalClipper.GetSegmentIntersectPt(ae1.bot, ae1.top, ae2.bot, ae2.top, ip)) { + if (!InternalClipper.GetLineIntersectPt(ae1.bot, ae1.top, ae2.bot, ae2.top, ip)) { ip = new Point64(ae1.curX, topY); } @@ -2497,7 +2497,7 @@ private static PointInPolygonResult PointInOpPolygon(Point64 pt, OutPt op) { if ((op2.prev.pt.x < pt.x && op2.pt.x < pt.x)) { val = 1 - val; // toggle val } else { - double d = InternalClipper.CrossProduct(op2.prev.pt, op2.pt, pt); + int d = InternalClipper.CrossProductSign(op2.prev.pt, op2.pt, pt); if (d == 0) { return PointInPolygonResult.IsOn; } @@ -2511,7 +2511,7 @@ private static PointInPolygonResult PointInOpPolygon(Point64 pt, OutPt op) { } if (isAbove != startingAbove) { - double d = InternalClipper.CrossProduct(op2.prev.pt, op2.pt, pt); + int d = InternalClipper.CrossProductSign(op2.prev.pt, op2.pt, pt); if (d == 0) { return PointInPolygonResult.IsOn; } @@ -2563,7 +2563,9 @@ private void MoveSplits(OutRec fromOr, OutRec toOr) { toOr.splits = new ArrayList<>(); } for (int i : fromOr.splits) { - toOr.splits.add(i); + if (i != toOr.idx) { + toOr.splits.add(i); + } } fromOr.splits = null; @@ -2693,8 +2695,8 @@ private void DoSplitOp(OutRec outrec, OutPt splitOp) { outrec.pts = prevOp; // OutPt result = prevOp; - Point64 ip = new Point64(); // ip mutated by GetSegmentIntersectPt() - InternalClipper.GetSegmentIntersectPt(prevOp.pt, splitOp.pt, splitOp.next.pt, nextNextOp.pt, ip); + Point64 ip = new Point64(); + InternalClipper.GetLineIntersectPt(prevOp.pt, splitOp.pt, splitOp.next.pt, nextNextOp.pt, ip); double area1 = Area(prevOp); double absArea1 = Math.abs(area1); @@ -2866,8 +2868,8 @@ private boolean CheckBounds(OutRec outrec) { } private boolean CheckSplitOwner(OutRec outrec, List splits) { - for (int i : splits) { - OutRec split = outrecList.get(i); + for (int i = 0; i < splits.size(); i++) { + OutRec split = outrecList.get(splits.get(i)); if (split.pts == null && split.splits != null && CheckSplitOwner(outrec, split.splits)) { return true; // #942 } diff --git a/src/main/java/clipper2/offset/ClipperOffset.java b/src/main/java/clipper2/offset/ClipperOffset.java index 6bee1d4..1531bcb 100644 --- a/src/main/java/clipper2/offset/ClipperOffset.java +++ b/src/main/java/clipper2/offset/ClipperOffset.java @@ -370,33 +370,6 @@ private static PointD GetAvgUnitVector(PointD vec1, PointD vec2) { return NormalizeVector(new PointD(vec1.x + vec2.x, vec1.y + vec2.y)); } - private static PointD IntersectPoint(PointD pt1a, PointD pt1b, PointD pt2a, PointD pt2b) { - if (InternalClipper.IsAlmostZero(pt1a.x - pt1b.x)) { // vertical - if (InternalClipper.IsAlmostZero(pt2a.x - pt2b.x)) { - return new PointD(0, 0); - } - double m2 = (pt2b.y - pt2a.y) / (pt2b.x - pt2a.x); - double b2 = pt2a.y - m2 * pt2a.x; - return new PointD(pt1a.x, m2 * pt1a.x + b2); - } - - if (InternalClipper.IsAlmostZero(pt2a.x - pt2b.x)) { // vertical - double m1 = (pt1b.y - pt1a.y) / (pt1b.x - pt1a.x); - double b1 = pt1a.y - m1 * pt1a.x; - return new PointD(pt2a.x, m1 * pt2a.x + b1); - } else { - double m1 = (pt1b.y - pt1a.y) / (pt1b.x - pt1a.x); - double b1 = pt1a.y - m1 * pt1a.x; - double m2 = (pt2b.y - pt2a.y) / (pt2b.x - pt2a.x); - double b2 = pt2a.y - m2 * pt2a.x; - if (InternalClipper.IsAlmostZero(m1 - m2)) { - return new PointD(0, 0); - } - double x = (b2 - b1) / (m1 - m2); - return new PointD(x, m1 * x + b1); - } - } - private Point64 GetPerpendic(Point64 pt, PointD norm) { return new Point64(pt.x + norm.x * groupDelta, pt.y + norm.y * groupDelta); } @@ -439,13 +412,15 @@ private void DoSquare(Path64 path, int j, int k) { if (j == k) { PointD pt4 = new PointD(pt3.x + vec.x * groupDelta, pt3.y + vec.y * groupDelta); - PointD pt = IntersectPoint(pt1, pt2, pt3, pt4); + PointD pt = new PointD(); + InternalClipper.GetLineIntersectPt(pt1, pt2, pt3, pt4, pt); // get the second intersect point through reflecion pathOut.add(new Point64(ReflectPoint(pt, ptQ))); pathOut.add(new Point64(pt)); } else { PointD pt4 = GetPerpendicD(path.get(j), normals.get(k)); - PointD pt = IntersectPoint(pt1, pt2, pt3, pt4); + PointD pt = new PointD(); + InternalClipper.GetLineIntersectPt(pt1, pt2, pt3, pt4, pt); pathOut.add(new Point64(pt)); // get the second intersect point through reflecion pathOut.add(new Point64(ReflectPoint(pt, ptQ))); diff --git a/src/main/java/clipper2/rectclip/RectClip64.java b/src/main/java/clipper2/rectclip/RectClip64.java index b538492..dcb705b 100644 --- a/src/main/java/clipper2/rectclip/RectClip64.java +++ b/src/main/java/clipper2/rectclip/RectClip64.java @@ -130,7 +130,7 @@ private static boolean path1ContainsPath2(Path64 p1, Path64 p2) { private static boolean isClockwise(Location prev, Location curr, Point64 p1, Point64 p2, Point64 mid) { if (areOpposites(prev, curr)) { - return InternalClipper.CrossProduct(p1, mid, p2) < 0; + return InternalClipper.CrossProductSign(p1, mid, p2) < 0; } return headingClockwise(prev, curr); } @@ -281,8 +281,8 @@ private static boolean isHorizontal(Point64 a, Point64 b) { } private static boolean getSegmentIntersection(Point64 p1, Point64 p2, Point64 p3, Point64 p4, Point64 ipRefObject) { - double r1 = InternalClipper.CrossProduct(p1, p3, p4); - double r2 = InternalClipper.CrossProduct(p2, p3, p4); + int r1 = InternalClipper.CrossProductSign(p1, p3, p4); + int r2 = InternalClipper.CrossProductSign(p2, p3, p4); if (r1 == 0) { ipRefObject.set(p1); if (r2 == 0) { @@ -310,8 +310,8 @@ private static boolean getSegmentIntersection(Point64 p1, Point64 p2, Point64 p3 ipRefObject.set(new Point64(0, 0)); return false; } - double r3 = InternalClipper.CrossProduct(p3, p1, p2); - double r4 = InternalClipper.CrossProduct(p4, p1, p2); + int r3 = InternalClipper.CrossProductSign(p3, p1, p2); + int r4 = InternalClipper.CrossProductSign(p4, p1, p2); if (r3 == 0) { ipRefObject.set(p3); if (p3.equals(p1) || p3.equals(p2)) { @@ -336,7 +336,7 @@ private static boolean getSegmentIntersection(Point64 p1, Point64 p2, Point64 p3 ipRefObject.set(new Point64(0, 0)); return false; } - return InternalClipper.GetSegmentIntersectPt(p1, p2, p3, p4, ipRefObject); + return InternalClipper.GetLineIntersectPt(p1, p2, p3, p4, ipRefObject); } protected static IntersectionResult getIntersection(Path64 rectPath, Point64 p, Point64 p2, Location loc, Point64 ipRefObject) { diff --git a/src/test/java/clipper2/TestPolygons.java b/src/test/java/clipper2/TestPolygons.java index f5fb0a5..2d1dfe1 100644 --- a/src/test/java/clipper2/TestPolygons.java +++ b/src/test/java/clipper2/TestPolygons.java @@ -50,8 +50,10 @@ final void RunPolygonsTestCase(TestCase test, int testNum, Object o, Object o1) assertTrue(countDiff <= 7, "Diff=" + countDiff); } else if (testNum == 126) { assertTrue(countDiff <= 3); - } else if (Arrays.asList(16, 27, 121).contains(testNum)) { + } else if (Arrays.asList(16, 27).contains(testNum)) { assertTrue(countDiff <= 2); + } else if (testNum == 121) { + assertTrue(countDiff <= 3); } else if (testNum >= 120) { assertTrue(countDiff <= 6); } else if (Arrays.asList(23, 37, 43, 45, 87, 102, 111, 118, 119).contains(testNum)) { diff --git a/src/test/java/clipper2/TestPolytree.java b/src/test/java/clipper2/TestPolytree.java index afbe2a9..4661d65 100644 --- a/src/test/java/clipper2/TestPolytree.java +++ b/src/test/java/clipper2/TestPolytree.java @@ -15,6 +15,8 @@ import org.junit.jupiter.params.provider.MethodSource; import clipper2.ClipperFileIO.TestCase; +import clipper2.core.ClipType; +import clipper2.core.FillRule; import clipper2.core.Path64; import clipper2.core.Paths64; import clipper2.core.Point64; @@ -212,4 +214,82 @@ void TestPolytree5() { // #973 assertTrue(solutionTree.getCount() == 1 && solutionTree.get(0).getCount() == 2); } + @Test + void TestPolytreeUnion() { + Paths64 subject = new Paths64(); + subject.add(Clipper.MakePath(new long[] { 0, 0, 0, 5, 5, 5, 5, 0 })); + subject.add(Clipper.MakePath(new long[] { 1, 1, 1, 6, 6, 6, 6, 1 })); + + Clipper64 clipper = new Clipper64(); + clipper.AddSubject(subject); + + PolyTree64 solution = new PolyTree64(); + Paths64 openPaths = new Paths64(); + if (Clipper.IsPositive(subject.get(0))) { + clipper.Execute(ClipType.Union, FillRule.Positive, solution, openPaths); + } else { + clipper.setReverseSolution(true); + clipper.Execute(ClipType.Union, FillRule.Negative, solution, openPaths); + } + + assertEquals(0, openPaths.size()); + assertEquals(1, solution.getCount()); + assertEquals(8, solution.get(0).getPolygon().size()); + assertEquals(Clipper.IsPositive(subject.get(0)), Clipper.IsPositive(solution.get(0).getPolygon())); + } + + @Test + void TestPolytreeUnion2() { // #987 + Paths64 subject = new Paths64(); + subject.add(Clipper.MakePath(new long[] { 534, 1024, 534, -800, 1026, -800, 1026, 1024 })); + subject.add(Clipper.MakePath(new long[] { 1, 1024, 8721, 1024, 8721, 1920, 1, 1920 })); + subject.add(Clipper.MakePath(new long[] { 30, 1024, 30, -800, 70, -800, 70, 1024 })); + subject.add(Clipper.MakePath(new long[] { 1, 1024, 1, -1024, 3841, -1024, 3841, 1024 })); + subject.add(Clipper.MakePath(new long[] { 3900, -1024, 6145, -1024, 6145, 1024, 3900, 1024 })); + subject.add(Clipper.MakePath(new long[] { 5884, 1024, 5662, 1024, 5662, -1024, 5884, -1024 })); + subject.add(Clipper.MakePath(new long[] { 534, 1024, 200, 1024, 200, -800, 534, -800 })); + subject.add(Clipper.MakePath(new long[] { 200, -800, 200, 1024, 70, 1024, 70, -800 })); + subject.add(Clipper.MakePath(new long[] { 1200, 1920, 1313, 1920, 1313, -800, 1200, -800 })); + subject.add(Clipper.MakePath(new long[] { 6045, -800, 6045, 1024, 5884, 1024, 5884, -800 })); + + Clipper64 clipper = new Clipper64(); + clipper.AddSubject(subject); + PolyTree64 solution = new PolyTree64(); + Paths64 openPaths = new Paths64(); + clipper.Execute(ClipType.Union, FillRule.EvenOdd, solution, openPaths); + + assertEquals(1, solution.getCount()); + assertEquals(1, solution.get(0).getCount()); + } + + @Test + void TestPolytreeUnion3() { + Paths64 subject = new Paths64(); + subject.add(Clipper.MakePath(new long[] { + -120927680, 590077597, + -120919386, 590077307, + -120919432, 590077309, + -120919451, 590077309, + -120919455, 590077310, + -120099297, 590048669, + -120928004, 590077608, + -120902794, 590076728, + -120919444, 590077309, + -120919450, 590077309, + -120919842, 590077323, + -120922852, 590077428, + -120902452, 590076716, + -120902455, 590076716, + -120912590, 590077070, + 11914491, 249689797 + })); + + Clipper64 clipper = new Clipper64(); + clipper.AddSubject(subject); + PolyTree64 solution = new PolyTree64(); + clipper.Execute(ClipType.Union, FillRule.EvenOdd, solution); + + assertTrue(solution.getCount() >= 0); + } + } diff --git a/src/test/java/clipper2/TestToStringOutput.java b/src/test/java/clipper2/TestToStringOutput.java index 45059bf..4203aa4 100644 --- a/src/test/java/clipper2/TestToStringOutput.java +++ b/src/test/java/clipper2/TestToStringOutput.java @@ -18,7 +18,7 @@ class TestToStringOutput { @Test void path64ToStringMatchesExistingFormat() { Path64 path = new Path64(new Point64(1, 2), new Point64(3, 4)); - assertEquals("(1,2) , (3,4) ", path.toString()); + assertEquals("(1,2), (3,4)", path.toString()); } @Test @@ -26,13 +26,13 @@ void pathDToStringMatchesExistingFormat() { PathD path = new PathD(2); path.add(new PointD(1.5, 2.5)); path.add(new PointD(3.5, 4.5)); - assertEquals("(1.500000,2.500000) , (3.500000,4.500000) ", path.toString()); + assertEquals("(1.500000,2.500000), (3.500000,4.500000)", path.toString()); } @Test void paths64ToStringMatchesExistingFormat() { Paths64 paths = new Paths64(new Path64(new Point64(1, 2))); - assertEquals("(1,2) \n", paths.toString()); + assertEquals("(1,2)", paths.toString()); } @Test @@ -41,7 +41,7 @@ void pathsDToStringMatchesExistingFormat() { PathD path = new PathD(1); path.add(new PointD(1.5, 2.5)); paths.add(path); - assertEquals("(1.500000,2.500000) \n", paths.toString()); + assertEquals("(1.500000,2.500000)", paths.toString()); } @Test From bf8ed3b8ed567022c1dd971ebdada35dfbb789fb Mon Sep 17 00:00:00 2001 From: Michael Carleton Date: Mon, 9 Mar 2026 11:20:39 +0000 Subject: [PATCH 2/3] repackage to com.github.micycle1.clipper2 --- README.md | 11 +--- pom.xml | 2 +- .../github/micycle1}/clipper2/Clipper.java | 52 +++++++++---------- .../github/micycle1}/clipper2/Minkowski.java | 14 ++--- .../github/micycle1}/clipper2/Nullable.java | 2 +- .../micycle1}/clipper2/core/ClipType.java | 2 +- .../micycle1}/clipper2/core/FillRule.java | 2 +- .../clipper2/core/InternalClipper.java | 6 +-- .../micycle1}/clipper2/core/Path64.java | 2 +- .../github/micycle1}/clipper2/core/PathD.java | 2 +- .../micycle1}/clipper2/core/PathType.java | 2 +- .../micycle1}/clipper2/core/Paths64.java | 2 +- .../micycle1}/clipper2/core/PathsD.java | 2 +- .../micycle1}/clipper2/core/Point64.java | 2 +- .../micycle1}/clipper2/core/PointD.java | 2 +- .../micycle1}/clipper2/core/Rect64.java | 2 +- .../github/micycle1}/clipper2/core/RectD.java | 2 +- .../micycle1}/clipper2/core/package-info.java | 2 +- .../micycle1}/clipper2/engine/Clipper64.java | 12 ++--- .../clipper2/engine/ClipperBase.java | 22 ++++---- .../micycle1}/clipper2/engine/ClipperD.java | 20 +++---- .../clipper2/engine/LocalMinima.java | 6 +-- .../clipper2/engine/NodeIterator.java | 2 +- .../clipper2/engine/PointInPolygonResult.java | 2 +- .../micycle1}/clipper2/engine/PolyPath64.java | 8 +-- .../clipper2/engine/PolyPathBase.java | 6 +-- .../micycle1}/clipper2/engine/PolyPathD.java | 10 ++-- .../micycle1}/clipper2/engine/PolyTree64.java | 2 +- .../micycle1}/clipper2/engine/PolyTreeD.java | 2 +- .../clipper2/engine/package-info.java | 2 +- .../clipper2/offset/ClipperOffset.java | 26 +++++----- .../clipper2/offset/DeltaCallback64.java | 6 +-- .../micycle1}/clipper2/offset/EndType.java | 2 +- .../micycle1}/clipper2/offset/Group.java | 10 ++-- .../micycle1}/clipper2/offset/JoinType.java | 2 +- .../clipper2/offset/package-info.java | 2 +- .../micycle1}/clipper2/package-info.java | 2 +- .../clipper2/rectclip/RectClip64.java | 16 +++--- .../clipper2/rectclip/RectClipLines64.java | 12 ++--- .../clipper2/rectclip/package-info.java | 2 +- src/main/java9/module-info.java | 10 ++-- .../micycle1}/clipper2/BenchmarkClipper1.java | 2 +- .../micycle1}/clipper2/BenchmarkClipper2.java | 14 ++--- .../micycle1}/clipper2/ClipperFileIO.java | 13 ++--- .../micycle1}/clipper2/TestIsCollinear.java | 18 +++---- .../github/micycle1}/clipper2/TestLines.java | 9 ++-- .../clipper2/TestOffsetOrientation.java | 13 ++--- .../micycle1}/clipper2/TestOffsets.java | 19 +++---- .../micycle1}/clipper2/TestPolygons.java | 13 ++--- .../micycle1}/clipper2/TestPolytree.java | 30 +++++------ .../github/micycle1}/clipper2/TestRect.java | 4 +- .../micycle1}/clipper2/TestRectClip.java | 13 ++--- .../clipper2/TestToStringOutput.java | 18 +++---- 53 files changed, 229 insertions(+), 232 deletions(-) rename src/main/java/{ => com/github/micycle1}/clipper2/Clipper.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/Minkowski.java (87%) rename src/main/java/{ => com/github/micycle1}/clipper2/Nullable.java (96%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/ClipType.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/FillRule.java (96%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/InternalClipper.java (98%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/Path64.java (96%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/PathD.java (95%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/PathType.java (50%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/Paths64.java (94%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/PathsD.java (94%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/Point64.java (98%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/PointD.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/Rect64.java (98%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/RectD.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/core/package-info.java (63%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/Clipper64.java (91%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/ClipperBase.java (99%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/ClipperD.java (88%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/LocalMinima.java (85%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/NodeIterator.java (92%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/PointInPolygonResult.java (59%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/PolyPath64.java (86%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/PolyPathBase.java (94%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/PolyPathD.java (82%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/PolyTree64.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/PolyTreeD.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/engine/package-info.java (94%) rename src/main/java/{ => com/github/micycle1}/clipper2/offset/ClipperOffset.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/offset/DeltaCallback64.java (91%) rename src/main/java/{ => com/github/micycle1}/clipper2/offset/EndType.java (94%) rename src/main/java/{ => com/github/micycle1}/clipper2/offset/Group.java (88%) rename src/main/java/{ => com/github/micycle1}/clipper2/offset/JoinType.java (97%) rename src/main/java/{ => com/github/micycle1}/clipper2/offset/package-info.java (84%) rename src/main/java/{ => com/github/micycle1}/clipper2/package-info.java (75%) rename src/main/java/{ => com/github/micycle1}/clipper2/rectclip/RectClip64.java (98%) rename src/main/java/{ => com/github/micycle1}/clipper2/rectclip/RectClipLines64.java (90%) rename src/main/java/{ => com/github/micycle1}/clipper2/rectclip/package-info.java (73%) rename src/test/java/{ => com/github/micycle1}/clipper2/BenchmarkClipper1.java (98%) rename src/test/java/{ => com/github/micycle1}/clipper2/BenchmarkClipper2.java (85%) rename src/test/java/{ => com/github/micycle1}/clipper2/ClipperFileIO.java (94%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestIsCollinear.java (87%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestLines.java (84%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestOffsetOrientation.java (82%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestOffsets.java (97%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestPolygons.java (90%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestPolytree.java (93%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestRect.java (94%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestRectClip.java (95%) rename src/test/java/{ => com/github/micycle1}/clipper2/TestToStringOutput.java (73%) diff --git a/README.md b/README.md index dcc5432..66dde54 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Clipper2-java is a fast planar geometry library for: The interface of *Clipper2-java* aims to match the original C# version closely. -For simple use cases, the static methods in `clipper2.Clipper` are sufficient. +For simple use cases, the static methods in `Clipper` class are sufficient. For advanced scenarios (open paths, PolyTree nesting, reusing engines), use `Clipper64` / `ClipperD` directly. @@ -45,15 +45,6 @@ solution.get(0).forEach(p -> System.out.println(p.toString())); *Clipper2-java* is available as a Maven/Gradle artifact via [Jitpack](https://jitpack.io/#micycle1/Clipper2-java). -## Port Info -* _tangiblesoftwaresolutions_' C# to Java Converter did the heavy lifting (but then a lot of manual work was required). -* Wrapper objects are used to replicate C# `ref` (pass-by-reference) behaviour. This isn't very Java-esque but avoids an unmanageable refactoring effort. -* Code passes all tests: polygon, line and polytree. -* Uses lower-case (x, y) for point coordinates. -* Private local variables have been renamed to their _camelCase_ variant but public methods (i.e. those of `Clipper.class`) retain their C# _PascalCase_ names (for now...). -* Benchmarks can be run by including `jmh:benchmark` to the chosen maven goal. -* `scanlineList` from `ClipperBase` uses Java `TreeSet` (variable renamed to `scanlineSet`). - ## Benchmark _lightbringer's_ Java [port](https://github.com/lightbringer/clipper-java) of Clipper1 is benchmarked against this project in the benchmarks. *Clipper2-java* is faster, which becomes more pronounced input size grows. ``` diff --git a/pom.xml b/pom.xml index 67ddba3..b957b74 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - micycle + com.github.micycle clipper2 2.0.1 Clipper2 diff --git a/src/main/java/clipper2/Clipper.java b/src/main/java/com/github/micycle1/clipper2/Clipper.java similarity index 97% rename from src/main/java/clipper2/Clipper.java rename to src/main/java/com/github/micycle1/clipper2/Clipper.java index 59064fb..51cc720 100644 --- a/src/main/java/clipper2/Clipper.java +++ b/src/main/java/com/github/micycle1/clipper2/Clipper.java @@ -1,34 +1,34 @@ -package clipper2; +package com.github.micycle1.clipper2; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.InternalClipper; -import clipper2.core.Path64; -import clipper2.core.PathD; -import clipper2.core.PathType; -import clipper2.core.Paths64; -import clipper2.core.PathsD; -import clipper2.core.Point64; -import clipper2.core.PointD; -import clipper2.core.Rect64; -import clipper2.core.RectD; -import clipper2.engine.Clipper64; -import clipper2.engine.ClipperD; -import clipper2.engine.PointInPolygonResult; -import clipper2.engine.PolyPath64; -import clipper2.engine.PolyPathBase; -import clipper2.engine.PolyPathD; -import clipper2.engine.PolyTree64; -import clipper2.engine.PolyTreeD; -import clipper2.offset.ClipperOffset; -import clipper2.offset.EndType; -import clipper2.offset.JoinType; -import clipper2.rectclip.RectClip64; -import clipper2.rectclip.RectClipLines64; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.InternalClipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathD; +import com.github.micycle1.clipper2.core.PathType; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.PathsD; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.core.PointD; +import com.github.micycle1.clipper2.core.Rect64; +import com.github.micycle1.clipper2.core.RectD; +import com.github.micycle1.clipper2.engine.Clipper64; +import com.github.micycle1.clipper2.engine.ClipperD; +import com.github.micycle1.clipper2.engine.PointInPolygonResult; +import com.github.micycle1.clipper2.engine.PolyPath64; +import com.github.micycle1.clipper2.engine.PolyPathBase; +import com.github.micycle1.clipper2.engine.PolyPathD; +import com.github.micycle1.clipper2.engine.PolyTree64; +import com.github.micycle1.clipper2.engine.PolyTreeD; +import com.github.micycle1.clipper2.offset.ClipperOffset; +import com.github.micycle1.clipper2.offset.EndType; +import com.github.micycle1.clipper2.offset.JoinType; +import com.github.micycle1.clipper2.rectclip.RectClip64; +import com.github.micycle1.clipper2.rectclip.RectClipLines64; /** * Line and polygon clipping, and offsetting. diff --git a/src/main/java/clipper2/Minkowski.java b/src/main/java/com/github/micycle1/clipper2/Minkowski.java similarity index 87% rename from src/main/java/clipper2/Minkowski.java rename to src/main/java/com/github/micycle1/clipper2/Minkowski.java index 3b0e1b3..11578b5 100644 --- a/src/main/java/clipper2/Minkowski.java +++ b/src/main/java/com/github/micycle1/clipper2/Minkowski.java @@ -1,11 +1,11 @@ -package clipper2; +package com.github.micycle1.clipper2; -import clipper2.core.FillRule; -import clipper2.core.Path64; -import clipper2.core.PathD; -import clipper2.core.Paths64; -import clipper2.core.PathsD; -import clipper2.core.Point64; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathD; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.PathsD; +import com.github.micycle1.clipper2.core.Point64; public final class Minkowski { diff --git a/src/main/java/clipper2/Nullable.java b/src/main/java/com/github/micycle1/clipper2/Nullable.java similarity index 96% rename from src/main/java/clipper2/Nullable.java rename to src/main/java/com/github/micycle1/clipper2/Nullable.java index a041fe1..0205484 100644 --- a/src/main/java/clipper2/Nullable.java +++ b/src/main/java/com/github/micycle1/clipper2/Nullable.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/clipper2/core/ClipType.java b/src/main/java/com/github/micycle1/clipper2/core/ClipType.java similarity index 97% rename from src/main/java/clipper2/core/ClipType.java rename to src/main/java/com/github/micycle1/clipper2/core/ClipType.java index 72b1b07..e9b2684 100644 --- a/src/main/java/clipper2/core/ClipType.java +++ b/src/main/java/com/github/micycle1/clipper2/core/ClipType.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; /** * All polygon clipping is performed with a Clipper object with the specific diff --git a/src/main/java/clipper2/core/FillRule.java b/src/main/java/com/github/micycle1/clipper2/core/FillRule.java similarity index 96% rename from src/main/java/clipper2/core/FillRule.java rename to src/main/java/com/github/micycle1/clipper2/core/FillRule.java index 5c850d2..c3385a2 100644 --- a/src/main/java/clipper2/core/FillRule.java +++ b/src/main/java/com/github/micycle1/clipper2/core/FillRule.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; /** * Complex polygons are defined by one or more closed paths that set both outer diff --git a/src/main/java/clipper2/core/InternalClipper.java b/src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java similarity index 98% rename from src/main/java/clipper2/core/InternalClipper.java rename to src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java index 786655f..78b9d07 100644 --- a/src/main/java/clipper2/core/InternalClipper.java +++ b/src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java @@ -1,6 +1,6 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; -import clipper2.engine.PointInPolygonResult; +import com.github.micycle1.clipper2.engine.PointInPolygonResult; public final class InternalClipper { @@ -352,7 +352,7 @@ public static Rect64 GetBounds(Path64 path) { if (path.isEmpty()) { return new Rect64(); } - Rect64 result = clipper2.Clipper.InvalidRect64.clone(); + Rect64 result = com.github.micycle1.clipper2.Clipper.InvalidRect64.clone(); for (Point64 pt : path) { if (pt.x < result.left) { result.left = pt.x; diff --git a/src/main/java/clipper2/core/Path64.java b/src/main/java/com/github/micycle1/clipper2/core/Path64.java similarity index 96% rename from src/main/java/clipper2/core/Path64.java rename to src/main/java/com/github/micycle1/clipper2/core/Path64.java index c780d95..f888286 100644 --- a/src/main/java/clipper2/core/Path64.java +++ b/src/main/java/com/github/micycle1/clipper2/core/Path64.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/clipper2/core/PathD.java b/src/main/java/com/github/micycle1/clipper2/core/PathD.java similarity index 95% rename from src/main/java/clipper2/core/PathD.java rename to src/main/java/com/github/micycle1/clipper2/core/PathD.java index d1b1df3..b6a1314 100644 --- a/src/main/java/clipper2/core/PathD.java +++ b/src/main/java/com/github/micycle1/clipper2/core/PathD.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/clipper2/core/PathType.java b/src/main/java/com/github/micycle1/clipper2/core/PathType.java similarity index 50% rename from src/main/java/clipper2/core/PathType.java rename to src/main/java/com/github/micycle1/clipper2/core/PathType.java index 4309eeb..a3fc2e4 100644 --- a/src/main/java/clipper2/core/PathType.java +++ b/src/main/java/com/github/micycle1/clipper2/core/PathType.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; public enum PathType { diff --git a/src/main/java/clipper2/core/Paths64.java b/src/main/java/com/github/micycle1/clipper2/core/Paths64.java similarity index 94% rename from src/main/java/clipper2/core/Paths64.java rename to src/main/java/com/github/micycle1/clipper2/core/Paths64.java index 47b0a66..ccf6116 100644 --- a/src/main/java/clipper2/core/Paths64.java +++ b/src/main/java/com/github/micycle1/clipper2/core/Paths64.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/clipper2/core/PathsD.java b/src/main/java/com/github/micycle1/clipper2/core/PathsD.java similarity index 94% rename from src/main/java/clipper2/core/PathsD.java rename to src/main/java/com/github/micycle1/clipper2/core/PathsD.java index 3244f29..1aa268b 100644 --- a/src/main/java/clipper2/core/PathsD.java +++ b/src/main/java/com/github/micycle1/clipper2/core/PathsD.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/clipper2/core/Point64.java b/src/main/java/com/github/micycle1/clipper2/core/Point64.java similarity index 98% rename from src/main/java/clipper2/core/Point64.java rename to src/main/java/com/github/micycle1/clipper2/core/Point64.java index 392c060..bc11a0b 100644 --- a/src/main/java/clipper2/core/Point64.java +++ b/src/main/java/com/github/micycle1/clipper2/core/Point64.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; /** * The Point64 structure is used to represent a single vertex (or coordinate) in diff --git a/src/main/java/clipper2/core/PointD.java b/src/main/java/com/github/micycle1/clipper2/core/PointD.java similarity index 97% rename from src/main/java/clipper2/core/PointD.java rename to src/main/java/com/github/micycle1/clipper2/core/PointD.java index b5bd6b0..74634da 100644 --- a/src/main/java/clipper2/core/PointD.java +++ b/src/main/java/com/github/micycle1/clipper2/core/PointD.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; /** * The PointD structure is used to represent a single floating point coordinate. diff --git a/src/main/java/clipper2/core/Rect64.java b/src/main/java/com/github/micycle1/clipper2/core/Rect64.java similarity index 98% rename from src/main/java/clipper2/core/Rect64.java rename to src/main/java/com/github/micycle1/clipper2/core/Rect64.java index cfd1d77..5dda2e4 100644 --- a/src/main/java/clipper2/core/Rect64.java +++ b/src/main/java/com/github/micycle1/clipper2/core/Rect64.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; public final class Rect64 { diff --git a/src/main/java/clipper2/core/RectD.java b/src/main/java/com/github/micycle1/clipper2/core/RectD.java similarity index 97% rename from src/main/java/clipper2/core/RectD.java rename to src/main/java/com/github/micycle1/clipper2/core/RectD.java index 1c51fe9..fccb53c 100644 --- a/src/main/java/clipper2/core/RectD.java +++ b/src/main/java/com/github/micycle1/clipper2/core/RectD.java @@ -1,4 +1,4 @@ -package clipper2.core; +package com.github.micycle1.clipper2.core; import java.util.Arrays; diff --git a/src/main/java/clipper2/core/package-info.java b/src/main/java/com/github/micycle1/clipper2/core/package-info.java similarity index 63% rename from src/main/java/clipper2/core/package-info.java rename to src/main/java/com/github/micycle1/clipper2/core/package-info.java index e10e54a..3c34c81 100644 --- a/src/main/java/clipper2/core/package-info.java +++ b/src/main/java/com/github/micycle1/clipper2/core/package-info.java @@ -1,4 +1,4 @@ /** * Core geometry types and enums used throughout the Clipper2 API. */ -package clipper2.core; +package com.github.micycle1.clipper2.core; diff --git a/src/main/java/clipper2/engine/Clipper64.java b/src/main/java/com/github/micycle1/clipper2/engine/Clipper64.java similarity index 91% rename from src/main/java/clipper2/engine/Clipper64.java rename to src/main/java/com/github/micycle1/clipper2/engine/Clipper64.java index bbc9bff..cd56977 100644 --- a/src/main/java/clipper2/engine/Clipper64.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/Clipper64.java @@ -1,10 +1,10 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.Path64; -import clipper2.core.PathType; -import clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathType; +import com.github.micycle1.clipper2.core.Paths64; /** * The Clipper class performs boolean 'clipping'. This class is very similar to diff --git a/src/main/java/clipper2/engine/ClipperBase.java b/src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java similarity index 99% rename from src/main/java/clipper2/engine/ClipperBase.java rename to src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java index 7fd315b..85e1c23 100644 --- a/src/main/java/clipper2/engine/ClipperBase.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java @@ -1,4 +1,4 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; import java.util.ArrayList; import java.util.Collections; @@ -6,16 +6,16 @@ import java.util.NavigableSet; import java.util.TreeSet; -import clipper2.Clipper; -import clipper2.Nullable; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.InternalClipper; -import clipper2.core.Path64; -import clipper2.core.PathType; -import clipper2.core.Paths64; -import clipper2.core.Point64; -import clipper2.core.Rect64; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.Nullable; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.InternalClipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathType; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.core.Rect64; /** * Subject and Clip paths are passed to a Clipper object via AddSubject, diff --git a/src/main/java/clipper2/engine/ClipperD.java b/src/main/java/com/github/micycle1/clipper2/engine/ClipperD.java similarity index 88% rename from src/main/java/clipper2/engine/ClipperD.java rename to src/main/java/com/github/micycle1/clipper2/engine/ClipperD.java index a721481..5846097 100644 --- a/src/main/java/clipper2/engine/ClipperD.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/ClipperD.java @@ -1,13 +1,13 @@ -package clipper2.engine; - -import clipper2.Clipper; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.Path64; -import clipper2.core.PathD; -import clipper2.core.PathType; -import clipper2.core.Paths64; -import clipper2.core.PathsD; +package com.github.micycle1.clipper2.engine; + +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathD; +import com.github.micycle1.clipper2.core.PathType; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.PathsD; /** * The ClipperD class performs boolean 'clipping'. This class is very similar to diff --git a/src/main/java/clipper2/engine/LocalMinima.java b/src/main/java/com/github/micycle1/clipper2/engine/LocalMinima.java similarity index 85% rename from src/main/java/clipper2/engine/LocalMinima.java rename to src/main/java/com/github/micycle1/clipper2/engine/LocalMinima.java index fd71bf9..155e528 100644 --- a/src/main/java/clipper2/engine/LocalMinima.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/LocalMinima.java @@ -1,7 +1,7 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; -import clipper2.core.PathType; -import clipper2.engine.ClipperBase.Vertex; +import com.github.micycle1.clipper2.core.PathType; +import com.github.micycle1.clipper2.engine.ClipperBase.Vertex; final class LocalMinima { diff --git a/src/main/java/clipper2/engine/NodeIterator.java b/src/main/java/com/github/micycle1/clipper2/engine/NodeIterator.java similarity index 92% rename from src/main/java/clipper2/engine/NodeIterator.java rename to src/main/java/com/github/micycle1/clipper2/engine/NodeIterator.java index 6d751e2..d048ee5 100644 --- a/src/main/java/clipper2/engine/NodeIterator.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/NodeIterator.java @@ -1,4 +1,4 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; import java.util.Iterator; import java.util.List; diff --git a/src/main/java/clipper2/engine/PointInPolygonResult.java b/src/main/java/com/github/micycle1/clipper2/engine/PointInPolygonResult.java similarity index 59% rename from src/main/java/clipper2/engine/PointInPolygonResult.java rename to src/main/java/com/github/micycle1/clipper2/engine/PointInPolygonResult.java index 7e4f892..0964dfa 100644 --- a/src/main/java/clipper2/engine/PointInPolygonResult.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PointInPolygonResult.java @@ -1,4 +1,4 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; public enum PointInPolygonResult { diff --git a/src/main/java/clipper2/engine/PolyPath64.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyPath64.java similarity index 86% rename from src/main/java/clipper2/engine/PolyPath64.java rename to src/main/java/com/github/micycle1/clipper2/engine/PolyPath64.java index 3cb5175..6d81d38 100644 --- a/src/main/java/clipper2/engine/PolyPath64.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyPath64.java @@ -1,8 +1,8 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; -import clipper2.Clipper; -import clipper2.Nullable; -import clipper2.core.Path64; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.Nullable; +import com.github.micycle1.clipper2.core.Path64; /** * PolyPath64 objects are contained inside PolyTree64s and represents a single diff --git a/src/main/java/clipper2/engine/PolyPathBase.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathBase.java similarity index 94% rename from src/main/java/clipper2/engine/PolyPathBase.java rename to src/main/java/com/github/micycle1/clipper2/engine/PolyPathBase.java index c1d9c97..dbaee1f 100644 --- a/src/main/java/clipper2/engine/PolyPathBase.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathBase.java @@ -1,10 +1,10 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; import java.util.ArrayList; import java.util.List; -import clipper2.Nullable; -import clipper2.core.Path64; +import com.github.micycle1.clipper2.Nullable; +import com.github.micycle1.clipper2.core.Path64; public abstract class PolyPathBase implements Iterable { diff --git a/src/main/java/clipper2/engine/PolyPathD.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathD.java similarity index 82% rename from src/main/java/clipper2/engine/PolyPathD.java rename to src/main/java/com/github/micycle1/clipper2/engine/PolyPathD.java index dc557d2..a02fb37 100644 --- a/src/main/java/clipper2/engine/PolyPathD.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathD.java @@ -1,9 +1,9 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; -import clipper2.Clipper; -import clipper2.Nullable; -import clipper2.core.Path64; -import clipper2.core.PathD; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.Nullable; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathD; public class PolyPathD extends PolyPathBase { diff --git a/src/main/java/clipper2/engine/PolyTree64.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyTree64.java similarity index 97% rename from src/main/java/clipper2/engine/PolyTree64.java rename to src/main/java/com/github/micycle1/clipper2/engine/PolyTree64.java index 17100e2..09bceaf 100644 --- a/src/main/java/clipper2/engine/PolyTree64.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyTree64.java @@ -1,4 +1,4 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; /** * PolyTree64 is a read-only data structure that receives solutions from diff --git a/src/main/java/clipper2/engine/PolyTreeD.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyTreeD.java similarity index 97% rename from src/main/java/clipper2/engine/PolyTreeD.java rename to src/main/java/com/github/micycle1/clipper2/engine/PolyTreeD.java index fdb5c3c..f550956 100644 --- a/src/main/java/clipper2/engine/PolyTreeD.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyTreeD.java @@ -1,4 +1,4 @@ -package clipper2.engine; +package com.github.micycle1.clipper2.engine; /** * PolyTreeD is a read-only data structure that receives solutions from clipping diff --git a/src/main/java/clipper2/engine/package-info.java b/src/main/java/com/github/micycle1/clipper2/engine/package-info.java similarity index 94% rename from src/main/java/clipper2/engine/package-info.java rename to src/main/java/com/github/micycle1/clipper2/engine/package-info.java index cd56b99..caa1d7c 100644 --- a/src/main/java/clipper2/engine/package-info.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/package-info.java @@ -13,4 +13,4 @@ * Polytree structure reflects polygon ownership (which polygons contain other * polygons). But using Polytrees will slow clipping, usually by 10-50%. */ -package clipper2.engine; \ No newline at end of file +package com.github.micycle1.clipper2.engine; \ No newline at end of file diff --git a/src/main/java/clipper2/offset/ClipperOffset.java b/src/main/java/com/github/micycle1/clipper2/offset/ClipperOffset.java similarity index 97% rename from src/main/java/clipper2/offset/ClipperOffset.java rename to src/main/java/com/github/micycle1/clipper2/offset/ClipperOffset.java index 1531bcb..33ca3a9 100644 --- a/src/main/java/clipper2/offset/ClipperOffset.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/ClipperOffset.java @@ -1,21 +1,21 @@ -package clipper2.offset; +package com.github.micycle1.clipper2.offset; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import clipper2.Clipper; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.InternalClipper; -import clipper2.core.Path64; -import clipper2.core.PathD; -import clipper2.core.Paths64; -import clipper2.core.Point64; -import clipper2.core.PointD; -import clipper2.core.Rect64; -import clipper2.engine.Clipper64; -import clipper2.engine.PolyTree64; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.InternalClipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathD; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.core.PointD; +import com.github.micycle1.clipper2.core.Rect64; +import com.github.micycle1.clipper2.engine.Clipper64; +import com.github.micycle1.clipper2.engine.PolyTree64; /** * Manages the process of offsetting (inflating/deflating) both open and closed diff --git a/src/main/java/clipper2/offset/DeltaCallback64.java b/src/main/java/com/github/micycle1/clipper2/offset/DeltaCallback64.java similarity index 91% rename from src/main/java/clipper2/offset/DeltaCallback64.java rename to src/main/java/com/github/micycle1/clipper2/offset/DeltaCallback64.java index f95cf7a..4e04605 100644 --- a/src/main/java/clipper2/offset/DeltaCallback64.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/DeltaCallback64.java @@ -1,7 +1,7 @@ -package clipper2.offset; +package com.github.micycle1.clipper2.offset; -import clipper2.core.Path64; -import clipper2.core.PathD; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathD; /** * Functional interface for calculating a variable delta during polygon diff --git a/src/main/java/clipper2/offset/EndType.java b/src/main/java/com/github/micycle1/clipper2/offset/EndType.java similarity index 94% rename from src/main/java/clipper2/offset/EndType.java rename to src/main/java/com/github/micycle1/clipper2/offset/EndType.java index bb258a6..a854dd6 100644 --- a/src/main/java/clipper2/offset/EndType.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/EndType.java @@ -1,4 +1,4 @@ -package clipper2.offset; +package com.github.micycle1.clipper2.offset; /** * The EndType enumerator is only needed when offsetting (inflating/shrinking). diff --git a/src/main/java/clipper2/offset/Group.java b/src/main/java/com/github/micycle1/clipper2/offset/Group.java similarity index 88% rename from src/main/java/clipper2/offset/Group.java rename to src/main/java/com/github/micycle1/clipper2/offset/Group.java index 8e35a9e..e52357f 100644 --- a/src/main/java/clipper2/offset/Group.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/Group.java @@ -1,11 +1,11 @@ -package clipper2.offset; +package com.github.micycle1.clipper2.offset; import java.util.ArrayList; -import clipper2.Clipper; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Point64; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; class Group { diff --git a/src/main/java/clipper2/offset/JoinType.java b/src/main/java/com/github/micycle1/clipper2/offset/JoinType.java similarity index 97% rename from src/main/java/clipper2/offset/JoinType.java rename to src/main/java/com/github/micycle1/clipper2/offset/JoinType.java index de736fd..009daa8 100644 --- a/src/main/java/clipper2/offset/JoinType.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/JoinType.java @@ -1,4 +1,4 @@ -package clipper2.offset; +package com.github.micycle1.clipper2.offset; /** * The JoinType enumerator is only needed when offsetting (inflating/shrinking). diff --git a/src/main/java/clipper2/offset/package-info.java b/src/main/java/com/github/micycle1/clipper2/offset/package-info.java similarity index 84% rename from src/main/java/clipper2/offset/package-info.java rename to src/main/java/com/github/micycle1/clipper2/offset/package-info.java index b7483f4..62f7575 100644 --- a/src/main/java/clipper2/offset/package-info.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/package-info.java @@ -4,4 +4,4 @@ * performed using the simple InflatePaths function that's found in the Clipper * Unit. */ -package clipper2.offset; \ No newline at end of file +package com.github.micycle1.clipper2.offset; \ No newline at end of file diff --git a/src/main/java/clipper2/package-info.java b/src/main/java/com/github/micycle1/clipper2/package-info.java similarity index 75% rename from src/main/java/clipper2/package-info.java rename to src/main/java/com/github/micycle1/clipper2/package-info.java index 3238498..8b1cc55 100644 --- a/src/main/java/clipper2/package-info.java +++ b/src/main/java/com/github/micycle1/clipper2/package-info.java @@ -2,4 +2,4 @@ * Clipper2 is an open source freeware library that performs line and polygon * clipping, and offsetting. */ -package clipper2; \ No newline at end of file +package com.github.micycle1.clipper2; \ No newline at end of file diff --git a/src/main/java/clipper2/rectclip/RectClip64.java b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java similarity index 98% rename from src/main/java/clipper2/rectclip/RectClip64.java rename to src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java index dcb705b..ee51125 100644 --- a/src/main/java/clipper2/rectclip/RectClip64.java +++ b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java @@ -1,15 +1,15 @@ -package clipper2.rectclip; +package com.github.micycle1.clipper2.rectclip; import java.util.ArrayList; import java.util.List; -import clipper2.Clipper; -import clipper2.core.InternalClipper; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Point64; -import clipper2.core.Rect64; -import clipper2.engine.PointInPolygonResult; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.InternalClipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.core.Rect64; +import com.github.micycle1.clipper2.engine.PointInPolygonResult; /** * RectClip64 intersects subject polygons with the specified rectangular diff --git a/src/main/java/clipper2/rectclip/RectClipLines64.java b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClipLines64.java similarity index 90% rename from src/main/java/clipper2/rectclip/RectClipLines64.java rename to src/main/java/com/github/micycle1/clipper2/rectclip/RectClipLines64.java index 7aca250..f2f08e2 100644 --- a/src/main/java/clipper2/rectclip/RectClipLines64.java +++ b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClipLines64.java @@ -1,10 +1,10 @@ -package clipper2.rectclip; +package com.github.micycle1.clipper2.rectclip; -import clipper2.Clipper; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Point64; -import clipper2.core.Rect64; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.core.Rect64; /** * RectClipLines64 intersects subject open paths (polylines) with the specified diff --git a/src/main/java/clipper2/rectclip/package-info.java b/src/main/java/com/github/micycle1/clipper2/rectclip/package-info.java similarity index 73% rename from src/main/java/clipper2/rectclip/package-info.java rename to src/main/java/com/github/micycle1/clipper2/rectclip/package-info.java index ec7f2f2..4b804aa 100644 --- a/src/main/java/clipper2/rectclip/package-info.java +++ b/src/main/java/com/github/micycle1/clipper2/rectclip/package-info.java @@ -4,4 +4,4 @@ * * @since 1.0.6 */ -package clipper2.rectclip; \ No newline at end of file +package com.github.micycle1.clipper2.rectclip; \ No newline at end of file diff --git a/src/main/java9/module-info.java b/src/main/java9/module-info.java index 2cfe063..ff87d84 100644 --- a/src/main/java9/module-info.java +++ b/src/main/java9/module-info.java @@ -1,7 +1,7 @@ module clipper2 { - exports clipper2; - exports clipper2.core; - exports clipper2.engine; - exports clipper2.offset; - exports clipper2.rectclip; + exports com.github.micycle1.clipper2; + exports com.github.micycle1.clipper2.core; + exports com.github.micycle1.clipper2.engine; + exports com.github.micycle1.clipper2.offset; + exports com.github.micycle1.clipper2.rectclip; } diff --git a/src/test/java/clipper2/BenchmarkClipper1.java b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper1.java similarity index 98% rename from src/test/java/clipper2/BenchmarkClipper1.java rename to src/test/java/com/github/micycle1/clipper2/BenchmarkClipper1.java index 8782406..d36f758 100644 --- a/src/test/java/clipper2/BenchmarkClipper1.java +++ b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper1.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import java.util.Random; import java.util.concurrent.TimeUnit; diff --git a/src/test/java/clipper2/BenchmarkClipper2.java b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper2.java similarity index 85% rename from src/test/java/clipper2/BenchmarkClipper2.java rename to src/test/java/com/github/micycle1/clipper2/BenchmarkClipper2.java index 00600b1..c0e761e 100644 --- a/src/test/java/clipper2/BenchmarkClipper2.java +++ b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper2.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import java.util.Random; import java.util.concurrent.TimeUnit; @@ -12,12 +12,12 @@ import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Point64; -import clipper2.engine.Clipper64; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.engine.Clipper64; /** * Benchmarks for Clipper 2. Class is located within test folder in order to be diff --git a/src/test/java/clipper2/ClipperFileIO.java b/src/test/java/com/github/micycle1/clipper2/ClipperFileIO.java similarity index 94% rename from src/test/java/clipper2/ClipperFileIO.java rename to src/test/java/com/github/micycle1/clipper2/ClipperFileIO.java index 5a6912e..45990c4 100644 --- a/src/test/java/clipper2/ClipperFileIO.java +++ b/src/test/java/com/github/micycle1/clipper2/ClipperFileIO.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import java.io.IOException; import java.nio.file.Files; @@ -6,11 +6,12 @@ import java.util.ArrayList; import java.util.List; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Point64; +import com.github.micycle1.clipper2.Nullable; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; class ClipperFileIO { diff --git a/src/test/java/clipper2/TestIsCollinear.java b/src/test/java/com/github/micycle1/clipper2/TestIsCollinear.java similarity index 87% rename from src/test/java/clipper2/TestIsCollinear.java rename to src/test/java/com/github/micycle1/clipper2/TestIsCollinear.java index e493236..33f95dc 100644 --- a/src/test/java/clipper2/TestIsCollinear.java +++ b/src/test/java/com/github/micycle1/clipper2/TestIsCollinear.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -8,13 +8,13 @@ import org.junit.jupiter.api.Test; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.InternalClipper; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Point64; -import clipper2.engine.Clipper64; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.InternalClipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.engine.Clipper64; class TestIsCollinear { @@ -31,7 +31,7 @@ private static void assertMulHi(Method mulMethod, Field hiField, String aHex, St void testHiCalculation() throws Exception { Method mulMethod = InternalClipper.class.getDeclaredMethod("multiplyUInt64", long.class, long.class); mulMethod.setAccessible(true); - Class resultClass = Class.forName("clipper2.core.InternalClipper$UInt128Struct"); + Class resultClass = Class.forName("com.github.micycle1.clipper2.core.InternalClipper$UInt128Struct"); Field hiField = resultClass.getDeclaredField("hi64"); hiField.setAccessible(true); diff --git a/src/test/java/clipper2/TestLines.java b/src/test/java/com/github/micycle1/clipper2/TestLines.java similarity index 84% rename from src/test/java/clipper2/TestLines.java rename to src/test/java/com/github/micycle1/clipper2/TestLines.java index 5e2dec1..a90e26f 100644 --- a/src/test/java/clipper2/TestLines.java +++ b/src/test/java/com/github/micycle1/clipper2/TestLines.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -10,9 +10,10 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import clipper2.ClipperFileIO.TestCase; -import clipper2.core.Paths64; -import clipper2.engine.Clipper64; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.ClipperFileIO.TestCase; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.engine.Clipper64; class TestLines { diff --git a/src/test/java/clipper2/TestOffsetOrientation.java b/src/test/java/com/github/micycle1/clipper2/TestOffsetOrientation.java similarity index 82% rename from src/test/java/clipper2/TestOffsetOrientation.java rename to src/test/java/com/github/micycle1/clipper2/TestOffsetOrientation.java index 70f144d..3f8237b 100644 --- a/src/test/java/clipper2/TestOffsetOrientation.java +++ b/src/test/java/com/github/micycle1/clipper2/TestOffsetOrientation.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.*; @@ -6,11 +6,12 @@ import org.junit.jupiter.api.Test; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.offset.ClipperOffset; -import clipper2.offset.EndType; -import clipper2.offset.JoinType; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.offset.ClipperOffset; +import com.github.micycle1.clipper2.offset.EndType; +import com.github.micycle1.clipper2.offset.JoinType; class TestOffsetOrientation { diff --git a/src/test/java/clipper2/TestOffsets.java b/src/test/java/com/github/micycle1/clipper2/TestOffsets.java similarity index 97% rename from src/test/java/clipper2/TestOffsets.java rename to src/test/java/com/github/micycle1/clipper2/TestOffsets.java index fed04fb..69b17a9 100644 --- a/src/test/java/clipper2/TestOffsets.java +++ b/src/test/java/com/github/micycle1/clipper2/TestOffsets.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.*; @@ -7,14 +7,15 @@ import org.junit.jupiter.api.Test; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.PathsD; -import clipper2.core.Point64; -import clipper2.core.PointD; -import clipper2.offset.ClipperOffset; -import clipper2.offset.EndType; -import clipper2.offset.JoinType; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.PathsD; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.core.PointD; +import com.github.micycle1.clipper2.offset.ClipperOffset; +import com.github.micycle1.clipper2.offset.EndType; +import com.github.micycle1.clipper2.offset.JoinType; class TestOffsets { diff --git a/src/test/java/clipper2/TestPolygons.java b/src/test/java/com/github/micycle1/clipper2/TestPolygons.java similarity index 90% rename from src/test/java/clipper2/TestPolygons.java rename to src/test/java/com/github/micycle1/clipper2/TestPolygons.java index 2d1dfe1..1626a27 100644 --- a/src/test/java/clipper2/TestPolygons.java +++ b/src/test/java/com/github/micycle1/clipper2/TestPolygons.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -12,11 +12,12 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import clipper2.ClipperFileIO.TestCase; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.Paths64; -import clipper2.engine.Clipper64; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.ClipperFileIO.TestCase; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.engine.Clipper64; class TestPolygons { diff --git a/src/test/java/clipper2/TestPolytree.java b/src/test/java/com/github/micycle1/clipper2/TestPolytree.java similarity index 93% rename from src/test/java/clipper2/TestPolytree.java rename to src/test/java/com/github/micycle1/clipper2/TestPolytree.java index 4661d65..95dfa36 100644 --- a/src/test/java/clipper2/TestPolytree.java +++ b/src/test/java/com/github/micycle1/clipper2/TestPolytree.java @@ -1,4 +1,4 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -14,17 +14,17 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import clipper2.ClipperFileIO.TestCase; -import clipper2.core.ClipType; -import clipper2.core.FillRule; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Point64; -import clipper2.engine.Clipper64; -import clipper2.engine.PointInPolygonResult; -import clipper2.engine.PolyPath64; -import clipper2.engine.PolyPathBase; -import clipper2.engine.PolyTree64; +import com.github.micycle1.clipper2.ClipperFileIO.TestCase; +import com.github.micycle1.clipper2.core.ClipType; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.engine.Clipper64; +import com.github.micycle1.clipper2.engine.PointInPolygonResult; +import com.github.micycle1.clipper2.engine.PolyPath64; +import com.github.micycle1.clipper2.engine.PolyPathBase; +import com.github.micycle1.clipper2.engine.PolyTree64; class TestPolytree { @@ -163,7 +163,7 @@ void TestPolytree3() { // #942 PolyTree64 solutionTree = new PolyTree64(); Clipper64 clipper = new Clipper64(); clipper.AddSubject(subject); - clipper.Execute(clipper2.core.ClipType.Union, clipper2.core.FillRule.NonZero, solutionTree); + clipper.Execute(ClipType.Union, FillRule.NonZero, solutionTree); assertTrue(solutionTree.getCount() == 1 && solutionTree.get(0).getCount() == 2 && solutionTree.get(0).get(1).getCount() == 1); } @@ -192,7 +192,7 @@ void TestPolytree4() { // #957 PolyTree64 solutionTree = new PolyTree64(); Clipper64 clipper = new Clipper64(); clipper.AddSubject(subject); - clipper.Execute(clipper2.core.ClipType.Union, clipper2.core.FillRule.NonZero, solutionTree); + clipper.Execute(ClipType.Union, FillRule.NonZero, solutionTree); assertTrue(solutionTree.getCount() == 1 && solutionTree.get(0).getCount() == 2 && solutionTree.get(0).get(0).getCount() == 1); } @@ -209,7 +209,7 @@ void TestPolytree5() { // #973 PolyTree64 solutionTree = new PolyTree64(); Clipper64 clipper = new Clipper64(); clipper.AddSubject(subject); - clipper.Execute(clipper2.core.ClipType.Union, clipper2.core.FillRule.NonZero, solutionTree); + clipper.Execute(ClipType.Union, FillRule.NonZero, solutionTree); assertTrue(solutionTree.getCount() == 1 && solutionTree.get(0).getCount() == 2); } diff --git a/src/test/java/clipper2/TestRect.java b/src/test/java/com/github/micycle1/clipper2/TestRect.java similarity index 94% rename from src/test/java/clipper2/TestRect.java rename to src/test/java/com/github/micycle1/clipper2/TestRect.java index 491bbce..6133df8 100644 --- a/src/test/java/clipper2/TestRect.java +++ b/src/test/java/com/github/micycle1/clipper2/TestRect.java @@ -1,10 +1,10 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import clipper2.core.Rect64; +import com.github.micycle1.clipper2.core.Rect64; class TestRect { diff --git a/src/test/java/clipper2/TestRectClip.java b/src/test/java/com/github/micycle1/clipper2/TestRectClip.java similarity index 95% rename from src/test/java/clipper2/TestRectClip.java rename to src/test/java/com/github/micycle1/clipper2/TestRectClip.java index 1ab99c6..4f0dd8d 100644 --- a/src/test/java/clipper2/TestRectClip.java +++ b/src/test/java/com/github/micycle1/clipper2/TestRectClip.java @@ -1,14 +1,15 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.*; -import clipper2.core.FillRule; -import clipper2.core.Path64; -import clipper2.core.Paths64; -import clipper2.core.Rect64; - import org.junit.jupiter.api.Test; +import com.github.micycle1.clipper2.Clipper; +import com.github.micycle1.clipper2.core.FillRule; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.Rect64; + /** * RectClip tests. Ported from C++ version. */ diff --git a/src/test/java/clipper2/TestToStringOutput.java b/src/test/java/com/github/micycle1/clipper2/TestToStringOutput.java similarity index 73% rename from src/test/java/clipper2/TestToStringOutput.java rename to src/test/java/com/github/micycle1/clipper2/TestToStringOutput.java index 4203aa4..32adacf 100644 --- a/src/test/java/clipper2/TestToStringOutput.java +++ b/src/test/java/com/github/micycle1/clipper2/TestToStringOutput.java @@ -1,17 +1,17 @@ -package clipper2; +package com.github.micycle1.clipper2; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; -import clipper2.core.Path64; -import clipper2.core.PathD; -import clipper2.core.Paths64; -import clipper2.core.PathsD; -import clipper2.core.Point64; -import clipper2.core.PointD; -import clipper2.engine.PolyPathBase; -import clipper2.engine.PolyTree64; +import com.github.micycle1.clipper2.core.Path64; +import com.github.micycle1.clipper2.core.PathD; +import com.github.micycle1.clipper2.core.Paths64; +import com.github.micycle1.clipper2.core.PathsD; +import com.github.micycle1.clipper2.core.Point64; +import com.github.micycle1.clipper2.core.PointD; +import com.github.micycle1.clipper2.engine.PolyPathBase; +import com.github.micycle1.clipper2.engine.PolyTree64; class TestToStringOutput { From 1d5fd9fa3896d90408c338499e985462e194ccc7 Mon Sep 17 00:00:00 2001 From: Michael Carleton Date: Mon, 9 Mar 2026 11:31:11 +0000 Subject: [PATCH 3/3] camelCase! --- README.md | 6 +- .../com/github/micycle1/clipper2/Clipper.java | 552 +++++++++--------- .../github/micycle1/clipper2/Minkowski.java | 36 +- .../clipper2/core/InternalClipper.java | 66 +-- .../github/micycle1/clipper2/core/PointD.java | 6 +- .../github/micycle1/clipper2/core/Rect64.java | 18 +- .../github/micycle1/clipper2/core/RectD.java | 12 +- .../micycle1/clipper2/engine/Clipper64.java | 52 +- .../micycle1/clipper2/engine/ClipperBase.java | 120 ++-- .../micycle1/clipper2/engine/ClipperD.java | 60 +- .../micycle1/clipper2/engine/PolyPath64.java | 8 +- .../clipper2/engine/PolyPathBase.java | 4 +- .../micycle1/clipper2/engine/PolyPathD.java | 10 +- .../clipper2/offset/ClipperOffset.java | 56 +- .../micycle1/clipper2/offset/Group.java | 4 +- .../clipper2/rectclip/RectClip64.java | 36 +- .../clipper2/rectclip/RectClipLines64.java | 10 +- .../micycle1/clipper2/BenchmarkClipper1.java | 2 +- .../micycle1/clipper2/BenchmarkClipper2.java | 8 +- .../micycle1/clipper2/ClipperFileIO.java | 2 +- .../micycle1/clipper2/TestIsCollinear.java | 6 +- .../github/micycle1/clipper2/TestLines.java | 10 +- .../clipper2/TestOffsetOrientation.java | 16 +- .../github/micycle1/clipper2/TestOffsets.java | 116 ++-- .../micycle1/clipper2/TestPolygons.java | 20 +- .../micycle1/clipper2/TestPolytree.java | 132 ++--- .../micycle1/clipper2/TestRectClip.java | 60 +- .../micycle1/clipper2/TestToStringOutput.java | 4 +- 28 files changed, 701 insertions(+), 731 deletions(-) diff --git a/README.md b/README.md index 66dde54..bf13685 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ Note Clipper2’s core algorithms operate on **integer coordinates** for numeric ```java Paths64 subj = new Paths64(); Paths64 clip = new Paths64(); -subj.add(Clipper.MakePath(new int[] { 100, 50, 10, 79, 65, 2, 65, 98, 10, 21 })); -clip.add(Clipper.MakePath(new int[] { 98, 63, 4, 68, 77, 8, 52, 100, 19, 12 })); -Paths64 solution = Clipper.Union(subj, clip, FillRule.NonZero); +subj.add(Clipper.makePath(new int[] { 100, 50, 10, 79, 65, 2, 65, 98, 10, 21 })); +clip.add(Clipper.makePath(new int[] { 98, 63, 4, 68, 77, 8, 52, 100, 19, 12 })); +Paths64 solution = Clipper.union(subj, clip, FillRule.NonZero); solution.get(0).forEach(p -> System.out.println(p.toString())); ``` diff --git a/src/main/java/com/github/micycle1/clipper2/Clipper.java b/src/main/java/com/github/micycle1/clipper2/Clipper.java index 51cc720..6cc36f6 100644 --- a/src/main/java/com/github/micycle1/clipper2/Clipper.java +++ b/src/main/java/com/github/micycle1/clipper2/Clipper.java @@ -77,8 +77,8 @@ * While all offsetting is performed by the ClipperOffset class in * the Clipper.Offset unit, the complexities of constructing and * using this class can usually be avoided by using instead the - * {@link #InflatePaths(PathsD, double, JoinType, EndType, double, double, int) - * InflatePaths()} function in this class. This function can both inflate and + * {@link #inflatePaths(PathsD, double, JoinType, EndType, double, double, int) + * inflatePaths()} function in this class. This function can both inflate and * shrink polygons (using positive and negative offsets respectively). * Offsetting can be performed using a number of JoinTypes and EndTypes. While * both open paths and closed paths can be offset, logically only closed paths @@ -107,8 +107,8 @@ public final class Clipper { * @param fillRule the polygon fill rule to apply. * @return the intersected paths. */ - public static Paths64 Intersect(Paths64 subject, Paths64 clip, FillRule fillRule) { - return BooleanOp(ClipType.Intersection, subject, clip, fillRule); + public static Paths64 intersect(Paths64 subject, Paths64 clip, FillRule fillRule) { + return booleanOp(ClipType.Intersection, subject, clip, fillRule); } /** @@ -119,8 +119,8 @@ public static Paths64 Intersect(Paths64 subject, Paths64 clip, FillRule fillRule * @param fillRule the polygon fill rule to apply. * @return the intersected paths. */ - public static PathsD Intersect(PathsD subject, PathsD clip, FillRule fillRule) { - return Intersect(subject, clip, fillRule, 2); + public static PathsD intersect(PathsD subject, PathsD clip, FillRule fillRule) { + return intersect(subject, clip, fillRule, 2); } /** @@ -132,8 +132,8 @@ public static PathsD Intersect(PathsD subject, PathsD clip, FillRule fillRule) { * @param precision the decimal precision to use when scaling coordinates. * @return the intersected paths. */ - public static PathsD Intersect(PathsD subject, PathsD clip, FillRule fillRule, int precision) { - return BooleanOp(ClipType.Intersection, subject, clip, fillRule, precision); + public static PathsD intersect(PathsD subject, PathsD clip, FillRule fillRule, int precision) { + return booleanOp(ClipType.Intersection, subject, clip, fillRule, precision); } /** @@ -143,8 +143,8 @@ public static PathsD Intersect(PathsD subject, PathsD clip, FillRule fillRule, i * @param fillRule the polygon fill rule to apply. * @return the unioned paths. */ - public static Paths64 Union(Paths64 subject, FillRule fillRule) { - return BooleanOp(ClipType.Union, subject, null, fillRule); + public static Paths64 union(Paths64 subject, FillRule fillRule) { + return booleanOp(ClipType.Union, subject, null, fillRule); } /** @@ -155,8 +155,8 @@ public static Paths64 Union(Paths64 subject, FillRule fillRule) { * @param fillRule the polygon fill rule to apply. * @return the unioned paths. */ - public static Paths64 Union(Paths64 subject, Paths64 clip, FillRule fillRule) { - return BooleanOp(ClipType.Union, subject, clip, fillRule); + public static Paths64 union(Paths64 subject, Paths64 clip, FillRule fillRule) { + return booleanOp(ClipType.Union, subject, clip, fillRule); } /** @@ -166,8 +166,8 @@ public static Paths64 Union(Paths64 subject, Paths64 clip, FillRule fillRule) { * @param fillRule the polygon fill rule to apply. * @return the unioned paths. */ - public static PathsD Union(PathsD subject, FillRule fillRule) { - return BooleanOp(ClipType.Union, subject, null, fillRule); + public static PathsD union(PathsD subject, FillRule fillRule) { + return booleanOp(ClipType.Union, subject, null, fillRule); } /** @@ -178,8 +178,8 @@ public static PathsD Union(PathsD subject, FillRule fillRule) { * @param fillRule the polygon fill rule to apply. * @return the unioned paths. */ - public static PathsD Union(PathsD subject, PathsD clip, FillRule fillRule) { - return Union(subject, clip, fillRule, 2); + public static PathsD union(PathsD subject, PathsD clip, FillRule fillRule) { + return union(subject, clip, fillRule, 2); } /** @@ -191,8 +191,8 @@ public static PathsD Union(PathsD subject, PathsD clip, FillRule fillRule) { * @param precision the decimal precision to use when scaling coordinates. * @return the unioned paths. */ - public static PathsD Union(PathsD subject, PathsD clip, FillRule fillRule, int precision) { - return BooleanOp(ClipType.Union, subject, clip, fillRule, precision); + public static PathsD union(PathsD subject, PathsD clip, FillRule fillRule, int precision) { + return booleanOp(ClipType.Union, subject, clip, fillRule, precision); } /** @@ -203,8 +203,8 @@ public static PathsD Union(PathsD subject, PathsD clip, FillRule fillRule, int p * @param fillRule the polygon fill rule to apply. * @return the difference of the subject and clip paths. */ - public static Paths64 Difference(Paths64 subject, Paths64 clip, FillRule fillRule) { - return BooleanOp(ClipType.Difference, subject, clip, fillRule); + public static Paths64 difference(Paths64 subject, Paths64 clip, FillRule fillRule) { + return booleanOp(ClipType.Difference, subject, clip, fillRule); } /** @@ -215,8 +215,8 @@ public static Paths64 Difference(Paths64 subject, Paths64 clip, FillRule fillRul * @param fillRule the polygon fill rule to apply. * @return the difference of the subject and clip paths. */ - public static PathsD Difference(PathsD subject, PathsD clip, FillRule fillRule) { - return Difference(subject, clip, fillRule, 2); + public static PathsD difference(PathsD subject, PathsD clip, FillRule fillRule) { + return difference(subject, clip, fillRule, 2); } /** @@ -228,8 +228,8 @@ public static PathsD Difference(PathsD subject, PathsD clip, FillRule fillRule) * @param precision the decimal precision to use when scaling coordinates. * @return the difference of the subject and clip paths. */ - public static PathsD Difference(PathsD subject, PathsD clip, FillRule fillRule, int precision) { - return BooleanOp(ClipType.Difference, subject, clip, fillRule, precision); + public static PathsD difference(PathsD subject, PathsD clip, FillRule fillRule, int precision) { + return booleanOp(ClipType.Difference, subject, clip, fillRule, precision); } /** @@ -240,8 +240,8 @@ public static PathsD Difference(PathsD subject, PathsD clip, FillRule fillRule, * @param fillRule the polygon fill rule to apply. * @return the exclusive-or of the subject and clip paths. */ - public static Paths64 Xor(Paths64 subject, Paths64 clip, FillRule fillRule) { - return BooleanOp(ClipType.Xor, subject, clip, fillRule); + public static Paths64 xor(Paths64 subject, Paths64 clip, FillRule fillRule) { + return booleanOp(ClipType.Xor, subject, clip, fillRule); } /** @@ -253,8 +253,8 @@ public static Paths64 Xor(Paths64 subject, Paths64 clip, FillRule fillRule) { * @param fillRule the polygon fill rule to apply. * @return the exclusive-or of the subject and clip paths. */ - public static PathsD Xor(PathsD subject, PathsD clip, FillRule fillRule) { - return Xor(subject, clip, fillRule, 2); + public static PathsD xor(PathsD subject, PathsD clip, FillRule fillRule) { + return xor(subject, clip, fillRule, 2); } /** @@ -266,8 +266,8 @@ public static PathsD Xor(PathsD subject, PathsD clip, FillRule fillRule) { * @param precision the decimal precision to use when scaling coordinates. * @return the exclusive-or of the subject and clip paths. */ - public static PathsD Xor(PathsD subject, PathsD clip, FillRule fillRule, int precision) { - return BooleanOp(ClipType.Xor, subject, clip, fillRule, precision); + public static PathsD xor(PathsD subject, PathsD clip, FillRule fillRule, int precision) { + return booleanOp(ClipType.Xor, subject, clip, fillRule, precision); } /** @@ -279,17 +279,17 @@ public static PathsD Xor(PathsD subject, PathsD clip, FillRule fillRule, int pre * @param fillRule the polygon fill rule to apply. * @return the resulting paths. */ - public static Paths64 BooleanOp(ClipType clipType, Paths64 subject, Paths64 clip, FillRule fillRule) { + public static Paths64 booleanOp(ClipType clipType, Paths64 subject, Paths64 clip, FillRule fillRule) { Paths64 solution = new Paths64(); if (subject == null) { return solution; } Clipper64 c = new Clipper64(); - c.AddPaths(subject, PathType.Subject); + c.addPaths(subject, PathType.Subject); if (clip != null) { - c.AddPaths(clip, PathType.Clip); + c.addPaths(clip, PathType.Clip); } - c.Execute(clipType, fillRule, solution); + c.execute(clipType, fillRule, solution); return solution; } @@ -303,16 +303,16 @@ public static Paths64 BooleanOp(ClipType clipType, Paths64 subject, Paths64 clip * @param polytree the destination polytree that receives the result. * @param fillRule the polygon fill rule to apply. */ - public static void BooleanOp(ClipType clipType, @Nullable Paths64 subject, @Nullable Paths64 clip, PolyTree64 polytree, FillRule fillRule) { + public static void booleanOp(ClipType clipType, @Nullable Paths64 subject, @Nullable Paths64 clip, PolyTree64 polytree, FillRule fillRule) { if (subject == null) { return; } Clipper64 c = new Clipper64(); - c.AddPaths(subject, PathType.Subject); + c.addPaths(subject, PathType.Subject); if (clip != null) { - c.AddPaths(clip, PathType.Clip); + c.addPaths(clip, PathType.Clip); } - c.Execute(clipType, fillRule, polytree); + c.execute(clipType, fillRule, polytree); } /** @@ -325,8 +325,8 @@ public static void BooleanOp(ClipType clipType, @Nullable Paths64 subject, @Null * @param fillRule the polygon fill rule to apply. * @return the resulting paths. */ - public static PathsD BooleanOp(ClipType clipType, PathsD subject, PathsD clip, FillRule fillRule) { - return BooleanOp(clipType, subject, clip, fillRule, 2); + public static PathsD booleanOp(ClipType clipType, PathsD subject, PathsD clip, FillRule fillRule) { + return booleanOp(clipType, subject, clip, fillRule, 2); } /** @@ -340,14 +340,14 @@ public static PathsD BooleanOp(ClipType clipType, PathsD subject, PathsD clip, F * @param precision The desired coordinate precision (up to 8 decimal places). * @return the resulting paths. */ - public static PathsD BooleanOp(ClipType clipType, PathsD subject, @Nullable PathsD clip, FillRule fillRule, int precision) { + public static PathsD booleanOp(ClipType clipType, PathsD subject, @Nullable PathsD clip, FillRule fillRule, int precision) { PathsD solution = new PathsD(); ClipperD c = new ClipperD(precision); - c.AddSubjects(subject); + c.addSubjects(subject); if (clip != null) { - c.AddClips(clip); + c.addClips(clip); } - c.Execute(clipType, fillRule, solution); + c.execute(clipType, fillRule, solution); return solution; } @@ -361,8 +361,8 @@ public static PathsD BooleanOp(ClipType clipType, PathsD subject, @Nullable Path * @param polytree the destination polytree that receives the result. * @param fillRule the polygon fill rule to apply. */ - public static void BooleanOp(ClipType clipType, @Nullable PathsD subject, @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule) { - BooleanOp(clipType, subject, clip, polytree, fillRule, 2); + public static void booleanOp(ClipType clipType, @Nullable PathsD subject, @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule) { + booleanOp(clipType, subject, clip, polytree, fillRule, 2); } /** @@ -376,16 +376,16 @@ public static void BooleanOp(ClipType clipType, @Nullable PathsD subject, @Nulla * @param fillRule the polygon fill rule to apply. * @param precision the decimal precision to use when scaling coordinates. */ - public static void BooleanOp(ClipType clipType, @Nullable PathsD subject, @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule, int precision) { + public static void booleanOp(ClipType clipType, @Nullable PathsD subject, @Nullable PathsD clip, PolyTreeD polytree, FillRule fillRule, int precision) { if (subject == null) { return; } ClipperD c = new ClipperD(precision); - c.AddPaths(subject, PathType.Subject); + c.addPaths(subject, PathType.Subject); if (clip != null) { - c.AddPaths(clip, PathType.Clip); + c.addPaths(clip, PathType.Clip); } - c.Execute(clipType, fillRule, polytree); + c.execute(clipType, fillRule, polytree); } /** @@ -397,10 +397,10 @@ public static void BooleanOp(ClipType clipType, @Nullable PathsD subject, @Nulla * @param endType the end treatment to apply. * @return the offset paths. * - * @see #InflatePaths(PathsD, double, JoinType, EndType, double, double, int) + * @see #inflatePaths(PathsD, double, JoinType, EndType, double, double, int) */ - public static Paths64 InflatePaths(Paths64 paths, double delta, JoinType joinType, EndType endType) { - return InflatePaths(paths, delta, joinType, endType, 2.0, 0.0); + public static Paths64 inflatePaths(Paths64 paths, double delta, JoinType joinType, EndType endType) { + return inflatePaths(paths, delta, joinType, endType, 2.0, 0.0); } /** @@ -414,13 +414,13 @@ public static Paths64 InflatePaths(Paths64 paths, double delta, JoinType joinTyp * @param arcTolerance the tolerance used when flattening round joins. * @return the offset paths. * - * @see #InflatePaths(PathsD, double, JoinType, EndType, double, double, int) + * @see #inflatePaths(PathsD, double, JoinType, EndType, double, double, int) */ - public static Paths64 InflatePaths(Paths64 paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance) { + public static Paths64 inflatePaths(Paths64 paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance) { ClipperOffset co = new ClipperOffset(miterLimit, arcTolerance); - co.AddPaths(paths, joinType, endType); + co.addPaths(paths, joinType, endType); Paths64 solution = new Paths64(); - co.Execute(delta, solution); + co.execute(delta, solution); return solution; } @@ -434,10 +434,10 @@ public static Paths64 InflatePaths(Paths64 paths, double delta, JoinType joinTyp * @param miterLimit the miter limit in multiples of {@code delta}. * @return the offset paths. * - * @see #InflatePaths(PathsD, double, JoinType, EndType, double, double, int) + * @see #inflatePaths(PathsD, double, JoinType, EndType, double, double, int) */ - public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit) { - return InflatePaths(paths, delta, joinType, endType, miterLimit, 0.0, 8); + public static PathsD inflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit) { + return inflatePaths(paths, delta, joinType, endType, miterLimit, 0.0, 8); } /** @@ -449,10 +449,10 @@ public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType, * @param endType the end treatment to apply. * @return the offset paths. * - * @see #InflatePaths(PathsD, double, JoinType, EndType, double, double, int) + * @see #inflatePaths(PathsD, double, JoinType, EndType, double, double, int) */ - public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType) { - return InflatePaths(paths, delta, joinType, endType, 2.0, 0.0, 8); + public static PathsD inflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType) { + return inflatePaths(paths, delta, joinType, endType, 2.0, 0.0, 8); } /** @@ -503,124 +503,124 @@ public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType, * when paths is type PathsD. (Maximum is 8 decimal places) * @return the offset paths. */ - public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance, int precision) { - InternalClipper.CheckPrecision(precision); + public static PathsD inflatePaths(PathsD paths, double delta, JoinType joinType, EndType endType, double miterLimit, double arcTolerance, int precision) { + InternalClipper.checkPrecision(precision); double scale = Math.pow(10, precision); - Paths64 tmp = ScalePaths64(paths, scale); + Paths64 tmp = scalePaths64(paths, scale); ClipperOffset co = new ClipperOffset(miterLimit, arcTolerance * scale); - co.AddPaths(tmp, joinType, endType); - co.Execute(delta * scale, tmp); // reuse 'tmp' to receive (scaled) solution - return ScalePathsD(tmp, 1 / scale); + co.addPaths(tmp, joinType, endType); + co.execute(delta * scale, tmp); // reuse 'tmp' to receive (scaled) solution + return scalePathsD(tmp, 1 / scale); } - public static Paths64 RectClip(Rect64 rect, Paths64 paths) { - if (rect.IsEmpty() || paths.isEmpty()) { + public static Paths64 rectClip(Rect64 rect, Paths64 paths) { + if (rect.isEmpty() || paths.isEmpty()) { return new Paths64(); } RectClip64 rc = new RectClip64(rect); - return rc.Execute(paths); + return rc.execute(paths); } - public static Paths64 RectClip(Rect64 rect, Path64 path) { - if (rect.IsEmpty() || path.isEmpty()) { + public static Paths64 rectClip(Rect64 rect, Path64 path) { + if (rect.isEmpty() || path.isEmpty()) { return new Paths64(); } Paths64 tmp = new Paths64(); tmp.add(path); - return RectClip(rect, tmp); + return rectClip(rect, tmp); } - public static PathsD RectClip(RectD rect, PathsD paths) { - return RectClip(rect, paths, 2); + public static PathsD rectClip(RectD rect, PathsD paths) { + return rectClip(rect, paths, 2); } - public static PathsD RectClip(RectD rect, PathsD paths, int precision) { - InternalClipper.CheckPrecision(precision); - if (rect.IsEmpty() || paths.isEmpty()) { + public static PathsD rectClip(RectD rect, PathsD paths, int precision) { + InternalClipper.checkPrecision(precision); + if (rect.isEmpty() || paths.isEmpty()) { return new PathsD(); } double scale = Math.pow(10, precision); - Rect64 r = ScaleRect(rect, scale); - Paths64 tmpPath = ScalePaths64(paths, scale); + Rect64 r = scaleRect(rect, scale); + Paths64 tmpPath = scalePaths64(paths, scale); RectClip64 rc = new RectClip64(r); - tmpPath = rc.Execute(tmpPath); - return ScalePathsD(tmpPath, 1 / scale); + tmpPath = rc.execute(tmpPath); + return scalePathsD(tmpPath, 1 / scale); } - public static PathsD RectClip(RectD rect, PathD path) { - return RectClip(rect, path, 2); + public static PathsD rectClip(RectD rect, PathD path) { + return rectClip(rect, path, 2); } - public static PathsD RectClip(RectD rect, PathD path, int precision) { - if (rect.IsEmpty() || path.isEmpty()) { + public static PathsD rectClip(RectD rect, PathD path, int precision) { + if (rect.isEmpty() || path.isEmpty()) { return new PathsD(); } PathsD tmp = new PathsD(); tmp.add(path); - return RectClip(rect, tmp, precision); + return rectClip(rect, tmp, precision); } - public static Paths64 RectClipLines(Rect64 rect, Paths64 paths) { - if (rect.IsEmpty() || paths.isEmpty()) { + public static Paths64 rectClipLines(Rect64 rect, Paths64 paths) { + if (rect.isEmpty() || paths.isEmpty()) { return new Paths64(); } RectClipLines64 rc = new RectClipLines64(rect); - return rc.Execute(paths); + return rc.execute(paths); } - public static Paths64 RectClipLines(Rect64 rect, Path64 path) { - if (rect.IsEmpty() || path.isEmpty()) { + public static Paths64 rectClipLines(Rect64 rect, Path64 path) { + if (rect.isEmpty() || path.isEmpty()) { return new Paths64(); } Paths64 tmp = new Paths64(); tmp.add(path); - return RectClipLines(rect, tmp); + return rectClipLines(rect, tmp); } - public static PathsD RectClipLines(RectD rect, PathsD paths) { - return RectClipLines(rect, paths, 2); + public static PathsD rectClipLines(RectD rect, PathsD paths) { + return rectClipLines(rect, paths, 2); } - public static PathsD RectClipLines(RectD rect, PathsD paths, int precision) { - InternalClipper.CheckPrecision(precision); - if (rect.IsEmpty() || paths.isEmpty()) { + public static PathsD rectClipLines(RectD rect, PathsD paths, int precision) { + InternalClipper.checkPrecision(precision); + if (rect.isEmpty() || paths.isEmpty()) { return new PathsD(); } double scale = Math.pow(10, precision); - Rect64 r = ScaleRect(rect, scale); - Paths64 tmpPath = ScalePaths64(paths, scale); + Rect64 r = scaleRect(rect, scale); + Paths64 tmpPath = scalePaths64(paths, scale); RectClipLines64 rc = new RectClipLines64(r); - tmpPath = rc.Execute(tmpPath); - return ScalePathsD(tmpPath, 1 / scale); + tmpPath = rc.execute(tmpPath); + return scalePathsD(tmpPath, 1 / scale); } - public static PathsD RectClipLines(RectD rect, PathD path) { - return RectClipLines(rect, path, 2); + public static PathsD rectClipLines(RectD rect, PathD path) { + return rectClipLines(rect, path, 2); } - public static PathsD RectClipLines(RectD rect, PathD path, int precision) { - if (rect.IsEmpty() || path.isEmpty()) { + public static PathsD rectClipLines(RectD rect, PathD path, int precision) { + if (rect.isEmpty() || path.isEmpty()) { return new PathsD(); } PathsD tmp = new PathsD(); tmp.add(path); - return RectClipLines(rect, tmp, precision); + return rectClipLines(rect, tmp, precision); } - public static Paths64 MinkowskiSum(Path64 pattern, Path64 path, boolean isClosed) { - return Minkowski.Sum(pattern, path, isClosed); + public static Paths64 minkowskiSum(Path64 pattern, Path64 path, boolean isClosed) { + return Minkowski.sum(pattern, path, isClosed); } - public static PathsD MinkowskiSum(PathD pattern, PathD path, boolean isClosed) { - return Minkowski.Sum(pattern, path, isClosed); + public static PathsD minkowskiSum(PathD pattern, PathD path, boolean isClosed) { + return Minkowski.sum(pattern, path, isClosed); } - public static Paths64 MinkowskiDiff(Path64 pattern, Path64 path, boolean isClosed) { - return Minkowski.Diff(pattern, path, isClosed); + public static Paths64 minkowskiDiff(Path64 pattern, Path64 path, boolean isClosed) { + return Minkowski.diff(pattern, path, isClosed); } - public static PathsD MinkowskiDiff(PathD pattern, PathD path, boolean isClosed) { - return Minkowski.Diff(pattern, path, isClosed); + public static PathsD minkowskiDiff(PathD pattern, PathD path, boolean isClosed) { + return Minkowski.diff(pattern, path, isClosed); } /** @@ -633,7 +633,7 @@ public static PathsD MinkowskiDiff(PathD pattern, PathD path, boolean isClosed) * @param path the path whose area will be calculated. * @return the signed area of the path. */ - public static double Area(Path64 path) { + public static double area(Path64 path) { // https://en.wikipedia.org/wiki/Shoelace_formula double a = 0.0; int cnt = path.size(); @@ -658,10 +658,10 @@ public static double Area(Path64 path) { * @param paths the paths whose total area will be calculated. * @return the sum of the signed areas of all supplied paths. */ - public static double Area(Paths64 paths) { + public static double area(Paths64 paths) { double a = 0.0; for (Path64 path : paths) { - a += Area(path); + a += area(path); } return a; } @@ -672,7 +672,7 @@ public static double Area(Paths64 paths) { * @param path the path whose area will be calculated. * @return the signed area of the path. */ - public static double Area(PathD path) { + public static double area(PathD path) { double a = 0.0; int cnt = path.size(); if (cnt < 3) { @@ -692,10 +692,10 @@ public static double Area(PathD path) { * @param paths the paths whose total area will be calculated. * @return the sum of the signed areas of all supplied paths. */ - public static double Area(PathsD paths) { + public static double area(PathsD paths) { double a = 0.0; for (PathD path : paths) { - a += Area(path); + a += area(path); } return a; } @@ -715,8 +715,8 @@ public static double Area(PathsD paths) { * @param poly the polygon to test. * @return {@code true} when the polygon has positive winding. */ - public static boolean IsPositive(Path64 poly) { - return Area(poly) >= 0; + public static boolean isPositive(Path64 poly) { + return area(poly) >= 0; } /** @@ -734,11 +734,11 @@ public static boolean IsPositive(Path64 poly) { * @param poly the polygon to test. * @return {@code true} when the polygon has positive winding. */ - public static boolean IsPositive(PathD poly) { - return Area(poly) >= 0; + public static boolean isPositive(PathD poly) { + return area(poly) >= 0; } - public static String Path64ToString(Path64 path) { + public static String path64ToString(Path64 path) { StringBuilder bld = new StringBuilder(); for (Point64 pt : path) { bld.append(pt.toString()); @@ -746,15 +746,15 @@ public static String Path64ToString(Path64 path) { return bld.toString() + '\n'; } - public static String Paths64ToString(Paths64 paths) { + public static String paths64ToString(Paths64 paths) { StringBuilder bld = new StringBuilder(); for (Path64 path : paths) { - bld.append(Path64ToString(path)); + bld.append(path64ToString(path)); } return bld.toString(); } - public static String PathDToString(PathD path) { + public static String pathDToString(PathD path) { StringBuilder bld = new StringBuilder(); for (PointD pt : path) { bld.append(pt.toString()); @@ -762,15 +762,15 @@ public static String PathDToString(PathD path) { return bld.toString() + '\n'; } - public static String PathsDToString(PathsD paths) { + public static String pathsDToString(PathsD paths) { StringBuilder bld = new StringBuilder(); for (PathD path : paths) { - bld.append(PathDToString(path)); + bld.append(pathDToString(path)); } return bld.toString(); } - public static Path64 OffsetPath(Path64 path, long dx, long dy) { + public static Path64 offsetPath(Path64 path, long dx, long dy) { Path64 result = new Path64(path.size()); for (Point64 pt : path) { result.add(new Point64(pt.x + dx, pt.y + dy)); @@ -778,27 +778,27 @@ public static Path64 OffsetPath(Path64 path, long dx, long dy) { return result; } - public static Point64 ScalePoint64(Point64 pt, double scale) { + public static Point64 scalePoint64(Point64 pt, double scale) { Point64 result = new Point64(); result.x = (long) Math.rint(pt.x * scale); result.y = (long) Math.rint(pt.y * scale); return result; } - public static PointD ScalePointD(Point64 pt, double scale) { + public static PointD scalePointD(Point64 pt, double scale) { PointD result = new PointD(); result.x = pt.x * scale; result.y = pt.y * scale; return result; } - public static Rect64 ScaleRect(RectD rec, double scale) { + public static Rect64 scaleRect(RectD rec, double scale) { Rect64 result = new Rect64((long) (rec.left * scale), (long) (rec.top * scale), (long) (rec.right * scale), (long) (rec.bottom * scale)); return result; } - public static Path64 ScalePath(Path64 path, double scale) { - if (InternalClipper.IsAlmostZero(scale - 1)) { + public static Path64 scalePath(Path64 path, double scale) { + if (InternalClipper.isAlmostZero(scale - 1)) { return path; } Path64 result = new Path64(path.size()); @@ -808,19 +808,19 @@ public static Path64 ScalePath(Path64 path, double scale) { return result; } - public static Paths64 ScalePaths(Paths64 paths, double scale) { - if (InternalClipper.IsAlmostZero(scale - 1)) { + public static Paths64 scalePaths(Paths64 paths, double scale) { + if (InternalClipper.isAlmostZero(scale - 1)) { return paths; } Paths64 result = new Paths64(paths.size()); for (Path64 path : paths) { - result.add(ScalePath(path, scale)); + result.add(scalePath(path, scale)); } return result; } - public static PathD ScalePath(PathD path, double scale) { - if (InternalClipper.IsAlmostZero(scale - 1)) { + public static PathD scalePath(PathD path, double scale) { + if (InternalClipper.isAlmostZero(scale - 1)) { return path; } PathD result = new PathD(path.size()); @@ -830,19 +830,19 @@ public static PathD ScalePath(PathD path, double scale) { return result; } - public static PathsD ScalePaths(PathsD paths, double scale) { - if (InternalClipper.IsAlmostZero(scale - 1)) { + public static PathsD scalePaths(PathsD paths, double scale) { + if (InternalClipper.isAlmostZero(scale - 1)) { return paths; } PathsD result = new PathsD(paths.size()); for (PathD path : paths) { - result.add(ScalePath(path, scale)); + result.add(scalePath(path, scale)); } return result; } // Unlike ScalePath, both ScalePath64 & ScalePathD also involve type conversion - public static Path64 ScalePath64(PathD path, double scale) { + public static Path64 scalePath64(PathD path, double scale) { int cnt = path.size(); Path64 res = new Path64(cnt); for (PointD pt : path) { @@ -851,16 +851,16 @@ public static Path64 ScalePath64(PathD path, double scale) { return res; } - public static Paths64 ScalePaths64(PathsD paths, double scale) { + public static Paths64 scalePaths64(PathsD paths, double scale) { int cnt = paths.size(); Paths64 res = new Paths64(cnt); for (PathD path : paths) { - res.add(ScalePath64(path, scale)); + res.add(scalePath64(path, scale)); } return res; } - public static PathD ScalePathD(Path64 path, double scale) { + public static PathD scalePathD(Path64 path, double scale) { int cnt = path.size(); PathD res = new PathD(cnt); for (Point64 pt : path) { @@ -869,17 +869,17 @@ public static PathD ScalePathD(Path64 path, double scale) { return res; } - public static PathsD ScalePathsD(Paths64 paths, double scale) { + public static PathsD scalePathsD(Paths64 paths, double scale) { int cnt = paths.size(); PathsD res = new PathsD(cnt); for (Path64 path : paths) { - res.add(ScalePathD(path, scale)); + res.add(scalePathD(path, scale)); } return res; } // The static functions Path64 and PathD convert path types without scaling - public static Path64 Path64(PathD path) { + public static Path64 path64(PathD path) { Path64 result = new Path64(path.size()); for (PointD pt : path) { result.add(new Point64(pt)); @@ -887,23 +887,23 @@ public static Path64 Path64(PathD path) { return result; } - public static Paths64 Paths64(PathsD paths) { + public static Paths64 paths64(PathsD paths) { Paths64 result = new Paths64(paths.size()); for (PathD path : paths) { - result.add(Path64(path)); + result.add(path64(path)); } return result; } - public static PathsD PathsD(Paths64 paths) { + public static PathsD pathsD(Paths64 paths) { PathsD result = new PathsD(paths.size()); for (Path64 path : paths) { - result.add(PathD(path)); + result.add(pathD(path)); } return result; } - public static PathD PathD(Path64 path) { + public static PathD pathD(Path64 path) { PathD result = new PathD(path.size()); for (Point64 pt : path) { result.add(new PointD(pt)); @@ -911,7 +911,7 @@ public static PathD PathD(Path64 path) { return result; } - public static Path64 TranslatePath(Path64 path, long dx, long dy) { + public static Path64 translatePath(Path64 path, long dx, long dy) { Path64 result = new Path64(path.size()); for (Point64 pt : path) { result.add(new Point64(pt.x + dx, pt.y + dy)); @@ -919,15 +919,15 @@ public static Path64 TranslatePath(Path64 path, long dx, long dy) { return result; } - public static Paths64 TranslatePaths(Paths64 paths, long dx, long dy) { + public static Paths64 translatePaths(Paths64 paths, long dx, long dy) { Paths64 result = new Paths64(paths.size()); for (Path64 path : paths) { - result.add(OffsetPath(path, dx, dy)); + result.add(offsetPath(path, dx, dy)); } return result; } - public static PathD TranslatePath(PathD path, double dx, double dy) { + public static PathD translatePath(PathD path, double dx, double dy) { PathD result = new PathD(path.size()); for (PointD pt : path) { result.add(new PointD(pt.x + dx, pt.y + dy)); @@ -935,39 +935,39 @@ public static PathD TranslatePath(PathD path, double dx, double dy) { return result; } - public static PathsD TranslatePaths(PathsD paths, double dx, double dy) { + public static PathsD translatePaths(PathsD paths, double dx, double dy) { PathsD result = new PathsD(paths.size()); for (PathD path : paths) { - result.add(TranslatePath(path, dx, dy)); + result.add(translatePath(path, dx, dy)); } return result; } - public static Path64 ReversePath(Path64 path) { + public static Path64 reversePath(Path64 path) { Path64 result = new Path64(path); Collections.reverse(result); return result; } - public static PathD ReversePath(PathD path) { + public static PathD reversePath(PathD path) { PathD result = new PathD(path); Collections.reverse(result); return result; } - public static Paths64 ReversePaths(Paths64 paths) { + public static Paths64 reversePaths(Paths64 paths) { Paths64 result = new Paths64(paths.size()); for (Path64 t : paths) { - result.add(ReversePath(t)); + result.add(reversePath(t)); } return result; } - public static PathsD ReversePaths(PathsD paths) { + public static PathsD reversePaths(PathsD paths) { PathsD result = new PathsD(paths.size()); for (PathD path : paths) { - result.add(ReversePath(path)); + result.add(reversePath(path)); } return result; } @@ -978,7 +978,7 @@ public static PathsD ReversePaths(PathsD paths) { * @param path the path to measure. * @return the path bounds, or an empty rectangle when the path is empty. */ - public static Rect64 GetBounds(Path64 path) { + public static Rect64 getBounds(Path64 path) { Rect64 result = InvalidRect64.clone(); for (Point64 pt : path) { if (pt.x < result.left) { @@ -1004,7 +1004,7 @@ public static Rect64 GetBounds(Path64 path) { * @return the combined bounds, or an empty rectangle when no points are * supplied. */ - public static Rect64 GetBounds(Paths64 paths) { + public static Rect64 getBounds(Paths64 paths) { Rect64 result = InvalidRect64.clone(); for (Path64 path : paths) { for (Point64 pt : path) { @@ -1031,7 +1031,7 @@ public static Rect64 GetBounds(Paths64 paths) { * @param path the path to measure. * @return the path bounds, or an empty rectangle when the path is empty. */ - public static RectD GetBounds(PathD path) { + public static RectD getBounds(PathD path) { RectD result = InvalidRectD.clone(); for (PointD pt : path) { if (pt.x < result.left) { @@ -1047,7 +1047,7 @@ public static RectD GetBounds(PathD path) { result.bottom = pt.y; } } - return InternalClipper.IsAlmostZero(result.left - Double.MAX_VALUE) ? new RectD() : result; + return InternalClipper.isAlmostZero(result.left - Double.MAX_VALUE) ? new RectD() : result; } /** @@ -1057,7 +1057,7 @@ public static RectD GetBounds(PathD path) { * @return the combined bounds, or an empty rectangle when no points are * supplied. */ - public static RectD GetBounds(PathsD paths) { + public static RectD getBounds(PathsD paths) { RectD result = InvalidRectD.clone(); for (PathD path : paths) { for (PointD pt : path) { @@ -1075,7 +1075,7 @@ public static RectD GetBounds(PathsD paths) { } } } - return InternalClipper.IsAlmostZero(result.left - Double.MAX_VALUE) ? new RectD() : result; + return InternalClipper.isAlmostZero(result.left - Double.MAX_VALUE) ? new RectD() : result; } /** @@ -1084,7 +1084,7 @@ public static RectD GetBounds(PathsD paths) { * @param arr the coordinate array. * @return the constructed path. */ - public static Path64 MakePath(int[] arr) { + public static Path64 makePath(int[] arr) { int len = arr.length / 2; Path64 p = new Path64(len); for (int i = 0; i < len; i++) { @@ -1093,7 +1093,7 @@ public static Path64 MakePath(int[] arr) { return p; } - public static Path64 MakePath(long[] arr) { + public static Path64 makePath(long[] arr) { int len = arr.length / 2; Path64 p = new Path64(len); for (int i = 0; i < len; i++) { @@ -1108,7 +1108,7 @@ public static Path64 MakePath(long[] arr) { * @param arr the coordinate array. * @return the constructed path. */ - public static PathD MakePath(double[] arr) { + public static PathD makePath(double[] arr) { int len = arr.length / 2; PathD p = new PathD(len); for (int i = 0; i < len; i++) { @@ -1117,11 +1117,11 @@ public static PathD MakePath(double[] arr) { return p; } - public static double Sqr(double value) { + public static double sqr(double value) { return value * value; } - public static double Sqr(long value) { + public static double sqr(long value) { return (double) value * (double) value; } @@ -1132,15 +1132,15 @@ public static double Sqr(long value) { * @param pt2 the second point. * @return the squared Euclidean distance between the two points. */ - public static double DistanceSqr(Point64 pt1, Point64 pt2) { - return Sqr(pt1.x - pt2.x) + Sqr(pt1.y - pt2.y); + public static double distanceSqr(Point64 pt1, Point64 pt2) { + return sqr(pt1.x - pt2.x) + sqr(pt1.y - pt2.y); } - public static Point64 MidPoint(Point64 pt1, Point64 pt2) { + public static Point64 midPoint(Point64 pt1, Point64 pt2) { return new Point64((pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2); } - public static PointD MidPoint(PointD pt1, PointD pt2) { + public static PointD midPoint(PointD pt1, PointD pt2) { return new PointD((pt1.x + pt2.x) / 2, (pt1.y + pt2.y) / 2); } @@ -1151,7 +1151,7 @@ public static PointD MidPoint(PointD pt1, PointD pt2) { * @param dx the horizontal delta to apply on both sides. * @param dy the vertical delta to apply on both sides. */ - public static void InflateRect(Rect64 rec, int dx, int dy) { + public static void inflateRect(Rect64 rec, int dx, int dy) { rec.left -= dx; rec.right += dx; rec.top -= dy; @@ -1165,18 +1165,18 @@ public static void InflateRect(Rect64 rec, int dx, int dy) { * @param dx the horizontal delta to apply on both sides. * @param dy the vertical delta to apply on both sides. */ - public static void InflateRect(RectD rec, double dx, double dy) { + public static void inflateRect(RectD rec, double dx, double dy) { rec.left -= dx; rec.right += dx; rec.top -= dy; rec.bottom += dy; } - public static boolean PointsNearEqual(PointD pt1, PointD pt2, double distanceSqrd) { - return Sqr(pt1.x - pt2.x) + Sqr(pt1.y - pt2.y) < distanceSqrd; + public static boolean pointsNearEqual(PointD pt1, PointD pt2, double distanceSqrd) { + return sqr(pt1.x - pt2.x) + sqr(pt1.y - pt2.y) < distanceSqrd; } - public static PathD StripNearDuplicates(PathD path, double minEdgeLenSqrd, boolean isClosedPath) { + public static PathD stripNearDuplicates(PathD path, double minEdgeLenSqrd, boolean isClosedPath) { int cnt = path.size(); PathD result = new PathD(cnt); if (cnt == 0) { @@ -1185,20 +1185,20 @@ public static PathD StripNearDuplicates(PathD path, double minEdgeLenSqrd, boole PointD lastPt = path.get(0); result.add(lastPt); for (int i = 1; i < cnt; i++) { - if (!PointsNearEqual(lastPt, path.get(i), minEdgeLenSqrd)) { + if (!pointsNearEqual(lastPt, path.get(i), minEdgeLenSqrd)) { lastPt = path.get(i); result.add(lastPt); } } - if (isClosedPath && PointsNearEqual(lastPt, result.get(0), minEdgeLenSqrd)) { + if (isClosedPath && pointsNearEqual(lastPt, result.get(0), minEdgeLenSqrd)) { result.remove(result.size() - 1); } return result; } - public static Path64 StripDuplicates(Path64 path, boolean isClosedPath) { + public static Path64 stripDuplicates(Path64 path, boolean isClosedPath) { int cnt = path.size(); Path64 result = new Path64(cnt); if (cnt == 0) { @@ -1225,7 +1225,7 @@ private static void AddPolyNodeToPaths(PolyPath64 polyPath, Paths64 paths) { polyPath.iterator().forEachRemaining(p -> AddPolyNodeToPaths((PolyPath64) p, paths)); } - public static Paths64 PolyTreeToPaths64(PolyTree64 polyTree) { + public static Paths64 polyTreeToPaths64(PolyTree64 polyTree) { Paths64 result = new Paths64(); polyTree.iterator().forEachRemaining(p -> AddPolyNodeToPaths((PolyPath64) p, result)); return result; @@ -1237,24 +1237,24 @@ public static Paths64 PolyTreeToPaths64(PolyTree64 polyTree) { * @param polyPath the current polytree node. * @param paths the destination path collection. */ - public static void AddPolyNodeToPathsD(PolyPathD polyPath, PathsD paths) { + public static void addPolyNodeToPathsD(PolyPathD polyPath, PathsD paths) { if (!polyPath.getPolygon().isEmpty()) { paths.add(polyPath.getPolygon()); } - polyPath.iterator().forEachRemaining(p -> AddPolyNodeToPathsD((PolyPathD) p, paths)); + polyPath.iterator().forEachRemaining(p -> addPolyNodeToPathsD((PolyPathD) p, paths)); } - public static PathsD PolyTreeToPathsD(PolyTreeD polyTree) { + public static PathsD polyTreeToPathsD(PolyTreeD polyTree) { PathsD result = new PathsD(); for (PolyPathBase polyPathBase : polyTree) { PolyPathD p = (PolyPathD) polyPathBase; - AddPolyNodeToPathsD(p, result); + addPolyNodeToPathsD(p, result); } return result; } - public static double PerpendicDistFromLineSqrd(PointD pt, PointD line1, PointD line2) { + public static double perpendicDistFromLineSqrd(PointD pt, PointD line1, PointD line2) { double a = pt.x - line1.x; double b = pt.y - line1.y; double c = line2.x - line1.x; @@ -1262,10 +1262,10 @@ public static double PerpendicDistFromLineSqrd(PointD pt, PointD line1, PointD l if (c == 0 && d == 0) { return 0; } - return Sqr(a * d - c * b) / (c * c + d * d); + return sqr(a * d - c * b) / (c * c + d * d); } - public static double PerpendicDistFromLineSqrd(Point64 pt, Point64 line1, Point64 line2) { + public static double perpendicDistFromLineSqrd(Point64 pt, Point64 line1, Point64 line2) { double a = (double) pt.x - line1.x; double b = (double) pt.y - line1.y; double c = (double) line2.x - line1.x; @@ -1273,10 +1273,10 @@ public static double PerpendicDistFromLineSqrd(Point64 pt, Point64 line1, Point6 if (c == 0 && d == 0) { return 0; } - return Sqr(a * d - c * b) / (c * c + d * d); + return sqr(a * d - c * b) / (c * c + d * d); } - public static void RDP(Path64 path, int begin, int end, double epsSqrd, List flags) { + public static void rDP(Path64 path, int begin, int end, double epsSqrd, List flags) { while (true) { int idx = 0; double maxD = 0; @@ -1285,7 +1285,7 @@ public static void RDP(Path64 path, int begin, int end, double epsSqrd, List begin + 1) { - RDP(path, begin, idx, epsSqrd, flags); + rDP(path, begin, idx, epsSqrd, flags); } if (idx < end - 1) { begin = idx; @@ -1325,7 +1325,7 @@ public static void RDP(Path64 path, int begin, int end, double epsSqrd, List flags = new ArrayList<>(Collections.nCopies(len, false)); flags.set(0, true); flags.set(len - 1, true); - RDP(path, 0, len - 1, Sqr(epsilon), flags); + rDP(path, 0, len - 1, sqr(epsilon), flags); Path64 result = new Path64(len); for (int i = 0; i < len; ++i) { if (flags.get(i).booleanValue()) { @@ -1361,15 +1361,15 @@ public static Path64 RamerDouglasPeuckerPath(Path64 path, double epsilon) { * @param epsilon the maximum permitted deviation from the original paths. * @return the simplified paths. */ - public static Paths64 RamerDouglasPeucker(Paths64 paths, double epsilon) { + public static Paths64 ramerDouglasPeucker(Paths64 paths, double epsilon) { Paths64 result = new Paths64(paths.size()); for (Path64 path : paths) { - result.add(RamerDouglasPeuckerPath(path, epsilon)); + result.add(ramerDouglasPeuckerPath(path, epsilon)); } return result; } - public static void RDP(PathD path, int begin, int end, double epsSqrd, List flags) { + public static void rDP(PathD path, int begin, int end, double epsSqrd, List flags) { while (true) { int idx = 0; double maxD = 0; @@ -1378,7 +1378,7 @@ public static void RDP(PathD path, int begin, int end, double epsSqrd, List begin + 1) { - RDP(path, begin, idx, epsSqrd, flags); + rDP(path, begin, idx, epsSqrd, flags); } if (idx < end - 1) { begin = idx; @@ -1407,7 +1407,7 @@ public static void RDP(PathD path, int begin, int end, double epsSqrd, List flags = new ArrayList<>(Collections.nCopies(len, false)); flags.set(0, true); flags.set(len - 1, true); - RDP(path, 0, len - 1, Sqr(epsilon), flags); + rDP(path, 0, len - 1, sqr(epsilon), flags); PathD result = new PathD(len); for (int i = 0; i < len; ++i) { if (flags.get(i).booleanValue()) { @@ -1432,10 +1432,10 @@ public static PathD RamerDouglasPeucker(PathD path, double epsilon) { * @param epsilon the maximum permitted deviation from the original paths. * @return the simplified paths. */ - public static PathsD RamerDouglasPeucker(PathsD paths, double epsilon) { + public static PathsD ramerDouglasPeucker(PathsD paths, double epsilon) { PathsD result = new PathsD(paths.size()); for (PathD path : paths) { - result.add(RamerDouglasPeucker(path, epsilon)); + result.add(ramerDouglasPeucker(path, epsilon)); } return result; } @@ -1481,8 +1481,8 @@ private static int GetPrior(int current, int high, final /* ref */ boolean[] fla * @param epsilon the maximum permitted deviation from the original path. * @return the simplified path. */ - public static Path64 SimplifyPath(Path64 path, double epsilon) { - return SimplifyPath(path, epsilon, false); + public static Path64 simplifyPath(Path64 path, double epsilon) { + return simplifyPath(path, epsilon, false); } /** @@ -1501,10 +1501,10 @@ public static Path64 SimplifyPath(Path64 path, double epsilon) { * @param isClosedPath whether the path should be treated as closed. * @return the simplified path. */ - public static Path64 SimplifyPath(Path64 path, double epsilon, boolean isClosedPath) { + public static Path64 simplifyPath(Path64 path, double epsilon, boolean isClosedPath) { int len = path.size(); int high = len - 1; - double epsSqr = Sqr(epsilon); + double epsSqr = sqr(epsilon); if (len < 4) { return path; // Return original path if too short } @@ -1514,15 +1514,15 @@ public static Path64 SimplifyPath(Path64 path, double epsilon, boolean isClosedP int curr = 0, prev, start, next, prior2; if (isClosedPath) { - dsq[0] = PerpendicDistFromLineSqrd(path.get(0), path.get(high), path.get(1)); - dsq[high] = PerpendicDistFromLineSqrd(path.get(high), path.get(0), path.get(high - 1)); + dsq[0] = perpendicDistFromLineSqrd(path.get(0), path.get(high), path.get(1)); + dsq[high] = perpendicDistFromLineSqrd(path.get(high), path.get(0), path.get(high - 1)); } else { dsq[0] = Double.MAX_VALUE; dsq[high] = Double.MAX_VALUE; } for (int i = 1; i < high; ++i) { - dsq[i] = PerpendicDistFromLineSqrd(path.get(i), path.get(i - 1), path.get(i + 1)); + dsq[i] = perpendicDistFromLineSqrd(path.get(i), path.get(i - 1), path.get(i + 1)); } for (;;) { @@ -1556,10 +1556,10 @@ public static Path64 SimplifyPath(Path64 path, double epsilon, boolean isClosedP next = GetNext(next, high, flags); if (isClosedPath || ((curr != high) && (curr != 0))) { - dsq[curr] = PerpendicDistFromLineSqrd(path.get(curr), path.get(prev), path.get(next)); + dsq[curr] = perpendicDistFromLineSqrd(path.get(curr), path.get(prev), path.get(next)); } if (isClosedPath || ((prev != 0) && (prev != high))) { - dsq[prev] = PerpendicDistFromLineSqrd(path.get(prev), path.get(prior2), path.get(curr)); + dsq[prev] = perpendicDistFromLineSqrd(path.get(prev), path.get(prior2), path.get(curr)); } } @@ -1579,8 +1579,8 @@ public static Path64 SimplifyPath(Path64 path, double epsilon, boolean isClosedP * @param epsilon the maximum permitted deviation from the original paths. * @return the simplified paths. */ - public static Paths64 SimplifyPaths(Paths64 paths, double epsilon) { - return SimplifyPaths(paths, epsilon, false); + public static Paths64 simplifyPaths(Paths64 paths, double epsilon) { + return simplifyPaths(paths, epsilon, false); } /** @@ -1591,10 +1591,10 @@ public static Paths64 SimplifyPaths(Paths64 paths, double epsilon) { * @param isClosedPath whether the paths should be treated as closed. * @return the simplified paths. */ - public static Paths64 SimplifyPaths(Paths64 paths, double epsilon, boolean isClosedPath) { + public static Paths64 simplifyPaths(Paths64 paths, double epsilon, boolean isClosedPath) { Paths64 result = new Paths64(paths.size()); for (Path64 path : paths) { - result.add(SimplifyPath(path, epsilon, isClosedPath)); + result.add(simplifyPath(path, epsilon, isClosedPath)); } return result; } @@ -1606,8 +1606,8 @@ public static Paths64 SimplifyPaths(Paths64 paths, double epsilon, boolean isClo * @param epsilon the maximum permitted deviation from the original path. * @return the simplified path. */ - public static PathD SimplifyPath(PathD path, double epsilon) { - return SimplifyPath(path, epsilon, false); + public static PathD simplifyPath(PathD path, double epsilon) { + return simplifyPath(path, epsilon, false); } /** @@ -1626,10 +1626,10 @@ public static PathD SimplifyPath(PathD path, double epsilon) { * @param isClosedPath whether the path should be treated as closed. * @return the simplified path. */ - public static PathD SimplifyPath(PathD path, double epsilon, boolean isClosedPath) { + public static PathD simplifyPath(PathD path, double epsilon, boolean isClosedPath) { int len = path.size(); int high = len - 1; - double epsSqr = Sqr(epsilon); + double epsSqr = sqr(epsilon); if (len < 4) { return path; } @@ -1639,15 +1639,15 @@ public static PathD SimplifyPath(PathD path, double epsilon, boolean isClosedPat int curr = 0, prev, start, next, prior2; if (isClosedPath) { - dsq[0] = PerpendicDistFromLineSqrd(path.get(0), path.get(high), path.get(1)); - dsq[high] = PerpendicDistFromLineSqrd(path.get(high), path.get(0), path.get(high - 1)); + dsq[0] = perpendicDistFromLineSqrd(path.get(0), path.get(high), path.get(1)); + dsq[high] = perpendicDistFromLineSqrd(path.get(high), path.get(0), path.get(high - 1)); } else { dsq[0] = Double.MAX_VALUE; dsq[high] = Double.MAX_VALUE; } for (int i = 1; i < high; ++i) { - dsq[i] = PerpendicDistFromLineSqrd(path.get(i), path.get(i - 1), path.get(i + 1)); + dsq[i] = perpendicDistFromLineSqrd(path.get(i), path.get(i - 1), path.get(i + 1)); } for (;;) { @@ -1680,10 +1680,10 @@ public static PathD SimplifyPath(PathD path, double epsilon, boolean isClosedPat curr = next; next = GetNext(next, high, flags); if (isClosedPath || ((curr != high) && (curr != 0))) { - dsq[curr] = PerpendicDistFromLineSqrd(path.get(curr), path.get(prev), path.get(next)); + dsq[curr] = perpendicDistFromLineSqrd(path.get(curr), path.get(prev), path.get(next)); } if (isClosedPath || ((prev != 0) && (prev != high))) { - dsq[prev] = PerpendicDistFromLineSqrd(path.get(prev), path.get(prior2), path.get(curr)); + dsq[prev] = perpendicDistFromLineSqrd(path.get(prev), path.get(prior2), path.get(curr)); } } @@ -1703,8 +1703,8 @@ public static PathD SimplifyPath(PathD path, double epsilon, boolean isClosedPat * @param epsilon the maximum permitted deviation from the original paths. * @return the simplified paths. */ - public static PathsD SimplifyPaths(PathsD paths, double epsilon) { - return SimplifyPaths(paths, epsilon, false); + public static PathsD simplifyPaths(PathsD paths, double epsilon) { + return simplifyPaths(paths, epsilon, false); } /** @@ -1715,10 +1715,10 @@ public static PathsD SimplifyPaths(PathsD paths, double epsilon) { * @param isClosedPath whether the paths should be treated as closed. * @return the simplified paths. */ - public static PathsD SimplifyPaths(PathsD paths, double epsilon, boolean isClosedPath) { + public static PathsD simplifyPaths(PathsD paths, double epsilon, boolean isClosedPath) { PathsD result = new PathsD(paths.size()); for (PathD path : paths) { - result.add(SimplifyPath(path, epsilon, isClosedPath)); + result.add(simplifyPath(path, epsilon, isClosedPath)); } return result; } @@ -1735,8 +1735,8 @@ public static PathsD SimplifyPaths(PathsD paths, double epsilon, boolean isClose * @param path the path to trim. * @return the trimmed path. */ - public static Path64 TrimCollinear(Path64 path) { - return TrimCollinear(path, false); + public static Path64 trimCollinear(Path64 path) { + return trimCollinear(path, false); } /** @@ -1752,14 +1752,14 @@ public static Path64 TrimCollinear(Path64 path) { * @param isOpen whether the path should be treated as open. * @return the trimmed path. */ - public static Path64 TrimCollinear(Path64 path, boolean isOpen) { + public static Path64 trimCollinear(Path64 path, boolean isOpen) { int len = path.size(); int i = 0; if (!isOpen) { - while (i < len - 1 && InternalClipper.IsCollinear(path.get(len - 1), path.get(i), path.get(i + 1))) { + while (i < len - 1 && InternalClipper.isCollinear(path.get(len - 1), path.get(i), path.get(i + 1))) { i++; } - while (i < len - 1 && InternalClipper.IsCollinear(path.get(len - 2), path.get(len - 1), path.get(i))) { + while (i < len - 1 && InternalClipper.isCollinear(path.get(len - 2), path.get(len - 1), path.get(i))) { len--; } } @@ -1775,7 +1775,7 @@ public static Path64 TrimCollinear(Path64 path, boolean isOpen) { Point64 last = path.get(i); result.add(last); for (i++; i < len - 1; i++) { - if (InternalClipper.IsCollinear(last, path.get(i), path.get(i + 1))) { + if (InternalClipper.isCollinear(last, path.get(i), path.get(i + 1))) { continue; } last = path.get(i); @@ -1784,10 +1784,10 @@ public static Path64 TrimCollinear(Path64 path, boolean isOpen) { if (isOpen) { result.add(path.get(len - 1)); - } else if (!InternalClipper.IsCollinear(last, path.get(len - 1), result.get(0))) { + } else if (!InternalClipper.isCollinear(last, path.get(len - 1), result.get(0))) { result.add(path.get(len - 1)); } else { - while (result.size() > 2 && InternalClipper.IsCollinear(result.get(result.size() - 1), result.get(result.size() - 2), result.get(0))) { + while (result.size() > 2 && InternalClipper.isCollinear(result.get(result.size() - 1), result.get(result.size() - 2), result.get(0))) { result.remove(result.size() - 1); } if (result.size() < 3) { @@ -1813,8 +1813,8 @@ public static Path64 TrimCollinear(Path64 path, boolean isOpen) { * @param precision the decimal precision used to test collinearity. * @return the trimmed path. */ - public static PathD TrimCollinear(PathD path, int precision) { - return TrimCollinear(path, precision, false); + public static PathD trimCollinear(PathD path, int precision) { + return trimCollinear(path, precision, false); } /** @@ -1834,28 +1834,28 @@ public static PathD TrimCollinear(PathD path, int precision) { * @param isOpen whether the path should be treated as open. * @return the trimmed path. */ - public static PathD TrimCollinear(PathD path, int precision, boolean isOpen) { - InternalClipper.CheckPrecision(precision); + public static PathD trimCollinear(PathD path, int precision, boolean isOpen) { + InternalClipper.checkPrecision(precision); double scale = Math.pow(10, precision); - Path64 p = ScalePath64(path, scale); - p = TrimCollinear(p, isOpen); - return ScalePathD(p, 1 / scale); + Path64 p = scalePath64(path, scale); + p = trimCollinear(p, isOpen); + return scalePathD(p, 1 / scale); } - public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { - return InternalClipper.PointInPolygon(pt, polygon); + public static PointInPolygonResult pointInPolygon(Point64 pt, Path64 polygon) { + return InternalClipper.pointInPolygon(pt, polygon); } - public static PointInPolygonResult PointInPolygon(PointD pt, PathD polygon) { - return PointInPolygon(pt, polygon, 2); + public static PointInPolygonResult pointInPolygon(PointD pt, PathD polygon) { + return pointInPolygon(pt, polygon, 2); } - public static PointInPolygonResult PointInPolygon(PointD pt, PathD polygon, int precision) { - InternalClipper.CheckPrecision(precision); + public static PointInPolygonResult pointInPolygon(PointD pt, PathD polygon, int precision) { + InternalClipper.checkPrecision(precision); double scale = Math.pow(10, precision); Point64 p = new Point64(pt, scale); - Path64 path = ScalePath64(polygon, scale); - return InternalClipper.PointInPolygon(p, path); + Path64 path = scalePath64(polygon, scale); + return InternalClipper.pointInPolygon(p, path); } /** @@ -1866,8 +1866,8 @@ public static PointInPolygonResult PointInPolygon(PointD pt, PathD polygon, int * @param radiusY the vertical radius. * @return the approximated ellipse path. */ - public static Path64 Ellipse(Point64 center, double radiusX, double radiusY) { - return Ellipse(center, radiusX, radiusY, 0); + public static Path64 ellipse(Point64 center, double radiusX, double radiusY) { + return ellipse(center, radiusX, radiusY, 0); } /** @@ -1877,8 +1877,8 @@ public static Path64 Ellipse(Point64 center, double radiusX, double radiusY) { * @param radiusX the radius to use on both axes. * @return the approximated circle path. */ - public static Path64 Ellipse(Point64 center, double radiusX) { - return Ellipse(center, radiusX, 0, 0); + public static Path64 ellipse(Point64 center, double radiusX) { + return ellipse(center, radiusX, 0, 0); } /** @@ -1891,7 +1891,7 @@ public static Path64 Ellipse(Point64 center, double radiusX) { * automatically. * @return the approximated ellipse path. */ - public static Path64 Ellipse(Point64 center, double radiusX, double radiusY, int steps) { + public static Path64 ellipse(Point64 center, double radiusX, double radiusY, int steps) { if (radiusX <= 0) { return new Path64(); } @@ -1925,8 +1925,8 @@ public static Path64 Ellipse(Point64 center, double radiusX, double radiusY, int * @param radiusY the vertical radius. * @return the approximated ellipse path. */ - public static PathD Ellipse(PointD center, double radiusX, double radiusY) { - return Ellipse(center, radiusX, radiusY, 0); + public static PathD ellipse(PointD center, double radiusX, double radiusY) { + return ellipse(center, radiusX, radiusY, 0); } /** @@ -1937,8 +1937,8 @@ public static PathD Ellipse(PointD center, double radiusX, double radiusY) { * @param radiusX the radius to use on both axes. * @return the approximated circle path. */ - public static PathD Ellipse(PointD center, double radiusX) { - return Ellipse(center, radiusX, 0, 0); + public static PathD ellipse(PointD center, double radiusX) { + return ellipse(center, radiusX, 0, 0); } /** @@ -1951,7 +1951,7 @@ public static PathD Ellipse(PointD center, double radiusX) { * automatically. * @return the approximated ellipse path. */ - public static PathD Ellipse(PointD center, double radiusX, double radiusY, int steps) { + public static PathD ellipse(PointD center, double radiusX, double radiusY, int steps) { if (radiusX <= 0) { return new PathD(); } diff --git a/src/main/java/com/github/micycle1/clipper2/Minkowski.java b/src/main/java/com/github/micycle1/clipper2/Minkowski.java index 11578b5..d89445f 100644 --- a/src/main/java/com/github/micycle1/clipper2/Minkowski.java +++ b/src/main/java/com/github/micycle1/clipper2/Minkowski.java @@ -12,35 +12,35 @@ public final class Minkowski { private Minkowski() { } - public static Paths64 Sum(Path64 pattern, Path64 path, boolean isClosed) { - return Clipper.Union(MinkowskiInternal(pattern, path, true, isClosed), FillRule.NonZero); + public static Paths64 sum(Path64 pattern, Path64 path, boolean isClosed) { + return Clipper.union(MinkowskiInternal(pattern, path, true, isClosed), FillRule.NonZero); } - public static PathsD Sum(PathD pattern, PathD path, boolean isClosed) { - return Sum(pattern, path, isClosed, 2); + public static PathsD sum(PathD pattern, PathD path, boolean isClosed) { + return sum(pattern, path, isClosed, 2); } - public static PathsD Sum(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) { + public static PathsD sum(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) { double scale = Math.pow(10, decimalPlaces); - Paths64 tmp = Clipper.Union( - MinkowskiInternal(Clipper.ScalePath64(pattern, scale), Clipper.ScalePath64(path, scale), true, isClosed), FillRule.NonZero); - return Clipper.ScalePathsD(tmp, 1 / scale); + Paths64 tmp = Clipper.union( + MinkowskiInternal(Clipper.scalePath64(pattern, scale), Clipper.scalePath64(path, scale), true, isClosed), FillRule.NonZero); + return Clipper.scalePathsD(tmp, 1 / scale); } - public static Paths64 Diff(Path64 pattern, Path64 path, boolean isClosed) { - return Clipper.Union(MinkowskiInternal(pattern, path, false, isClosed), FillRule.NonZero); + public static Paths64 diff(Path64 pattern, Path64 path, boolean isClosed) { + return Clipper.union(MinkowskiInternal(pattern, path, false, isClosed), FillRule.NonZero); } - public static PathsD Diff(PathD pattern, PathD path, boolean isClosed) { - return Diff(pattern, path, isClosed, 2); + public static PathsD diff(PathD pattern, PathD path, boolean isClosed) { + return diff(pattern, path, isClosed, 2); } - public static PathsD Diff(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) { + public static PathsD diff(PathD pattern, PathD path, boolean isClosed, int decimalPlaces) { double scale = Math.pow(10, decimalPlaces); - Paths64 tmp = Clipper.Union( - MinkowskiInternal(Clipper.ScalePath64(pattern, scale), Clipper.ScalePath64(path, scale), false, isClosed), + Paths64 tmp = Clipper.union( + MinkowskiInternal(Clipper.scalePath64(pattern, scale), Clipper.scalePath64(path, scale), false, isClosed), FillRule.NonZero); - return Clipper.ScalePathsD(tmp, 1 / scale); + return Clipper.scalePathsD(tmp, 1 / scale); } private static Paths64 MinkowskiInternal(Path64 pattern, Path64 path, boolean isSum, boolean isClosed) { @@ -69,8 +69,8 @@ private static Paths64 MinkowskiInternal(Path64 pattern, Path64 path, boolean is for (int i = delta; i < pathLen; i++) { for (int j = 0; j < patLen; j++) { Path64 quad = new Path64(tmp.get(g).get(h), tmp.get(i).get(h), tmp.get(i).get(j), tmp.get(g).get(j)); - if (!Clipper.IsPositive(quad)) { - result.add(Clipper.ReversePath(quad)); + if (!Clipper.isPositive(quad)) { + result.add(Clipper.reversePath(quad)); } else { result.add(quad); } diff --git a/src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java b/src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java index 78b9d07..8fbc07b 100644 --- a/src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java +++ b/src/main/java/com/github/micycle1/clipper2/core/InternalClipper.java @@ -13,7 +13,7 @@ public final class InternalClipper { private static final String PRECISION_RANGE_ERROR = "Error: Precision is out of range."; - public static void CheckPrecision(int precision) { + public static void checkPrecision(int precision) { if (precision < -8 || precision > 8) { throw new IllegalArgumentException(PRECISION_RANGE_ERROR); } @@ -22,16 +22,16 @@ public static void CheckPrecision(int precision) { private InternalClipper() { } - public static boolean IsAlmostZero(double value) { + public static boolean isAlmostZero(double value) { return (Math.abs(value) <= FLOATING_POINT_TOLERANCE); } - public static double CrossProduct(Point64 pt1, Point64 pt2, Point64 pt3) { + public static double crossProduct(Point64 pt1, Point64 pt2, Point64 pt3) { // typecast to double to avoid potential int overflow return ((double) (pt2.x - pt1.x) * (pt3.y - pt2.y) - (double) (pt2.y - pt1.y) * (pt3.x - pt2.x)); } - public static int CrossProductSign(Point64 pt1, Point64 pt2, Point64 pt3) { + public static int crossProductSign(Point64 pt1, Point64 pt2, Point64 pt3) { long a = pt2.x - pt1.x; long b = pt3.y - pt2.y; long c = pt2.y - pt1.y; @@ -56,27 +56,27 @@ public static int CrossProductSign(Point64 pt1, Point64 pt2, Point64 pt3) { return signAB > signCD ? 1 : -1; } - public static double DotProduct(Point64 pt1, Point64 pt2, Point64 pt3) { + public static double dotProduct(Point64 pt1, Point64 pt2, Point64 pt3) { // typecast to double to avoid potential int overflow return ((double) (pt2.x - pt1.x) * (pt3.x - pt2.x) + (double) (pt2.y - pt1.y) * (pt3.y - pt2.y)); } - public static double CrossProduct(PointD vec1, PointD vec2) { + public static double crossProduct(PointD vec1, PointD vec2) { return (vec1.y * vec2.x - vec2.y * vec1.x); } - public static double DotProduct(PointD vec1, PointD vec2) { + public static double dotProduct(PointD vec1, PointD vec2) { return (vec1.x * vec2.x + vec1.y * vec2.y); } - public static long CheckCastInt64(double val) { + public static long checkCastInt64(double val) { if ((val >= MAX_COORD) || (val <= MIN_COORD)) { return Invalid64; } return (long) Math.rint(val); } - public static boolean GetLineIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { + public static boolean getLineIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { double dy1 = (ln1b.y - ln1a.y); double dx1 = (ln1b.x - ln1a.x); double dy2 = (ln2b.y - ln2a.y); @@ -110,7 +110,7 @@ public static boolean GetLineIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2 return true; } - public static boolean GetLineIntersectPt(PointD ln1a, PointD ln1b, PointD ln2a, PointD ln2b, /* out */ PointD ip) { + public static boolean getLineIntersectPt(PointD ln1a, PointD ln1b, PointD ln2a, PointD ln2b, /* out */ PointD ip) { double dy1 = (ln1b.y - ln1a.y); double dx1 = (ln1b.x - ln1a.x); double dy2 = (ln2b.y - ln2a.y); @@ -137,38 +137,38 @@ public static boolean GetLineIntersectPt(PointD ln1a, PointD ln1b, PointD ln2a, return true; } - public static boolean GetSegmentIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { - return GetLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip); + public static boolean getSegmentIntersectPt(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { + return getLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip); } @Deprecated - public static boolean GetIntersectPoint(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { - return GetLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip); + public static boolean getIntersectPoint(Point64 ln1a, Point64 ln1b, Point64 ln2a, Point64 ln2b, /* out */ Point64 ip) { + return getLineIntersectPt(ln1a, ln1b, ln2a, ln2b, ip); } - public static boolean SegsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b) { - return SegsIntersect(seg1a, seg1b, seg2a, seg2b, false); + public static boolean segsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b) { + return segsIntersect(seg1a, seg1b, seg2a, seg2b, false); } - public static boolean SegsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b, boolean inclusive) { + public static boolean segsIntersect(Point64 seg1a, Point64 seg1b, Point64 seg2a, Point64 seg2b, boolean inclusive) { if (inclusive) { - double res1 = CrossProduct(seg1a, seg2a, seg2b); - double res2 = CrossProduct(seg1b, seg2a, seg2b); + double res1 = crossProduct(seg1a, seg2a, seg2b); + double res2 = crossProduct(seg1b, seg2a, seg2b); if (res1 * res2 > 0) { return false; } - double res3 = CrossProduct(seg2a, seg1a, seg1b); - double res4 = CrossProduct(seg2b, seg1a, seg1b); + double res3 = crossProduct(seg2a, seg1a, seg1b); + double res4 = crossProduct(seg2b, seg1a, seg1b); if (res3 * res4 > 0) { return false; } return (res1 != 0 || res2 != 0 || res3 != 0 || res4 != 0); } - return (CrossProduct(seg1a, seg2a, seg2b) * CrossProduct(seg1b, seg2a, seg2b) < 0) - && (CrossProduct(seg2a, seg1a, seg1b) * CrossProduct(seg2b, seg1a, seg1b) < 0); + return (crossProduct(seg1a, seg2a, seg2b) * crossProduct(seg1b, seg2a, seg2b) < 0) + && (crossProduct(seg2a, seg1a, seg1b) * crossProduct(seg2b, seg1a, seg1b) < 0); } - public static Point64 GetClosestPtOnSegment(Point64 offPt, Point64 seg1, Point64 seg2) { + public static Point64 getClosestPtOnSegment(Point64 offPt, Point64 seg1, Point64 seg2) { if (seg1.x == seg2.x && seg1.y == seg2.y) { return seg1; } @@ -183,7 +183,7 @@ public static Point64 GetClosestPtOnSegment(Point64 offPt, Point64 seg1, Point64 return new Point64(seg1.x + Math.rint(q * dx), seg1.y + Math.rint(q * dy)); } - public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { + public static PointInPolygonResult pointInPolygon(Point64 pt, Path64 polygon) { int len = polygon.size(), start = 0; if (len < 3) { return PointInPolygonResult.IsOutside; @@ -246,7 +246,7 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { } else if (pt.x > prev.x && pt.x > curr.x) { val = 1 - val; // toggle val } else { - int cps = CrossProductSign(prev, curr, pt); + int cps = crossProductSign(prev, curr, pt); if (cps == 0) { return PointInPolygonResult.IsOn; } @@ -262,7 +262,7 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { if (i == len) { i = 0; } - int cps = (i == 0) ? CrossProductSign(polygon.get(len - 1), polygon.get(0), pt) : CrossProductSign(polygon.get(i - 1), polygon.get(i), pt); + int cps = (i == 0) ? crossProductSign(polygon.get(len - 1), polygon.get(0), pt) : crossProductSign(polygon.get(i - 1), polygon.get(i), pt); if (cps == 0) { return PointInPolygonResult.IsOn; } @@ -280,7 +280,7 @@ public static PointInPolygonResult PointInPolygon(Point64 pt, Path64 polygon) { /** * Given three points, returns true if they are collinear. */ - public static boolean IsCollinear(Point64 pt1, Point64 sharedPt, Point64 pt2) { + public static boolean isCollinear(Point64 pt1, Point64 sharedPt, Point64 pt2) { long a = sharedPt.x - pt1.x; long b = pt2.y - sharedPt.y; long c = sharedPt.y - pt1.y; @@ -348,7 +348,7 @@ private static int triSign(long x) { return x < 0 ? -1 : (x > 0 ? 1 : 0); } - public static Rect64 GetBounds(Path64 path) { + public static Rect64 getBounds(Path64 path) { if (path.isEmpty()) { return new Rect64(); } @@ -370,11 +370,11 @@ public static Rect64 GetBounds(Path64 path) { return result; } - public static boolean Path2ContainsPath1(Path64 path1, Path64 path2) { + public static boolean path2ContainsPath1(Path64 path1, Path64 path2) { // accommodate potential rounding error before deciding either way PointInPolygonResult pip = PointInPolygonResult.IsOn; for (Point64 pt : path1) { - switch (PointInPolygon(pt, path2)) { + switch (pointInPolygon(pt, path2)) { case IsOutside: if (pip == PointInPolygonResult.IsOutside) { return false; @@ -392,8 +392,8 @@ public static boolean Path2ContainsPath1(Path64 path1, Path64 path2) { } } // path1 is still equivocal, so test its midpoint - Point64 mp = GetBounds(path1).MidPoint(); - return PointInPolygon(mp, path2) != PointInPolygonResult.IsOutside; + Point64 mp = getBounds(path1).midPoint(); + return pointInPolygon(mp, path2) != PointInPolygonResult.IsOutside; } } diff --git a/src/main/java/com/github/micycle1/clipper2/core/PointD.java b/src/main/java/com/github/micycle1/clipper2/core/PointD.java index 74634da..f45ccb0 100644 --- a/src/main/java/com/github/micycle1/clipper2/core/PointD.java +++ b/src/main/java/com/github/micycle1/clipper2/core/PointD.java @@ -42,7 +42,7 @@ public PointD(double x, double y) { this.y = y; } - public void Negate() { + public void negate() { x = -x; y = -y; } @@ -53,11 +53,11 @@ public final String toString() { } public static boolean opEquals(PointD lhs, PointD rhs) { - return InternalClipper.IsAlmostZero(lhs.x - rhs.x) && InternalClipper.IsAlmostZero(lhs.y - rhs.y); + return InternalClipper.isAlmostZero(lhs.x - rhs.x) && InternalClipper.isAlmostZero(lhs.y - rhs.y); } public static boolean opNotEquals(PointD lhs, PointD rhs) { - return !InternalClipper.IsAlmostZero(lhs.x - rhs.x) || !InternalClipper.IsAlmostZero(lhs.y - rhs.y); + return !InternalClipper.isAlmostZero(lhs.x - rhs.x) || !InternalClipper.isAlmostZero(lhs.y - rhs.y); } @Override diff --git a/src/main/java/com/github/micycle1/clipper2/core/Rect64.java b/src/main/java/com/github/micycle1/clipper2/core/Rect64.java index 5dda2e4..0711684 100644 --- a/src/main/java/com/github/micycle1/clipper2/core/Rect64.java +++ b/src/main/java/com/github/micycle1/clipper2/core/Rect64.java @@ -58,7 +58,7 @@ public void setHeight(long value) { bottom = top + value; } - public Path64 AsPath() { + public Path64 asPath() { Path64 result = new Path64(4); result.add(new Point64(left, top)); result.add(new Point64(right, top)); @@ -67,35 +67,35 @@ public Path64 AsPath() { return result; } - public boolean IsEmpty() { + public boolean isEmpty() { return bottom <= top || right <= left; } - public boolean IsValid() { + public boolean isValid() { return left < Long.MAX_VALUE; } - public Point64 MidPoint() { + public Point64 midPoint() { return new Point64((left + right) / 2, (top + bottom) / 2); } - public boolean Contains(Point64 pt) { + public boolean contains(Point64 pt) { return pt.x > left && pt.x < right && pt.y > top && pt.y < bottom; } - public boolean Intersects(Rect64 rec) { + public boolean intersects(Rect64 rec) { return (Math.max(left, rec.left) <= Math.min(right, rec.right)) && (Math.max(top, rec.top) <= Math.min(bottom, rec.bottom)); } - public boolean Contains(Rect64 rec) { + public boolean contains(Rect64 rec) { return rec.left >= left && rec.right <= right && rec.top >= top && rec.bottom <= bottom; } public static Rect64 opAdd(Rect64 lhs, Rect64 rhs) { - if (!lhs.IsValid()) { + if (!lhs.isValid()) { return rhs.clone(); } - if (!rhs.IsValid()) { + if (!rhs.isValid()) { return lhs.clone(); } return new Rect64(Math.min(lhs.left, rhs.left), Math.min(lhs.top, rhs.top), Math.max(lhs.right, rhs.right), diff --git a/src/main/java/com/github/micycle1/clipper2/core/RectD.java b/src/main/java/com/github/micycle1/clipper2/core/RectD.java index fccb53c..e27e9cb 100644 --- a/src/main/java/com/github/micycle1/clipper2/core/RectD.java +++ b/src/main/java/com/github/micycle1/clipper2/core/RectD.java @@ -60,27 +60,27 @@ public void setHeight(double value) { bottom = top + value; } - public boolean IsEmpty() { + public boolean isEmpty() { return bottom <= top || right <= left; } - public PointD MidPoint() { + public PointD midPoint() { return new PointD((left + right) / 2, (top + bottom) / 2); } - public boolean Contains(PointD pt) { + public boolean contains(PointD pt) { return pt.x > left && pt.x < right && pt.y > top && pt.y < bottom; } - public boolean Contains(RectD rec) { + public boolean contains(RectD rec) { return rec.left >= left && rec.right <= right && rec.top >= top && rec.bottom <= bottom; } - public boolean Intersects(RectD rec) { + public boolean intersects(RectD rec) { return (Math.max(left, rec.left) < Math.min(right, rec.right)) && (Math.max(top, rec.top) < Math.min(bottom, rec.bottom)); } - public PathD AsPath() { + public PathD asPath() { PathD result = new PathD( Arrays.asList(new PointD(left, top), new PointD(right, top), new PointD(right, bottom), new PointD(left, bottom))); return result; diff --git a/src/main/java/com/github/micycle1/clipper2/engine/Clipper64.java b/src/main/java/com/github/micycle1/clipper2/engine/Clipper64.java index cd56977..430e5c6 100644 --- a/src/main/java/com/github/micycle1/clipper2/engine/Clipper64.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/Clipper64.java @@ -2,8 +2,6 @@ import com.github.micycle1.clipper2.core.ClipType; import com.github.micycle1.clipper2.core.FillRule; -import com.github.micycle1.clipper2.core.Path64; -import com.github.micycle1.clipper2.core.PathType; import com.github.micycle1.clipper2.core.Paths64; /** @@ -13,39 +11,11 @@ */ public class Clipper64 extends ClipperBase { - public final void addPath(Path64 path, PathType polytype) { - addPath(path, polytype, false); - } - - public final void addPath(Path64 path, PathType polytype, boolean isOpen) { - super.AddPath(path, polytype, isOpen); - } - - public final void addPaths(Paths64 paths, PathType polytype) { - addPaths(paths, polytype, false); - } - - public final void addPaths(Paths64 paths, PathType polytype, boolean isOpen) { - super.AddPaths(paths, polytype, isOpen); - } - - public final void addSubject(Paths64 paths) { - addPaths(paths, PathType.Subject); - } - - public final void addOpenSubject(Paths64 paths) { - addPaths(paths, PathType.Subject, true); - } - - public final void addClip(Paths64 paths) { - addPaths(paths, PathType.Clip); - } - /** * Once subject and clip paths have been assigned (via * {@link #addSubject(Paths64) addSubject()}, {@link #addOpenSubject(Paths64) * addOpenSubject()} and {@link #addClip(Paths64) addClip()} methods), - * Execute() can then perform the specified clipping operation + * execute() can then perform the specified clipping operation * (intersection, union, difference or XOR). *

* The solution parameter can be either a Paths64 or a PolyTree64, though since @@ -59,7 +29,7 @@ public final void addClip(Paths64 paths) { * preserve these parent-child relationships, these two PolyTree classes will be * very useful to some users. */ - public final boolean Execute(ClipType clipType, FillRule fillRule, Paths64 solutionClosed, Paths64 solutionOpen) { + public final boolean execute(ClipType clipType, FillRule fillRule, Paths64 solutionClosed, Paths64 solutionOpen) { solutionClosed.clear(); solutionOpen.clear(); try { @@ -73,12 +43,12 @@ public final boolean Execute(ClipType clipType, FillRule fillRule, Paths64 solut return succeeded; } - public final boolean Execute(ClipType clipType, FillRule fillRule, Paths64 solutionClosed) { - return Execute(clipType, fillRule, solutionClosed, new Paths64()); + public final boolean execute(ClipType clipType, FillRule fillRule, Paths64 solutionClosed) { + return execute(clipType, fillRule, solutionClosed, new Paths64()); } - public final boolean Execute(ClipType clipType, FillRule fillRule, PolyTree64 polytree, Paths64 openPaths) { - polytree.Clear(); + public final boolean execute(ClipType clipType, FillRule fillRule, PolyTree64 polytree, Paths64 openPaths) { + polytree.clear(); openPaths.clear(); usingPolytree = true; try { @@ -92,13 +62,13 @@ public final boolean Execute(ClipType clipType, FillRule fillRule, PolyTree64 po return succeeded; } - public final boolean Execute(ClipType clipType, FillRule fillRule, PolyTree64 polytree) { - return Execute(clipType, fillRule, polytree, new Paths64()); + public final boolean execute(ClipType clipType, FillRule fillRule, PolyTree64 polytree) { + return execute(clipType, fillRule, polytree, new Paths64()); } @Override - public void AddReuseableData(ReuseableDataContainer64 reuseableData) { - super.AddReuseableData(reuseableData); + public void addReuseableData(ReuseableDataContainer64 reuseableData) { + super.addReuseableData(reuseableData); } -} \ No newline at end of file +} diff --git a/src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java b/src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java index 85e1c23..9626c82 100644 --- a/src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java @@ -251,12 +251,12 @@ public ReuseableDataContainer64() { vertexList = new ArrayList<>(); } - public void Clear() { + public void clear() { minimaList.clear(); vertexList.clear(); } - public void AddPaths(Paths64 paths, PathType pt, boolean isOpen) { + public void addPaths(Paths64 paths, PathType pt, boolean isOpen) { ClipperEngine.AddPathsToVertexList(paths, pt, isOpen, minimaList, vertexList); } } @@ -582,7 +582,7 @@ private static void SetOwner(OutRec outrec, OutRec newOwner) { outrec.owner = newOwner; } - private static double Area(OutPt op) { + private static double area(OutPt op) { // https://en.wikipedia.org/wiki/Shoelaceformula double area = 0.0; OutPt op2 = op; @@ -650,7 +650,7 @@ protected final void ClearSolutionOnly() { horzJoinList.clear(); } - public final void Clear() { + public final void clear() { ClearSolutionOnly(); minimaList.clear(); vertexList.clear(); @@ -705,54 +705,54 @@ private LocalMinima PopLocalMinima() { return minimaList.get(currentLocMin++); } - public final void AddSubject(Path64 path) { - AddPath(path, PathType.Subject); + public final void addSubject(Path64 path) { + addPath(path, PathType.Subject); } /** * Adds one or more closed subject paths (polygons) to the Clipper object. */ - public final void AddSubject(Paths64 paths) { - paths.forEach(path -> AddPath(path, PathType.Subject)); + public final void addSubject(Paths64 paths) { + paths.forEach(path -> addPath(path, PathType.Subject)); } /** * Adds one or more open subject paths (polylines) to the Clipper object. */ - public final void AddOpenSubject(Path64 path) { - AddPath(path, PathType.Subject, true); + public final void addOpenSubject(Path64 path) { + addPath(path, PathType.Subject, true); } - public final void AddOpenSubject(Paths64 paths) { - paths.forEach(path -> AddPath(path, PathType.Subject, true)); + public final void addOpenSubject(Paths64 paths) { + paths.forEach(path -> addPath(path, PathType.Subject, true)); } /** * Adds one or more clip polygons to the Clipper object. */ - public final void AddClip(Path64 path) { - AddPath(path, PathType.Clip); + public final void addClip(Path64 path) { + addPath(path, PathType.Clip); } - public final void AddClip(Paths64 paths) { - paths.forEach(path -> AddPath(path, PathType.Clip)); + public final void addClip(Paths64 paths) { + paths.forEach(path -> addPath(path, PathType.Clip)); } - public final void AddPath(Path64 path, PathType polytype) { - AddPath(path, polytype, false); + public final void addPath(Path64 path, PathType polytype) { + addPath(path, polytype, false); } - public final void AddPath(Path64 path, PathType polytype, boolean isOpen) { + public final void addPath(Path64 path, PathType polytype, boolean isOpen) { Paths64 tmp = new Paths64(); tmp.add(path); - AddPaths(tmp, polytype, isOpen); + addPaths(tmp, polytype, isOpen); } - public final void AddPaths(Paths64 paths, PathType polytype) { - AddPaths(paths, polytype, false); + public final void addPaths(Paths64 paths, PathType polytype) { + addPaths(paths, polytype, false); } - public final void AddPaths(Paths64 paths, PathType polytype, boolean isOpen) { + public final void addPaths(Paths64 paths, PathType polytype, boolean isOpen) { if (isOpen) { hasOpenPaths = true; } @@ -760,7 +760,7 @@ public final void AddPaths(Paths64 paths, PathType polytype, boolean isOpen) { ClipperEngine.AddPathsToVertexList(paths, polytype, isOpen, minimaList, vertexList); } - protected void AddReuseableData(ReuseableDataContainer64 reuseableData) { + protected void addReuseableData(ReuseableDataContainer64 reuseableData) { if (reuseableData.minimaList.isEmpty()) { return; } @@ -971,7 +971,7 @@ private static boolean IsValidAelOrder(Active resident, Active newcomer) { } // get the turning direction a1.top, a2.bot, a2.top - int d = InternalClipper.CrossProductSign(resident.top, newcomer.bot, newcomer.top); + int d = InternalClipper.crossProductSign(resident.top, newcomer.bot, newcomer.top); if (d != 0) { return (d < 0); } @@ -981,11 +981,11 @@ private static boolean IsValidAelOrder(Active resident, Active newcomer) { // for starting open paths, place them according to // the direction they're about to turn if (!IsMaxima(resident) && (resident.top.y > newcomer.top.y)) { - return InternalClipper.CrossProductSign(newcomer.bot, resident.top, NextVertex(resident).pt) <= 0; + return InternalClipper.crossProductSign(newcomer.bot, resident.top, NextVertex(resident).pt) <= 0; } if (!IsMaxima(newcomer) && (newcomer.top.y > resident.top.y)) { - return InternalClipper.CrossProductSign(newcomer.bot, newcomer.top, NextVertex(newcomer).pt) >= 0; + return InternalClipper.crossProductSign(newcomer.bot, newcomer.top, NextVertex(newcomer).pt) >= 0; } long y = newcomer.bot.y; @@ -998,11 +998,11 @@ private static boolean IsValidAelOrder(Active resident, Active newcomer) { if (resident.isLeftBound != newcomerIsLeft) { return newcomerIsLeft; } - if (InternalClipper.IsCollinear(PrevPrevVertex(resident).pt, resident.bot, resident.top)) { + if (InternalClipper.isCollinear(PrevPrevVertex(resident).pt, resident.bot, resident.top)) { return true; } // compare turning direction of the alternate bound - return (InternalClipper.CrossProductSign(PrevPrevVertex(resident).pt, newcomer.bot, PrevPrevVertex(newcomer).pt) > 0) == newcomerIsLeft; + return (InternalClipper.crossProductSign(PrevPrevVertex(resident).pt, newcomer.bot, PrevPrevVertex(newcomer).pt) > 0) == newcomerIsLeft; } private void InsertLeftEdge(Active ae) { @@ -1718,7 +1718,7 @@ private void DisposeIntersectNodes() { private void AddNewIntersectNode(Active ae1, Active ae2, long topY) { Point64 ip = new Point64(); - if (!InternalClipper.GetLineIntersectPt(ae1.bot, ae1.top, ae2.bot, ae2.top, ip)) { + if (!InternalClipper.getLineIntersectPt(ae1.bot, ae1.top, ae2.bot, ae2.top, ip)) { ip = new Point64(ae1.curX, topY); } @@ -1727,14 +1727,14 @@ private void AddNewIntersectNode(Active ae1, Active ae2, long topY) { double absDx2 = Math.abs(ae2.dx); if (absDx1 > 100 && absDx2 > 100) { if (absDx1 > absDx2) { - ip = InternalClipper.GetClosestPtOnSegment(ip, ae1.bot, ae1.top); + ip = InternalClipper.getClosestPtOnSegment(ip, ae1.bot, ae1.top); } else { - ip = InternalClipper.GetClosestPtOnSegment(ip, ae2.bot, ae2.top); + ip = InternalClipper.getClosestPtOnSegment(ip, ae2.bot, ae2.top); } } else if (absDx1 > 100) { - ip = InternalClipper.GetClosestPtOnSegment(ip, ae1.bot, ae1.top); + ip = InternalClipper.getClosestPtOnSegment(ip, ae1.bot, ae1.top); } else if (absDx2 > 100) { - ip = InternalClipper.GetClosestPtOnSegment(ip, ae2.bot, ae2.top); + ip = InternalClipper.getClosestPtOnSegment(ip, ae2.bot, ae2.top); } else { if (ip.y < topY) { ip.y = topY; @@ -2234,13 +2234,13 @@ private void CheckJoinLeft(Active e, Point64 pt, boolean checkCurrX) { // Position and Collinearity checks if (checkCurrX) { - if (Clipper.PerpendicDistFromLineSqrd(pt, prev.bot, prev.top) > 0.25) { + if (Clipper.perpendicDistFromLineSqrd(pt, prev.bot, prev.top) > 0.25) { return; } } else if (e.curX != prev.curX) { return; } - if (!InternalClipper.IsCollinear(e.top, pt, prev.top)) { + if (!InternalClipper.isCollinear(e.top, pt, prev.top)) { return; } @@ -2274,13 +2274,13 @@ private void CheckJoinRight(Active e, Point64 pt, boolean checkCurrX) { // Position and Collinearity checks if (checkCurrX) { - if (Clipper.PerpendicDistFromLineSqrd(pt, next.bot, next.top) > 0.25) { + if (Clipper.perpendicDistFromLineSqrd(pt, next.bot, next.top) > 0.25) { return; } } else if (e.curX != next.curX) { return; } - if (!InternalClipper.IsCollinear(e.top, pt, next.top)) { + if (!InternalClipper.isCollinear(e.top, pt, next.top)) { return; } @@ -2497,7 +2497,7 @@ private static PointInPolygonResult PointInOpPolygon(Point64 pt, OutPt op) { if ((op2.prev.pt.x < pt.x && op2.pt.x < pt.x)) { val = 1 - val; // toggle val } else { - int d = InternalClipper.CrossProductSign(op2.prev.pt, op2.pt, pt); + int d = InternalClipper.crossProductSign(op2.prev.pt, op2.pt, pt); if (d == 0) { return PointInPolygonResult.IsOn; } @@ -2511,7 +2511,7 @@ private static PointInPolygonResult PointInOpPolygon(Point64 pt, OutPt op) { } if (isAbove != startingAbove) { - int d = InternalClipper.CrossProductSign(op2.prev.pt, op2.pt, pt); + int d = InternalClipper.crossProductSign(op2.prev.pt, op2.pt, pt); if (d == 0) { return PointInPolygonResult.IsOn; } @@ -2552,7 +2552,7 @@ private static boolean Path1InsidePath2(OutPt op1, OutPt op2) { op = op.next; } while (op != op1); // result is unclear, so try again using cleaned paths - return InternalClipper.Path2ContainsPath1(GetCleanPath(op1), GetCleanPath(op2)); // #973 + return InternalClipper.path2ContainsPath1(GetCleanPath(op1), GetCleanPath(op2)); // #973 } private void MoveSplits(OutRec fromOr, OutRec toOr) { @@ -2666,8 +2666,8 @@ private void CleanCollinear(OutRec outrec) { OutPt op2 = startOp; for (;;) { // NB if preserveCollinear == true, then only remove 180 deg. spikes - if ((InternalClipper.IsCollinear(op2.prev.pt, op2.pt, op2.next.pt)) && ((op2.pt.opEquals(op2.prev.pt)) || (op2.pt.opEquals(op2.next.pt)) - || !getPreserveCollinear() || (InternalClipper.DotProduct(op2.prev.pt, op2.pt, op2.next.pt) < 0))) { + if ((InternalClipper.isCollinear(op2.prev.pt, op2.pt, op2.next.pt)) && ((op2.pt.opEquals(op2.prev.pt)) || (op2.pt.opEquals(op2.next.pt)) + || !getPreserveCollinear() || (InternalClipper.dotProduct(op2.prev.pt, op2.pt, op2.next.pt) < 0))) { if (op2.equals(outrec.pts)) { outrec.pts = op2.prev; } @@ -2696,9 +2696,9 @@ private void DoSplitOp(OutRec outrec, OutPt splitOp) { // OutPt result = prevOp; Point64 ip = new Point64(); - InternalClipper.GetLineIntersectPt(prevOp.pt, splitOp.pt, splitOp.next.pt, nextNextOp.pt, ip); + InternalClipper.getLineIntersectPt(prevOp.pt, splitOp.pt, splitOp.next.pt, nextNextOp.pt, ip); - double area1 = Area(prevOp); + double area1 = area(prevOp); double absArea1 = Math.abs(area1); if (absArea1 < 2) { @@ -2768,7 +2768,7 @@ private void FixSelfIntersects(OutRec outrec) { if (op2.prev == op2.next.next) { break; } - if (InternalClipper.SegsIntersect(op2.prev.pt, op2.pt, op2.next.pt, op2.next.next.pt)) { + if (InternalClipper.segsIntersect(op2.prev.pt, op2.pt, op2.next.pt, op2.next.next.pt)) { DoSplitOp(outrec, op2); if (outrec.pts == null) { return; @@ -2783,7 +2783,7 @@ private void FixSelfIntersects(OutRec outrec) { } } - public static boolean BuildPath(@Nullable OutPt op, boolean reverse, boolean isOpen, Path64 path) { + public static boolean buildPath(@Nullable OutPt op, boolean reverse, boolean isOpen, Path64 path) { if (op == null || op.next == op || (!isOpen && op.next == op.prev)) { return false; } @@ -2837,14 +2837,14 @@ protected final boolean BuildPaths(Paths64 solutionClosed, Paths64 solutionOpen) Path64 path = new Path64(); if (outrec.isOpen) { - if (BuildPath(outrec.pts, getReverseSolution(), true, path)) { + if (buildPath(outrec.pts, getReverseSolution(), true, path)) { solutionOpen.add(path); } } else { CleanCollinear(outrec); // closed paths should always return a Positive orientation // except when reverseSolution == true - if (BuildPath(outrec.pts, getReverseSolution(), false, path)) { + if (buildPath(outrec.pts, getReverseSolution(), false, path)) { solutionClosed.add(path); } } @@ -2856,14 +2856,14 @@ private boolean CheckBounds(OutRec outrec) { if (outrec.pts == null) { return false; } - if (!outrec.bounds.IsEmpty()) { + if (!outrec.bounds.isEmpty()) { return true; } CleanCollinear(outrec); - if (outrec.pts == null || !BuildPath(outrec.pts, getReverseSolution(), false, outrec.path)) { + if (outrec.pts == null || !buildPath(outrec.pts, getReverseSolution(), false, outrec.path)) { return false; } - outrec.bounds = InternalClipper.GetBounds(outrec.path); + outrec.bounds = InternalClipper.getBounds(outrec.path); return true; } @@ -2881,7 +2881,7 @@ private boolean CheckSplitOwner(OutRec outrec, List splits) { if (split.splits != null && CheckSplitOwner(outrec, split.splits)) { return true; } - if (!CheckBounds(split) || !split.bounds.Contains(outrec.bounds) || !Path1InsidePath2(outrec.pts, split.pts)) { + if (!CheckBounds(split) || !split.bounds.contains(outrec.bounds) || !Path1InsidePath2(outrec.pts, split.pts)) { continue; } if (!IsValidOwner(outrec, split)) { @@ -2898,7 +2898,7 @@ private void RecursiveCheckOwners(OutRec outrec, PolyPathBase polypath) { // pre-condition: outrec will have valid bounds // post-condition: if a valid path, outrec will have a polypath - if (outrec.polypath != null || outrec.bounds.IsEmpty()) { + if (outrec.polypath != null || outrec.bounds.isEmpty()) { return; } @@ -2916,14 +2916,14 @@ private void RecursiveCheckOwners(OutRec outrec, PolyPathBase polypath) { if (outrec.owner.polypath == null) { RecursiveCheckOwners(outrec.owner, polypath); } - outrec.polypath = outrec.owner.polypath.AddChild(outrec.path); + outrec.polypath = outrec.owner.polypath.addChild(outrec.path); } else { - outrec.polypath = polypath.AddChild(outrec.path); + outrec.polypath = polypath.addChild(outrec.path); } } protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) { - polytree.Clear(); + polytree.clear(); solutionOpen.clear(); if (hasOpenPaths) { solutionOpen.ensureCapacity(outrecList.size()); @@ -2941,7 +2941,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) { if (outrec.isOpen) { Path64 openPath = new Path64(); - if (BuildPath(outrec.pts, getReverseSolution(), true, openPath)) { + if (buildPath(outrec.pts, getReverseSolution(), true, openPath)) { solutionOpen.add(openPath); } continue; @@ -2952,7 +2952,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) { } } - public final Rect64 GetBounds() { + public final Rect64 getBounds() { Rect64 bounds = Clipper.InvalidRect64.clone(); for (Vertex t : vertexList) { Vertex v = t; @@ -2972,7 +2972,7 @@ public final Rect64 GetBounds() { v = v.next; } while (v != t); } - return bounds.IsEmpty() ? new Rect64(0, 0, 0, 0) : bounds; + return bounds.isEmpty() ? new Rect64(0, 0, 0, 0) : bounds; } } diff --git a/src/main/java/com/github/micycle1/clipper2/engine/ClipperD.java b/src/main/java/com/github/micycle1/clipper2/engine/ClipperD.java index 5846097..07e9f28 100644 --- a/src/main/java/com/github/micycle1/clipper2/engine/ClipperD.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/ClipperD.java @@ -35,47 +35,47 @@ public ClipperD(int roundingDecimalPrecision) { invScale = 1 / scale; } - public void AddPath(PathD path, PathType polytype) { - AddPath(path, polytype, false); + public void addPath(PathD path, PathType polytype) { + addPath(path, polytype, false); } - public void AddPath(PathD path, PathType polytype, boolean isOpen) { - super.AddPath(Clipper.ScalePath64(path, scale), polytype, isOpen); + public void addPath(PathD path, PathType polytype, boolean isOpen) { + super.addPath(Clipper.scalePath64(path, scale), polytype, isOpen); } - public void AddPaths(PathsD paths, PathType polytype) { - AddPaths(paths, polytype, false); + public void addPaths(PathsD paths, PathType polytype) { + addPaths(paths, polytype, false); } - public void AddPaths(PathsD paths, PathType polytype, boolean isOpen) { - super.AddPaths(Clipper.ScalePaths64(paths, scale), polytype, isOpen); + public void addPaths(PathsD paths, PathType polytype, boolean isOpen) { + super.addPaths(Clipper.scalePaths64(paths, scale), polytype, isOpen); } - public void AddSubject(PathD path) { - AddPath(path, PathType.Subject); + public void addSubject(PathD path) { + addPath(path, PathType.Subject); } - public void AddOpenSubject(PathD path) { - AddPath(path, PathType.Subject, true); + public void addOpenSubject(PathD path) { + addPath(path, PathType.Subject, true); } - public void AddClip(PathD path) { - AddPath(path, PathType.Clip); + public void addClip(PathD path) { + addPath(path, PathType.Clip); } - public void AddSubjects(PathsD paths) { - AddPaths(paths, PathType.Subject); + public void addSubjects(PathsD paths) { + addPaths(paths, PathType.Subject); } - public void AddOpenSubjects(PathsD paths) { - AddPaths(paths, PathType.Subject, true); + public void addOpenSubjects(PathsD paths) { + addPaths(paths, PathType.Subject, true); } - public void AddClips(PathsD paths) { - AddPaths(paths, PathType.Clip); + public void addClips(PathsD paths) { + addPaths(paths, PathType.Clip); } - public boolean Execute(ClipType clipType, FillRule fillRule, PathsD solutionClosed, PathsD solutionOpen) { + public boolean execute(ClipType clipType, FillRule fillRule, PathsD solutionClosed, PathsD solutionOpen) { Paths64 solClosed64 = new Paths64(), solOpen64 = new Paths64(); boolean success = true; @@ -95,22 +95,22 @@ public boolean Execute(ClipType clipType, FillRule fillRule, PathsD solutionClos solutionClosed.ensureCapacity(solClosed64.size()); for (Path64 path : solClosed64) { - solutionClosed.add(Clipper.ScalePathD(path, invScale)); + solutionClosed.add(Clipper.scalePathD(path, invScale)); } solutionOpen.ensureCapacity(solOpen64.size()); for (Path64 path : solOpen64) { - solutionOpen.add(Clipper.ScalePathD(path, invScale)); + solutionOpen.add(Clipper.scalePathD(path, invScale)); } return true; } - public boolean Execute(ClipType clipType, FillRule fillRule, PathsD solutionClosed) { - return Execute(clipType, fillRule, solutionClosed, new PathsD()); + public boolean execute(ClipType clipType, FillRule fillRule, PathsD solutionClosed) { + return execute(clipType, fillRule, solutionClosed, new PathsD()); } - public boolean Execute(ClipType clipType, FillRule fillRule, PolyTreeD polytree, PathsD openPaths) { - polytree.Clear(); + public boolean execute(ClipType clipType, FillRule fillRule, PolyTreeD polytree, PathsD openPaths) { + polytree.clear(); polytree.setScale(invScale); openPaths.clear(); Paths64 oPaths = new Paths64(); @@ -130,13 +130,13 @@ public boolean Execute(ClipType clipType, FillRule fillRule, PolyTreeD polytree, } openPaths.ensureCapacity(oPaths.size()); for (Path64 path : oPaths) { - openPaths.add(Clipper.ScalePathD(path, invScale)); + openPaths.add(Clipper.scalePathD(path, invScale)); } return true; } - public boolean Execute(ClipType clipType, FillRule fillRule, PolyTreeD polytree) { - return Execute(clipType, fillRule, polytree, new PathsD()); + public boolean execute(ClipType clipType, FillRule fillRule, PolyTreeD polytree) { + return execute(clipType, fillRule, polytree, new PathsD()); } } diff --git a/src/main/java/com/github/micycle1/clipper2/engine/PolyPath64.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyPath64.java index 6d81d38..277d166 100644 --- a/src/main/java/com/github/micycle1/clipper2/engine/PolyPath64.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyPath64.java @@ -22,7 +22,7 @@ public PolyPath64(@Nullable PolyPathBase parent) { } @Override - public PolyPathBase AddChild(Path64 p) { + public PolyPathBase addChild(Path64 p) { PolyPath64 newChild = new PolyPath64(this); newChild.setPolygon(p); children.add(newChild); @@ -36,11 +36,11 @@ public final PolyPath64 get(int index) { return (PolyPath64) children.get(index); } - public final double Area() { - double result = getPolygon() == null ? 0 : Clipper.Area(getPolygon()); + public final double area() { + double result = getPolygon() == null ? 0 : Clipper.area(getPolygon()); for (PolyPathBase polyPathBase : children) { PolyPath64 child = (PolyPath64) polyPathBase; - result += child.Area(); + result += child.area(); } return result; } diff --git a/src/main/java/com/github/micycle1/clipper2/engine/PolyPathBase.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathBase.java index dbaee1f..baa9fc0 100644 --- a/src/main/java/com/github/micycle1/clipper2/engine/PolyPathBase.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathBase.java @@ -52,12 +52,12 @@ public final int getCount() { return children.size(); } - public abstract PolyPathBase AddChild(Path64 p); + public abstract PolyPathBase addChild(Path64 p); /** * This method clears the Polygon and deletes any contained children. */ - public final void Clear() { + public final void clear() { children.clear(); } diff --git a/src/main/java/com/github/micycle1/clipper2/engine/PolyPathD.java b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathD.java index a02fb37..da84248 100644 --- a/src/main/java/com/github/micycle1/clipper2/engine/PolyPathD.java +++ b/src/main/java/com/github/micycle1/clipper2/engine/PolyPathD.java @@ -19,10 +19,10 @@ public class PolyPathD extends PolyPathBase { } @Override - public PolyPathBase AddChild(Path64 p) { + public PolyPathBase addChild(Path64 p) { PolyPathD newChild = new PolyPathD(this); newChild.setScale(scale); - newChild.setPolygon(Clipper.ScalePathD(p, scale)); + newChild.setPolygon(Clipper.scalePathD(p, scale)); children.add(newChild); return newChild; } @@ -34,11 +34,11 @@ public final PolyPathD get(int index) { return (PolyPathD) children.get(index); } - public final double Area() { - double result = getPolygon() == null ? 0 : Clipper.Area(getPolygon()); + public final double area() { + double result = getPolygon() == null ? 0 : Clipper.area(getPolygon()); for (PolyPathBase polyPathBase : children) { PolyPathD child = (PolyPathD) polyPathBase; - result += child.Area(); + result += child.area(); } return result; } diff --git a/src/main/java/com/github/micycle1/clipper2/offset/ClipperOffset.java b/src/main/java/com/github/micycle1/clipper2/offset/ClipperOffset.java index 33ca3a9..2f7a438 100644 --- a/src/main/java/com/github/micycle1/clipper2/offset/ClipperOffset.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/ClipperOffset.java @@ -26,8 +26,8 @@ *

* Library users will rarely need to access this class directly since it's * generally easier to use the - * {@link Clipper#InflatePaths(Paths64, double, JoinType, EndType) - * InflatePaths()} function for polygon offsetting. + * {@link Clipper#inflatePaths(Paths64, double, JoinType, EndType) + * inflatePaths()} function for polygon offsetting. *

* Notes: *

    @@ -58,7 +58,7 @@ * point coordinates, the InflatePaths function will accept paths with * floating point coordinates. *
  • Redundant segments should be removed before offsetting (see - * {@link Clipper#SimplifyPaths(Paths64, double) SimplifyPaths()}), and between + * {@link Clipper#simplifyPaths(Paths64, double) simplifyPaths()}), and between * offsetting operations too. These redundant segments not only slow down * offsetting, but they can cause unexpected blemishes in offset solutions.
  • *
@@ -149,10 +149,10 @@ public ClipperOffset() { * arcTolerance is only relevant when offsetting with * {@link JoinType#Round} and / or * {@link EndType#Round} (see - * {{@link #AddPath(Path64, JoinType, EndType) - * AddPath()} and - * {@link #AddPaths(Paths64, JoinType, EndType) - * AddPaths()}. The default arcTolerance is 0.0, which + * {{@link #addPath(Path64, JoinType, EndType) + * addPath()} and + * {@link #addPaths(Paths64, JoinType, EndType) + * addPaths()}. The default arcTolerance is 0.0, which * enables automatic scaling (offset radius / 500). * @param preserveCollinear When adjacent edges are collinear in closed path * solutions, the common vertex can safely be removed @@ -174,20 +174,20 @@ public ClipperOffset(double miterLimit, double arcTolerance, boolean preserveCol setReverseSolution(reverseSolution); } - public final void Clear() { + public final void clear() { groupList.clear(); } - public final void AddPath(Path64 path, JoinType joinType, EndType endType) { + public final void addPath(Path64 path, JoinType joinType, EndType endType) { int cnt = path.size(); if (cnt == 0) { return; } Paths64 pp = new Paths64(Arrays.asList(path)); - AddPaths(pp, joinType, endType); + addPaths(pp, joinType, endType); } - public final void AddPaths(Paths64 paths, JoinType joinType, EndType endType) { + public final void addPaths(Paths64 paths, JoinType joinType, EndType endType) { int cnt = paths.size(); if (cnt == 0) { return; @@ -219,7 +219,7 @@ private void ExecuteInternal(double delta) { return; } this.delta = delta; - this.mitLimSqr = (miterLimit <= 1 ? 2.0 : 2.0 / Clipper.Sqr(miterLimit)); + this.mitLimSqr = (miterLimit <= 1 ? 2.0 : 2.0 / Clipper.sqr(miterLimit)); for (Group group : groupList) { DoGroupOffset(group); @@ -236,11 +236,11 @@ private void ExecuteInternal(double delta) { c.setPreserveCollinear(preserveCollinear); // the solution should retain the orientation of the input c.setReverseSolution(reverseSolution != pathsReversed); - c.AddSubject(this.solution); + c.addSubject(this.solution); if (solutionTree != null) { - c.Execute(ClipType.Union, fillRule, solutionTree); + c.execute(ClipType.Union, fillRule, solutionTree); } else { - c.Execute(ClipType.Union, fillRule, this.solution); + c.execute(ClipType.Union, fillRule, this.solution); } } @@ -256,20 +256,20 @@ boolean CheckPathsReversed() { return result; } - public final void Execute(double delta, Paths64 solution) { + public final void execute(double delta, Paths64 solution) { solution.clear(); solutionTree = null; this.solution = solution; ExecuteInternal(delta); } - public void Execute(DeltaCallback64 deltaCallback64, Paths64 solution) { + public void execute(DeltaCallback64 deltaCallback64, Paths64 solution) { deltaCallback = deltaCallback64; - Execute(1.0, solution); + execute(1.0, solution); } - public void Execute(double delta, PolyTree64 solutionTree) { - solutionTree.Clear(); + public void execute(double delta, PolyTree64 solutionTree) { + solutionTree.clear(); this.solutionTree = solutionTree; solution.clear(); ExecuteInternal(delta); @@ -413,14 +413,14 @@ private void DoSquare(Path64 path, int j, int k) { if (j == k) { PointD pt4 = new PointD(pt3.x + vec.x * groupDelta, pt3.y + vec.y * groupDelta); PointD pt = new PointD(); - InternalClipper.GetLineIntersectPt(pt1, pt2, pt3, pt4, pt); + InternalClipper.getLineIntersectPt(pt1, pt2, pt3, pt4, pt); // get the second intersect point through reflecion pathOut.add(new Point64(ReflectPoint(pt, ptQ))); pathOut.add(new Point64(pt)); } else { PointD pt4 = GetPerpendicD(path.get(j), normals.get(k)); PointD pt = new PointD(); - InternalClipper.GetLineIntersectPt(pt1, pt2, pt3, pt4, pt); + InternalClipper.getLineIntersectPt(pt1, pt2, pt3, pt4, pt); pathOut.add(new Point64(pt)); // get the second intersect point through reflecion pathOut.add(new Point64(ReflectPoint(pt, ptQ))); @@ -450,7 +450,7 @@ private void DoRound(Path64 path, int j, int k, double angle) { final Point64 pt = path.get(j); PointD offsetVec = new PointD(normals.get(k).x * groupDelta, normals.get(k).y * groupDelta); if (j == k) { - offsetVec.Negate(); + offsetVec.negate(); } pathOut.add(new Point64(pt.x + offsetVec.x, pt.y + offsetVec.y)); int steps = (int) Math.ceil(stepsPerRad * Math.abs(angle)); // #448, #456 @@ -486,8 +486,8 @@ private int OffsetPoint(Group group, Path64 path, int j, int k) { // A == PI: edges 'spike' // sin(A) < 0: right turning // cos(A) < 0: change in angle is more than 90 degree - double sinA = InternalClipper.CrossProduct(normals.get(j), normals.get(k)); - double cosA = InternalClipper.DotProduct(normals.get(j), normals.get(k)); + double sinA = InternalClipper.crossProduct(normals.get(j), normals.get(k)); + double cosA = InternalClipper.dotProduct(normals.get(j), normals.get(k)); if (sinA > 1.0) { sinA = 1.0; } else if (sinA < -1.0) { @@ -545,7 +545,7 @@ private void OffsetPolygon(Group group, Path64 path) { private void OffsetOpenJoined(Group group, Path64 path) { OffsetPolygon(group, path); - path = Clipper.ReversePath(path); + path = Clipper.reversePath(path); BuildNormals(path); OffsetPolygon(group, path); } @@ -687,11 +687,11 @@ private void DoGroupOffset(Group group) { if (group.endType == EndType.Round) { double r = absDelta; int steps = (int) Math.ceil(stepsPerRad * 2 * Math.PI); - pathOut = Clipper.Ellipse(pt, r, r, steps); + pathOut = Clipper.ellipse(pt, r, r, steps); } else { int d = (int) Math.ceil(groupDelta); Rect64 r = new Rect64(pt.x - d, pt.y - d, pt.x + d, pt.y + d); - pathOut = r.AsPath(); + pathOut = r.asPath(); } solution.add(pathOut); continue; diff --git a/src/main/java/com/github/micycle1/clipper2/offset/Group.java b/src/main/java/com/github/micycle1/clipper2/offset/Group.java index e52357f..a07cd79 100644 --- a/src/main/java/com/github/micycle1/clipper2/offset/Group.java +++ b/src/main/java/com/github/micycle1/clipper2/offset/Group.java @@ -27,7 +27,7 @@ class Group { inPaths = new Paths64(paths.size()); for (Path64 path : paths) { - inPaths.add(Clipper.StripDuplicates(path, isJoined)); + inPaths.add(Clipper.stripDuplicates(path, isJoined)); } if (endType == EndType.Polygon) { @@ -59,7 +59,7 @@ private static LowestPathInfo GetLowestPathInfo(Paths64 paths) { continue; } if (area == Double.MAX_VALUE) { - area = Clipper.Area(paths.get(i)); + area = Clipper.area(paths.get(i)); if (area == 0) { break; // invalid closed path } diff --git a/src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java index ee51125..1e1e076 100644 --- a/src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java +++ b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java @@ -70,8 +70,8 @@ protected static final class NextLocationResult { public RectClip64(Rect64 rect) { currIdx_ = -1; rect_ = rect; - mp_ = rect.MidPoint(); - rectPath_ = rect.AsPath(); + mp_ = rect.midPoint(); + rectPath_ = rect.asPath(); results_ = new ArrayList<>(); edges_ = new ArrayList[8]; for (int i = 0; i < 8; i++) { @@ -112,7 +112,7 @@ protected OutPt2 add(Point64 pt, boolean startingNewPath) { private static boolean path1ContainsPath2(Path64 p1, Path64 p2) { int io = 0; for (Point64 pt : p2) { - PointInPolygonResult pip = InternalClipper.PointInPolygon(pt, p1); + PointInPolygonResult pip = InternalClipper.pointInPolygon(pt, p1); switch (pip) { case IsInside : io--; @@ -130,7 +130,7 @@ private static boolean path1ContainsPath2(Path64 p1, Path64 p2) { private static boolean isClockwise(Location prev, Location curr, Point64 p1, Point64 p2, Point64 mid) { if (areOpposites(prev, curr)) { - return InternalClipper.CrossProductSign(p1, mid, p2) < 0; + return InternalClipper.crossProductSign(p1, mid, p2) < 0; } return headingClockwise(prev, curr); } @@ -281,8 +281,8 @@ private static boolean isHorizontal(Point64 a, Point64 b) { } private static boolean getSegmentIntersection(Point64 p1, Point64 p2, Point64 p3, Point64 p4, Point64 ipRefObject) { - int r1 = InternalClipper.CrossProductSign(p1, p3, p4); - int r2 = InternalClipper.CrossProductSign(p2, p3, p4); + int r1 = InternalClipper.crossProductSign(p1, p3, p4); + int r2 = InternalClipper.crossProductSign(p2, p3, p4); if (r1 == 0) { ipRefObject.set(p1); if (r2 == 0) { @@ -310,8 +310,8 @@ private static boolean getSegmentIntersection(Point64 p1, Point64 p2, Point64 p3 ipRefObject.set(new Point64(0, 0)); return false; } - int r3 = InternalClipper.CrossProductSign(p3, p1, p2); - int r4 = InternalClipper.CrossProductSign(p4, p1, p2); + int r3 = InternalClipper.crossProductSign(p3, p1, p2); + int r4 = InternalClipper.crossProductSign(p4, p1, p2); if (r3 == 0) { ipRefObject.set(p3); if (p3.equals(p1) || p3.equals(p2)) { @@ -336,7 +336,7 @@ private static boolean getSegmentIntersection(Point64 p1, Point64 p2, Point64 p3 ipRefObject.set(new Point64(0, 0)); return false; } - return InternalClipper.GetLineIntersectPt(p1, p2, p3, p4, ipRefObject); + return InternalClipper.getLineIntersectPt(p1, p2, p3, p4, ipRefObject); } protected static IntersectionResult getIntersection(Path64 rectPath, Point64 p, Point64 p2, Location loc, Point64 ipRefObject) { @@ -518,7 +518,7 @@ private static boolean startLocsAreClockwise(List locs) { } protected void executeInternal(Path64 path) { - if (path.size() < 3 || rect_.IsEmpty()) { + if (path.size() < 3 || rect_.isEmpty()) { return; } @@ -663,7 +663,7 @@ protected void executeInternal(Path64 path) { // ––– tail‐end logic (unchanged) if (firstCross == Location.inside) { // never intersected - if (startingLoc == Location.inside || !pathBounds_.Contains(rect_) || !path1ContainsPath2(path, rectPath_)) { + if (startingLoc == Location.inside || !pathBounds_.contains(rect_) || !path1ContainsPath2(path, rectPath_)) { return; } @@ -691,20 +691,20 @@ protected void executeInternal(Path64 path) { } } - public Paths64 Execute(List paths) { + public Paths64 execute(List paths) { Paths64 res = new Paths64(); - if (rect_.IsEmpty()) { + if (rect_.isEmpty()) { return res; } for (Path64 path : paths) { if (path.size() < 3) { continue; } - pathBounds_ = Clipper.GetBounds(path); - if (!rect_.Intersects(pathBounds_)) { + pathBounds_ = Clipper.getBounds(path); + if (!rect_.intersects(pathBounds_)) { continue; } - if (rect_.Contains(pathBounds_)) { + if (rect_.contains(pathBounds_)) { res.add(path); continue; } @@ -735,7 +735,7 @@ private void checkEdges() { } OutPt2 o2 = op; do { - if (InternalClipper.IsCollinear(o2.prev.pt, o2.pt, o2.next.pt)) { + if (InternalClipper.isCollinear(o2.prev.pt, o2.pt, o2.next.pt)) { if (o2 == op) { o2 = unlinkOpBack(o2); if (o2 == null) { @@ -909,7 +909,7 @@ private static Path64 getPath(OutPt2 op) { } OutPt2 start = op.next; while (start != null && start != op) { - if (InternalClipper.IsCollinear(start.prev.pt, start.pt, start.next.pt)) { + if (InternalClipper.isCollinear(start.prev.pt, start.pt, start.next.pt)) { op = start.prev; start = unlinkOp(start); } else { diff --git a/src/main/java/com/github/micycle1/clipper2/rectclip/RectClipLines64.java b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClipLines64.java index f2f08e2..3e3f0c4 100644 --- a/src/main/java/com/github/micycle1/clipper2/rectclip/RectClipLines64.java +++ b/src/main/java/com/github/micycle1/clipper2/rectclip/RectClipLines64.java @@ -22,17 +22,17 @@ public RectClipLines64(Rect64 rect) { super(rect); } - public Paths64 Execute(Paths64 paths) { + public Paths64 execute(Paths64 paths) { Paths64 res = new Paths64(); - if (rect_.IsEmpty()) { + if (rect_.isEmpty()) { return res; } for (Path64 path : paths) { if (path.size() < 2) { continue; } - pathBounds_ = Clipper.GetBounds(path); - if (!rect_.Intersects(pathBounds_)) { + pathBounds_ = Clipper.getBounds(path); + if (!rect_.intersects(pathBounds_)) { continue; } executeInternal(path); @@ -68,7 +68,7 @@ private static Path64 getPath(OutPt2 op) { @Override protected void executeInternal(Path64 path) { results_.clear(); - if (path.size() < 2 || rect_.IsEmpty()) { + if (path.size() < 2 || rect_.isEmpty()) { return; } Location loc = Location.inside; diff --git a/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper1.java b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper1.java index d36f758..c8f110b 100644 --- a/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper1.java +++ b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper1.java @@ -58,7 +58,7 @@ public void setup() { @Benchmark @OutputTimeUnit(TimeUnit.SECONDS) - public void Intersection(BenchmarkState state) { + public void intersection(BenchmarkState state) { DefaultClipper c = new DefaultClipper(); c.addPaths(state.subj, PolyType.SUBJECT, true); c.addPaths(state.clip, PolyType.CLIP, true); diff --git a/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper2.java b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper2.java index c0e761e..5b349d7 100644 --- a/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper2.java +++ b/src/test/java/com/github/micycle1/clipper2/BenchmarkClipper2.java @@ -57,11 +57,11 @@ public void setup() { @Benchmark @OutputTimeUnit(TimeUnit.SECONDS) - public void Intersection(BenchmarkState state) { + public void intersection(BenchmarkState state) { Clipper64 c = new Clipper64(); - c.AddSubject(state.subj); // closed - c.AddClip(state.clip); // closed - c.Execute(ClipType.Intersection, FillRule.NonZero, state.solution); + c.addSubject(state.subj); // closed + c.addClip(state.clip); // closed + c.execute(ClipType.Intersection, FillRule.NonZero, state.solution); } private static Point64 MakeRandomPt(int maxWidth, int maxHeight, Random rand) { diff --git a/src/test/java/com/github/micycle1/clipper2/ClipperFileIO.java b/src/test/java/com/github/micycle1/clipper2/ClipperFileIO.java index 45990c4..5033989 100644 --- a/src/test/java/com/github/micycle1/clipper2/ClipperFileIO.java +++ b/src/test/java/com/github/micycle1/clipper2/ClipperFileIO.java @@ -61,7 +61,7 @@ public int count() { return count; } - public int GetIdx() { + public int getIdx() { return GetIdx; } diff --git a/src/test/java/com/github/micycle1/clipper2/TestIsCollinear.java b/src/test/java/com/github/micycle1/clipper2/TestIsCollinear.java index 33f95dc..9241a1e 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestIsCollinear.java +++ b/src/test/java/com/github/micycle1/clipper2/TestIsCollinear.java @@ -64,7 +64,7 @@ void testIsCollinear() { Point64 pt1 = new Point64(0, 0); Point64 sharedPt = new Point64(i, i * 10); Point64 pt2 = new Point64(i * 10, i * 100); - assertTrue(InternalClipper.IsCollinear(pt1, sharedPt, pt2)); + assertTrue(InternalClipper.isCollinear(pt1, sharedPt, pt2)); } @Test @@ -72,9 +72,9 @@ void testIsCollinear2() { // see #831 final long i = 0x4000000000000L; Path64 subject = new Path64(new Point64(-i, -i), new Point64(i, -i), new Point64(-i, i), new Point64(i, i)); Clipper64 clipper = new Clipper64(); - clipper.AddSubject(new Paths64(subject)); + clipper.addSubject(new Paths64(subject)); Paths64 solution = new Paths64(); - clipper.Execute(ClipType.Union, FillRule.EvenOdd, solution); + clipper.execute(ClipType.Union, FillRule.EvenOdd, solution); assertEquals(2, solution.size()); } } diff --git a/src/test/java/com/github/micycle1/clipper2/TestLines.java b/src/test/java/com/github/micycle1/clipper2/TestLines.java index a90e26f..eb8c43a 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestLines.java +++ b/src/test/java/com/github/micycle1/clipper2/TestLines.java @@ -28,13 +28,13 @@ final void RunLinesTestCase(TestCase test, String caption, Object o, Object o1) Paths64 solution = new Paths64(); Paths64 solution_open = new Paths64(); - c64.AddSubject(test.subj()); - c64.AddOpenSubject(test.subj_open()); - c64.AddClip(test.clip()); - c64.Execute(test.clipType(), test.fillRule(), solution, solution_open); + c64.addSubject(test.subj()); + c64.addOpenSubject(test.subj_open()); + c64.addClip(test.clip()); + c64.execute(test.clipType(), test.fillRule(), solution, solution_open); if (test.area() > 0) { - double area2 = Clipper.Area(solution); + double area2 = Clipper.area(solution); assertEquals(test.area(), area2, test.area() * 0.005); } diff --git a/src/test/java/com/github/micycle1/clipper2/TestOffsetOrientation.java b/src/test/java/com/github/micycle1/clipper2/TestOffsetOrientation.java index 3f8237b..2a7e203 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestOffsetOrientation.java +++ b/src/test/java/com/github/micycle1/clipper2/TestOffsetOrientation.java @@ -17,27 +17,27 @@ class TestOffsetOrientation { @Test void TestOffsettingOrientation1() { - Paths64 subject = new Paths64(Clipper.MakePath(new int[] { 0, 0, 0, 5, 5, 5, 5, 0 })); + Paths64 subject = new Paths64(Clipper.makePath(new int[] { 0, 0, 0, 5, 5, 5, 5, 0 })); - Paths64 solution = Clipper.InflatePaths(subject, 1, JoinType.Round, EndType.Polygon); + Paths64 solution = Clipper.inflatePaths(subject, 1, JoinType.Round, EndType.Polygon); assertEquals(1, solution.size()); // when offsetting, output orientation should match input - assertTrue(Clipper.IsPositive(subject.get(0)) == Clipper.IsPositive(solution.get(0))); + assertTrue(Clipper.isPositive(subject.get(0)) == Clipper.isPositive(solution.get(0))); } @Test void TestOffsettingOrientation2() { - Path64 s1 = Clipper.MakePath(new int[] { 20, 220, 280, 220, 280, 280, 20, 280 }); - Path64 s2 = Clipper.MakePath(new int[] { 0, 200, 0, 300, 300, 300, 300, 200 }); + Path64 s1 = Clipper.makePath(new int[] { 20, 220, 280, 220, 280, 280, 20, 280 }); + Path64 s2 = Clipper.makePath(new int[] { 0, 200, 0, 300, 300, 300, 300, 200 }); Paths64 subject = new Paths64(List.of(s1, s2)); ClipperOffset co = new ClipperOffset(); co.setReverseSolution(true); - co.AddPaths(subject, JoinType.Round, EndType.Polygon); + co.addPaths(subject, JoinType.Round, EndType.Polygon); Paths64 solution = new Paths64(); - co.Execute(5, solution); + co.execute(5, solution); assertEquals(2, solution.size()); /* @@ -49,7 +49,7 @@ void TestOffsettingOrientation2() { * sweep-line algorithm used, paths with larger Y coordinates will likely be * listed first. */ - assertTrue(Clipper.IsPositive(subject.get(1)) != Clipper.IsPositive(solution.get(0))); + assertTrue(Clipper.isPositive(subject.get(1)) != Clipper.isPositive(solution.get(0))); } diff --git a/src/test/java/com/github/micycle1/clipper2/TestOffsets.java b/src/test/java/com/github/micycle1/clipper2/TestOffsets.java index 69b17a9..b4414fe 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestOffsets.java +++ b/src/test/java/com/github/micycle1/clipper2/TestOffsets.java @@ -26,13 +26,13 @@ void TestOffsets2() { // see #448 & #456 Paths64 subject = new Paths64(); Paths64 solution = new Paths64(); ClipperOffset c = new ClipperOffset(); - subject.add(Clipper.MakePath(new long[] { 50, 50, 100, 50, 100, 150, 50, 150, 0, 100 })); + subject.add(Clipper.makePath(new long[] { 50, 50, 100, 50, 100, 150, 50, 150, 0, 100 })); - subject = Clipper.ScalePaths(subject, scale); + subject = Clipper.scalePaths(subject, scale); - c.AddPaths(subject, JoinType.Round, EndType.Polygon); + c.addPaths(subject, JoinType.Round, EndType.Polygon); c.setArcTolerance(arc_tol); - c.Execute(delta, solution); + c.execute(delta, solution); double min_dist = delta * 2; double max_dist = 0; @@ -58,7 +58,7 @@ void TestOffsets2() { // see #448 & #456 @Test void TestOffsets3() { // see #424 - Paths64 subjects = new Paths64(List.of(Clipper.MakePath(new long[] { 1525311078, 1352369439, 1526632284, 1366692987, 1519397110, 1367437476, 1520246456, + Paths64 subjects = new Paths64(List.of(Clipper.makePath(new long[] { 1525311078, 1352369439, 1526632284, 1366692987, 1519397110, 1367437476, 1520246456, 1380177674, 1520613458, 1385913385, 1517383844, 1386238444, 1517771817, 1392099983, 1518233190, 1398758441, 1518421934, 1401883197, 1518694564, 1406612275, 1520267428, 1430289121, 1520770744, 1438027612, 1521148232, 1443438264, 1521441833, 1448964260, 1521683005, 1452518932, 1521819320, 1454374912, 1527943004, 1454154711, 1527649403, 1448523858, 1535901696, 1447989084, 1535524209, 1442788147, 1538953052, 1442463089, 1541553521, @@ -69,34 +69,34 @@ void TestOffsets3() { // see #424 1376350372, 1530050642, 1361806623, 1599487345, 1352704983, 1602758902, 1378489467, 1618990858, 1376350372, 1615058698, 1344085688, 1603230761, 1345700495, 1598648484, 1346329641, 1598931599, 1348667965, 1596698132, 1348993024, 1595775386, 1342722540 }))); - Paths64 solution = Clipper.InflatePaths(subjects, -209715, JoinType.Miter, EndType.Polygon); + Paths64 solution = Clipper.inflatePaths(subjects, -209715, JoinType.Miter, EndType.Polygon); assertTrue(solution.get(0).size() - subjects.get(0).size() <= 1); } @Test void TestOffsets4() { // see #482 - Paths64 paths = new Paths64(List.of(Clipper.MakePath(new long[] { 0, 0, 20000, 200, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); - Paths64 solution = Clipper.InflatePaths(paths, -5000, JoinType.Square, EndType.Polygon); + Paths64 paths = new Paths64(List.of(Clipper.makePath(new long[] { 0, 0, 20000, 200, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); + Paths64 solution = Clipper.inflatePaths(paths, -5000, JoinType.Square, EndType.Polygon); assertEquals(5, solution.get(0).size()); - paths = new Paths64(List.of(Clipper.MakePath(new long[] { 0, 0, 20000, 400, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); - solution = Clipper.InflatePaths(paths, -5000, JoinType.Square, EndType.Polygon); + paths = new Paths64(List.of(Clipper.makePath(new long[] { 0, 0, 20000, 400, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); + solution = Clipper.inflatePaths(paths, -5000, JoinType.Square, EndType.Polygon); assertEquals(5, solution.get(0).size()); - paths = new Paths64(List.of(Clipper.MakePath(new long[] { 0, 0, 20000, 400, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); - solution = Clipper.InflatePaths(paths, -5000, JoinType.Round, EndType.Polygon, 2, 100); + paths = new Paths64(List.of(Clipper.makePath(new long[] { 0, 0, 20000, 400, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); + solution = Clipper.inflatePaths(paths, -5000, JoinType.Round, EndType.Polygon, 2, 100); assertTrue(solution.get(0).size() > 5); - paths = new Paths64(List.of(Clipper.MakePath(new long[] { 0, 0, 20000, 1500, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); - solution = Clipper.InflatePaths(paths, -5000, JoinType.Round, EndType.Polygon, 2, 100); + paths = new Paths64(List.of(Clipper.makePath(new long[] { 0, 0, 20000, 1500, 40000, 0, 40000, 50000, 0, 50000, 0, 0 }))); + solution = Clipper.inflatePaths(paths, -5000, JoinType.Round, EndType.Polygon, 2, 100); assertTrue(solution.get(0).size() > 5); } @Test void TestOffsets6() { - Path64 squarePath = Clipper.MakePath(new long[] { 620, 620, -620, 620, -620, -620, 620, -620 }); + Path64 squarePath = Clipper.makePath(new long[] { 620, 620, -620, 620, -620, -620, 620, -620 }); - Path64 complexPath = Clipper.MakePath(new long[] { 20, -277, 42, -275, 59, -272, 80, -266, 97, -261, 114, -254, 135, -243, 149, -235, 167, -222, 182, + Path64 complexPath = Clipper.makePath(new long[] { 20, -277, 42, -275, 59, -272, 80, -266, 97, -261, 114, -254, 135, -243, 149, -235, 167, -222, 182, -211, 197, -197, 212, -181, 223, -167, 234, -150, 244, -133, 253, -116, 260, -99, 267, -78, 272, -61, 275, -40, 278, -18, 276, -39, 272, -61, 267, -79, 260, -99, 253, -116, 245, -133, 235, -150, 223, -167, 212, -181, 197, -197, 182, -211, 168, -222, 152, -233, 135, -243, 114, -254, 97, -261, 80, -267, 59, -272, 42, -275, 20, -278 }); @@ -106,41 +106,41 @@ void TestOffsets6() { final double offset = -50; ClipperOffset offseter = new ClipperOffset(); - offseter.AddPaths(subjects, JoinType.Round, EndType.Polygon); + offseter.addPaths(subjects, JoinType.Round, EndType.Polygon); Paths64 solution = new Paths64(); - offseter.Execute(offset, solution); + offseter.execute(offset, solution); assertEquals(2, solution.size()); - double area = Clipper.Area(solution.get(1)); + double area = Clipper.area(solution.get(1)); assertTrue(area < -47500); } @Test void TestOffsets7() { // (#593 & #715) Paths64 solution; - Paths64 subject = new Paths64(List.of(Clipper.MakePath(new long[] { 0, 0, 100, 0, 100, 100, 0, 100 }))); + Paths64 subject = new Paths64(List.of(Clipper.makePath(new long[] { 0, 0, 100, 0, 100, 100, 0, 100 }))); - solution = Clipper.InflatePaths(subject, -50, JoinType.Miter, EndType.Polygon); + solution = Clipper.inflatePaths(subject, -50, JoinType.Miter, EndType.Polygon); assertEquals(0, solution.size()); - subject.add(Clipper.MakePath(new long[] { 40, 60, 60, 60, 60, 40, 40, 40 })); - solution = Clipper.InflatePaths(subject, 10, JoinType.Miter, EndType.Polygon); + subject.add(Clipper.makePath(new long[] { 40, 60, 60, 60, 60, 40, 40, 40 })); + solution = Clipper.inflatePaths(subject, 10, JoinType.Miter, EndType.Polygon); assertEquals(1, solution.size()); Collections.reverse(subject.get(0)); Collections.reverse(subject.get(1)); - solution = Clipper.InflatePaths(subject, 10, JoinType.Miter, EndType.Polygon); + solution = Clipper.inflatePaths(subject, 10, JoinType.Miter, EndType.Polygon); assertEquals(1, solution.size()); subject = new Paths64(List.of(subject.get(0))); - solution = Clipper.InflatePaths(subject, -50, JoinType.Miter, EndType.Polygon); + solution = Clipper.inflatePaths(subject, -50, JoinType.Miter, EndType.Polygon); assertEquals(0, solution.size()); } @Test void TestOffsets8() { // (#724) - Paths64 subject = new Paths64(List.of(Clipper.MakePath(new long[] { 91759700, -49711991, 83886095, -50331657, -872415388, -50331657, -880288993, + Paths64 subject = new Paths64(List.of(Clipper.makePath(new long[] { 91759700, -49711991, 83886095, -50331657, -872415388, -50331657, -880288993, -49711991, -887968725, -47868251, -895265482, -44845834, -901999593, -40719165, -908005244, -35589856, -913134553, -29584205, -917261224, -22850094, -920283639, -15553337, -922127379, -7873605, -922747045, 0, -922747045, 1434498600, -922160557, 1442159790, -920414763, 1449642437, -917550346, 1456772156, -913634061, 1463382794, -908757180, 1469320287, -903033355, 1474446264, -896595982, 1478641262, -889595081, 1481807519, @@ -185,7 +185,7 @@ void TestOffsets8() { // (#724) double offset = -50329979.277800001; double arc_tol = 5000; - Paths64 solution = Clipper.InflatePaths(subject, offset, JoinType.Round, EndType.Polygon, 2, arc_tol); + Paths64 solution = Clipper.inflatePaths(subject, offset, JoinType.Round, EndType.Polygon, 2, arc_tol); OffsetQual oq = getOffsetQuality(subject.get(0), solution.get(0), offset); double smallestDist = distance(oq.smallestInSub, oq.smallestInSol); double largestDist = distance(oq.largestInSub, oq.largestInSol); @@ -202,73 +202,73 @@ void TestOffsets9() { // (#733) // reverse_solution is set true in ClipperOffset's constructor // start subject's orientation positive ... - Paths64 subject = new Paths64(Clipper.MakePath(new long[] { 100, 100, 200, 100, 200, 400, 100, 400 })); - Paths64 solution = Clipper.InflatePaths(subject, 50, JoinType.Miter, EndType.Polygon); + Paths64 subject = new Paths64(Clipper.makePath(new long[] { 100, 100, 200, 100, 200, 400, 100, 400 })); + Paths64 solution = Clipper.inflatePaths(subject, 50, JoinType.Miter, EndType.Polygon); assertEquals(1, solution.size()); - assertTrue(Clipper.IsPositive(solution.get(0))); + assertTrue(Clipper.isPositive(solution.get(0))); // reversing subject's orientation should not affect delta direction // (ie where positive deltas inflate). Collections.reverse(subject.get(0)); - solution = Clipper.InflatePaths(subject, 50, JoinType.Miter, EndType.Polygon); + solution = Clipper.inflatePaths(subject, 50, JoinType.Miter, EndType.Polygon); assertEquals(1, solution.size()); - assertTrue(Math.abs(Clipper.Area(solution.get(0))) > Math.abs(Clipper.Area(subject.get(0)))); - assertFalse(Clipper.IsPositive(solution.get(0))); + assertTrue(Math.abs(Clipper.area(solution.get(0))) > Math.abs(Clipper.area(subject.get(0)))); + assertFalse(Clipper.isPositive(solution.get(0))); ClipperOffset co = new ClipperOffset(2, 0, false, true); // last param. reverses solution - co.AddPaths(subject, JoinType.Miter, EndType.Polygon); - co.Execute(50, solution); + co.addPaths(subject, JoinType.Miter, EndType.Polygon); + co.execute(50, solution); assertEquals(1, solution.size()); - assertTrue(Math.abs(Clipper.Area(solution.get(0))) > Math.abs(Clipper.Area(subject.get(0)))); - assertTrue(Clipper.IsPositive(solution.get(0))); + assertTrue(Math.abs(Clipper.area(solution.get(0))) > Math.abs(Clipper.area(subject.get(0)))); + assertTrue(Clipper.isPositive(solution.get(0))); // add a hole (ie has reverse orientation to outer path) - subject.add(Clipper.MakePath(new long[] { 130, 130, 170, 130, 170, 370, 130, 370 })); - solution = Clipper.InflatePaths(subject, 30, JoinType.Miter, EndType.Polygon); + subject.add(Clipper.makePath(new long[] { 130, 130, 170, 130, 170, 370, 130, 370 })); + solution = Clipper.inflatePaths(subject, 30, JoinType.Miter, EndType.Polygon); assertEquals(1, solution.size()); - assertFalse(Clipper.IsPositive(solution.get(0))); + assertFalse(Clipper.isPositive(solution.get(0))); - co.Clear(); // should still reverse solution orientation - co.AddPaths(subject, JoinType.Miter, EndType.Polygon); - co.Execute(30, solution); + co.clear(); // should still reverse solution orientation + co.addPaths(subject, JoinType.Miter, EndType.Polygon); + co.execute(30, solution); assertEquals(1, solution.size()); - assertTrue(Math.abs(Clipper.Area(solution.get(0))) > Math.abs(Clipper.Area(subject.get(0)))); - assertTrue(Clipper.IsPositive(solution.get(0))); + assertTrue(Math.abs(Clipper.area(solution.get(0))) > Math.abs(Clipper.area(subject.get(0)))); + assertTrue(Clipper.isPositive(solution.get(0))); - solution = Clipper.InflatePaths(subject, -15, JoinType.Miter, EndType.Polygon); + solution = Clipper.inflatePaths(subject, -15, JoinType.Miter, EndType.Polygon); assertEquals(0, solution.size()); } @Test void TestOffsets10() { // see #715 - Paths64 subjects = new Paths64(List.of(Clipper.MakePath(new long[] { 508685336, -435806096, 509492982, -434729201, 509615525, -434003092, 509615525, + Paths64 subjects = new Paths64(List.of(Clipper.makePath(new long[] { 508685336, -435806096, 509492982, -434729201, 509615525, -434003092, 509615525, 493372891, 509206033, 494655198, 508129138, 495462844, 507403029, 495585387, -545800889, 495585387, -547083196, 495175895, -547890842, 494099000, -548013385, 493372891, -548013385, -434003092, -547603893, -435285399, -546526998, -436093045, -545800889, -436215588, 507403029, - -436215588 }), Clipper.MakePath(new long[] { 106954765, -62914568, 106795129, -63717113, 106340524, -64397478, 105660159, -64852084, 104857613, + -436215588 }), Clipper.makePath(new long[] { 106954765, -62914568, 106795129, -63717113, 106340524, -64397478, 105660159, -64852084, 104857613, -65011720, 104055068, -64852084, 103374703, -64397478, 102920097, -63717113, 102760461, -62914568, 102920097, -62112022, 103374703, -61431657, 104055068, -60977052, 104857613, -60817416, 105660159, -60977052, 106340524, -61431657, 106795129, -62112022 }))); ClipperOffset offseter = new ClipperOffset(2, 104857.61318750000); Paths64 solution = new Paths64(); - offseter.AddPaths(subjects, JoinType.Round, EndType.Polygon); - offseter.Execute(-2212495.6382562499, solution); + offseter.addPaths(subjects, JoinType.Round, EndType.Polygon); + offseter.execute(-2212495.6382562499, solution); assertEquals(2, solution.size()); } @Test void TestOffsets11() { // see #405 PathsD subject = new PathsD(); - subject.add(Clipper.MakePath(new double[] { -1.0, -1.0, -1.0, 11.0, 11.0, 11.0, 11.0, -1.0 })); + subject.add(Clipper.makePath(new double[] { -1.0, -1.0, -1.0, 11.0, 11.0, 11.0, 11.0, -1.0 })); // offset polygon - PathsD solution = Clipper.InflatePaths(subject, -50, JoinType.Miter, EndType.Polygon); + PathsD solution = Clipper.inflatePaths(subject, -50, JoinType.Miter, EndType.Polygon); assertTrue(solution.isEmpty()); } @Test void TestOffsets12() { // see #873 Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 667680768, -36382704, 737202688, -87034880, 742581888, -86055680, 747603968, -84684800 })); - Paths64 solution = Clipper.InflatePaths(subject, -249561088, JoinType.Miter, EndType.Polygon); + subject.add(Clipper.makePath(new long[] { 667680768, -36382704, 737202688, -87034880, 742581888, -86055680, 747603968, -84684800 })); + Paths64 solution = Clipper.inflatePaths(subject, -249561088, JoinType.Miter, EndType.Polygon); assertTrue(solution.isEmpty()); } @@ -279,15 +279,15 @@ void TestOffsets13() { // see #965 Paths64 subjects1 = new Paths64(); subjects1.add(subject1); - Paths64 solution1 = Clipper.InflatePaths(subjects1, delta, JoinType.Miter, EndType.Polygon); - long area1 = Math.round(Math.abs(Clipper.Area(solution1))); + Paths64 solution1 = Clipper.inflatePaths(subjects1, delta, JoinType.Miter, EndType.Polygon); + long area1 = Math.round(Math.abs(Clipper.area(solution1))); assertEquals(122L, area1); Paths64 subjects2 = new Paths64(); subjects2.add(subject1); subjects2.add(new Path64(List.of(new Point64(0, 20)))); // single-point path should not change output - Paths64 solution2 = Clipper.InflatePaths(subjects2, delta, JoinType.Miter, EndType.Polygon); - long area2 = Math.round(Math.abs(Clipper.Area(solution2))); + Paths64 solution2 = Clipper.inflatePaths(subjects2, delta, JoinType.Miter, EndType.Polygon); + long area2 = Math.round(Math.abs(Clipper.area(solution2))); assertEquals(122L, area2); } diff --git a/src/test/java/com/github/micycle1/clipper2/TestPolygons.java b/src/test/java/com/github/micycle1/clipper2/TestPolygons.java index 1626a27..dca58be 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestPolygons.java +++ b/src/test/java/com/github/micycle1/clipper2/TestPolygons.java @@ -32,13 +32,13 @@ final void RunPolygonsTestCase(TestCase test, int testNum, Object o, Object o1) Paths64 solution = new Paths64(); Paths64 solution_open = new Paths64(); - c64.AddSubject(test.subj()); - c64.AddOpenSubject(test.subj_open()); - c64.AddClip(test.clip()); - c64.Execute(test.clipType(), test.fillRule(), solution, solution_open); + c64.addSubject(test.subj()); + c64.addOpenSubject(test.subj_open()); + c64.addClip(test.clip()); + c64.execute(test.clipType(), test.fillRule(), solution, solution_open); int measuredCount = solution.size(); - long measuredArea = (long) Clipper.Area(solution); + long measuredArea = (long) Clipper.area(solution); int storedCount = test.count(); long storedArea = test.area(); int countDiff = storedCount > 0 ? Math.abs(storedCount - measuredCount) : 0; @@ -88,15 +88,15 @@ final void RunPolygonsTestCase(TestCase test, int testNum, Object o, Object o1) @Test void TestCollinearOnMacOs() { // #777 Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 0, -453054451, 0, -433253797, -455550000, 0 })); - subject.add(Clipper.MakePath(new long[] { 0, -433253797, 0, 0, -455550000, 0 })); + subject.add(Clipper.makePath(new long[] { 0, -453054451, 0, -433253797, -455550000, 0 })); + subject.add(Clipper.makePath(new long[] { 0, -433253797, 0, 0, -455550000, 0 })); Clipper64 clipper = new Clipper64(); clipper.setPreserveCollinear(false); - clipper.AddSubject(subject); + clipper.addSubject(subject); Paths64 solution = new Paths64(); - clipper.Execute(ClipType.Union, FillRule.NonZero, solution); + clipper.execute(ClipType.Union, FillRule.NonZero, solution); assertEquals(1, solution.size()); assertEquals(3, solution.get(0).size()); - assertEquals(Clipper.IsPositive(subject.get(0)), Clipper.IsPositive(solution.get(0))); + assertEquals(Clipper.isPositive(subject.get(0)), Clipper.isPositive(solution.get(0))); } } diff --git a/src/test/java/com/github/micycle1/clipper2/TestPolytree.java b/src/test/java/com/github/micycle1/clipper2/TestPolytree.java index 95dfa36..6ca0575 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestPolytree.java +++ b/src/test/java/com/github/micycle1/clipper2/TestPolytree.java @@ -49,7 +49,7 @@ final void RunPolytreeTestCase(TestCase test, String caption, Object o, Object o for (Point64 pt : pointsOfInterestOutside) { for (Path64 path : subject) { - assertEquals(PointInPolygonResult.IsOutside, Clipper.PointInPolygon(pt, path), + assertEquals(PointInPolygonResult.IsOutside, Clipper.pointInPolygon(pt, path), "outside point of interest found inside subject"); } } @@ -60,20 +60,20 @@ final void RunPolytreeTestCase(TestCase test, String caption, Object o, Object o for (Point64 pt : pointsOfInterestInside) { int poi_inside_counter = 0; for (Path64 path : subject) { - if (Clipper.PointInPolygon(pt, path) == PointInPolygonResult.IsInside) { + if (Clipper.pointInPolygon(pt, path) == PointInPolygonResult.IsInside) { poi_inside_counter++; } } assertEquals(1, poi_inside_counter, String.format("poi_inside_counter - expected 1 but got %1$s", poi_inside_counter)); } - clipper.AddSubject(subject); - clipper.AddOpenSubject(subjectOpen); - clipper.AddClip(clip); - clipper.Execute(test.clipType(), test.fillRule(), solutionTree, solution_open); + clipper.addSubject(subject); + clipper.addOpenSubject(subjectOpen); + clipper.addClip(clip); + clipper.execute(test.clipType(), test.fillRule(), solutionTree, solution_open); - Paths64 solutionPaths = Clipper.PolyTreeToPaths64(solutionTree); - double a1 = Clipper.Area(solutionPaths), a2 = solutionTree.Area(); + Paths64 solutionPaths = Clipper.polyTreeToPaths64(solutionTree); + double a1 = Clipper.area(solutionPaths), a2 = solutionTree.area(); assertTrue(a1 > 330000, String.format("solution has wrong area - value expected: 331,052; value returned; %1$s ", a1)); @@ -106,7 +106,7 @@ private static boolean PolyPathFullyContainsChildren(PolyPath64 pp) { for (PolyPathBase c : pp) { PolyPath64 child = (PolyPath64) c; for (Point64 pt : child.getPolygon()) { - if (Clipper.PointInPolygon(pt, pp.getPolygon()) == PointInPolygonResult.IsOutside) { + if (Clipper.pointInPolygon(pt, pp.getPolygon()) == PointInPolygonResult.IsOutside) { return false; } } @@ -128,7 +128,7 @@ private static boolean PolytreeContainsPoint(PolyTree64 pp, Point64 pt) { } private static int PolyPathContainsPoint(PolyPath64 pp, Point64 pt, int counter) { - if (Clipper.PointInPolygon(pt, pp.getPolygon()) != PointInPolygonResult.IsOutside) { + if (Clipper.pointInPolygon(pt, pp.getPolygon()) != PointInPolygonResult.IsOutside) { if (pp.getIsHole()) { counter--; } else { @@ -145,10 +145,10 @@ private static int PolyPathContainsPoint(PolyPath64 pp, Point64 pt, int counter) @Test void TestPolytree3() { // #942 Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 1588700, -8717600, 1616200, -8474800, 1588700, -8474800 })); - subject.add(Clipper.MakePath(new long[] { 13583800, -15601600, 13582800, -15508500, 13555300, -15508500, 13555500, -15182200, 13010900, -15185400 })); - subject.add(Clipper.MakePath(new long[] { 956700, -3092300, 1152600, 3147400, 25600, 3151700 })); - subject.add(Clipper.MakePath(new long[] { 22575900, -16604000, 31286800, -12171900, 31110200, 4882800, 30996200, 4826300, 30414400, 5447400, 30260000, 5391500, + subject.add(Clipper.makePath(new long[] { 1588700, -8717600, 1616200, -8474800, 1588700, -8474800 })); + subject.add(Clipper.makePath(new long[] { 13583800, -15601600, 13582800, -15508500, 13555300, -15508500, 13555500, -15182200, 13010900, -15185400 })); + subject.add(Clipper.makePath(new long[] { 956700, -3092300, 1152600, 3147400, 25600, 3151700 })); + subject.add(Clipper.makePath(new long[] { 22575900, -16604000, 31286800, -12171900, 31110200, 4882800, 30996200, 4826300, 30414400, 5447400, 30260000, 5391500, 29662200, 5805400, 28844500, 5337900, 28435000, 5789300, 27721400, 5026400, 22876300, 5034300, 21977700, 4414900, 21148000, 4654700, 20917600, 4653400, 19334300, 12411000, -2591700, 12177200, 53200, 3151100, -2564300, 12149800, 7819400, 4692400, 10116000, 5228600, 6975500, 3120100, 7379700, 3124700, 11037900, 596200, 12257000, 2587800, 12257000, 596200, 15227300, 2352700, 18444400, 1112100, 19961100, 5549400, 20173200, 5078600, 20330000, 5079300, @@ -157,13 +157,13 @@ void TestPolytree3() { // #942 29269900, 162300, 28941400, 213100, 27491300, -3041500, 27588700, -2997800, 22104900, -16142800, 13010900, -15603000, 13555500, -15182200, 13555300, -15508500, 13582800, -15508500, 13583100, -15154700, 1588700, -8822800, 1588700, -8379900, 1588700, -8474800, 1616200, -8474800, 1003900, -630100, 1253300, -12284500, 12983400, -16239900 })); - subject.add(Clipper.MakePath(new long[] { 198200, 12149800, 1010600, 12149800, 1011500, 11859600 })); - subject.add(Clipper.MakePath(new long[] { 21996700, -7432000, 22096700, -7432000, 22096700, -7332000 })); + subject.add(Clipper.makePath(new long[] { 198200, 12149800, 1010600, 12149800, 1011500, 11859600 })); + subject.add(Clipper.makePath(new long[] { 21996700, -7432000, 22096700, -7432000, 22096700, -7332000 })); PolyTree64 solutionTree = new PolyTree64(); Clipper64 clipper = new Clipper64(); - clipper.AddSubject(subject); - clipper.Execute(ClipType.Union, FillRule.NonZero, solutionTree); + clipper.addSubject(subject); + clipper.execute(ClipType.Union, FillRule.NonZero, solutionTree); assertTrue(solutionTree.getCount() == 1 && solutionTree.get(0).getCount() == 2 && solutionTree.get(0).get(1).getCount() == 1); } @@ -171,28 +171,28 @@ void TestPolytree3() { // #942 @Test void TestPolytree4() { // #957 Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 77910, 46865, 78720, 46865, 78720, 48000, 77910, 48000, 77910, 46865 })); - subject.add(Clipper.MakePath(new long[] { 82780, 53015, 93600, 53015, 93600, 54335, 82780, 54335, 82780, 53015 })); - subject.add(Clipper.MakePath(new long[] { 82780, 48975, 84080, 48975, 84080, 53015, 82780, 53015, 82780, 48975 })); - subject.add(Clipper.MakePath(new long[] { 77910, 48000, 84080, 48000, 84080, 48975, 77910, 48975, 77910, 48000 })); - subject.add(Clipper.MakePath(new long[] { 89880, 40615, 90700, 40615, 90700, 46865, 89880, 46865, 89880, 40615 })); - subject.add(Clipper.MakePath(new long[] { 92700, 54335, 93600, 54335, 93600, 61420, 92700, 61420, 92700, 54335 })); - subject.add(Clipper.MakePath(new long[] { 78950, 47425, 84080, 47425, 84080, 47770, 78950, 47770, 78950, 47425 })); - subject.add(Clipper.MakePath(new long[] { 82780, 61420, 93600, 61420, 93600, 62435, 82780, 62435, 82780, 61420 })); - subject.add(Clipper.MakePath(new long[] { 101680, 63085, 100675, 63085, 100675, 47770, 100680, 47770, 100680, 40615, 101680, 40615, 101680, 63085 })); - subject.add(Clipper.MakePath(new long[] { 76195, 39880, 89880, 39880, 89880, 41045, 76195, 41045, 76195, 39880 })); - subject.add(Clipper.MakePath(new long[] { 85490, 56145, 90520, 56145, 90520, 59235, 85490, 59235, 85490, 56145 })); - subject.add(Clipper.MakePath(new long[] { 89880, 39880, 101680, 39880, 101680, 40615, 89880, 40615, 89880, 39880 })); - subject.add(Clipper.MakePath(new long[] { 89880, 46865, 100680, 46865, 100680, 47770, 89880, 47770, 89880, 46865 })); - subject.add(Clipper.MakePath(new long[] { 82780, 54335, 83280, 54335, 83280, 61420, 82780, 61420, 82780, 54335 })); - subject.add(Clipper.MakePath(new long[] { 76195, 41045, 76855, 41045, 76855, 62665, 76195, 62665, 76195, 41045 })); - subject.add(Clipper.MakePath(new long[] { 76195, 62665, 100675, 62665, 100675, 63085, 76195, 63085, 76195, 62665 })); - subject.add(Clipper.MakePath(new long[] { 82780, 41045, 84080, 41045, 84080, 47425, 82780, 47425, 82780, 41045 })); + subject.add(Clipper.makePath(new long[] { 77910, 46865, 78720, 46865, 78720, 48000, 77910, 48000, 77910, 46865 })); + subject.add(Clipper.makePath(new long[] { 82780, 53015, 93600, 53015, 93600, 54335, 82780, 54335, 82780, 53015 })); + subject.add(Clipper.makePath(new long[] { 82780, 48975, 84080, 48975, 84080, 53015, 82780, 53015, 82780, 48975 })); + subject.add(Clipper.makePath(new long[] { 77910, 48000, 84080, 48000, 84080, 48975, 77910, 48975, 77910, 48000 })); + subject.add(Clipper.makePath(new long[] { 89880, 40615, 90700, 40615, 90700, 46865, 89880, 46865, 89880, 40615 })); + subject.add(Clipper.makePath(new long[] { 92700, 54335, 93600, 54335, 93600, 61420, 92700, 61420, 92700, 54335 })); + subject.add(Clipper.makePath(new long[] { 78950, 47425, 84080, 47425, 84080, 47770, 78950, 47770, 78950, 47425 })); + subject.add(Clipper.makePath(new long[] { 82780, 61420, 93600, 61420, 93600, 62435, 82780, 62435, 82780, 61420 })); + subject.add(Clipper.makePath(new long[] { 101680, 63085, 100675, 63085, 100675, 47770, 100680, 47770, 100680, 40615, 101680, 40615, 101680, 63085 })); + subject.add(Clipper.makePath(new long[] { 76195, 39880, 89880, 39880, 89880, 41045, 76195, 41045, 76195, 39880 })); + subject.add(Clipper.makePath(new long[] { 85490, 56145, 90520, 56145, 90520, 59235, 85490, 59235, 85490, 56145 })); + subject.add(Clipper.makePath(new long[] { 89880, 39880, 101680, 39880, 101680, 40615, 89880, 40615, 89880, 39880 })); + subject.add(Clipper.makePath(new long[] { 89880, 46865, 100680, 46865, 100680, 47770, 89880, 47770, 89880, 46865 })); + subject.add(Clipper.makePath(new long[] { 82780, 54335, 83280, 54335, 83280, 61420, 82780, 61420, 82780, 54335 })); + subject.add(Clipper.makePath(new long[] { 76195, 41045, 76855, 41045, 76855, 62665, 76195, 62665, 76195, 41045 })); + subject.add(Clipper.makePath(new long[] { 76195, 62665, 100675, 62665, 100675, 63085, 76195, 63085, 76195, 62665 })); + subject.add(Clipper.makePath(new long[] { 82780, 41045, 84080, 41045, 84080, 47425, 82780, 47425, 82780, 41045 })); PolyTree64 solutionTree = new PolyTree64(); Clipper64 clipper = new Clipper64(); - clipper.AddSubject(subject); - clipper.Execute(ClipType.Union, FillRule.NonZero, solutionTree); + clipper.addSubject(subject); + clipper.execute(ClipType.Union, FillRule.NonZero, solutionTree); assertTrue(solutionTree.getCount() == 1 && solutionTree.get(0).getCount() == 2 && solutionTree.get(0).get(0).getCount() == 1); } @@ -200,16 +200,16 @@ void TestPolytree4() { // #957 @Test void TestPolytree5() { // #973 Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 0, 0, 79530, 0, 79530, 940, 0, 940, 0, 0 })); - subject.add(Clipper.MakePath(new long[] { 0, 33360, 79530, 33360, 79530, 34300, 0, 34300, 0, 33360 })); - subject.add(Clipper.MakePath(new long[] { 78470, 940, 79530, 940, 79530, 33360, 78470, 33360, 78470, 940 })); - subject.add(Clipper.MakePath(new long[] { 0, 940, 940, 940, 940, 33360, 0, 33360, 0, 940 })); - subject.add(Clipper.MakePath(new long[] { 29290, 940, 30350, 940, 30350, 33360, 29290, 33360, 29290, 940 })); + subject.add(Clipper.makePath(new long[] { 0, 0, 79530, 0, 79530, 940, 0, 940, 0, 0 })); + subject.add(Clipper.makePath(new long[] { 0, 33360, 79530, 33360, 79530, 34300, 0, 34300, 0, 33360 })); + subject.add(Clipper.makePath(new long[] { 78470, 940, 79530, 940, 79530, 33360, 78470, 33360, 78470, 940 })); + subject.add(Clipper.makePath(new long[] { 0, 940, 940, 940, 940, 33360, 0, 33360, 0, 940 })); + subject.add(Clipper.makePath(new long[] { 29290, 940, 30350, 940, 30350, 33360, 29290, 33360, 29290, 940 })); PolyTree64 solutionTree = new PolyTree64(); Clipper64 clipper = new Clipper64(); - clipper.AddSubject(subject); - clipper.Execute(ClipType.Union, FillRule.NonZero, solutionTree); + clipper.addSubject(subject); + clipper.execute(ClipType.Union, FillRule.NonZero, solutionTree); assertTrue(solutionTree.getCount() == 1 && solutionTree.get(0).getCount() == 2); } @@ -217,46 +217,46 @@ void TestPolytree5() { // #973 @Test void TestPolytreeUnion() { Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 0, 0, 0, 5, 5, 5, 5, 0 })); - subject.add(Clipper.MakePath(new long[] { 1, 1, 1, 6, 6, 6, 6, 1 })); + subject.add(Clipper.makePath(new long[] { 0, 0, 0, 5, 5, 5, 5, 0 })); + subject.add(Clipper.makePath(new long[] { 1, 1, 1, 6, 6, 6, 6, 1 })); Clipper64 clipper = new Clipper64(); - clipper.AddSubject(subject); + clipper.addSubject(subject); PolyTree64 solution = new PolyTree64(); Paths64 openPaths = new Paths64(); - if (Clipper.IsPositive(subject.get(0))) { - clipper.Execute(ClipType.Union, FillRule.Positive, solution, openPaths); + if (Clipper.isPositive(subject.get(0))) { + clipper.execute(ClipType.Union, FillRule.Positive, solution, openPaths); } else { clipper.setReverseSolution(true); - clipper.Execute(ClipType.Union, FillRule.Negative, solution, openPaths); + clipper.execute(ClipType.Union, FillRule.Negative, solution, openPaths); } assertEquals(0, openPaths.size()); assertEquals(1, solution.getCount()); assertEquals(8, solution.get(0).getPolygon().size()); - assertEquals(Clipper.IsPositive(subject.get(0)), Clipper.IsPositive(solution.get(0).getPolygon())); + assertEquals(Clipper.isPositive(subject.get(0)), Clipper.isPositive(solution.get(0).getPolygon())); } @Test void TestPolytreeUnion2() { // #987 Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 534, 1024, 534, -800, 1026, -800, 1026, 1024 })); - subject.add(Clipper.MakePath(new long[] { 1, 1024, 8721, 1024, 8721, 1920, 1, 1920 })); - subject.add(Clipper.MakePath(new long[] { 30, 1024, 30, -800, 70, -800, 70, 1024 })); - subject.add(Clipper.MakePath(new long[] { 1, 1024, 1, -1024, 3841, -1024, 3841, 1024 })); - subject.add(Clipper.MakePath(new long[] { 3900, -1024, 6145, -1024, 6145, 1024, 3900, 1024 })); - subject.add(Clipper.MakePath(new long[] { 5884, 1024, 5662, 1024, 5662, -1024, 5884, -1024 })); - subject.add(Clipper.MakePath(new long[] { 534, 1024, 200, 1024, 200, -800, 534, -800 })); - subject.add(Clipper.MakePath(new long[] { 200, -800, 200, 1024, 70, 1024, 70, -800 })); - subject.add(Clipper.MakePath(new long[] { 1200, 1920, 1313, 1920, 1313, -800, 1200, -800 })); - subject.add(Clipper.MakePath(new long[] { 6045, -800, 6045, 1024, 5884, 1024, 5884, -800 })); + subject.add(Clipper.makePath(new long[] { 534, 1024, 534, -800, 1026, -800, 1026, 1024 })); + subject.add(Clipper.makePath(new long[] { 1, 1024, 8721, 1024, 8721, 1920, 1, 1920 })); + subject.add(Clipper.makePath(new long[] { 30, 1024, 30, -800, 70, -800, 70, 1024 })); + subject.add(Clipper.makePath(new long[] { 1, 1024, 1, -1024, 3841, -1024, 3841, 1024 })); + subject.add(Clipper.makePath(new long[] { 3900, -1024, 6145, -1024, 6145, 1024, 3900, 1024 })); + subject.add(Clipper.makePath(new long[] { 5884, 1024, 5662, 1024, 5662, -1024, 5884, -1024 })); + subject.add(Clipper.makePath(new long[] { 534, 1024, 200, 1024, 200, -800, 534, -800 })); + subject.add(Clipper.makePath(new long[] { 200, -800, 200, 1024, 70, 1024, 70, -800 })); + subject.add(Clipper.makePath(new long[] { 1200, 1920, 1313, 1920, 1313, -800, 1200, -800 })); + subject.add(Clipper.makePath(new long[] { 6045, -800, 6045, 1024, 5884, 1024, 5884, -800 })); Clipper64 clipper = new Clipper64(); - clipper.AddSubject(subject); + clipper.addSubject(subject); PolyTree64 solution = new PolyTree64(); Paths64 openPaths = new Paths64(); - clipper.Execute(ClipType.Union, FillRule.EvenOdd, solution, openPaths); + clipper.execute(ClipType.Union, FillRule.EvenOdd, solution, openPaths); assertEquals(1, solution.getCount()); assertEquals(1, solution.get(0).getCount()); @@ -265,7 +265,7 @@ void TestPolytreeUnion2() { // #987 @Test void TestPolytreeUnion3() { Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { + subject.add(Clipper.makePath(new long[] { -120927680, 590077597, -120919386, 590077307, -120919432, 590077309, @@ -285,9 +285,9 @@ void TestPolytreeUnion3() { })); Clipper64 clipper = new Clipper64(); - clipper.AddSubject(subject); + clipper.addSubject(subject); PolyTree64 solution = new PolyTree64(); - clipper.Execute(ClipType.Union, FillRule.EvenOdd, solution); + clipper.execute(ClipType.Union, FillRule.EvenOdd, solution); assertTrue(solution.getCount() >= 0); } diff --git a/src/test/java/com/github/micycle1/clipper2/TestRectClip.java b/src/test/java/com/github/micycle1/clipper2/TestRectClip.java index 4f0dd8d..31ec026 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestRectClip.java +++ b/src/test/java/com/github/micycle1/clipper2/TestRectClip.java @@ -22,68 +22,68 @@ void testRectClip() { Paths64 sol; // Solution will be assigned by RectClip Rect64 rect = new Rect64(100, 100, 700, 500); - clp.add(rect.AsPath()); + clp.add(rect.asPath()); // Test case 1: Subject is identical to clip rect - sub.add(Clipper.MakePath(new long[] { 100, 100, 700, 100, 700, 500, 100, 500 })); - sol = Clipper.RectClip(rect, sub); + sub.add(Clipper.makePath(new long[] { 100, 100, 700, 100, 700, 500, 100, 500 })); + sol = Clipper.rectClip(rect, sub); // Use Math.abs because area can be negative depending on orientation - assertEquals(Math.abs(Clipper.Area(sub)), Math.abs(Clipper.Area(sol)), "Test 1 failed"); + assertEquals(Math.abs(Clipper.area(sub)), Math.abs(Clipper.area(sol)), "Test 1 failed"); // Test case 2: Subject partially outside but covers same area within clip rect sub.clear(); - sub.add(Clipper.MakePath(new long[] { 110, 110, 700, 100, 700, 500, 100, 500 })); - sol = Clipper.RectClip(rect, sub); + sub.add(Clipper.makePath(new long[] { 110, 110, 700, 100, 700, 500, 100, 500 })); + sol = Clipper.rectClip(rect, sub); // Area might differ slightly due to clipping precise shape, but conceptually // check against original subject // A better check might involve comparing vertices if area isn't exact? // Or check against the expected clipped shape area if known. // For now, let's keep the original logic's intent, assuming Area reflects the // clipped portion. - assertEquals(Math.abs(Clipper.Area(sub)), Math.abs(Clipper.Area(sol)), "Test 2 failed"); // Might be brittle + assertEquals(Math.abs(Clipper.area(sub)), Math.abs(Clipper.area(sol)), "Test 2 failed"); // Might be brittle // Test case 3: Subject partially outside, clipped area should equal clip rect // area sub.clear(); - sub.add(Clipper.MakePath(new long[] { 90, 90, 700, 100, 700, 500, 100, 500 })); - sol = Clipper.RectClip(rect, sub); - assertEquals(Math.abs(Clipper.Area(clp)), Math.abs(Clipper.Area(sol)), "Test 3 failed"); + sub.add(Clipper.makePath(new long[] { 90, 90, 700, 100, 700, 500, 100, 500 })); + sol = Clipper.rectClip(rect, sub); + assertEquals(Math.abs(Clipper.area(clp)), Math.abs(Clipper.area(sol)), "Test 3 failed"); // Test case 4: Subject fully inside clip rect sub.clear(); - sub.add(Clipper.MakePath(new long[] { 110, 110, 690, 110, 690, 490, 110, 490 })); - sol = Clipper.RectClip(rect, sub); - assertEquals(Math.abs(Clipper.Area(sub)), Math.abs(Clipper.Area(sol)), "Test 4 failed"); + sub.add(Clipper.makePath(new long[] { 110, 110, 690, 110, 690, 490, 110, 490 })); + sol = Clipper.rectClip(rect, sub); + assertEquals(Math.abs(Clipper.area(sub)), Math.abs(Clipper.area(sol)), "Test 4 failed"); // Test case 5: Subject touches edge, should result in empty solution sub.clear(); clp.clear(); // Clear previous clip path rect = new Rect64(390, 290, 410, 310); - // No need to add rect.AsPath() to clp for RectClip, rect object is passed + // No need to add rect.asPath() to clp for RectClip, rect object is passed // directly - sub.add(Clipper.MakePath(new long[] { 410, 290, 500, 290, 500, 310, 410, 310 })); - sol = Clipper.RectClip(rect, sub); + sub.add(Clipper.makePath(new long[] { 410, 290, 500, 290, 500, 310, 410, 310 })); + sol = Clipper.rectClip(rect, sub); assertTrue(sol.isEmpty(), "Test 5 failed - should be empty"); // Test case 6: Triangle outside rect sub.clear(); - sub.add(Clipper.MakePath(new long[] { 430, 290, 470, 330, 390, 330 })); - sol = Clipper.RectClip(rect, sub); + sub.add(Clipper.makePath(new long[] { 430, 290, 470, 330, 390, 330 })); + sol = Clipper.rectClip(rect, sub); assertTrue(sol.isEmpty(), "Test 6 failed - should be empty"); // Test case 7: Triangle outside rect sub.clear(); - sub.add(Clipper.MakePath(new long[] { 450, 290, 480, 330, 450, 330 })); - sol = Clipper.RectClip(rect, sub); + sub.add(Clipper.makePath(new long[] { 450, 290, 480, 330, 450, 330 })); + sol = Clipper.rectClip(rect, sub); assertTrue(sol.isEmpty(), "Test 7 failed - should be empty"); // Test case 8: Complex polygon clipped, check bounds of result sub.clear(); - sub.add(Clipper.MakePath(new long[] { 208, 66, 366, 112, 402, 303, 234, 332, 233, 262, 243, 140, 215, 126, 40, 172 })); + sub.add(Clipper.makePath(new long[] { 208, 66, 366, 112, 402, 303, 234, 332, 233, 262, 243, 140, 215, 126, 40, 172 })); rect = new Rect64(237, 164, 322, 248); - sol = Clipper.RectClip(rect, sub); + sol = Clipper.rectClip(rect, sub); assertFalse(sol.isEmpty(), "Test 8 failed - should not be empty"); // Basic check - Rect64 solBounds = Clipper.GetBounds(sol); + Rect64 solBounds = Clipper.getBounds(sol); // Check if the resulting bounds match the clipping rectangle bounds // Note: The clipped polygon might not *fill* the entire rect, but its bounds // should ideally be constrained *within* or *equal to* the clip rect if it @@ -98,9 +98,9 @@ void testRectClip() { void testRectClip2() { Rect64 rect = new Rect64(54690, 0, 65628, 6000); Paths64 subject = new Paths64(); - subject.add(Clipper.MakePath(new long[] { 700000, 6000, 0, 6000, 0, 5925, 700000, 5925 })); + subject.add(Clipper.makePath(new long[] { 700000, 6000, 0, 6000, 0, 5925, 700000, 5925 })); - Paths64 solution = Clipper.RectClip(rect, subject); + Paths64 solution = Clipper.rectClip(rect, subject); assertNotNull(solution, "TestRectClip2 Solution should not be null"); assertEquals(1, solution.size(), "TestRectClip2 Should have 1 path"); @@ -113,19 +113,19 @@ void testRectClip3() { Paths64 subject = new Paths64(); Paths64 solution; - subject.add(Clipper.MakePath(new long[] { -1800000000L, 10005000L, -1800000000L, -5000L, -1789994999L, -5000L, -1789994999L, 10005000L })); + subject.add(Clipper.makePath(new long[] { -1800000000L, 10005000L, -1800000000L, -5000L, -1789994999L, -5000L, -1789994999L, 10005000L })); - solution = Clipper.RectClip(r, subject); + solution = Clipper.rectClip(r, subject); assertNotNull(solution, "TestRectClip3 Solution should not be null"); assertEquals(1, solution.size(), "TestRectClip3 Should have 1 path"); assertFalse(solution.get(0).isEmpty(), "TestRectClip3 Path should not be empty"); - Path64 expectedPath = Clipper.MakePath(new long[] { -1789994999L, 3355443L, -1800000000L, 3355443L, -1800000000L, -5000L, -1789994999L, -5000L }); - assertEquals(Math.abs(Clipper.Area(expectedPath)), Math.abs(Clipper.Area(solution.get(0))), "TestRectClip3 Area check"); + Path64 expectedPath = Clipper.makePath(new long[] { -1789994999L, 3355443L, -1800000000L, 3355443L, -1800000000L, -5000L, -1789994999L, -5000L }); + assertEquals(Math.abs(Clipper.area(expectedPath)), Math.abs(Clipper.area(solution.get(0))), "TestRectClip3 Area check"); } private static Path64 clipper(Rect64 r, Paths64 subject) { - return Clipper.Intersect(subject, new Paths64(r.AsPath()), FillRule.EvenOdd).get(0); + return Clipper.intersect(subject, new Paths64(r.asPath()), FillRule.EvenOdd).get(0); } } \ No newline at end of file diff --git a/src/test/java/com/github/micycle1/clipper2/TestToStringOutput.java b/src/test/java/com/github/micycle1/clipper2/TestToStringOutput.java index 32adacf..5e172f4 100644 --- a/src/test/java/com/github/micycle1/clipper2/TestToStringOutput.java +++ b/src/test/java/com/github/micycle1/clipper2/TestToStringOutput.java @@ -47,8 +47,8 @@ void pathsDToStringMatchesExistingFormat() { @Test void polyPathBaseToStringMatchesExistingFormat() { PolyTree64 tree = new PolyTree64(); - PolyPathBase polygon = tree.AddChild(new Path64()); - polygon.AddChild(new Path64()); + PolyPathBase polygon = tree.addChild(new Path64()); + polygon.addChild(new Path64()); assertEquals("Polytree with 1 polygon.\n +- polygon (0) contains 1 hole.\n\n", tree.toString()); } }