From c1399d9138e4ce905720a51971a9f02c228f58c9 Mon Sep 17 00:00:00 2001 From: Anthonie Kramer Date: Tue, 28 Nov 2023 08:58:43 -0800 Subject: [PATCH] bring back constant --- .../src/IFCToHypar/Converters/FromIfcDoorConverter.cs | 2 +- Elements.Serialization.IFC/test/IFCTests.cs | 4 ++-- Elements/src/BIM/Door/Door.cs | 10 ++++++---- Elements/test/DoorTest.cs | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Elements.Serialization.IFC/src/IFCToHypar/Converters/FromIfcDoorConverter.cs b/Elements.Serialization.IFC/src/IFCToHypar/Converters/FromIfcDoorConverter.cs index f038fe230..ab190b5c6 100644 --- a/Elements.Serialization.IFC/src/IFCToHypar/Converters/FromIfcDoorConverter.cs +++ b/Elements.Serialization.IFC/src/IFCToHypar/Converters/FromIfcDoorConverter.cs @@ -37,7 +37,7 @@ public GeometricElement ConvertToElement(IfcProduct ifcProduct, RepresentationDa //var wall = GetWallFromDoor(ifcDoor, allWalls); var doorWidth = (IfcLengthMeasure)ifcDoor.OverallWidth; var doorHeight = (IfcLengthMeasure)ifcDoor.OverallHeight; - var doorThickness = 2 * 0.0254; + var doorThickness = Door.DEFAULT_DOOR_THICKNESS; var result = new Door(doorWidth, doorHeight, diff --git a/Elements.Serialization.IFC/test/IFCTests.cs b/Elements.Serialization.IFC/test/IFCTests.cs index 77ea7f01b..cd6a0d76f 100644 --- a/Elements.Serialization.IFC/test/IFCTests.cs +++ b/Elements.Serialization.IFC/test/IFCTests.cs @@ -138,8 +138,8 @@ public void Doors() var wall1 = new StandardWall(wallLine1, 0.2, 3, name: "Wall1"); var wall2 = new StandardWall(wallLine2, 0.2, 2, name: "Wall2"); - var door1 = new Door(wallLine1, 0.5, 1.5, 2.0, 2 * 0.0254, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing); - var door2 = new Door(wallLine2, 0.5, 1.5, 1.8, 2 * 0.0254, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing); + var door1 = new Door(wallLine1, 0.5, 1.5, 2.0, Door.DEFAULT_DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing); + var door2 = new Door(wallLine2, 0.5, 1.5, 1.8, Door.DEFAULT_DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.DoubleSwing); wall1.AddDoorOpening(door1); wall2.AddDoorOpening(door2); diff --git a/Elements/src/BIM/Door/Door.cs b/Elements/src/BIM/Door/Door.cs index c1e01e828..3ac461d7e 100644 --- a/Elements/src/BIM/Door/Door.cs +++ b/Elements/src/BIM/Door/Door.cs @@ -23,8 +23,10 @@ public class Door : GeometricElement public double DoorWidth { get; set; } /// Height of a door without a frame. public double DoorHeight { get; set; } + /// Default door thickness. + public static double DEFAULT_DOOR_THICKNESS = 2 * 0.0254; /// Door thickness. - public double DoorThickness { get; set; } + public double DoorThickness { get; set; } = DEFAULT_DOOR_THICKNESS; /// Default thickness of a door frame. public double FrameDepth { get; set; } = 4 * 0.0254; /// Default width of a door frame. @@ -84,7 +86,7 @@ public Door(double clearWidth, DoorHeight = clearHeight; DoorWidth = clearWidth; DoorThickness = thickness; - Material = material; + Material = material ?? BuiltInMaterials.Default; } /// @@ -126,7 +128,7 @@ public Door(Line line, DoorWidth = clearWidth; DoorHeight = clearHeight; DoorThickness = thickness; - Material = material; + Material = material ?? BuiltInMaterials.Default; Transform = GetDoorTransform(line.PointAtNormalized(tPos), line); } @@ -175,7 +177,7 @@ public override void UpdateRepresentations() /// public string GetRepresentationHash() { - return $"{this.GetType().Name}-{this.DoorWidth}-{this.DoorHeight}-{this.DoorThickness}-{this.FrameDepth}-{this.FrameWidth}{this.FrameMaterial}-{this.OpeningType}-{this.OpeningSide}-{this.Material.Name}"; + return $"{this.GetType().Name}-{this.DoorWidth}-{this.DoorHeight}-{this.DoorThickness}-{this.FrameDepth}-{this.FrameWidth}{this.FrameMaterial.Name}-{this.OpeningType}-{this.OpeningSide}-{this.Material.Name}"; } public List GetInstances() diff --git a/Elements/test/DoorTest.cs b/Elements/test/DoorTest.cs index e241e87c2..574171a85 100644 --- a/Elements/test/DoorTest.cs +++ b/Elements/test/DoorTest.cs @@ -14,7 +14,7 @@ public void MakeDoorElement() var line = new Line(new Vector3(0, 0, 0), new Vector3(10, 10, 0)); var wall = new StandardWall(line, 0.1, 3.0); - var door = new Door(wall.CenterLine, 0.5, 2.0, 2.0, 2 * 0.0254, DoorOpeningSide.LeftHand, DoorOpeningType.SingleSwing); + var door = new Door(wall.CenterLine, 0.5, 2.0, 2.0, Door.DEFAULT_DOOR_THICKNESS, DoorOpeningSide.LeftHand, DoorOpeningType.SingleSwing); wall.AddDoorOpening(door); Assert.Single(wall.Openings);