Skip to content

Commit

Permalink
Merge pull request #77 from hypar-io/circulation-space-fix
Browse files Browse the repository at this point in the history
Height fix and circulation space for doors (#77)
  • Loading branch information
anthonie-kramer authored Dec 7, 2023
2 parents afa646a + dca3d38 commit ac4af05
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 25 deletions.
18 changes: 15 additions & 3 deletions LayoutFunctions/Doors/src/Doors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,29 @@ public static DoorsOutputs Execute(Dictionary<string, Model> 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<Door>();

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)
Expand Down
2 changes: 1 addition & 1 deletion LayoutFunctions/LayoutFunctionCommon/ISpaceBoundary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
43 changes: 22 additions & 21 deletions LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,24 @@ public static HashSet<Guid> StandardLayoutOnAllLevels<TLevelElements, TLevelVolu
(lvl.AdditionalProperties.TryGetValue("LevelVolumeId", out var levelVolumeId) &&
levelVolumeId as string == l.Id.ToString())) ??
levelVolumes.FirstOrDefault(l => l.Name == lvl.Name);
var wallCandidateLines = new List<RoomEdge>();
foreach (var room in roomBoundaries)
{
var wallCandidateLines = new List<RoomEdge>();
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)
Expand Down Expand Up @@ -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<RoomEdge>();

foreach (var room in roomBoundaries)
{
var wallCandidateLines = new List<RoomEdge>();
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)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Elements
{
public partial class CirculationSegment : ICirculationSegment
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Elements
{
public partial class LevelVolume : ILevelVolume
{
}
}

0 comments on commit ac4af05

Please sign in to comment.