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

handle position fix #1068

Merged
merged 2 commits into from
Dec 1, 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
35 changes: 18 additions & 17 deletions Elements/src/BIM/Door/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@
[JsonProperty("Door Type")]
public string DoorType { get; set; }
/// <summary>Default door thickness.</summary>
public static double DEFAULT_DOOR_THICKNESS = 2 * 0.0254;
public static double DEFAULT_DOOR_THICKNESS = Units.InchesToMeters(2.0);
/// <summary>Door thickness.</summary>
public double DoorThickness { get; set; } = DEFAULT_DOOR_THICKNESS;
/// <summary>Default thickness of a door frame.</summary>
public double FrameDepth { get; set; } = 4 * 0.0254;
public double FrameDepth { get; set; } = Units.InchesToMeters(4.0);
/// <summary>Default width of a door frame.</summary>
public double FrameWidth { get; set; } = 2 * 0.0254; //2 inches
public double FrameWidth { get; set; } = Units.InchesToMeters(2.0); //2 inches
/// <summary>Height of the door handle from the ground</summary>
public double HandleHeight { get; set; } = 42 * 0.0254;
public double HandleHeight { get; set; } = Units.InchesToMeters(42.0);
/// <summary>Radius of the fixture against the door</summary>
public double HandleBaseRadius { get; set; } = 1.35 * 0.0254;
public double HandleBaseRadius { get; set; } = Units.InchesToMeters(1.35);
/// <summary>Radius of the handle</summary>
public double HandleRadius { get; set; } = 0.45 * 0.0254;
public double HandleRadius { get; set; } = Units.InchesToMeters(0.45);
/// <summary>Length of the handle</summary>
public double HandleLength { get; set; } = 5 * 0.0254;
public double HandleLength { get; set; } = Units.InchesToMeters(5.0);
/// <summary>Depth of the handle from the face of the door</summary>
public double HandleDepth { get; set; } = 2 * 0.0254;
public double HandleDepth { get; set; } = Units.InchesToMeters(2.0);
/// <summary>Original position of the door used for override identity</summary>
public Vector3 OriginalPosition { get; set; }

Expand Down Expand Up @@ -186,7 +186,7 @@
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>()
{
Expand Down Expand Up @@ -431,15 +431,15 @@

if (OpeningSide == DoorOpeningSide.DoubleDoor)
{
var handlePair1 = CreateHandlePair(-3 * 0.0254, false);
var handlePair1 = CreateHandlePair(DoorWidth / 2 + Units.InchesToMeters(3.0), false);
solidOperationsList.AddRange(handlePair1);

var handlePair2 = CreateHandlePair(3 * 0.0254, true);
var handlePair2 = CreateHandlePair(DoorWidth / 2 + Units.InchesToMeters(3.0), true);
solidOperationsList.AddRange(handlePair2);
}
else if (OpeningSide != DoorOpeningSide.Undefined)
{
var xPos = OpeningSide == DoorOpeningSide.LeftHand ? -(FullDoorWidthWithoutFrame / 2 - 2 * 0.0254) : (FullDoorWidthWithoutFrame / 2 - 2 * 0.0254);
var xPos = OpeningSide == DoorOpeningSide.LeftHand ? Units.InchesToMeters(3.0) : Units.InchesToMeters(3.0);
var handle = CreateHandlePair(xPos, OpeningSide == DoorOpeningSide.LeftHand);
solidOperationsList.AddRange(handle);
}
Expand All @@ -450,14 +450,15 @@
return repInst;
}

private List<SolidOperation> CreateHandlePair(double xRelPos, bool isCodirectionalToX)
private List<SolidOperation> CreateHandlePair(double handleOffset, bool isCodirectionalToX)
{
var xOffset = xRelPos * DoorWidth * Vector3.XAxis;
var yOffset = DoorThickness * Vector3.YAxis;
var handleDir = isCodirectionalToX ? Vector3.XAxis : Vector3.XAxis.Negate();

var xOffset = (-DoorWidth / 2 + handleOffset) * handleDir;
var yOffset = DoorThickness / 2 * Vector3.YAxis;
var zOffset = HandleHeight * Vector3.ZAxis;

var solidOperationsList = new List<SolidOperation>();
var handleDir = isCodirectionalToX ? Vector3.XAxis : Vector3.XAxis.Negate();

var handleOrigin1 = xOffset + yOffset + zOffset;
var handle1Ops = CreateHandle(handleOrigin1, handleDir, Vector3.YAxis);
Expand All @@ -474,9 +475,9 @@
{
var circleTransform = new Transform(origin, handleDir, yDir);
var circle = new Circle(circleTransform, HandleBaseRadius).ToPolygon();
var circleOperation = new Extrude(circle, 0.1 * HandleDepth, yDir);
var circleOperation = new Extrude(circle, 0.1 * HandleDepth, yDir.Negate());

var cyl1Transform = new Transform(origin + 0.1 * HandleDepth * yDir, handleDir, yDir);
var cyl1Transform = new Transform(origin, handleDir, yDir);
var cyl1Circle = new Circle(cyl1Transform, HandleRadius).ToPolygon();
var cyl1Operation = new Extrude(cyl1Circle, 0.9 * HandleDepth, yDir);

Expand Down
Loading