1
1
package clipper2 .engine ;
2
2
3
+ import java .util .ArrayList ;
4
+ import java .util .Collections ;
5
+ import java .util .Comparator ;
6
+ import java .util .List ;
7
+ import java .util .NavigableSet ;
8
+ import java .util .TreeSet ;
9
+
3
10
import clipper2 .Clipper ;
4
11
import clipper2 .Nullable ;
5
12
import clipper2 .core .ClipType ;
14
21
import tangible .OutObject ;
15
22
import tangible .RefObject ;
16
23
17
- import java .util .ArrayList ;
18
- import java .util .Collections ;
19
- import java .util .Comparator ;
20
- import java .util .List ;
21
- import java .util .NavigableSet ;
22
- import java .util .TreeSet ;
23
-
24
24
/**
25
25
* Subject and Clip paths are passed to a Clipper object via AddSubject,
26
26
* AddOpenSubject and AddClip methods. Clipping operations are then initiated by
@@ -39,7 +39,7 @@ abstract class ClipperBase {
39
39
private List <OutRec > outrecList ;
40
40
private NavigableSet <Long > scanlineSet ;
41
41
private List <HorzSegment > horzSegList ;
42
- private List <HorzJoin > _horzJoinList ;
42
+ private List <HorzJoin > horzJoinList ;
43
43
private int currentLocMin ;
44
44
private long currentBotY ;
45
45
private boolean isSortedMinimaList ;
@@ -89,7 +89,7 @@ public int compare(@Nullable HorzSegment hs1, @Nullable HorzSegment hs2) {
89
89
}
90
90
91
91
private static class HorzSegment {
92
-
92
+
93
93
public @ Nullable OutPt leftOp ;
94
94
public @ Nullable OutPt rightOp ;
95
95
public boolean leftToRight ;
@@ -102,7 +102,7 @@ public HorzSegment(OutPt op) {
102
102
}
103
103
104
104
private static class HorzJoin {
105
-
105
+
106
106
public @ Nullable OutPt op1 ;
107
107
public @ Nullable OutPt op2 ;
108
108
@@ -236,7 +236,7 @@ protected ClipperBase() {
236
236
outrecList = new ArrayList <>();
237
237
scanlineSet = new TreeSet <>();
238
238
horzSegList = new ArrayList <>();
239
- _horzJoinList = new ArrayList <>();
239
+ horzJoinList = new ArrayList <>();
240
240
setPreserveCollinear (true );
241
241
}
242
242
@@ -458,7 +458,7 @@ private static void SwapOutrecs(Active ae1, Active ae2) {
458
458
}
459
459
460
460
private static void SetOwner (OutRec outrec , OutRec newOwner ) {
461
- // precondition1: new_owner is never null
461
+ // precondition1: newOwner is never null
462
462
while (newOwner .owner != null && newOwner .owner .pts == null ) {
463
463
newOwner .owner = newOwner .owner .owner ;
464
464
}
@@ -533,7 +533,7 @@ protected final void ClearSolutionOnly() {
533
533
DisposeIntersectNodes ();
534
534
outrecList .clear ();
535
535
horzSegList .clear ();
536
- _horzJoinList .clear ();
536
+ horzJoinList .clear ();
537
537
}
538
538
539
539
public final void Clear () {
@@ -1954,19 +1954,19 @@ private void DoHorizontal(Active horz)
1954
1954
long Y = horz .bot .y ;
1955
1955
1956
1956
@ Nullable
1957
- Vertex vertex_max = horzIsOpen ? GetCurrYMaximaVertex_Open (horz ) : GetCurrYMaximaVertex (horz );
1957
+ Vertex vertexMax = horzIsOpen ? GetCurrYMaximaVertex_Open (horz ) : GetCurrYMaximaVertex (horz );
1958
1958
1959
1959
// remove 180 deg.spikes and also simplify
1960
1960
// consecutive horizontals when PreserveCollinear = true
1961
- if (vertex_max != null && !horzIsOpen && vertex_max != horz .vertexTop ) {
1961
+ if (vertexMax != null && !horzIsOpen && vertexMax != horz .vertexTop ) {
1962
1962
TrimHorz (horz , getPreserveCollinear ());
1963
1963
}
1964
1964
1965
1965
long leftX ;
1966
1966
OutObject <Long > tempOutleftX = new OutObject <>();
1967
1967
long rightX ;
1968
1968
OutObject <Long > tempOutrightX = new OutObject <>();
1969
- boolean isLeftToRight = ResetHorzDirection (horz , vertex_max , tempOutleftX , tempOutrightX );
1969
+ boolean isLeftToRight = ResetHorzDirection (horz , vertexMax , tempOutleftX , tempOutrightX );
1970
1970
rightX = tempOutrightX .argValue ;
1971
1971
leftX = tempOutleftX .argValue ;
1972
1972
@@ -1983,14 +1983,14 @@ private void DoHorizontal(Active horz)
1983
1983
Active ae = isLeftToRight ? horz .nextInAEL : horz .prevInAEL ;
1984
1984
1985
1985
while (ae != null ) {
1986
- if (ae .vertexTop == vertex_max ) {
1986
+ if (ae .vertexTop == vertexMax ) {
1987
1987
// do this first!!
1988
1988
if (IsHotEdge (horz ) && IsJoined (ae )) {
1989
1989
Split (ae , ae .top );
1990
1990
}
1991
1991
1992
1992
if (IsHotEdge (horz )) {
1993
- while (horz .vertexTop != vertex_max ) {
1993
+ while (horz .vertexTop != vertexMax ) {
1994
1994
AddOutPt (horz , horz .top );
1995
1995
UpdateEdgeIntoAEL (horz );
1996
1996
}
@@ -2007,7 +2007,7 @@ private void DoHorizontal(Active horz)
2007
2007
2008
2008
// if horzEdge is a maxima, keep going until we reach
2009
2009
// its maxima pair, otherwise check for break conditions
2010
- if (vertex_max != horz .vertexTop || IsOpenEnd (horz )) {
2010
+ if (vertexMax != horz .vertexTop || IsOpenEnd (horz )) {
2011
2011
// otherwise stop when 'ae' is beyond the end of the horizontal line
2012
2012
if ((isLeftToRight && ae .curX > rightX ) || (!isLeftToRight && ae .curX < leftX )) {
2013
2013
break ;
@@ -2086,7 +2086,7 @@ else if ((isLeftToRight && (TopX(ae, pt.y) >= pt.x)) || (!isLeftToRight && (TopX
2086
2086
2087
2087
OutObject <Long > tempOutleftX2 = new OutObject <>();
2088
2088
OutObject <Long > tempOutrightX2 = new OutObject <>();
2089
- isLeftToRight = ResetHorzDirection (horz , vertex_max , tempOutleftX2 , tempOutrightX2 );
2089
+ isLeftToRight = ResetHorzDirection (horz , vertexMax , tempOutleftX2 , tempOutrightX2 );
2090
2090
rightX = tempOutrightX2 .argValue ;
2091
2091
leftX = tempOutleftX2 .argValue ;
2092
2092
@@ -2300,21 +2300,21 @@ private static boolean UpdateHorzSegment(HorzSegment hs) {
2300
2300
OutPt op = hs .leftOp ;
2301
2301
OutRec outrec = GetRealOutRec (op .outrec );
2302
2302
boolean outrecHasEdges = outrec .frontEdge != null ;
2303
- long curr_y = op .pt .y ;
2303
+ long currY = op .pt .y ;
2304
2304
OutPt opP = op , opN = op ;
2305
2305
if (outrecHasEdges ) {
2306
2306
OutPt opA = outrec .pts , opZ = opA .next ;
2307
- while (opP != opZ && opP .prev .pt .y == curr_y ) {
2307
+ while (opP != opZ && opP .prev .pt .y == currY ) {
2308
2308
opP = opP .prev ;
2309
2309
}
2310
- while (opN != opA && opN .next .pt .y == curr_y ) {
2310
+ while (opN != opA && opN .next .pt .y == currY ) {
2311
2311
opN = opN .next ;
2312
2312
}
2313
2313
} else {
2314
- while (opP .prev != opN && opP .prev .pt .y == curr_y ) {
2314
+ while (opP .prev != opN && opP .prev .pt .y == currY ) {
2315
2315
opP = opP .prev ;
2316
2316
}
2317
- while (opN .next != opP && opN .next .pt .y == curr_y ) {
2317
+ while (opN .next != opP && opN .next .pt .y == currY ) {
2318
2318
opN = opN .next ;
2319
2319
}
2320
2320
}
@@ -2328,9 +2328,9 @@ private static boolean UpdateHorzSegment(HorzSegment hs) {
2328
2328
return result ;
2329
2329
}
2330
2330
2331
- private static OutPt DuplicateOp (OutPt op , boolean insert_after ) {
2331
+ private static OutPt DuplicateOp (OutPt op , boolean insertAfter ) {
2332
2332
OutPt result = new OutPt (op .pt , op .outrec );
2333
- if (insert_after ) {
2333
+ if (insertAfter ) {
2334
2334
result .next = op .next ;
2335
2335
result .next .prev = result ;
2336
2336
result .prev = op ;
@@ -2367,25 +2367,25 @@ private void ConvertHorzSegsToJoins() {
2367
2367
if (hs2 .leftToRight == hs1 .leftToRight || (hs2 .rightOp .pt .x <= hs1 .leftOp .pt .x )) {
2368
2368
continue ;
2369
2369
}
2370
- long curr_y = hs1 .leftOp .pt .y ;
2370
+ long currY = hs1 .leftOp .pt .y ;
2371
2371
if ((hs1 ).leftToRight ) {
2372
- while (hs1 .leftOp .next .pt .y == curr_y && hs1 .leftOp .next .pt .x <= hs2 .leftOp .pt .x ) {
2372
+ while (hs1 .leftOp .next .pt .y == currY && hs1 .leftOp .next .pt .x <= hs2 .leftOp .pt .x ) {
2373
2373
hs1 .leftOp = hs1 .leftOp .next ;
2374
2374
}
2375
- while (hs2 .leftOp .prev .pt .y == curr_y && hs2 .leftOp .prev .pt .x <= hs1 .leftOp .pt .x ) {
2375
+ while (hs2 .leftOp .prev .pt .y == currY && hs2 .leftOp .prev .pt .x <= hs1 .leftOp .pt .x ) {
2376
2376
(hs2 ).leftOp = (hs2 ).leftOp .prev ;
2377
2377
}
2378
2378
HorzJoin join = new HorzJoin (DuplicateOp ((hs1 ).leftOp , true ), DuplicateOp ((hs2 ).leftOp , false ));
2379
- _horzJoinList .add (join );
2379
+ horzJoinList .add (join );
2380
2380
} else {
2381
- while (hs1 .leftOp .prev .pt .y == curr_y && hs1 .leftOp .prev .pt .x <= hs2 .leftOp .pt .x ) {
2381
+ while (hs1 .leftOp .prev .pt .y == currY && hs1 .leftOp .prev .pt .x <= hs2 .leftOp .pt .x ) {
2382
2382
hs1 .leftOp = hs1 .leftOp .prev ;
2383
2383
}
2384
- while (hs2 .leftOp .next .pt .y == curr_y && hs2 .leftOp .next .pt .x <= (hs1 ).leftOp .pt .x ) {
2384
+ while (hs2 .leftOp .next .pt .y == currY && hs2 .leftOp .next .pt .x <= (hs1 ).leftOp .pt .x ) {
2385
2385
hs2 .leftOp = (hs2 ).leftOp .next ;
2386
2386
}
2387
2387
HorzJoin join = new HorzJoin (DuplicateOp ((hs2 ).leftOp , true ), DuplicateOp ((hs1 ).leftOp , false ));
2388
- _horzJoinList .add (join );
2388
+ horzJoinList .add (join );
2389
2389
}
2390
2390
}
2391
2391
}
@@ -2496,27 +2496,27 @@ private static PointInPolygonResult PointInOpPolygon(Point64 pt, OutPt op) {
2496
2496
private static boolean Path1InsidePath2 (OutPt op1 , OutPt op2 ) {
2497
2497
// we need to make some accommodation for rounding errors
2498
2498
// so we won't jump if the first vertex is found outside
2499
- int outside_cnt = 0 ;
2499
+ int outsideCnt = 0 ;
2500
2500
OutPt op = op1 ;
2501
2501
do {
2502
2502
PointInPolygonResult result = PointInOpPolygon (op .pt , op2 );
2503
2503
if (result == PointInPolygonResult .IsOutside ) {
2504
- ++outside_cnt ;
2504
+ ++outsideCnt ;
2505
2505
} else if (result == PointInPolygonResult .IsInside ) {
2506
- --outside_cnt ;
2506
+ --outsideCnt ;
2507
2507
}
2508
2508
op = op .next ;
2509
- } while (op != op1 && Math .abs (outside_cnt ) < 2 );
2510
- if (Math .abs (outside_cnt ) > 1 ) {
2511
- return (outside_cnt < 0 );
2509
+ } while (op != op1 && Math .abs (outsideCnt ) < 2 );
2510
+ if (Math .abs (outsideCnt ) > 1 ) {
2511
+ return (outsideCnt < 0 );
2512
2512
}
2513
2513
// since path1's location is still equivocal, check its midpoint
2514
2514
Point64 mp = GetBounds (op ).MidPoint ();
2515
2515
return PointInOpPolygon (mp , op2 ) == PointInPolygonResult .IsInside ;
2516
2516
}
2517
2517
2518
2518
private void ProcessHorzJoins () {
2519
- for (HorzJoin j : _horzJoinList ) {
2519
+ for (HorzJoin j : horzJoinList ) {
2520
2520
OutRec or1 = GetRealOutRec (j .op1 .outrec );
2521
2521
OutRec or2 = GetRealOutRec (j .op2 .outrec );
2522
2522
@@ -2749,7 +2749,7 @@ protected final boolean BuildPaths(Paths64 solutionClosed, Paths64 solutionOpen)
2749
2749
solutionOpen .clear ();
2750
2750
2751
2751
int i = 0 ;
2752
- // _outrecList .Count is not static here because
2752
+ // outrecList .Count is not static here because
2753
2753
// CleanCollinear can indirectly add additional OutRec
2754
2754
while (i < outrecList .size ()) {
2755
2755
OutRec outrec = outrecList .get (i ++);
@@ -2870,7 +2870,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) {
2870
2870
solutionOpen .clear ();
2871
2871
2872
2872
int i = 0 ;
2873
- // _outrecList .Count is not static here because
2873
+ // outrecList .Count is not static here because
2874
2874
// CheckBounds below can indirectly add additional
2875
2875
// OutRec (via FixOutRecPts & CleanCollinear)
2876
2876
while (i < outrecList .size ()) {
@@ -2880,9 +2880,9 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) {
2880
2880
}
2881
2881
2882
2882
if (outrec .isOpen ) {
2883
- Path64 open_path = new Path64 ();
2884
- if (BuildPath (outrec .pts , getReverseSolution (), true , open_path )) {
2885
- solutionOpen .add (open_path );
2883
+ Path64 openPath = new Path64 ();
2884
+ if (BuildPath (outrec .pts , getReverseSolution (), true , openPath )) {
2885
+ solutionOpen .add (openPath );
2886
2886
}
2887
2887
continue ;
2888
2888
}
0 commit comments