From 17de3569fd2be84a14ede2f59927756da2e9a4eb Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:37:02 -0500 Subject: [PATCH 1/5] SMLib: pin f916a8d (a round on a definition face is its definition; the G1 setback fill certified convex, setbacks too short refused naming the least; the G2 certificate halves a span no level can certify at once) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ --- crates/smlib/SMLIB_PREBUILT | 16 ++++++++-------- crates/smlib/SMLIB_REV | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/smlib/SMLIB_PREBUILT b/crates/smlib/SMLIB_PREBUILT index 1811dc299..e32b5afb3 100644 --- a/crates/smlib/SMLIB_PREBUILT +++ b/crates/smlib/SMLIB_PREBUILT @@ -1,10 +1,10 @@ # Rust target, SHA-256 of smlib-.tar.gz in the release prebuilt- of # tangency-labs/smlib. Written by scripts/fetch-smlib.sh --pin; never edited by hand. -aarch64-apple-darwin 48461900e6d041389bb3736f2772f7bb21f2d202a1e1f4d27d6c6915c298bb8a -aarch64-pc-windows-msvc 2ba752b4bf8a3f18b47cbc6773763d7d9a3a0393be27c3d4e98a6d5ca9cf0b4d -aarch64-unknown-linux-gnu 8c66c2a113a64e574d945772965f7cc0de46ff8bbb3ce450e95bf57abe6058c0 -i686-pc-windows-msvc dd771c1dede08a3bdfe012ef509d99a16087872790792b44bb8b26cc1015a671 -wasm32-unknown-unknown 7bb1507b9d474d9ee19f2a61d22c9167fdf360672897d9d8dfeb4647a1993fd5 -x86_64-apple-darwin 7ad19f0b30c4c0787f0d3459e2263906fa290db2247afab9efd068feb185fa26 -x86_64-pc-windows-msvc 0dcc44829efa70e19b739b06a19d3cbbc2101c0cc9fb0cc44f28fb97066ce20d -x86_64-unknown-linux-gnu 8d009ebf182f04c95c6a64f9b0b13b355796b62fef60d81665341915136c5851 +aarch64-apple-darwin b1d0e36c05090ab89e96601079b156a656024d0b209a0ac1973443494ed814ba +aarch64-pc-windows-msvc 5c02e2a884acd2de419867392bac497eae7bcd258e90a7de50d8a6c8eaaf7a89 +aarch64-unknown-linux-gnu 52a9d8c58747bc86495be8e81bb7b352faf85bc35b87fd4340e8eab7f4a9d988 +i686-pc-windows-msvc a071be49f30fea979d5972c35542bbcbef04794cbb9891c1a1a78e12720836bd +wasm32-unknown-unknown 6bd987227bc707cdc4f287c1a70fc01e53437a9657e05901fa3a7904ec920351 +x86_64-apple-darwin 8d3fd575337059e345a6b5e7f7e9be94fae7f5a9edc66989f6e1e033eec0ab2e +x86_64-pc-windows-msvc 158fb9fa89cf44bffa44452b2b4829e9a54586d86c0b8c7e5c2d640ac8b45515 +x86_64-unknown-linux-gnu 2a9560c23ad693e89a48d1491d2a75ecfe8e0575d07cfff29ec61cb712429299 diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV index 33fcdb90f..57e5be618 100644 --- a/crates/smlib/SMLIB_REV +++ b/crates/smlib/SMLIB_REV @@ -1 +1 @@ -5e8c9c19bb2cff6b5ae321ecda577496955fe037 +f916a8d628a063333a39b2e303849e584dcc9f26 From 5136898b9d8800c729f55f3358f2ee328e8b883b Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:52:54 -0500 Subject: [PATCH 2/5] Fillet: a setback too short for its corner is refused naming the least that builds (smlib_blend_fit_size) SMLib's setback corner takes a G1 fill only once certified convex, and refuses a setback too short for that as SMLIB_ERR_NO_ROOM with SMLIB_FIT_SETBACK_AT_LEAST, the smallest setback that builds. The kernel reads it (solidcraft-smlib binds smlib_blend_fit_size) and names it; the Fillet dialog says it in plain words. Other room refusals keep their words. The r5 box corner set back 5.5 is refused naming 5.962, which builds. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ --- .../pending/fillet-setback-at-least.json | 23 +++++++++++++++ crates/kernel/src/blend.rs | 4 +++ crates/kernel/src/blend_smlib.rs | 10 ++++++- crates/kernel/src/fillet_setback_tests.rs | 17 +++++++++-- crates/kernel/src/lib.rs | 4 +-- crates/smlib/src/ffi/ops.rs | 21 +++++++++++++- crates/smlib/src/lib.rs | 2 +- crates/smlib/src/ops.rs | 29 +++++++++++++++++++ crates/ui-egui/src/dialogs.rs | 14 ++++++--- crates/ui-egui/src/dialogs_dense.rs | 20 +++++++++++++ 10 files changed, 132 insertions(+), 12 deletions(-) create mode 100644 assets/locales/pending/fillet-setback-at-least.json diff --git a/assets/locales/pending/fillet-setback-at-least.json b/assets/locales/pending/fillet-setback-at-least.json new file mode 100644 index 000000000..9c2ac2a48 --- /dev/null +++ b/assets/locales/pending/fillet-setback-at-least.json @@ -0,0 +1,23 @@ +{ + "en": { + "ui.fillet_error_setback_short": "The setback is too short for this corner's patch: it builds from {least} on. Try a longer Setback." + }, + "ar": { + "ui.fillet_error_setback_short": "مسافة الإرجاع قصيرة جدًا على رقعة هذه الزاوية: تُبنى ابتداءً من {least}. جرّب مسافة إرجاع أطول." + }, + "de": { + "ui.fillet_error_setback_short": "Der Rücksprung ist für das Eckstück zu kurz: Es lässt sich ab {least} bauen. Versuchen Sie einen längeren Rücksprung." + }, + "he": { + "ui.fillet_error_setback_short": "הנסיגה קצרה מדי עבור הטלאי של פינה זו: הוא נבנה החל מ-{least}. נסו נסיגה ארוכה יותר." + }, + "ja": { + "ui.fillet_error_setback_short": "このコーナーのパッチにはセットバックが短すぎます。{least} 以上で作れます。より長いセットバックを試してください。" + }, + "ko": { + "ui.fillet_error_setback_short": "이 코너의 패치에 비해 셋백이 너무 짧습니다. {least}부터 만들 수 있습니다. 더 긴 셋백을 시도해 보세요." + }, + "zh": { + "ui.fillet_error_setback_short": "对于此角点的面片,后退距离太短:从 {least} 起可以构建。请尝试更长的后退距离。" + } +} diff --git a/crates/kernel/src/blend.rs b/crates/kernel/src/blend.rs index 9dc8e3960..3627436f7 100644 --- a/crates/kernel/src/blend.rs +++ b/crates/kernel/src/blend.rs @@ -224,6 +224,10 @@ pub fn fillet_removing(body: &Body, edges: &[Vec3], radius: f64) -> Result<(Body Ok((closed(body, b)?, gone)) } +/// What a refusal of a setback too short for its corner says before the least that builds (in +/// mm): SMLib certifies the corner's fill convex only from that setback on ([`fillet_setback`]). +pub const SETBACK_AT_LEAST: &str = "the smallest setback that builds is "; + /// [`fillet`] with corner setbacks: each `(at, distance)` sets back the corner at the vertex /// nearest `at`, a vertex where every edge is rounded, so its patch starts `distance` along /// each of its edges from the vertex (one distance for all of a corner's edges: SMLib keeps one diff --git a/crates/kernel/src/blend_smlib.rs b/crates/kernel/src/blend_smlib.rs index 88e209246..032aea79a 100644 --- a/crates/kernel/src/blend_smlib.rs +++ b/crates/kernel/src/blend_smlib.rs @@ -418,7 +418,15 @@ mod imp { "not supported yet: the {what} meets a corner of this kind, which SMLib's blends do not handle yet (where its edges \ run on tangentially into each other, or meet in a way no blend corner builds)" )), - SmError::NoRoom => KernelError::TooLarge(format!("the {what} is larger than the faces beside its edges allow")), + // A setback too short for its corner's fill (SMLib certifies it convex only from + // its least on) names that least; any other is a blend too large for its room. + SmError::NoRoom => match solidcraft_smlib::blend_fit() { + Some(solidcraft_smlib::Fit::SetbackAtLeast(least)) => KernelError::Invalid(format!( + "the setback is too short for its corner: {}{least:.4} mm (the corner's patch is convex only from there)", + crate::SETBACK_AT_LEAST + )), + _ => KernelError::TooLarge(format!("the {what} is larger than the faces beside its edges allow")), + }, e => failed(what, "operation", e), })?; // Checked here unless the evaluation's validation mode leaves it to the feature's end diff --git a/crates/kernel/src/fillet_setback_tests.rs b/crates/kernel/src/fillet_setback_tests.rs index 5c9166099..04a92776e 100644 --- a/crates/kernel/src/fillet_setback_tests.rs +++ b/crates/kernel/src/fillet_setback_tests.rs @@ -44,8 +44,10 @@ fn a_setback_off_the_rounded_corner_is_refused() { } /// A setback that does not reach past where the corner's rounds meet without one (on faces square -/// to each other, the radius) is refused before SMLib runs, naming that least setback; a setback -/// just past it builds. +/// to each other, the radius) is refused before SMLib runs, naming that least setback. Past it, a +/// setback still too short for SMLib's corner fill (certified convex only from a setback on, +/// smlib_blend_fit_size's SMLIB_FIT_SETBACK_AT_LEAST) is refused naming the smallest that builds, +/// at most twice the one asked for (the certificate scales the setbacks up to 2); that one builds. #[test] fn a_setback_not_past_the_radius_is_refused_naming_the_least() { for s in [2.0, 5.0] { @@ -54,7 +56,16 @@ fn a_setback_not_past_the_radius_is_refused_naming_the_least() { other => panic!("setback {s}: {:?}", other.map(|b| b.face_count())), } } - let out = corner_case(Some(5.5)).unwrap(); + let least = match corner_case(Some(5.5)) { + Err(KernelError::Invalid(why)) => { + let named = why.split_once(SETBACK_AT_LEAST).and_then(|(_, rest)| rest.split_once(" mm")).and_then(|(n, _)| n.parse::().ok()); + named.unwrap_or_else(|| panic!("no least setback named: {why}")) + } + other => panic!("setback 5.5: {:?}", other.map(|b| b.face_count())), + }; + eprintln!("setback 5.5 refused: the smallest that builds is {least}"); + assert!(least > 5.5 && least <= 11.0, "{least}"); + let out = corner_case(Some(least)).unwrap(); assert!(out.validity().is_empty(), "{:?}", out.validity()); // The least the refusal names, for a form to show before it runs; none at no vertex. let b = box_solid(Vec3::new(0.0, 0.0, 0.0), Vec3::new(60.0, 40.0, 20.0)).unwrap(); diff --git a/crates/kernel/src/lib.rs b/crates/kernel/src/lib.rs index 461fed2fa..72ee89ccf 100644 --- a/crates/kernel/src/lib.rs +++ b/crates/kernel/src/lib.rs @@ -156,8 +156,8 @@ mod validity; pub mod watch; pub use blend::{ - ChamferSide, blend_edges, chamfer, chamfer_max, chamfer_sides, fillet, fillet_each, fillet_g2, fillet_g2_corners, fillet_g2_with_g2_corners, - fillet_least_setback, fillet_max, fillet_max_each, fillet_removing, fillet_setback, tangent_chain, + ChamferSide, SETBACK_AT_LEAST, blend_edges, chamfer, chamfer_max, chamfer_sides, fillet, fillet_each, fillet_g2, fillet_g2_corners, + fillet_g2_with_g2_corners, fillet_least_setback, fillet_max, fillet_max_each, fillet_removing, fillet_setback, tangent_chain, }; pub use blend_corner::fillet_radii; pub use blend_variable::{RadiusSpline, Taper, fillet_chord, fillet_tapered, fillet_variable, fillet_variable_points, fillet_variable_spline, taper}; diff --git a/crates/smlib/src/ffi/ops.rs b/crates/smlib/src/ffi/ops.rs index 9d2ba3bfd..6cdc07c44 100644 --- a/crates/smlib/src/ffi/ops.rs +++ b/crates/smlib/src/ffi/ops.rs @@ -1,5 +1,5 @@ //! The operations block of `capi/include/smlib.h` (`smlib_boolean`, `smlib_boolean_union_all`, `smlib_boolean2d`, `smlib_fillet`, -//! `smlib_chamfer`, `smlib_blend`, `smlib_blend_dropping`, `smlib_blend_setback`, `smlib_blend_setback_open`, `smlib_fillet_variable`, `smlib_chamfer_sides`, `smlib_shell`, `smlib_offset_faces`, +//! `smlib_chamfer`, `smlib_blend`, `smlib_blend_dropping`, `smlib_blend_setback`, `smlib_blend_setback_open`, `smlib_blend_fit_size`, `smlib_fillet_variable`, `smlib_chamfer_sides`, `smlib_shell`, `smlib_offset_faces`, //! `smlib_thicken`, `smlib_draft`, `smlib_merge_faces`, `smlib_brep_solid_count`, `smlib_imprint`; the fork's `capi/src/smlib_ops.cpp`), declared by //! hand. Part of the FFI boundary, like its parent: called only through //! [`crate::ops`]. @@ -31,6 +31,11 @@ pub const BLEND_CURVATURE: i32 = 1; pub const BLEND_CHORD: i32 = 2; pub const BLEND_CHAMFER: i32 = 3; +pub const FIT_SIZE: i32 = 0; +pub const FIT_SETBACK: i32 = 1; +pub const FIT_SCALE: i32 = 2; +pub const FIT_SETBACK_AT_LEAST: i32 = 3; + /// Which selection operation: the C functions share one signature. #[derive(Clone, Copy)] pub enum Pick { @@ -95,6 +100,7 @@ unsafe extern "C" { out: *mut *mut RawBrep, out_failed_point: *mut i64, ) -> i32; + fn smlib_blend_fit_size(out_size: *mut f64, out_what: *mut i32) -> i32; fn smlib_blend_dropping( brep: *const RawBrep, kind: i32, @@ -251,6 +257,19 @@ pub fn pick_op(kind: Pick, b: &Handle, points: &[[f64; 3]], tolerance: f64, size }) } +/// `smlib_blend_fit_size`: the size that builds, and what it sizes (`FIT_*`), for the last blend +/// call SMLib refused as too large or a setback as too short; `None` where it names none. +#[cfg(feature = "native")] +pub fn blend_fit_size() -> Option<(f64, i32)> { + let (mut size, mut what) = (0.0f64, -1i32); + (unsafe { smlib_blend_fit_size(&mut size, &mut what) } == OK).then_some((size, what)) +} + +#[cfg(not(feature = "native"))] +pub fn blend_fit_size() -> Option<(f64, i32)> { + None +} + #[cfg(feature = "native")] pub fn thicken(b: &Handle, thickness: f64, symmetric: bool) -> Result { new_brep(|out| unsafe { smlib_thicken(b.raw(), thickness, i32::from(symmetric), out) }) diff --git a/crates/smlib/src/lib.rs b/crates/smlib/src/lib.rs index 3682e6a8a..8a63fb7b8 100644 --- a/crates/smlib/src/lib.rs +++ b/crates/smlib/src/lib.rs @@ -32,7 +32,7 @@ pub mod trim; pub use check::{CheckLevel, CheckReport}; pub use measure::{MEASURE_ACCURACY, MassProperties, PointClass}; -pub use ops::{Blend, BooleanOp, ChamferSecond, Hole, HoleEdge, MAX_POINTS, MAX_UNION_BREPS}; +pub use ops::{Blend, BooleanOp, ChamferSecond, Fit, Hole, HoleEdge, MAX_POINTS, MAX_UNION_BREPS, blend_fit}; /// Why an SMLib call failed. #[derive(Clone, Debug, PartialEq)] diff --git a/crates/smlib/src/ops.rs b/crates/smlib/src/ops.rs index 44d5f422d..83f41e12d 100644 --- a/crates/smlib/src/ops.rs +++ b/crates/smlib/src/ops.rs @@ -8,6 +8,35 @@ use crate::{Brep, Error, Result, error, ffi, init}; +/// What size builds a blend SMLib refused ([`blend_fit`]): from the refusal's own cause, never by +/// building again. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Fit { + /// The largest size (a round's radius, a chamfer's distance, a chord's width) that builds. + Size(f64), + /// The largest setback of a set-back corner that fits (the one asked for is too long). + Setback(f64), + /// The factor (< 1) a two-distance chamfer's distances are both scaled by to build. + Scale(f64), + /// The smallest setback that builds the corner (the one asked for is too short: its fill is + /// certified convex only from there). + SetbackAtLeast(f64), +} + +/// The size that builds the last blend this process's SMLib refused as too large +/// ([`Error::NoRoom`]) or whose setback it refused as too short; `None` where it names no single +/// size. Read it right after the refused call: SMLib keeps only the last one. +pub fn blend_fit() -> Option { + let (size, what) = ffi::ops::blend_fit_size()?; + match what { + ffi::ops::FIT_SIZE => Some(Fit::Size(size)), + ffi::ops::FIT_SETBACK => Some(Fit::Setback(size)), + ffi::ops::FIT_SCALE => Some(Fit::Scale(size)), + ffi::ops::FIT_SETBACK_AT_LEAST => Some(Fit::SetbackAtLeast(size)), + _ => None, + } +} + /// How [`Brep::boolean`] combines two bodies. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum BooleanOp { diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 533ae07b3..e6cdb875b 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -2665,7 +2665,7 @@ fn error_rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui: &mut #[derive(Debug, PartialEq)] pub(crate) enum FilletRefusal { /// In these plain words. - Plain(&'static str), + Plain(String), /// Not again: the Setback field already flags the value and names the least it takes. InField, } @@ -2680,6 +2680,12 @@ pub(crate) fn fillet_plain_error(error: &str, setback_in_field: bool) -> Option< if setback_in_field && error.contains("the setback must be more than") { return Some(FilletRefusal::InField); } + // A setback too short for its corner's patch: the least that builds, as the kernel names it + if let Some((_, rest)) = error.split_once(solidcraft_engine::kernel::SETBACK_AT_LEAST) + && let Some(least) = rest.split_once(" mm").map(|(n, _)| n.trim()).filter(|n| n.parse::().is_ok()) + { + return Some(FilletRefusal::Plain(crate::i18n::format("ui.fillet_error_setback_short", &[("least", &format!("{least} mm"))]))); + } let too_large = error.contains("larger than the faces beside its edges allow"); let corner = error.contains("setback") || error.contains("G2 corner") || error.contains("corner patch"); let kernel = error.contains("SMLib") @@ -2688,11 +2694,11 @@ pub(crate) fn fillet_plain_error(error: &str, setback_in_field: bool) -> Option< || error.contains("kernel internal error") || error.contains("the rounds would leave openings"); if too_large { - Some(FilletRefusal::Plain(tr("ui.fillet_error_too_large"))) + Some(FilletRefusal::Plain(tr("ui.fillet_error_too_large").to_string())) } else if corner && kernel { - Some(FilletRefusal::Plain(tr("ui.fillet_error_corner"))) + Some(FilletRefusal::Plain(tr("ui.fillet_error_corner").to_string())) } else if kernel { - Some(FilletRefusal::Plain(tr("ui.fillet_error_failed"))) + Some(FilletRefusal::Plain(tr("ui.fillet_error_failed").to_string())) } else { None } diff --git a/crates/ui-egui/src/dialogs_dense.rs b/crates/ui-egui/src/dialogs_dense.rs index 3814f8c02..f9f8400bd 100644 --- a/crates/ui-egui/src/dialogs_dense.rs +++ b/crates/ui-egui/src/dialogs_dense.rs @@ -1416,6 +1416,26 @@ mod tests { /// A smooth-patch fillet reopens with its corner and setback, and OK writes them as saved; a /// setback list the dialog cannot show as one distance is kept as it is. + /// A setback too short for SMLib's corner fill (past the least the field flags) is refused by + /// the kernel naming the smallest that builds; the dialog says it in plain words, that length + /// in them. + #[test] + fn a_setback_too_short_for_the_corner_says_the_least_that_builds() { + let refused = format!( + "invalid parameters for `solid.fillet`: the setback is too short for its corner: {}5.9620 mm (the corner's patch is convex only from there)", + solidcraft_engine::kernel::SETBACK_AT_LEAST + ); + match crate::dialogs::fillet_plain_error(&refused, true) { + Some(crate::dialogs::FilletRefusal::Plain(plain)) => assert!(plain.contains("5.9620 mm"), "{plain}"), + other => panic!("{other:?}"), + } + // A blend too large for its faces keeps its own words. + assert_eq!( + crate::dialogs::fillet_plain_error("the fillet is larger than the faces beside its edges allow", true), + Some(crate::dialogs::FilletRefusal::Plain(crate::i18n::tr("ui.fillet_error_too_large").to_string())) + ); + } + #[test] fn a_saved_smooth_patch_reopens_with_its_setback() { for (setbacks, field) in [ From e6db7be0af9705c11b2560a519ad4941adc2818b Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:52:54 -0500 Subject: [PATCH 3/5] Kernel tests: three rounds of different radii at a corner meet in SMLib's setback corner Each round runs whole to its section square to its edge at its setback (the owner's rule, at least 1.5 r, scaled to the least at which the G1 fill is certified convex), and the hole is the setback split: one patch per round and the triangle in three quadrilaterals, 15 faces, G1. Outside the box the sections span the body is the three strips', so its volume is theirs within that box's. A later r3 round at the mitred corner makes the body all three at once make (7928.142563938, 15 faces), as the engine and the model-cache tests have it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ --- apps/solidcraft-cli/tests/model_cache.rs | 7 +-- crates/engine/src/tests.rs | 17 +++--- crates/kernel/src/blend_corner.rs | 68 ++++++++++-------------- tests/KNOWN_FAILING_TESTS | 1 - 4 files changed, 41 insertions(+), 52 deletions(-) diff --git a/apps/solidcraft-cli/tests/model_cache.rs b/apps/solidcraft-cli/tests/model_cache.rs index c5586052a..5d9ec3ed5 100644 --- a/apps/solidcraft-cli/tests/model_cache.rs +++ b/apps/solidcraft-cli/tests/model_cache.rs @@ -317,7 +317,8 @@ fn a_model_saved_under_another_check_mode_is_evaluated_again() { /// later round at the corner where they meet blends them again with it whether the design was /// opened from its model or evaluated anew. Two edges of a 20 mm box rounded r2 (a mitre at the /// corner (20, 0, 20)), saved; opened, the upright edge there rounded r3: the corner all three -/// rounded at once make, 10 faces and 7928.743041 mm³, the same body as the design evaluated anew. +/// rounded at once make (SMLib's setback corner, kernel `three_rounds_at_a_corner`), 15 faces and +/// 7928.142563938 mm³, the same body as the design evaluated anew. #[test] fn a_later_round_after_opening_blends_the_saved_rounds_again() { let mut built = Session::default(); @@ -334,8 +335,8 @@ fn a_later_round_after_opening_blends_the_saved_rounds_again() { let st = s.model.state(); let b = &st.body("Box").unwrap().body; let v = solidcraft_engine::kernel::measure(b).unwrap().volume; - assert_eq!(b.face_count(), 10); - assert!((v - 7928.743041).abs() < 1e-6, "{v}"); + assert_eq!(b.face_count(), 15); + assert!((v - 7928.142563938).abs() < 1e-6, "{v}"); } assert_eq!(model("later round", &cached), model("later round", &rebuilt)); let _ = std::fs::remove_file(&path); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 598d39e50..4c8c5fd00 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -91,10 +91,10 @@ fn fillet_as_wide_as_a_face_rounds_it_off() { /// The owner's ruling of 2026-10-30: two edges of a 20 mm box rounded r2 in one fillet (they /// meet in a mitre at the corner (20, 0, 20), the upright edge there sharp), then the upright edge -/// r3 in a second fillet, whose tangent chain takes the mitre's seam with it. The corner is one -/// smooth patch, the body rounding all three at once makes (kernel `fillet_radii` of the box with -/// each edge's radius: 10 faces, 7928.743041 mm³); the r2 rounds keep their names, and the r3 -/// round and the corner patch are the second fillet's. +/// r3 in a second fillet, whose tangent chain takes the mitre's seam with it. The corner is the +/// body rounding all three at once makes (kernel `fillet_radii` of the box with each edge's +/// radius, `three_rounds_at_a_corner`: SMLib's setback corner, 15 faces, 7928.142563938 mm³); the +/// r2 rounds keep their names, and the r3 round and the corner's patches are the second fillet's. #[test] fn a_later_round_at_a_mitred_corner_is_blended_with_the_rounds_there() { let mut s = Session::default(); @@ -116,16 +116,17 @@ fn a_later_round_at_a_mitred_corner_is_blended_with_the_rounds_there() { let second = run(&mut s, "solid.fillet", json!({"edges": [[20, 0, 10]], "radius": 3}))["feature"].as_u64().unwrap(); assert!(s.model.results.iter().all(|r| r.error.is_none()), "{:?}", s.model.results); let v = volume(&mut s); - assert!((v - 7928.743041).abs() < 1e-5, "{v}"); + assert!((v - 7928.142563938).abs() < 1e-6, "{v}"); let faces = run(&mut s, "model.faces", json!({"body": "Box"}))["faces"].as_array().cloned().unwrap_or_default(); - assert_eq!(faces.len(), 10); + assert_eq!(faces.len(), 15); let after: Vec = rounds.iter().map(|p| named(&mut s, *p)).collect(); assert_eq!(after, before); - // The r3 round (halfway up, at 45°) and the corner patch: the two faces the second fillet made. + // The r3 round (halfway up, at 45°) and the corner's patches: the faces the second fillet made. let k3 = 3.0 - 4.5_f64.sqrt(); assert!(named(&mut s, solidcraft_geom::Vec3::new(20.0 - k3, k3, 10.0)).starts_with(&format!("F{second}:blend:"))); let made = faces.iter().filter(|f| f["name"].as_str().is_some_and(|n| n.starts_with(&format!("F{second}:")))).count(); - assert_eq!(made, 2, "{faces:?}"); + // the r3 round and the corner's six patches (a setback patch per round, three in the triangle) + assert_eq!(made, 7, "{faces:?}"); } #[test] diff --git a/crates/kernel/src/blend_corner.rs b/crates/kernel/src/blend_corner.rs index a6fbaf575..544e2a2ef 100644 --- a/crates/kernel/src/blend_corner.rs +++ b/crates/kernel/src/blend_corner.rs @@ -305,30 +305,6 @@ mod tests { 8000.0 - full + (sum - union) * hh * hh } - /// What the strips leave of the corner block where a patch over the corner of rounds `ra`, - /// `rb`, `rc` on a, b, c lies: beyond a's end section (y < rc), b's (x > 20 − rc) and c's end - /// (z > 20 − max(ra, rb), where c's rails meet a's and b's), the box's material that no - /// strip removes, by columns along z. Outside that block such a body is the strips' (its - /// rounds are the strips' cylinders up to those ends), so its patch takes at most this - /// beyond them. - fn corner_block(ra: f64, rb: f64, rc: f64) -> f64 { - let len = |d: f64, r: f64| if d < r { r - (r * r - (r - d) * (r - d)).max(0.0).sqrt() } else { 0.0 }; - let (n, depth) = (2000, ra.max(rb)); - let h = rc / n as f64; - let mut kept = 0.0; - for i in 0..n { - let dx = (i as f64 + 0.5) * h; - for j in 0..n { - let dy = (j as f64 + 0.5) * h; - if (rc - dx).powi(2) + (rc - dy).powi(2) > rc * rc && dx < rc && dy < rc { - continue; - } - kept += depth - len(dx, ra).max(len(dy, rb)).min(depth); - } - } - kept * h * h - } - /// Largest angle (degrees) between the two faces' normals along edges between curved faces. fn kink(b: &Body) -> f64 { let rec = Faces::of(b).unwrap(); @@ -515,29 +491,41 @@ mod tests { assert!(r.validity().is_empty(), "{:?}", r.validity()); assert!((vol(&r) - sphere).abs() < 1e-11 * sphere, "{} vs {sphere}", vol(&r)); assert!(kink(&r) < 0.01); - // Different radii: a smooth patch over the corner, more than the strips take, and no more - // than they leave in the block it lies in: its rounds end at a's section y = rc, b's - // x = 20 − rc, and c's rails where they meet a's and b's (z = 20 − ra, z = 20 − rb), the - // patch's four corners. (2, 2, 3): 1.168 beyond the strips, of the 11.86 the block keeps; - // (2, 3, 4): 3.099 of 32.69. + // Different radii: SMLib's setback corner (SmBlendSetback.h). Each round runs whole up to + // its section square to its edge at its setback, the owner's rule's (at least 1.5 r, more + // where the rails beside it cross later, scaled to the least at which the corner's G1 fill + // is certified convex), and the hole between the three sections is filled by the setback + // split: one setback patch per round and the triangle between them in three + // quadrilaterals, so 6 planes, 3 rounds and 6 patches (15 faces), G1 across every seam. + // Outside the box the sections span ([20 - d_b, 20] x [0, d_a] x [20 - d_c, 20], d each + // edge's setback) the body is the three strips', so its volume is theirs within that box's. + // The rounds a and b of one radius lie mirrored about the plane x + y = 20 with c: one + // setback. (2, 2, 3): 3.6155, 3.6155, 4.6485; (2, 3, 4): 4.7745, 5.03975, 6.366 (a, b, c). for (rs, sel) in [((2.0, 2.0, 3.0), fillet(&ab, &[c], 3.0)), ((2.0, 3.0, 4.0), fillet_radii(&bx, &[(a, 2.0), (b, 3.0), (c, 4.0)]))] { let r = sel.unwrap(); - assert_eq!(r.face_count(), 10); + assert_eq!(r.face_count(), 15); assert_eq!(r.unmeshed_faces(), 0); + assert!(r.validity().is_empty(), "{:?}", r.validity()); let k = kink(&r); - assert!(k < 0.05, "kink {k}°"); + assert!(k < 0.01, "kink {k}°"); let (ra, rb, rc) = rs; - let ends = [ - Vec3::new(20.0 - ra, rc, 20.0), - Vec3::new(20.0, rc, 20.0 - ra), - Vec3::new(20.0 - rc, rb, 20.0), - Vec3::new(20.0 - rc, 0.0, 20.0 - rb), - ]; - for p in ends { - assert!(vertices(&r).iter().any(|q| q.dist(p) < 1e-9), "{rs:?}: no patch corner at {p:?}"); + let vs = vertices(&r); + // An edge's setback: where its round's section meets both faces, at two vertices. + let setback = |at: &dyn Fn(f64) -> [Vec3; 2], r: f64| -> Option { + vs.iter() + .flat_map(|p| [p.y, 20.0 - p.x, 20.0 - p.z]) + .find(|d| *d >= 1.5 * r - 1e-9 && *d < 20.0 && at(*d).iter().all(|q| vs.iter().any(|p| p.dist(*q) < 1e-9))) + }; + let da = setback(&|d| [Vec3::new(20.0 - ra, d, 20.0), Vec3::new(20.0, d, 20.0 - ra)], ra); + let db = setback(&|d| [Vec3::new(20.0 - d, 0.0, 20.0 - rb), Vec3::new(20.0 - d, rb, 20.0)], rb); + let dc = setback(&|d| [Vec3::new(20.0 - rc, 0.0, 20.0 - d), Vec3::new(20.0, rc, 20.0 - d)], rc); + eprintln!("{rs:?}: setbacks {da:?} {db:?} {dc:?}"); + let (Some(da), Some(db), Some(dc)) = (da, db, dc) else { panic!("{rs:?}: a round's setback section is missing: {da:?} {db:?} {dc:?}") }; + if ra == rb { + assert!((da - db).abs() < 1e-9, "{da} vs {db}"); } let (v, s) = (vol(&r), strips(ra, rb, rc)); - assert!(v < s + 0.05 && v > s - corner_block(ra, rb, rc), "{v} vs {s}"); + assert!((v - s).abs() < db * da * dc, "{v} vs {s}"); } } diff --git a/tests/KNOWN_FAILING_TESTS b/tests/KNOWN_FAILING_TESTS index e9003bc98..49db644ff 100644 --- a/tests/KNOWN_FAILING_TESTS +++ b/tests/KNOWN_FAILING_TESTS @@ -15,7 +15,6 @@ solidcraft-engine::tests::shell_tangent_chain_that_opens_every_face_explains_how solidcraft-kernel::blend::corner_tests::a_round_ending_in_an_earlier_round_matches_both_together SMLib fillet status 1001 on the round that ends in the earlier one solidcraft-kernel::blend::corner_tests::corner_blends_hold_at_any_scale at 0.01x a picked edge runs on tangentially into an unblended edge and SMLib's result is not a closed solid (the smooth-vertex End, tangency-labs/smlib#81) solidcraft-kernel::blend_corner::tests::issue2422_vertical_after_separate_bottom_rounds SMLib's check refuses the fillet: edge and vertex tolerance 0.97 against the body's 0.01 (#2422) -solidcraft-kernel::blend_corner::tests::three_rounds_at_a_corner the corner's variable-radius transition between rounds of different radii (its elliptic law, a rail edge the corner interpolates) meets its neighbours at 0.144 degrees once its sections are the balls' touch circles (0 with the great circles); the corner step replaces that transition solidcraft-kernel::corner_g2::tests::a_long_setback_keeps_the_g2_patch_inside_the_box at set backs 11 to 15 the G2 corner patch bulges 2.6e-6 to 1.33e-3 past the box (the explicit corner is in progress) solidcraft-kernel::corner_g2::tests::the_box_corner_g2_patch_is_a_closed_solid_curvature_continuous_to_its_neighbours the fitted G2 corner patch bulges 1.7e-5 past the box, which SMLib's exact tight box now sees (the explicit G2 corner builds it inside) solidcraft-kernel::tests::fillet_tabbed_plate_outer_loop_and_partial_selection_after_hole the partial selection runs on tangentially into an unblended edge and SMLib's result is not a closed solid (the smooth-vertex End, tangency-labs/smlib#81) From 5d168a5e26721800a4e4267bb3a5a09ce6e9e95d Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sun, 1 Nov 2026 21:52:54 -0500 Subject: [PATCH 4/5] Kernel tests: SMLib's own corner between curvature rounds is curvature continuous, as the G2 patch is Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ --- crates/kernel/src/corner_g2_tests.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/kernel/src/corner_g2_tests.rs b/crates/kernel/src/corner_g2_tests.rs index 88125bc27..325741826 100644 --- a/crates/kernel/src/corner_g2_tests.rs +++ b/crates/kernel/src/corner_g2_tests.rs @@ -344,10 +344,11 @@ fn a_mixed_convexity_corner_is_refused() { } /// Curvature-continuous rounds (`fillet_g2`, equivalent radius 5) of the three edges at the box -/// corner: SMLib's own corner patch between them is only tangent to the rounds, its curvature -/// jumping across their seams (it showed as a dome on the corner), so the corner is the G2 patch -/// instead, filled between the curvature rounds' setback sections: one closed valid solid, the -/// patch curvature-continuous to every round and face round it clear of the hole's corners. +/// corner: SMLib's own corner between them is its setback corner, whose fill for curvature +/// sections meets the rounds and faces curvature-continuously (SmBlendSetback.h: G2 for an order +/// 2 section), as the G2 patch filled between the curvature rounds' setback sections does: each +/// one closed valid solid, curvature-continuous across every seam round the corner clear of the +/// hole's corners. #[test] fn curvature_rounds_meet_at_a_g2_corner() { let (body, edges) = box_corner(); @@ -357,9 +358,9 @@ fn curvature_rounds_meet_at_a_g2_corner() { let v = crate::validity::validity(&g2); assert!(v.ok(), "{:?}", v); let (_, clear, n) = corner_seams(&g2, 0.15); - let (_, smlib_clear, _) = corner_seams(&smlib_corner, 0.15); + let (_, smlib_clear, smlib_n) = corner_seams(&smlib_corner, 0.15); assert!(n > 0 && clear <= CURVATURE_SHARE / 5.0, "{clear} over {n} stations"); - assert!(smlib_clear > 10.0 * CURVATURE_SHARE / 5.0, "SMLib's own corner patch: {smlib_clear}"); + assert!(smlib_n > 0 && smlib_clear <= CURVATURE_SHARE / 5.0, "SMLib's own corner: {smlib_clear} over {smlib_n} stations"); // Both differ only within the setback cube (side 1.5 r = 7.5) at the corner. let (a, b) = (measure(&g2).unwrap().volume, measure(&smlib_corner).unwrap().volume); assert!((a - b).abs() < 7.5f64.powi(3), "{a} vs {b}"); From 99953687c7536b27606ae9589cf751f9a5d8a9b0 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Sun, 1 Nov 2026 22:45:59 -0500 Subject: [PATCH 5/5] Kernel rig: the boss root's and the hole rim's curvature rounds take the default timeout again (37 s and 34 s on the box under the rig's parallel load, tangency-labs/smlib#96) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ --- .../cov-fillet-section-curvature-boss-root-r2/expected.json | 3 +-- .../fillets/every-hole-top-rim-r1-curvature/expected.json | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/kernel-cases/fillets/cov-fillet-section-curvature-boss-root-r2/expected.json b/tests/kernel-cases/fillets/cov-fillet-section-curvature-boss-root-r2/expected.json index 06733808a..f752858e7 100644 --- a/tests/kernel-cases/fillets/cov-fillet-section-curvature-boss-root-r2/expected.json +++ b/tests/kernel-cases/fillets/cov-fillet-section-curvature-boss-root-r2/expected.json @@ -11,6 +11,5 @@ }, "tolerance": { "rel": 1e-07 - }, - "timeout_s": 1800 + } } diff --git a/tests/kernel-cases/fillets/every-hole-top-rim-r1-curvature/expected.json b/tests/kernel-cases/fillets/every-hole-top-rim-r1-curvature/expected.json index a05967899..8f1712ccb 100644 --- a/tests/kernel-cases/fillets/every-hole-top-rim-r1-curvature/expected.json +++ b/tests/kernel-cases/fillets/every-hole-top-rim-r1-curvature/expected.json @@ -20,6 +20,5 @@ }, "continuity": { "order": "g2" - }, - "timeout_s": 600 + } }