Skip to content

Commit

Permalink
Merge pull request #1068 from hypar-io/door-handle-fix
Browse files Browse the repository at this point in the history
handle position fix (#1068)
  • Loading branch information
anthonie-kramer authored Dec 1, 2023
2 parents 0f97b40 + dd770bf commit 311e767
Showing 1 changed file with 18 additions and 17 deletions.
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 @@ public class Door : GeometricElement
[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 @@ -431,15 +431,15 @@ private RepresentationInstance CreateDoorHandleRepresentation()

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 @@ private RepresentationInstance CreateDoorHandleRepresentation()
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 @@ private List<SolidOperation> CreateHandle(Vector3 origin, Vector3 handleDir, Vec
{
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

0 comments on commit 311e767

Please sign in to comment.