Skip to content

Commit 40f2eca

Browse files
committed
6d69b97 rename rectclip... to rectclip...64. fix minor offsetting bugs
1 parent 7404d2a commit 40f2eca

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

src/main/java/clipper2/Clipper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import clipper2.offset.ClipperOffset;
2929
import clipper2.offset.EndType;
3030
import clipper2.offset.JoinType;
31-
import clipper2.rectclip.RectClip;
32-
import clipper2.rectclip.RectClipLines;
31+
import clipper2.rectclip.RectClip64;
32+
import clipper2.rectclip.RectClipLines64;
3333

3434
public final class Clipper {
3535

@@ -234,7 +234,7 @@ public static Paths64 ExecuteRectClip(Rect64 rect, Paths64 paths, boolean convex
234234
if (rect.IsEmpty() || paths.size() == 0) {
235235
return new Paths64();
236236
}
237-
RectClip rc = new RectClip(rect);
237+
RectClip64 rc = new RectClip64(rect);
238238
return rc.Execute(paths, convexOnly);
239239
}
240240

@@ -263,7 +263,7 @@ public static PathsD ExecuteRectClip(RectD rect, PathsD paths, int precision, bo
263263
double scale = Math.pow(10, precision);
264264
Rect64 r = ScaleRect(rect, scale);
265265
Paths64 tmpPath = ScalePaths64(paths, scale);
266-
RectClip rc = new RectClip(r);
266+
RectClip64 rc = new RectClip64(r);
267267
tmpPath = rc.Execute(tmpPath, convexOnly);
268268
return ScalePathsD(tmpPath, 1 / scale);
269269
}
@@ -285,7 +285,7 @@ public static Paths64 ExecuteRectClipLines(Rect64 rect, Paths64 paths) {
285285
if (rect.IsEmpty() || paths.size() == 0) {
286286
return new Paths64();
287287
}
288-
RectClipLines rc = new RectClipLines(rect);
288+
RectClipLines64 rc = new RectClipLines64(rect);
289289
return rc.Execute(paths);
290290
}
291291

@@ -310,7 +310,7 @@ public static PathsD ExecuteRectClipLines(RectD rect, PathsD paths, int precisio
310310
double scale = Math.pow(10, precision);
311311
Rect64 r = ScaleRect(rect, scale);
312312
Paths64 tmpPath = ScalePaths64(paths, scale);
313-
RectClipLines rc = new RectClipLines(r);
313+
RectClipLines64 rc = new RectClipLines64(r);
314314
tmpPath = rc.Execute(tmpPath);
315315
return ScalePathsD(tmpPath, 1 / scale);
316316
}

src/main/java/clipper2/offset/ClipperOffset.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ private PointD GetPerpendicD(Point64 pt, PointD norm) {
385385
private void DoSquare(Group group, Path64 path, int j, int k) {
386386
PointD vec;
387387
if (j == k) {
388-
vec = new PointD(normals.get(0).y, -normals.get(0).x);
388+
vec = new PointD(normals.get(j).y, -normals.get(j).x);
389389
} else {
390390
vec = GetAvgUnitVector(new PointD(-normals.get(k).y, normals.get(k).x), new PointD(normals.get(j).y, -normals.get(j).x));
391391
}
@@ -486,7 +486,7 @@ private void OffsetPoint(Group group, Path64 path, int j, RefObject<Integer> k)
486486
return;
487487
}
488488

489-
if (cosA > 0.99) {
489+
if (cosA > 0.999) {
490490
DoMiter(group, path, j, k.argValue, cosA);
491491
} else if (cosA > -0.99 && (sinA * groupDelta < 0)) {
492492
// is concave
@@ -502,7 +502,7 @@ private void OffsetPoint(Group group, Path64 path, int j, RefObject<Integer> k)
502502
} else {
503503
DoSquare(group, path, j, k.argValue);
504504
}
505-
} else if (joinType == JoinType.Square) {
505+
} else if (cosA > 0.99 || joinType == JoinType.Square) {
506506
// angle less than 8 degrees or a squared join
507507
DoSquare(group, path, j, k.argValue);
508508
} else {

src/main/java/clipper2/rectclip/RectClip.java renamed to src/main/java/clipper2/rectclip/RectClip64.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
import tangible.RefObject;
1616

1717
/**
18-
* RectClip intersects subject polygons with the specified rectangular clipping
19-
* region. Polygons may be simple or complex (self-intersecting).
18+
* RectClip64 intersects subject polygons with the specified rectangular
19+
* clipping region. Polygons may be simple or complex (self-intersecting).
2020
* <p>
2121
* This function is extremely fast when compared to the Library's general
2222
* purpose Intersect clipper. Where Intersect has roughly O(n³) performance,
23-
* RectClip has O(n) performance.
23+
* RectClip64 has O(n) performance.
2424
*
2525
* @since 1.0.6
2626
*/
27-
public class RectClip {
27+
public class RectClip64 {
2828

2929
protected static class OutPt2 {
3030
@Nullable
@@ -55,7 +55,7 @@ protected enum Location {
5555
protected int currIdx = -1;
5656

5757
@SuppressWarnings("unchecked")
58-
public RectClip(Rect64 rect) {
58+
public RectClip64(Rect64 rect) {
5959
currIdx = -1;
6060
this.rect = rect;
6161
mp = rect.MidPoint();

src/main/java/clipper2/rectclip/RectClipLines.java renamed to src/main/java/clipper2/rectclip/RectClipLines64.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
import tangible.RefObject;
1010

1111
/**
12-
* RectClipLines intersects subject open paths (polylines) with the specified
12+
* RectClipLines64 intersects subject open paths (polylines) with the specified
1313
* rectangular clipping region.
1414
* <p>
1515
* This function is extremely fast when compared to the Library's general
1616
* purpose Intersect clipper. Where Intersect has roughly O(n³) performance,
17-
* RectClipLines has O(n) performance.
17+
* RectClipLines64 has O(n) performance.
1818
*
1919
* @since 1.0.6
2020
*/
21-
public class RectClipLines extends RectClip {
21+
public class RectClipLines64 extends RectClip64 {
2222

23-
public RectClipLines(Rect64 rect) {
23+
public RectClipLines64(Rect64 rect) {
2424
super(rect);
2525
}
2626

@@ -123,9 +123,8 @@ private void ExecuteInternal(Path64 path) {
123123
// we must be crossing the rect boundary to get here
124124
////////////////////////////////////////////////////
125125

126-
if (loc.argValue == Location.INSIDE) // path must be entering rect
127-
{
128-
Add(ip);
126+
if (loc.argValue == Location.INSIDE) { // path must be entering rect
127+
Add(ip, true);
129128
} else if (prev.argValue != Location.INSIDE) {
130129
// passing right through rect. 'ip' here will be the second
131130
// intersect pt but we'll also need the first intersect pt (ip2)

src/main/java/clipper2/rectclip/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This unit contains the code that implements the RectClip functions found in
2+
* This unit contains the code that implements the RectClip64 functions found in
33
* the Clipper Unit.
44
*
55
* @since 1.0.6

0 commit comments

Comments
 (0)