From fa3d914af68152e4f6271a4c4beaf7f623ccee71 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 22 Oct 2026 00:49:57 -0400 Subject: [PATCH] kernel: SMLib measures mass properties at its documented 1e-4 measure_backend asked SMLib for mass properties at 1e-8, the finest its integrator allows and below the range SmApiBrepComputeMassProperties documents ("Relative accuracy, clamped to [1e-4, 1e-1]", SmApiQueries.h, whose cost is "governed by dRelativeAccuracy"). The tight request was there because the documented range did not hold on faces bounded by circles (KNOWN_ISSUES.md); the fork's dcbb07d integrates each trim-curve knot span on its own, and such faces now meet it (a cylinder's volume 1.8e-6 off at 1e-4). At 1e-8 SMLib's measure was most of the regression rig's time on a modelled thread (threads/602). The measure now asks 1e-4: ten times inside the 1e-3 it is held to (AGREE against the mesh measure, and the rig's volume and area tolerance). NURBS spheres and tori can still miss 1e-4 by a small factor (tangency-labs/ solidcore#384; a torus's volume 2.5e-4 at 1e-4), inside that 1e-3. Brep::mass_properties keeps MEASURE_ACCURACY (1e-8) as its tests' default. SMLIB_REV: the fork at dcbb07d. Not built: base in progress (kernel-smlib/no-truck 52f25ca3 does not build). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017itGh5fpMEousnZ91cYcVt --- crates/kernel/src/measure_backend.rs | 9 ++++++++- crates/smlib/SMLIB_REV | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/kernel/src/measure_backend.rs b/crates/kernel/src/measure_backend.rs index 26bdd8c4a..92ba4c51f 100644 --- a/crates/kernel/src/measure_backend.rs +++ b/crates/kernel/src/measure_backend.rs @@ -14,6 +14,13 @@ use crate::measure::MassMeasure; /// centroid): SMLib must agree with it this closely for its numbers to be used. const AGREE: f64 = 1e-3; +/// The relative accuracy SMLib integrates at: the finest of SmApiBrepComputeMassProperties' +/// documented range ("clamped to [1e-4, 1e-1]", SmApiQueries.h), ten times inside the 1e-3 the +/// measure is held to ([`AGREE`], and the regression rig's volume and area tolerance). Its cost is +/// "governed by dRelativeAccuracy": the finest the integrator allows, 1e-8, took tens of seconds +/// on a modelled thread's faces. +const ACCURACY: f64 = 1e-4; + /// Exact volume, area and centroid. pub(crate) struct Exact { pub volume: f64, @@ -31,7 +38,7 @@ pub(crate) struct Choice { #[cfg(feature = "smlib")] fn exact(b: &Body) -> Result { let sb = crate::native::smlib_body(b).map_err(|e| e.to_string())?; - let m = sb.mass_properties(solidcraft_smlib::MEASURE_ACCURACY).map_err(|e| format!("SMLib mass properties: {e}"))?; + let m = sb.mass_properties(ACCURACY).map_err(|e| format!("SMLib mass properties: {e}"))?; let [x, y, z] = m.centroid; Ok(Exact { volume: m.volume, area: m.area, centroid: Vec3::new(x, y, z) }) } diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV index e10e2624e..0b7fc3e8c 100644 --- a/crates/smlib/SMLIB_REV +++ b/crates/smlib/SMLIB_REV @@ -1 +1 @@ -f6f428bfa2588f9d163ea06dfcf05c3777d9ce57 +a6a0c024fd455adc9f98c6076806db7ea7164e2d