Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inputs"></param>
        /// <param name="roomDefs"></param>
        /// <returns></returns>
        public static List <Suite> PlaceSuites(PlanByProgramInputs inputs, List <RoomDefinition> roomDefs)
        {
            bool northeast = true;
            bool minCoord  = true;
            bool diagonal  = inputs.DiagonalAdjacency;

            if (inputs.PrimaryDirection == PrimaryDirection.Southwest)
            {
                northeast = false;
            }
            if (inputs.CoordinateAdjacency == CoordinateAdjacency.Maximum)
            {
                minCoord = false;
            }
            var suites     = SuiteMaker(inputs, roomDefs, inputs.SuiteRatio);
            var footPrints = new List <Polygon>
            {
                suites.First().CompassCorridor.Box
            };
            var anchorSuite = suites.First();
            var elevation   = 0.0;
            var height      = 0.0;

            foreach (var suite in suites.Skip(1))
            {
                var testHeight = suite.Rooms.OrderByDescending(r => r.Height).First().Height;
                if (testHeight > height)
                {
                    height = testHeight;
                }
                var footprint = PlaceAdjacentToSuite(anchorSuite.CompassCorridor.Box,
                                                     suite.CompassCorridor.Box,
                                                     footPrints,
                                                     northeast,
                                                     minCoord,
                                                     diagonal);

                if (footprint == null && inputs.MultipleLevels == true)
                {
                    elevation += height + inputs.PlenumHeight;
                    footPrints.Clear();
                    footprint   = suite.CompassCorridor.Box;
                    anchorSuite = suite;
                }
                if (footprint == null && inputs.MultipleLevels == false)
                {
                    footprint = PlaceAdjacentToFootprint(suite.CompassCorridor.Box, footPrints, diagonal);
                    if (footprint != null)
                    {
                        height = 0.0;
                    }
                }
                if (footprint == null)
                {
                    continue;
                }
                if (!Shaper.NearEqual(suite.CompassCorridor.AspectRatio, footprint.Compass().AspectRatio))
                {
                    suite.Rotate(Vector3.Origin, 90.0);
                }
                suite.MoveFromTo(suite.CompassCorridor.SW, footprint.Compass().SW);
                suite.Elevation = elevation;
                footPrints.Add(suite.CompassCorridor.Box);
                footPrints = Shaper.Merge(footPrints);
            }
            return(suites);
        }
Beispiel #2
0
        public void PlaceOrthogonal()
        {
            var polygon = new Polygon
                          (
                new[]
            {
                Vector3.Origin,
                new Vector3(10.0, 0.0),
                new Vector3(10.0, 6.0),
                new Vector3(0.0, 6.0)
            }
                          );
            var place = new Polygon
                        (
                new[]
            {
                Vector3.Origin,
                new Vector3(6.0, 0.0),
                new Vector3(6.0, 3.0),
                new Vector3(0.0, 3.0)
            }
                        );

            // Horizontal polygon, northeast, minimum coord
            place = Shaper.PlaceOrthogonal(polygon, place, true, true);
            var points = place.Vertices;

            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, 6.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, 9.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 6.0) && Shaper.NearEqual(p.Y, 6.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 6.0) && Shaper.NearEqual(p.Y, 9.0));

            // Vertical polygon, northeast, minimum coord
            polygon = polygon.Rotate(Vector3.Origin, 90.0);
            place   = Shaper.PlaceOrthogonal(polygon, place, true, true);
            points  = place.Vertices;
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, 6.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 3.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 3.0) && Shaper.NearEqual(p.Y, 6.0));

            // Horizontal polygon, northeast, maximum coord
            polygon = polygon.Rotate(Vector3.Origin, -90.0);
            place   = Shaper.PlaceOrthogonal(polygon, place, true, false);
            points  = place.Vertices;
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 10.0) && Shaper.NearEqual(p.Y, 6.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 10.0) && Shaper.NearEqual(p.Y, 9.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 4.0) && Shaper.NearEqual(p.Y, 6.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 4.0) && Shaper.NearEqual(p.Y, 9.0));

            // Vertical polygon, northeast, maximum coord
            polygon = polygon.Rotate(Vector3.Origin, 90.0);
            place   = Shaper.PlaceOrthogonal(polygon, place, true, false);
            points  = place.Vertices;
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, 10.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 3.0) && Shaper.NearEqual(p.Y, 10.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, 4.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 3.0) && Shaper.NearEqual(p.Y, 4.0));

            // Horizontal polygon, southwest, minimum coord
            polygon = polygon.Rotate(Vector3.Origin, -90.0);
            place   = Shaper.PlaceOrthogonal(polygon, place, false, true);
            points  = place.Vertices;
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 6.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 0.0) && Shaper.NearEqual(p.Y, -3.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 6.0) && Shaper.NearEqual(p.Y, -3.0));

            // Vertical polygon, southwast, minimum coord
            polygon = polygon.Rotate(Vector3.Origin, 90.0);
            place   = Shaper.PlaceOrthogonal(polygon, place, false, true);
            points  = place.Vertices;
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -6.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -9.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -6.0) && Shaper.NearEqual(p.Y, 6.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -9.0) && Shaper.NearEqual(p.Y, 6.0));

            // Horizontal polygon, southwest, maximum coord
            polygon = polygon.Rotate(Vector3.Origin, -90.0);
            place   = Shaper.PlaceOrthogonal(polygon, place, false, false);
            points  = place.Vertices;
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 4.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 10.0) && Shaper.NearEqual(p.Y, 0.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 4.0) && Shaper.NearEqual(p.Y, -3.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, 10.0) && Shaper.NearEqual(p.Y, -3.0));

            // Vertical polygon, southwest, maximum coord
            polygon = polygon.Rotate(Vector3.Origin, 90.0);
            place   = Shaper.PlaceOrthogonal(polygon, place, false, false);
            points  = place.Vertices;
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -6.0) && Shaper.NearEqual(p.Y, 10.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -9.0) && Shaper.NearEqual(p.Y, 10.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -6.0) && Shaper.NearEqual(p.Y, 4.0));
            Assert.Contains(points, p => Shaper.NearEqual(p.X, -9.0) && Shaper.NearEqual(p.Y, 4.0));
        }