private static boolean linearPathIntersectsEnvelope_ ( MultiPath multipath_a , Envelope2D env_b , double tolerance , ProgressTracker progress_tracker ) { if ( ! multipath_a . hasNonLinearSegments ( ) ) { Envelope2D env_b_inflated = new Envelope2D ( ) ; env_b_inflated . setCoords ( env_b ) ; env_b_inflated . inflate ( tolerance , tolerance ) ; MultiPathImpl mimpl_a = ( MultiPathImpl ) multipath_a . _getImpl ( ) ; AttributeStreamOfDbl xy = ( AttributeStreamOfDbl ) ( mimpl_a . getAttributeStreamRef ( VertexDescription . Semantics . POSITION ) ) ; Point2D pt = new Point2D ( ) ; Point2D pt_prev = new Point2D ( ) ; Point2D pt_1 = new Point2D ( ) ; Point2D pt_2 = new Point2D ( ) ; for ( int ipath = 0 , npath = mimpl_a . getPathCount ( ) ; ipath < npath ; ipath ++ ) { boolean b_first = true ; for ( int i = mimpl_a . getPathStart ( ipath ) , n = mimpl_a . getPathEnd ( ipath ) ; i < n ; i ++ ) { if ( b_first ) { xy . read ( 2 * i , pt_prev ) ; b_first = false ; continue ; } xy . read ( 2 * i , pt ) ; pt_1 . setCoords ( pt_prev ) ; pt_2 . setCoords ( pt ) ; if ( env_b_inflated . clipLine ( pt_1 , pt_2 ) != 0 ) return true ; pt_prev . setCoords ( pt ) ; } } } else { Line line_1 = new Line ( env_b . xmin , env_b . ymin , env_b . xmin , env_b . ymax ) ; Line line_2 = new Line ( env_b . xmin , env_b . ymax , env_b . xmax , env_b . ymax ) ; Line line3 = new Line ( env_b . xmax , env_b . ymax , env_b . xmax , env_b . ymin ) ; Line line4 = new Line ( env_b . xmax , env_b . ymin , env_b . xmin , env_b . ymin ) ; SegmentIterator iter = multipath_a . querySegmentIterator ( ) ; while ( iter . nextPath ( ) ) { while ( iter . hasNextSegment ( ) ) { Segment polySeg = iter . nextSegment ( ) ; if ( polySeg . isIntersecting ( line_1 , tolerance ) ) return true ; if ( polySeg . isIntersecting ( line_2 , tolerance ) ) return true ; if ( polySeg . isIntersecting ( line3 , tolerance ) ) return true ; if ( polySeg . isIntersecting ( line4 , tolerance ) ) return true ; } } } return false ; }
Returns true if the segments of multipathA intersects env_b