SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Tapered cut: run on less, then start on the face, when the run on closes a small corner (#4825) (#4858)
dudedagger42cc9d76cd8678
diff --git a/crates/doc/src/eval.rs b/crates/doc/src/eval.rsindex 493da1b6ec..4b596b08a9 100644--- a/crates/doc/src/eval.rs+++ b/crates/doc/src/eval.rs@@ -4438,8 +4438,25 @@ fn feature_tools_with_constructor(// A start that can't run on (the profile hangs over the face's edge):// the sides stand straight for a hair first, so the boolean can push the// face the tool stands on into the body.- let foot = if a >= 0.0 && on_face { TAPER_FOOT.min((b - a) * 0.01) } else { 0.0 };- let body = kernel::extrude_tapered_between(&start_plane, r, a, b, foot, sign, taper)?;+ let build = |a: f64| {+ let foot = if a >= 0.0 && on_face { TAPER_FOOT.min((b - a) * 0.01) } else { 0.0 };+ kernel::extrude_tapered_between(&start_plane, r, a, b, foot, sign, taper)+ };+ let mut body = build(a);+ // A taper that widens the tool where it cuts narrows it behind its start, so+ // the run on can close a small corner arc the tool itself never shrinks+ // (#4825): run on less, then start on the face.+ for k in [0.5, 0.25, 0.0] {+ if body.is_ok() || a >= 0.0 {+ break;+ }+ let shorter = build(a * k);+ if shorter.is_ok() {+ a *= k;+ body = shorter;+ }+ }+ let body = body?;growth = growth.max(a.abs().max(b.abs()) * taper.tan().abs());Ok(roles.tool(body, None))})diff --git a/crates/engine/src/cmd/features_more_tests.rs b/crates/engine/src/cmd/features_more_tests.rsindex bf608b61d5..7060a6a440 100644--- a/crates/engine/src/cmd/features_more_tests.rs+++ b/crates/engine/src/cmd/features_more_tests.rs@@ -1050,6 +1050,34 @@ fn a_tapered_text_joins_a_block_on_its_face_or_hanging_over_its_edge() {}}+/// A tapered pocket cut 5 mm down from a block's top face, from a 282 × 176 rounded rectangle whose+/// 2 mm corners are smaller than the 2.89 mm the 30° taper widens it by (#4825). Run on out of the+/// block with its slope, the tool narrowed there and closed its corner arcs: "the taper closes+/// the profile", though the pocket only grows. It runs on less, then starts on the face.+#[test]+fn a_tapered_cut_that_widens_cuts_from_small_corners() {+ let (w, h, r, depth) = (282.0, 176.0, 2.0, 5.0);+ for deg in [20.0f64, 30.0, 45.0] {+ let k = deg.to_radians().tan();+ let mut s = Session::default();+ run(&mut s, "sketch.create", json!({"plane":"XY"}));+ run(&mut s, "sketch.rectangle.two_point", json!({"p0":[-159,-106],"p1":[159,106]}));+ run(&mut s, "sketch.finish", json!({}));+ run(&mut s, "solid.extrude", json!({"distance":20,"body_name":"Block"}));+ run(&mut s, "sketch.create", json!({"plane":"XY","offset":20}));+ run(&mut s, "sketch.rectangle.rounded", json!({"p0":[-w / 2.0,-h / 2.0],"p1":[w / 2.0,h / 2.0],"radius":r}));+ run(&mut s, "sketch.finish", json!({}));+ let cut = json!({"distance":depth,"direction":"negative","taper":format!("{deg} deg"),"operation":"cut","targets":["Block"]});+ run(&mut s, "solid.extrude", cut);+ // The pocket: a rounded rectangle grown by k·t at depth t.+ let (l, c) = (depth, 4.0 - std::f64::consts::PI);+ let pocket = w * h * l + k * (w + h) * l * l + 4.0 / 3.0 * k * k * l.powi(3) - c * (r * r * l + r * k * l * l + k * k * l.powi(3) / 3.0);+ let v = volume(&mut s);+ assert!((v - (318.0 * 212.0 * 20.0 - pocket)).abs() < 1e-3 * pocket, "{deg}°: {v}, a {pocket} mm³ pocket");+ assert_eq!(s.world_state().bodies.len(), 1);+ }+}+/// A tapered foot extruded 3 mm down from a part's bottom face and joined (#1534). Run on into/// the part with their slope, sides that narrow the foot away from the face widened it past the/// face: a box got a lip round its walls (0.16 mm wide, and nothing said), a cylinder's join found