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

add space associations for all child elements #78

Merged
merged 2 commits into from
Dec 7, 2023
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
3 changes: 3 additions & 0 deletions LayoutFunctions/ClassroomLayout/src/ClassroomLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static ClassroomLayoutOutputs Execute(Dictionary<string, Model> inputMode
{
var componentInstance = InstantiateLayout(configs, width, depth, rect, room.Transform);
LayoutStrategies.SetLevelVolume(componentInstance, levelVolume?.Id);
LayoutStrategies.SetParentSpace(componentInstance, room.Id);
output.Model.AddElement(componentInstance);
}
else if (trimmedGeo.Count() > 0)
Expand All @@ -102,6 +103,7 @@ public static ClassroomLayoutOutputs Execute(Dictionary<string, Model> inputMode

var componentInstance = InstantiateLayout(configs, width, depth, cinchedPoly, room.Transform);
LayoutStrategies.SetLevelVolume(componentInstance, levelVolume?.Id);
LayoutStrategies.SetParentSpace(componentInstance, room.Id);
output.Model.AddElement(componentInstance);
}
try
Expand Down Expand Up @@ -135,6 +137,7 @@ public static ClassroomLayoutOutputs Execute(Dictionary<string, Model> inputMode
"Desk");

LayoutStrategies.SetLevelVolume(instance, levelVolume?.Id);
LayoutStrategies.SetParentSpace(instance, room.Id);
output.Model.AddElement(instance);
}
}
Expand Down
17 changes: 12 additions & 5 deletions LayoutFunctions/DataHall/src/DataHallLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
var floorGrid = new Grid2d(profile.Perimeter, alignment);
floorGrid.U.DivideByFixedLength(0.6096);
floorGrid.V.DivideByFixedLength(0.6096);
model.AddElement(ToModelLines(floorGrid, room.Transform));
model.AddElement(ToModelLines(floorGrid, room.Transform, room.Id));

double rackAngle = 0;
if (input.SwapColdHotPattern) rackAngle = 180;
Expand All @@ -115,22 +115,28 @@
}
if (cell.Type == "Hot Aisle")
{
model.AddElement(new Panel(cellRect, BuiltInMaterials.XAxis, room.Transform));
var panel = new Panel(cellRect, BuiltInMaterials.XAxis, room.Transform);
panel.AdditionalProperties["Space"] = room.Id;
model.AddElement(panel);
}
else if (cell.Type == "Cold Aisle")
{
model.AddElement(new Panel(cellRect, BuiltInMaterials.ZAxis, room.Transform));
var panel = new Panel(cellRect, BuiltInMaterials.ZAxis, room.Transform);
panel.AdditionalProperties["Space"] = room.Id;
model.AddElement(panel);
}
else if (cell.Type == "Forward Rack" && cellRect.Area().ApproximatelyEquals(width * depth, 0.01) && !intersectsColumn)
{
var centroid = cellRect.Centroid();
var rackInstance = dataRack.CreateInstance(alignment.Concatenated(new Transform(new Vector3(), rackAngle - 180)).Concatenated(new Transform(centroid)).Concatenated(room.Transform), "Rack");
rackInstance.AdditionalProperties["Space"] = room.Id;
model.AddElement(rackInstance);
}
else if (cell.Type == "Backward Rack" && cellRect.Area().ApproximatelyEquals(width * depth, 0.01) && !intersectsColumn)
{
var centroid = cellRect.Centroid();
var rackInstance = dataRack.CreateInstance(alignment.Concatenated(new Transform(new Vector3(), rackAngle)).Concatenated(new Transform(centroid)).Concatenated(room.Transform), "Rack");
rackInstance.AdditionalProperties["Space"] = room.Id;
model.AddElement(rackInstance);
}
}
Expand Down Expand Up @@ -160,7 +166,7 @@
return columns.Count > 0 ? columns : null;
}

private static bool CheckIntersectsWithColumns(Polygon? cellRect, List<Column> columns)

Check warning on line 169 in LayoutFunctions/DataHall/src/DataHallLayout.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 169 in LayoutFunctions/DataHall/src/DataHallLayout.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (cellRect == null || columns == null || columns.Count == 0)
{
Expand All @@ -170,14 +176,14 @@
return columns.Any(column => cellRect.Intersects(column.Profile.Perimeter.TransformedPolygon(new Transform(column.Location))));
}

private static ModelLines ToModelLines(Grid2d grid, Transform transform)
private static ModelLines ToModelLines(Grid2d grid, Transform transform, System.Guid id)
{
var boundary = grid.GetTrimmedCellGeometry();
var uLines = grid.GetCellSeparators(GridDirection.U, true);
var vLines = grid.GetCellSeparators(GridDirection.V, true);
var curves = boundary.Concat(uLines).Concat(vLines).OfType<BoundedCurve>();

ModelLines ml = new ModelLines(transform: transform);
var ml = new ModelLines(transform: transform);
foreach (var b in boundary.Concat(curves))
{
var parameters = b.GetSubdivisionParameters();
Expand All @@ -188,6 +194,7 @@
}
}
ml.SetSelectable(false);
ml.AdditionalProperties["Space"] = id;
return ml;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
<ItemGroup>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="2.2.0-alpha.17" />
<PackageReference Include="Hypar.Functions" Version="1.11.0-alpha.10" />
<PackageReference Include="Hypar.Elements" Version="2.2.0-alpha.17" />
<PackageReference Include="Hypar.Elements.Components" Version="2.2.0-alpha.17" />
<!-- <ProjectReference Include="..\..\..\Elements\Elements\src\Elements.csproj" />
<ProjectReference Include="..\..\..\Hypar\Hypar.Functions\src\Hypar.Functions.csproj" />
<ProjectReference Include="..\..\..\Elements\Elements.Components\src\Elements.Components.csproj" /> -->

