diff --git a/Elements/src/BIM/Door/Door.cs b/Elements/src/BIM/Door/Door.cs index 781eac298..bba017140 100644 --- a/Elements/src/BIM/Door/Door.cs +++ b/Elements/src/BIM/Door/Door.cs @@ -11,18 +11,25 @@ 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; } + /// Type of door (Glass or Solid). + [JsonProperty("Door Type")] + public string DoorType { get; set; } /// Default door thickness. public static double DEFAULT_DOOR_THICKNESS = 2 * 0.0254; /// Door thickness. @@ -31,7 +38,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 +192,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 +223,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 +296,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)