From fad9c44dac4fea1e8f3c519be6ec34dbc96aad6d Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 29 Oct 2026 00:19:42 -0400 Subject: [PATCH] kernel: measure integrates to SMLib's finest accuracy, 1e-8, not 1e-4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit measure asked SMLib for a relative accuracy of 1e-4, after SmApiBrepComputeMassProperties' documented clamp to [1e-4, 1e-1]. smlib_brep_mass_properties does not go through that call: it calls the kernel's integration directly because the clamp "leaves curved faces off by 1e-5 to 1e-3", and takes [1e-8, 1e-1] (solidcraft_smlib::MEASURE_ACCURACY). Asking 1e-4 threw that away: a swept cylinder's centre came out 5e-7 off its exact place, and a 0.0177 mm³ crescent (a pin 0.59 µm off its hole) 0.27% off the lens of two circles. Measured at 1e-8, the sweep centres are exact to 1e-7 and the crescents match the closed form to 1e-6; the engine-commands batch runs in the same 20 s. Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/measure.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/kernel/src/measure.rs b/crates/kernel/src/measure.rs index beecbe483..0915b0337 100644 --- a/crates/kernel/src/measure.rs +++ b/crates/kernel/src/measure.rs @@ -43,10 +43,11 @@ pub struct MassMeasure { pub notes: Vec, } -/// The relative accuracy SMLib integrates at: the finest of SmApiBrepComputeMassProperties' -/// documented range ("clamped to [1e-4, 1e-1]", SmApiQueries.h). Its cost is "governed by -/// dRelativeAccuracy". -const ACCURACY: f64 = 1e-4; +/// The relative accuracy SMLib integrates at: the finest the C API takes +/// ([`solidcraft_smlib::MEASURE_ACCURACY`], 1e-8). `smlib_brep_mass_properties` calls the +/// kernel's integration directly because SmApiBrepComputeMassProperties clamps to [1e-4, 1e-1], +/// which leaves curved faces off by 1e-5 to 1e-3; asking 1e-4 here threw that away. +const ACCURACY: f64 = solidcraft_smlib::MEASURE_ACCURACY; /// Measure a body. A B-rep body's volume, area and centre are SMLib's, integrated on its exact /// surfaces over its material regions (a sheet's: its faces' area and their centre, volume 0),