diff --git a/LayoutFunctions/Doors/dependencies/DoorsInputs.g.cs b/LayoutFunctions/Doors/dependencies/DoorsInputs.g.cs index bdeab929..66fe2d69 100644 --- a/LayoutFunctions/Doors/dependencies/DoorsInputs.g.cs +++ b/LayoutFunctions/Doors/dependencies/DoorsInputs.g.cs @@ -329,19 +329,19 @@ public partial class DoorPositionsValue { [Newtonsoft.Json.JsonConstructor] - public DoorPositionsValue(Transform @transform, double @doorWidth, double @doorHeight, DoorPositionsValueDefaultDoorOpeningSide @defaultDoorOpeningSide, DoorPositionsValueDefaultDoorOpeningType @defaultDoorOpeningType) + public DoorPositionsValue(Transform @transform, double @doorWidth, double @doorHeight, DoorPositionsValueDoorOpeningSide @doorOpeningSide, DoorPositionsValueDoorOpeningType @doorOpeningType) { var validator = Validator.Instance.GetFirstValidatorForType(); if(validator != null) { - validator.PreConstruct(new object[]{ @transform, @doorWidth, @doorHeight, @defaultDoorOpeningSide, @defaultDoorOpeningType}); + validator.PreConstruct(new object[]{ @transform, @doorWidth, @doorHeight, @doorOpeningSide, @doorOpeningType}); } this.Transform = @transform; this.DoorWidth = @doorWidth; this.DoorHeight = @doorHeight; - this.DefaultDoorOpeningSide = @defaultDoorOpeningSide; - this.DefaultDoorOpeningType = @defaultDoorOpeningType; + this.DoorOpeningSide = @doorOpeningSide; + this.DoorOpeningType = @doorOpeningType; if(validator != null) { @@ -363,14 +363,14 @@ public DoorPositionsValue(Transform @transform, double @doorWidth, double @doorH public double DoorHeight { get; set; } = 2.1D; /// The opening side of a door. - [Newtonsoft.Json.JsonProperty("Default Door Opening Side", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("Door Opening Side", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public DoorPositionsValueDefaultDoorOpeningSide DefaultDoorOpeningSide { get; set; } = DoorPositionsValueDefaultDoorOpeningSide.Left_Hand; + public DoorPositionsValueDoorOpeningSide DoorOpeningSide { get; set; } = DoorPositionsValueDoorOpeningSide.Left_Hand; /// The type of a door. - [Newtonsoft.Json.JsonProperty("Default Door Opening Type", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonProperty("Door Opening Type", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] - public DoorPositionsValueDefaultDoorOpeningType DefaultDoorOpeningType { get; set; } = DoorPositionsValueDefaultDoorOpeningType.Single_Swing; + public DoorPositionsValueDoorOpeningType DoorOpeningType { get; set; } = DoorPositionsValueDoorOpeningType.Single_Swing; } @@ -426,7 +426,7 @@ public DoorPositionsOverrideAdditionValue(Transform @transform, double @doorWidt } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.21.0 (Newtonsoft.Json v13.0.0.0)")] - public enum DoorPositionsValueDefaultDoorOpeningSide + public enum DoorPositionsValueDoorOpeningSide { [System.Runtime.Serialization.EnumMember(Value = @"Left Hand")] Left_Hand = 0, @@ -440,7 +440,7 @@ public enum DoorPositionsValueDefaultDoorOpeningSide } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.21.0 (Newtonsoft.Json v13.0.0.0)")] - public enum DoorPositionsValueDefaultDoorOpeningType + public enum DoorPositionsValueDoorOpeningType { [System.Runtime.Serialization.EnumMember(Value = @"Single Swing")] Single_Swing = 0, diff --git a/LayoutFunctions/Doors/hypar.json b/LayoutFunctions/Doors/hypar.json index 0022dfe1..e15d8d83 100644 --- a/LayoutFunctions/Doors/hypar.json +++ b/LayoutFunctions/Doors/hypar.json @@ -180,7 +180,7 @@ "$hyparUnitType": "length", "minimum": 2.032 }, - "Default Door Opening Side": { + "Door Opening Side": { "default": "Left Hand", "description": "The opening side of a door.", "type": "string", @@ -190,7 +190,7 @@ "Double Door" ] }, - "Default Door Opening Type": { + "Door Opening Type": { "default": "Single Swing", "description": "The type of a door.", "type": "string", diff --git a/LayoutFunctions/Doors/src/Doors.cs b/LayoutFunctions/Doors/src/Doors.cs index ac756e40..024e6d42 100644 --- a/LayoutFunctions/Doors/src/Doors.cs +++ b/LayoutFunctions/Doors/src/Doors.cs @@ -32,23 +32,23 @@ public static DoorsOutputs Execute(Dictionary inputModels, DoorsI foreach (var room in rooms) { var pair = RoomDefaultDoorWall(room, levelCorridorsSegments, walls); - if (pair == null || pair.Value.RoomEdge == null || pair.Value.Segment == null) + if (pair == null || pair.Value.Wall == null || pair.Value.Segment == null) { continue; } - var wallCandidate = pair.Value.RoomEdge; + var wall = pair.Value.Wall; var openingSide = ConvertOpeningSideEnum(input.DefaultDoorOpeningSide); var openingType = ConvertOpeningTypeEnum(input.DefaultDoorOpeningType); - if (!wallCandidate.Thickness.HasValue) continue; - var wallThickness = wallCandidate.Thickness.Value.innerWidth + wallCandidate.Thickness.Value.outerWidth; + if (!wall.Thickness.HasValue) continue; + var wallThickness = wall.Thickness.Value.innerWidth + wall.Thickness.Value.outerWidth; // Don't add door if the wall is zero thickness. if (wallThickness == 0.0) continue; // Don't add door if the wall length is too short. - if (wallCandidate.Line.Length() < doorOffset + input.DefaultDoorWidth) continue; + if (wall.Line.Length() < doorOffset + input.DefaultDoorWidth) continue; var doorOriginalPosition = pair.Value.Segment.PointAt(doorOffset + input.DefaultDoorWidth / 2); @@ -59,15 +59,15 @@ public static DoorsOutputs Execute(Dictionary inputModels, DoorsI if (doorOverride != null && doorOverride.Value.Transform != null) { doorCurrentPosition = doorOverride.Value.Transform.Origin; - openingSide = ConvertOpeningSideEnum(doorOverride.Value.DefaultDoorOpeningSide); - openingType = ConvertOpeningTypeEnum(doorOverride.Value.DefaultDoorOpeningType); - wallCandidate = GetClosestWallCandidate(doorCurrentPosition, walls, out doorCurrentPosition); + openingSide = ConvertOpeningSideEnum(doorOverride.Value.DoorOpeningSide); + openingType = ConvertOpeningTypeEnum(doorOverride.Value.DoorOpeningType); + wall = GetClosestWallCandidate(doorCurrentPosition, walls, out doorCurrentPosition); } double width = doorOverride?.Value.DoorWidth ?? input.DefaultDoorWidth; double height = doorOverride?.Value.DoorHeight ?? input.DefaultDoorHeight; - var door = CreateDoor(wallCandidate, doorOriginalPosition, doorCurrentPosition, width, height, Door.DOOR_THICKNESS, openingSide, openingType, doorOverride); + var door = CreateDoor(wall, doorOriginalPosition, doorCurrentPosition, width, height, Door.DOOR_THICKNESS, openingSide, openingType, doorOverride); if (door != null) { doors.Add(door); @@ -78,7 +78,7 @@ public static DoorsOutputs Execute(Dictionary inputModels, DoorsI AddDoors(doors, input.Overrides.Additions.DoorPositions, walls, input.Overrides); RemoveDoors(doors, input.Overrides.Removals.DoorPositions); - output.Model.AddElements(doors); + // output.Model.AddElements(doors); return output; } @@ -140,7 +140,7 @@ private static List GetWallCandidates(Dictionary inputM return roomEdges; } - private static (Line Segment, RoomEdge RoomEdge)? RoomDefaultDoorWall( + private static (Line Segment, RoomEdge Wall)? RoomDefaultDoorWall( SpaceBoundary room, IEnumerable corridorsSegments, IEnumerable wallCandidates) @@ -159,7 +159,7 @@ private static (Line Segment, RoomEdge RoomEdge)? RoomDefaultDoorWall( return null; } - var wall = RoomLongestWallCandidate(roomWalls); + var wall = RoomLongestWallCandidate(room, roomWalls); wall = roomWalls.FirstOrDefault(x => x.Item2.PrimaryEntryEdge == true); @@ -168,7 +168,7 @@ private static (Line Segment, RoomEdge RoomEdge)? RoomDefaultDoorWall( private static void AddDoors(List doors, IEnumerable additions, - List roomEdges, + List walls, Overrides overrides) { foreach (var addition in additions) @@ -176,8 +176,8 @@ private static void AddDoors(List doors, var originalPosition = addition.Value.Transform.Origin; var openingSide = ConvertOpeningSideEnum(addition.Value.DoorOpeningSide); var openingType = ConvertOpeningTypeEnum(addition.Value.DoorOpeningType); - var wallCandidate = GetClosestWallCandidate(originalPosition, roomEdges, out originalPosition); - if (wallCandidate == null) + var wall = GetClosestWallCandidate(originalPosition, walls, out originalPosition); + if (wall == null) { continue; } @@ -192,12 +192,12 @@ private static void AddDoors(List doors, currentPosition = doorOverride.Value.Transform.Origin; width = doorOverride.Value.DoorWidth; height = doorOverride.Value.DoorHeight; - wallCandidate = GetClosestWallCandidate(currentPosition, roomEdges, out currentPosition); - openingSide = ConvertOpeningSideEnum(doorOverride.Value.DefaultDoorOpeningSide); - openingType = ConvertOpeningTypeEnum(doorOverride.Value.DefaultDoorOpeningType); + wall = GetClosestWallCandidate(currentPosition, walls, out currentPosition); + openingSide = ConvertOpeningSideEnum(doorOverride.Value.DoorOpeningSide); + openingType = ConvertOpeningTypeEnum(doorOverride.Value.DoorOpeningType); } - var door = CreateDoor(wallCandidate, originalPosition, currentPosition, width, height, Door.DOOR_THICKNESS, openingSide, openingType, doorOverride); + var door = CreateDoor(wall, originalPosition, currentPosition, width, height, Door.DOOR_THICKNESS, openingSide, openingType, doorOverride); if (door != null) { doors.Add(door); @@ -227,29 +227,30 @@ private static void RemoveDoors(List doors, .Select(edge => edge.Line).ToList(); return corridorEdges; } - private static List<(Line, RoomEdge)> GetRoomWallCandidates(List corridorEdges, + private static List<(Line, RoomEdge)> GetRoomWallCandidates(List corridorEdges, IEnumerable wallCandidates) { - var roomEdges = new List<(Line, RoomEdge)>(); + var roomWalls = new List<(Line, RoomEdge)>(); foreach (var rs in corridorEdges) { var wall = wallCandidates.FirstOrDefault(wc => IsWallCoverRoomSegment(rs, wc)); if (wall != null) { - roomEdges.Add((rs, wall)); + roomWalls.Add((rs, wall)); } } - return roomEdges; + return roomWalls; } private static (Line, RoomEdge)? RoomLongestWallCandidate( - IEnumerable<(Line CorridorEdge, RoomEdge RoomEdge)> roomEdges) + SpaceBoundary room, + IEnumerable<(Line CorridorEdge, RoomEdge Wall)> roomWalls) { double maxLength = 0; (Line, RoomEdge)? longestWall = null; - foreach (var (edge, wall) in roomEdges) + foreach (var (edge, wall) in roomWalls) { var wallLength = edge.Length(); if (wallLength > maxLength) @@ -309,7 +310,7 @@ private static bool IsWallCoverRoomSegment(Line segment, RoomEdge wallCandidate) return null; } - double minDist = double.MaxValue; + double minDist = Double.MaxValue; RoomEdge? closestWall = null; foreach (var wall in wallCandidates)