Skip to content

Commit

Permalink
assembly -> model
Browse files Browse the repository at this point in the history
  • Loading branch information
chenkasirer committed May 6, 2024
1 parent 2cc28d7 commit 91091a2
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 53 deletions.
3 changes: 0 additions & 3 deletions src/compas_timber/assembly/__init__.py

This file was deleted.

8 changes: 4 additions & 4 deletions src/compas_timber/connections/butt_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
class ButtJoint(Joint):
"""Abstract Lap type joint with functions common to L-Butt and T-Butt Joints.
Do not instantiate directly. Please use `**LapJoint.create()` to properly create an instance of lap sub-class and associate it with an assembly.
Do not instantiate directly. Please use `**LapJoint.create()` to properly create an instance of lap sub-class and associate it with an model.
Parameters
----------
assembly : :class:`~compas_timber.assembly.TimberAssembly`
The assembly associated with the beams to be joined.
model : :class:`~compas_timber.model.TimberAssembly`
The model associated with the beams to be joined.
main_beam : :class:`~compas_timber.parts.Beam`
The main beam to be joined.
cross_beam : :class:`~compas_timber.parts.Beam`
Expand Down Expand Up @@ -73,7 +73,7 @@ def beams(self):
return [self.main_beam, self.cross_beam]

def restore_beams_from_keys(self, model):
"""After de-serialization, resotres references to the main and cross beams saved in the assembly."""
"""After de-serialization, resotres references to the main and cross beams saved in the model."""
self.main_beam = model.elementdict[self.main_beam_key]
self.cross_beam = model.elementdict[self.cross_beam_key]

Expand Down
8 changes: 4 additions & 4 deletions src/compas_timber/connections/french_ridge_lap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class FrenchRidgeLapJoint(Joint):
This joint type is compatible with beams in L topology.
Please use `LButtJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `LButtJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
assembly : :class:`~compas_timber.assembly.TimberAssembly`
The assembly associated with the beams to be joined.
model : :class:`~compas_timber.model.TimberAssembly`
The model associated with the beams to be joined.
beam_a : :class:`~compas_timber.parts.Beam`
The top beam to be joined.
beam_b : :class:`~compas_timber.parts.Beam`
Expand Down Expand Up @@ -75,7 +75,7 @@ def cutting_plane_bottom(self):
return cfr

def restore_beams_from_keys(self, assemly):
"""After de-serialization, restores references to the top and bottom beams saved in the assembly."""
"""After de-serialization, restores references to the top and bottom beams saved in the model."""
self.beam_a = assemly.find_by_key(self.beam_a_key)
self.beam_b = assemly.find_by_key(self.beam_b_key)
self._beams = (self.beam_a, self.beam_b)
Expand Down
16 changes: 8 additions & 8 deletions src/compas_timber/connections/joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def restore_beams_from_keys(self):
"""Restores the reference to the beams associate with this joint.
During serialization, :class:`compas_timber.parts.Beam` objects
are serialized by :class:`compas_timber.assembly`. To avoid circular references, Joint only stores the keys
are serialized by :class:`compas_timber.model`. To avoid circular references, Joint only stores the keys
of the respective beams.
This method is called by :class:`compas_timber.assembly` during de-serialization to restore the references.
This method is called by :class:`compas_timber.model` during de-serialization to restore the references.
Since the roles of the beams are joint specific (e.g. main/cross beam) this method should be implemented by
the concrete implementation.
Expand All @@ -95,10 +95,10 @@ def restore_beams_from_keys(self):
raise NotImplementedError

