Skip to content

Commit

Permalink
Changelog, format, lint, test
Browse files Browse the repository at this point in the history
  • Loading branch information
obucklin committed Mar 19, 2024
1 parent d0e7aad commit ff0c2d4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 39 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added new `NullJoint`.
* Added `mill_depth` argument to butt joints, with geometric representation of milled recess in cross beam.
* Added `ButtJoint` class with methods common to `LButtJoint` and `TButtJoint`
* Added BTLx support for `TButtJoint` and `LButtJoint`
* Added `BTLxLap` process class

### Changed

Expand Down
36 changes: 23 additions & 13 deletions src/compas_timber/connections/butt_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def __init__(
self.features = []
self.test = []


@property
def __data__(self):
data_dict = {
Expand Down Expand Up @@ -110,15 +109,20 @@ def joint_type(self):
return "Butt"

def get_main_cutting_plane(self):
"""Returns the cutting plane for the main beam and the beam.face from which it is derived."""
assert self.main_beam and self.cross_beam

self.reference_side_index_cross, _ = self.get_face_most_towards_beam(self.main_beam, self.cross_beam, ignore_ends=False)
self.reference_side_index_cross, _ = self.get_face_most_towards_beam(
self.main_beam, self.cross_beam, ignore_ends=False
)
if self.reject_i and self.reference_side_index in [4, 5]:
raise BeamJoinningError(
beams=self.beams, joint=self, debug_info="Beams are in I topology and reject_i flag is True"
)

self.reference_side_index_cross, cfr = self.get_face_most_ortho_to_beam(self.main_beam, self.cross_beam, ignore_ends=True)
self.reference_side_index_cross, cfr = self.get_face_most_ortho_to_beam(
self.main_beam, self.cross_beam, ignore_ends=True
)
self.btlx_params_cross["reference_plane_id"] = self.reference_side_index_cross
cross_mating_frame = cfr.copy()
cfr = Frame(cfr.point, cfr.xaxis, cfr.yaxis * -1.0) # flip normal
Expand All @@ -131,22 +135,27 @@ def restore_beams_from_keys(self, assemly):
self.cross_beam = assemly.find_by_key(self.cross_beam_key)

def side_surfaces_cross(self):
"""Returns the two side surfaces of the cross beam."""
if self.reference_side_index_cross == 0:
return self.cross_beam.faces[3], self.cross_beam.faces[1]
elif self.reference_side_index_cross < 3: # 1 or 2
return self.cross_beam.faces[self.reference_side_index_cross-1], self.cross_beam.faces[self.reference_side_index_cross+1]
elif self.reference_side_index_cross < 3: # 1 or 2
return (
self.cross_beam.faces[self.reference_side_index_cross - 1],
self.cross_beam.faces[self.reference_side_index_cross + 1],
)
else:
return self.cross_beam.faces[2], self.cross_beam.faces[0]


def front_back_surface_main(self):
"""Returns the front and back surfaces of the main beam."""
face_dict = Joint._beam_side_incidence(self.cross_beam, self.main_beam, ignore_ends=True)
face_indices = face_dict.keys()
angles = face_dict.values()
angles, face_indices = zip(*sorted(zip(angles, face_indices)))
return self.main_beam.faces[face_indices[0]], self.main_beam.faces[face_indices[3]]

def subtraction_volume(self):
"""Returns the volume to be subtracted from the cross beam."""
vertices = []
front_frame, back_frame = self.front_back_surface_main()
top_frame, bottom_frame = self.get_main_cutting_plane()
Expand All @@ -164,7 +173,7 @@ def subtraction_volume(self):
dots = [dot_vectors(v, self.cross_beam.centerline.direction) for v in pv]
dots, points = zip(*sorted(zip(dots, points)))
min_pt, max_pt = points[0], points[-1]
if i ==1:
if i == 1:
self.btlx_params_cross["start_x"] = abs(dots[0])

top_line = Line(*intersection_plane_plane(Plane.from_frame(side), Plane.from_frame(top_frame)))
Expand All @@ -184,15 +193,18 @@ def subtraction_volume(self):
print(_len)

front_line = Line(*intersection_plane_plane(Plane.from_frame(front_frame), Plane.from_frame(top_frame)))
back_line = Line(*intersection_plane_plane(Plane.from_frame(back_frame), Plane.from_frame(top_frame)))

self.btlx_params_cross["depth"] = self.mill_depth
self.btlx_params_cross["width"] = self.cross_beam.width if self.reference_side_index_cross % 2 == 0 else self.cross_beam.height
self.btlx_params_cross["width"] = (
self.cross_beam.width if self.reference_side_index_cross % 2 == 0 else self.cross_beam.height
)

self.btlx_params_cross["length"] = _len #distance_line_line(front_line, back_line)
self.btlx_params_cross["length"] = _len
if dot_vectors(top_frame.yaxis, front_line.direction) < 0:
front_line = Line(front_line.end, front_line.start)
self.btlx_params_cross["angle"] = abs(angle_vectors_signed(top_frame.xaxis, front_line.direction, top_frame.zaxis, deg=True))
self.btlx_params_cross["angle"] = abs(
angle_vectors_signed(top_frame.xaxis, front_line.direction, top_frame.zaxis, deg=True)
)

center = (vertices[0] + vertices[1] + vertices[2] + vertices[3]) * 0.25
angle = angle_vectors_signed(
Expand All @@ -209,8 +221,6 @@ def subtraction_volume(self):
# self.test = vertices
return ph



def add_features(self):
"""Adds the required extension and trimming features to both beams.
Expand Down
2 changes: 2 additions & 0 deletions src/compas_timber/fabrication/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .btlx import BTLxProcess
from .btlx_processes.btlx_french_ridge_lap import BTLxFrenchRidgeLap
from .btlx_processes.btlx_jack_cut import BTLxJackCut
from .btlx_processes.lap import BTLxLap
from .joint_factories.french_ridge_factory import FrenchRidgeFactory
from .joint_factories.l_butt_factory import LButtFactory
from .joint_factories.l_miter_factory import LMiterFactory
Expand All @@ -11,6 +12,7 @@
"BTLx",
"BTLxProcess",
"BTLxJackCut",
"BTLxLap",
"BTLxFrenchRidgeLap",
"LButtFactory",
"TButtFactory",
Expand Down
27 changes: 10 additions & 17 deletions src/compas_timber/fabrication/btlx_processes/lap.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import math
from collections import OrderedDict

from compas.geometry import Line
from compas.geometry import Plane
from compas.geometry import angle_vectors_signed
from compas.geometry import cross_vectors

from compas_timber.fabrication import BTLx
from compas_timber.fabrication import BTLxProcess
from compas_timber.utils.compas_extra import intersection_line_plane


class BTLxLap(object):
Expand All @@ -17,12 +9,12 @@ class BTLxLap(object):
Parameters
----------
part : :class:`~compas_timber.fabrication.btlx_part.BTLxPart`
The BTLxPart object representing the beam.
frame : :class:`~compas.geometry.Frame`
The frame object representing the cutting plane.
joint_name : str, optional
The name of the joint. Defaults to None.
param_dict : dict
A dictionary containing the parameters for the BTLx lap process.
joint_name : str
The name of the joint. If not provided, the default name is "lap".
kwargs : dict
Additional keyword arguments to be added to the object.
"""

Expand Down Expand Up @@ -65,12 +57,12 @@ def header_attributes(self):
"Process": "yes",
"Priority": "0",
"ProcessID": "0",
"ReferencePlaneID": str(self.reference_plane_id + 1)
"ReferencePlaneID": str(self.reference_plane_id + 1),
}

@property
def process_params(self):
"""This property is required for all process types. It returns a dict with the geometric parameters to fabricate the joint. """
"""This property is required for all process types. It returns a dict with the geometric parameters to fabricate the joint."""

if self.apply_process:
"""the following attributes are specific to Lap"""
Expand All @@ -89,7 +81,7 @@ def process_params(self):
("LeadAngle", "{:.{prec}f}".format(self.lead_angle, prec=BTLx.ANGLE_PRECISION)),
("LeadInclinationParallel", "yes"),
("LeadInclination", "{:.{prec}f}".format(self.lead_inclination, prec=BTLx.ANGLE_PRECISION)),
("MachiningLimits", self.machining_limits)
("MachiningLimits", self.machining_limits),
]
)
print("param dict", od)
Expand All @@ -99,5 +91,6 @@ def process_params(self):

