@@ -2253,11 +2253,12 @@ private void CheckJoinLeft(Active e, Point64 pt, boolean checkCurrX) {
22532253 return ;
22542254 }
22552255
2256- if (( pt . y < e . top . y + 2 || pt . y < prev . top . y + 2 ) && // avoid trivial joins
2257- ((e .bot .y > pt .y ) || (prev .bot .y > pt .y ))) {
2258- return ; // (#490)
2256+ // Trivial join check (#490)
2257+ if (( pt . y < e . top . y + 2 || pt . y < prev . top . y + 2 ) && ((e .bot .y > pt .y ) || (prev .bot .y > pt .y ))) {
2258+ return ;
22592259 }
22602260
2261+ // Position and Collinearity checks
22612262 if (checkCurrX ) {
22622263 if (Clipper .PerpendicDistFromLineSqrd (pt , prev .bot , prev .top ) > 0.25 ) {
22632264 return ;
@@ -2269,6 +2270,7 @@ private void CheckJoinLeft(Active e, Point64 pt, boolean checkCurrX) {
22692270 return ;
22702271 }
22712272
2273+ // Join/Split logic
22722274 if (e .outrec .idx == prev .outrec .idx ) {
22732275 AddLocalMaxPoly (prev , e , pt );
22742276 } else if (e .outrec .idx < prev .outrec .idx ) {
@@ -2287,14 +2289,16 @@ private void CheckJoinRight(Active e, Point64 pt) {
22872289 private void CheckJoinRight (Active e , Point64 pt , boolean checkCurrX ) {
22882290 @ Nullable
22892291 Active next = e .nextInAEL ;
2290- if (IsOpen (e ) || ! IsHotEdge ( e ) || IsJoined (e ) || next == null || IsOpen (next ) || ! IsHotEdge ( next )) {
2292+ if (next == null || IsOpen (e ) || IsOpen ( next ) || ! IsHotEdge (e ) || ! IsHotEdge (next ) || IsJoined ( e )) {
22912293 return ;
22922294 }
2293- if ((pt .y < e .top .y + 2 || pt .y < next .top .y + 2 ) && // avoid trivial joins
2294- ((e .bot .y > pt .y ) || (next .bot .y > pt .y ))) {
2295- return ; // (#490)
2295+
2296+ // Trivial join check (#490)
2297+ if ((pt .y < e .top .y + 2 || pt .y < next .top .y + 2 ) && ((e .bot .y > pt .y ) || (next .bot .y > pt .y ))) {
2298+ return ;
22962299 }
22972300
2301+ // Position and Collinearity checks
22982302 if (checkCurrX ) {
22992303 if (Clipper .PerpendicDistFromLineSqrd (pt , next .bot , next .top ) > 0.25 ) {
23002304 return ;
@@ -2306,6 +2310,7 @@ private void CheckJoinRight(Active e, Point64 pt, boolean checkCurrX) {
23062310 return ;
23072311 }
23082312
2313+ // Join/Split logic
23092314 if (e .outrec .idx == next .outrec .idx ) {
23102315 AddLocalMaxPoly (e , next , pt );
23112316 } else if (e .outrec .idx < next .outrec .idx ) {
@@ -2586,10 +2591,11 @@ private void ProcessHorzJoins() {
25862591 op2b .next = op1b ;
25872592
25882593 if (or1 == or2 ) { // 'join' is really a split
2589- or2 = new OutRec ();
2594+ or2 = NewOutRec ();
25902595 or2 .pts = op1b ;
25912596 FixOutRecPts (or2 );
2592- // if or1->pts has moved to or2 then update or1->pts!!
2597+
2598+ // if or1->pts has moved to or2 then update or1->pts
25932599 if (or1 .pts .outrec == or2 ) {
25942600 or1 .pts = j .op1 ;
25952601 or1 .pts .outrec = or1 ;
@@ -2598,9 +2604,9 @@ private void ProcessHorzJoins() {
25982604 if (usingPolytree ) { // #498, #520, #584, D#576, #618
25992605 if (Path1InsidePath2 (or1 .pts , or2 .pts )) {
26002606 // swap or1's & or2's pts
2601- OutPt tmp = or1 .pts ;
2602- or1 .pts = or2 .pts ;
2603- or2 .pts = tmp ;
2607+ OutPt temp = or2 .pts ;
2608+ or2 .pts = or1 .pts ;
2609+ or1 .pts = temp ;
26042610 FixOutRecPts (or1 );
26052611 FixOutRecPts (or2 );
26062612 // or2 is now inside or1
@@ -2610,14 +2616,14 @@ private void ProcessHorzJoins() {
26102616 } else {
26112617 or2 .owner = or1 .owner ;
26122618 }
2619+
26132620 if (or1 .splits == null ) {
26142621 or1 .splits = new ArrayList <>();
26152622 }
26162623 or1 .splits .add (or2 .idx );
26172624 } else {
26182625 or2 .owner = or1 ;
26192626 }
2620- // outrecList.add(or2); // NOTE removed in 6e15ba0, but then fails tests
26212627 } else {
26222628 or2 .pts = null ;
26232629 if (usingPolytree ) {
@@ -2927,29 +2933,6 @@ private void RecursiveCheckOwners(OutRec outrec, PolyPathBase polypath) {
29272933 }
29282934 }
29292935
2930- private void DeepCheckOwners (OutRec outrec , PolyPathBase polypath ) {
2931- RecursiveCheckOwners (outrec , polypath );
2932-
2933- while (outrec .owner != null && outrec .owner .splits != null ) {
2934- @ Nullable
2935- OutRec split = null ;
2936- for (int i : outrec .owner .splits ) {
2937- split = GetRealOutRec (outrecList .get (i ));
2938- if (split != null && split != outrec && split != outrec .owner && CheckBounds (split ) && split .bounds .Contains (outrec .bounds )
2939- && Path1InsidePath2 (outrec .pts , split .pts )) {
2940- RecursiveCheckOwners (split , polypath );
2941- outrec .owner = split ; // found in split
2942- break ; // inner 'for' loop
2943- } else {
2944- split = null ;
2945- }
2946- }
2947- if (split == null ) {
2948- break ;
2949- }
2950- }
2951- }
2952-
29532936 protected void BuildTree (PolyPathBase polytree , Paths64 solutionOpen ) {
29542937 polytree .Clear ();
29552938 solutionOpen .clear ();
0 commit comments