A join failed with the kernel's internal error "tolerance must be no less than 1e-6" at vendor/truck-geometry/src/decorators/intersection_curve.rs:172: IntersectionCurve::parameter_division asserted truck's minimum tolerance, and the guard turned the panic into a failed operation. A tolerance below truck's TOLERANCE, or one that is not a number, now divides at TOLERANCE: the curve's points are only found to within it anyway. The test divides the intersection edges of a hole cut through a B-spline face at 5e-7, 1e-12, 0, -1 and NaN: each gives the division at 1e-6. Without the fix it panics with the reported message at the reported line. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,3 +79,23 @@ fn hinted_division_matches_the_search_from_nothing_and_is_faster() {
|
||||
// loaded runner doesn't trip it, but one a fallback to the search for every point would.
|
||||
assert!(hinted_time * 2 < scratch_time, "hinted {hinted_time:?}, from nothing {scratch_time:?}");
|
||||
}
|
||||
|
||||
/// #4623: dividing an intersection edge at a tolerance finer than truck's 1e-6 (or one that is
|
||||
/// not a number) panicked in truck's tolerance assertion, and the join that asked for it failed.
|
||||
/// It divides at 1e-6 instead.
|
||||
#[test]
|
||||
fn dividing_an_intersection_edge_finer_than_truck_allows_divides_at_its_tolerance() {
|
||||
let (_, cut) = holed();
|
||||
let curves = intersection_curves(&cut);
|
||||
assert!(!curves.is_empty());
|
||||
for curve in curves {
|
||||
let mt::Curve::IntersectionCurve(ic) = &curve else { continue };
|
||||
let range = ic.range_tuple();
|
||||
let at_truck = ic.parameter_division(range, 1e-6);
|
||||
for tol in [5e-7, 1e-12, 0.0, -1.0, f64::NAN] {
|
||||
let got = std::panic::catch_unwind(|| ic.parameter_division(range, tol));
|
||||
let Ok(got) = got else { panic!("dividing at {tol:e} panicked") };
|
||||
assert_eq!(got, at_truck, "tolerance {tol:e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -78,6 +78,10 @@ Changes:
|
||||
does. They multiplied by p only, so the second derivatives of every B-spline and NURBS surface
|
||||
of degree p ≥ 3 were 1/(p − 1) of their value (a cubic surface's curvature read as half, #763).
|
||||
`crates/kernel/src/surface_second_derivative_tests.rs` holds them to finite differences.
|
||||
- `decorators/intersection_curve.rs`: `IntersectionCurve::parameter_division` with a tolerance
|
||||
below truck's `TOLERANCE` (1e-6), or one that is not a number, divides at `TOLERANCE` instead
|
||||
of panicking in truck's tolerance assertion; a join failed on that panic (#4623).
|
||||
`crates/kernel/src/issue_1038_tests.rs` holds it to the division at 1e-6.
|
||||
|
||||
## truck-stepio 0.3.0 (Apache-2.0, © RICOS Co. Ltd., https://github.com/ricosjp/truck)
|
||||
|
||||
|
||||
@@ -169,7 +169,10 @@ where
|
||||
// that search ran for every point and made dividing an intersection edge on a large B-spline
|
||||
// surface take seconds. A point the hinted projection misses is searched for as before.
|
||||
fn parameter_division(&self, range: (f64, f64), tol: f64) -> (Vec<f64>, Vec<Point3>) {
|
||||
nonpositive_tolerance!(tol);
|
||||
// SolidCraft: a tolerance finer than truck's (or not a number) divides at truck's
|
||||
// instead of panicking: the points are only found to within it anyway. truck asserted
|
||||
// the tolerance, and a join whose caller asked for less failed on the panic (#4623).
|
||||
let tol = if tol >= TOLERANCE { tol } else { TOLERANCE };
|
||||
let start = self.hinted_triple(range.0, None);
|
||||
let end = self.hinted_triple(range.1, None);
|
||||
hinted_sub_division(self, range, (start, end), tol, 100)
|
||||
|
||||
Reference in New Issue
Block a user