From 97f16007cbb1cafb0f6013e4af0cf5ddcd893242 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 7 Jan 2024 07:13:01 -0500 Subject: [PATCH 1/4] set specific meeting room types --- .../LayoutFunctionCommon/ISpaceBoundary.cs | 3 ++ .../LayoutFunctionCommon/LayoutGeneration.cs | 10 ++++- .../LayoutFunctionCommon/LayoutStrategies.cs | 40 ++++++++++++++++++- .../dependencies/SpaceBoundary.cs | 4 +- 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs b/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs index d6a96717..5894e12b 100644 --- a/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs +++ b/LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs @@ -21,6 +21,9 @@ public interface ISpaceBoundary public string DefaultWallType { get; set; } + [JsonProperty("Config Id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string ConfigId { get; set; } + } } \ No newline at end of file diff --git a/LayoutFunctions/LayoutFunctionCommon/LayoutGeneration.cs b/LayoutFunctions/LayoutFunctionCommon/LayoutGeneration.cs index a146563f..04fad27a 100644 --- a/LayoutFunctions/LayoutFunctionCommon/LayoutGeneration.cs +++ b/LayoutFunctions/LayoutFunctionCommon/LayoutGeneration.cs @@ -61,6 +61,12 @@ public class LayoutGeneration()); + var configsForRoom = configs; + if (room.ConfigId != null) + { + configsForRoom = LayoutStrategies.LimitConfigsToId(configs, room, wallCandidateOptions); + } + var possibleConfigs = new List<(ConfigInfo configInfo, List wallCandidates)>(); foreach (var (OrientationGuideEdge, WallCandidates) in wallCandidateOptions) { @@ -68,7 +74,7 @@ public class LayoutGeneration? selectedConfigPair = null; foreach (var configPair in orderedConfigs) { - if (configPair.Value.CellBoundary.Width < width && configPair.Value.CellBoundary.Depth < length) + if (configPair.Value.CellBoundary.Width < (width + Vector3.EPSILON) && configPair.Value.CellBoundary.Depth < (length + Vector3.EPSILON)) { selectedConfigPair = configPair; break; diff --git a/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs b/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs index 87190ea8..5347bfcb 100644 --- a/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs +++ b/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs @@ -211,7 +211,13 @@ public static bool IsNearlyARectangle(IEnumerable polygons) foreach (var room in roomBoundaries) { var wallCandidateLines = new List(); - var layoutSucceeded = ProcessRoom(room, outputModel, countSeats, configs, corridorSegments, levelVolume, wallCandidateLines); + + var configsForRoom = configs; + if (room.ConfigId != null) + { + configsForRoom = LimitConfigsToId(configs, room); + } + var layoutSucceeded = ProcessRoom(room, outputModel, countSeats, configsForRoom, corridorSegments, levelVolume, wallCandidateLines); if (layoutSucceeded) { processedSpaces.Add(room.Id); } double height = room.Height == 0 ? 3 : room.Height; @@ -240,6 +246,38 @@ public static bool IsNearlyARectangle(IEnumerable polygons) return processedSpaces; } + /// + /// Pringle-specific behavior to pick a specific config and orientation. This code only executes if the room has a `ConfigId` property, which is only set on pringle. + /// + public static SpaceConfiguration LimitConfigsToId(SpaceConfiguration configs, TSpaceBoundary room, List<(RoomEdge OrientationGuideEdge, List WallCandidates)> wallCandidateOptions = null) where TSpaceBoundary : Element, ISpaceBoundary + { + // If a set of wall candidate options are provided, limit to the one that aligns with the boundary's first edge. + // In the future, as room shapes become more editable, we might want to pass in an explicit "orientation edge" instead of just using the first edge. + if (wallCandidateOptions != null) + { + var roomOrientationEdge = room.Boundary.Perimeter.Segments().First(); + for (int i = wallCandidateOptions.Count - 1; i >= 0; i--) + { + var (OrientationGuideEdge, _) = wallCandidateOptions[i]; + if (OrientationGuideEdge.Line.Mid().DistanceTo(roomOrientationEdge.Mid()) > 0.01) + { + wallCandidateOptions.RemoveAt(i); + } + } + } + + // Limit the possible configs to the one specified by the room's ConfigId property. + var configId = room.ConfigId; + var config = new SpaceConfiguration(); + if (configs.ContainsKey(configId)) + { + config.Add(configId, configs[configId]); + return config; + } + + return configs; + } + /// /// Basically the same as StandardLayoutOnAllLevels, but without the actual furniture layout part — just the wall creation. diff --git a/LayoutFunctions/MeetingRoomLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/MeetingRoomLayout/dependencies/SpaceBoundary.cs index ed244d1f..7f3af68c 100644 --- a/LayoutFunctions/MeetingRoomLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/MeetingRoomLayout/dependencies/SpaceBoundary.cs @@ -1,9 +1,11 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } - + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file From 01d488593bc37c08226b47aa6565175d6cef2072 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 7 Jan 2024 07:20:51 -0500 Subject: [PATCH 2/4] variable renaming --- .../LayoutFunctionCommon/LayoutStrategies.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs b/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs index 5347bfcb..40049b75 100644 --- a/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs +++ b/LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs @@ -249,7 +249,7 @@ public static bool IsNearlyARectangle(IEnumerable polygons) /// /// Pringle-specific behavior to pick a specific config and orientation. This code only executes if the room has a `ConfigId` property, which is only set on pringle. /// - public static SpaceConfiguration LimitConfigsToId(SpaceConfiguration configs, TSpaceBoundary room, List<(RoomEdge OrientationGuideEdge, List WallCandidates)> wallCandidateOptions = null) where TSpaceBoundary : Element, ISpaceBoundary + public static SpaceConfiguration LimitConfigsToId(SpaceConfiguration originalConfigs, TSpaceBoundary room, List<(RoomEdge OrientationGuideEdge, List WallCandidates)> wallCandidateOptions = null) where TSpaceBoundary : Element, ISpaceBoundary { // If a set of wall candidate options are provided, limit to the one that aligns with the boundary's first edge. // In the future, as room shapes become more editable, we might want to pass in an explicit "orientation edge" instead of just using the first edge. @@ -266,16 +266,16 @@ public static bool IsNearlyARectangle(IEnumerable polygons) } } - // Limit the possible configs to the one specified by the room's ConfigId property. + // Limit the possible configs to the one specified by the room's ConfigId property, if it's found in the set. var configId = room.ConfigId; - var config = new SpaceConfiguration(); - if (configs.ContainsKey(configId)) + var newConfigs = new SpaceConfiguration(); + if (originalConfigs.ContainsKey(configId)) { - config.Add(configId, configs[configId]); - return config; + newConfigs.Add(configId, originalConfigs[configId]); + return newConfigs; } - return configs; + return originalConfigs; } From d51248f8ef9821f6f97ab74664dda8e772753294 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 7 Jan 2024 08:13:04 -0500 Subject: [PATCH 3/4] add config id to all types --- .../ClassroomLayout/dependencies/SpaceBoundary.cs | 4 ++++ LayoutFunctions/CustomLayout/dependencies/SpaceBoundary.cs | 4 ++++ LayoutFunctions/LoungeLayout/dependencies/SpaceBoundary.cs | 3 +++ .../OpenCollabLayout/dependencies/SpaceBoundary.cs | 4 +++- .../OpenOfficeLayout/dependencies/SpaceBoundary.cs | 3 +++ LayoutFunctions/PantryLayout/dependencies/SpaceBoundary.cs | 4 ++++ .../PhoneBoothLayout/dependencies/SpaceBoundary.cs | 4 ++++ .../PrivateOfficeLayout/dependencies/SpaceBoundary.cs | 5 ++++- .../ReceptionLayout/dependencies/SpaceBoundary.cs | 4 ++++ 9 files changed, 33 insertions(+), 2 deletions(-) diff --git a/LayoutFunctions/ClassroomLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/ClassroomLayout/dependencies/SpaceBoundary.cs index 56498781..90db1c65 100644 --- a/LayoutFunctions/ClassroomLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/ClassroomLayout/dependencies/SpaceBoundary.cs @@ -1,9 +1,13 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } + + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file diff --git a/LayoutFunctions/CustomLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/CustomLayout/dependencies/SpaceBoundary.cs index 56498781..b7f596a6 100644 --- a/LayoutFunctions/CustomLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/CustomLayout/dependencies/SpaceBoundary.cs @@ -1,9 +1,13 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } + + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file diff --git a/LayoutFunctions/LoungeLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/LoungeLayout/dependencies/SpaceBoundary.cs index 73853484..ac0a45ee 100644 --- a/LayoutFunctions/LoungeLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/LoungeLayout/dependencies/SpaceBoundary.cs @@ -1,9 +1,12 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { public partial class SpaceBoundary : ISpaceBoundary { public Vector3? ParentCentroid { get; set; } + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file diff --git a/LayoutFunctions/OpenCollabLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/OpenCollabLayout/dependencies/SpaceBoundary.cs index ed244d1f..7f3af68c 100644 --- a/LayoutFunctions/OpenCollabLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/OpenCollabLayout/dependencies/SpaceBoundary.cs @@ -1,9 +1,11 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } - + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file diff --git a/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs index d349d071..4770815b 100644 --- a/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs @@ -24,6 +24,9 @@ public partial class SpaceBoundary : ISpaceBoundary public int SpaceCount { get; set; } = 1; + [JsonProperty("Config Id")] + public string ConfigId { get; set; } // unused by this layout type + [Newtonsoft.Json.JsonIgnore] public LevelElements LevelElements { get; set; } diff --git a/LayoutFunctions/PantryLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/PantryLayout/dependencies/SpaceBoundary.cs index ed244d1f..b7f596a6 100644 --- a/LayoutFunctions/PantryLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/PantryLayout/dependencies/SpaceBoundary.cs @@ -1,9 +1,13 @@ using Elements.Geometry; +using Newtonsoft.Json; + namespace Elements { public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file diff --git a/LayoutFunctions/PhoneBoothLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/PhoneBoothLayout/dependencies/SpaceBoundary.cs index 56498781..90db1c65 100644 --- a/LayoutFunctions/PhoneBoothLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/PhoneBoothLayout/dependencies/SpaceBoundary.cs @@ -1,9 +1,13 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } + + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file diff --git a/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs index 2b2109d5..ff49147a 100644 --- a/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs @@ -5,7 +5,10 @@ namespace Elements public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } - + public Vector3? IndividualCentroid { get; set; } + + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file diff --git a/LayoutFunctions/ReceptionLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/ReceptionLayout/dependencies/SpaceBoundary.cs index 8d79f6b9..baf721b0 100644 --- a/LayoutFunctions/ReceptionLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/ReceptionLayout/dependencies/SpaceBoundary.cs @@ -3,10 +3,14 @@ using System.Linq; using System.Collections.Generic; using Elements.Geometry; +using Newtonsoft.Json; + namespace Elements { public partial class SpaceBoundary : ISpaceBoundary { public Vector3? ParentCentroid { get; set; } + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file From e7923d688970abcfb68e73c0f581cf796f049578 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 7 Jan 2024 08:16:38 -0500 Subject: [PATCH 4/4] fix build errors --- LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs | 1 + .../PrivateOfficeLayout/dependencies/SpaceBoundary.cs | 1 + SpaceConfigurationFromModel/dependencies/SpaceBoundary.cs | 3 +++ 3 files changed, 5 insertions(+) diff --git a/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs index 4770815b..68387b9b 100644 --- a/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/OpenOfficeLayout/dependencies/SpaceBoundary.cs @@ -4,6 +4,7 @@ using Elements.Geometry; using Elements.Geometry.Solids; using LayoutFunctionCommon; +using Newtonsoft.Json; namespace Elements { diff --git a/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs b/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs index ff49147a..c4065516 100644 --- a/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs +++ b/LayoutFunctions/PrivateOfficeLayout/dependencies/SpaceBoundary.cs @@ -1,4 +1,5 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { diff --git a/SpaceConfigurationFromModel/dependencies/SpaceBoundary.cs b/SpaceConfigurationFromModel/dependencies/SpaceBoundary.cs index ed244d1f..0669512f 100644 --- a/SpaceConfigurationFromModel/dependencies/SpaceBoundary.cs +++ b/SpaceConfigurationFromModel/dependencies/SpaceBoundary.cs @@ -1,9 +1,12 @@ using Elements.Geometry; +using Newtonsoft.Json; namespace Elements { public partial class SpaceBoundary : GeometricElement, ISpaceBoundary { public Vector3? ParentCentroid { get; set; } + [JsonProperty("Config Id")] + public string ConfigId { get; set; } } } \ No newline at end of file