Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="start0"></param>
        /// <param name="end0"></param>
        /// <param name="mc"></param>
        /// <param name="start1"></param>
        /// <param name="end1"></param>
        /// <param name="mco"></param>
        private void ComputeOverlaps(int start0, int end0, MonotoneChain mc, int start1, int end1, MonotoneChainOverlapAction mco)
        {
            ICoordinate p00 = pts[start0];
            ICoordinate p01 = pts[end0];
            ICoordinate p10 = mc.pts[start1];
            ICoordinate p11 = mc.pts[end1];
            
            // terminating condition for the recursion
            if (end0 - start0 == 1 && end1 - start1 == 1)
            {
                mco.Overlap(this, start0, mc, start1);
                return;
            }
            // nothing to do if the envelopes of these chains don't overlap
            mco.TempEnv1.Init(p00, p01);
            mco.TempEnv2.Init(p10, p11);
            if (! mco.TempEnv1.Intersects(mco.TempEnv2)) 
                return;

            // the chains overlap, so split each in half and iterate  (binary search)
            int mid0 = (start0 + end0) / 2;
            int mid1 = (start1 + end1) / 2;

            // Assert: mid != start or end (since we checked above for end - start <= 1)
            // check terminating conditions before recursing
            if (start0 < mid0)
            {
                if (start1 < mid1)
                    ComputeOverlaps(start0, mid0, mc, start1, mid1, mco);
                if (mid1 < end1) 
                    ComputeOverlaps(start0, mid0, mc, mid1, end1, mco);
            }
            if (mid0 < end0)
            {
                if (start1 < mid1) 
                    ComputeOverlaps(mid0, end0, mc, start1, mid1, mco);
                if (mid1 < end1) 
                    ComputeOverlaps(mid0, end0, mc, mid1, end1, mco);
            }
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="start0"></param>
        /// <param name="end0"></param>
        /// <param name="mc"></param>
        /// <param name="start1"></param>
        /// <param name="end1"></param>
        /// <param name="mco"></param>
        private void ComputeOverlaps(int start0, int end0, MonotoneChain mc, int start1, int end1, MonotoneChainOverlapAction mco)
        {
            ICoordinate p00 = pts[start0];
            ICoordinate p01 = pts[end0];
            ICoordinate p10 = mc.pts[start1];
            ICoordinate p11 = mc.pts[end1];

            // terminating condition for the recursion
            if (end0 - start0 == 1 && end1 - start1 == 1)
            {
                mco.Overlap(this, start0, mc, start1);
                return;
            }
            // nothing to do if the envelopes of these chains don't overlap
            mco.TempEnv1.Init(p00, p01);
            mco.TempEnv2.Init(p10, p11);
            if (!mco.TempEnv1.Intersects(mco.TempEnv2))
            {
                return;
            }

            // the chains overlap, so split each in half and iterate  (binary search)
            int mid0 = (start0 + end0) / 2;
            int mid1 = (start1 + end1) / 2;

            // Assert: mid != start or end (since we checked above for end - start <= 1)
            // check terminating conditions before recursing
            if (start0 < mid0)
            {
                if (start1 < mid1)
                {
                    ComputeOverlaps(start0, mid0, mc, start1, mid1, mco);
                }
                if (mid1 < end1)
                {
                    ComputeOverlaps(start0, mid0, mc, mid1, end1, mco);
                }
            }
            if (mid0 < end0)
            {
                if (start1 < mid1)
                {
                    ComputeOverlaps(mid0, end0, mc, start1, mid1, mco);
                }
                if (mid1 < end1)
                {
                    ComputeOverlaps(mid0, end0, mc, mid1, end1, mco);
                }
            }
        }
Example #3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="mco"></param>
 public  void ComputeOverlaps(MonotoneChain mc, MonotoneChainOverlapAction mco)
 {
     ComputeOverlaps(start, end, mc, mc.start, mc.end, mco);
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="mco"></param>
 public void ComputeOverlaps(MonotoneChain mc, MonotoneChainOverlapAction mco)
 {
     ComputeOverlaps(start, end, mc, mc.start, mc.end, mco);
 }