Esempio n. 1
0
        /// <summary>
        /// Calculate intersection of all footprints in the given set of floors (converted into the space of this floor)
        /// </summary>
        /// <param name="floors"></param>
        /// <returns></returns>
        private IReadOnlyList <Vector2> IntersectionOfFootprints(IReadOnlyList <IFloor> floors)
        {
            Contract.Requires(floors != null);
            Contract.Ensures(Contract.Result <IReadOnlyList <Vector2> >() != null);

            var c = new Clipper();

            //Transform all floor footprints into the space of this floor, and intersect them
            //This is the allowable space for placing a new vertical element between these floors
            var results = c.IntersectAll(floors
                                         .Select(f => f
                                                 .Bounds
                                                 .Footprint
                                                 .Select(a => Vector3
                                                         .Transform(a.X_Y(0), f.InverseWorldTransformation * WorldTransformation)
                                                         .XZ()
                                                         )
                                                 )
                                         ).ToArray();

            //Return the one with the largest area
            return(results
                   .Select(a => a.ToArray())
                   .MaxItem(a => Math.Abs(a.Area())));
        }