@classmethod
def create_process(cls, param_dict, joint_name=None, **kwargs):
"""Creates a lap process from a dictionary of parameters."""
lap = BTLxLap(param_dict, joint_name, **kwargs)
return BTLxProcess(BTLxLap.PROCESS_TYPE, lap.header_attributes, lap.process_params)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from compas_timber.connections import LButtJoint
from compas_timber.fabrication import BTLx
from compas_timber.fabrication import BTLxJackCut
from compas_timber.fabrication import BTLxLap


class LButtFactory(object):
Expand Down Expand Up @@ -36,6 +37,8 @@ def apply_processings(cls, joint, parts):
cross_part.processings.append(
BTLxJackCut.create_process(cross_part, joint.get_cross_cutting_plane(), "L-Butt Joint")
)
if joint.mill_depth > 0:
cross_part.processings.append(BTLxLap.create_process(joint.btlx_params_cross, "T-Butt Joint"))


BTLx.register_joint(LButtJoint, LButtFactory)
12 changes: 3 additions & 9 deletions src/compas_timber/fabrication/joint_factories/t_butt_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,9 @@ def apply_processings(cls, joint, parts):
cut_plane = joint.get_main_cutting_plane()[0]
main_part.processings.append(BTLxJackCut.create_process(main_part, cut_plane, "T-Butt Joint"))

cross_part = parts[str(joint.cross_beam.key)]
cross_part.processings.append(BTLxLap.create_process(joint.btlx_params_cross, "T-Butt Joint"))





if joint.mill_depth > 0:
cross_part = parts[str(joint.cross_beam.key)]
cross_part.processings.append(BTLxLap.create_process(joint.btlx_params_cross, "T-Butt Joint"))


BTLx.register_joint(TButtJoint, TButtFactory)


0 comments on commit ff0c2d4

Please sign in to comment.