Пример #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)
        {
            Coordinate p0 = _pts[start0];
            Coordinate 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>
 /// 
 /// </summary>
 /// <param name="rayEnv"></param>
 /// <param name="mcSelecter"></param>
 /// <param name="mc"></param>
 private static void TestMonotoneChain(IEnvelope rayEnv, MonotoneChainSelectAction mcSelecter, MonotoneChain mc)
 {
     mc.Select(rayEnv, mcSelecter);
 }
Пример #3
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);
 }