int splitSegment ( int origin_vertex , double [ ] split_scalars , int split_count ) { int actual_splits = 0 ; int next_vertex = getNextVertex ( origin_vertex ) ; if ( next_vertex == - 1 ) throw GeometryException . GeometryInternalError ( ) ; int vindex = getVertexIndex ( origin_vertex ) ; int vindex_next = getVertexIndex ( next_vertex ) ; Segment seg = getSegmentFromIndex_ ( vindex ) ; double seg_length = seg == null ? m_vertices . _getShortestDistance ( vindex , vindex_next ) : seg . calculateLength2D ( ) ; double told = 0.0 ; for ( int i = 0 ; i < split_count ; i ++ ) { double t = split_scalars [ i ] ; if ( told < t && t < 1.0 ) { double f = t ; if ( seg != null ) { f = seg_length > 0 ? seg . _calculateSubLength ( t ) / seg_length : 0.0 ; } m_vertices . _interpolateTwoVertices ( vindex , vindex_next , f , getHelperPoint_ ( ) ) ; // use this call mainly to // interpolate the attributes. XYs // are interpolated incorrectly for // curves and are recalculated when // segment is cut below. int inserted_vertex = insertVertex_ ( getPathFromVertex ( origin_vertex ) , next_vertex , getHelperPoint_ ( ) ) ; actual_splits ++ ; if ( seg != null ) { Segment subseg = seg . cut ( told , t ) ; int prev_vertex = getPrevVertex ( inserted_vertex ) ; int vindex_prev = getVertexIndex ( prev_vertex ) ; setSegmentToIndex_ ( vindex_prev , subseg ) ; setXY ( inserted_vertex , subseg . getEndXY ( ) ) ; // fix XY // coordinates // to be // parameter // based // (interpolate_two_vertices_) if ( i == split_count - 1 || split_scalars [ i + 1 ] == 1.0 ) { // last // chance // to // set // last // split // segment // here: Segment subseg_end = seg . cut ( t , 1.0 ) ; setSegmentToIndex_ ( vindex_prev , subseg_end ) ; } } } } return actual_splits ; }
happend ) .