} // public void Select( Envelope searchEnv, MonotoneChainSelectAction mcs ) private void ComputeSelect( Envelope searchEnv, int start0, int end0, MonotoneChainSelectAction mcs) { Coordinate p0 = _pts[start0]; Coordinate p1 = _pts[end0]; _env1.Initialize(p0, p1); //Trace.WriteLine( "trying:" + p0.ToString() + p1.ToString() + " [ " + start0.ToString() + ", " + end0.ToString() + " ]"); // terminating condition for the recursion if (end0 - start0 == 1) { //Trace.WriteLine("ComputeSelect:" + p0.ToString() + p1.ToString() ); mcs.Select(this, start0); return; } // nothing to do if the envelopes don't overlap if (!searchEnv.Intersects(_env1)) { return; } // the chains overlap, so split each in half and iterate (binary search) int mid = (start0 + end0) / 2; // Assert: mid != start or end (since we checked above for end - start <= 1) // check terminating conditions before recursing if (start0 < mid) { ComputeSelect(searchEnv, start0, mid, mcs); } if (mid < end0) { ComputeSelect(searchEnv, mid, end0, mcs); } } // private void ComputeSelect(...
} // public void Select( Envelope searchEnv, MonotoneChainSelectAction mcs ) private void ComputeSelect( Envelope searchEnv, int start0, int end0, MonotoneChainSelectAction mcs ) { Coordinate p0 = _pts[start0]; Coordinate p1 = _pts[end0]; _env1.Initialize( p0, p1 ); //Trace.WriteLine( "trying:" + p0.ToString() + p1.ToString() + " [ " + start0.ToString() + ", " + end0.ToString() + " ]"); // terminating condition for the recursion if (end0 - start0 == 1) { //Trace.WriteLine("ComputeSelect:" + p0.ToString() + p1.ToString() ); mcs.Select( this, start0 ); return; } // nothing to do if the envelopes don't overlap if ( !searchEnv.Intersects( _env1 ) ) { return; } // the chains overlap, so split each in half and iterate (binary search) int mid = ( start0 + end0 ) / 2; // Assert: mid != start or end (since we checked above for end - start <= 1) // check terminating conditions before recursing if ( start0 < mid ) { ComputeSelect( searchEnv, start0, mid, mcs ); } if ( mid < end0 ) { ComputeSelect( searchEnv, mid, end0, mcs ); } } // private void ComputeSelect(...
} // public Coordinates GetCoordinates() /// <summary> /// Determine all the line segments in the chain whose envelopes overlap /// the searchEnvelope, and process them /// </summary> /// <param name="searchEnv"></param> /// <param name="mcs"></param> public void Select( Envelope searchEnv, MonotoneChainSelectAction mcs ) { ComputeSelect( searchEnv, _start, _end, mcs ); } // public void Select( Envelope searchEnv, MonotoneChainSelectAction mcs )
} // public Coordinates GetCoordinates() /// <summary> /// Determine all the line segments in the chain whose envelopes overlap /// the searchEnvelope, and process them /// </summary> /// <param name="searchEnv"></param> /// <param name="mcs"></param> public void Select(Envelope searchEnv, MonotoneChainSelectAction mcs) { ComputeSelect(searchEnv, _start, _end, mcs); } // public void Select( Envelope searchEnv, MonotoneChainSelectAction mcs )