From c3beb99153536db1e4a41f548b193ccda5db52a1 Mon Sep 17 00:00:00 2001 From: Anthonie Kramer Date: Wed, 29 Nov 2023 13:42:37 -0800 Subject: [PATCH 1/3] fix enums and representations --- Elements/src/BIM/Door/Door.cs | 75 +++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 26 deletions(-) diff --git a/Elements/src/BIM/Door/Door.cs b/Elements/src/BIM/Door/Door.cs index 781eac298..b76c86b3c 100644 --- a/Elements/src/BIM/Door/Door.cs +++ b/Elements/src/BIM/Door/Door.cs @@ -11,17 +11,21 @@ namespace Elements /// Definition of a door public class Door : GeometricElement { + /// The material to be used on the door frame public Material FrameMaterial { get; set; } = new Material(Colors.Gray, 0.5, 0.25, false, null, false, false, null, false, null, 0, false, default, "Silver Frame"); - /// The opening type of the door that should be placed [JsonProperty("Door Opening Type")] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public DoorOpeningType OpeningType { get; private set; } /// The opening side of the door that should be placed [JsonProperty("Door Opening Side")] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] public DoorOpeningSide OpeningSide { get; private set; } /// Width of a door without a frame. + [JsonProperty("Door Width")] public double DoorWidth { get; set; } /// Height of a door without a frame. + [JsonProperty("Door Height")] public double DoorHeight { get; set; } /// Default door thickness. public static double DEFAULT_DOOR_THICKNESS = 2 * 0.0254; @@ -31,7 +35,6 @@ public class Door : GeometricElement public double FrameDepth { get; set; } = 4 * 0.0254; /// Default width of a door frame. public double FrameWidth { get; set; } = 2 * 0.0254; //2 inches - /// Height of the door handle from the ground public double HandleHeight { get; set; } = 42 * 0.0254; /// Radius of the fixture against the door @@ -186,10 +189,11 @@ public List GetInstances() { this.CreateDoorSolidRepresentation(), this.CreateDoorFrameRepresentation(), - this.CreateDoorCurveRepresentation(), this.CreateDoorHandleRepresentation() }; + representationInstances.AddRange(this.CreateDoorCurveRepresentation()); + return representationInstances.Where(instance => instance != null).ToList(); } @@ -216,15 +220,11 @@ private double GetDoorFullWidthWithoutFrame() return 0; } - private RepresentationInstance CreateDoorCurveRepresentation() + private List CreateDoorCurveRepresentation() { - var points = CollectPointsForSchematicVisualization(); - var curve = new IndexedPolycurve(points); - var curveRep = new CurveRepresentation(curve, false); - curveRep.SetSnappingPoints(new List()); - var repInstance = new RepresentationInstance(curveRep, BuiltInMaterials.Black); + var repInstances = CollectPointsForSchematicVisualization(); - return repInstance; + return repInstances; } private RepresentationInstance CreateDoorFrameRepresentation() @@ -293,41 +293,64 @@ private RepresentationInstance CreateDoorSolidRepresentation() return repInstance; } - private List CollectPointsForSchematicVisualization() + private List CollectPointsForSchematicVisualization() { - var points = new List(); + var representationInstances = new List(); if (this.OpeningSide == DoorOpeningSide.Undefined || this.OpeningType == DoorOpeningType.Undefined) { - return points; + return representationInstances; } if (this.OpeningSide != DoorOpeningSide.LeftHand) { - points.AddRange(CollectSchematicVisualizationLines(this, false, false, 90)); + var points = CollectSchematicVisualizationLines(this, false, false, 90); + points.Add(points[0]); + var curve = new IndexedPolycurve(points); + var curveRep = new CurveRepresentation(curve, false); + curveRep.SetSnappingPoints(new List()); + var repInstance = new RepresentationInstance(curveRep, BuiltInMaterials.Black); + representationInstances.Add(repInstance); } if (this.OpeningSide != DoorOpeningSide.RightHand) { - points.AddRange(CollectSchematicVisualizationLines(this, true, false, 90)); + var points = CollectSchematicVisualizationLines(this, true, false, 90); + points.Add(points[0]); + var curve = new IndexedPolycurve(points); + var curveRep = new CurveRepresentation(curve, false); + curveRep.SetSnappingPoints(new List()); + var repInstance = new RepresentationInstance(curveRep, BuiltInMaterials.Black); + representationInstances.Add(repInstance); } - if (this.OpeningType == DoorOpeningType.SingleSwing) + if (this.OpeningType == DoorOpeningType.DoubleSwing) { - return points; - } - if (this.OpeningSide != DoorOpeningSide.LeftHand) - { - points.AddRange(CollectSchematicVisualizationLines(this, false, true, 90)); - } + if (this.OpeningSide != DoorOpeningSide.LeftHand) + { + var points = CollectSchematicVisualizationLines(this, false, true, 90); + points.Add(points[0]); + var curve = new IndexedPolycurve(points); + var curveRep = new CurveRepresentation(curve, false); + curveRep.SetSnappingPoints(new List()); + var repInstance = new RepresentationInstance(curveRep, BuiltInMaterials.Black); + representationInstances.Add(repInstance); + } - if (this.OpeningSide != DoorOpeningSide.RightHand) - { - points.AddRange(CollectSchematicVisualizationLines(this, true, true, 90)); + if (this.OpeningSide != DoorOpeningSide.RightHand) + { + var points = CollectSchematicVisualizationLines(this, true, true, 90); + points.Add(points[0]); + var curve = new IndexedPolycurve(points); + var curveRep = new CurveRepresentation(curve, false); + curveRep.SetSnappingPoints(new List()); + var repInstance = new RepresentationInstance(curveRep, BuiltInMaterials.Black); + representationInstances.Add(repInstance); + } } - return points; + return representationInstances; } private List CollectSchematicVisualizationLines(Door door, bool leftSide, bool inside, double angle) From 59f2e2044b32add2c65e4ae1c5c6581848f7c029 Mon Sep 17 00:00:00 2001 From: Anthonie Kramer Date: Wed, 29 Nov 2023 14:10:50 -0800 Subject: [PATCH 2/3] Included door type override --- Elements/src/BIM/Door/Door.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Elements/src/BIM/Door/Door.cs b/Elements/src/BIM/Door/Door.cs index b76c86b3c..055e9fcf1 100644 --- a/Elements/src/BIM/Door/Door.cs +++ b/Elements/src/BIM/Door/Door.cs @@ -27,6 +27,8 @@ public class Door : GeometricElement /// Height of a door without a frame. [JsonProperty("Door Height")] public double DoorHeight { get; set; } + [JsonProperty("Door Type")] + public string DoorType { get; set; } /// Default door thickness. public static double DEFAULT_DOOR_THICKNESS = 2 * 0.0254; /// Door thickness. From 60b69e821eeda17b613e2a6b7aab1e12c7b40cb9 Mon Sep 17 00:00:00 2001 From: Anthonie Kramer Date: Wed, 29 Nov 2023 14:12:07 -0800 Subject: [PATCH 3/3] description --- Elements/src/BIM/Door/Door.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Elements/src/BIM/Door/Door.cs b/Elements/src/BIM/Door/Door.cs index 055e9fcf1..bba017140 100644 --- a/Elements/src/BIM/Door/Door.cs +++ b/Elements/src/BIM/Door/Door.cs @@ -27,6 +27,7 @@ public class Door : GeometricElement /// Height of a door without a frame. [JsonProperty("Door Height")] public double DoorHeight { get; set; } + /// Type of door (Glass or Solid). [JsonProperty("Door Type")] public string DoorType { get; set; } /// Default door thickness.