diff --git a/pom.xml b/pom.xml index c058cfb..effb356 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 micycle clipper2 - 1.2.0 + 1.2.2 Clipper2 1.36 diff --git a/src/main/java/clipper2/Clipper.java b/src/main/java/clipper2/Clipper.java index 2604d76..45302ca 100644 --- a/src/main/java/clipper2/Clipper.java +++ b/src/main/java/clipper2/Clipper.java @@ -1,5 +1,10 @@ package clipper2; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import clipper2.core.ClipType; import clipper2.core.FillRule; import clipper2.core.InternalClipper; @@ -26,11 +31,6 @@ import clipper2.rectclip.RectClip; import clipper2.rectclip.RectClipLines; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - public final class Clipper { public static final Rect64 InvalidRect64 = new Rect64(false); @@ -887,20 +887,20 @@ public static double PerpendicDistFromLineSqrd(Point64 pt, Point64 line1, Point6 public static void RDP(Path64 path, int begin, int end, double epsSqrd, List flags) { int idx = 0; - double max_d = 0; + double maxD = 0; while (end > begin && path.get(begin).equals(path.get(end))) { flags.set(end--, false); } for (int i = begin + 1; i < end; ++i) { // PerpendicDistFromLineSqrd - avoids expensive Sqrt() double d = PerpendicDistFromLineSqrd(path.get(i), path.get(begin), path.get(end)); - if (d <= max_d) { + if (d <= maxD) { continue; } - max_d = d; + maxD = d; idx = i; } - if (max_d <= epsSqrd) { + if (maxD <= epsSqrd) { return; } flags.set(idx, true); @@ -976,20 +976,20 @@ public static Paths64 RamerDouglasPeucker(Paths64 paths, double epsilon) { public static void RDP(PathD path, int begin, int end, double epsSqrd, List flags) { int idx = 0; - double max_d = 0; + double maxD = 0; while (end > begin && path.get(begin).equals(path.get(end))) { flags.set(end--, false); } for (int i = begin + 1; i < end; ++i) { // PerpendicDistFromLineSqrd - avoids expensive Sqrt() double d = PerpendicDistFromLineSqrd(path.get(i), path.get(begin), path.get(end)); - if (d <= max_d) { + if (d <= maxD) { continue; } - max_d = d; + maxD = d; idx = i; } - if (max_d <= epsSqrd) { + if (maxD <= epsSqrd) { return; } flags.set(idx, true); diff --git a/src/main/java/clipper2/engine/ClipperBase.java b/src/main/java/clipper2/engine/ClipperBase.java index 2f8fc3e..d57e33f 100644 --- a/src/main/java/clipper2/engine/ClipperBase.java +++ b/src/main/java/clipper2/engine/ClipperBase.java @@ -1,5 +1,12 @@ package clipper2.engine; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.NavigableSet; +import java.util.TreeSet; + import clipper2.Clipper; import clipper2.Nullable; import clipper2.core.ClipType; @@ -14,13 +21,6 @@ import tangible.OutObject; import tangible.RefObject; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.NavigableSet; -import java.util.TreeSet; - /** * Subject and Clip paths are passed to a Clipper object via AddSubject, * AddOpenSubject and AddClip methods. Clipping operations are then initiated by @@ -39,7 +39,7 @@ abstract class ClipperBase { private List outrecList; private NavigableSet scanlineSet; private List horzSegList; - private List _horzJoinList; + private List horzJoinList; private int currentLocMin; private long currentBotY; private boolean isSortedMinimaList; @@ -89,7 +89,7 @@ public int compare(@Nullable HorzSegment hs1, @Nullable HorzSegment hs2) { } private static class HorzSegment { - + public @Nullable OutPt leftOp; public @Nullable OutPt rightOp; public boolean leftToRight; @@ -102,7 +102,7 @@ public HorzSegment(OutPt op) { } private static class HorzJoin { - + public @Nullable OutPt op1; public @Nullable OutPt op2; @@ -236,7 +236,7 @@ protected ClipperBase() { outrecList = new ArrayList<>(); scanlineSet = new TreeSet<>(); horzSegList = new ArrayList<>(); - _horzJoinList = new ArrayList<>(); + horzJoinList = new ArrayList<>(); setPreserveCollinear(true); } @@ -458,7 +458,7 @@ private static void SwapOutrecs(Active ae1, Active ae2) { } private static void SetOwner(OutRec outrec, OutRec newOwner) { - // precondition1: new_owner is never null + // precondition1: newOwner is never null while (newOwner.owner != null && newOwner.owner.pts == null) { newOwner.owner = newOwner.owner.owner; } @@ -533,7 +533,7 @@ protected final void ClearSolutionOnly() { DisposeIntersectNodes(); outrecList.clear(); horzSegList.clear(); - _horzJoinList.clear(); + horzJoinList.clear(); } public final void Clear() { @@ -1954,11 +1954,11 @@ private void DoHorizontal(Active horz) long Y = horz.bot.y; @Nullable - Vertex vertex_max = horzIsOpen ? GetCurrYMaximaVertex_Open(horz) : GetCurrYMaximaVertex(horz); + Vertex vertexMax = horzIsOpen ? GetCurrYMaximaVertex_Open(horz) : GetCurrYMaximaVertex(horz); // remove 180 deg.spikes and also simplify // consecutive horizontals when PreserveCollinear = true - if (vertex_max != null && !horzIsOpen && vertex_max != horz.vertexTop) { + if (vertexMax != null && !horzIsOpen && vertexMax != horz.vertexTop) { TrimHorz(horz, getPreserveCollinear()); } @@ -1966,7 +1966,7 @@ private void DoHorizontal(Active horz) OutObject tempOutleftX = new OutObject<>(); long rightX; OutObject tempOutrightX = new OutObject<>(); - boolean isLeftToRight = ResetHorzDirection(horz, vertex_max, tempOutleftX, tempOutrightX); + boolean isLeftToRight = ResetHorzDirection(horz, vertexMax, tempOutleftX, tempOutrightX); rightX = tempOutrightX.argValue; leftX = tempOutleftX.argValue; @@ -1983,14 +1983,14 @@ private void DoHorizontal(Active horz) Active ae = isLeftToRight ? horz.nextInAEL : horz.prevInAEL; while (ae != null) { - if (ae.vertexTop == vertex_max) { + if (ae.vertexTop == vertexMax) { // do this first!! if (IsHotEdge(horz) && IsJoined(ae)) { Split(ae, ae.top); } if (IsHotEdge(horz)) { - while (horz.vertexTop != vertex_max) { + while (horz.vertexTop != vertexMax) { AddOutPt(horz, horz.top); UpdateEdgeIntoAEL(horz); } @@ -2007,7 +2007,7 @@ private void DoHorizontal(Active horz) // if horzEdge is a maxima, keep going until we reach // its maxima pair, otherwise check for break conditions - if (vertex_max != horz.vertexTop || IsOpenEnd(horz)) { + if (vertexMax != horz.vertexTop || IsOpenEnd(horz)) { // otherwise stop when 'ae' is beyond the end of the horizontal line if ((isLeftToRight && ae.curX > rightX) || (!isLeftToRight && ae.curX < leftX)) { break; @@ -2086,7 +2086,7 @@ else if ((isLeftToRight && (TopX(ae, pt.y) >= pt.x)) || (!isLeftToRight && (TopX OutObject tempOutleftX2 = new OutObject<>(); OutObject tempOutrightX2 = new OutObject<>(); - isLeftToRight = ResetHorzDirection(horz, vertex_max, tempOutleftX2, tempOutrightX2); + isLeftToRight = ResetHorzDirection(horz, vertexMax, tempOutleftX2, tempOutrightX2); rightX = tempOutrightX2.argValue; leftX = tempOutleftX2.argValue; @@ -2300,21 +2300,21 @@ private static boolean UpdateHorzSegment(HorzSegment hs) { OutPt op = hs.leftOp; OutRec outrec = GetRealOutRec(op.outrec); boolean outrecHasEdges = outrec.frontEdge != null; - long curr_y = op.pt.y; + long currY = op.pt.y; OutPt opP = op, opN = op; if (outrecHasEdges) { OutPt opA = outrec.pts, opZ = opA.next; - while (opP != opZ && opP.prev.pt.y == curr_y) { + while (opP != opZ && opP.prev.pt.y == currY) { opP = opP.prev; } - while (opN != opA && opN.next.pt.y == curr_y) { + while (opN != opA && opN.next.pt.y == currY) { opN = opN.next; } } else { - while (opP.prev != opN && opP.prev.pt.y == curr_y) { + while (opP.prev != opN && opP.prev.pt.y == currY) { opP = opP.prev; } - while (opN.next != opP && opN.next.pt.y == curr_y) { + while (opN.next != opP && opN.next.pt.y == currY) { opN = opN.next; } } @@ -2328,9 +2328,9 @@ private static boolean UpdateHorzSegment(HorzSegment hs) { return result; } - private static OutPt DuplicateOp(OutPt op, boolean insert_after) { + private static OutPt DuplicateOp(OutPt op, boolean insertAfter) { OutPt result = new OutPt(op.pt, op.outrec); - if (insert_after) { + if (insertAfter) { result.next = op.next; result.next.prev = result; result.prev = op; @@ -2367,25 +2367,25 @@ private void ConvertHorzSegsToJoins() { if (hs2.leftToRight == hs1.leftToRight || (hs2.rightOp.pt.x <= hs1.leftOp.pt.x)) { continue; } - long curr_y = hs1.leftOp.pt.y; + long currY = hs1.leftOp.pt.y; if ((hs1).leftToRight) { - while (hs1.leftOp.next.pt.y == curr_y && hs1.leftOp.next.pt.x <= hs2.leftOp.pt.x) { + while (hs1.leftOp.next.pt.y == currY && hs1.leftOp.next.pt.x <= hs2.leftOp.pt.x) { hs1.leftOp = hs1.leftOp.next; } - while (hs2.leftOp.prev.pt.y == curr_y && hs2.leftOp.prev.pt.x <= hs1.leftOp.pt.x) { + while (hs2.leftOp.prev.pt.y == currY && hs2.leftOp.prev.pt.x <= hs1.leftOp.pt.x) { (hs2).leftOp = (hs2).leftOp.prev; } HorzJoin join = new HorzJoin(DuplicateOp((hs1).leftOp, true), DuplicateOp((hs2).leftOp, false)); - _horzJoinList.add(join); + horzJoinList.add(join); } else { - while (hs1.leftOp.prev.pt.y == curr_y && hs1.leftOp.prev.pt.x <= hs2.leftOp.pt.x) { + while (hs1.leftOp.prev.pt.y == currY && hs1.leftOp.prev.pt.x <= hs2.leftOp.pt.x) { hs1.leftOp = hs1.leftOp.prev; } - while (hs2.leftOp.next.pt.y == curr_y && hs2.leftOp.next.pt.x <= (hs1).leftOp.pt.x) { + while (hs2.leftOp.next.pt.y == currY && hs2.leftOp.next.pt.x <= (hs1).leftOp.pt.x) { hs2.leftOp = (hs2).leftOp.next; } HorzJoin join = new HorzJoin(DuplicateOp((hs2).leftOp, true), DuplicateOp((hs1).leftOp, false)); - _horzJoinList.add(join); + horzJoinList.add(join); } } } @@ -2496,19 +2496,19 @@ private static PointInPolygonResult PointInOpPolygon(Point64 pt, OutPt op) { private static boolean Path1InsidePath2(OutPt op1, OutPt op2) { // we need to make some accommodation for rounding errors // so we won't jump if the first vertex is found outside - int outside_cnt = 0; + int outsideCnt = 0; OutPt op = op1; do { PointInPolygonResult result = PointInOpPolygon(op.pt, op2); if (result == PointInPolygonResult.IsOutside) { - ++outside_cnt; + ++outsideCnt; } else if (result == PointInPolygonResult.IsInside) { - --outside_cnt; + --outsideCnt; } op = op.next; - } while (op != op1 && Math.abs(outside_cnt) < 2); - if (Math.abs(outside_cnt) > 1) { - return (outside_cnt < 0); + } while (op != op1 && Math.abs(outsideCnt) < 2); + if (Math.abs(outsideCnt) > 1) { + return (outsideCnt < 0); } // since path1's location is still equivocal, check its midpoint Point64 mp = GetBounds(op).MidPoint(); @@ -2516,7 +2516,7 @@ private static boolean Path1InsidePath2(OutPt op1, OutPt op2) { } private void ProcessHorzJoins() { - for (HorzJoin j : _horzJoinList) { + for (HorzJoin j : horzJoinList) { OutRec or1 = GetRealOutRec(j.op1.outrec); OutRec or2 = GetRealOutRec(j.op2.outrec); @@ -2749,7 +2749,7 @@ protected final boolean BuildPaths(Paths64 solutionClosed, Paths64 solutionOpen) solutionOpen.clear(); int i = 0; - // _outrecList.Count is not static here because + // outrecList.Count is not static here because // CleanCollinear can indirectly add additional OutRec while (i < outrecList.size()) { OutRec outrec = outrecList.get(i++); @@ -2870,7 +2870,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) { solutionOpen.clear(); int i = 0; - // _outrecList.Count is not static here because + // outrecList.Count is not static here because // CheckBounds below can indirectly add additional // OutRec (via FixOutRecPts & CleanCollinear) while (i < outrecList.size()) { @@ -2880,9 +2880,9 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) { } if (outrec.isOpen) { - Path64 open_path = new Path64(); - if (BuildPath(outrec.pts, getReverseSolution(), true, open_path)) { - solutionOpen.add(open_path); + Path64 openPath = new Path64(); + if (BuildPath(outrec.pts, getReverseSolution(), true, openPath)) { + solutionOpen.add(openPath); } continue; } diff --git a/src/main/java/clipper2/offset/ClipperOffset.java b/src/main/java/clipper2/offset/ClipperOffset.java index 5309d85..8618dc8 100644 --- a/src/main/java/clipper2/offset/ClipperOffset.java +++ b/src/main/java/clipper2/offset/ClipperOffset.java @@ -2,6 +2,10 @@ import static clipper2.core.InternalClipper.DEFAULT_ARC_TOLERANCE; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import clipper2.Clipper; import clipper2.core.ClipType; import clipper2.core.FillRule; @@ -17,10 +21,6 @@ import tangible.OutObject; import tangible.RefObject; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * Geometric offsetting refers to the process of creating parallel curves that * are offset a specified distance from their primary curves. @@ -41,12 +41,12 @@ */ public class ClipperOffset { - private final List _groupList = new ArrayList<>(); + private final List groupList = new ArrayList<>(); private final PathD normals = new PathD(); private final Paths64 solution = new Paths64(); - private double group_delta; // *0.5 for open paths; *-1.0 for negative areas + private double groupDelta; // *0.5 for open paths; *-1.0 for negative areas private double delta; - private double abs_group_delta; + private double absGroupDelta; private double mitLimSqr; private double stepsPerRad; private double stepSin; @@ -93,13 +93,13 @@ public ClipperOffset() { * Creates a ClipperOffset object, using the supplied parameters. * * @param miterLimit This property sets the maximum distance in multiples - * of group_delta that vertices can be offset from + * of groupDelta that vertices can be offset from * their original positions before squaring is applied. * (Squaring truncates a miter by 'cutting it off' at 1 - * × group_delta distance from the original vertex.) + * × groupDelta distance from the original vertex.) *

* The default value for miterLimit is 2 - * (i.e. twice group_delta). This is also the smallest + * (i.e. twice groupDelta). This is also the smallest * MiterLimit that's allowed. If mitering was * unrestricted (ie without any squaring), then offsets * at very acute angles would generate unacceptably @@ -110,8 +110,8 @@ public ClipperOffset() { * during offsetting. *

* It's important to make arcTolerance a sensible - * fraction of the offset group_delta (arc radius). - * Large tolerances relative to the offset group_delta + * fraction of the offset groupDelta (arc radius). + * Large tolerances relative to the offset groupDelta * will produce poor arc approximations but, just as * importantly, very small tolerances will slow * offsetting performance without noticeably improving @@ -145,7 +145,7 @@ public ClipperOffset(double miterLimit, double arcTolerance, boolean preserveCol } public final void Clear() { - _groupList.clear(); + groupList.clear(); } public final void AddPath(Path64 path, JoinType joinType, EndType endType) { @@ -162,17 +162,17 @@ public final void AddPaths(Paths64 paths, JoinType joinType, EndType endType) { if (cnt == 0) { return; } - _groupList.add(new Group(paths, joinType, endType)); + groupList.add(new Group(paths, joinType, endType)); } private void ExecuteInternal(double delta) { solution.clear(); - if (_groupList.isEmpty()) { + if (groupList.isEmpty()) { return; } if (Math.abs(delta) < 0.5) { - for (Group group : _groupList) { + for (Group group : groupList) { for (Path64 path : group.inPaths) { solution.add(path); } @@ -181,7 +181,7 @@ private void ExecuteInternal(double delta) { this.delta = delta; this.mitLimSqr = (getMiterLimit() <= 1 ? 2.0 : 2.0 / Clipper.Sqr(getMiterLimit())); - for (Group group : _groupList) { + for (Group group : groupList) { DoGroupOffset(group); } } @@ -194,9 +194,9 @@ public final void Execute(double delta, Paths64 solution) { // clean up self-intersections ... Clipper64 c = new Clipper64(); c.setPreserveCollinear(getPreserveCollinear()); - c.setReverseSolution(getReverseSolution() != _groupList.get(0).pathsReversed); + c.setReverseSolution(getReverseSolution() != groupList.get(0).pathsReversed); c.AddSubject(solution); - if (_groupList.get(0).pathsReversed) { + if (groupList.get(0).pathsReversed) { c.Execute(ClipType.Union, FillRule.Negative, solution); } else { c.Execute(ClipType.Union, FillRule.Positive, solution); @@ -211,9 +211,9 @@ public void Execute(double delta, PolyTree64 polytree) { Clipper64 c = new Clipper64(); c.setPreserveCollinear(getPreserveCollinear()); // the solution should retain the orientation of the input - c.setReverseSolution(getReverseSolution() != _groupList.get(0).pathsReversed); + c.setReverseSolution(getReverseSolution() != groupList.get(0).pathsReversed); c.AddSubject(solution); - if (_groupList.get(0).pathsReversed) { + if (groupList.get(0).pathsReversed) { c.Execute(ClipType.Union, FillRule.Negative, polytree); } else { c.Execute(ClipType.Union, FillRule.Positive, polytree); @@ -360,11 +360,11 @@ private static PointD IntersectPoint(PointD pt1a, PointD pt1b, PointD pt2a, Poin } private Point64 GetPerpendic(Point64 pt, PointD norm) { - return new Point64(pt.x + norm.x * group_delta, pt.y + norm.y * group_delta); + return new Point64(pt.x + norm.x * groupDelta, pt.y + norm.y * groupDelta); } private PointD GetPerpendicD(Point64 pt, PointD norm) { - return new PointD(pt.x + norm.x * group_delta, pt.y + norm.y * group_delta); + return new PointD(pt.x + norm.x * groupDelta, pt.y + norm.y * groupDelta); } private void DoSquare(Group group, Path64 path, int j, int k) { @@ -377,16 +377,16 @@ private void DoSquare(Group group, Path64 path, int j, int k) { // now offset the original vertex delta units along unit vector PointD ptQ = new PointD(path.get(j)); - ptQ = TranslatePoint(ptQ, abs_group_delta * vec.x, abs_group_delta * vec.y); + ptQ = TranslatePoint(ptQ, absGroupDelta * vec.x, absGroupDelta * vec.y); // get perpendicular vertices - PointD pt1 = TranslatePoint(ptQ, group_delta * vec.y, group_delta * -vec.x); - PointD pt2 = TranslatePoint(ptQ, group_delta * -vec.y, group_delta * vec.x); + PointD pt1 = TranslatePoint(ptQ, groupDelta * vec.y, groupDelta * -vec.x); + PointD pt2 = TranslatePoint(ptQ, groupDelta * -vec.y, groupDelta * vec.x); // get 2 vertices along one edge offset PointD pt3 = GetPerpendicD(path.get(k), normals.get(k)); if (j == k) { - PointD pt4 = new PointD(pt3.x + vec.x * group_delta, pt3.y + vec.y * group_delta); + PointD pt4 = new PointD(pt3.x + vec.x * groupDelta, pt3.y + vec.y * groupDelta); PointD pt = IntersectPoint(pt1, pt2, pt3, pt4); // get the second intersect point through reflecion group.outPath.add(new Point64(ReflectPoint(pt, ptQ))); @@ -401,14 +401,14 @@ private void DoSquare(Group group, Path64 path, int j, int k) { } private void DoMiter(Group group, Path64 path, int j, int k, double cosA) { - double q = group_delta / (cosA + 1); + double q = groupDelta / (cosA + 1); group.outPath.add(new Point64(path.get(j).x + (normals.get(k).x + normals.get(j).x) * q, path.get(j).y + (normals.get(k).y + normals.get(j).y) * q)); } private void DoRound(Group group, Path64 path, int j, int k, double angle) { Point64 pt = path.get(j); - PointD offsetVec = new PointD(normals.get(k).x * group_delta, normals.get(k).y * group_delta); + PointD offsetVec = new PointD(normals.get(k).x * groupDelta, normals.get(k).y * groupDelta); if (j == k) { offsetVec.Negate(); } @@ -418,10 +418,7 @@ private void DoRound(Group group, Path64 path, int j, int k, double angle) { int steps = (int) Math.ceil(stepsPerRad * Math.abs(angle)); for (int i = 1; i < steps; i++) // ie 1 less than steps { - offsetVec = new PointD( - offsetVec.x * stepCos - stepSin * offsetVec.y, - offsetVec.x * stepSin + offsetVec.y * stepCos - ); + offsetVec = new PointD(offsetVec.x * stepCos - stepSin * offsetVec.y, offsetVec.x * stepSin + offsetVec.y * stepCos); group.outPath.add(new Point64(pt.x + offsetVec.x, pt.y + offsetVec.y)); } } @@ -455,9 +452,10 @@ private void OffsetPoint(Group group, Path64 path, int j, RefObject k) if (cosA > 0.99) // almost straight - less than 8 degrees { group.outPath.add(GetPerpendic(path.get(j), normals.get(k.argValue))); - if (cosA < 0.9998) // greater than 1 degree (#424) + if (cosA < 0.9998) { // greater than 1 degree (#424) group.outPath.add(GetPerpendic(path.get(j), normals.get(j))); // (#418) - } else if (cosA > -0.99 && (sinA * group_delta < 0)) // is concave + } + } else if (cosA > -0.99 && (sinA * groupDelta < 0)) // is concave { group.outPath.add(GetPerpendic(path.get(j), normals.get(k.argValue))); // this extra point is the only (simple) way to ensure that @@ -508,10 +506,8 @@ private void OffsetOpenPath(Group group, Path64 path) { // do the line start cap switch (this.endType) { case Butt : - group.outPath.add(new Point64( - path.get(0).x - normals.get(0).x * group_delta, - path.get(0).y - normals.get(0).y * group_delta - )); + group.outPath + .add(new Point64(path.get(0).x - normals.get(0).x * groupDelta, path.get(0).y - normals.get(0).y * groupDelta)); group.outPath.add(GetPerpendic(path.get(0), normals.get(0))); break; case Round : @@ -537,8 +533,8 @@ private void OffsetOpenPath(Group group, Path64 path) { // do the line end cap switch (this.endType) { case Butt : - group.outPath.add(new Point64(path.get(highI).x - normals.get(highI).x * group_delta, - path.get(highI).y - normals.get(highI).y * group_delta)); + group.outPath.add(new Point64(path.get(highI).x - normals.get(highI).x * groupDelta, + path.get(highI).y - normals.get(highI).y * groupDelta)); group.outPath.add(GetPerpendic(path.get(highI), normals.get(highI))); break; case Round : @@ -569,18 +565,18 @@ private void DoGroupOffset(Group group) { return; } double area = Clipper.Area(group.inPaths.get(lowestIdx.argValue)); - //if (area == 0) return; // this is probably unhelpful (#430) + // if (area == 0) return; // this is probably unhelpful (#430) group.pathsReversed = (area < 0); if (group.pathsReversed) { - this.group_delta = -this.delta; + this.groupDelta = -this.delta; } else { - this.group_delta = this.delta; + this.groupDelta = this.delta; } } else { group.pathsReversed = false; - this.group_delta = Math.abs(this.delta) * 0.5; + this.groupDelta = Math.abs(this.delta) * 0.5; } - this.abs_group_delta = Math.abs(this.group_delta); + this.absGroupDelta = Math.abs(this.groupDelta); this.joinType = group.joinType; this.endType = group.endType; @@ -590,11 +586,13 @@ private void DoGroupOffset(Group group) { // curve imprecision that's allowed is based on the size of the // offset (delta). Obviously very large offsets will almost always // require much less precision. See also offset_triginometry2.svg - double arcTol = arcTolerance > 0.01 ? arcTolerance : Math.log10(2 + this.abs_group_delta) * DEFAULT_ARC_TOLERANCE; - double stepsPer360 = Math.PI / Math.acos(1 - arcTol / abs_group_delta); + double arcTol = arcTolerance > 0.01 ? arcTolerance : Math.log10(2 + this.absGroupDelta) * DEFAULT_ARC_TOLERANCE; + double stepsPer360 = Math.PI / Math.acos(1 - arcTol / absGroupDelta); stepSin = Math.sin((2 * Math.PI) / stepsPer360); stepCos = Math.cos((2 * Math.PI) / stepsPer360); - if (group_delta < 0.0) stepSin = -stepSin; + if (groupDelta < 0.0) { + stepSin = -stepSin; + } stepsPerRad = stepsPer360 / (2 * Math.PI); } @@ -611,10 +609,10 @@ private void DoGroupOffset(Group group) { group.outPath = new Path64(); // single vertex so build a circle or square ... if (group.endType == EndType.Round) { - double r = this.abs_group_delta; + double r = this.absGroupDelta; group.outPath = Clipper.Ellipse(path.get(0), r, r); } else { - int d = (int) Math.ceil(this.group_delta); + int d = (int) Math.ceil(this.groupDelta); Rect64 r = new Rect64(path.get(0).x - d, path.get(0).y - d, path.get(0).x - d, path.get(0).y - d); group.outPath = r.AsPath(); } diff --git a/src/main/java/clipper2/rectclip/RectClip.java b/src/main/java/clipper2/rectclip/RectClip.java index 2e6e160..1b3d7b1 100644 --- a/src/main/java/clipper2/rectclip/RectClip.java +++ b/src/main/java/clipper2/rectclip/RectClip.java @@ -1,5 +1,8 @@ package clipper2.rectclip; +import java.util.ArrayList; +import java.util.List; + import clipper2.Clipper; import clipper2.Nullable; import clipper2.core.InternalClipper; @@ -11,16 +14,13 @@ import tangible.OutObject; import tangible.RefObject; -import java.util.ArrayList; -import java.util.List; - /** - * ExecuteRectClipLines intersects subject polygons with the specified rectangular clipping + * RectClip intersects subject polygons with the specified rectangular clipping * region. Polygons may be simple or complex (self-intersecting). *

* This function is extremely fast when compared to the Library's general * purpose Intersect clipper. Where Intersect has roughly O(n³) performance, - * ExecuteRectClipLines has O(n) performance. + * RectClip has O(n) performance. * * @since 1.0.6 */ @@ -31,7 +31,7 @@ protected static class OutPt2 { OutPt2 next; @Nullable OutPt2 prev; - + Point64 pt; int ownerIdx; @Nullable @@ -775,9 +775,9 @@ private void TidyEdgePair(int idx, List<@Nullable OutPt2> cw, List<@Nullable Out } if (!isRejoining) { - int new_idx = results.size(); + int newIdx = results.size(); results.add(p1a); - SetNewOwner(p1a, new_idx); + SetNewOwner(p1a, newIdx); } if (cwIsTowardLarger) { diff --git a/src/main/java/clipper2/rectclip/RectClipLines.java b/src/main/java/clipper2/rectclip/RectClipLines.java index 21c3a09..a8040bd 100644 --- a/src/main/java/clipper2/rectclip/RectClipLines.java +++ b/src/main/java/clipper2/rectclip/RectClipLines.java @@ -9,12 +9,12 @@ import tangible.RefObject; /** - * ExecuteRectClipLines intersects subject open paths (polylines) with the specified + * RectClipLines intersects subject open paths (polylines) with the specified * rectangular clipping region. *

* This function is extremely fast when compared to the Library's general * purpose Intersect clipper. Where Intersect has roughly O(n³) performance, - * ExecuteRectClipLines has O(n) performance. + * RectClipLines has O(n) performance. * * @since 1.0.6 */