public Tower MakeTower() { var tower = new Tower() { Color = Palette.Aqua, Elevation = -8.0, Floors = 20, HeightLimit = 80.0, Perimeter = Shaper.Rectangle(60.0, 20.0), StoryHeight = 4.0, TargetArea = 24000.0 }; tower.Stack(); var entry = new Room() { Height = 6.0 }; tower.SetStoryHeight(0, 8.0); tower.Stories[0].Color = Palette.Granite; entry.SetPerimeter(new Vector3(30.0, -0.1), new Vector3(30.0, 6.0), 2.0); tower.Stories[1].AddCorridor(entry); var coreShaft = new Room() { Perimeter = Shaper.Rectangle(5.0, 8.0, new Vector3(27.5, 6.0)) }; for (int i = 1; i < 3; i++) { tower.Stories[i].Color = Palette.Green; tower.SetStoryHeight(i, 6.0); tower.Stories[i].RoomsByDivision(4, 1, 5.5, 0.5, "Retail", Palette.Lime); tower.Stories[i].AddExclusion(coreShaft); } var corridor = new Room() { Height = 3.5 }; corridor.SetPerimeter(new Vector3(0.5, 10.0), new Vector3(59.5, 10), 2.0); for (int i = 3; i < tower.Stories.Count; i++) { tower.Stories[i].RoomsByDivision(4, 2, 3.5, 0.5, "Office", Palette.Teal); tower.Stories[i].AddCorridor(corridor); tower.Stories[i].AddExclusion(coreShaft); } tower.AddCore(coreShaft.Perimeter, 0, 3.0, Palette.Granite); var model = new Model(); foreach (Space space in tower.Spaces) { model.AddElement(space); } //model.ToGlTF("../../../../Tower.glb"); return(tower); }
/// <summary> /// The MultiResidence function. /// </summary> /// <param name="model">The model. /// Add elements to the model to have them persisted.</param> /// <param name="input">The arguments to the execution.</param> /// <returns>A MultiResidenceOutputs instance containing computed results.</returns> public static MultiResidenceOutputs Execute(Model model, MultiResidenceInputs input) { var boundary = new Elements.Geometry.Polygon(ParseCoords(model, input)); var centroid = boundary.Centroid(); var site = new Mass(new Profile(boundary), 0.2, new Material("site", new Color(1.0f, 1.0f, 1.0f, 0.0f), 0.0f, 0.0f), new Transform(0.0, 0.0, 0.2)); model.AddElement(site); var tower = new Tower { Color = Palette.White, StoryHeight = 4.0, TargetArea = 0.0 }; if (input.Units < 8) { var polygon = Elements.Geometry.Polygon.Rectangle(23.0, 16.0); //if (boundary.Covers(polygon.MoveFromTo(Vector3.Origin, centroid))) //{ // model.AddElement(site); // return new MultiResidenceOutputs(0.0, 0.0, 0.0, 0.0); //} tower.Floors = (int)Math.Ceiling(input.Units / 2); tower.Perimeter = polygon; tower.Stack(); foreach (var story in tower.Stories) { story.RoomsByDivision(2, 1, 3.5, 0.1, color: Palette.Aqua); Room corridor = null; if (story.Elevation <= 0.0) { corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(0.0, -8.0), new Vector3(0.0, 8.0)).Thicken(3.0), height: 3.5); } else { corridor = new Room(perimeter: new Elements.Geometry.Line(Vector3.Origin, new Vector3(0.0, 8.0)).Thicken(3.0), height: 3.5); } story.AddCorridor(corridor); if (tower.Floors > 1) { var core = Elements.Geometry.Polygon.Rectangle(3.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(0.0, 8.0)); tower.AddCore(core, 0, 3.0, Palette.Gray); } } } else if (input.Units < 30) { var polygon = Elements.Geometry.Polygon.Rectangle(23.0, 32.0); //if (boundary.Covers(polygon.MoveFromTo(Vector3.Origin, centroid))) //{ // model.AddElement(site); // return new MultiResidenceOutputs(0.0, 0.0, 0.0, 0.0); //} tower.Floors = (int)input.Units / 4; tower.Perimeter = polygon; tower.Stack(); foreach (var story in tower.Stories) { story.RoomsByDivision(2, 1, 3.5, 0.1, color: Palette.Aqua); Room corridor = null; if (story.Elevation <= 0.0) { corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(0.0, -16.0), new Vector3(0.0, 16.0)).Thicken(3.0), height: 3.5); } else { corridor = new Room(perimeter: new Elements.Geometry.Line(Vector3.Origin, new Vector3(0.0, 8.0)).Thicken(3.0), height: 3.5); } story.AddCorridor(corridor); if (tower.Floors > 1) { var core = Elements.Geometry.Polygon.Rectangle(3.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(0.0, 8.0)); tower.AddCore(core, 0, 3.0, Palette.Gray); } } } else { var polygon = Elements.Geometry.Polygon.Rectangle(36.0, 32.0); //if (!boundary.Covers(polygon.MoveFromTo(Vector3.Origin, centroid))) //{ // model.AddElement(site); // return new MultiResidenceOutputs(0.0, 0.0, 0.0, 0.0); //} tower.Floors = (int)input.Units / 6; tower.Perimeter = Elements.Geometry.Polygon.Rectangle(36.0, 32.0); tower.Stack(); foreach (var story in tower.Stories) { story.RoomsByDivision(3, 2, 3.5, 0.1, color: Palette.Aqua); Room corridor = null; if (story.Elevation <= 0.0) { corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(-6.5, -16.0), new Vector3(-6.5, 16.0)).Thicken(3.0), height: 3.5); story.AddCorridor(corridor); corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(6.5, -16.0), new Vector3(6.5, 16.0)).Thicken(3.0), height: 3.5); story.AddCorridor(corridor); } else { corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(-6.5, 0.0), new Vector3(-6.5, 16.0)).Thicken(3.0), height: 3.5); story.AddCorridor(corridor); corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(6.5, 0.0), new Vector3(6.5, 16.0)).Thicken(3.0), height: 3.5); story.AddCorridor(corridor); } corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(-10.0, 0.0), new Vector3(10, 0.0)).Thicken(3.0), height: 3.5); story.AddCorridor(corridor); if (tower.Floors > 1) { var core = Elements.Geometry.Polygon.Rectangle(6.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(-8.0, 16.0)); tower.AddCore(core, 0, 3.0, Palette.Gray); core = Elements.Geometry.Polygon.Rectangle(6.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(8.0, 16.0)); tower.AddCore(core, 0, 3.0, Palette.Gray); } } } tower.MoveFromTo(Vector3.Origin, centroid); foreach (var core in tower.Cores) { model.AddElement(core.AsMass); } var unitQty = 0; var totalArea = 0.0; foreach (var story in tower.Stories) { unitQty += story.Rooms.Count; totalArea += story.Area; foreach (var mass in story.InteriorsAsMasses) { model.AddElement(mass); } model.AddElement(story.Slab); } var output = new MultiResidenceOutputs(unitQty, totalArea, Math.Abs(tower.Area / boundary.Area()), tower.Height); return(output); }