Skip to content

CrossSection: drop FillRule/Compose, add SetTolerance/GetTolerance#1760

Merged
elalish merged 7 commits into
elalish:masterfrom
zmerlynn:pr/cross-section-api-break
Jun 17, 2026
Merged

CrossSection: drop FillRule/Compose, add SetTolerance/GetTolerance#1760
elalish merged 7 commits into
elalish:masterfrom
zmerlynn:pr/cross-section-api-break

Conversation

@zmerlynn

Copy link
Copy Markdown
Contributor

Summary

Part of #1707. Breaks the CrossSection public API now that the boolean2 backend
is the only backend (#1751).

Dropped:

  • FillRule enum and constructors that accepted it. The boolean2 backend
    supports only positive-winding fill; the enum had no effect since Cut over CrossSection from Clipper2 to boolean2 #1751, and
    passing any non-Positive value triggered a DEBUG_ASSERT in assert-enabled
    builds. Callers passing FillRule::Positive (the only valid value) just drop
    the argument.
  • Compose(const std::vector<CrossSection>&) static. It was a batch boolean
    union - identical to BatchBoolean(..., OpType::Add). Use BatchBoolean or
    the + operator instead.
  • ManifoldFillRule enum from the C header (types.h).

Added:

  • GetTolerance() / SetTolerance(double) - mirrors Manifold::GetTolerance /
    Manifold::SetTolerance. GetTolerance returns the cross-section's propagated
    drift budget. SetTolerance returns a copy with it adjusted: raising simplifies
    to the new budget; lowering floors at the geometry's natural epsilon.

Changed:

  • Simplify(double epsilon = 1e-6) -> Simplify(double tolerance = 0). Default
    0 uses the section's own tolerance (from GetTolerance()). Callers passing
    an explicit non-zero value are unaffected.
  • Hull(SimplePolygon pts) / Hull(Polygons polys) now take const-ref.
    HullImpl sorts in place; the old by-value signature obscured this.
  • Rect, Square, and Circle constructors now set tolerance_ from
    InferEps on the output geometry, consistent with the Polygons constructor.
    Previously GetTolerance() returned 0 for these paths.

Fixed (pre-existing):

  • WASM JoinType: 'Bevel' was missing from the TypeScript type and from
    joinTypeToInt in bindings.js, so passing 'Bevel' silently fell through
    to 'Square'.

C, Python, and WASM bindings updated throughout.

Test plan

  • 119 tests pass (58 CrossSection + 39 Boolean2 + 22 CBIND existing +
    1 new CBIND.cross_section_tolerance). 2 seed-queue CrossSection tests remain
    disabled pending fixes on a separate branch.

zmerlynn and others added 6 commits June 16, 2026 11:44
…ef Hull, tolerance API

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Drop stale @param fillrule from CrossSection(SimplePolygon) doc
- Replace CrossSection.compose with batch_boolean in all_apis.py
- Add get_tolerance/set_tolerance to all_apis.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
'Bevel' was registered in the embind enum but missing from the
TypeScript type and from joinTypeToInt(), so passing 'Bevel' silently
fell through to 'Square' (0). Add it to both.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rect and Circle constructors now set tolerance_ via InferEps,
  consistent with the Polygons constructor. Previously GetTolerance()
  returned 0 for these paths.
- Hull(const SimplePolygon&): use the local sorted copy (points) for
  InferEps, not the original const-ref (pts).
- Move SetTolerance declaration to the Information doxygen group
  alongside GetTolerance.
- Add CBIND.cross_section_tolerance smoke test for
  manifold_cross_section_get/set_tolerance.
- Fix stale comment in SimplifyPostFiltersBoolean2Output referencing
  the old epsilon=1e-6 default.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.83%. Comparing base (ecc145f) to head (dd078c1).

Files with missing lines Patch % Lines
src/cross_section.cpp 95.83% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1760   +/-   ##
=======================================
  Coverage   93.83%   93.83%           
=======================================
  Files          44       44           
  Lines        9985     9992    +7     
=======================================
+ Hits         9369     9376    +7     
  Misses        616      616           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…Simplify default

- Remove 'compose' from crossSectionStaticFunctions in garbage-collector.ts
  (CrossSection.compose no longer exists; wrapping undefined crashed with
  "originalFn is not a function" in WASM TBB:OFF CI lanes)
- Add 'setTolerance' to crossSectionMemberFunctions (returns new CrossSection)
- Update voronoi.mjs to use CrossSection.union() instead of .compose()
- Fix stale @param epsilon / default 1e-6 in manifold-encapsulated-types.d.ts
  (parameter is now 'tolerance', default 0 uses the geometry's own tolerance)
- Add @param doc note to CrossSection::Simplify explaining that default 0
  resolves to tolerance_ (geometry-scale-derived, not a fixed 1e-6)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@elalish elalish left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, looking much cleaner!

@elalish elalish merged commit bf47ebc into elalish:master Jun 17, 2026
43 checks passed
zmerlynn added a commit to zmerlynn/manifold that referenced this pull request Jun 20, 2026
CrossSection::Compose removed - replace with BatchBoolean(Add).
CrossSection::FillRule enum removed - drop from constructors (new
default uses positive winding, same semantics as FillRule::Positive).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zmerlynn added a commit to zmerlynn/manifold that referenced this pull request Jun 22, 2026
CrossSection::Compose removed - replace with BatchBoolean(Add).
CrossSection::FillRule enum removed - drop from constructors (new
default uses positive winding, same semantics as FillRule::Positive).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zmerlynn added a commit to zmerlynn/manifold that referenced this pull request Jun 23, 2026
CrossSection::Compose removed - replace with BatchBoolean(Add).
CrossSection::FillRule enum removed - drop from constructors (new
default uses positive winding, same semantics as FillRule::Positive).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
zmerlynn added a commit to zmerlynn/manifold that referenced this pull request Jun 24, 2026
CrossSection::Compose removed - replace with BatchBoolean(Add).
CrossSection::FillRule enum removed - drop from constructors (new
default uses positive winding, same semantics as FillRule::Positive).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants