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

Modify STL export to enable non-relative tolerancing and speed up export. #1432

Merged
merged 6 commits into from
Nov 15, 2023

Conversation

brhubbar
Copy link
Contributor

@brhubbar brhubbar commented Nov 1, 2023

First off, thank you for building this tool - it's been awesome to get to know! Greatly appreciate the API and the comments contained throughout, and it has saved me a lot of headache!

In the event that a model has very large and very small geometries, relative sizing for the mesh results in one of those scales being severely over- or under-resolved. For example, a dodecagon might be sufficient for a small hole, but a large hole requires many more facets to be properly represented. With relative sizing, getting the large hole up to a sufficient resolution results in the small hole meshing down to sizes that approach floating point errors and result in geometry collapses.

Also, the docs explicitly state that mesh.Perform() is called by the constructor, so calling it again doubles runtime with no change in the result (that I've been able to observe)

None of the changes here modify the existing default behavior.

This PR is ready for review ✔️

Copy link

codecov bot commented Nov 2, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8a9e5a0) 94.32% compared to head (36bcedf) 94.31%.
Report is 2 commits behind head on master.

❗ Current head 36bcedf differs from pull request most recent head 3b4a33c. Consider uploading reports for the commit 3b4a33c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1432      +/-   ##
==========================================
- Coverage   94.32%   94.31%   -0.01%     
==========================================
  Files          28       28              
  Lines        5813     5809       -4     
  Branches      994      993       -1     
==========================================
- Hits         5483     5479       -4     
  Misses        198      198              
  Partials      132      132              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@adam-urbanczyk adam-urbanczyk left a comment

Choose a reason for hiding this comment

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

LGTM, one minor tweak

cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
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.

mesh.Perform() is called by the constructor, so calling it again doubles runtime

Unfortunately I cannot reproduce the doubled runtime or performance benefit of removing the call. I agree the the Perform call can be removed.
I believe OCCT skips building the mesh again if it already exists.

I did find significant performance improvement with the parallel option enabled.

In one example, time to generate a large mesh with 4.5e6 facets, ~220MB STL file, was 18 seconds vs 122 seconds.

I'd suggest to enable the parallel flag by default. It is enabled for boolean operations:

parallel: bool = True,

cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
@brhubbar
Copy link
Contributor Author

brhubbar commented Nov 6, 2023

Unfortunately I cannot reproduce the doubled runtime or performance benefit of removing the call. I agree the the Perform call can be removed.
I believe OCCT skips building the mesh again if it already exists.

I did find significant performance improvement with the parallel option enabled.

In one example, time to generate a large mesh with 4.5e6 facets, ~220MB STL file, was 18 seconds vs 122 seconds.

Interesting the difference here - I’m running Windows + Pip package, I wonder if that’s a source of the difference

I'd suggest to enable the parallel flag by default. It is enabled for boolean operations:

Can do - I only did not in order to not change any current behavior.

Copy link
Member

@adam-urbanczyk adam-urbanczyk left a comment

Choose a reason for hiding this comment

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

Just some bike-shedding

cadquery/occ_impl/shapes.py Outdated Show resolved Hide resolved
@adam-urbanczyk
Copy link
Member

Thanks @brhubbar !

@adam-urbanczyk adam-urbanczyk merged commit 13344cd into CadQuery:master Nov 15, 2023
1 check passed
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