Skip to content

Commit

Permalink
Use GetCellSeparators lines for Grid visualization performance improv…
Browse files Browse the repository at this point in the history
…ement. Add "No Grid" filter
  • Loading branch information
DmytroMuravskyi committed Jul 25, 2023
1 parent 79ec042 commit 04d5a85
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="2.0.0-alpha.18" />
<PackageReference Include="Hypar.Elements" Version="2.0.0-alpha.24" />
<PackageReference Include="Hypar.Functions" Version="1.6.0" />
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions LayoutFunctions/DataHall/hypar.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@
"content_catalogs": [
"https://hypar-content-catalogs.s3-us-west-2.amazonaws.com/56433155-6494-428c-b800-53d18234e5cf/data-rack-56433155-6494-428c-b800-53d18234e5cf-model.json"
],
"filters": {
"No Grid": {
"context": "[*discriminator!=Elements.ModelLines]",
"default": true
}
},
"repository_url": "https://github.com/hypar-io/function",
"source_file_key": null,
"preview_image": null,
Expand Down
22 changes: 21 additions & 1 deletion LayoutFunctions/DataHall/src/DataHallLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static DataHallLayoutOutputs Execute(Dictionary<string, Model> inputModel
var floorGrid = new Grid2d(profile.Perimeter, alignment);
floorGrid.U.DivideByFixedLength(0.6096);
floorGrid.V.DivideByFixedLength(0.6096);
model.AddElements(floorGrid.ToModelCurves(room.Transform));
model.AddElement(ToModelLines(floorGrid, room.Transform));

double rackAngle = 0;
if (input.SwapColdHotPattern) rackAngle = 180;
Expand Down Expand Up @@ -141,5 +141,25 @@ public static DataHallLayoutOutputs Execute(Dictionary<string, Model> inputModel
output.Warnings.AddRange(warnings);
return output;
}

private static ModelLines ToModelLines(Grid2d grid, Transform transform)
{
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);
foreach (var b in boundary.Concat(curves))
{
var parameters = b.GetSubdivisionParameters();
var points = parameters.Select(p => b.PointAt(p)).ToList();
for (int i = 0; i < points.Count - 1; i++)
{
ml.Lines.Add(new Line(points[i], points[i + 1]));
}
}
return ml;
}
}
}

0 comments on commit 04d5a85

Please sign in to comment.