Skip to content

Conversation

@gonzalocasas
Copy link
Member

If the part has no features assigned, the call to .geometry causes an exception, but additionally, it's very inefficient to do all those transformations from shape to mesh back to polyhedron which, in the case of no attached features to be boolean'ed into the geometry, is not needed.

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

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.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

@gonzalocasas gonzalocasas requested a review from tomvanmele March 16, 2022 19:27
@gonzalocasas
Copy link
Member Author

/cc @funkchaser

Comment on lines 148 to 154
A = Mesh.from_shape(self.shape)
for shape, operation in self.features:
A.quads_to_triangles()
B = Mesh.from_shape(shape)
B.quads_to_triangles()
A = Part.operations[operation](A.to_vertices_and_faces(), B.to_vertices_and_faces())
geometry = Shape(*A)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this can be further reduced since geometrical shapes can be converted to triangulated polyhedrons directly.

A = self.shape.to_vertices_and_faces(triangulated=True)
for shape in operation in self.features:
    B = shape.to_vertices_and_faces(triangulated=True)
    A = Part.operations[operation](A, B)  # this is always a triangulation...
geometry = Shape(*A)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! 510bb43

@gonzalocasas gonzalocasas merged commit 0b27903 into main Mar 22, 2022
@gonzalocasas gonzalocasas deleted the fix-geometry-of-part branch March 22, 2022 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants