public bool AreOverlapping(BuildingCoordinates b1, BuildingCoordinates b2, out int[] combined) { List <int> coordinateList = new List <int>(); Rectangle r1 = b1.GetRectangle(); Rectangle r2 = b2.GetRectangle(); bool intersects = r1.IntersectsWith(r2); if (intersects) { // Left side of first building coordinateList.Add(b1.X1); coordinateList.Add(b1.Y1); combined = null; } else { // Now calculate the X, Y, X, Y, ... coordinate list coordinateList.Add(b1.X1); coordinateList.Add(b1.Y1); coordinateList.Add(b1.X2); coordinateList.Add(b1.Y2); coordinateList.Add(b2.X1); coordinateList.Add(b2.Y1); coordinateList.Add(b2.X2); coordinateList.Add(b2.Y2); combined = coordinateList.ToArray(); } return(intersects); }
public static bool AreOverlapping(BuildingCoordinates b1, BuildingCoordinates b2, out int[] resultingBuildingProfile) { bool isOverlapping = false; Rectangle r1 = GetRectangleFromBuildingCoordinate(b1); Rectangle r2 = GetRectangleFromBuildingCoordinate(b2); // Are these intersecting (overlapping)? Rectangle r3 = Rectangle.Intersect(r1, r2); isOverlapping = !r3.IsEmpty; Rectangle r4 = Rectangle.Union(r1, r2); //Create a simple region. Region region1 = new Region(r1); // Extract the region data. System.Drawing.Drawing2D.RegionData region1Data = region1.GetRegionData(); byte[] data1; data1 = region1Data.Data; //var region = new Region(r1); //region.Exclude(r2); resultingBuildingProfile = null; return(isOverlapping); }
public BuildingCoordinates GetScaledCoordinates(int canvasWidth, int canvasHeight, int XMax, int YMax) { int left, height, right; left = ScaleX(this.Left, canvasWidth, XMax); right = ScaleX(this.Right, canvasWidth, XMax); height = ScaleY(this.Height, canvasHeight, YMax); BuildingCoordinates b = new BuildingCoordinates(left, height, right); return(b); }
public Rectangle GetScaledRectangle(int canvasWidth, int canvasHeight, int XMax, int YMax) { BuildingCoordinates b = GetScaledCoordinates(canvasWidth, canvasHeight, XMax, YMax); return(b.GetRectangle()); }
private static Rectangle GetRectangleFromBuildingCoordinate(BuildingCoordinates b) { return(new Rectangle(b.Left, 0, b.Right - b.Left, b.Height)); }