Skip to content

Commit

Permalink
Merge pull request #262 from gramaziokohler/plate_element
Browse files Browse the repository at this point in the history
add plate element
  • Loading branch information
obucklin committed Sep 9, 2024
2 parents cde3ab7 + b4c3b85 commit 857bf0d
Show file tree
Hide file tree
Showing 18 changed files with 521 additions and 128 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added `Plate` element.
* Added attribute `plates` to `TimberModel`.

### Changed

* Renamed `beam` to `element` in different locations to make it more generic.

### Removed

* Removed `add_beam` from `TimberModel`, use `add_element` instead.
* Removed `add_plate` from `TimberModel`, use `add_element` instead.
* Removed `add_wall` from `TimberModel`, use `add_element` instead.


## [0.9.1] 2024-07-05

Expand Down
1 change: 0 additions & 1 deletion src/compas_timber/design/wall_from_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ def generate_perimeter_elements(self):
angle_vectors(segment.direction, self.z_axis, deg=True) < 1
or angle_vectors(segment.direction, self.z_axis, deg=True) > 179
):

if self.lintel_posts:
element.type = "jack_stud"
else:
Expand Down
6 changes: 3 additions & 3 deletions src/compas_timber/design/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ class FeatureDefinition(object):
"""

def __init__(self, feature, beams):
def __init__(self, feature, elements):
self.feature = feature
self.beams = beams
self.elements = elements

def __repr__(self):
return "{}({}, {})".format(FeatureDefinition.__name__, repr(self.feature), self.beams)
return "{}({}, {})".format(FeatureDefinition.__name__, repr(self.feature), self.elements)

def ToString(self):
return repr(self)
Expand Down
2 changes: 2 additions & 0 deletions src/compas_timber/elements/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .beam import Beam
from .plate import Plate
from .wall import Wall
from .features import BrepSubtraction
from .features import CutFeature
Expand All @@ -9,6 +10,7 @@
__all__ = [
"Wall",
"Beam",
"Plate",
"CutFeature",
"DrillFeature",
"MillVolume",
Expand Down
74 changes: 37 additions & 37 deletions src/compas_timber/elements/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@


class FeatureApplicationError(Exception):
"""Raised when a feature cannot be applied to a beam geometry.
"""Raised when a feature cannot be applied to an element geometry.
Attributes
----------
feature_geometry : :class:`~compas.geometry.Geometry`
The geometry of the feature that could not be applied.
beam_geometry : :class:`~compas.geometry.Geometry`
The geometry of the beam that could not be modified.
element_geometry : :class:`~compas.geometry.Geometry`
The geometry of the element that could not be modified.
message : str
The error message.
"""

def __init__(self, feature_geometry, beam_geometry, message):
def __init__(self, feature_geometry, element_geometry, message):
self.feature_geometry = feature_geometry
self.beam_geometry = beam_geometry
self.element_geometry = element_geometry
self.message = message


Expand Down Expand Up @@ -52,12 +52,12 @@ def is_joinery(self):


class CutFeature(Feature):
"""Indicates a cut to be made on a beam.
"""Indicates a cut to be made on an element.
Parameters
----------
cutting_plane : :class:`compas.geometry.Frame`
The plane to cut the beam with.
The plane to cut the element with.
"""

Expand All @@ -71,13 +71,13 @@ def __data__(self):
data_dict["cutting_plane"] = self.cutting_plane
return data_dict

def apply(self, beam_geometry):
"""Apply the feature to the beam geometry.
def apply(self, element_geometry):
"""Apply the feature to the element geometry.
Raises
------
:class:`compas_timber.elements.FeatureApplicationError`
If the cutting plane does not intersect with the beam geometry.
If the cutting plane does not intersect with the element geometry.
Returns
-------
Expand All @@ -86,17 +86,17 @@ def apply(self, beam_geometry):
"""
try:
return beam_geometry.trimmed(self.cutting_plane)
return element_geometry.trimmed(self.cutting_plane)
except BrepTrimmingError:
raise FeatureApplicationError(
self.cutting_plane,
beam_geometry,
"The cutting plane does not intersect with beam geometry.",
element_geometry,
"The cutting plane does not intersect with element geometry.",
)


