Skip to content

Raise in free fillet and chamfer when the operation fails - #2132

Open
RClaudiuM wants to merge 2 commits into
CadQuery:masterfrom
RClaudiuM:fix/2114-fillet-chamfer-not-done
Open

RClaudiuM wants to merge 2 commits into
CadQuery:masterfrom
RClaudiuM:fix/2114-fillet-chamfer-not-done

Conversation

@RClaudiuM

Copy link
Copy Markdown

cadquery.func.fillet and cadquery.func.chamfer call builder.Shape() even when builder.Build() failed. Shape() then builds again, and that second build of BRepFilletAPI_MakeFillet / BRepFilletAPI_MakeChamfer segfaults inside OCCT, so a fillet that is too large kills the process instead of raising.

This checks IsDone() right after Build() and raises ValueError, the same guard #2106 added for makeNSidedSurface. The check runs before _update_history, so a failed operation is not recorded in the history. The docstrings now list the ValueError.

Fixes #2114

Test

test_fillet_chamfer_failure in tests/test_free_functions.py fillets and chamfers every edge of a unit box by 0.5, which cannot be built, and expects ValueError.

pytest "tests/test_free_functions.py::test_fillet_chamfer_failure"
  • Before: Fatal Python error: Segmentation fault (exit 139) for both fillet and chamfer
  • After: 2 passed; tests/test_free_functions.py 74 passed

black --check (CadQuery fork) is clean. mypy cadquery reports the same errors before and after this change (missing OCP stubs in a pip install). On a pip install on macOS arm64, the full suite gives the same results as master: test_interpPlate also fails on master there, and test_examples / test_jupyter need docutils and IPython.

cadquery.func.fillet and cadquery.func.chamfer called Shape() on the
builder even when Build() had failed. Shape() then builds again, and the
second build of BRepFilletAPI_MakeFillet / MakeChamfer segfaults inside
OCCT. Check IsDone() right after Build() and raise ValueError instead.

Fixes CadQuery#2114
@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.82%. Comparing base (477d87d) to head (b871425).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2132   +/-   ##
=======================================
  Coverage   95.81%   95.82%           
=======================================
  Files          30       30           
  Lines        9605     9618   +13     
  Branches     1443     1449    +6     
=======================================
+ Hits         9203     9216   +13     
  Misses        247      247           
  Partials      155      155           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adam-urbanczyk adam-urbanczyk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, some tweaks

Comment thread cadquery/occ_impl/shapes.py Resolved
Comment thread cadquery/occ_impl/shapes.py Resolved
Comment thread tests/test_free_functions.py Resolved
Comment thread tests/test_free_functions.py Resolved
Comment thread tests/test_free_functions.py Resolved
Comment thread tests/test_free_functions.py Resolved
Co-authored-by: AU <adam-urbanczyk@users.noreply.github.com>
@adam-urbanczyk

Copy link
Copy Markdown
Member

Small change, merging with one review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

func.fillet / func.chamfer segfault instead of raising when the operation fails

2 participants