/// <summary> /// Determines if the fence intersects a supplied world coordinate bounding extent /// </summary> /// <param name="extent"></param> /// <returns></returns> public bool IntersectsExtent(BoundingWorldExtent3D extent) { // Check extent vertex inclusion in the fence if (IncludesPoint(extent.MinX, extent.MinY) || IncludesPoint(extent.MinX, extent.MaxY) || IncludesPoint(extent.MaxX, extent.MinY) || IncludesPoint(extent.MaxX, extent.MaxY)) { return(true); } // Check fence vertex inclusion in Extents foreach (FencePoint pt in Points) { if (extent.Includes(pt.X, pt.Y)) { return(true); } } // Check for intersecting lines if (IncludesLine(extent.MinX, extent.MinY, extent.MinX, extent.MaxY) || IncludesLine(extent.MinX, extent.MaxY, extent.MaxX, extent.MaxY) || IncludesLine(extent.MaxX, extent.MaxY, extent.MaxX, extent.MinY) || IncludesLine(extent.MaxX, extent.MinY, extent.MinX, extent.MinY)) { return(true); } // The fence and the square do not intersect return(false); }
/// <summary> /// Determines if the fence includes a supplied world coordinate bounding extent /// </summary> /// <param name="extent"></param> /// <returns></returns> public bool IncludesExtent(BoundingWorldExtent3D extent) { // Check extent vertex inclusion in the fence if (!(IncludesPoint(extent.MinX, extent.MinY) && IncludesPoint(extent.MinX, extent.MaxY) && IncludesPoint(extent.MaxX, extent.MinY) && IncludesPoint(extent.MaxX, extent.MaxY))) { return(false); } if (IsRectangle || IsSquare) { // No Further checks are necessary, it is included return(true); } // Check fence vertex inclusion in Extents for (int i = 0, limit = Points.Count; i < limit; i++) { var pt = Points[i]; if (extent.Includes(pt.X, pt.Y)) { // There must be some area of the extent that does not reside in the filter return(false); } } // Check for intersecting lines. Intersection means at least part of the given extent must lie outside the fence if (BoundaryIntersectsLine(extent.MinX, extent.MinY, extent.MinX, extent.MaxY) || BoundaryIntersectsLine(extent.MinX, extent.MaxY, extent.MaxX, extent.MaxY) || BoundaryIntersectsLine(extent.MaxX, extent.MaxY, extent.MaxX, extent.MinY) || BoundaryIntersectsLine(extent.MaxX, extent.MinY, extent.MinX, extent.MinY)) { return(false); } // The fence must include the square return(true); }
/// <summary> /// Constructor that creates a rectangular fence from a world coordinate bounding extent /// </summary> public Fence(BoundingWorldExtent3D extent) : this(extent.MinX, extent.MinY, extent.MaxX, extent.MaxY) { }