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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SdcgEu4Lr3moCCisdZShKz
This commit is contained in:
1 parent
881899bee1
commit
8a730c6273
5 files changed
+23
-12
No files matched your search
@@ -444,11 +444,11 @@ fn with_largest_fit(
|
||||
size: &str,
|
||||
search: impl FnOnce() -> std::result::Result<Option<(f64, kernel::Body)>, 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) => {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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}");
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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};
|
||||
|
||||
Reference in new issue
Block a user