void setSplitVariables ( List < Point2D_I32 > contour , Element < Corner > e0 , Element < Corner > e1 ) { int distance0 = CircularIndex . distanceP ( e0 . object . index , e1 . object . index , contour . size ( ) ) ; int index0 = CircularIndex . plusPOffset ( e0 . object . index , minimumSideLength , contour . size ( ) ) ; int index1 = CircularIndex . minusPOffset ( e1 . object . index , minimumSideLength , contour . size ( ) ) ; splitter . selectSplitPoint ( contour , index0 , index1 , resultsA ) ; // if convex only perform the split if it would result in a convex polygon if ( convex ) { Point2D_I32 a = contour . get ( e0 . object . index ) ; Point2D_I32 b = contour . get ( resultsA . index ) ; Point2D_I32 c = contour . get ( next ( e0 ) . object . index ) ; if ( UtilPolygons2D_I32 . isPositiveZ ( a , b , c ) ) { e0 . object . splitable = false ; return ; } } // see if this would result in a side that's too small int dist0 = CircularIndex . distanceP ( e0 . object . index , resultsA . index , contour . size ( ) ) ; if ( dist0 < minimumSideLength || ( contour . size ( ) - dist0 ) < minimumSideLength ) { throw new RuntimeException ( "Should be impossible" ) ; } // this function is only called if splitable is set to true so no need to set it again e0 . object . splitLocation = resultsA . index ; e0 . object . splitError0 = computeSideError ( contour , e0 . object . index , resultsA . index ) ; e0 . object . splitError1 = computeSideError ( contour , resultsA . index , e1 . object . index ) ; if ( e0 . object . splitLocation >= contour . size ( ) ) throw new RuntimeException ( "Egads" ) ; }
Selects and splits the side defined by the e0 corner . If convex a check is performed to ensure that the polyline will be convex still .