Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to place a Room perimeter on the next open segment of the row.
        /// </summary>
        /// <param name="room">Room from which to derive the Polygon to place.</param>
        /// <returns>
        /// True if the Room was successfully placed.
        /// </returns>
        public bool AddRoomFitted(Room room, bool within = true)
        {
            if (room == null ||
                insert.DistanceTo(compass.SE) < Tolerance ||
                compass.SW.DistanceTo(insert).NearEqual(compass.SW.DistanceTo(compass.SE)))
            {
                return(false);
            }
            var ratio    = room.DesignRatio > 1.0 ? 1 / room.DesignRatio : room.DesignRatio;
            var boundary = within ? new Polygon(perimeterJig.Vertices) : null;
            var polygon  =
                Shaper.RectangleByRatio(ratio).MoveFromTo(Vector3.Origin, insert)
                .ExpandToArea(room.DesignArea, ratio, Tolerance, Orient.SW, boundary, RoomsAsPolygons);

            insert         = polygon.Compass().SE;
            room.Perimeter = polygon.Rotate(Vector3.Origin, Angle);
            room.Placed    = true;
            Rooms.Add(room);
            return(true);
        }