Skip to content

Booleans: walls joined flush round a part glue exactly (#4058) - #4059

Closed
kaievns wants to merge 1 commit into
tangency-labs:mainfrom
kaievns:walls-flush-join
Closed

kaievns wants to merge 1 commit into
tangency-labs:mainfrom
kaievns:walls-flush-join

Conversation

@kaievns

@kaievns kaievns commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #4058. Related to #2770, which this does not fix (see the end).

This is the kernel half of #2465, split out on its own on current main. #2465 keeps the Extrude window's Targets row (#2464).

Draft, on hold. @jyviko asked to pause new kernel fixes aimed at truck's booleans while the maintainers evaluate the kernel (#3992, solidcore). This PR is ready for review once that evaluation is done. Until then it stays a draft.

Overlaps with other open drafts:

What changes

A ring extruded round a part, its hole the part's outline (rounded corners included), only touches the part, back to back on planes and on cylinders. The B-rep boolean can't intersect faces lying on each other, so the retry ladder ended in "no result" after many full booleans. Now the join is exact:

  • Contact seen from both bodies (coplanar::faces_touch). A 40 mm wall's face meshes into two triangles, and none of their samples lands on a 3 mm floor's side. So the exact imprint-and-glue route was never tried.
  • Round contact faces glued too.
    • cylinders_imprinted splits each body's faces on a shared cylinder across the axis, where the other body's faces end. The splits are exact arcs of the circle (splitface::split_across, given the cylinder), so revolved and STEP round sides are cut the same way.
    • glue_round then pairs back-to-back cylinder faces as it pairs planar ones, wherever the result is checked for slits (below).
    • An arc's side is the one that runs on the face's mesh; the face's edges decide only a tie.
  • Slits refused. A glued join can leave two of its faces back to back on a contact surface over a common area: a crack of no width, which no volume, membership or shell check sees. coplanar::slit_free refuses that on every glue path, and the ladder goes on.
    • This includes the glue of touching operands, which now pairs round faces too. On main a pin through a hole, on a base under the plate, is left with a slit (the test fails with the base -10..50).
    • The check compares only faces on one surface facing each other, through a grid.
  • Lineage kept. An imprint step that changed nothing handed its body back with its previous history, and that history was then composed again. The glued body lost its history or got a wrong one. boolean_record::step composes only when a step changed the body.
  • Faster cylinder lookups. cylinders() walked the face list once per face. That is quadratic: about 0.4 s per call on a 2,100-face body, with several calls per boolean. Faces that can lie on the other body's cylinders are now found by their corners first.

The change is the same as #2465's kernel half (compared line for line). Two things are new here:

  • the engine regression test now lives in boolean_regression_tests.rs;
  • the docs/robustness.md entry says "after many retries" rather than "after a minute of retries", because the small reproduction fails in seconds.

Before / after

Walls round a floor on main and with this branch: the Extrude window, then OK

Steps: a 60 × 50 floor with r4 corners, a tapered pocket and a socket under it. The 10 mm ring sketched round it (r14 outside) is extruded 40 mm as a Join, through the Extrude window over the control channel. The issue has the same steps as a solidcraft-cli script.

Measured on main 776541b against this branch:

main this PR
Extrude window, OK stays open: boolean Union: the operation failed: no result done in 0.3 s, one solid
solidcraft-cli run walls-repro.json error: step 14 (solid.extrude): boolean Union: the operation failed: no result after 4.6 s exit 0 in 1.4 s; Floor 109,378.39 mm³ = 11,559.34 + 97,819.05 (the ring's 2,445.49 mm² × 40 = 97,819.47)

Tests

  • Kernel (coplanar_tests.rs, mod wall_join, 7 tests):
    • the wall joins from the floor's bottom and from below it, in both operand orders. Each join needs no tool nudge, gives one shell and the expected volume, leaves no slit, and keeps every face's lineage on its operand face's surface;
    • a contact much smaller than its face is seen;
    • slits:
      • two blocks side by side, and a disc filling a ring's bore, are slits;
      • the fused blocks are not;
      • faces on one side of a contact surface only, however finely meshed, are no slit;
      • a narrow real gap over a contact face is no slit;
    • a pin through a hole, on a base as wide as the chamfered plate or wider, has no slit;
    • round sides split across their axis on exact arcs:
      • half turns;
      • a 3/4-turn 1 mm boss on a 300 mm plate (its chain keeps no inner points);
      • the same taller, with a quarter cut away above the split (both sides);
      • a drilled side;
      • a revolved tube;
    • an arc counts as on a round face only the way the face runs.
  • Engine (boolean_regression_tests.rs, walls_join_flush_round_a_floor): the walls joined through solid.extrude, from the floor's bottom (40 mm) and from the socket's floor (10 mm). Each join is exact (no strategy that alters the result), gives one valid shell, and adds the ring's area × height to within 2e-5.

Without the fix they fail. With the kernel's production files (boolean_record.rs, coplanar.rs, ops.rs, outline.rs, splitface.rs) set back to main's:

  • the engine test fails with boolean Union: the operation failed: no result;
  • the wall join, contact and pin tests fail. For this run, slit_free and its helpers were added on top of main's coplanar.rs so that the tests compile:
    • the wall join: no result;
    • the contact: faces_touch(&plate, &wall) is false;
    • the pin: a slit where the bodies touched, with the base -10..50.

The split-arc tests and the two slit-checker tests test new functions, which don't exist on main. Each fix was also checked by putting its bug back on this branch:

Bug put back Test that fails
exact arcs off in fit_on the round-side split test (a point 8.5e-7 off the circle); the wall join also fails (no result)
arc_on_face ignoring the face the arc-side test
history composed after a no-op step the wall join (no history on the result)
touching-operand glue without the slit check the pin test (a slit with the base -10..50)

Robustness goldens

Seed 33 is recorded again, with its reason in the file's notes. Its join of a box onto a filleted revolved disc (step 5) is now exact. On main it needed a tool nudge and left the body as two shells touching along a face, so that face's area was counted twice.

The fused body then changes what the generator draws later: rejected 4 → 3, unsupported 1 → 2. The design ends with one shell fewer (4 → 3), 68 mm² less area and the same volume within 0.6 mm³. Every step passes the validity and volume-direction checks. The new record was made on macOS and matches #2465's record within the test's 1e-6 relative tolerance.

All 96 seeds were run on main 776541b and on this branch (macOS):

  • seed 33 is the only seed that changes;
  • seeds 36 and 71 differ from the shared record on main too, identically on both, and are left as they are. The record is the Linux one CI checks.

Checks

On macOS, Rust 1.99, ci profile, on this branch at main 776541b (since rebased onto main e949009, which changes only the IGES importer in the kernel; after the rebase clippy, the kernel wall_join tests, the engine boolean_regression_tests and seed 33 pass again):

  • cargo fmt --all --check;
  • cargo clippy --profile ci -p solidcraft-kernel -p solidcraft-engine --all-targets -- -D warnings;
  • cargo check --target wasm32-unknown-unknown --profile ci -p solidcraft-kernel -p solidcraft-engine;
  • cargo test -p solidcraft-kernel: 857 library tests passed, 28 ignored; the integration test binaries pass;
  • cargo test -p solidcraft-engine --lib -- --skip robustness_goldens: 1825 passed, 1 failed. The failure is prism_local_tests::a_ring_cut_round_a_counterbored_hole_in_a_chamfered_disc (148.2797 taken, want 148.4403). It fails identically with main's kernel on this Mac, so it is not caused by this change;
  • the robustness goldens, as above.

cargo xtask ci was not run as a whole; GitHub CI runs the rest.

Not fixed here

🤖 Generated with Claude Code

…#4058)

A ring extruded round a part, its hole the part's outline (rounded
corners included), only touches the part, back to back on planes and
cylinders. The boolean can't intersect faces lying on each other, and
the join failed with "Union: no result" after many retries.

- Contact seen from both bodies (coplanar::faces_touch): a tall wall's
  face meshes too coarsely for any sample to land on a thin floor's
  side, so the imprint-and-glue route was never tried.
- Round contact faces glued: cylinders_imprinted splits each body's
  faces on a shared cylinder across the axis where the other's faces
  end, on exact arcs (splitface::split_across), and glue_round pairs
  back-to-back cylinder faces as glue pairs planar ones.
- Slits refused: a glued union that leaves two faces back to back on a
  contact surface over a common area is refused (coplanar::slit_free),
  on every glue path, including the glue of touching operands.
- Lineage kept: an imprint step that changed nothing no longer composes
  the previous step's history twice (boolean_record::step).
- Faster cylinder lookups: faces that can lie on the other body's
  cylinders are found by their corners before their surfaces are
  classified.

Seed 33's golden is recorded again: its join of a box onto a filleted
revolved disc is now exact.

Fixes tangency-labs#4058
@kaievns

kaievns commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main now runs on the SMLib kernel (#11351), so this truck-based change no longer applies. If the case it fixed still shows up on SMLib, I'll report it against the new kernel or solidcore (#1597) instead.

@kaievns kaievns closed this Nov 3, 2026
@martinpalsson

Copy link
Copy Markdown
Contributor

Closing: main now runs on the SMLib kernel (#11351), so this truck-based change no longer applies. If the case it fixed still shows up on SMLib, I'll report it against the new kernel or solidcore (#1597) instead.

Oh happy day!

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

Labels

area:infra CI, tooling, repo, docs area:kernel B-rep kernel, booleans, blends, STEP/IGES

Projects

None yet

2 participants