private static Polygon PlaceAdjacentToFootprint(Polygon suitBox, List <Polygon> footPrints, bool diagonal) { Polygon footPrint = null; foreach (var ftPrint in footPrints) { footPrint = Shaper.PlaceOrthogonal(ftPrint, suitBox, true, true); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceOrthogonal(ftPrint, suitBox, true, false); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceOrthogonal(ftPrint, suitBox, false, true); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceOrthogonal(ftPrint, suitBox, false, false); if (!footPrint.Intersects(footPrints)) { return(footPrint); } if (!diagonal) { continue; } footPrint = Shaper.PlaceDiagonal(ftPrint, suitBox, Corner.NE); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceDiagonal(ftPrint, suitBox, Corner.SE); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceDiagonal(ftPrint, suitBox, Corner.NW); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceDiagonal(ftPrint, suitBox, Corner.SW); if (!footPrint.Intersects(footPrints)) { return(footPrint); } } return(footPrint); }
private static Polygon PlaceAdjacentToSuite(Polygon lastBox, Polygon suitBox, List <Polygon> footPrints, bool northeast, bool minCoord, bool diagonal) { var footPrint = Shaper.PlaceOrthogonal(lastBox, suitBox, northeast, minCoord); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceOrthogonal(lastBox, suitBox, northeast, !minCoord); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceOrthogonal(lastBox, suitBox, !northeast, minCoord); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceOrthogonal(lastBox, suitBox, !northeast, !minCoord); if (!footPrint.Intersects(footPrints)) { return(footPrint); } var corners = new List <Corner>(); if (!diagonal) { return(null); } if (northeast) { corners.Add(Corner.NE); corners.Add(Corner.NW); corners.Add(Corner.SE); corners.Add(Corner.SW); } else { corners.Add(Corner.SW); corners.Add(Corner.SE); corners.Add(Corner.NW); corners.Add(Corner.NE); } footPrint = Shaper.PlaceDiagonal(lastBox, suitBox, corners[0]); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceDiagonal(lastBox, suitBox, corners[1]); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceDiagonal(lastBox, suitBox, corners[2]); if (!footPrint.Intersects(footPrints)) { return(footPrint); } footPrint = Shaper.PlaceDiagonal(lastBox, suitBox, corners[3]); if (!footPrint.Intersects(footPrints)) { return(footPrint); } return(null); }