Skip to content

Commit 8d03e7f

Browse files
1.0.6 requested changes
1 parent d9db7f9 commit 8d03e7f

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

src/main/java/clipper2/Clipper.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import clipper2.core.Rect64;
1414
import clipper2.core.RectD;
1515
import clipper2.engine.Clipper64;
16-
import clipper2.engine.ClipperBase;
1716
import clipper2.engine.ClipperD;
1817
import clipper2.engine.PointInPolygonResult;
1918
import clipper2.engine.PolyPath64;
@@ -37,7 +36,7 @@ public final class Clipper {
3736
public static final Rect64 MaxInvalidRect64 = new Rect64(Long.MAX_VALUE, Long.MAX_VALUE, Long.MIN_VALUE, Long.MIN_VALUE);
3837

3938
public static final RectD MaxInvalidRectD = new RectD(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
40-
public static final String PRECISION_RANGE_ERROR = "Error: Precision is out of range.";
39+
private static final String PRECISION_RANGE_ERROR = "Error: Precision is out of range.";
4140

4241
public static Paths64 Intersect(Paths64 subject, Paths64 clip, FillRule fillRule) {
4342
return BooleanOp(ClipType.Intersection, subject, clip, fillRule);
@@ -211,7 +210,7 @@ public static Paths64 RectClip(Rect64 rect, Paths64 paths)
211210
Paths64 result = new Paths64(paths.size());
212211
RectClip rc = new RectClip(rect);
213212
for (Path64 path : paths) {
214-
Rect64 pathRec = ClipperBase.GetBounds(path);
213+
Rect64 pathRec = GetBounds(path);
215214
if (!rect.Intersects(pathRec))
216215
continue;
217216
else if (rect.Contains(pathRec))
@@ -257,7 +256,7 @@ public static PathsD RectClip(RectD rect, PathsD paths, int precision)
257256
RectClip rc = new RectClip(r);
258257
PathsD result = new PathsD(paths.size());
259258
for (PathD p : paths) {
260-
RectD pathRec = ClipperBase.GetBounds(p);
259+
RectD pathRec = GetBounds(p);
261260
if (!rect.Intersects(pathRec))
262261
continue;
263262
else if (rect.Contains(pathRec))
@@ -285,7 +284,7 @@ public static Paths64 RectClipLines(Rect64 rect, Paths64 paths)
285284
if (rect.IsEmpty() || paths.size() == 0) return result;
286285
RectClipLines rco = new RectClipLines(rect);
287286
for (Path64 path : paths) {
288-
Rect64 pathRec = ClipperBase.GetBounds(path);
287+
Rect64 pathRec = GetBounds(path);
289288
if (!rect.Intersects(pathRec))
290289
continue;
291290
else if (rect.Contains(pathRec))
@@ -331,7 +330,7 @@ public static PathsD RectClipLines(RectD rect, PathsD paths, int precision)
331330
Rect64 r = ScaleRect(rect, scale);
332331
RectClipLines rco = new RectClipLines(r);
333332
for (PathD p : paths) {
334-
RectD pathRec = ClipperBase.GetBounds(p);
333+
RectD pathRec = GetBounds(p);
335334
if (!rect.Intersects(pathRec))
336335
continue;
337336
else if (rect.Contains(pathRec))
@@ -705,6 +704,18 @@ public static Rect64 GetBounds(Path64 path)
705704
return result.IsEmpty() ? new Rect64() : result;
706705
}
707706

707+
public static RectD GetBounds(PathD path)
708+
{
709+
RectD result = MaxInvalidRectD;
710+
for (PointD pt : path) {
711+
if (pt.x < result.left) result.left = pt.x;
712+
if (pt.x > result.right) result.right = pt.x;
713+
if (pt.y < result.top) result.top = pt.y;
714+
if (pt.y > result.bottom) result.bottom = pt.y;
715+
}
716+
return result.IsEmpty() ? new RectD() : result;
717+
}
718+
708719
public static Rect64 GetBounds(Paths64 paths) {
709720
Rect64 result = MaxInvalidRect64;
710721
for (Path64 path : paths) {

src/main/java/clipper2/engine/ClipperBase.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package clipper2.engine;
22

3-
import static clipper2.Clipper.MaxInvalidRectD;
4-
53
import clipper2.Clipper;
64
import clipper2.Nullable;
75
import clipper2.core.ClipType;
@@ -30,7 +28,7 @@
3028
* calling Execute. And Execute can be called multiple times (ie with different
3129
* ClipTypes & FillRules) without having to reload these paths.
3230
*/
33-
public abstract class ClipperBase {
31+
abstract class ClipperBase {
3432

3533
private ClipType cliptype;
3634
private FillRule fillrule = FillRule.EvenOdd;
@@ -3162,18 +3160,6 @@ private boolean Path1InsidePath2(OutRec or1, OutRec or2) {
31623160
return result == PointInPolygonResult.IsInside;
31633161
}
31643162

3165-
public static RectD GetBounds(PathD path)
3166-
{
3167-
RectD result = MaxInvalidRectD;
3168-
for (PointD pt : path) {
3169-
if (pt.x < result.left) result.left = pt.x;
3170-
if (pt.x > result.right) result.right = pt.x;
3171-
if (pt.y < result.top) result.top = pt.y;
3172-
if (pt.y > result.bottom) result.bottom = pt.y;
3173-
}
3174-
return result.IsEmpty() ? new RectD() : result;
3175-
}
3176-
31773163
public static Rect64 GetBounds(Path64 path) {
31783164
if (path.isEmpty()) {
31793165
return new Rect64();

src/main/java/clipper2/rectclip/RectClip.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package clipper2.rectclip;
22

3+
import static clipper2.Clipper.GetBounds;
4+
35
import clipper2.Clipper;
46
import clipper2.core.InternalClipper;
57
import clipper2.core.Path64;
68
import clipper2.core.Paths64;
79
import clipper2.core.Point64;
810
import clipper2.core.Rect64;
9-
import clipper2.engine.ClipperBase;
1011
import clipper2.engine.PointInPolygonResult;
1112
import tangible.OutObject;
1213
import tangible.RefObject;
@@ -19,8 +20,6 @@ protected enum Location {
1920
left, top, right, bottom, inside
2021
}
2122

22-
;
23-
2423
final protected Rect64 rect_;
2524
final protected Point64 mp_;
2625
final protected Path64 rectPath_;
@@ -393,7 +392,7 @@ public Path64 ExecuteInternal(Path64 path) {
393392
if (firstCross_ == Location.inside) {
394393
if (startingLoc == Location.inside)
395394
return path;
396-
Rect64 tmp_rect = ClipperBase.GetBounds(path);
395+
Rect64 tmp_rect = GetBounds(path);
397396
if (tmp_rect.Contains(rect_) &&
398397
Path1ContainsPath2(path, rectPath_)
399398
!= PointInPolygonResult.IsOutside)
@@ -444,7 +443,7 @@ else if (InternalClipper.CrossProduct(result.get(0), result.get(k - 1), result.g
444443
private Paths64 ExecuteInternal(Paths64 paths) {
445444
Paths64 result = new Paths64(paths.size());
446445
for (Path64 path : paths) {
447-
if (rect_.Intersects(ClipperBase.GetBounds(path)))
446+
if (rect_.Intersects(GetBounds(path)))
448447
result.add(ExecuteInternal(path));
449448
}
450449
return result;

0 commit comments

Comments
 (0)