Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Wave 104/509: solidcraft-smlib: pin the fork at 2d7c7ed, the second round of SMLib C++ fixes (and 1 more)

jyvikoe63bcc3808c5
diff --git a/apps/solidcraft-cli/src/kernel_cases.rs b/apps/solidcraft-cli/src/kernel_cases.rs
index 49d5f0e092..5c3ac8b713 100644
--- a/apps/solidcraft-cli/src/kernel_cases.rs
+++ b/apps/solidcraft-cli/src/kernel_cases.rs
@@ -11,7 +11,16 @@ use crate::{read_json, recipe};
/// The kernel this process runs on (`SOLIDCRAFT_KERNEL`, set by the caller).
fn kernel() -> String {
- std::env::var("SOLIDCRAFT_KERNEL").ok().filter(|k| !k.is_empty()).unwrap_or_else(|| "default".into())
+ kernel_name(std::env::var("SOLIDCRAFT_KERNEL").ok().as_deref())
+}
+
+/// The rig's name for a `SOLIDCRAFT_KERNEL` setting: unset, empty or `truck` (all of which the
+/// kernel runs as truck) is `default`, the name `boolean_kernel` reports for truck.
+fn kernel_name(setting: Option<&str>) -> String {
+ match setting.map(str::trim) {
+ None | Some("") | Some("truck") => "default".into(),
+ Some(other) => other.into(),
+ }
}
/// How many cases a chain of `base` recipes may go through (a ladder case builds on the one
@@ -371,6 +380,15 @@ mod tests {
let _ = std::fs::remove_dir_all(&root);
}
+ #[test]
+ fn truck_named_explicitly_is_the_default_kernel() {
+ // `SOLIDCRAFT_KERNEL=truck` runs truck, so the rig must not call it a build mismatch.
+ for setting in [None, Some(""), Some(" "), Some("truck")] {
+ assert_eq!(kernel_name(setting), "default");
+ }
+ assert_eq!(kernel_name(Some("smlib")), "smlib");
+ }
+
#[test]
fn a_base_cycle_is_an_error_not_a_hang() {
let root = std::env::temp_dir().join(format!("kernel-cases-cycle-{}", std::process::id()));
diff --git a/crates/kernel/src/blend_smlib.rs b/crates/kernel/src/blend_smlib.rs
index f7bf6739bc..451a3d5c9c 100644
--- a/crates/kernel/src/blend_smlib.rs
+++ b/crates/kernel/src/blend_smlib.rs
@@ -451,10 +451,9 @@ mod tests {
fn options_smlib_cannot_build_are_refused() {
assert!(unsupported("x").to_string().contains("not supported yet"));
let b = cube();
- // A radius law with a corner (4 → 2 → 4, straight on both halves).
- let corner = RadiusSpline { degree: 1, knots: vec![0.0, 0.0, 0.5, 1.0, 1.0], radii: vec![4.0, 2.0, 4.0] };
- let e = imp::variable(&b, Vec3::new(10.0, 20.0, 20.0), Vec3::new(0.0, 20.0, 20.0), &corner).unwrap_err();
- assert!(e.to_string().contains("not supported yet"), "{e}");
+ // A radius law down to zero inside the edge would pinch the round to a point.
+ let pinch = RadiusSpline { degree: 1, knots: vec![0.0, 0.0, 0.5, 1.0, 1.0], radii: vec![4.0, 0.0, 4.0] };
+ assert!(imp::variable(&b, Vec3::new(10.0, 20.0, 20.0), Vec3::new(0.0, 20.0, 20.0), &pinch).is_err());
assert!(imp::blend(&b, "fillet", Kind::Round, &[Vec3::new(10.0, 20.0, 20.0)], &[f64::NAN]).is_err());
assert!(imp::blend(&b, "fillet", Kind::Round, &[Vec3::new(f64::NAN, 20.0, 20.0)], &[1.0]).is_err());
assert!(imp::blend(&b, "fillet", Kind::Round, &[], &[]).is_err());
diff --git a/crates/kernel/src/tess/tests.rs b/crates/kernel/src/tess/tests.rs
index 7ce933745f..14a2829a9d 100644
--- a/crates/kernel/src/tess/tests.rs
+++ b/crates/kernel/src/tess/tests.rs
@@ -715,8 +715,10 @@ fn the_halves_of_a_split_smlib_coil_measure_as_the_whole() {
// π r² · 2πR · turns; SMLib's wall is a spline within a ten-thousandth of the pitch.
let (whole, analytic) = (volume(&coil), PI * 2.0 * PI * 20.0 * 6.0);
assert!((whole - analytic).abs() < 3e-3 * analytic, "coil {whole} vs {analytic}");
+ // The halves are held to the closed form itself: the whole coil's one wall is meshed
+ // within 3e-3 of it, which made the whole a looser yardstick than the truth.
let halves = volume(&upper) + volume(&lower);
- assert!((halves - whole).abs() < 1e-3 * whole, "halves {halves} vs the whole {whole}");
+ assert!((halves - analytic).abs() < 1e-3 * analytic, "halves {halves} vs {analytic} (the whole measures {whole})");
}
/// Thinning keeps a grid within its cap whatever the rounding, both ends of each direction,
diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV
index fde534702d..74914273be 100644
--- a/crates/smlib/SMLIB_REV
+++ b/crates/smlib/SMLIB_REV
@@ -1 +1 @@
-276b509ad2b634843b2f256e1eb1fbaa29a5ef87
+2d7c7edcff20b8f70c4e4d8aa952265bca2acc9d
diff --git a/crates/smlib/src/ops_tests.rs b/crates/smlib/src/ops_tests.rs
index 8048dde56b..a74b898da7 100644
--- a/crates/smlib/src/ops_tests.rs
+++ b/crates/smlib/src/ops_tests.rs
@@ -285,11 +285,15 @@ fn a_variable_round_follows_its_law() {
let zero = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &knots, &[4.0, 0.0]).unwrap();
shot(&zero, "variable-to-zero");
assert_close(volume(&zero), 8000.0 - q * 20.0 * 16.0 / 3.0, 1e-5, "down to zero");
- // A law with a corner (4 → 2 → 4, straight on both halves): SMLib's section fit runs across
- // the corner and misses it, so it is refused; the same points joined smoothly (C1 cubic
- // pieces, as RadiusSpline::through makes them) are built.
- let corner = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 2.0, 4.0]);
- assert_eq!(corner.unwrap_err(), Error::Unsupported);
+ // A law with a corner (4 → 2 → 4, straight on both halves): the round turns at the corner,
+ // each half taking away (1 - pi/4) (L / 2) (16 + 8 + 4) / 3; the same points joined smoothly
+ // (C1 cubic pieces, as RadiusSpline::through makes them) are built too.
+ let corner = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 2.0, 4.0]).unwrap();
+ shot(&corner, "variable-corner-4-2-4");
+ assert_close(volume(&corner), 8000.0 - q * 20.0 * 28.0 / 3.0, 1e-6, "corner law");
+ // A law down to zero inside the edge would pinch the round to a point: refused.
+ let pinch = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 1, &[0.0, 0.0, 0.5, 1.0, 1.0], &[4.0, 0.0, 4.0]);
+ assert!(pinch.is_err(), "a law pinching to zero inside the edge");
let smooth_knots = [0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0, 1.0, 1.0];
let smooth = c.fillet_variable([10.0, 20.0, 20.0], 0.1, [0.0, 20.0, 20.0], 3, &smooth_knots, &[4.0, 10.0 / 3.0, 2.0, 2.0, 2.0, 10.0 / 3.0, 4.0]);
shot(&smooth.unwrap(), "variable-smooth-4-2-4");