/// <summary>
		/// Return a list of the monotone chains
		/// for the given list of coordinates.
		/// </summary>
		/// <param name="pts"></param>
		/// <returns></returns>
		public static ArrayList GetChains(Coordinates pts)
		{
			ArrayList mcList = new ArrayList();
			int[] startIndex = GetChainStartIndices( pts );
			for ( int i = 0; i < startIndex.Length - 1; i++ ) 
			{
				MonotoneChain mc = new MonotoneChain( pts, startIndex[i], startIndex[i + 1] );
				mcList.Add( mc );
			} // for ( int i = 0; i < startIndex.Length - 1; i++ )
			return mcList;
		} // public static ArrayList GetChains(Coordinates pts)
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mc"></param>
 /// <param name="start"></param>
 public void Select(MonotoneChain mc, int start)
 {
     mc.GetLineSegment(start, ref _seg);
     Select(_seg);                               // this does nothing...
 }
Esempio n. 3
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="rayEnv"></param>
		/// <param name="mcSelecter"></param>
		/// <param name="mc"></param>
		private void TestMonotoneChain(Envelope rayEnv, MCSelecter mcSelecter, MonotoneChain mc)
		{
			mc.Select(rayEnv, mcSelecter);
		}
 /// <summary>
 /// This function can be overridden if the original chains are needed.
 /// </summary>
 /// <param name="mc1"></param>
 /// <param name="start1"></param>
 /// <param name="mc2"></param>
 /// <param name="start2"></param>
 public void Overlap(MonotoneChain mc1, int start1, MonotoneChain mc2, int start2)
 {
     mc1.GetLineSegment(start1, ref _seg1);
     mc2.GetLineSegment(start2, ref _seg2);
     Overlap(_seg1, _seg2); // This does nothing.
 }                          // public void Overlap(MonotoneChain mc1, int start1, MonotoneChain mc2, int start2)
Esempio n. 5
0
		} // public void ComputeOverlaps( MonotoneChain mc, MonotoneChainOverlapAction mco )


		private void ComputeOverlaps(
			int start0, int end0,
			MonotoneChain mc,
			int start1, int end1,
			MonotoneChainOverlapAction mco)
		{
			Coordinate p00 = _pts[start0];
			Coordinate p01 = _pts[end0];
			Coordinate p10 = mc.GetCoordinates()[start1];
			Coordinate p11 = mc.GetCoordinates()[end1];
			//Trace.WriteLine( "ComputeIntersectsForChain:" + p00.ToString() + p01.ToString() + p10.ToString() + p11.ToString() );

			// 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
			_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 )
				{
					ComputeOverlaps( start0, mid0, mc, start1,  mid1, mco );
				}
				if (mid1 < end1)
				{
					ComputeOverlaps( start0, mid0, mc, mid1,    end1, mco );
				}
			} // if ( start0 < mid0 )
			if ( mid0 < end0 ) 
			{
				if ( start1 < mid1 )
				{
					ComputeOverlaps(mid0,   end0, mc, start1,  mid1, mco);
				}
				if ( mid1 < end1 )   
				{
					ComputeOverlaps(mid0,   end0, mc, mid1,    end1, mco);
				}
			} // if ( mid0 < end0 )
		} // private void ComputeOverlaps(...
Esempio n. 6
0
		} // private void ComputeSelect(...

		/// <summary>
		/// 
		/// </summary>
		/// <param name="mc"></param>
		/// <param name="mco"></param>
		public void ComputeOverlaps( MonotoneChain mc, MonotoneChainOverlapAction mco )
		{
			ComputeOverlaps( _start, _end, mc, mc.StartIndex, mc.EndIndex, mco );
		} // public void ComputeOverlaps( MonotoneChain mc, MonotoneChainOverlapAction mco )
		/// <summary>
		/// 
		/// </summary>
		/// <param name="mc"></param>
		/// <param name="start"></param>
		public void Select( MonotoneChain mc, int start )
		{
			mc.GetLineSegment( start, ref _seg );
			Select( _seg );			// this does nothing...
		}
		/// <summary>
		/// This function can be overridden if the original chains are needed.
		/// </summary>
		/// <param name="mc1"></param>
		/// <param name="start1"></param>
		/// <param name="mc2"></param>
		/// <param name="start2"></param>
		public void Overlap(MonotoneChain mc1, int start1, MonotoneChain mc2, int start2)
		{
			mc1.GetLineSegment( start1, ref _seg1 );
			mc2.GetLineSegment( start2, ref _seg2 );
			Overlap( _seg1, _seg2 );		// This does nothing.
		} // public void Overlap(MonotoneChain mc1, int start1, MonotoneChain mc2, int start2)
Esempio n. 9
0
        }         // private void ComputeSelect(...

        /// <summary>
        ///
        /// </summary>
        /// <param name="mc"></param>
        /// <param name="mco"></param>
        public void ComputeOverlaps(MonotoneChain mc, MonotoneChainOverlapAction mco)
        {
            ComputeOverlaps(_start, _end, mc, mc.StartIndex, mc.EndIndex, mco);
        }         // public void ComputeOverlaps( MonotoneChain mc, MonotoneChainOverlapAction mco )