11package clipper2 .engine ;
22
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+
310import clipper2 .Clipper ;
411import clipper2 .Nullable ;
512import clipper2 .core .ClipType ;
1421import tangible .OutObject ;
1522import tangible .RefObject ;
1623
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-
2424/**
2525 * Subject and Clip paths are passed to a Clipper object via AddSubject,
2626 * AddOpenSubject and AddClip methods. Clipping operations are then initiated by
@@ -39,7 +39,7 @@ abstract class ClipperBase {
3939 private List <OutRec > outrecList ;
4040 private NavigableSet <Long > scanlineSet ;
4141 private List <HorzSegment > horzSegList ;
42- private List <HorzJoin > _horzJoinList ;
42+ private List <HorzJoin > horzJoinList ;
4343 private int currentLocMin ;
4444 private long currentBotY ;
4545 private boolean isSortedMinimaList ;
@@ -89,7 +89,7 @@ public int compare(@Nullable HorzSegment hs1, @Nullable HorzSegment hs2) {
8989 }
9090
9191 private static class HorzSegment {
92-
92+
9393 public @ Nullable OutPt leftOp ;
9494 public @ Nullable OutPt rightOp ;
9595 public boolean leftToRight ;
@@ -102,7 +102,7 @@ public HorzSegment(OutPt op) {
102102 }
103103
104104 private static class HorzJoin {
105-
105+
106106 public @ Nullable OutPt op1 ;
107107 public @ Nullable OutPt op2 ;
108108
@@ -236,7 +236,7 @@ protected ClipperBase() {
236236 outrecList = new ArrayList <>();
237237 scanlineSet = new TreeSet <>();
238238 horzSegList = new ArrayList <>();
239- _horzJoinList = new ArrayList <>();
239+ horzJoinList = new ArrayList <>();
240240 setPreserveCollinear (true );
241241 }
242242
@@ -458,7 +458,7 @@ private static void SwapOutrecs(Active ae1, Active ae2) {
458458 }
459459
460460 private static void SetOwner (OutRec outrec , OutRec newOwner ) {
461- // precondition1: new_owner is never null
461+ // precondition1: newOwner is never null
462462 while (newOwner .owner != null && newOwner .owner .pts == null ) {
463463 newOwner .owner = newOwner .owner .owner ;
464464 }
@@ -533,7 +533,7 @@ protected final void ClearSolutionOnly() {
533533 DisposeIntersectNodes ();
534534 outrecList .clear ();
535535 horzSegList .clear ();
536- _horzJoinList .clear ();
536+ horzJoinList .clear ();
537537 }
538538
539539 public final void Clear () {
@@ -1954,19 +1954,19 @@ private void DoHorizontal(Active horz)
19541954 long Y = horz .bot .y ;
19551955
19561956 @ Nullable
1957- Vertex vertex_max = horzIsOpen ? GetCurrYMaximaVertex_Open (horz ) : GetCurrYMaximaVertex (horz );
1957+ Vertex vertexMax = horzIsOpen ? GetCurrYMaximaVertex_Open (horz ) : GetCurrYMaximaVertex (horz );
19581958
19591959 // remove 180 deg.spikes and also simplify
19601960 // consecutive horizontals when PreserveCollinear = true
1961- if (vertex_max != null && !horzIsOpen && vertex_max != horz .vertexTop ) {
1961+ if (vertexMax != null && !horzIsOpen && vertexMax != horz .vertexTop ) {
19621962 TrimHorz (horz , getPreserveCollinear ());
19631963 }
19641964
19651965 long leftX ;
19661966 OutObject <Long > tempOutleftX = new OutObject <>();
19671967 long rightX ;
19681968 OutObject <Long > tempOutrightX = new OutObject <>();
1969- boolean isLeftToRight = ResetHorzDirection (horz , vertex_max , tempOutleftX , tempOutrightX );
1969+ boolean isLeftToRight = ResetHorzDirection (horz , vertexMax , tempOutleftX , tempOutrightX );
19701970 rightX = tempOutrightX .argValue ;
19711971 leftX = tempOutleftX .argValue ;
19721972
@@ -1983,14 +1983,14 @@ private void DoHorizontal(Active horz)
19831983 Active ae = isLeftToRight ? horz .nextInAEL : horz .prevInAEL ;
19841984
19851985 while (ae != null ) {
1986- if (ae .vertexTop == vertex_max ) {
1986+ if (ae .vertexTop == vertexMax ) {
19871987 // do this first!!
19881988 if (IsHotEdge (horz ) && IsJoined (ae )) {
19891989 Split (ae , ae .top );
19901990 }
19911991
19921992 if (IsHotEdge (horz )) {
1993- while (horz .vertexTop != vertex_max ) {
1993+ while (horz .vertexTop != vertexMax ) {
19941994 AddOutPt (horz , horz .top );
19951995 UpdateEdgeIntoAEL (horz );
19961996 }
@@ -2007,7 +2007,7 @@ private void DoHorizontal(Active horz)
20072007
20082008 // if horzEdge is a maxima, keep going until we reach
20092009 // its maxima pair, otherwise check for break conditions
2010- if (vertex_max != horz .vertexTop || IsOpenEnd (horz )) {
2010+ if (vertexMax != horz .vertexTop || IsOpenEnd (horz )) {
20112011 // otherwise stop when 'ae' is beyond the end of the horizontal line
20122012 if ((isLeftToRight && ae .curX > rightX ) || (!isLeftToRight && ae .curX < leftX )) {
20132013 break ;
@@ -2086,7 +2086,7 @@ else if ((isLeftToRight && (TopX(ae, pt.y) >= pt.x)) || (!isLeftToRight && (TopX
20862086
20872087 OutObject <Long > tempOutleftX2 = new OutObject <>();
20882088 OutObject <Long > tempOutrightX2 = new OutObject <>();
2089- isLeftToRight = ResetHorzDirection (horz , vertex_max , tempOutleftX2 , tempOutrightX2 );
2089+ isLeftToRight = ResetHorzDirection (horz , vertexMax , tempOutleftX2 , tempOutrightX2 );
20902090 rightX = tempOutrightX2 .argValue ;
20912091 leftX = tempOutleftX2 .argValue ;
20922092
@@ -2300,21 +2300,21 @@ private static boolean UpdateHorzSegment(HorzSegment hs) {
23002300 OutPt op = hs .leftOp ;
23012301 OutRec outrec = GetRealOutRec (op .outrec );
23022302 boolean outrecHasEdges = outrec .frontEdge != null ;
2303- long curr_y = op .pt .y ;
2303+ long currY = op .pt .y ;
23042304 OutPt opP = op , opN = op ;
23052305 if (outrecHasEdges ) {
23062306 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 ) {
23082308 opP = opP .prev ;
23092309 }
2310- while (opN != opA && opN .next .pt .y == curr_y ) {
2310+ while (opN != opA && opN .next .pt .y == currY ) {
23112311 opN = opN .next ;
23122312 }
23132313 } else {
2314- while (opP .prev != opN && opP .prev .pt .y == curr_y ) {
2314+ while (opP .prev != opN && opP .prev .pt .y == currY ) {
23152315 opP = opP .prev ;
23162316 }
2317- while (opN .next != opP && opN .next .pt .y == curr_y ) {
2317+ while (opN .next != opP && opN .next .pt .y == currY ) {
23182318 opN = opN .next ;
23192319 }
23202320 }
@@ -2328,9 +2328,9 @@ private static boolean UpdateHorzSegment(HorzSegment hs) {
23282328 return result ;
23292329 }
23302330
2331- private static OutPt DuplicateOp (OutPt op , boolean insert_after ) {
2331+ private static OutPt DuplicateOp (OutPt op , boolean insertAfter ) {
23322332 OutPt result = new OutPt (op .pt , op .outrec );
2333- if (insert_after ) {
2333+ if (insertAfter ) {
23342334 result .next = op .next ;
23352335 result .next .prev = result ;
23362336 result .prev = op ;
@@ -2367,25 +2367,25 @@ private void ConvertHorzSegsToJoins() {
23672367 if (hs2 .leftToRight == hs1 .leftToRight || (hs2 .rightOp .pt .x <= hs1 .leftOp .pt .x )) {
23682368 continue ;
23692369 }
2370- long curr_y = hs1 .leftOp .pt .y ;
2370+ long currY = hs1 .leftOp .pt .y ;
23712371 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 ) {
23732373 hs1 .leftOp = hs1 .leftOp .next ;
23742374 }
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 ) {
23762376 (hs2 ).leftOp = (hs2 ).leftOp .prev ;
23772377 }
23782378 HorzJoin join = new HorzJoin (DuplicateOp ((hs1 ).leftOp , true ), DuplicateOp ((hs2 ).leftOp , false ));
2379- _horzJoinList .add (join );
2379+ horzJoinList .add (join );
23802380 } 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 ) {
23822382 hs1 .leftOp = hs1 .leftOp .prev ;
23832383 }
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 ) {
23852385 hs2 .leftOp = (hs2 ).leftOp .next ;
23862386 }
23872387 HorzJoin join = new HorzJoin (DuplicateOp ((hs2 ).leftOp , true ), DuplicateOp ((hs1 ).leftOp , false ));
2388- _horzJoinList .add (join );
2388+ horzJoinList .add (join );
23892389 }
23902390 }
23912391 }
@@ -2496,27 +2496,27 @@ private static PointInPolygonResult PointInOpPolygon(Point64 pt, OutPt op) {
24962496 private static boolean Path1InsidePath2 (OutPt op1 , OutPt op2 ) {
24972497 // we need to make some accommodation for rounding errors
24982498 // so we won't jump if the first vertex is found outside
2499- int outside_cnt = 0 ;
2499+ int outsideCnt = 0 ;
25002500 OutPt op = op1 ;
25012501 do {
25022502 PointInPolygonResult result = PointInOpPolygon (op .pt , op2 );
25032503 if (result == PointInPolygonResult .IsOutside ) {
2504- ++outside_cnt ;
2504+ ++outsideCnt ;
25052505 } else if (result == PointInPolygonResult .IsInside ) {
2506- --outside_cnt ;
2506+ --outsideCnt ;
25072507 }
25082508 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 );
25122512 }
25132513 // since path1's location is still equivocal, check its midpoint
25142514 Point64 mp = GetBounds (op ).MidPoint ();
25152515 return PointInOpPolygon (mp , op2 ) == PointInPolygonResult .IsInside ;
25162516 }
25172517
25182518 private void ProcessHorzJoins () {
2519- for (HorzJoin j : _horzJoinList ) {
2519+ for (HorzJoin j : horzJoinList ) {
25202520 OutRec or1 = GetRealOutRec (j .op1 .outrec );
25212521 OutRec or2 = GetRealOutRec (j .op2 .outrec );
25222522
@@ -2749,7 +2749,7 @@ protected final boolean BuildPaths(Paths64 solutionClosed, Paths64 solutionOpen)
27492749 solutionOpen .clear ();
27502750
27512751 int i = 0 ;
2752- // _outrecList .Count is not static here because
2752+ // outrecList .Count is not static here because
27532753 // CleanCollinear can indirectly add additional OutRec
27542754 while (i < outrecList .size ()) {
27552755 OutRec outrec = outrecList .get (i ++);
@@ -2870,7 +2870,7 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) {
28702870 solutionOpen .clear ();
28712871
28722872 int i = 0 ;
2873- // _outrecList .Count is not static here because
2873+ // outrecList .Count is not static here because
28742874 // CheckBounds below can indirectly add additional
28752875 // OutRec (via FixOutRecPts & CleanCollinear)
28762876 while (i < outrecList .size ()) {
@@ -2880,9 +2880,9 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) {
28802880 }
28812881
28822882 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 );
28862886 }
28872887 continue ;
28882888 }
0 commit comments