/// <summary>
        /// If this extents were a rectangle, this would return the borders of the
        /// rectangle that fall within the specified extents.
        /// </summary>
        /// <param name="Ext">An Extents object specifying the region to return segments from.</param>
        /// <returns>A List of Segments containing any segments that have any intersection with Ext</returns>
        public List <Segment> SegmentsWithin(Extents Ext)
        {
            List <Segment> SegList = new List <Segment>();
            Segment        seg     = new Segment(xMin, yMin, xMin, yMax);

            if (Ext.IntersectWith(seg))
            {
                SegList.Add(seg);
            }
            seg = new Segment(xMax, yMin, xMax, yMax);
            if (Ext.IntersectWith(seg))
            {
                SegList.Add(seg);
            }
            seg = new Segment(xMin, yMin, xMax, yMin);
            if (Ext.IntersectWith(seg))
            {
                SegList.Add(seg);
            }
            seg = new Segment(xMin, yMax, xMax, yMax);
            if (Ext.IntersectWith(seg))
            {
                SegList.Add(seg);
            }
            return(SegList);
        }
        /// <summary>
        /// Tests to see if any of the boundaries are the same or touch.
        /// </summary>
        /// <param name="Ext">The Extents object to compare with.</param>
        /// <returns>True if any of the extents are the same.</returns>
        bool TouchesTheBoundaryOf(Extents Ext)
        {
            if (Ext.IntersectWith(this) == false)
            {
                return(false);
            }
            List <Segment> MySegs = SegmentsWithin(Ext);

            for (int I = 0; I < MySegs.Count; I++)
            {
                if (MySegs[I].TouchesTheBoundaryOf(Ext))
                {
                    return(true);
                }
            }
            List <Segment> Segs = Ext.SegmentsWithin(this);

            for (int J = 0; J < Segs.Count; J++)
            {
                if (Segs[J].TouchesTheBoundaryOf(this))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Returns a list of segments from the Polyline that are within the
        /// submitted extents.
        /// </summary>
        /// <param name="Ext">Extents to check for an intersection with.</param>
        /// <returns>Returns a list of possible Extents within range.</returns>
        public List <Segment> SegmentsWithin(Extents Ext)
        {
            List <Segment> SegList = new List <Segment>();
            Segment        seg;

            for (int iPoint = 0; iPoint < Points.Count - 1; iPoint++)
            {
                seg = new Segment(Points[iPoint], Points[iPoint + 1]);
                if (Ext.IntersectWith(seg))
                {
                    SegList.Add(seg);
                }
            }
            return(SegList);
        }
 /// <summary>
 /// This returns true if either endpoint touchest any of the boundaries of the extents.
 /// This does not distinguish between whether this object is inside or outside or
 /// overlapping with the extent borders, simply that one endpoint touches.
 /// </summary>
 /// <param name="Ext">The extents to compare to.</param>
 /// <returns></returns>
 public bool TouchesTheBoundaryOf(Extents Ext)
 {
     if (Ext.IntersectWith(this) == false)
     {
         return(false);
     }
     if (Ext.xMin == X1)
     {
         if (Ext.yMin <= Y1 && Y1 <= Ext.yMax)
         {
             return(true);
         }
     }
     if (Ext.xMin == X2)
     {
         if (Ext.yMin <= Y2 && Y2 <= Ext.yMax)
         {
             return(true);
         }
     }
     if (Ext.yMin == Y1)
     {
         if (Ext.xMin <= X1 && X1 <= Ext.xMax)
         {
             return(true);
         }
     }
     if (Ext.yMax == Y2)
     {
         if (Ext.xMin <= X2 && X2 <= Ext.xMax)
         {
             return(true);
         }
     }
     return(false);
 }