/// <summary>
        /// This specifically checks the borders to see if any of the segments
        /// completely cross over each other.  Touching or overlapping won't
        /// evaluate as true.
        /// </summary>
        /// <param name="Ext">The extents object to compare with.</param>
        /// <returns>Boolean, true if any of the segments from this </returns>
        bool IsCrossedByTheOutlineOf(Extents Ext)
        {
            // the two extents have to intersect for crossing to be possible, which takes longer to check.
            if (IntersectWith(Ext) == false)
            {
                return(false);
            }
            List <Segment> MySegs = ToSegments();
            List <Segment> Segs   = Ext.ToSegments();

            for (int I = 0; I < MySegs.Count; I++)
            {
                for (int J = 0; J < Segs.Count; J++)
                {
                    if (MySegs[I].Crosses(Segs[J]))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 /// <summary>
 /// checks to ensure that this Extents completely contains the specified extents.
 /// </summary>
 /// <param name="Ext">The extents to compare to this extents</param>
 /// <returns>Boolean, true if the specified extents is within this extents without touching the borders</returns>
 public bool CompletelyContains(Extents Ext)
 {
     // Interestingly, we can check the four corners.  If all of them are within this rectangle,
     // then we are completely contained.
     if (CompletelyContains(new Point(Ext.xMin, Ext.yMin)) == false)
     {
         return(false);
     }
     if (CompletelyContains(new Point(Ext.xMin, Ext.yMax)) == false)
     {
         return(false);
     }
     if (CompletelyContains(new Point(Ext.xMax, Ext.yMin)) == false)
     {
         return(false);
     }
     if (CompletelyContains(new Point(Ext.xMax, Ext.yMax)) == false)
     {
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// Finds the shortest path starting at this extents and ending at the specified one.
        /// </summary>
        /// <param name="Ext">The Topology2D.Extents object to compare to.</param>
        /// <returns>Either a Topology2D.Segment with a startpoint on this object's borders
        /// and an endpoint on the specified extents, or null if the two intersect.</returns>
        public Segment ShortestPathTo(Extents Ext)
        {
            if (IntersectWith(Ext) == true)
            {
                return(null);
            }


            List <Segment> Segs         = Ext.ToSegments();
            double         Dist         = double.PositiveInfinity;
            Segment        ShortestPath = new Segment();

            for (int I = 0; I < Segs.Count; I++)
            {
                Segment path = ShortestPathTo(Segs[I]);
                if (path.Length < Dist)
                {
                    Dist         = path.Length;
                    ShortestPath = path;
                }
            }
            return(ShortestPath);
        }
 /// <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);
 }
Beispiel #5
0
        /// <summary>
        /// Creates a new instance of the polyline class
        /// </summary>
        /// <param name="mwShape">A MapWinGIS.Shape to derive the polyline from</param>
        /// <remarks>Assumes shape is one part.  To Split Multipart shapes, use Split.</remarks>
        public PolyLine(MapWinGIS.Shape mwShape)
        {
            if (Adapter.GetCategory(mwShape) != ShapeCategories.Line)
            {
                throw new ArgumentException("The Split method only takes Polyline shape types.");
            }
            m_Extents    = new Extents(mwShape.Extents);
            extentsValid = true; // When adding all the points at once, we have no problem.

            m_Length    = 0;
            lengthValid = false; // Calculate this only if it is needed

            m_Center    = new Point((m_Extents.xMin + m_Extents.xMax) / 2, (m_Extents.yMin + m_Extents.yMax) / 2);
            centerValid = true; // since extents were ok already, we can quickly find the center

            m_MaxRadius    = 0;
            maxradiusValid = false; // Calculate this only if it is needed

            m_Points = new List <Point>();
            for (int I = 0; I < mwShape.NumParts; I++)
            {
                Add_Point(mwShape.get_Point(I));
            }
        }
 /// <summary>
 /// For completeness.  Simply tests if the Extents specified contains these extents.
 /// </summary>
 /// <param name="Ext">The extents to compare against these extents</param>
 /// <returns>Boolean, true if every corner of this rectangle intersects with the specified rectangle.</returns>
 bool IsContainedBy(Extents Ext)
 {
     return(Ext.Contains(this));
 }
 /// <summary>
 /// For completeness.  Simply tests if the specified extents contain these
 /// extents completely so that no borders are touching.
 /// </summary>
 /// <param name="Ext">The extents to compare against</param>
 /// <returns>Boolean, true if all the points of this extents lie within the other extents.</returns>
 bool IsCompletelyWithin(Extents Ext)
 {
     return(Ext.CompletelyContains(this));
 }
        /// <summary>
        /// Returns a new instance of the Extents class with the same values as this object.
        /// </summary>
        /// <returns>Topology2D.Extents with identical properties.</returns>
        public Extents Copy()
        {
            Extents NewExt = new Extents(xMin, xMax, yMin, yMax);

            return(NewExt);
        }