<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
<PackageReference Include="Elements.LargestInteriorRectangle" Version="2.0.0" />
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions LayoutFunctions/LayoutFunctionCommon/LayoutStrategies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -865,5 +865,13 @@ public static void SetParentSpace(ComponentInstance componentInstance, Guid? par
}
}
}

public static void SetParentSpace(ElementInstance elementInstance, Guid parentSpaceId)
{
if (elementInstance != null)
{
elementInstance.AdditionalProperties["Space"] = parentSpaceId;
}
}
}
}
12 changes: 12 additions & 0 deletions LayoutFunctions/OpenOfficeLayout/Model.dib
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!meta

{"kernelInfo":{"defaultKernelName":"csharp","items":[{"aliases":[],"name":"csharp"}]}}

#!csharp

#r "nuget: Hypar.Elements, *-*"

#!csharp

var modelPath = "/Users/andrewheumann/Downloads/model 45.json";
Model.FromJson(File)
1 change: 1 addition & 0 deletions LayoutFunctions/OpenOfficeLayout/src/OpenOfficeLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public static OpenOfficeLayoutOutputs Execute(Dictionary<string, Model> inputMod
foreach (var desk in desks)
{
LayoutStrategies.SetLevelVolume(desk as ElementInstance, levelVolume?.Id);
LayoutStrategies.SetParentSpace(desk as ElementInstance, ob.Id);
}
output.Model.AddElements(desks);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>EKN5BGA37XK4SY88</RequestId><HostId>QVRfH3TrGZQKXsMveW3bcXf2M6ghPoasNYLw2g7c0lGb3OSFD7Lf4OOK6sPbkgZLd10nxN6Fjhc=</HostId></Error>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>CMH857YEYZ5WRC90</RequestId><HostId>hOtw+YejhNRIAP2YyzyqSnUjP3wPHraUapiGGnH8Mwq0k6kSQLGiP2KlSyrql96/d6PcnrsdF0o=</HostId></Error>
2 changes: 2 additions & 0 deletions LayoutFunctions/PhoneBoothLayout/src/PhoneBoothLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static PhoneBoothLayoutOutputs Execute(Dictionary<string, Model> inputMod
if (layout != null)
{
LayoutStrategies.SetLevelVolume(layout, levelVolume?.Id);
LayoutStrategies.SetParentSpace(layout, room.Id);
output.Model.AddElement(layout);
seatsCount++;
}
Expand All @@ -112,6 +113,7 @@ public static PhoneBoothLayoutOutputs Execute(Dictionary<string, Model> inputMod
if (layout != null)
{
LayoutStrategies.SetLevelVolume(layout, levelVolume?.Id);
LayoutStrategies.SetParentSpace(layout, room.Id);
output.Model.AddElement(layout);
seatsCount++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public static PrivateOfficeLayoutOutputs Execute(Dictionary<string, Model> input
{
var layout = InstantiateLayout(configs, width, depth, rect, levelVolume?.Transform ?? new Transform(), out var seats);
LayoutStrategies.SetLevelVolume(layout, levelVolume?.Id);
LayoutStrategies.SetParentSpace(layout, room.Id);
output.Model.AddElement(layout);
privateOfficeCount++;
seatsCount += seats;
Expand All @@ -134,6 +135,7 @@ public static PrivateOfficeLayoutOutputs Execute(Dictionary<string, Model> input
{
var layout = InstantiateLayout(configs, width, depth, cinchedPoly, levelVolume?.Transform ?? new Transform(), out var seats);
LayoutStrategies.SetLevelVolume(layout, levelVolume?.Id);
LayoutStrategies.SetParentSpace(layout, room.Id);
output.Model.AddElement(layout);
privateOfficeCount++;
seatsCount += seats;
Expand Down
2 changes: 2 additions & 0 deletions LayoutFunctions/ReceptionLayout/src/ReceptionLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static ReceptionLayoutOutputs Execute(Dictionary<string, Model> inputMode
{
var layout = InstantiateLayout(configs, width, depth, rect, room.Transform, out var seats);
LayoutStrategies.SetLevelVolume(layout, levelVolume?.Id);
LayoutStrategies.SetParentSpace(layout, room.Id);
output.Model.AddElement(layout);
seatsCount += seats;
}
Expand All @@ -104,6 +105,7 @@ public static ReceptionLayoutOutputs Execute(Dictionary<string, Model> inputMode
// output.Model.AddElement(new ModelCurve(cinchedPoly, BuiltInMaterials.ZAxis, levelVolume.Transform));
var layout = InstantiateLayout(configs, width, depth, cinchedPoly, room.Transform, out var seats);
LayoutStrategies.SetLevelVolume(layout, levelVolume?.Id);
LayoutStrategies.SetParentSpace(layout, room.Id);
output.Model.AddElement(layout);
Console.WriteLine("🤷‍♂️ funny shape!!!");
seatsCount += seats;
Expand Down
Loading