Skip to content

Commit

Permalink
added btlx ref edges to Beam
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkasirer committed Jul 8, 2024
1 parent 9289c6e commit 9da597b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Added `ref_frame` attribute to `Beam`.
* Added `ref_sides` attribute to `Beam`.
* Added `ref_edges` attribute to `Beam`.

### Changed

Expand Down
13 changes: 13 additions & 0 deletions src/compas_timber/elements/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class Beam(Element):
Reference frame for machining processes according to BTLx standard.
ref_sides : tuple(:class:`~compas.geometry.Frame`)
A tuple containing the 6 frames representing the sides of the beam according to BTLx standard.
ref_edges : tuple(:class:`~compas.geometry.Line`)
A tuple containing the 4 lines representing the long edges of the beam according to BTLx standard.
faces : list(:class:`~compas.geometry.Frame`)
A list of frames representing the 6 faces of this beam.
0: +y (side's frame normal is equal to the beam's Y positive direction)
Expand Down Expand Up @@ -190,6 +192,17 @@ def ref_sides(self):
Frame(rs6_point, self.ref_frame.zaxis, -self.ref_frame.yaxis, name="RS_6"),
)

@property
def ref_edges(self):
# so tuple is not created every time
ref_sides = self.ref_sides
return (
Line(ref_sides[0].point, ref_sides[0].point + ref_sides[0].xaxis * self.blank_length, name="RE_1"),
Line(ref_sides[1].point, ref_sides[1].point + ref_sides[1].xaxis * self.blank_length, name="RE_2"),
Line(ref_sides[2].point, ref_sides[2].point + ref_sides[2].xaxis * self.blank_length, name="RE_3"),
Line(ref_sides[3].point, ref_sides[3].point + ref_sides[3].xaxis * self.blank_length, name="RE_4"),
)

@property
def centerline(self):
return Line(self.centerline_start, self.centerline_end)
Expand Down
28 changes: 28 additions & 0 deletions tests/compas_timber/test_btlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,31 @@ def test_beam_ref_faces_attribute(mock_beam):
ref_side = mock_beam.ref_sides[index]
assert ref_side_frames_expected[index] == ref_side
assert ref_side.name == "RS_{}".format(index + 1)


def test_beam_ref_edges(mock_beam):

ref_edges_expected = (
Line(
Point(x=-48.67193560518159, y=20.35704602012424, z=0.0005429194857271558),
Point(x=-38.61153715338159, y=24.06100004952424, z=0.5005429194857273),
),
Line(
Point(x=-48.7156552451492, y=20.340949685829152, z=0.9994570805142728),
Point(x=-38.6552567933492, y=24.04490371522915, z=1.499457080514273),
),
Line(
Point(x=-48.37015592401841, y=19.402530686075757, z=0.9994570805142728),
Point(x=-38.309757472218415, y=23.106484715475755, z=1.499457080514273),
),
Line(
Point(x=-48.3264362840508, y=19.41862702037084, z=0.000542919485727154),
Point(x=-38.2660378322508, y=23.12258104977084, z=0.5005429194857273),
),
)
assert len(mock_beam.ref_edges) == 4

for index in range(4):
ref_edge = mock_beam.ref_edges[index]
assert ref_edges_expected[index] == ref_edge
assert ref_edge.name == "RE_{}".format(index + 1)

0 comments on commit 9da597b

Please sign in to comment.