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
@@ -108,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);
}
/**
@@ -120,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);
}
/**
@@ -133,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);
}
/**
@@ -144,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);
}
/**
@@ -156,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);
}
/**
@@ -167,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);
}
/**
@@ -179,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);
}
/**
@@ -192,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);
}
/**
@@ -204,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);
}
/**
@@ -216,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);
}
/**
@@ -229,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);
}
/**
@@ -241,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);
}
/**
@@ -254,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);
}
/**
@@ -267,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);
}
/**
@@ -280,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;
}
@@ -304,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);
}
/**
@@ -326,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);
}
/**
@@ -341,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;
}
@@ -362,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);
}
/**
@@ -377,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);
}
/**
@@ -398,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);
}
/**
@@ -415,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;
}
@@ -435,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);
}
/**
@@ -450,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);
}
/**
@@ -504,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);
}
/**
@@ -634,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();
@@ -659,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;
}
@@ -673,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) {
@@ -693,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;
}
@@ -716,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;
}
/**
@@ -735,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());
@@ -747,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());
@@ -763,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));
@@ -779,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());
@@ -809,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());
@@ -831,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) {
@@ -852,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) {
@@ -870,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));
@@ -888,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));
@@ -912,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));
@@ -920,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));
@@ -936,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;
}
@@ -979,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) {
@@ -1005,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) {
@@ -1032,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) {
@@ -1048,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;
}
/**
@@ -1058,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) {
@@ -1076,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;
}
/**
@@ -1085,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++) {
@@ -1094,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++) {
@@ -1109,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++) {
@@ -1118,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;
}
@@ -1133,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);
}
@@ -1152,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;
@@ -1166,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) {
@@ -1186,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) {
@@ -1226,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;
@@ -1238,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;
@@ -1263,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;
@@ -1274,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, ListExecute() 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/clipper2/engine/ClipperBase.java b/src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java
similarity index 94%
rename from src/main/java/clipper2/engine/ClipperBase.java
rename to src/main/java/com/github/micycle1/clipper2/engine/ClipperBase.java
index d1b4f21..9626c82 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,
@@ -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
- 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;
@@ -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.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);
}
@@ -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 {
- 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;
}
@@ -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) {
@@ -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;
@@ -2664,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;
}
@@ -2693,10 +2695,10 @@ 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 area1 = area(prevOp);
double absArea1 = Math.abs(area1);
if (absArea1 < 2) {
@@ -2766,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;
@@ -2781,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;
}
@@ -2835,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);
}
}
@@ -2854,20 +2856,20 @@ 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;
}
private boolean CheckSplitOwner(OutRec outrec, List
* 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.
*
@@ -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);
@@ -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)));
@@ -475,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
@@ -511,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) {
@@ -570,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);
}
@@ -712,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/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 83%
rename from src/main/java/clipper2/offset/Group.java
rename to src/main/java/com/github/micycle1/clipper2/offset/Group.java
index 8e35a9e..a07cd79 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 {
@@ -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/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 94%
rename from src/main/java/clipper2/rectclip/RectClip64.java
rename to src/main/java/com/github/micycle1/clipper2/rectclip/RectClip64.java
index b538492..1e1e076 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
@@ -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.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) {
@@ -518,7 +518,7 @@ private static boolean startLocsAreClockwise(List