@classmethod
def create(cls, assembly, *beams, **kwargs):
"""Creates an instance of this joint and creates the new connection in `assembly`.
def create(cls, model, *beams, **kwargs):
"""Creates an instance of this joint and creates the new connection in `model`.
`beams` are expected to have been added to `assembly` before calling this method.
`beams` are expected to have been added to `model` before calling this method.
This code does not verify that the given beams are adjacent and/or lie in a topology which allows connecting
them. This is the responsibility of the calling code.
Expand All @@ -107,8 +107,8 @@ def create(cls, assembly, *beams, **kwargs):
Parameters
----------
assemebly : :class:`~compas_timber.assembly.Assembly`
The assembly to which the beams and this joing belong.
model : :class:`~compas_timber.model.TimberModel`
The model to which the beams and this joing belong.
beams : list(:class:`~compas_timber.parts.Beam`)
A list containing two beams that whould be joined together
Expand All @@ -122,7 +122,7 @@ def create(cls, assembly, *beams, **kwargs):
if len(beams) < 2:
raise ValueError("Expected at least 2 beams. Got instead: {}".format(len(beams)))
joint = cls(*beams, **kwargs)
assembly.add_joint(joint, beams)
model.add_joint(joint, beams)
joint.add_features()
return joint

Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/connections/l_butt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class LButtJoint(ButtJoint):
This joint type is compatible with beams in L topology.
Please use `LButtJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `LButtJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/connections/l_halflap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LHalfLapJoint(LapJoint):
This joint type is compatible with beams in L topology.
Please use `LHalfLapJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `LHalfLapJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/connections/l_miter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LMiterJoint(Joint):
This joint type is compatible with beams in L topology.
Please use `LMiterJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `LMiterJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
Expand Down
4 changes: 2 additions & 2 deletions src/compas_timber/connections/lap_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class LapJoint(Joint):
"""Abstract Lap type joint with functions common to L-Lap, T-Lap, and X-Lap Joints.
Do not instantiate directly. Please use `**LapJoint.create()` to properly create an instance of lap sub-class and associate it with an assembly.
Do not instantiate directly. Please use `**LapJoint.create()` to properly create an instance of lap sub-class and associate it with an model.
Parameters
----------
Expand Down Expand Up @@ -64,7 +64,7 @@ def beams(self):
return [self.main_beam, self.cross_beam]

def restore_beams_from_keys(self, model):
"""After de-serialization, resotres references to the main and cross beams saved in the assembly."""
"""After de-serialization, resotres references to the main and cross beams saved in the model."""
self.main_beam = model.elementdict[self.main_beam_key]
self.cross_beam = model.elementdict[self.cross_beam_key]

Expand Down
4 changes: 2 additions & 2 deletions src/compas_timber/connections/null_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class NullJoint(Joint):
Can be used to join to beams which shouldn't join.
Please use `NullJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `NullJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
Expand Down Expand Up @@ -55,7 +55,7 @@ def beams(self):
return [self.beam_a, self.beam_b]

def restore_beams_from_keys(self, model):
"""After de-serialization, resotres references to the main and cross beams saved in the assembly."""
"""After de-serialization, resotres references to the main and cross beams saved in the model."""
self.beam_a = model.elementdict[self.beam_a_key]
self.beam_b = model.elementdict[self.beam_b_key]

Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/connections/t_butt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TButtJoint(ButtJoint):
This joint type is compatible with beams in T topology.
Please use `TButtJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `TButtJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/connections/t_halflap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class THalfLapJoint(LapJoint):
This joint type is compatible with beams in T topology.
Please use `THalfLapJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `THalfLapJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/connections/x_halflap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class XHalfLapJoint(LapJoint):
This joint type is compatible with beams in T topology.
Please use `XHalfLapJoint.create()` to properly create an instance of this class and associate it with an assembly.
Please use `XHalfLapJoint.create()` to properly create an instance of this class and associate it with an model.
Parameters
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ghpythonlib.componentbase import executingcomponent as component
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Warning

from compas_timber.assembly import TimberModel
from compas_timber.model import TimberModel
from compas_timber.connections import BeamJoinningError
from compas_timber.connections import ConnectionSolver
from compas_timber.connections import JointTopology
Expand All @@ -23,7 +23,7 @@
}


class Assembly(component):
class ModelComponent(component):
def get_joints_from_rules(self, beams, rules, topologies):
if not isinstance(rules, list):
rules = [rules]
Expand Down Expand Up @@ -119,14 +119,14 @@ def RunScript(self, Beams, JointRules, Features, MaxDistance, CreateGeometry):
if MaxDistance is None:
MaxDistance = TOL.ABSOLUTE # compared to calculted distance, so shouldn't be just 0.0

Assembly = TimberModel()
Model = TimberModel()
debug_info = DebugInfomation()
for beam in Beams:
# prepare beams for downstream processing
beam.remove_features()
beam.remove_blank_extension()
beam.debug_infos = []
Assembly.add_beam(beam)
Model.add_beam(beam)
topologies = []
solver = ConnectionSolver()
found_pairs = solver.find_intersecting_pairs(Beams, rtree=True, max_distance=MaxDistance)
Expand All @@ -135,9 +135,9 @@ def RunScript(self, Beams, JointRules, Features, MaxDistance, CreateGeometry):
detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=MaxDistance)
if not detected_topo == JointTopology.TOPO_UNKNOWN:
topologies.append({"detected_topo": detected_topo, "beam_a": beam_a, "beam_b": beam_b})
Assembly.set_topologies(topologies)
Model.set_topologies(topologies)

beams = Assembly.beams
beams = Model.beams
joints = self.get_joints_from_rules(beams, JointRules, topologies)

if joints:
Expand All @@ -150,7 +150,7 @@ def RunScript(self, Beams, JointRules, Features, MaxDistance, CreateGeometry):
if beam_pair_ids in handled_beams:
continue
try:
joint.joint_type.create(Assembly, *beams_to_pair, **joint.kwargs)
joint.joint_type.create(Model, *beams_to_pair, **joint.kwargs)
except BeamJoinningError as bje:
debug_info.add_joint_error(bje)
else:
Expand All @@ -164,7 +164,7 @@ def RunScript(self, Beams, JointRules, Features, MaxDistance, CreateGeometry):

Geometry = None
scene = Scene()
for beam in Assembly.beams:
for beam in Model.beams:
if CreateGeometry:
scene.add(beam.geometry)
if beam.debug_infos:
Expand All @@ -176,4 +176,4 @@ def RunScript(self, Beams, JointRules, Features, MaxDistance, CreateGeometry):
self.AddRuntimeMessage(Warning, "Error found during joint creation. See DebugInfo output for details.")

Geometry = scene.draw()
return Assembly, Geometry, debug_info
return Model, Geometry, debug_info
3 changes: 3 additions & 0 deletions src/compas_timber/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .model import TimberModel

__all__ = ["TimberModel"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@


class TimberModel(Model):
"""Represents a timber assembly containing beams and joints etc.
"""Represents a timber model containing beams and joints etc.
Attributes
----------
beams : list(:class:`~compas_timber.parts.Beam`)
A list of beams assigned to this assembly.
A list of beams assigned to this model.
joints : list(:class:`~compas_timber.connections.Joint`)
A list of joints assigned to this assembly.
A list of joints assigned to this model.
topologies : list(dict)
A list of JointTopology for assembly. dict is: {"detected_topo": detected_topo, "beam_a_key": beam_a_key, "beam_b_key":beam_b_key}
A list of JointTopology for model. dict is: {"detected_topo": detected_topo, "beam_a_key": beam_a_key, "beam_b_key":beam_b_key}
See :class:`~compas_timber.connections.JointTopology`.
"""
Expand All @@ -35,7 +35,7 @@ def __init__(self, *args, **kwargs):
self._topologies = [] # added to avoid calculating multiple times

