Skip to content

Commit

Permalink
handle orientation consistency in other pathway
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheumann committed Jan 10, 2024
1 parent 792cd8a commit dc49304
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,9 @@ public static bool IsNearlyARectangle(IEnumerable<Polygon> polygons)
/// </summary>
public static SpaceConfiguration LimitConfigsToId<TSpaceBoundary>(SpaceConfiguration originalConfigs, 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().Project(Plane.XY).DistanceTo(roomOrientationEdge.Mid().Project(Plane.XY)) > 0.01)
{
wallCandidateOptions.RemoveAt(i);
}
}
LimitWallCandidateOptionsByConfigId(wallCandidateOptions, room);
}

// Limit the possible configs to the one specified by the room's ConfigId property, if it's found in the set.
Expand All @@ -278,6 +268,21 @@ public static bool IsNearlyARectangle(IEnumerable<Polygon> polygons)
return originalConfigs;
}

public static void LimitWallCandidateOptionsByConfigId<TSpaceBoundary>(List<(RoomEdge OrientationGuideEdge, List<RoomEdge> WallCandidates)> wallCandidateOptions, TSpaceBoundary room) 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.
var roomOrientationEdge = room.Boundary.Perimeter.Segments().First();
for (int i = wallCandidateOptions.Count - 1; i >= 0; i--)
{
var (OrientationGuideEdge, _) = wallCandidateOptions[i];
if (OrientationGuideEdge.Line.Mid().Project(Plane.XY).DistanceTo(roomOrientationEdge.Mid().Project(Plane.XY)) > 0.01)
{
wallCandidateOptions.RemoveAt(i);
}
}
}


/// <summary>
/// Basically the same as StandardLayoutOnAllLevels, but without the actual furniture layout part — just the wall creation.
Expand Down Expand Up @@ -377,6 +382,10 @@ Model outputModel
var success = false;
var spaceBoundary = room.Boundary;
var wallCandidateOptions = WallGeneration.FindWallCandidateOptions(room, levelVolume?.Profile, corridorSegments);
if (room.ConfigId != null && wallCandidateOptions != null)
{
LimitWallCandidateOptionsByConfigId(wallCandidateOptions, room);
}

foreach (var (OrientationGuideEdge, WallCandidates) in wallCandidateOptions)
{
Expand Down

0 comments on commit dc49304

Please sign in to comment.