Skip to content

Commit

Permalink
Merge pull request #74 from hypar-io/doors-and-walls-update
Browse files Browse the repository at this point in the history
Doors-and-walls-update (#74)
  • Loading branch information
anthonie-kramer authored Dec 2, 2023
2 parents 86390dd + 8cec412 commit afa646a
Show file tree
Hide file tree
Showing 121 changed files with 2,684 additions and 1,017 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="2.1.0" />
<PackageReference Include="Hypar.Functions" Version="1.10.0" />
<!-- <PackageReference Include="Hypar.Space.LayoutFunctionCommon" Version="1.4.0" /> -->
</ItemGroup>
<ItemGroup>
<!-- <ProjectReference Include="..\..\..\Elements\Elements\src\Elements.csproj" /> -->
<ProjectReference Include="..\..\LayoutFunctionCommon\LayoutFunctionCommon.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="2.2.0-alpha.17" />
<PackageReference Include="Hypar.Functions" Version="1.11.0-alpha.10" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public LevelVolume()
public System.Guid? PlanView { get; set; }

/// <summary>Multiple profiles used for a collection of volumes</summary>
[JsonProperty("Profiles", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[JsonProperty("Profiles", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public IList<Profile> Profiles { get; set; }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Hypar.Elements" Version="2.1.0" />
<PackageReference Include="Hypar.Elements.Components" Version="2.1.0" />
<PackageReference Include="Hypar.Functions" Version="1.10.0" />
<PackageReference Include="Hypar.Elements" Version="2.2.0-alpha.17" />
<PackageReference Include="Hypar.Functions" Version="1.11.0-alpha.10" />
<PackageReference Include="Hypar.Elements.Components" Version="2.2.0-alpha.17" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion LayoutFunctions/CustomLayout/dependencies/LevelVolume.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public LevelVolume()
public System.Guid? PlanView { get; set; }

/// <summary>Multiple profiles used for a collection of volumes</summary>
[JsonProperty("Profiles", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[JsonProperty("Profiles", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public IList<Profile> Profiles { get; set; }


Expand Down
25 changes: 12 additions & 13 deletions LayoutFunctions/CustomLayout/src/CustomSpaceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static CustomSpaceTypeOutputs Execute(Dictionary<string, Model> inputMode
var anchorIndex = Enumerable.Range(0, anchors.Count).OrderBy(a => anchors[a].DistanceTo(anchor)).First();
var closestAnchor = anchors[anchorIndex];
var offsetXform = placedInstance.Transform.Concatenated(new Transform(anchor.Negate())).Concatenated(new Transform(anchor - closestAnchor));
// create rule
// create rule
var placementRule = new PositionPlacementRule(placedInstance.Name, anchorIndex, placedInstance.BaseDefinition, offsetXform);
rules.Add(placementRule);

Expand Down Expand Up @@ -132,19 +132,14 @@ public static CustomSpaceTypeOutputs Execute(Dictionary<string, Model> inputMode
public static Polygon[] OffsetThickenedPolyline(ThickenedPolyline wall, Polyline p)
{
Polygon[] offsets = null;
if (wall.Width.HasValue && wall.Flip.HasValue)

if (wall.LeftWidth > Vector3.EPSILON)
{
offsets = p.OffsetOnSide(wall.Width.Value, wall.Flip.Value);
p = p.OffsetOpen(-wall.LeftWidth);
}
else
{
if (wall.LeftWidth > Vector3.EPSILON)
{
p = p.OffsetOpen(-wall.LeftWidth);
}

offsets = p.OffsetOnSide(wall.LeftWidth + wall.RightWidth, false);
}
offsets = p.OffsetOnSide(wall.LeftWidth + wall.RightWidth, false);

return offsets;
}

Expand All @@ -161,9 +156,13 @@ private static void LayOutAllRoomsOfSpaceType(Model model, IEnumerable<LevelVolu
foreach (var room in meetingRmBoundaries)
{
var spaceBoundary = room.Boundary;
Line orientationGuideEdge = WallGeneration.FindPrimaryAccessEdge(spaceBoundary.Perimeter.Segments(), corridorSegments, levelVolume?.Profile, out var otherSegments);

var orientationTransform = new Transform(Vector3.Origin, orientationGuideEdge.Direction(), Vector3.ZAxis);
var roomEdges = new List<RoomEdge>();
roomEdges.AddRange(spaceBoundary.Perimeter.Segments().Select(s => new RoomEdge() { Line = s }));

RoomEdge orientationGuideEdge = WallGeneration.FindPrimaryAccessEdge(roomEdges, corridorSegments, levelVolume?.Profile, out var otherSegments);

var orientationTransform = new Transform(Vector3.Origin, orientationGuideEdge.Line.Direction(), Vector3.ZAxis);
var boundaryCurves = new List<Polygon>();
boundaryCurves.Add(spaceBoundary.Perimeter);
boundaryCurves.AddRange(spaceBoundary.Voids ?? new List<Polygon>());
Expand Down
10 changes: 5 additions & 5 deletions LayoutFunctions/CustomLayout/test/WallOffsetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void WallOffsetTest()
new Vector3(10,10,0)
});

var tp = new ThickenedPolyline(polyline, 1.0, false, 0.0, 0.0);
var tp = new ThickenedPolyline(polyline, 0, 0);
var walls = CustomSpaceType.OffsetThickenedPolyline(tp, polyline);
Assert.Equal(2, walls.Count());
Assert.Equal(4, walls.First().Vertices.Count);
Expand All @@ -36,7 +36,7 @@ public void WallOffsetTest()
Assert.Contains(new Vector3(11, 10, 0), walls.Last().Vertices);
Assert.Contains(new Vector3(10, 10, 0), walls.Last().Vertices);

tp = new ThickenedPolyline(polyline, 1.0, true, 0.0, 0.0);
tp = new ThickenedPolyline(polyline, 0, 0);
walls = CustomSpaceType.OffsetThickenedPolyline(tp, polyline);
Assert.Contains(new Vector3(0, 1, 0), walls.First().Vertices);
Assert.Contains(new Vector3(9, 1, 0), walls.First().Vertices);
Expand All @@ -47,7 +47,7 @@ public void WallOffsetTest()
Assert.Contains(new Vector3(9, 10, 0), walls.Last().Vertices);
Assert.Contains(new Vector3(10, 10, 0), walls.Last().Vertices);

tp = new ThickenedPolyline(polyline, null, null, 0.0, 1.0);
tp = new ThickenedPolyline(polyline, 0, 1);
walls = CustomSpaceType.OffsetThickenedPolyline(tp, polyline);
Assert.Equal(2, walls.Count());
Assert.Equal(4, walls.First().Vertices.Count);
Expand All @@ -61,7 +61,7 @@ public void WallOffsetTest()
Assert.Contains(new Vector3(11, 10, 0), walls.Last().Vertices);
Assert.Contains(new Vector3(10, 10, 0), walls.Last().Vertices);

tp = new ThickenedPolyline(polyline, null, null, 1.0, 0.0);
tp = new ThickenedPolyline(polyline, 1, 0);
walls = CustomSpaceType.OffsetThickenedPolyline(tp, polyline);
Assert.Contains(new Vector3(0, 1, 0), walls.First().Vertices);
Assert.Contains(new Vector3(9, 1, 0), walls.First().Vertices);
Expand All @@ -72,7 +72,7 @@ public void WallOffsetTest()
Assert.Contains(new Vector3(9, 10, 0), walls.Last().Vertices);
Assert.Contains(new Vector3(10, 10, 0), walls.Last().Vertices);

tp = new ThickenedPolyline(polyline, null, null, 0.4, 0.6);
tp = new ThickenedPolyline(polyline, 0.4, 0.6);
walls = CustomSpaceType.OffsetThickenedPolyline(tp, polyline);
Assert.Contains(new Vector3(0, -0.6, 0), walls.First().Vertices);
Assert.Contains(new Vector3(10.6, -0.6, 0), walls.First().Vertices);
Expand Down
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.1.0-alpha.22" />
<PackageReference Include="Hypar.Functions" Version="1.9.0-alpha.3" />
<PackageReference Include="Hypar.Elements" Version="2.2.0-alpha.17" />
<PackageReference Include="Hypar.Functions" Version="1.11.0-alpha.10" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ namespace DataHallLayout

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.21.0 (Newtonsoft.Json v13.0.0.0)")]

public class DataHallLayoutInputs : S3Args
public class DataHallLayoutInputs : ArgsBase

{
[Newtonsoft.Json.JsonConstructor]

public DataHallLayoutInputs(DataHallLayoutInputsCabinetDepth @cabinetDepth, DataHallLayoutInputsCabinetHeight @cabinetHeight, double @kWRack, double @hotAisleWidth, double @coldAisleWidth, double @clearance, bool @flipDirection, bool @swapColdHotPattern, string bucketName, string uploadsBucket, Dictionary<string, string> modelInputKeys, string gltfKey, string elementsKey, string ifcKey):
base(bucketName, uploadsBucket, modelInputKeys, gltfKey, elementsKey, ifcKey)
public DataHallLayoutInputs(DataHallLayoutInputsCabinetDepth @cabinetDepth, DataHallLayoutInputsCabinetHeight @cabinetHeight, double @kWRack, double @hotAisleWidth, double @coldAisleWidth, double @clearance, bool @flipDirection, bool @swapColdHotPattern, Dictionary<string, string> modelInputKeys, string gltfKey, string elementsKey, string ifcKey):
base(modelInputKeys, gltfKey, elementsKey, ifcKey)
{
var validator = Validator.Instance.GetFirstValidatorForType<DataHallLayoutInputs>();
if(validator != null)
Expand Down
10 changes: 3 additions & 7 deletions LayoutFunctions/DataHall/dependencies/DataHallLayoutOutputs.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,28 @@ public class DataHallLayoutOutputs: SystemResults
/// The number of server cabinets.
/// </summary>
[JsonProperty("Rack Count")]
public double RackCount {get; set;}
public double RackCount { get; set; }

/// <summary>
/// Watts per square foot
/// </summary>
[JsonProperty("Watts/sf")]
public string Wattssf {get; set;}


public string Wattssf { get; set; }

/// <summary>
/// Construct a DataHallLayoutOutputs with default inputs.
/// This should be used for testing only.
/// </summary>
public DataHallLayoutOutputs() : base()
{

}


/// <summary>
/// Construct a DataHallLayoutOutputs specifying all inputs.
/// </summary>
/// <returns></returns>
[JsonConstructor]
public DataHallLayoutOutputs(double rackCount, string wattssf): base()
public DataHallLayoutOutputs(double rackCount, string wattssf) : base()
{
this.RackCount = rackCount;
this.Wattssf = wattssf;
Expand Down
8 changes: 4 additions & 4 deletions LayoutFunctions/DataHall/server/DataHallLayout.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<ItemGroup>
<ProjectReference Include="..\src\DataHallLayout.csproj" />
<ItemGroup>
<ProjectReference Include="..\src\DataHallLayout.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Hypar.Server" Version="1.8.0" />
<ItemGroup>
<PackageReference Include="Hypar.Server" Version="1.11.0-alpha.10" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion LayoutFunctions/DataHall/server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ await HyparServer.StartAsync(
var input = executionRequest.Args.ToObject<DataHallLayout.DataHallLayoutInputs>();
var function = new DataHallLayout.Function();
Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(DataHallLayout.Function).Assembly.Location)!);
return await function.Handler(input, null);
return await function.Handler(input);
});
}
}
Expand Down
16 changes: 4 additions & 12 deletions LayoutFunctions/DataHall/src/Function.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Edits to this code will be overwritten the next time you run 'hypar init'.
// DO NOT EDIT THIS FILE.

using Amazon;
using Amazon.Lambda.Core;
using Hypar.Functions.Execution;
using Hypar.Functions.Execution.AWS;
Expand All @@ -19,9 +18,9 @@ public class Function
{
// Cache the model store for use by subsequent
// executions of this lambda.
private IModelStore<DataHallLayoutInputs> store;
private UrlModelStore<DataHallLayoutInputs> store;

public async Task<DataHallLayoutOutputs> Handler(DataHallLayoutInputs args, ILambdaContext context)
public async Task<DataHallLayoutOutputs> Handler(DataHallLayoutInputs args)
{
// Preload dependencies (if they exist),
// so that they are available during model deserialization.
Expand Down Expand Up @@ -61,15 +60,8 @@ public async Task<DataHallLayoutOutputs> Handler(DataHallLayoutInputs args, ILam
Console.WriteLine($"Time to load assemblies: {sw.Elapsed.TotalSeconds})");

if(this.store == null)
{
if (args.SignedResourceUrls == null)
{
this.store = new S3ModelStore<DataHallLayoutInputs>(RegionEndpoint.GetBySystemName("us-west-1"));
}
else
{
this.store = new UrlModelStore<DataHallLayoutInputs>();
}
{
this.store = new UrlModelStore<DataHallLayoutInputs>();
}


Expand Down
29 changes: 29 additions & 0 deletions LayoutFunctions/Doors/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"inputs": [
{
"id": "workflowId",
"type": "promptString",
"description": "Enter the workflow id to run."
}
],
"configurations": [
{
"name": "Attach to Hypar Run",
"type": "coreclr",
"request": "attach",
"processName": "Doors.Server"
},
{
"name": "Launch Hypar Run (Run once only)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceFolder}/server/bin/Debug/net6.0/Doors.Server.dll",
"args": [
"--workflow-id",
"${input:workflowId}"
],
"preLaunchTask": "server-build"
}
]
}
15 changes: 15 additions & 0 deletions LayoutFunctions/Doors/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "server-build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/server/Doors.Server.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
3 changes: 2 additions & 1 deletion LayoutFunctions/Doors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Create doors for space boundary rooms.
|---|---|---|
|Default Door Width|number|Width of a door panel without a frame. For double doors, the clear width will be double the door width.|
|Default Door Height|number|Height of a door without a frame.|
|Default Type|string|The type of door.|
|Default Door Opening Side|string|The opening side of a door.|
|Default Door Opening Type|string|The type of a door.|


<br>
Expand Down
1 change: 1 addition & 0 deletions LayoutFunctions/Doors/dependencies/CirculationSegment.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public CirculationSegment(ThickenedPolyline @geometry, Profile @profile, double
this.Geometry = @geometry;
}


// Empty constructor
public CirculationSegment()
: base()
Expand Down
Loading

0 comments on commit afa646a

Please sign in to comment.