From dca3d38536e37f554b454b471b06c2bbaff3127a Mon Sep 17 00:00:00 2001 From: Anthonie Kramer Date: Mon, 4 Dec 2023 11:21:30 -0800 Subject: [PATCH] Height fix and circulation space for doors --- LayoutFunctions/Doors/src/Doors.cs | 18 ++++++-- .../LayoutFunctionCommon/ISpaceBoundary.cs | 2 +- .../LayoutFunctionCommon/LayoutStrategies.cs | 43 ++++++++++--------- .../dependencies/CirculationSegment.cs | 6 +++ .../dependencies/LevelVolume.cs | 6 +++ 5 files changed, 50 insertions(+), 25 deletions(-) create mode 100644 LayoutFunctions/PrivateOfficeLayout/dependencies/CirculationSegment.cs create mode 100644 LayoutFunctions/PrivateOfficeLayout/dependencies/LevelVolume.cs diff --git a/LayoutFunctions/Doors/src/Doors.cs b/LayoutFunctions/Doors/src/Doors.cs index 0b616571..1068e270 100644 --- a/LayoutFunctions/Doors/src/Doors.cs +++ b/LayoutFunctions/Doors/src/Doors.cs @@ -24,17 +24,29 @@ public static DoorsOutputs Execute(Dictionary inputModels, DoorsI DoorRepresentationStorage.Doors.Clear(); - var rooms = GetSpaceBoundaries(inputModels); + var allSpaces = GetSpaceBoundaries(inputModels); + + var rooms = allSpaces.Where(x => x.ProgramType != "Circulation").ToList(); + var circulationSpaces = allSpaces.Where(x => x.ProgramType == "Circulation").ToList(); + var corridors = GetCirculationSegments(inputModels); var walls = GetWallCandidates(inputModels); var doors = new List(); - foreach (var roomsOfLevel in rooms.GroupBy(r => r.Level)) + var roomGroups = rooms.GroupBy(r => r.Level); + + foreach (var roomsOfLevel in roomGroups) { var levelCorridors = corridors.Where(c => c.Level == roomsOfLevel.Key); var levelCorridorsSegments = levelCorridors.SelectMany( c => c.Profile.Transformed(c.Transform).Segments()).ToList(); - foreach (var room in rooms) + + // Get circulation space boundary segments + var levelCorridorSpaces = circulationSpaces.Where(x => x.Level == roomsOfLevel.Key); + var levelCorridorSpaceSegments = levelCorridorSpaces.SelectMany(x => x.Boundary.Perimeter.Segments()).ToList(); + levelCorridorsSegments.AddRange(levelCorridorSpaceSegments); + + foreach (var room in roomsOfLevel) { var pair = RoomDefaultDoorWall(room, levelCorridorsSegments, walls); if (pair == null || pair.Value.Wall == null || pair.Value.Segment == null) diff --git a/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs b/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs index 33275e83..d6a96717 100644 --- a/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs +++ b/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs @@ -9,9 +9,9 @@ namespace Elements public interface ISpaceBoundary { string Name { get; set; } + double Height { get; set; } Profile Boundary { get; set; } Transform Transform { get; set; } - Vector3? ParentCentroid { get; set; } Guid Id { get; set; } diff --git a/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs b/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs index 43fefdc9..4d6d9e62 100644 --- a/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs +++ b/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs @@ -205,24 +205,24 @@ public static HashSet StandardLayoutOnAllLevels l.Name == lvl.Name); - var wallCandidateLines = new List(); foreach (var room in roomBoundaries) { + var wallCandidateLines = new List(); var layoutSucceeded = ProcessRoom(room, outputModel, countSeats, configs, corridorSegments, levelVolume, wallCandidateLines); if (layoutSucceeded) { processedSpaces.Add(room.Id); } - } - double height = levelVolume?.Height ?? 3; - Transform xform = levelVolume?.Transform ?? new Transform(); + double height = room.Height == 0 ? 3 : room.Height; + Transform xform = levelVolume?.Transform ?? new Transform(); - if (createWalls && wallCandidateLines.Count > 0) - { - outputModel.AddElement(new InteriorPartitionCandidate(Guid.NewGuid()) + if (createWalls && wallCandidateLines.Count > 0) { - WallCandidateLines = wallCandidateLines, - Height = height, - LevelTransform = xform, - }); + outputModel.AddElement(new InteriorPartitionCandidate(Guid.NewGuid()) + { + WallCandidateLines = wallCandidateLines, + Height = height, + LevelTransform = xform, + }); + } } } foreach (var room in allSpaceBoundaries) @@ -273,21 +273,22 @@ Model outputModel (lvl.AdditionalProperties.TryGetValue("LevelVolumeId", out var levelVolumeId) && levelVolumeId as string == l.Id.ToString())) ?? levelVolumes.FirstOrDefault(l => l.Name == lvl.Name); - var wallCandidateLines = new List(); + foreach (var room in roomBoundaries) { + var wallCandidateLines = new List(); GenerateWallsForSpace(room, levelVolume, corridorSegments, wallCandidateLines); - } - double height = levelVolume?.Height ?? 3; - Transform xform = levelVolume?.Transform ?? new Transform(); + double height = room.Height == 0 ? 3 : room.Height; + Transform xform = levelVolume?.Transform ?? new Transform(); - outputModel.AddElement(new InteriorPartitionCandidate(Guid.NewGuid()) - { - WallCandidateLines = wallCandidateLines, - Height = height, - LevelTransform = xform, - }); + outputModel.AddElement(new InteriorPartitionCandidate(Guid.NewGuid()) + { + WallCandidateLines = wallCandidateLines, + Height = height, + LevelTransform = xform, + }); + } } foreach (var room in allSpaceBoundaries) { diff --git a/LayoutFunctions/PrivateOfficeLayout/dependencies/CirculationSegment.cs b/LayoutFunctions/PrivateOfficeLayout/dependencies/CirculationSegment.cs new file mode 100644 index 00000000..29fd7287 --- /dev/null +++ b/LayoutFunctions/PrivateOfficeLayout/dependencies/CirculationSegment.cs @@ -0,0 +1,6 @@ +namespace Elements +{ + public partial class CirculationSegment : ICirculationSegment + { + } +} \ No newline at end of file diff --git a/LayoutFunctions/PrivateOfficeLayout/dependencies/LevelVolume.cs b/LayoutFunctions/PrivateOfficeLayout/dependencies/LevelVolume.cs new file mode 100644 index 00000000..ac72b4b7 --- /dev/null +++ b/LayoutFunctions/PrivateOfficeLayout/dependencies/LevelVolume.cs @@ -0,0 +1,6 @@ +namespace Elements +{ + public partial class LevelVolume : ILevelVolume + { + } +} \ No newline at end of file