Skip to content

Commit dc929e0

Browse files
committed
9d946d7 Removed ConvexOnly parameter from ClipRect function
1 parent 40f2eca commit dc929e0

File tree

2 files changed

+35
-45
lines changed

2 files changed

+35
-45
lines changed

src/main/java/clipper2/Clipper.java

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -226,85 +226,77 @@ public static PathsD InflatePaths(PathsD paths, double delta, JoinType joinType,
226226
return ScalePathsD(tmp, 1 / scale);
227227
}
228228

229-
public static Paths64 ExecuteRectClip(Rect64 rect, Paths64 paths) {
230-
return ExecuteRectClip(rect, paths, false);
231-
}
232-
233-
public static Paths64 ExecuteRectClip(Rect64 rect, Paths64 paths, boolean convexOnly) {
234-
if (rect.IsEmpty() || paths.size() == 0) {
229+
public static Paths64 RectClip(Rect64 rect, Paths64 paths) {
230+
if (rect.IsEmpty() || paths.isEmpty()) {
235231
return new Paths64();
236232
}
237233
RectClip64 rc = new RectClip64(rect);
238-
return rc.Execute(paths, convexOnly);
239-
}
240-
241-
public static Paths64 ExecuteRectClip(Rect64 rect, Path64 path) {
242-
return ExecuteRectClip(rect, path, false);
234+
return rc.Execute(paths);
243235
}
244236

245-
public static Paths64 ExecuteRectClip(Rect64 rect, Path64 path, boolean convexOnly) {
246-
if (rect.IsEmpty() || path.size() == 0) {
237+
public static Paths64 RectClip(Rect64 rect, Path64 path) {
238+
if (rect.IsEmpty() || path.isEmpty()) {
247239
return new Paths64();
248240
}
249241
Paths64 tmp = new Paths64();
250242
tmp.add(path);
251-
return ExecuteRectClip(rect, tmp, convexOnly);
243+
return RectClip(rect, tmp);
252244
}
253245

254-
public static PathsD ExecuteRectClip(RectD rect, PathsD paths) {
255-
return ExecuteRectClip(rect, paths, 2, false);
246+
public static PathsD RectClip(RectD rect, PathsD paths) {
247+
return RectClip(rect, paths, 2);
256248
}
257249

258-
public static PathsD ExecuteRectClip(RectD rect, PathsD paths, int precision, boolean convexOnly) {
250+
public static PathsD RectClip(RectD rect, PathsD paths, int precision) {
259251
InternalClipper.CheckPrecision(precision);
260-
if (rect.IsEmpty() || paths.size() == 0) {
252+
if (rect.IsEmpty() || paths.isEmpty()) {
261253
return new PathsD();
262254
}
263255
double scale = Math.pow(10, precision);
264256
Rect64 r = ScaleRect(rect, scale);
265257
Paths64 tmpPath = ScalePaths64(paths, scale);
266258
RectClip64 rc = new RectClip64(r);
267-
tmpPath = rc.Execute(tmpPath, convexOnly);
259+
tmpPath = rc.Execute(tmpPath);
268260
return ScalePathsD(tmpPath, 1 / scale);
269261
}
270262

271-
public static PathsD ExecuteRectClip(RectD rect, PathD path) {
272-
return ExecuteRectClip(rect, path, 2, false);
263+
public static PathsD RectClip(RectD rect, PathD path) {
264+
return RectClip(rect, path, 2);
273265
}
274266

275-
public static PathsD ExecuteRectClip(RectD rect, PathD path, int precision, boolean convexOnly) {
276-
if (rect.IsEmpty() || path.size() == 0) {
267+
public static PathsD RectClip(RectD rect, PathD path, int precision) {
268+
if (rect.IsEmpty() || path.isEmpty()) {
277269
return new PathsD();
278270
}
279271
PathsD tmp = new PathsD();
280272
tmp.add(path);
281-
return ExecuteRectClip(rect, tmp, precision, convexOnly);
273+
return RectClip(rect, tmp, precision);
282274
}
283275

284-
public static Paths64 ExecuteRectClipLines(Rect64 rect, Paths64 paths) {
285-
if (rect.IsEmpty() || paths.size() == 0) {
276+
public static Paths64 RectClipLines(Rect64 rect, Paths64 paths) {
277+
if (rect.IsEmpty() || paths.isEmpty()) {
286278
return new Paths64();
287279
}
288280
RectClipLines64 rc = new RectClipLines64(rect);
289281
return rc.Execute(paths);
290282
}
291283

292-
public static Paths64 ExecuteRectClipLines(Rect64 rect, Path64 path) {
293-
if (rect.IsEmpty() || path.size() == 0) {
284+
public static Paths64 RectClipLines(Rect64 rect, Path64 path) {
285+
if (rect.IsEmpty() || path.isEmpty()) {
294286
return new Paths64();
295287
}
296288
Paths64 tmp = new Paths64();
297289
tmp.add(path);
298-
return ExecuteRectClipLines(rect, tmp);
290+
return RectClipLines(rect, tmp);
299291
}
300292

301-
public static PathsD ExecuteRectClipLines(RectD rect, PathsD paths) {
302-
return ExecuteRectClipLines(rect, paths, 2);
293+
public static PathsD RectClipLines(RectD rect, PathsD paths) {
294+
return RectClipLines(rect, paths, 2);
303295
}
304296

305-
public static PathsD ExecuteRectClipLines(RectD rect, PathsD paths, int precision) {
297+
public static PathsD RectClipLines(RectD rect, PathsD paths, int precision) {
306298
InternalClipper.CheckPrecision(precision);
307-
if (rect.IsEmpty() || paths.size() == 0) {
299+
if (rect.IsEmpty() || paths.isEmpty()) {
308300
return new PathsD();
309301
}
310302
double scale = Math.pow(10, precision);
@@ -315,17 +307,17 @@ public static PathsD ExecuteRectClipLines(RectD rect, PathsD paths, int precisio
315307
return ScalePathsD(tmpPath, 1 / scale);
316308
}
317309

318-
public static PathsD ExecuteRectClipLines(RectD rect, PathD path) {
319-
return ExecuteRectClipLines(rect, path, 2);
310+
public static PathsD RectClipLines(RectD rect, PathD path) {
311+
return RectClipLines(rect, path, 2);
320312
}
321313

322-
public static PathsD ExecuteRectClipLines(RectD rect, PathD path, int precision) {
323-
if (rect.IsEmpty() || path.size() == 0) {
314+
public static PathsD RectClipLines(RectD rect, PathD path, int precision) {
315+
if (rect.IsEmpty() || path.isEmpty()) {
324316
return new PathsD();
325317
}
326318
PathsD tmp = new PathsD();
327319
tmp.add(path);
328-
return ExecuteRectClipLines(rect, tmp, precision);
320+
return RectClipLines(rect, tmp, precision);
329321
}
330322

331323
public static Paths64 MinkowskiSum(Path64 pattern, Path64 path, boolean isClosed) {

src/main/java/clipper2/rectclip/RectClip64.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ private void ExecuteInternal(Path64 path) {
586586
}
587587
}
588588
} else if (loc.argValue != Location.INSIDE && (loc.argValue != firstCross || startLocs.size() > 2)) {
589-
if (startLocs.size() > 0) {
589+
if (!startLocs.isEmpty()) {
590590
prev.argValue = loc.argValue;
591591
for (Location loc2 : startLocs) {
592592
if (prev.argValue == loc2) {
@@ -603,7 +603,7 @@ private void ExecuteInternal(Path64 path) {
603603
}
604604
}
605605

606-
public Paths64 Execute(Paths64 paths, boolean convexOnly) {
606+
public Paths64 Execute(Paths64 paths) {
607607
Paths64 result = new Paths64();
608608
if (rect.IsEmpty()) {
609609
return result;
@@ -621,11 +621,9 @@ public Paths64 Execute(Paths64 paths, boolean convexOnly) {
621621
continue;
622622
}
623623
ExecuteInternal(path);
624-
if (!convexOnly) {
625-
CheckEdges();
626-
for (int i = 0; i < 4; ++i) {
627-
TidyEdgePair(i, edges[i * 2], edges[i * 2 + 1]);
628-
}
624+
CheckEdges();
625+
for (int i = 0; i < 4; ++i) {
626+
TidyEdgePair(i, edges[i * 2], edges[i * 2 + 1]);
629627
}
630628

631629
for (@Nullable

0 commit comments

Comments
 (0)