예제 #1
0
파일: Room.cs 프로젝트: kraftwerk15/RoomKit
 /// <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);
 }
예제 #2
0
파일: Room.cs 프로젝트: kraftwerk15/RoomKit
 /// <summary>
 /// Creates and sets a rectangular Room Perimeter, Height, and southwest corner location with a supplied vectors.
 /// Sets the DesignX and DesignY properties.
 /// </summary>
 /// <param name="xyz">Vector3 dimensions of a new Polygon Perimeter. If xy.Z is > 0.0, sets the height of the Room.</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 SetDimensions(Vector3 xyz, Vector3 moveTo = null)
 {
     if (xyz.X <= 0.0 || xyz.Y <= 0.0)
     {
         return(false);
     }
     perimeter = Shaper.Rectangle(xyz.X, xyz.Y, moveTo);
     height    = xyz.Z > 0.0 ? xyz.Z : height;
     return(true);
 }
예제 #3
0
        /// <summary>
        /// Clears the current Rooms list and creates new Rooms defined by orthogonal x- and y-axis divisions of the RoomGroup Perimeter.
        /// </summary>
        /// <param name="xRooms">The quantity of Rooms along orthogonal x-axis. Must be positive.</param>
        /// <param name="yRooms">The quantity of Rooms along orthogonal y-axis. Must be positive.</param>
        /// <returns>
        /// True if the Rooms are created.
        /// </returns>
        public bool RoomsByDivision(int xRooms = 1, int yRooms = 1, double height = 3.0, string name = "")
        {
            if (Perimeter == null || xRooms < 1 || yRooms < 1 || height <= 0.0)
            {
                return(false);
            }
            var sizeX    = SizeX / xRooms;
            var sizeY    = SizeY / yRooms;
            var count    = xRooms * yRooms;
            var box      = new TopoBox(Perimeter);
            var newRooms = new List <Room>();

            for (int xIdx = 0; xIdx < xRooms; xIdx++)
            {
                var xCoord = box.SW.X + (xIdx * sizeX);
                for (int yIdx = 0; yIdx < yRooms; yIdx++)
                {
                    var yCoord  = box.SW.Y + (yIdx * sizeY);
                    var polygon = Shaper.Rectangle(sizeX, sizeY);
                    polygon = polygon.MoveFromTo(Vector3.Origin, new Vector3(xCoord, yCoord)).Intersection(Perimeter).First();
                    var room = new Room()
                    {
                        Height    = height,
                        Name      = name,
                        Perimeter = polygon
                    };
                    newRooms.Add(room);
                }
            }
            if (newRooms.Count == 0)
            {
                return(false);
            }
            Rooms.Clear();
            Rooms.AddRange(newRooms);
            return(true);
        }