Skip to content

(1/3) Harden hull() against degenerate input - #2100

Open
kimstik wants to merge 3 commits into
CadQuery:masterfrom
kimstik:hull_reinforcing
Open

kimstik wants to merge 3 commits into
CadQuery:masterfrom
kimstik:hull_reinforcing

Conversation

@kimstik

@kimstik kimstik commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

This PR hardens hull() against degenerate input - nested geometry, circles split at the seam by a fuse.
The direction is a hull for valid input and a clear error for the rest, not a crash.
Each fix sits where the algorithm assumed general position.

Arcs on one circle are matched exactly, so #1224 is only partly addressed for the moment.

Follows of #2096.

Fixes #1888. Partially addresses #943 and #1224.

This one is the first of three in a hull fix PR series, and the base for the other two.
The march (hulls on ordinary input) and the arc related rework are expected to follow.

kimstik added 3 commits September 23, 2026 08:53
_pt_arc takes sqrt(l**2 - r**2), which has no real value when the point is
inside the circle and degenerates to the point itself when it is on it: a
line end inside a circle, or a circle inside a bigger one, raised
ValueError; a line end on the circle produced an empty segment. Such an
entity cannot touch the hull beyond the circle, so it is not a candidate -
report it the way get_angle already reports an entity against itself.

Partially addresses CadQuery#1190 and CadQuery#1224.
A circle with every other entity inside it is its own hull, but the march
raised "Hull could not be closed". The lone-circle shortcut was one instance
of this and is folded in.
Two arcs on the same circle became two entities: arc_arc divided by the
distance between their centres, and since the march closes on identity it
could come back to the other one and fail to close. The merged bounds only
steer select_lowest_arc; every tangent takes the full circle.

Fixes CadQuery#1888. Partially addresses CadQuery#943 and CadQuery#1224.
@kimstik kimstik changed the title (1/3) Harden hull() against degenerate input (1/3) Harden hull() against degenerate input Sep 23, 2026
@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.81%. Comparing base (c11b3f9) to head (c45ce4f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2100   +/-   ##
=======================================
  Coverage   95.80%   95.81%           
=======================================
  Files          30       30           
  Lines        9589     9596    +7     
  Branches     1439     1441    +2     
=======================================
+ Hits         9187     9194    +7     
  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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sketch hull failure due to overlapping geometries

1 participant