Skip to content

Commit

Permalink
set specific meeting room types
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheumann committed Jan 7, 2024
1 parent cc71458 commit 97f1600
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
3 changes: 3 additions & 0 deletions LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

}

}
10 changes: 8 additions & 2 deletions LayoutFunctions/LayoutFunctionCommon/LayoutGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,20 @@ public virtual LayoutGenerationResult StandardLayoutOnAllLevels(string programTy
};
boundaryCurves.AddRange(spaceBoundary.Voids ?? new List<Polygon>());

var configsForRoom = configs;
if (room.ConfigId != null)
{
configsForRoom = LayoutStrategies.LimitConfigsToId(configs, room, wallCandidateOptions);
}

var possibleConfigs = new List<(ConfigInfo configInfo, List<RoomEdge> wallCandidates)>();
foreach (var (OrientationGuideEdge, WallCandidates) in wallCandidateOptions)
{
var orientationTransform = new Transform(Vector3.Origin, OrientationGuideEdge.Direction, Vector3.ZAxis);
var grid = new Grid2d(boundaryCurves, orientationTransform);
foreach (var cell in grid.GetCells())
{
var config = FindConfigByFit(configs, cell);
var config = FindConfigByFit(configsForRoom, cell);
if (config != null)
{
possibleConfigs.Add((config.Value, WallCandidates));
Expand Down Expand Up @@ -238,7 +244,7 @@ protected virtual SpaceConfiguration DeserializeConfigJson(string configJson)
KeyValuePair<string, ContentConfiguration>? 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;
Expand Down
40 changes: 39 additions & 1 deletion LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,13 @@ public static HashSet<Guid> StandardLayoutOnAllLevels<TLevelElements, TLevelVolu
foreach (var room in roomBoundaries)
{
var wallCandidateLines = new List<RoomEdge>();
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;
Expand Down Expand Up @@ -240,6 +246,38 @@ public static HashSet<Guid> StandardLayoutOnAllLevels<TLevelElements, TLevelVolu
return processedSpaces;
}

/// <summary>
/// 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.
/// </summary>
public static SpaceConfiguration LimitConfigsToId<TSpaceBoundary>(SpaceConfiguration configs, TSpaceBoundary room, List<(RoomEdge OrientationGuideEdge, List<RoomEdge> 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;
}


/// <summary>
/// Basically the same as StandardLayoutOnAllLevels, but without the actual furniture layout part — just the wall creation.
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }
}
}

0 comments on commit 97f1600

Please sign in to comment.