From 8a730c6273f487bcd39ba9366a7df4ea0944f499 Mon Sep 17 00:00:00 2001 From: brett19 Date: Sun, 1 Nov 2026 23:13:17 -0700 Subject: [PATCH] Fillets on solidcore: the largest size that fits is still the one the search builds; the kernel's names the edge solidcore's fit is the largest size less a margin (34.99 where the L bracket's bend builds 35, 4.29 where #3435's ring builds 4.3), so the feature's search keeps naming the size, and solidcore's is the answer only where the search finds none. The refusal keeps its words, "larger than the faces beside its edges allow", with the edge after them. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SdcgEu4Lr3moCCisdZShKz --- crates/doc/src/eval.rs | 8 ++++---- crates/engine/src/tests/blend_fit.rs | 7 ++++--- crates/kernel/src/blend.rs | 13 +++++++++++-- crates/kernel/src/blend_smlib.rs | 6 +++--- crates/kernel/src/lib.rs | 1 + 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/doc/src/eval.rs b/crates/doc/src/eval.rs index 043a697bf..60d210d89 100644 --- a/crates/doc/src/eval.rs +++ b/crates/doc/src/eval.rs @@ -444,11 +444,11 @@ fn with_largest_fit( size: &str, search: impl FnOnce() -> std::result::Result, kernel::KernelError>, ) -> kernel::KernelError { - // The kernel's refusal may name it already, sized exactly where it was found. - if kernel::names_largest_fit(&why) { - return kernel::KernelError::TooLarge(why); - } + // On solidcore the refusal names a size already, less a margin (34.99 where 35 builds), and + // its edge: the edge stays, the size is the largest the search builds, solidcore's where the + // search finds none. match search() { + Ok(Some((largest, _))) if kernel::names_largest_fit(&why) => kernel::KernelError::TooLarge(kernel::with_fit_note(&why, size, largest)), Ok(Some((largest, _))) => kernel::KernelError::TooLarge(format!("{why}; {}", kernel::largest_fit_note(size, largest))), Ok(None) => kernel::KernelError::TooLarge(why), Err(e) => { diff --git a/crates/engine/src/tests/blend_fit.rs b/crates/engine/src/tests/blend_fit.rs index 15b3c3949..e4b364347 100644 --- a/crates/engine/src/tests/blend_fit.rs +++ b/crates/engine/src/tests/blend_fit.rs @@ -47,8 +47,8 @@ fn chamfer_that_fits_still_builds() { /// #199's bar, 14 x 6 x 10, its four upright edges rounded: past a full round of its 6 mm ends /// the two rounds on each end would cross. Refused, naming 3 mm; on solidcore the kernel's refusal -/// carries that size and the edge it was found for (`SolidError::FilletRefused`), so the message -/// names the edge and the feature runs no search. +/// carries a size and the edge it was found for (`SolidError::FilletRefused`), and the message +/// names the edge. #[test] fn a_round_past_a_full_round_is_refused_naming_the_largest_that_fits_and_its_edge() { let mut s = Session::default(); @@ -58,7 +58,8 @@ fn a_round_past_a_full_round_is_refused_naming_the_largest_that_fits_and_its_edg for r in [3.001, 3.5] { let e = s.execute("solid.fillet", &json!({"edges": uprights, "radius": r})).unwrap_err().to_string(); assert!(e.contains("the largest radius that fits is 3 mm"), "{r}: {e}"); - assert!(!on_solidcore || e.contains("beside the edge at ("), "{r}: {e}"); + assert!(!on_solidcore || e.contains("allow, at the edge at ("), "{r}: {e}"); + assert_eq!(e.matches("that fits is").count(), 1, "{r}: {e}"); } assert!((volume(&mut s) - 840.0).abs() < 1e-6, "the part stays as it was"); } diff --git a/crates/kernel/src/blend.rs b/crates/kernel/src/blend.rs index 61b2215e1..ce7bb00c5 100644 --- a/crates/kernel/src/blend.rs +++ b/crates/kernel/src/blend.rs @@ -32,12 +32,21 @@ pub fn largest_fit_note(size: &str, largest: f64) -> String { format!("the largest {size} that fits is {} mm", trimmed_mm(largest)) } -/// Whether a refusal already names the largest size that fits ([`largest_fit_note`]), so no search -/// for it is needed. +/// Whether a refusal already names the largest size that fits ([`largest_fit_note`]). pub fn names_largest_fit(why: &str) -> bool { why.contains("that fits is ") } +/// `why` with the largest size that fits it names ([`largest_fit_note`]) replaced by `largest`: +/// solidcore names the size less a margin (34.99 where 35 builds), a feature's search the +/// largest it built. `why` itself where it names none. +pub fn with_fit_note(why: &str, size: &str, largest: f64) -> String { + let Some(start) = why.find("the largest ") else { return why.to_owned() }; + let Some(len) = why.get(start..).and_then(|rest| rest.find(" mm")) else { return why.to_owned() }; + let (head, tail) = (why.get(..start).unwrap_or_default(), why.get(start + len + 3..).unwrap_or_default()); + format!("{head}{}{tail}", largest_fit_note(size, largest)) +} + /// `v` to the micrometre, without trailing zeros. pub(crate) fn trimmed_mm(v: f64) -> String { let s = format!("{v:.6}"); diff --git a/crates/kernel/src/blend_smlib.rs b/crates/kernel/src/blend_smlib.rs index d9a0d4c68..272b1666b 100644 --- a/crates/kernel/src/blend_smlib.rs +++ b/crates/kernel/src/blend_smlib.rs @@ -447,8 +447,8 @@ mod imp { SmError::NoRoom => KernelError::TooLarge(format!("the {what} is larger than the faces beside its edges allow")), SmError::TooLarge { size, kind, at } => { let beside = match at { - Some([x, y, z]) => format!("the edge at ({x:.3}, {y:.3}, {z:.3})"), - None => "its edges".to_owned(), + Some([x, y, z]) => format!(", at the edge at ({x:.3}, {y:.3}, {z:.3})"), + None => String::new(), }; let fits = match kind { solidcraft_smlib::FitKind::Scale => { @@ -456,7 +456,7 @@ mod imp { } kind => crate::blend::largest_fit_note(kind.word(), size), }; - KernelError::TooLarge(format!("the {what} is larger than the faces beside {beside} allow; {fits}")) + KernelError::TooLarge(format!("the {what} is larger than the faces beside its edges allow{beside}; {fits}")) } SmError::Unported(why) => KernelError::Invalid(format!("not supported yet: {why}")), e => failed(what, "operation", e), diff --git a/crates/kernel/src/lib.rs b/crates/kernel/src/lib.rs index 4f7d6c320..aa865abb6 100644 --- a/crates/kernel/src/lib.rs +++ b/crates/kernel/src/lib.rs @@ -158,6 +158,7 @@ pub mod watch; pub use blend::{ 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, largest_fit_note, names_largest_fit, tangent_chain, + with_fit_note, }; 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};