SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Intersection edges divide at 1e-6 when asked for less, instead of panicking (#4623) (#4650)
DuBeartef422bb1263c7
diff --git a/crates/kernel/src/issue_1038_tests.rs b/crates/kernel/src/issue_1038_tests.rsindex ca3f16f1cf..979ff729dc 100644--- a/crates/kernel/src/issue_1038_tests.rs+++ b/crates/kernel/src/issue_1038_tests.rs@@ -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}");+ }+ }+}diff --git a/vendor/README.md b/vendor/README.mdindex 25ed1cd677..9226d70ace 100644--- a/vendor/README.md+++ b/vendor/README.md@@ -78,6 +78,10 @@ Changes:does. They multiplied by p only, so the second derivatives of every B-spline and NURBS surfaceof 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)diff --git a/vendor/truck-geometry/src/decorators/intersection_curve.rs b/vendor/truck-geometry/src/decorators/intersection_curve.rsindex d6390e61e2..9b14d0ef12 100644--- a/vendor/truck-geometry/src/decorators/intersection_curve.rs+++ b/vendor/truck-geometry/src/decorators/intersection_curve.rs@@ -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)