1313import clipper2 .core .Rect64 ;
1414import clipper2 .core .RectD ;
1515import clipper2 .engine .Clipper64 ;
16- import clipper2 .engine .ClipperBase ;
1716import clipper2 .engine .ClipperD ;
1817import clipper2 .engine .PointInPolygonResult ;
1918import 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 ) {
0 commit comments