Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support relative transforms on rooms #102

Merged
merged 7 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ obj/
nupkg/
.DS_Store
*/test/Generated/*
settings.json
9 changes: 5 additions & 4 deletions LayoutFunctions/DataHall/src/DataHallLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static DataHallLayoutOutputs Execute(Dictionary<string, Model> inputModel
foreach (var cell in grid.GetCells())
{
var cellRect = cell.GetCellGeometry() as Polygon;
bool intersectsColumn = CheckIntersectsWithColumns(cellRect, roomColumns);
bool intersectsColumn = CheckIntersectsWithColumns(cellRect, roomColumns, room.Transform);

if (cell.IsTrimmed() || cell.Type == null || cell.GetTrimmedCellGeometry().Count() == 0)
{
Expand Down Expand Up @@ -164,21 +164,22 @@ private static List<Column> GetColumnsInRoom(SpaceBoundary room, Dictionary<stri
}

var allColumns = inputModels["Columns"].Elements.Values.OfType<Column>().ToList();
var roomBoundary = room.Boundary.Transformed(room.Transform);
var columns = allColumns
.Where(column => column.Profile.Perimeter.Vertices.All(point => room.Boundary.Contains(point + column.Location)))
.Where(column => column.Profile.Perimeter.Vertices.All(point => roomBoundary.Contains(point + column.Location)))
.ToList();

return columns.Count > 0 ? columns : null;
}

private static bool CheckIntersectsWithColumns(Polygon cellRect, List<Column> columns)
private static bool CheckIntersectsWithColumns(Polygon cellRect, List<Column> columns, Transform roomTransform)
{
if (cellRect == null || columns == null || columns.Count == 0)
{
return false;
}

return columns.Any(column => cellRect.Intersects(column.Profile.Perimeter.TransformedPolygon(new Transform(column.Location))));
return columns.Any(column => cellRect.TransformedPolygon(roomTransform).Intersects(column.Profile.Perimeter.TransformedPolygon(new Transform(column.Location))));
}

private static ModelLines ToModelLines(Grid2d grid, Transform transform, System.Guid id)
Expand Down
4 changes: 4 additions & 0 deletions LayoutFunctions/LayoutFunctionCommon/WallGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
}), corridorSegments, levelProfile, out var wallCandidates);
orientationGuideEdge.Type = room.DefaultWallType ?? "Glass";
orientationGuideEdge.PrimaryEntryEdge = true;
// Return the orientation guide edge relative to the room's transform.
orientationGuideEdge.Line = orientationGuideEdge.Line.TransformedLine(room.Transform.Inverted());
wallCandidateLines.Add(orientationGuideEdge);
if (levelProfile != null)
{
Expand Down Expand Up @@ -78,6 +80,8 @@
{
orientationGuideEdge.Line.Type = room.DefaultWallType ?? "Glass";
orientationGuideEdge.Line.PrimaryEntryEdge = true;
// Return the orientation guide edge relative to the room's transform.
orientationGuideEdge.Line.Line = orientationGuideEdge.Line.Line.TransformedLine(room.Transform.Inverted());
var wallCandidateLines = new List<RoomEdge>
{
orientationGuideEdge.Line
Expand Down Expand Up @@ -115,7 +119,7 @@
public static List<RoomEdge> DeduplicateWallLines(List<InteriorPartitionCandidate> interiorPartitionCandidates)
{
return interiorPartitionCandidates.SelectMany(i => i.WallCandidateLines).Where(l => l.Type != null && interiorPartitionTypePriority.Keys.Contains(l.Type)).ToList();
var resultCandidates = new List<RoomEdge>();

Check warning on line 122 in LayoutFunctions/LayoutFunctionCommon/WallGeneration.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected

Check warning on line 122 in LayoutFunctions/LayoutFunctionCommon/WallGeneration.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected
var typedLines = interiorPartitionCandidates.SelectMany(c => c.WallCandidateLines)
.Where(l => l.Type != null && interiorPartitionTypePriority.Keys.Contains(l.Type));
var collinearLinesGroups = GroupCollinearLines(typedLines);
Expand Down
2 changes: 0 additions & 2 deletions LayoutFunctions/MeetingRoomLayout/src/MeetingRoomLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public override LayoutGenerationResult StandardLayoutOnAllLevels(string programT
seatsTable = new Dictionary<string, RoomTally>();

var result = base.StandardLayoutOnAllLevels(programTypeName, inputModels, (object)overrides, createWalls, configs);


result.OutputModel.AddElements(seatsTable.Select(kvp => kvp.Value).OrderByDescending(a => a.SeatsCount));
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ private static IEnumerable<SpaceBoundary> DivideBoundaryAlongVAxis(SpaceBoundary
}
var relativeRoomTransform = room.Transform.Concatenated(levelInvertedTransform);
var relativeRoomTransformProjected = new Transform(0, 0, -relativeRoomTransform.Origin.Z);
var orientationTransform = new Transform(Vector3.Origin, orientationGuideEdge.Direction, Vector3.ZAxis);
orientationTransform.Concatenate(relativeRoomTransform);
var orientationTransform = new Transform(Vector3.Origin, orientationGuideEdge.Direction, Vector3.ZAxis).Concatenated(relativeRoomTransform);
var boundaryCurves = new List<Polygon>();
boundaryCurves.Add(room.Boundary.Perimeter.TransformedPolygon(relativeRoomTransform));
boundaryCurves.AddRange(room.Boundary.Voids?.Select(v => v.TransformedPolygon(relativeRoomTransform)) ?? new List<Polygon>());
Expand Down
7 changes: 6 additions & 1 deletion LayoutFunctions/WallsLOD200/src/WallsLOD200.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ public static WallsLOD200Outputs Execute(Dictionary<string, Model> inputModels,
foreach (var group in wallGroups)
{
var level = levels.FirstOrDefault(l => l.Id.ToString() == group.Key.ToString()) ?? new Level(0, 3, null);
var lines = UnifyLines(group.ToList().Select(g => g.CenterLine).ToList());
var lines = UnifyLines(group.ToList().Select(wall =>
{
var transform = new Transform(wall.Transform);
transform.Move(0, 0, -level.Elevation); // To keep the level.Elevation logic below, negate the wall's Z-position.
return wall.CenterLine.TransformedLine(transform);
}).ToList());
var roundedZLines = lines.Select(l =>
{
var roundedStart = new Vector3(l.Start.X, l.Start.Y, Math.Round(l.Start.Z, 5));
Expand Down
Loading