예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchEnv"></param>
        /// <param name="start0"></param>
        /// <param name="end0"></param>
        /// <param name="mcs"></param>
        private void ComputeSelect(IEnvelope searchEnv, int start0, int end0, MonotoneChainSelectAction mcs)
        {
            ICoordinate p0 = pts[start0];
            ICoordinate p1 = pts[end0];

            mcs.TempEnv1.Init(p0, p1);

            // terminating condition for the recursion
            if (end0 - start0 == 1)
            {
                mcs.Select(this, start0);
                return;
            }
            // nothing to do if the envelopes don't overlap
            if (!searchEnv.Intersects(mcs.TempEnv1))
            {
                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);
            }
        }
예제 #2
0
 /// <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 virtual void Select(IEnvelope searchEnv, MonotoneChainSelectAction mcs)
 {
     ComputeSelect(searchEnv, start, end, mcs);
 }