예제 #1
0
        /// <summary>
        /// Adds a Room to the Corridors list.
        /// </summary>
        /// <param name="room">Room to add.</param>
        /// <returns>
        /// True if one or more Rooms were added.
        /// </returns>
        public bool AddCorridor(Room room,
                                bool merge       = true,
                                double tolerance = 0.0,
                                double minLength = 0.0)
        {
            var perimeters = Shaper.FitWithin(room.Perimeter, Perimeter);

            if (perimeters.Count == 0)
            {
                return(false);
            }
            var fitAmong = new List <Polygon>(OpeningsAsPolygons);

            fitAmong.AddRange(ExclusionsAsPolygons);
            fitAmong.AddRange(ServicesAsPolygons);
            var corridors = Shaper.Differences(perimeters, fitAmong).ToList();

            if (corridors.Count() == 0)
            {
                return(false);
            }
            corridors.AddRange(CorridorsAsPolygons);
            if (merge)
            {
                corridors = Shaper.Merge(corridors);
            }
            Corridors.Clear();
            foreach (var corridor in corridors)
            {
                Corridors.Add(
                    new Room(room)
                {
                    Elevation = Elevation,
                    Height    = room.Height,
                    Perimeter = corridor
                });
            }
            FitRooms();
            return(true);
        }