Skip to content
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

added new method of performing ordered boolean operations #770

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from

Conversation

billingsley-john
Copy link

Proposed changes

Starting PR which updates the method for performing boolean operations of cut, union and intersect. At the moment, the order in which these operations are performed is hard coded. This PR introduces a boolean_operations dictionary to shapes in which the boolean operations and their orders can be specified.

Types of changes

What types of changes does your code introduce to the Paramak?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • New tests

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.

  • Pep8 applied
  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@billingsley-john billingsley-john marked this pull request as ready for review March 8, 2021 16:28
@billingsley-john
Copy link
Author

billingsley-john commented Mar 8, 2021

Usage:

  • Cutting single shape: (likewise for union and intersect)
    my_shape.boolean_operations = {"cut": shape_1}

  • Cutting multiple shapes: (likewise for union and intersect)
    my_shape.boolean_operations = {"cut": [shape_1, shape_2]}
    shape_1 is cut first, shape_2 cut second

  • Ordering boolean operations
    my_shape.boolean_operations = {"union": shape_1, "cut": shape_2}
    shape_1 is unioned before shape_2 is cut

@billingsley-john
Copy link
Author

billingsley-john commented Mar 8, 2021

Need to be careful when defining new boolean operations after a shape class has already been defined.
I.e. as boolean_operations now controls cut, union and intersect, if we want to 'add' a boolean operation, we need to make sure we don't overwrite any original boolean operations that may already exist.
E.g.
my_shape = p.RotateStraightShape(boolean_operations={"cut": shape_1})

If we now want to add a union, we need to make sure to include the original cut:
my_shape.boolean_operations={"cut": shape_1, "union": shape_2},
or, alternatively, add the key-value pair like this:
my_shape.boolean_operations["union"] = shape_2
Note. this second method only works if boolean_operations is already a dictionary

@RemDelaporteMathurin RemDelaporteMathurin linked an issue May 10, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

boolean operation ordering Add the option of set the order between boolean operations and rotation
1 participant