def __str__(self):
"""Returns a formatted string representation of this assembly.
"""Returns a formatted string representation of this model.
Return
------
Expand All @@ -57,12 +57,12 @@ def joints(self):
return self._joints

def add_beam(self, beam):
"""Adds a Beam to this assembly.
"""Adds a Beam to this model.
Parameters
----------
beam : :class:`~compas_timber.parts.Beam`
The beam to add to the assembly.
The beam to add to the model.
Returns
-------
Expand All @@ -74,7 +74,7 @@ def add_beam(self, beam):
self._beams.append(beam)

def add_joint(self, joint, parts):
"""Add a joint object to the assembly.
"""Add a joint object to the model.
Parameters
----------
Expand All @@ -87,7 +87,7 @@ def add_joint(self, joint, parts):
Returns
-------
int
The identifier of the joint in the current assembly graph.
The identifier of the joint in the current model graph.
"""
# self._validate_joining_operation(joint, parts)
Expand All @@ -100,7 +100,7 @@ def add_joint(self, joint, parts):
self._joints.append(joint)

def remove_joint(self, joint):
"""Removes this joint object from the assembly.
"""Removes this joint object from the model.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/planning/sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from compas.data import json_load
from compas.geometry import Frame

from compas_timber.assembly import TimberModel
from compas_timber.model import TimberModel


class Actor(object):
Expand Down
2 changes: 1 addition & 1 deletion tests/compas_timber/test_assembly.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from compas.data import json_dumps, json_loads
from compas.geometry import Frame, Point, Vector
from compas_timber.assembly import TimberModel
from compas_timber.model import TimberModel
from compas_timber.connections import LButtJoint, TButtJoint
from compas_timber.parts import Beam

Expand Down
2 changes: 1 addition & 1 deletion tests/compas_timber/test_joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from compas.data import json_load
from compas.geometry import Frame, Line, Point, Vector
from compas_timber.assembly import TimberModel
from compas_timber.model import TimberModel
from compas_timber.connections import (
LButtJoint,
LHalfLapJoint,
Expand Down
2 changes: 1 addition & 1 deletion tests/compas_timber/test_sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from compas.data import json_dumps, json_loads
from compas.geometry import Frame
from compas_timber.assembly import TimberModel
from compas_timber.model import TimberModel
from compas_timber.parts import Beam
from compas_timber.planning import SimpleSequenceGenerator

Expand Down
2 changes: 1 addition & 1 deletion tests/compas_timber/test_t_butt_joint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from compas.geometry import Point, Vector
from compas_timber.assembly import TimberModel
from compas_timber.model import TimberModel
from compas_timber.connections import TButtJoint
from compas_timber.parts import Beam

Expand Down

0 comments on commit 91091a2

Please sign in to comment.