private IEnumerator CreateFloors() { var floorModel = new Model(); var poly = new Polygon(new[] { Vector3.Origin, new Vector3(l1, 0, 0), new Vector3(l1, width, 0), new Vector3(width, width, 0), new Vector3(width, l2, 0), new Vector3(0, l2, 0) }); var coreHole1 = Polygon.Rectangle(3, 4, new Vector3(l1, width / 2)); var coreHole2 = Polygon.Rectangle(4, 3, new Vector3(width / 2, l2)); var profile = new Profile(poly, new[] { coreHole1, coreHole2 }); var floorType = new FloorType("100mm", 0.1); totalArea = 0.0; for (var i = 0.0; i <= height; i += floorToFloor) { var floor = new Floor(profile, floorType, i, BuiltInMaterials.Concrete); totalArea += floor.Area(); floorModel.AddElement(floor); yield return(null); } foreach (var go in next) { go.SendMessage("UpdateModel", floorModel); } yield return(floorModel.ToGameObjects(this.gameObject)); }
public void Area() { // A floor with two holes punched in it. var p1 = Polygon.Rectangle(1, 1); var p2 = Polygon.Rectangle(1, 1); var o1 = new Opening(p1, 1, 1); var o2 = new Opening(p2, 3, 3); var floor = new Floor(Polygon.Rectangle(10, 10), 0.2); Assert.Equal(100.0, floor.Area()); }
public void Area() { // A floor with two holes punched in it. var p1 = Polygon.Rectangle(new Vector3(1, 1, 0), 1, 1); var p2 = Polygon.Rectangle(new Vector3(3, 3, 0), 1, 1); var profile = new Profile(Polygon.Rectangle(Vector3.Origin, 10, 10), new[] { p1, p2 }); var floorType = new FloorType("test", 0.2); var floor = new Floor(profile, floorType, 0.0, BuiltInMaterials.Concrete); Assert.Equal(100.0 - 2.0, floor.Area()); }
public void Area() { // A floor with two holes punched in it. var p1 = Polygon.Rectangle(1, 1); var p2 = Polygon.Rectangle(1, 1); var o1 = new Opening(p1, 1, 1); var o2 = new Opening(p2, 3, 3); var floorType = new FloorType("test", 0.2); var floor = new Floor(Polygon.Rectangle(10, 10), floorType, 0.0, null, new List <Opening>() { o1, o2 }); Assert.Equal(100.0, floor.Area()); }
/// <summary> /// Generates Floors for each LevelPerimeter in the model configured ith slab thickness and setback.. /// </summary> /// <param name="model">The input model.</param> /// <param name="input">The arguments to the execution.</param> /// <returns>A FloorsByLevelsOutputs instance containing computed results and the model with any new elements.</returns> public static FloorsByLevelsOutputs Execute(Dictionary <string, Model> inputModels, FloorsByLevelsInputs input) { inputModels.Keys.ToList().ForEach(key => Console.WriteLine(key)); // Extract LevelVolumes from Levels dependency var levels = new List <LevelPerimeter>(); inputModels.TryGetValue("Levels", out var model); if (model == null || ( model.AllElementsOfType <LevelPerimeter>().Count() == 0 && model.AllElementsOfType <LevelVolume>().Count() == 0 ) ) { throw new ArgumentException("No LevelPerimeters found."); } var levelVolumes = model.AllElementsOfType <LevelVolume>(); var floorMaterial = new Material("Concrete", new Color(0.34, 0.34, 0.34, 1.0), 0.3, 0.3); levels.AddRange(model.AllElementsOfType <LevelPerimeter>()); // Extract shafts from Core dependency, if it exists var shafts = new List <Polygon>(); inputModels.TryGetValue("Core", out var core); if (core != null) { var shaftMasses = core.AllElementsOfType <Mass>(); var shaftPerimeters = shaftMasses.Where(mass => mass.Name == "void").Select(mass => mass.Profile.Perimeter.Project(new Plane(Vector3.Origin, Vector3.ZAxis))); shafts.AddRange(shaftPerimeters); } var floors = new List <Floor>(); var floorArea = 0.0; if (levelVolumes.Count() > 0) { foreach (var level in levelVolumes) { var representation = level.Representation; var profiles = representation.SolidOperations.Count > 1 ? GetProfilesFromRepresentation(representation) : new List <Profile> { level.Profile }; foreach (var profile in profiles) { var flrOffsets = profile.Offset(input.FloorSetback * -1); var elevation = level.Transform.Origin.Z; if (flrOffsets.Count() > 0) { if (shafts.Count() > 0) { flrOffsets = flrOffsets.Select(offset => CreateFloorProfile(offset.Perimeter, shafts)).ToList(); } foreach (var fo in flrOffsets) { var floor = new Floor(fo, input.FloorThickness, new Transform(0.0, 0.0, elevation - input.FloorThickness), floorMaterial, null, false, Guid.NewGuid(), null); floor.AdditionalProperties["Level"] = level.Id; floors.Add(floor); floorArea += floor.Area(); } } else { var floorProfile = shafts.Count() > 0 ? CreateFloorProfile(profile.Perimeter, shafts.Union(profile.Voids).ToList()) : profile; var floor = new Floor(floorProfile, input.FloorThickness, new Transform(0.0, 0.0, elevation - input.FloorThickness), floorMaterial, null, false, Guid.NewGuid(), null); floor.AdditionalProperties["Level"] = level.Id; floors.Add(floor); floorArea += floor.Area(); } } } } else { // Old pathway, which did not support floors with holes foreach (var level in levels) { Floor floor = null; var flrOffsets = level.Perimeter.Offset(input.FloorSetback * -1); if (flrOffsets.Count() > 0) { floor = new Floor(flrOffsets.First(), input.FloorThickness, new Transform(0.0, 0.0, level.Elevation - input.FloorThickness), floorMaterial, null, false, Guid.NewGuid(), null); } else { floor = new Floor(level.Perimeter, input.FloorThickness, new Transform(0.0, 0.0, level.Elevation - input.FloorThickness), floorMaterial, null, false, Guid.NewGuid(), null); } floors.Add(floor); floorArea += floor.Area(); } } floors = floors.OrderBy(f => f.Elevation).ToList(); floors.First().Transform.Move(new Vector3(0.0, 0.0, input.FloorThickness)); var output = new FloorsByLevelsOutputs(floorArea, floors.Count()); output.Model.AddElements(floors); return(output); }