-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeContour
BTLxProcessing
#382
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments.
if @papachap can have a look it would be great
# create subprocessing elements | ||
if self.subprocessings: | ||
for subprocessing in self.subprocessings: | ||
processing_element.append(self._create_processing(subprocessing)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as BTLxWriter_create_processing()
gets removed, recursively call create_processing
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@papachap can you confirm that this works as currently written? is there a processing we could test this on?
I responded to @chenkasirer s comments. Will wait for @papachap :-) |
added test, removed writer._create_part
@@ -155,8 +155,8 @@ def _create_project_element(self, model): | |||
# create parts element | |||
parts_element = ET.SubElement(project_element, "Parts") | |||
# create part elements for each beam | |||
for i, beam in enumerate(model.beams): # TODO: we need to add at least Plates to this too. | |||
part_element = self._create_part(beam, i) | |||
for i, element in enumerate(list(model.beams) + list(model.plates)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe update the _create_part()
method as well to accept an element instead of a beam and adjust the docstring.
processings : list | ||
A list of the processings applied to the beam. | ||
et_element : :class:`~xml.etree.ElementTree.Element` | ||
The ET element of the BTLx part. | ||
|
||
""" | ||
|
||
def __init__(self, beam, order_num): | ||
self.beam = beam | ||
def __init__(self, element, order_num): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the docstring accordingly.
) | ||
# create parameter subelements | ||
for key, value in self.params_dict.items(): | ||
print(key, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove print
@@ -177,7 +193,7 @@ def compute_aabb(self, inflate=0.0): | |||
box.zsize += inflate | |||
return box | |||
|
|||
def compute_obb(self, inflate=0.0): | |||
def compute_obb(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update docstring
@property | ||
def blank_length(self): | ||
return self._blank.xsize | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the docstring here as well
@@ -62,6 +63,10 @@ def __init__(self, outline, thickness, vector=None, frame=None, **kwargs): | |||
self.attributes = {} | |||
self.attributes.update(kwargs) | |||
self.debug_info = [] | |||
self._ref_frame = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it redundant to have both a vector and frame argument?
contour_feature = FreeContour.from_polyline_and_element(self.outline.points, self, interior=False) | ||
self.add_feature(contour_feature) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary to add a contour feature by default? maybe consider making this optional if not always needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels there are a lot of hiddent dependencies in this code where properties are set implicitly. For example, the blank
property is set when the compute_obb()
method is called, which happens when ref_frame
is accessed, and ref_frame
is triggered when the FreeContour
processing is instantiated.
All this creates an extensive chain of implicit side effects that we need to reduce by explicitly setting some of these properties.
for feature in self.features: | ||
try: | ||
plate_geo = feature.apply(plate_geo, self) | ||
except FeatureApplicationError as error: | ||
self.debug_info.append(error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless you want to completely remove the posibility of computing the geometry without the features (which in this case you should remove the include_features
argument), add an additional if
statement for that.
@property | ||
def params_dict(self): | ||
return FreeCountourParams(self).as_dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the use of this property anymore since the create_processing()
doesn't access it and instead it directly creates the XML elements for the processing.
def create_processing(self): | ||
"""Creates a processing element. This method creates the subprocess elements and appends them to the processing element. | ||
NOTE: moved to BTLxProcessing because some processings are significantly different and need to be overridden. | ||
|
||
Parameters | ||
---------- | ||
processing : :class:`~compas_timber.fabrication.btlx.BTLxProcessing` | ||
The processing object. | ||
|
||
Returns | ||
------- | ||
:class:`~xml.etree.ElementTree.Element` | ||
The processing element. | ||
|
||
""" | ||
# create processing element | ||
processing_element = ET.Element( | ||
self.PROCESSING_NAME, | ||
self.header_attributes, | ||
) | ||
contour_element = ET.SubElement(processing_element, "Contour", self.contour_attributes) | ||
ET.SubElement(contour_element, "StartPoint", BTLxPart.et_point_vals(self.contour_points[0])) | ||
for pt in self.contour_points[1:]: | ||
point_element = ET.SubElement(contour_element, "Line") # TODO: consider implementing arcs. maybe as tuple? (Point,Point) | ||
point_element.append(ET.Element("EndPoint", BTLxPart.et_point_vals(pt))) | ||
return processing_element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that this is a completely different BTLx processing and requires a different approach. However, I'm not a huge fan of mixing XML generation with the core logic. This approach bypasses the parameters dictionary for this class. I wonder if we can refactor the FreeContourParams
class to achieve what we need. Perhaps we could use a similar approach to the House
BTLx processing, where we nest processings.
@obucklin @chenkasirer I added some comments as well. If you want we can sit have a look at it together. |
This adds the
FreeContour
BTLx Processing and updates thePlate
element to function as a BTLx Part. ThePlate.geometry
is now created withFreeContour
(and other) processings. TheSurfaceModel
andSurfaecModel.Window
have been updated to generateFreeContour
features and output BTLx files with all elements.What type of change is this?
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
).invoke test
).invoke lint
).compas_timber.datastructures.Beam
.