boolean savePolyline ( ) { int N = loops ? 3 : 2 ; // if a polyline of this size has already been saved then over write it CandidatePolyline c ; if ( list . size ( ) <= polylines . size + N - 1 ) { c = polylines . get ( list . size ( ) - N ) ; // sanity check if ( c . splits . size != list . size ( ) ) throw new RuntimeException ( "Egads saved polylines aren't in the expected order" ) ; } else { c = polylines . grow ( ) ; c . reset ( ) ; c . score = Double . MAX_VALUE ; } double foundScore = computeScore ( list , cornerScorePenalty , loops ) ; // only save the results if it's an improvement if ( c . score > foundScore ) { c . score = foundScore ; c . splits . reset ( ) ; c . sideErrors . reset ( ) ; Element < Corner > e = list . getHead ( ) ; double maxSideError = 0 ; while ( e != null ) { maxSideError = Math . max ( maxSideError , e . object . sideError ) ; c . splits . add ( e . object . index ) ; c . sideErrors . add ( e . object . sideError ) ; e = e . next ; } c . maxSideError = maxSideError ; return true ; } else { return false ; } }
Saves the current polyline