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

Add tol to cut and intersect #1332

Merged
merged 7 commits into from
May 10, 2023
Merged

Add tol to cut and intersect #1332

merged 7 commits into from
May 10, 2023

Conversation

adam-urbanczyk
Copy link
Member

@adam-urbanczyk adam-urbanczyk commented May 6, 2023

Adds fuzzy cut and intersect

@adam-urbanczyk adam-urbanczyk marked this pull request as draft May 6, 2023 17:55
@adam-urbanczyk adam-urbanczyk linked an issue May 6, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented May 7, 2023

Codecov Report

Merging #1332 (1920135) into master (3c576f4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 1920135 differs from pull request most recent head e3fbbe5. Consider uploading reports for the commit e3fbbe5 to get more accurate results

@@           Coverage Diff           @@
##           master    #1332   +/-   ##
=======================================
  Coverage   94.29%   94.30%           
=======================================
  Files          26       26           
  Lines        5575     5583    +8     
  Branches      950      954    +4     
=======================================
+ Hits         5257     5265    +8     
  Misses        187      187           
  Partials      131      131           
Impacted Files Coverage Δ
cadquery/cq.py 92.23% <100.00%> (ø)
cadquery/occ_impl/shapes.py 92.85% <100.00%> (+0.04%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@adam-urbanczyk adam-urbanczyk marked this pull request as ready for review May 8, 2023 04:01
@jmwright
Copy link
Member

jmwright commented May 8, 2023

One thing that I think is expected behavior but seems like it could confuse users, is that setting the tolerance too high will lead to no resulting geometry, with no error. The following code shows nothing in CQ-editor, but does not throw an error either.

import cadquery as cq

box1 = cq.Workplane().box(10, 10, 10)
box2 = cq.Workplane().center(5, 5).box(10, 10, 10)

res = box2.intersect(box1, tol=3.0)

show_object(res)

That is a contrived example, but it is not hard to imagine that it will happen with lower tolerances with complex geometry. There have been a few models in the KiCAD library that had fuse glitches. In those cases the issue was solved by shifting parts and/or breaking sharp edges between geometries, but I think there is potential there for the same kinds of issues with cut and intersect. I don't have a solution except maybe to note that setting the tolerance too high may result in incorrect or missing geometry.

Copy link
Member

@jmwright jmwright left a comment

Choose a reason for hiding this comment

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

I made one comment, but the code looks good to me and works as I expected when experimenting with it in CQ-editor. Thanks @adam-urbanczyk !

Copy link
Member

@lorenzncode lorenzncode left a comment

Choose a reason for hiding this comment

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

LGTM. I've done some manual testing and did not find any problem.

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.

[Discussion] Fuzzy Boolean operations
3 participants