class DrillFeature(Feature):
"""Parametric drill hole to be made on a beam.
"""Parametric drill hole to be made on an element.
Parameters
----------
Expand All @@ -123,42 +123,42 @@ def __data__(self):
data_dict["length"] = self.length
return data_dict

def apply(self, beam_geometry):
"""Apply the feature to the beam geometry.
def apply(self, element_geometry):
"""Apply the feature to the element geometry.
Raises
------
:class:`compas_timber.elements.FeatureApplicationError`
If the drill volume is not contained in the beam geometry.
If the drill volume is not contained in the element geometry.
Returns
-------
:class:`compas.geometry.Brep`
The resulting geometry after processing.
"""
print("applying drill hole feature to beam")
print("applying drill hole feature to element")
plane = Plane(point=self.line.start, normal=self.line.vector)
plane.point += plane.normal * 0.5 * self.length
drill_volume = Cylinder(frame=Frame.from_plane(plane), radius=self.diameter / 2.0, height=self.length)

try:
return beam_geometry - Brep.from_cylinder(drill_volume)
return element_geometry - Brep.from_cylinder(drill_volume)
except IndexError:
raise FeatureApplicationError(
drill_volume,
beam_geometry,
"The drill volume is not contained in the beam geometry.",
element_geometry,
"The drill volume is not contained in the element geometry.",
)


class MillVolume(Feature):
"""A volume to be milled out of a beam.
"""A volume to be milled out of an element.
Parameters
----------
volume : :class:`compas.geometry.Polyhedron` | :class:`compas.datastructures.Mesh`
The volume to be milled out of the beam.
The volume to be milled out of the element.
"""

Expand All @@ -172,13 +172,13 @@ def __init__(self, volume, **kwargs):
super(MillVolume, self).__init__(**kwargs)
self.mesh_volume = volume

def apply(self, beam_geometry):
"""Apply the feature to the beam geometry.
def apply(self, element_geometry):
"""Apply the feature to the element geometry.
Raises
------
:class:`compas_timber.elements.FeatureApplicationError`
If the volume does not intersect with the beam geometry.
If the volume does not intersect with the element geometry.
Returns
-------
Expand All @@ -192,22 +192,22 @@ def apply(self, beam_geometry):
mesh = self.mesh_volume.to_mesh()
volume = Brep.from_mesh(mesh)
try:
return beam_geometry - volume
return element_geometry - volume
except IndexError:
raise FeatureApplicationError(
volume,
beam_geometry,
"The volume does not intersect with beam geometry.",
element_geometry,
"The volume does not intersect with element geometry.",
)


class BrepSubtraction(Feature):
"""Generic volume subtraction from a beam.
"""Generic volume subtraction from an element.
Parameters
----------
volume : :class:`compas.geometry.Brep`
The volume to be subtracted from the beam.
The volume to be subtracted from the element.
"""

Expand All @@ -221,13 +221,13 @@ def __data__(self):
data_dict["volume"] = self.volume
return data_dict

def apply(self, beam_geometry):
"""Apply the feature to the beam geometry.
def apply(self, element_geometry):
"""Apply the feature to the element geometry.
Raises
------
:class:`compas_timber.elements.FeatureApplicationError`
If the volume does not intersect with the beam geometry.
If the volume does not intersect with the element geometry.
Returns
-------
Expand All @@ -236,10 +236,10 @@ def apply(self, beam_geometry):
"""
try:
return beam_geometry - self.volume
return element_geometry - self.volume
except IndexError:
raise FeatureApplicationError(
self.volume,
beam_geometry,
"The volume does not intersect with beam geometry.",
element_geometry,
"The volume does not intersect with element geometry.",
)
Loading

0 comments on commit 857bf0d

Please sign in to comment.