Пример #1
0
        /// <summary>
        /// Get a set of vertical elements which start on this floor
        /// </summary>
        /// <param name="parentBuilding"></param>
        /// <returns></returns>
        private IReadOnlyList <ConstrainedVerticalSelection> ConstrainVerticalElements(IBuilding parentBuilding)
        {
            //Get all vertical selections which start on this floor
            var starting = parentBuilding
                           .Verticals(FloorIndex, FloorIndex)
                           .Where(a => a.StartingFloor() == FloorIndex)
                           .ToArray();

            //Create somewhere to put results
            var results = new ConstrainedVerticalSelection[starting.Length];

            //Inspect all the floors which overlap each vertical, and constrain the area the vertical can be placed in
            for (var i = 0; i < starting.Length; i++)
            {
                var verticalSelection = starting[i];

                //Get all floors this feature overlaps
                var crossedFloors = (
                    from f in Enumerable.Range(verticalSelection.Bottom, verticalSelection.Top - verticalSelection.Bottom + 1)
                    select parentBuilding.Floor(f)
                    ).ToArray();

                //Calculate the intersection of all crossed floor footprints
                var intersection = IntersectionOfFootprints(crossedFloors);

                results[i] = new ConstrainedVerticalSelection(verticalSelection, intersection);
            }

            return(results);
        }