Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Door property and representation update #1067

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 52 additions & 26 deletions Elements/src/BIM/Door/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@
/// <summary>Definition of a door</summary>
public class Door : GeometricElement
{
/// <summary>The material to be used on the door frame</summary>
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");

/// <summary>The opening type of the door that should be placed</summary>
[JsonProperty("Door Opening Type")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public DoorOpeningType OpeningType { get; private set; }
/// <summary>The opening side of the door that should be placed</summary>
[JsonProperty("Door Opening Side")]
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public DoorOpeningSide OpeningSide { get; private set; }
/// <summary>Width of a door without a frame.</summary>
[JsonProperty("Door Width")]
public double DoorWidth { get; set; }
/// <summary>Height of a door without a frame.</summary>
[JsonProperty("Door Height")]
public double DoorHeight { get; set; }
/// <summary>Type of door (Glass or Solid).</summary>
[JsonProperty("Door Type")]
public string DoorType { get; set; }
/// <summary>Default door thickness.</summary>
public static double DEFAULT_DOOR_THICKNESS = 2 * 0.0254;
/// <summary>Door thickness.</summary>
Expand All @@ -31,7 +38,6 @@
public double FrameDepth { get; set; } = 4 * 0.0254;
/// <summary>Default width of a door frame.</summary>
public double FrameWidth { get; set; } = 2 * 0.0254; //2 inches

/// <summary>Height of the door handle from the ground</summary>
public double HandleHeight { get; set; } = 42 * 0.0254;
/// <summary>Radius of the fixture against the door</summary>
Expand Down Expand Up @@ -180,16 +186,17 @@
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<RepresentationInstance> GetInstances()

Check warning on line 189 in Elements/src/BIM/Door/Door.cs

View workflow job for this annotation

GitHub Actions / build-and-test

Missing XML comment for publicly visible type or member 'Door.GetInstances()'
{
var representationInstances = new List<RepresentationInstance>()
{
this.CreateDoorSolidRepresentation(),
this.CreateDoorFrameRepresentation(),
this.CreateDoorCurveRepresentation(),
this.CreateDoorHandleRepresentation()
};

representationInstances.AddRange(this.CreateDoorCurveRepresentation());

return representationInstances.Where(instance => instance != null).ToList();
}

Expand All @@ -216,15 +223,11 @@
return 0;
}

private RepresentationInstance CreateDoorCurveRepresentation()
private List<RepresentationInstance> CreateDoorCurveRepresentation()
{
var points = CollectPointsForSchematicVisualization();
var curve = new IndexedPolycurve(points);
var curveRep = new CurveRepresentation(curve, false);
curveRep.SetSnappingPoints(new List<SnappingPoints>());
var repInstance = new RepresentationInstance(curveRep, BuiltInMaterials.Black);
var repInstances = CollectPointsForSchematicVisualization();

return repInstance;
return repInstances;
}

private RepresentationInstance CreateDoorFrameRepresentation()
Expand Down Expand Up @@ -293,41 +296,64 @@
return repInstance;
}

private List<Vector3> CollectPointsForSchematicVisualization()
private List<RepresentationInstance> CollectPointsForSchematicVisualization()
{
var points = new List<Vector3>();
var representationInstances = new List<RepresentationInstance>();

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<SnappingPoints>());
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<SnappingPoints>());
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<SnappingPoints>());
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<SnappingPoints>());
var repInstance = new RepresentationInstance(curveRep, BuiltInMaterials.Black);
representationInstances.Add(repInstance);
}
}

return points;
return representationInstances;
}

private List<Vector3> CollectSchematicVisualizationLines(Door door, bool leftSide, bool inside, double angle)
Expand Down
Loading