Skip to content

Commit

Permalink
Responded to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
obucklin committed Jul 2, 2024
1 parent d357a41 commit b5d4582
Showing 1 changed file with 25 additions and 33 deletions.
58 changes: 25 additions & 33 deletions src/compas_timber/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,31 @@ def __str__(self):

@property
def beams(self):
# type: () -> list[Beam]
return [element if isinstance(element, Beam) else None for element in self.elements()]
# type: () -> Generator[Beam]
for element in self.elements():
if isinstance(element, Beam):
yield element

# @property
# def plates(self):
# # type: () -> list[Beam]
# return [element if isinstance(element, Plate) else None for element in self.elements()]
# # type: () -> Generator[Plate]
# for element in self.elements():
# if isinstance(element, Plate):
# yield element

@property
def joints(self):
# type: () -> list[Joint]
return [
interaction if isinstance(interaction, Joint) else None for interaction in self.interactions()
] # TODO: consider if there are other interaction types...
# type: () -> Generator[Joint]
for interaction in self.interactions():
if isinstance(interaction, Joint):
yield interaction # TODO: consider if there are other interaction types...

@property
def walls(self):
# type: () -> list[Wall]
return [element if isinstance(element, Wall) else None for element in self.elements()]
# type: () -> Generator[Wall]
for element in self.elements():
if isinstance(element, Wall):
yield element

@property
def topologies(self):
Expand All @@ -81,9 +87,7 @@ def center_of_mass(self):
total_position = Point(0, 0, 0)

for element in self.elements():
vol = (
element.obb.volume
) # TODO: include material density...? this uses volume as proxy for mass, which assumes all parts have equal density
vol = element.obb.volume # TODO: include material density...? this uses volume as proxy for mass, which assumes all parts have equal density
point = element.obb.frame.point
total_vol += vol
total_position += point * vol
Expand All @@ -106,44 +110,32 @@ def element_by_guid(self, guid):
Returns
-------
:class:`~compas_timber.elements.Element`
:class:`~compas_model.elements.Element`
The element with the specified GUID.
"""
return self._guid_element[guid]

def add_element(self, element):
# type: (Beam) -> None
"""Adds a Beam to this model.
Parameters
----------
element : :class:`~compas_timber.elements.Element`
The element to add to the model.
"""
_ = super(TimberModel, self).add_element(element)

def add_interaction(self, interaction, elements):
# type: (Joint, tuple[Interaction]) -> None
def add_joint(self, joint, elements):
# type: (Joint, tuple[Element]) -> None
"""Add a joint object to the model.
Parameters
----------
interaction : :class:`~compas_timber.connections.joint`
An instance of a Joint class.
interaction : :class:`~compas_timber.connections.Interaction`
An instance of Interaction class.
beams : tuple(:class:`~compas_timber.elements.Element`)
elements : tuple(:class:`~compas_timber.elements.Element`)
The two elements that should be joined.
"""
if len(elements) != 2:
raise ValueError("Expected 2 parts. Got instead: {}".format(len(elements)))
a, b = elements
print(a, b)
_ = super(TimberModel, self).add_interaction(a, b, interaction=interaction)
_ = super(TimberModel, self).add_interaction(a, b, interaction=joint)

def remove_interaction(self, joint):
def remove_joint(self, joint):
# type: (Joint) -> None
"""Removes this joint object from the model.
Expand Down

0 comments on commit b5d4582

Please sign in to comment.