Exemplo n.º 1
0
        }         // public void ComputeIntersectsForChain( int chainIndex0,

        private void ComputeIntersectsForChain(int start0,
                                               int end0,
                                               MonotoneChainEdge mce,
                                               int start1,
                                               int end1,
                                               SegmentIntersector ei)
        {
            Coordinate p00 = _pts[start0];
            Coordinate p01 = _pts[end0];
            Coordinate p10 = mce.Coordinates[start1];
            Coordinate p11 = mce.Coordinates[end1];

            //Debug.println("computeIntersectsForChain:" + p00 + p01 + p10 + p11);
            // terminating condition for the recursion
            if (end0 - start0 == 1 && end1 - start1 == 1)
            {
                ei.AddIntersections(_e, start0, mce.Edge, start1);
                return;
            }
            // nothing to do if the envelopes of these chains don't overlap
            _env1.Initialize(p00, p01);
            _env2.Initialize(p10, p11);
            if (!_env1.Intersects(_env2))
            {
                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)
                {
                    ComputeIntersectsForChain(start0, mid0, mce, start1, mid1, ei);
                }
                if (mid1 < end1)
                {
                    ComputeIntersectsForChain(start0, mid0, mce, mid1, end1, ei);
                }
            }
            if (mid0 < end0)
            {
                if (start1 < mid1)
                {
                    ComputeIntersectsForChain(mid0, end0, mce, start1, mid1, ei);
                }
                if (mid1 < end1)
                {
                    ComputeIntersectsForChain(mid0, end0, mce, mid1, end1, ei);
                }
            }
        }         // private void ComputeIntersectsForChain(		int start0,...
Exemplo n.º 2
0
        }         // public double GetMaxX(int chainIndex)

        /// <summary>
        ///
        /// </summary>
        /// <param name="mce"></param>
        /// <param name="si"></param>
        public void ComputeIntersects(MonotoneChainEdge mce, SegmentIntersector si)
        {
            for (int i = 0; i < _startIndex.Length - 1; i++)
            {
                for (int j = 0; j < mce.StartIndex.Length - 1; j++)
                {
                    ComputeIntersectsForChain(i, mce, j, si);
                }
            }
        }         // public void ComputeIntersects(MonotoneChainEdge mce, SegmentIntersector si)
Exemplo n.º 3
0
        }         // public void ComputeIntersects(MonotoneChainEdge mce, SegmentIntersector si)

        /// <summary>
        ///
        /// </summary>
        /// <param name="chainIndex0"></param>
        /// <param name="mce"></param>
        /// <param name="chainIndex1"></param>
        /// <param name="si"></param>
        public void ComputeIntersectsForChain(int chainIndex0,
                                              MonotoneChainEdge mce,
                                              int chainIndex1,
                                              SegmentIntersector si)
        {
            ComputeIntersectsForChain(_startIndex[chainIndex0],
                                      _startIndex[chainIndex0 + 1],
                                      mce,
                                      mce.StartIndex[chainIndex1], mce.StartIndex[chainIndex1 + 1],
                                      si);
        }         // public void ComputeIntersectsForChain( int chainIndex0,
        }         // private void Add(ArrayList edges, int geomIndex)

        private void Add(Edge edge, int geomIndex)
        {
            MonotoneChainEdge mce = edge.GetMonotoneChainEdge();

            int[] startIndex = mce.StartIndex;
            for (int i = 0; i < startIndex.Length - 1; i++)
            {
                MonotoneChain  mc          = new MonotoneChain(mce, i, geomIndex);
                SweepLineEvent insertEvent = new SweepLineEvent(geomIndex, mce.GetMinX(i), null, mc);
                _events.Add(insertEvent);
                _events.Add(new SweepLineEvent(geomIndex, mce.GetMaxX(i), insertEvent, mc));
            }
        }         // private void Add(Edge edge, int geomIndex)
Exemplo n.º 5
0
        private void ComputeIntersectsForChain(		int start0,
													int end0,
													MonotoneChainEdge mce,
													int start1,
													int end1,
													SegmentIntersector ei	)
        {
            Coordinate p00 = _pts[start0];
            Coordinate p01 = _pts[end0];
            Coordinate p10 = mce.Coordinates[start1];
            Coordinate p11 = mce.Coordinates[end1];
            //Debug.println("computeIntersectsForChain:" + p00 + p01 + p10 + p11);
            // terminating condition for the recursion
            if (end0 - start0 == 1 && end1 - start1 == 1)
            {
             	ei.AddIntersections( _e, start0, mce.Edge, start1);
             	return;
            }
            // nothing to do if the envelopes of these chains don't overlap
            _env1.Initialize(p00, p01);
            _env2.Initialize(p10, p11);
            if ( !_env1.Intersects( _env2 ) ) 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)
             	{
             		ComputeIntersectsForChain( start0, mid0, mce, start1, mid1, ei );
             	}
             	if (mid1 < end1)
             	{
             		ComputeIntersectsForChain( start0, mid0, mce, mid1, end1, ei );
             	}
            }
            if (mid0 < end0)
            {
             	if (start1 < mid1)
             	{
             		ComputeIntersectsForChain( mid0, end0, mce, start1,  mid1, ei);
             	}
             	if (mid1 < end1)
             	{
             		ComputeIntersectsForChain( mid0, end0, mce, mid1,    end1, ei);
             	}
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="chainIndex0"></param>
        /// <param name="mce"></param>
        /// <param name="chainIndex1"></param>
        /// <param name="si"></param>
        public void ComputeIntersectsForChain( int chainIndex0,
												MonotoneChainEdge mce,
												int chainIndex1,
												SegmentIntersector si	)
        {
            ComputeIntersectsForChain(	_startIndex[chainIndex0],
                                        _startIndex[chainIndex0 + 1],
             							mce,
             							mce.StartIndex[chainIndex1], mce.StartIndex[chainIndex1 + 1],
             							si );
        }
Exemplo n.º 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="mce"></param>
 /// <param name="si"></param>
 public void ComputeIntersects(MonotoneChainEdge mce, SegmentIntersector si)
 {
     for (int i = 0; i < _startIndex.Length - 1; i++)
     {
      	for (int j = 0; j <  mce.StartIndex.Length - 1; j++)
         {
             ComputeIntersectsForChain( i, mce, j, si );
         }
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the MonotoneChain class.
 /// </summary>
 public MonotoneChain(MonotoneChainEdge mce, int chainIndex, int geomIndex)
 {
     _mce        = mce;
     _chainIndex = chainIndex;
     _geomIndex  = geomIndex;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Returns the MonotoneChainEdge object.
 /// </summary>
 public MonotoneChainEdge GetMonotoneChainEdge()
 {
     if (_monotoneChainEdge == null)
         {
             _monotoneChainEdge = new MonotoneChainEdge( this );
         }
         return _monotoneChainEdge;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the MonotoneChain class.
 /// </summary>
 public MonotoneChain( MonotoneChainEdge mce, int chainIndex, int geomIndex )
 {
     _mce = mce;
     _chainIndex = chainIndex;
     _geomIndex = geomIndex;
 }