Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>micycle</groupId>
<artifactId>clipper2</artifactId>
<version>1.2.2</version>
<version>1.2.4</version>
<name>Clipper2</name>
<properties>
<jmh.version>1.36</jmh.version>
Expand Down
80 changes: 36 additions & 44 deletions src/main/java/clipper2/Clipper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import clipper2.offset.ClipperOffset;
import clipper2.offset.EndType;
import clipper2.offset.JoinType;
import clipper2.rectclip.RectClip;
import clipper2.rectclip.RectClipLines;
import clipper2.rectclip.RectClip64;
import clipper2.rectclip.RectClipLines64;

public final class Clipper {

Expand Down Expand Up @@ -226,106 +226,98 @@ public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType,
return ScalePathsD(tmp, 1 / scale);
}

public static Paths64 ExecuteRectClip(Rect64 rect, Paths64 paths) {
return ExecuteRectClip(rect, paths, false);
}

public static Paths64 ExecuteRectClip(Rect64 rect, Paths64 paths, boolean convexOnly) {
if (rect.IsEmpty() || paths.size() == 0) {
public static Paths64 RectClip(Rect64 rect, Paths64 paths) {
if (rect.IsEmpty() || paths.isEmpty()) {
return new Paths64();
}
RectClip rc = new RectClip(rect);
return rc.Execute(paths, convexOnly);
}

public static Paths64 ExecuteRectClip(Rect64 rect, Path64 path) {
return ExecuteRectClip(rect, path, false);
RectClip64 rc = new RectClip64(rect);
return rc.Execute(paths);
}

public static Paths64 ExecuteRectClip(Rect64 rect, Path64 path, boolean convexOnly) {
if (rect.IsEmpty() || path.size() == 0) {
public static Paths64 RectClip(Rect64 rect, Path64 path) {
if (rect.IsEmpty() || path.isEmpty()) {
return new Paths64();
}
Paths64 tmp = new Paths64();
tmp.add(path);
return ExecuteRectClip(rect, tmp, convexOnly);
return RectClip(rect, tmp);
}

public static PathsD ExecuteRectClip(RectD rect, PathsD paths) {
return ExecuteRectClip(rect, paths, 2, false);
public static PathsD RectClip(RectD rect, PathsD paths) {
return RectClip(rect, paths, 2);
}

public static PathsD ExecuteRectClip(RectD rect, PathsD paths, int precision, boolean convexOnly) {
public static PathsD RectClip(RectD rect, PathsD paths, int precision) {
InternalClipper.CheckPrecision(precision);
if (rect.IsEmpty() || paths.size() == 0) {
if (rect.IsEmpty() || paths.isEmpty()) {
return new PathsD();
}
double scale = Math.pow(10, precision);
Rect64 r = ScaleRect(rect, scale);
Paths64 tmpPath = ScalePaths64(paths, scale);
RectClip rc = new RectClip(r);
tmpPath = rc.Execute(tmpPath, convexOnly);
RectClip64 rc = new RectClip64(r);
tmpPath = rc.Execute(tmpPath);
return ScalePathsD(tmpPath, 1 / scale);
}

public static PathsD ExecuteRectClip(RectD rect, PathD path) {
return ExecuteRectClip(rect, path, 2, false);
public static PathsD RectClip(RectD rect, PathD path) {
return RectClip(rect, path, 2);
}

public static PathsD ExecuteRectClip(RectD rect, PathD path, int precision, boolean convexOnly) {
if (rect.IsEmpty() || path.size() == 0) {
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 ExecuteRectClip(rect, tmp, precision, convexOnly);
return RectClip(rect, tmp, precision);
}

public static Paths64 ExecuteRectClipLines(Rect64 rect, Paths64 paths) {
if (rect.IsEmpty() || paths.size() == 0) {
public static Paths64 RectClipLines(Rect64 rect, Paths64 paths) {
if (rect.IsEmpty() || paths.isEmpty()) {
return new Paths64();
}
RectClipLines rc = new RectClipLines(rect);
RectClipLines64 rc = new RectClipLines64(rect);
return rc.Execute(paths);
}

public static Paths64 ExecuteRectClipLines(Rect64 rect, Path64 path) {
if (rect.IsEmpty() || path.size() == 0) {
public static Paths64 RectClipLines(Rect64 rect, Path64 path) {
if (rect.IsEmpty() || path.isEmpty()) {
return new Paths64();
}
Paths64 tmp = new Paths64();
tmp.add(path);
return ExecuteRectClipLines(rect, tmp);
return RectClipLines(rect, tmp);
}

public static PathsD ExecuteRectClipLines(RectD rect, PathsD paths) {
return ExecuteRectClipLines(rect, paths, 2);
public static PathsD RectClipLines(RectD rect, PathsD paths) {
return RectClipLines(rect, paths, 2);
}

public static PathsD ExecuteRectClipLines(RectD rect, PathsD paths, int precision) {
public static PathsD RectClipLines(RectD rect, PathsD paths, int precision) {
InternalClipper.CheckPrecision(precision);
if (rect.IsEmpty() || paths.size() == 0) {
if (rect.IsEmpty() || paths.isEmpty()) {
return new PathsD();
}
double scale = Math.pow(10, precision);
Rect64 r = ScaleRect(rect, scale);
Paths64 tmpPath = ScalePaths64(paths, scale);
RectClipLines rc = new RectClipLines(r);
RectClipLines64 rc = new RectClipLines64(r);
tmpPath = rc.Execute(tmpPath);
return ScalePathsD(tmpPath, 1 / scale);
}

public static PathsD ExecuteRectClipLines(RectD rect, PathD path) {
return ExecuteRectClipLines(rect, path, 2);
public static PathsD RectClipLines(RectD rect, PathD path) {
return RectClipLines(rect, path, 2);
}

public static PathsD ExecuteRectClipLines(RectD rect, PathD path, int precision) {
if (rect.IsEmpty() || path.size() == 0) {
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 ExecuteRectClipLines(rect, tmp, precision);
return RectClipLines(rect, tmp, precision);
}

public static Paths64 MinkowskiSum(Path64 pattern, Path64 path, boolean isClosed) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/clipper2/engine/Clipper64.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ public final boolean Execute(ClipType clipType, FillRule fillRule, PolyTree64 po
return Execute(clipType, fillRule, polytree, new Paths64());
}

@Override
public void AddReuseableData(ReuseableDataContainer64 reuseableData) {
this.AddReuseableData(reuseableData);
}

}
Loading