Beispiel #1
0
 /// <summary>
 /// Creates and sets a rectangular Room Perimeter with dimensions derived from Room characteristics with its southwest corner at the origin or at the 2D location specified by the supplied Vector3.
 /// </summary>
 /// <returns>
 /// True if the Perimeter is successfully set.
 /// </returns>
 public bool SetPerimeter(Vector3 moveTo = null, double width = 0.0)
 {
     if (width > 0.0)
     {
         if (DesignSet)
         {
             Perimeter = Shaper.Rectangle(DesignLength * DesignWidth / width, width, moveTo);
             return(true);
         }
         else if (DesignArea > 0.0)
         {
             Perimeter = Shaper.Rectangle(DesignArea / width, width, moveTo);
             return(true);
         }
     }
     else if (DesignSet)
     {
         Perimeter = Shaper.Rectangle(DesignLength, DesignWidth, moveTo);
         return(true);
     }
     else if (DesignArea > 0.0 && DesignRatio > 0.0)
     {
         Perimeter = Shaper.RectangleByArea(DesignArea, DesignRatio, moveTo);
         return(true);
     }
     return(false);
 }
Beispiel #2
0
 /// <summary>
 /// Creates and sets a rectangular Room Perimeter with dimensions derived from Room characteristics with its southwest corner at the supplied Vector3 point. If no point is supplied, the southwest corner is placed at the origin.
 /// </summary>
 /// <param name="area">Area override for the new Room Perimeter. If zero, defaults to the value of DesignArea.</param>
 /// <param name="ratio">Desired ratio of X to Y Room dimensions.</param>
 /// <param name="moveTo">Vector3 location of the new Polygon's southwest corner.</param>
 /// <returns>
 /// True if the Perimeter is successfully set.
 /// </returns>
 public bool SetPerimeter(double area, double ratio = 1.0, Vector3 moveTo = null)
 {
     if (area <= 0.0 || ratio <= 0.0)
     {
         return(false);
     }
     Perimeter = Shaper.RectangleByArea(area, ratio, moveTo);
     return(true);
 }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="suite"></param>
        /// <returns></returns>
        private void PlaceByAxis()
        {
            if (Rooms.Count == 0)
            {
                return;
            }
            var area = 0.0;

            foreach (var room in Rooms)
            {
                area += room.Area;
            }
            var roomRows = new List <RoomRow>();

            while (RoomsPlaced.Count < Rooms.Count)
            {
                roomRows.Clear();
                Perimeter = Shaper.RectangleByArea(area * 0.5, Ratio);
                var roomRow = new RoomRow(Perimeter);
                roomRows.Add(roomRow);
                var i = 0;
                while (i < Rooms.Count)
                {
                    if (!roomRow.AddRoomFitted(Rooms[i], false))
                    {
                        break;
                    }
                    i++;
                }
                if (i == Rooms.Count)
                {
                    return;
                }
                var compass  = Perimeter.Compass();
                var row      = new Line(compass.SE, compass.SW);
                var matchRow = new RoomRow(row, area / row.Length());
                roomRows.Add(matchRow);
                while (i < Rooms.Count)
                {
                    if (!matchRow.AddRoomFitted(Rooms[i], false))
                    {
                        break;
                    }
                    i++;
                }
                Ratio += 0.1;
            }
            Rooms.Clear();
            foreach (var roomRow in roomRows)
            {
                foreach (var room in roomRow.Rooms)
                {
                    Rooms.Add(room);
                }
            }
            Perimeter = Footprint;
        }
Beispiel #4
0
 /// <summary>
 /// Constructor creates a Room by a positive area and a positive x : y dimension ratio and a positive height with the SW corner at the origin.
 /// </summary>
 public Room(double area, double ratio, double height)
 {
     area        = area.NearEqual(0.0) ? 1.0 : Math.Round(Math.Abs(area), PRECISION);
     ratio       = ratio.NearEqual(0.0) ? 1.0 : Math.Round(Math.Abs(ratio), PRECISION);
     height      = height.NearEqual(0.0) ? 1.0 : Math.Round(Math.Abs(height), PRECISION);
     Color       = Palette.White;
     Department  = "";
     DesignArea  = area;
     DesignRatio = ratio;
     Height      = height;
     Name        = "";
     Number      = "";
     Perimeter   = Shaper.RectangleByArea(area, ratio);
     elevation   = 0.0;
     Placed      = false;
     Suite       = "";
     SuiteID     = "";
     UniqueID    = Guid.NewGuid().ToString();
 }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="suite"></param>
        /// <returns></returns>
        private void PlaceReciprocal()
        {
            if (Rooms.Count == 0)
            {
                return;
            }
            var area = 0.0;

            foreach (var room in Rooms)
            {
                area += room.Area;
            }
            var roomRows = new List <RoomRow>();

            while (RoomsPlaced.Count < Rooms.Count)
            {
                roomRows.Clear();
                Perimeter = Shaper.RectangleByArea(area, Ratio);
                var roomRow = new RoomRow(Perimeter);
                roomRows.Add(roomRow);
                var i = 0;
                while (i < Rooms.Count)
                {
                    if (!roomRow.AddRoomFitted(Rooms[i], false))
                    {
                        break;
                    }
                    i++;
                }
                if (i == Rooms.Count)
                {
                    return;
                }
                var perimeter = Shaper.Differences(roomRow.Perimeter.ToList(), roomRow.Footprint.ToList());
                if (perimeter.Count == 0)
                {
                    break;
                }
                var matchRow = new RoomRow(perimeter.First());
                roomRows.Add(matchRow);
                while (i < Rooms.Count)
                {
                    if (!matchRow.AddRoomFitted(Rooms[i], true))
                    {
                        break;
                    }
                    i++;
                }
                Ratio += 0.1;
            }
            Rooms.Clear();
            foreach (var roomRow in roomRows)
            {
                foreach (var room in roomRow.Rooms)
                {
                    Rooms.Add(room);
                }
            }
            //2020.07.09 Anthony Hauck
            //Commented code makes suite geometric room diffs into one or more extra rooms.
            //Overall the results were more confusing that just ignoring them, but leaving
            //this here in case future developers have a better idea.
            //var lastRow = roomRows.Last();
            //var rooms = lastRow.RoomsAsPolygons;
            //var diffs = lastRow.Perimeter.Difference(rooms).ToList();
            //if (diffs.Count > 0)
            //{
            //    var height = lastRow.Rooms.Last().Height;
            //    diffs = Shaper.Merge(diffs);
            //    foreach (var diff in diffs)
            //    {
            //        Rooms.Add(
            //            new Room(diff, height)
            //            {
            //                Color = Palette.White
            //            });
            //    }
            //}
            Perimeter = Footprint;
        }