geometry: a partition the kernel can only nudge off its plane is refused (#427)

The kernel's last-resort boolean retry moves the tool 1.3 µm and turns it
2 µrad. For a partition that puts the cut beside the face it was meant to
run along and leaves a cell bounded by slivers (the open boundary at x = 130
on the crank half). halves() now refuses a result-altering retry and names it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-16 00:20:02 -04:00
1 parent 1af87f1f98
commit 3d38753cad
4 files changed
+56 -8

No files matched your search

+12 -1
View File
@@ -187,6 +187,10 @@ impl Design {
/// several times the body's size, and its boolean then puts the cut up to a few micrometres off
/// the plane (1.8 µm on a 140 mm body), off the faces it should meet (#384); boxes of the body's own
/// size keep the cut on the plane.
///
/// A boolean the kernel could only make by moving one body against the other (its last-resort
/// tool nudge, micrometres and microradians) is refused: the cut would lie off the plane, next to
/// the face it was meant to run along, and leave a cell bounded by slivers no mesher takes (#427).
fn halves(body: &Shape, plane: &Plane) -> solidcraft_kernel::Result<Vec<solidcraft_kernel::Body>> {
let bbox = solidcraft_kernel::measure(&body.body)?.bbox;
let reach = bbox.diagonal().max(LINEAR_REACH);
@@ -203,7 +207,14 @@ fn halves(body: &Shape, plane: &Plane) -> solidcraft_kernel::Result<Vec<solidcra
let mut out = Vec::with_capacity(2);
for (lo, hi) in [(0.0, reach), (-reach, 0.0)] {
let Some(side) = solidcraft_kernel::extrude(plane, std::slice::from_ref(&square), lo, hi)?.pop() else { continue };
out.extend(solidcraft_kernel::boolean(&body.body, &side, solidcraft_kernel::BoolOp::Intersect)?);
let (cut, report) =
solidcraft_kernel::capture_boolean_diagnostics(|| solidcraft_kernel::boolean(&body.body, &side, solidcraft_kernel::BoolOp::Intersect));
if let Some(moved) = report.warning() {
return Err(solidcraft_kernel::KernelError::Failed(format!(
"the cut is only made off the plane ({moved}); the plane runs along a face or edge of the body: move it off (by a fraction of the element size)"
)));
}
out.extend(cut?);
}
Ok(out)
}