11package clipper2 ;
22
3- import java .util .ArrayList ;
4- import java .util .Arrays ;
5- import java .util .Collections ;
6- import java .util .List ;
7-
83import clipper2 .core .ClipType ;
94import clipper2 .core .FillRule ;
105import clipper2 .core .InternalClipper ;
3126import clipper2 .rectclip .RectClip ;
3227import clipper2 .rectclip .RectClipLines ;
3328
29+ import java .util .ArrayList ;
30+ import java .util .Arrays ;
31+ import java .util .Collections ;
32+ import java .util .List ;
33+
3434public final class Clipper {
3535
3636 public static final Rect64 InvalidRect64 = new Rect64 (false );
@@ -203,7 +203,9 @@ public static Paths64 InflatePaths(Paths64 paths, double delta, JoinType joinTyp
203203 public static Paths64 InflatePaths (Paths64 paths , double delta , JoinType joinType , EndType endType , double miterLimit ) {
204204 ClipperOffset co = new ClipperOffset (miterLimit );
205205 co .AddPaths (paths , joinType , endType );
206- return co .Execute (delta );
206+ Paths64 solution = new Paths64 ();
207+ co .Execute (delta , solution );
208+ return solution ;
207209 }
208210
209211 public static PathsD InflatePaths (PathsD paths , double delta , JoinType joinType , EndType endType , double miterLimit ) {
@@ -220,40 +222,40 @@ public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType,
220222 Paths64 tmp = ScalePaths64 (paths , scale );
221223 ClipperOffset co = new ClipperOffset (miterLimit );
222224 co .AddPaths (tmp , joinType , endType );
223- tmp = co .Execute (delta * scale );
225+ co .Execute (delta * scale , tmp ); // reuse 'tmp' to receive (scaled) solution
224226 return ScalePathsD (tmp , 1 / scale );
225227 }
226228
227- public static Paths64 RectClip (Rect64 rect , Paths64 paths ) {
228- return RectClip (rect , paths , false );
229+ public static Paths64 ExecuteRectClip (Rect64 rect , Paths64 paths ) {
230+ return ExecuteRectClip (rect , paths , false );
229231 }
230232
231- public static Paths64 RectClip (Rect64 rect , Paths64 paths , boolean convexOnly ) {
233+ public static Paths64 ExecuteRectClip (Rect64 rect , Paths64 paths , boolean convexOnly ) {
232234 if (rect .IsEmpty () || paths .size () == 0 ) {
233235 return new Paths64 ();
234236 }
235237 RectClip rc = new RectClip (rect );
236238 return rc .Execute (paths , convexOnly );
237239 }
238240
239- public static Paths64 RectClip (Rect64 rect , Path64 path ) {
240- return RectClip (rect , path , false );
241+ public static Paths64 ExecuteRectClip (Rect64 rect , Path64 path ) {
242+ return ExecuteRectClip (rect , path , false );
241243 }
242244
243- public static Paths64 RectClip (Rect64 rect , Path64 path , boolean convexOnly ) {
245+ public static Paths64 ExecuteRectClip (Rect64 rect , Path64 path , boolean convexOnly ) {
244246 if (rect .IsEmpty () || path .size () == 0 ) {
245247 return new Paths64 ();
246248 }
247249 Paths64 tmp = new Paths64 ();
248250 tmp .add (path );
249- return RectClip (rect , tmp , convexOnly );
251+ return ExecuteRectClip (rect , tmp , convexOnly );
250252 }
251253
252- public static PathsD RectClip (RectD rect , PathsD paths ) {
253- return RectClip (rect , paths , 2 , false );
254+ public static PathsD ExecuteRectClip (RectD rect , PathsD paths ) {
255+ return ExecuteRectClip (rect , paths , 2 , false );
254256 }
255257
256- public static PathsD RectClip (RectD rect , PathsD paths , int precision , boolean convexOnly ) {
258+ public static PathsD ExecuteRectClip (RectD rect , PathsD paths , int precision , boolean convexOnly ) {
257259 InternalClipper .CheckPrecision (precision );
258260 if (rect .IsEmpty () || paths .size () == 0 ) {
259261 return new PathsD ();
@@ -266,41 +268,41 @@ public static PathsD RectClip(RectD rect, PathsD paths, int precision, boolean c
266268 return ScalePathsD (tmpPath , 1 / scale );
267269 }
268270
269- public static PathsD RectClip (RectD rect , PathD path ) {
270- return RectClip (rect , path , 2 , false );
271+ public static PathsD ExecuteRectClip (RectD rect , PathD path ) {
272+ return ExecuteRectClip (rect , path , 2 , false );
271273 }
272274
273- public static PathsD RectClip (RectD rect , PathD path , int precision , boolean convexOnly ) {
275+ public static PathsD ExecuteRectClip (RectD rect , PathD path , int precision , boolean convexOnly ) {
274276 if (rect .IsEmpty () || path .size () == 0 ) {
275277 return new PathsD ();
276278 }
277279 PathsD tmp = new PathsD ();
278280 tmp .add (path );
279- return RectClip (rect , tmp , precision , convexOnly );
281+ return ExecuteRectClip (rect , tmp , precision , convexOnly );
280282 }
281283
282- public static Paths64 RectClipLines (Rect64 rect , Paths64 paths ) {
284+ public static Paths64 ExecuteRectClipLines (Rect64 rect , Paths64 paths ) {
283285 if (rect .IsEmpty () || paths .size () == 0 ) {
284286 return new Paths64 ();
285287 }
286288 RectClipLines rc = new RectClipLines (rect );
287289 return rc .Execute (paths );
288290 }
289291
290- public static Paths64 RectClipLines (Rect64 rect , Path64 path ) {
292+ public static Paths64 ExecuteRectClipLines (Rect64 rect , Path64 path ) {
291293 if (rect .IsEmpty () || path .size () == 0 ) {
292294 return new Paths64 ();
293295 }
294296 Paths64 tmp = new Paths64 ();
295297 tmp .add (path );
296- return RectClipLines (rect , tmp );
298+ return ExecuteRectClipLines (rect , tmp );
297299 }
298300
299- public static PathsD RectClipLines (RectD rect , PathsD paths ) {
300- return RectClipLines (rect , paths , 2 );
301+ public static PathsD ExecuteRectClipLines (RectD rect , PathsD paths ) {
302+ return ExecuteRectClipLines (rect , paths , 2 );
301303 }
302304
303- public static PathsD RectClipLines (RectD rect , PathsD paths , int precision ) {
305+ public static PathsD ExecuteRectClipLines (RectD rect , PathsD paths , int precision ) {
304306 InternalClipper .CheckPrecision (precision );
305307 if (rect .IsEmpty () || paths .size () == 0 ) {
306308 return new PathsD ();
@@ -313,17 +315,17 @@ public static PathsD RectClipLines(RectD rect, PathsD paths, int precision) {
313315 return ScalePathsD (tmpPath , 1 / scale );
314316 }
315317
316- public static PathsD RectClipLines (RectD rect , PathD path ) {
317- return RectClipLines (rect , path , 2 );
318+ public static PathsD ExecuteRectClipLines (RectD rect , PathD path ) {
319+ return ExecuteRectClipLines (rect , path , 2 );
318320 }
319321
320- public static PathsD RectClipLines (RectD rect , PathD path , int precision ) {
322+ public static PathsD ExecuteRectClipLines (RectD rect , PathD path , int precision ) {
321323 if (rect .IsEmpty () || path .size () == 0 ) {
322324 return new PathsD ();
323325 }
324326 PathsD tmp = new PathsD ();
325327 tmp .add (path );
326- return RectClipLines (rect , tmp , precision );
328+ return ExecuteRectClipLines (rect , tmp , precision );
327329 }
328330
329331 public static Paths64 MinkowskiSum (Path64 pattern , Path64 path , boolean isClosed ) {
0 commit comments