SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Modeled threads: the thread runs down to a flat face with no uncut block, so a nut can bottom out (#11782)
bherbruck481687fff380
diff --git a/crates/doc/src/eval_thread.rs b/crates/doc/src/eval_thread.rsindex 44653a1559..9490817afe 100644--- a/crates/doc/src/eval_thread.rs+++ b/crates/doc/src/eval_thread.rs@@ -103,6 +103,11 @@ enum End {/// At (or within half a pitch of) an end of the face where material goes on past it, a/// shoulder, a head, a blind hole's bottom: the groove stops short, clear of it.Closed,+ /// At an end of an external thread's face where a shoulder starts and stays beyond the face's+ /// end: the groove runs on through the plane of that end and is trimmed there, so the root+ /// reaches the shoulder at every angle, a nut bottoms out on it, and nothing past the plane+ /// is cut.+ Shoulder,/// Inside the face: the groove stops square there.Inside,}@@ -121,6 +126,9 @@ pub(super) struct ThreadOn {/// A modelled internal thread in a hole wider than it needs: the radius the bore is narrowed/// to (the thread's minor radius) before the groove is cut, with the hole's own radius.narrow: Option<f64>,+ /// A shoulder keeps the square stop because the kernel couldn't check whether it stays beyond+ /// the face's end.+ shoulder_unchecked: bool,}/// The free-end test of a face's two ends (`side` 0 at its start, 1 at its end), each made@@ -160,6 +168,22 @@ impl FaceEnds<'_> {}Ok(free)}++ /// Does the shoulder at this closed end stay beyond the plane of the face's end? Not where it+ /// rises back along the face (a slanted plate, a boss on a round body), which a groove+ /// running to that plane would cut into: there is material outside the face just inside it.+ /// The caller keeps the square stop, and says so, when the kernel can't make the check.+ fn clear_of_end_plane(&self, side: usize) -> Result<bool> {+ #[cfg(test)]+ if tests::FAIL_CLEARANCE.get() {+ return Err(kernel::KernelError::Failed("clearance refused for the test".into()).into());+ }+ let (p, e) = (self.pitch, self.pitch * 1e-3);+ let inside = if side == 0 { (self.cyl.start + e, self.cyl.start + p) } else { (self.cyl.end - p, self.cyl.end - e) };+ // All the radii the groove cuts beyond the face; only touching their rims is not in its+ // way, as in `free`.+ kernel::material_in_ring(self.body, self.cyl, self.beyond.0 + e, self.beyond.1 - e, inside).map(|hit| !hit).map_err(DocError::from)+ }}/// A thread on the cylindrical face at `p`: its size, and the part of the face it runs over.@@ -333,11 +357,23 @@ pub(super) fn thread_on(st: &ModelState, feature: u64, p: Vec3, ask: &ThreadAsk)// How each end of the thread meets the face: at a face end, or within half a pitch (and its// runout) of one, where the groove would reach past it, that end's free-end test decides.let near = |at: f64, side: usize| if side == 0 { at - lo } else { hi - at } < pitch / 2.0 + ease.get(side).copied().unwrap_or(0.0);+ // A shoulder whose check the kernel couldn't make keeps the square stop, and the feature says so.+ let mut unchecked = false;let mut kind = |at: f64, side: usize| -> Result<End> {Ok(if !ask.modeled || !near(at, side) {End::Inside} else if !ends.free(side)? {- End::Closed+ let at_end = (if side == 0 { at - lo } else { hi - at }) < pitch * 1e-3;+ let square = ease.get(side).copied().unwrap_or(0.0) == 0.0;+ let clear = at_end && square && !cyl.internal && !form.is_taper() && {+ let check = ends.clear_of_end_plane(side);+ unchecked |= matches!(check, Err(DocError::Kernel(_)));+ match check {+ Err(DocError::Kernel(_)) => false,+ other => other?,+ }+ };+ if clear { End::Shoulder } else { End::Closed }} else if (if side == 0 { at - lo } else { hi - at }) < pitch * 1e-3 {End::Free} else {@@ -373,7 +409,7 @@ pub(super) fn thread_on(st: &ModelState, feature: u64, p: Vec3, ask: &ThreadAsk).then(|| form.groove(major, pitch, true)).filter(|g| !(g.root_r - cyl.radius >= g.basic_depth / 4.0)).map(|g| g.crest_r);- Ok(ThreadOn { info, cyl, ends, steep: ask.steep, ease, from: side, narrow })+ Ok(ThreadOn { info, cyl, ends, steep: ask.steep, ease, from: side, narrow, shoulder_unchecked: unchecked })}/// The end of the face (0: its start, 1: its end) a thread of limited length starts at: the end@@ -536,7 +572,9 @@ fn thread_grooves(// Past a free end of the face the groove runs out into the air, a pitch beyond it. Before// a closed one it stops with its section clear of the face's end (its centre as far inside// as the section reaches that way), so it never cuts into the shoulder there; inside the- // face it stops square at the threaded length's end.+ // face it stops square at the threaded length's end. At a shoulder it can be trimmed against+ // ([`End::Shoulder`]) its whole section runs past the plane of the face's end, so every angle+ // of the last turn is cut down to that plane ([`trim_at_shoulders`] takes off the rest).//// A runout `e` at an end (ISO 3508) fades the groove out over `e`: its section moves out of// the material (an external thread's away from the axis, past the surface; an internal@@ -548,12 +586,14 @@ fn thread_grooves((End::Free, false) => t.start - p,(End::Free, true) => t.start,(End::Closed, _) => (t.start - ease[0]).max(face.0 + w_lo),+ (End::Shoulder, _) => face.0 - w_hi - 0.1 * p,(End::Inside, _) => t.start - ease[0],};let s1 = match (ends[1], ease[1] > 0.0) {(End::Free, false) => t.end + p,(End::Free, true) => t.end,(End::Closed, _) => (t.end + ease[1]).min(face.1 - w_hi),+ (End::Shoulder, _) => face.1 + w_lo + 0.1 * p,(End::Inside, _) => t.end + ease[1],};if !(s1 - s0 > p * 1e-3) {@@ -698,6 +738,24 @@ fn taper_envelope(t: &ThreadInfo, radius: f64, ends: [End; 2], (d0, from): (f64,Ok(ring.pop())}+/// The groove with what runs past a shoulder's plane taken off ([`End::Shoulder`]), so cutting it+/// leaves the shoulder whole.+fn trim_at_shoulders(mut tool: Body, axis: Vec3, ends: [End; 2], face: (f64, f64), k: UnitVec3) -> Result<Body> {+ for (end, at, keep_positive) in [(ends[0], face.0, true), (ends[1], face.1, false)] {+ if end != End::Shoulder {+ continue;+ }+ let plane = Plane::from_normal(axis + k * at, *k).ok_or_else(|| DocError::Invalid("thread axis".into()))?;+ // An error of the cut, like the kernel's own: `cut` then falls back to the square stop.+ let missed = || kernel::KernelError::Failed("the thread's groove misses its face".into());+ let kept = kernel::half_space(&tool, &plane, keep_positive)?.0;+ #[cfg(test)]+ let kept = kept.filter(|_| !tests::EMPTY_TRIM.get());+ tool = kept.ok_or_else(missed)?;+ }+ Ok(tool)+}+/// Evaluate a thread feature: a cosmetic thread is listed in the model's threads, a modelled/// one cut into its body.pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st: &mut ModelState, warning: &mut Option<String>) -> Result<()> {@@ -768,7 +826,13 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature,None => note,});}- cut(st, on, (*tip, angle, depth))+ if let Some(note) = cut(st, on, (*tip, angle, depth))? {+ *warning = Some(match warning.take() {+ Some(w) => format!("{w}; {note}"),+ None => note,+ });+ }+ Ok(())}/// A runout as (mm, pitches): ISO 3508's standard 2.5 P and short 1.25 P, or a length.@@ -783,9 +847,10 @@ pub(super) fn runout(vals: &BTreeMap<String, Value>, e: &Option<crate::ThreadRun/// Cut a modelled thread resolved on its face into its body: the grooves (SMLib's exact screw/// sweeps, a taper's crests by its envelope) by one B-rep boolean, then the chamfered tip-/// (`tip`, with its angle and depth when given).-pub(super) fn cut(st: &mut ModelState, on: ThreadOn, (tip, angle, depth): (ThreadTip, Option<f64>, Option<f64>)) -> Result<()> {- let ThreadOn { info: t, cyl, ends, steep, ease, from: from_side, narrow } = on;+/// (`tip`, with its angle and depth when given). What the user should be told about the result, if+/// anything, is returned.+pub(super) fn cut(st: &mut ModelState, on: ThreadOn, (tip, angle, depth): (ThreadTip, Option<f64>, Option<f64>)) -> Result<Option<String>> {+ let ThreadOn { info: t, cyl, ends, steep, ease, from: from_side, narrow, shoulder_unchecked } = on;let i = st.bodies.iter().position(|b| b.name == t.body).ok_or_else(|| DocError::Invalid("threaded body".into()))?;let Some(mb) = st.bodies.get(i).cloned() else { return Err(DocError::Invalid("body".into())) };let (mut input, radius) = (mb.traced(), cyl.radius);@@ -822,21 +887,46 @@ pub(super) fn cut(st: &mut ModelState, on: ThreadOn, (tip, angle, depth): (Threa}false => None,};- let mut grooves = Vec::new();- for g in thread_grooves(&t, groove_radius, (cyl.start, cyl.end), ends, steep, ease, taper)? {- let section = Region2 { outer: solidcore_record::Loop2::polygon(&g.section), holes: Vec::new() };- grooves.push(kernel::sweep_helix_radial(&g.plane, §ion, g.base, g.axis, g.pitch, g.turns, &g.law)?);- }- if let Some(taper) = taper- && let Some(envelope) = taper_envelope(&t, radius, ends, taper)?- {- grooves.push(envelope);- }- let tool = match grooves.as_slice() {- [one] => one.clone(),- many => kernel::union_all(&many.iter().collect::<Vec<_>>())?,+ let cut_grooves = |ends: [End; 2]| -> Result<(Option<Body>, usize)> {+ let mut grooves = Vec::new();+ for g in thread_grooves(&t, groove_radius, (cyl.start, cyl.end), ends, steep, ease, taper)? {+ let section = Region2 { outer: solidcore_record::Loop2::polygon(&g.section), holes: Vec::new() };+ grooves.push(kernel::sweep_helix_radial(&g.plane, §ion, g.base, g.axis, g.pitch, g.turns, &g.law)?);+ }+ if let Some(taper) = taper+ && let Some(envelope) = taper_envelope(&t, radius, ends, taper)?+ {+ grooves.push(envelope);+ }+ let tool = match grooves.as_slice() {+ [one] => one.clone(),+ many => kernel::union_all(&many.iter().collect::<Vec<_>>())?,+ };+ let tool = trim_at_shoulders(tool, t.axis_point, ends, (cyl.start, cyl.end), t.axis)?;+ let cut = kernel::boolean(&input.body, &tool, BoolOp::Cut)?;+ // Now rather than at the feature's end, where it could only fail the feature.+ if ends.contains(&End::Shoulder)+ && let Some(body) = &cut+ {+ kernel::check_kept(body)?;+ }+ Ok((cut, tool.face_count()))};- let (nb, groove_faces) = (kernel::boolean(&input.body, &tool, BoolOp::Cut)?, tool.face_count());+ // A design that built with the square stop keeps building: where the kernel can't make the+ // trimmed cut, the groove stops clear of the shoulder as it did, and the feature says so.+ let mut made = cut_grooves(ends);+ let mut square_stop = shoulder_unchecked;+ if matches!(made, Err(DocError::Kernel(_))) && ends.contains(&End::Shoulder) {+ made = cut_grooves(ends.map(|e| if e == End::Shoulder { End::Closed } else { e }));+ square_stop = true;+ }+ let note = (square_stop && made.is_ok()).then(|| {+ format!(+ "the {} thread's groove could not be run down to the shoulder here, so it stops clear of it and its last turn is left uncut",+ t.designation+ )+ });+ let (nb, groove_faces) = made?;let nb = nb.ok_or_else(|| DocError::Invalid("the thread removed everything".into()))?;// The groove's faces have no role to name them by.let groove = crate::lineage::Lineage::unnamed_faces(groove_faces);@@ -854,7 +944,7 @@ pub(super) fn cut(st: &mut ModelState, on: ThreadOn, (tip, angle, depth): (Threaif let Some(slot) = st.bodies.get_mut(i) {*slot = ModelBody::traced_new(mb.name, nb, mb.feature);}- Ok(())+ Ok(note)}/// The chamfered tip of an external thread (ISO 4753, chamfered end CH) at the free ends `tip`@@ -937,3 +1027,99 @@ fn tip_cones(}Ok(out)}++#[cfg(test)]+mod tests {+ use super::*;+ use std::cell::Cell;++ thread_local! {+ /// Make [`trim_at_shoulders`] find nothing of the groove left.+ pub(super) static EMPTY_TRIM: Cell<bool> = const { Cell::new(false) };+ /// Make the rising-shoulder check fail as the kernel would.+ pub(super) static FAIL_CLEARANCE: Cell<bool> = const { Cell::new(false) };+ }++ fn ask() -> ThreadAsk<'static> {+ ThreadAsk {+ form: None,+ designation: Some("M10"),+ hand: ThreadHand::Right,+ starts: 1,+ steep: SteepFlank::default(),+ extent: Extent::Full,+ from: None,+ modeled: true,+ ease_out: (0.0, 0.0),+ tapped: false,+ old_auto_size: false,+ }+ }++ /// How a thread's ends meet the face at (5, 0, z) of `body`.+ fn ends_of(body: Body, z: f64) -> [End; 2] {+ let mut st = ModelState::default();+ st.bodies.push(ModelBody::new("Part".into(), body, 1));+ thread_on(&st, 1, Vec3::new(5.0, 0.0, z), &ask()).unwrap().ends+ }++ /// A shoulder that stays beyond the face's end takes the trim. One rising back along the face+ /// (a slanted plate, a boss on a round body) keeps the square stop.+ #[test]+ fn only_a_shoulder_that_stays_beyond_the_faces_end_takes_the_trim() {+ let z = Vec3::new(0.0, 0.0, 1.0);+ let join = |a: &Body, b: &Body| kernel::boolean(a, b, BoolOp::Union).unwrap().unwrap();+ let boss = kernel::cylinder(Vec3::new(0.0, 0.0, 2.0), z, 5.0, 26.0).unwrap();+ let plate = kernel::box_solid(Vec3::new(-20.0, -20.0, -6.0), Vec3::new(20.0, 20.0, 2.0)).unwrap();+ let flat = ends_of(join(&plate, &boss), 20.0);+ assert!(flat.contains(&End::Shoulder), "{flat:?}");+ let tilted = kernel::cylinder(Vec3::new(0.0, 0.0, 0.0), Vec3::new(0.2, 0.0, 1.0), 20.0, 6.0).unwrap();+ let slanted = ends_of(join(&tilted, &boss), 20.0);+ assert!(slanted.contains(&End::Closed) && !slanted.contains(&End::Shoulder), "{slanted:?}");+ let round = kernel::cylinder(Vec3::new(0.0, -20.0, 0.0), Vec3::new(0.0, 1.0, 0.0), 10.0, 40.0).unwrap();+ let on_round = ends_of(join(&round, &boss), 20.0);+ assert!(on_round.contains(&End::Closed) && !on_round.contains(&End::Shoulder), "{on_round:?}");+ }++ /// Where the kernel can't check the shoulder, the thread still builds with the square stop, and+ /// the feature says its last turn is left uncut.+ #[test]+ fn a_shoulder_the_kernel_cannot_check_keeps_the_square_stop_and_says_so() {+ let plate = kernel::box_solid(Vec3::new(-20.0, -20.0, 0.0), Vec3::new(20.0, 20.0, 6.0)).unwrap();+ let boss = kernel::cylinder(Vec3::new(0.0, 0.0, 6.0), Vec3::new(0.0, 0.0, 1.0), 5.0, 16.0).unwrap();+ let body = kernel::boolean(&plate, &boss, BoolOp::Union).unwrap().unwrap();+ let mut st = ModelState::default();+ st.bodies.push(ModelBody::new("Part".into(), body, 1));+ FAIL_CLEARANCE.set(true);+ let on = thread_on(&st, 1, Vec3::new(5.0, 0.0, 14.0), &ask());+ FAIL_CLEARANCE.set(false);+ let on = on.unwrap();+ assert!(on.ends.contains(&End::Closed) && !on.ends.contains(&End::Shoulder), "{:?}", on.ends);+ let note = cut(&mut st, on, (ThreadTip::None, None, None)).unwrap();+ assert!(note.is_some_and(|n| n.contains("M10") && n.contains("left uncut")));+ }++ /// Where the trim leaves nothing of the groove, a thread at a shoulder that built with the+ /// square stop still builds with it, and the feature says its last turn is left uncut.+ #[test]+ fn a_shoulder_cut_the_kernel_refuses_falls_back_to_the_square_stop_and_says_so() {+ let plate = kernel::box_solid(Vec3::new(-20.0, -20.0, 0.0), Vec3::new(20.0, 20.0, 6.0)).unwrap();+ let boss = kernel::cylinder(Vec3::new(0.0, 0.0, 6.0), Vec3::new(0.0, 0.0, 1.0), 5.0, 16.0).unwrap();+ let body = kernel::boolean(&plate, &boss, BoolOp::Union).unwrap().unwrap();+ let build = |fail: bool| {+ let mut st = ModelState::default();+ st.bodies.push(ModelBody::new("Part".into(), body.clone(), 1));+ let on = thread_on(&st, 1, Vec3::new(5.0, 0.0, 14.0), &ask()).unwrap();+ EMPTY_TRIM.set(fail);+ let note = cut(&mut st, on, (ThreadTip::None, None, None));+ EMPTY_TRIM.set(false);+ (note.unwrap(), kernel::measure(&st.bodies[0].body).unwrap().volume)+ };+ let (none, trimmed) = build(false);+ assert_eq!(none, None);+ let (note, square) = build(true);+ assert!(note.is_some_and(|n| n.contains("M10") && n.contains("left uncut")));+ // The square stop leaves about half a pitch's worth of groove uncut: well over a mm³.+ assert!(square > trimmed + 1.0, "{square} vs {trimmed}");+ }+}diff --git a/crates/engine/src/thread_tests.rs b/crates/engine/src/thread_tests.rsindex 393d9d06b3..9975f7f7ed 100644--- a/crates/engine/src/thread_tests.rs+++ b/crates/engine/src/thread_tests.rs@@ -512,15 +512,127 @@ fn shaft_on_collar() -> Session {}/// Rig 602, ladder 06/004: a thread on a shaft ran a pitch past both ends of its face, into the-/// collar below as into the air above. At a shoulder it stops with its widest part clear of it:-/// the collar keeps its whole π 8² 10, and the groove takes (25 - w)/P turns, w its half width-/// (a square stop inside material takes exactly its length over P, the section being symmetric).+/// collar below as into the air above. It runs down to the shoulder and is trimmed at its plane+/// (#11610): the collar keeps its whole π 8² 10, and the groove takes 25/P turns, each slice of+/// the shaft along the axis losing the same.#[test]-fn a_thread_stops_clear_of_a_shoulder() {+fn a_thread_runs_down_to_a_shoulder_and_leaves_it_whole() {let mut s = shaft_on_collar();run(&mut s, "solid.thread", json!({"face": [5, 0, 25], "designation": "M10", "modeled": true}));+ let want = PI * 64.0 * 10.0 + PI * 25.0 * 25.0 - 25.0 / 1.5 * ext_turn(10.0, 1.5, 5.0);+ let got = exact_volume(&s, "Part");+ assert!((got - want).abs() < want * 2e-4, "{got} vs {want}");+}++/// The volume of a body's part between two heights along Z, within a quadrant of X and Y when+/// given (their signs).+fn volume_between(s: &Session, b: &str, (z0, z1): (f64, f64), quadrant: Option<(bool, bool)>) -> f64 {+ let st = s.model.state();+ let mut part = st.body(b).unwrap().body.clone();+ let on = |origin: Vec3, normal: Vec3| solidcore_record::Plane::from_normal(origin, normal.normalized().unwrap()).unwrap();+ let z = Vec3::new(0.0, 0.0, 1.0);+ let mut cuts = vec![(on(Vec3::new(0.0, 0.0, z0), z), true), (on(Vec3::new(0.0, 0.0, z1), z), false)];+ if let Some((x, y)) = quadrant {+ cuts.push((on(Vec3::ZERO, Vec3::new(1.0, 0.0, 0.0)), x));+ cuts.push((on(Vec3::ZERO, Vec3::new(0.0, 1.0, 0.0)), y));+ }+ for (plane, positive) in cuts {+ part = solidcraft_kernel::half_space(&part, &plane, positive).unwrap().0.unwrap();+ }+ solidcraft_kernel::measure(&part).unwrap().volume+}++/// #11610: a boss standing on a flat plate. The groove reaches the plate at every angle of the+/// last turn, wherever the helix lands on it (each height a different gap under a pitch): a thin+/// slice on the plate has lost as much as any slice of the thread, a pitch's slice as much in each+/// quadrant (the uncut block of the old stop sat in some of them), and the plate is whole. Before,+/// the last pitch kept up to a whole turn's groove uncut.+#[test]+fn a_thread_reaches_a_flat_shoulder_at_every_angle_and_leaves_it_whole() {+ let (p, t, turn) = (1.5, 6.0, ext_turn(10.0, 1.5, 5.0));+ let per_mm = PI * 25.0 - turn / p;+ for (h, extra) in [+ (16.0, json!({})),+ (16.45, json!({})),+ (16.6, json!({})),+ (16.9, json!({})),+ (17.4, json!({})),+ (16.0, json!({"hand": "left"})),+ (16.6, json!({"tip": "both"})),+ ] {+ let mut s = Session::default();+ run(&mut s, "solid.box", json!({"corner": [-20, -20, 0], "length": 40, "width": 40, "height": t, "body_name": "Part"}));+ run(&mut s, "solid.cylinder", json!({"base": [0, 0, t], "radius": 5, "height": h, "operation": "join", "targets": ["Part"]}));+ let mut ask = json!({"face": [5, 0, t + h / 2.0], "designation": "M10", "modeled": true});+ if let (Some(a), Value::Object(e)) = (ask.as_object_mut(), &extra) {+ a.extend(e.clone());+ }+ run(&mut s, "solid.thread", ask);+ let name = format!("h {h} {extra}");+ assert!(s.model.state().body("Part").unwrap().body.validity().is_empty(), "{name}");+ let plate = volume_between(&s, "Part", (-1.0, t), None);+ assert!((plate - 1600.0 * t).abs() < 1e-6 * 1600.0 * t, "{name}: the plate lost {} mm³", 1600.0 * t - plate);+ let thin = volume_between(&s, "Part", (t, t + 0.1 * p), None);+ let want = per_mm * 0.1 * p;+ assert!((thin - want).abs() < want * 2e-3, "{name}: the slice on the plate is {thin}, not {want}");+ for quadrant in [(true, true), (true, false), (false, true), (false, false)] {+ let got = volume_between(&s, "Part", (t, t + p), Some(quadrant));+ let want = per_mm * p / 4.0;+ assert!((got - want).abs() < want * 2e-3, "{name}: {quadrant:?} of the last pitch is {got}, not {want}");+ }+ }+}++/// #11610: where a shoulder is not flat. A fillet or a chamfer at the shaft's base stays whole, the+/// groove trimmed where the face ends above it. A shoulder that rises back along the face (a+/// slanted plate, a boss on a round body) would be cut by a groove running to the plane of the+/// face's lowest point, so the groove keeps its square stop there. Nothing here fails.+#[test]+fn a_thread_at_a_shoulder_that_is_not_flat_still_builds() {+ let (p, turn) = (1.5, ext_turn(10.0, 1.5, 5.0));+ let plate = |s: &mut Session| {+ run(s, "solid.box", json!({"corner": [-20, -20, 0], "length": 40, "width": 40, "height": 6, "body_name": "Part"}));+ run(s, "solid.cylinder", json!({"base": [0, 0, 6], "radius": 5, "height": 16, "operation": "join", "targets": ["Part"]}));+ };+ for finish in [("solid.fillet", json!({"edges": [[5, 0, 6]], "radius": 1})), ("solid.chamfer", json!({"edges": [[5, 0, 6]], "distance": 1}))] {+ let mut s = Session::default();+ plate(&mut s);+ run(&mut s, finish.0, finish.1);+ let (base, shaft) = (volume_between(&s, "Part", (-1.0, 7.0), None), exact_volume(&s, "Part"));+ run(&mut s, "solid.thread", json!({"face": [5, 0, 15], "designation": "M10", "modeled": true}));+ assert!(s.model.state().body("Part").unwrap().body.validity().is_empty(), "{}", finish.0);+ let left = volume_between(&s, "Part", (-1.0, 7.0), None);+ assert!((left - base).abs() < 1e-6 * base, "{}: the base lost {} mm³", finish.0, base - left);+ let (got, want) = (exact_volume(&s, "Part"), shaft - 15.0 / p * turn);+ assert!((got - want).abs() < want * 2e-4, "{}: {got} vs {want}", finish.0);+ }+ let rising = [+ vec![("solid.cylinder", json!({"base": [0, 0, 0], "axis": [0.2, 0, 1], "radius": 20, "height": 6, "body_name": "Part"}))],+ vec![("solid.cylinder", json!({"base": [0, -20, 0], "axis": [0, 1, 0], "radius": 10, "height": 40, "body_name": "Part"}))],+ ];+ for cmds in rising {+ let mut s = Session::default();+ for (c, ask) in cmds {+ run(&mut s, c, ask);+ }+ run(&mut s, "solid.cylinder", json!({"base": [0, 0, 2], "radius": 5, "height": 26, "operation": "join", "targets": ["Part"]}));+ let before = exact_volume(&s, "Part");+ run(&mut s, "solid.thread", json!({"face": [5, 0, 20], "designation": "M10", "modeled": true}));+ assert!(s.model.state().body("Part").unwrap().body.validity().is_empty());+ assert!(exact_volume(&s, "Part") < before);+ }+}++/// #11610: the trim is for a thread that runs the whole face. A length stopping short of the+/// shoulder still stops there, however near.+#[test]+fn a_thread_of_some_length_stops_where_it_is_told_short_of_a_shoulder() {let (p, w) = (1.5, ext_half_width(10.0, 1.5));- let want = PI * 64.0 * 10.0 + PI * 25.0 * 25.0 - (25.0 - w) / p * ext_turn(10.0, p, 5.0);+ let mut s = shaft_on_collar();+ let before = exact_volume(&s, "Part");+ run(&mut s, "solid.thread", json!({"face": [5, 0, 25], "designation": "M10", "length": 24.6, "modeled": true}));+ // Its end is within half a pitch of the shoulder: the stop stays clear of it.+ let want = before - (24.6f64).min(25.0 - w) / p * ext_turn(10.0, p, 5.0);let got = exact_volume(&s, "Part");assert!((got - want).abs() < want * 2e-4, "{got} vs {want}");}@@ -528,7 +640,7 @@ fn a_thread_stops_clear_of_a_shoulder() {/// A d10 boss (z t..t+16) on a plate t thick, threaded M10: the plate's top is the shoulder./// The groove, with or without its runout, stays on the boss: the plate keeps all of itself/// (what lies below z = t after the boss is cut away), and without a runout the boss loses-/// (16 - w)/P turns, as at a collar. The owner's bug: built as the app builds it (a rounded+/// 16/P turns, as at a collar. The owner's bug: built as the app builds it (a rounded/// plate, a circle sketched on its top face and extruded with Join), a plate thinner than 1.5 P/// had no material where the free-end test looked (1 to 1.5 pitches past the face), so its top/// was taken for a free end and the overrun cut a pitch into it.@@ -562,10 +674,10 @@ fn a_thread_on_a_boss_never_cuts_into_the_plate_below() {exact_volume(&s, "Body1")};let plate = |t: f64| (40.0 * 40.0 - (4.0 - PI) * 25.0) * t;- let (p, w) = (1.5, ext_half_width(10.0, 1.5));+ let p = 1.5;for t in [6.0, 1.0] {let s = boss(t, json!({}));- let want = plate(t) + PI * 25.0 * 16.0 - (16.0 - w) / p * ext_turn(10.0, p, 5.0);+ let want = plate(t) + PI * 25.0 * 16.0 - 16.0 / p * ext_turn(10.0, p, 5.0);let got = exact_volume(&s, "Body1");assert!((got - want).abs() < want * 2e-4, "plate {t}: {got} vs {want}");let left = plate_left(s, t);@@ -915,10 +1027,9 @@ fn a_chamfered_tip_tapers_the_last_teeth() {"solid.thread",json!({"face": [5, 0, 25], "designation": "M10", "tip": "both", "chamfer_angle": "30 deg", "chamfer_depth": 0.5, "modeled": true}),);- let w = ext_half_width(10.0, 1.5);let rf = 4.5;let slope = 30f64.to_radians().tan();- let want = PI * 64.0 * 10.0 + PI * 25.0 * w + m10_stock(10.0 + w, 35.0, |z| 5f64.min(rf + (35.0 - z) * slope));+ let want = PI * 64.0 * 10.0 + m10_stock(10.0, 35.0, |z| 5f64.min(rf + (35.0 - z) * slope));let got = exact_volume(&s, "Part");assert!((got - want).abs() < want * 1e-4, "{got} vs {want}");// Internal threads take a countersink instead.@@ -1004,7 +1115,8 @@ fn a_runout_fades_the_groove_out_before_the_shoulder() {let (p, w) = (1.5, ext_half_width(10.0, 1.5));let root = 5.0 - 5.0 * p * 3f64.sqrt() / 16.0;let h = 5.0 - root + 0.05 * p;- let turns = (35.0 - 10.0 - 2.0 * w) / p;+ // Trimmed at the bottom collar's plane, stopped clear of the top one for its runout.+ let turns = (35.0 - 10.0 - w) / p;for (ease, r_out) in [(json!("short"), 1.25), (json!("standard"), 2.5), (json!("1 mm"), 1.0 / 1.5)] {let mut s = shaft_on_collar();run(&mut s, "solid.cylinder", json!({"base": [0, 0, 35], "radius": 8, "height": 10, "operation": "join", "targets": ["Part"]}));diff --git a/docs/kernel-ladder.md b/docs/kernel-ladder.mdindex ea4ef85467..598488249e 100644--- a/docs/kernel-ladder.md+++ b/docs/kernel-ladder.md@@ -108,9 +108,6 @@ Times are the commands' own, in seconds, from the case's process; **golden** is| ladder/06-threads/020-external-g-1-2 | a modelled G 1/2 parallel pipe thread (ISO 228-1, 55 deg) on a d20.955 shaft, six turns | analytic | pass | 0.999 | 0.999 | || ladder/06-threads/015-internal-tr20x4-nut | a modelled internal Tr20x4 thread in a d16 (D1 = d - P) bore through a 40x40x24 block | analytic | pass | 1.074 | 1.074 | || ladder/06-threads/014-external-buttress-asme-1.5-8 | a modelled 1.5-8 buttress thread (ASME B1.9 basic profile, 7/45 deg) on a 1.5 in shaft, six turns | analytic | pass | 1.098 | 1.098 | |-| ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder | a modelled S20x4 buttress thread on a d20 shaft down to a d30 shoulder, the steep flank toward the thread's start (down): the 30 deg wall faces the shoulder | analytic | pass | 1.147 | 1.147 | |-| ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder | a modelled S20x4 buttress thread on a d20 shaft down to a d30 shoulder, the steep flank toward the thread's end (up, the default): the 3 deg wall faces the shoulder | analytic | pass | 1.182 | 1.182 | |-| ladder/06-threads/010-part-threaded-boss | the running part with a modelled M16 thread on its d16 boss | analytic | pass | 1.239 | 1.239 | || ladder/06-threads/003-external-m10-partial-length | a modelled M10 thread over 15 of the 30 mm from the top end (`from`): it stops square in the middle of the face | analytic | pass | 1.339 | 1.339 | || ladder/06-threads/028-external-tr20x4-chamfer-30-deg-2.5-deep | 011's modelled Tr20x4 thread with chamfered ends at its own angle and depth: 30 deg to the axis, 2.5 mm in from the major diameter | analytic | pass | 1.351 | 1.351 | || ladder/06-threads/024-internal-rc-1-2-taper | a modelled Rc 1/2 internal taper pipe thread (ISO 7-1) in a d17.6 hole (the tap maker's) through a 13.2 mm plate, from its top face | analytic | pass | 1.554 | 1.554 | |@@ -119,15 +116,18 @@ Times are the commands' own, in seconds, from the case's process; **golden** is| ladder/06-threads/005-internal-m10-through | a modelled internal M10 thread in a d8.5 (tap drill) hole through a 30x30x20 block | analytic | pass | 1.791 | 1.791 | || ladder/06-threads/023-external-1-2-npt | a modelled 1/2-14 NPT taper pipe thread (ASME B1.20.1, 60 deg, 1 in 16) on its 0.840 in pipe, its effective thread L2 from the end | analytic | pass | 1.850 | 1.850 | || ladder/06-threads/009-thread-runout-length | 004's M10 thread run from the free top end, vanishing over a 3 mm (2 P) runout before the d16 shoulder | analytic | pass | 2.142 | 2.142 | |-| ladder/06-threads/004-external-m10-to-shoulder | a modelled M10 thread on a d10 shaft running down to a d16 shoulder: it stops clear of it, the collar whole | analytic | pass | 2.202 | 2.202 | |-| ladder/06-threads/007-external-m10-at-filleted-shoulder | a modelled M10 thread on a d10 shaft whose root at the d16 shoulder has an r1 fillet: it stops clear of the fillet | analytic | pass | 2.250 | 2.250 | || ladder/06-threads/016-external-m10-left-hand | 001's modelled M10 thread, left-handed: the same volume, turning the other way | analytic | pass | 2.587 | 2.587 | || ladder/06-threads/001-external-m10-full | a modelled M10 thread over the whole of a d10 x 30 cylinder | analytic | pass | 2.722 | 2.722 | || ladder/06-threads/006-external-m10-into-chamfer | a d10 x 30 cylinder with a 1 mm chamfer on top, then a modelled M10 thread over its cylinder face, running out through the chamfer | analytic | pass | 2.753 | 2.753 | |+| ladder/06-threads/010-part-threaded-boss | the running part with a modelled M16 thread on its d16 boss | analytic | pass | 2.787 | 2.787 | || ladder/06-threads/027-external-m10-chamfered-start | 001's modelled M10 thread with ISO 4753's chamfered end at the end it starts from only (`tip: start`, from the top) | analytic | pass | 3.107 | 3.107 | |+| ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder | a modelled S20x4 buttress thread on a d20 shaft down to a d30 shoulder, the steep flank toward the thread's end (up, the default): the 3 deg wall faces the shoulder | analytic | pass | 3.114 | 3.114 | || ladder/06-threads/017-external-m10-chamfered-tip | 001's modelled M10 thread with ISO 4753's chamfered end at both free ends: a 45 deg cone down to the external minor diameter d3, cut after the groove | analytic | pass | 3.390 | 3.390 | |+| ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder | a modelled S20x4 buttress thread on a d20 shaft down to a d30 shoulder, the steep flank toward the thread's start (down): the 30 deg wall faces the shoulder | analytic | pass | 3.470 | 3.470 | || ladder/06-threads/002-external-m10x1-fine | a modelled fine M10x1 thread over a d10 x 30 cylinder | analytic | pass | 4.222 | 4.222 | || ladder/06-threads/008-multi-start-thread | a two-start M10 thread (lead 3, pitch 1.5) over a d10 x 30 cylinder | analytic | pass | 4.423 | 4.423 | |+| ladder/06-threads/007-external-m10-at-filleted-shoulder | a modelled M10 thread on a d10 shaft whose root at the d16 shoulder has an r1 fillet: it reaches the fillet at every angle, the fillet whole | analytic | pass | 5.496 | 5.496 | |+| ladder/06-threads/004-external-m10-to-shoulder | a modelled M10 thread on a d10 shaft running down to a d16 shoulder: it reaches the shoulder at every angle, the collar whole | analytic | pass | 5.740 | 5.740 | || ladder/06-threads/018-external-m10-both-hands | 001's modelled M10 thread cut both ways: a right- and a left-handed groove crossing on a d10 x 30 cylinder | analytic | pass | 15.346 | 15.346 | || ladder/07-fillets/008-constant-r1e-3 | a constant 1e-3 mm round on the top front edge | analytic | pass | 0.018 | 0.018 | || ladder/07-fillets/007-variable-r5-to-1e-3 | a variable round on the top front edge, r5 down to 1e-3 mm | analytic | pass | 0.022 | 0.022 | |@@ -183,8 +183,8 @@ Times are the commands' own, in seconds, from the case's process; **golden** is| ladder/10-patterns-and-mirrors/008-part-vents | the running part with a d3 vent hole in its top patterned 4 times at 5 mm | analytic | pass | 3.010 | 3.010 | || ladder/11-cumulative-parts/001-bracket | an L bracket: concave r5 round, 5 mm outer chamfer, a hole in each leg | analytic | pass | 0.143 | 0.143 | || ladder/11-cumulative-parts/002-flange | a revolved flange and hub with a bore, six bolt holes, a hub chamfer and a hub-root round | analytic | pass | 1.040 | 1.040 | |-| ladder/11-cumulative-parts/003-threaded-flange | the flange with a modelled M30 thread on its hub, between the round and the chamfer, and M8 tapped holes in the disk | analytic | pass | 3.758 | 3.758 | || ladder/11-cumulative-parts/004-housing | the running part with every tier: back wall, boss, slot, spline window, tapped holes, rounds, chamfers, shell, vents, and a modelled M16 thread on the boss | analytic | pass | 4.129 | 4.129 | |+| ladder/11-cumulative-parts/003-threaded-flange | the flange with a modelled M30 thread on its hub, between the round and the chamfer, and M8 tapped holes in the disk | analytic | pass | 7.150 | 7.150 | || ladder/12-sheet-metal/001-base-flange | a 100 x 60 base flange, 2 mm sheet | analytic | pass | 0.003 | 0.003 | || ladder/12-sheet-metal/002-edge-flange-90 | a 20 mm 90 deg edge flange along the base's front edge | analytic | pass | 0.006 | 0.006 | || ladder/12-sheet-metal/010-fold-90 | 001's base folded 90 deg up along a sketch line across it at x = 70 | analytic | pass | 0.006 | 0.006 | |diff --git a/docs/threads.md b/docs/threads.mdindex f37f37aeb2..25e29ae3a1 100644--- a/docs/threads.md+++ b/docs/threads.md@@ -85,8 +85,16 @@ the groove runs out through, a counterbore wider than the thread are free; a showhose corners reach past the root, a blind hole's bottom are not.- At a free end the groove runs out a pitch past the end, into the air.-- At a closed end it stops with its section clear of the end: its centre as far inside as the- section reaches that way, so it never cuts into the shoulder.+- At a shoulder that starts at the end of an external thread's face and stays beyond the plane of+ that end, a thread running the whole face goes on through the plane and is trimmed there: the+ root reaches the shoulder at every angle of the last turn, so a nut bottoms out on it, and+ nothing past the plane is cut. A fillet or chamfer at the base stays whole: the groove ends where+ the cylinder does. With no runout, each slice along the axis loses the same, so the groove takes+ exactly length / P turns.+- At any other closed end (a shoulder rising back along the face, a blind hole's bottom, a+ taper's far end, a length stopping within half a pitch of the end) it stops with its section+ clear of the end: its centre as far inside as the section reaches that way, so it stays out of+ the shoulder at that end.- Inside the face it stops square. For a symmetric section a square stop inside material removesexactly length / P turns (what the last section leaves uncut ahead of the stop, it cuts behindit in mirror image).diff --git a/tests/kernel-cases/ladder/06-threads/004-external-m10-to-shoulder/expected.json b/tests/kernel-cases/ladder/06-threads/004-external-m10-to-shoulder/expected.jsonindex 3603aa0920..d0bb981dad 100644--- a/tests/kernel-cases/ladder/06-threads/004-external-m10-to-shoulder/expected.json+++ b/tests/kernel-cases/ladder/06-threads/004-external-m10-to-shoulder/expected.json@@ -1,14 +1,14 @@{"sources": [],- "what": "a modelled M10 thread on a d10 shaft running down to a d16 shoulder: it stops clear of it, the collar whole",+ "what": "a modelled M10 thread on a d10 shaft running down to a d16 shoulder: it reaches the shoulder at every angle, the collar whole","source": "analytic",- "method": "the shaft's lower end is a shoulder (the d16 collar lies past it, in the groove's way), so the groove stops there with its widest part clear of it: its centre w = (P/4 + 2 (d/2 + 0.05P - r_root) tan30)/2 = 0.699551 mm above the shoulder (its half width at the tool's outer edge, 0.05 P past the crest), and the square stop inside material removes exactly as if the groove ended at its centre (see 003); the top end is free, the groove runs out into the air. V = pi 8^2 10 (the collar) + pi 5^2 w + 2 pi int_{10+w}^35 int r m(r) dr dz (m as in 001); the centre of mass from the three parts' moments (the threaded part's at its middle, the screw averaging every meridian alike; its stop moves it under 0.002 mm). Tolerance 0.05%: the groove is SMLib's exact screw sweep; a groove running a pitch into the collar (the old free-end overrun) removes 0.9% more",+ "method": "the shaft's lower end is a shoulder (the d16 collar lies past it, in the groove's way), so the groove runs on past its plane and is trimmed there; the top end is free, the groove runs out into the air. Every slice of the shaft along the axis then loses the same, whatever its height: V = pi 8^2 10 (the collar) + pi 5^2 25 - (25/P) V_turn, V_turn = 2 pi int r m(r) dr one turn of the groove within the shaft (m as in 001); the centre of mass from the two parts' moments (the threaded part's at its middle, the screw averaging every meridian alike). Tolerance 0.05%: the groove is SMLib's exact screw sweep; a groove running a pitch into the collar (the old free-end overrun) removes 0.9% more, and one stopping clear of the shoulder leaves its last turn uncut, 0.26% more material","body_count": 1,- "volume_mm3": 3648.530350498,+ "volume_mm3": 3639.157562673,"center_of_mass": [0,0,- 12.824948457564597+ 12.831323],"bbox": {"min": [diff --git a/tests/kernel-cases/ladder/06-threads/007-external-m10-at-filleted-shoulder/expected.json b/tests/kernel-cases/ladder/06-threads/007-external-m10-at-filleted-shoulder/expected.jsonindex 64b7ab947d..bdc7eded16 100644--- a/tests/kernel-cases/ladder/06-threads/007-external-m10-at-filleted-shoulder/expected.json+++ b/tests/kernel-cases/ladder/06-threads/007-external-m10-at-filleted-shoulder/expected.json@@ -1,14 +1,14 @@{"sources": [],- "what": "a modelled M10 thread on a d10 shaft whose root at the d16 shoulder has an r1 fillet: it stops clear of the fillet",+ "what": "a modelled M10 thread on a d10 shaft whose root at the d16 shoulder has an r1 fillet: it reaches the fillet at every angle, the fillet whole","source": "analytic",- "method": "the fillet's ring: the corner square [5,6]x[10,11] less the quarter disc about (6,11), V_f = 2 pi (5.5 - pi/4 (6 - 4/(3 pi))), its centroid z from the same moments; the cylinder face starts at z=11, where the fillet meets it. the shaft's lower end (z=11) is a shoulder (the fillet and the collar lies past it, in the groove's way), so the groove stops there with its widest part clear of it: its centre w = (P/4 + 2 (d/2 + 0.05P - r_root) tan30)/2 = 0.699551 mm above the shoulder (its half width at the tool's outer edge, 0.05 P past the crest), and the square stop inside material removes exactly as if the groove ended at its centre (see 003); the top end is free, the groove runs out into the air. V = pi 8^2 10 + V_f + pi 5^2 (1 + w) + 2 pi int_{11+w}^35 int r m(r) dr dz. Tolerance 0.05%: SMLib's exact screw sweep",+ "method": "the fillet's ring: the corner square [5,6]x[10,11] less the quarter disc about (6,11), V_f = 2 pi (5.5 - pi/4 (6 - 4/(3 pi))), its centroid z from the same moments; the cylinder face starts at z=11, where the fillet meets it. the shaft's lower end (z=11) is a shoulder (the fillet and the collar lies past it, in the groove's way), so the groove runs on past its plane and is trimmed there, and every slice of the shaft above it loses the same; the top end is free, the groove runs out into the air. V = pi 8^2 10 + V_f + pi 5^2 1 + 24 (pi 5^2 - V_turn/P), V_turn one turn of the groove within the shaft (m as in 001). Tolerance 0.05%: SMLib's exact screw sweep","body_count": 1,- "volume_mm3": 3668.971737351,+ "volume_mm3": 3659.598949526,"center_of_mass": [0,0,- 12.813982957360412+ 12.817761],"bbox": {"min": [diff --git a/tests/kernel-cases/ladder/06-threads/010-part-threaded-boss/expected.json b/tests/kernel-cases/ladder/06-threads/010-part-threaded-boss/expected.jsonindex 287cb64f05..4aceac9ec6 100644--- a/tests/kernel-cases/ladder/06-threads/010-part-threaded-boss/expected.json+++ b/tests/kernel-cases/ladder/06-threads/010-part-threaded-boss/expected.json@@ -2,9 +2,9 @@"sources": [],"what": "the running part with a modelled M16 thread on its d16 boss","source": "analytic",- "method": "the boss (r8, z 20..30) stands on the base's top face, a shoulder: the groove stops with its centre w = 0.932735 above it (004's rule, M16 P = 2) and runs out past the free top end; its root r = 8 - 5H/8 = 6.917 stays clear of the M5 tap drill (r 2.1) in the boss. V = the tier-05 part - (pi 8^2 (30 - 20 - w) - 2 pi int_{20+w}^30 int r m(r) dr dz), m as in 001; the bbox is the part's. Later tiers build on the part before this step and 11-cumulative-parts adds the thread last",+ "method": "the boss (r8, z 20..30) stands on the base's top face, a shoulder: the groove runs on past its plane and is trimmed there (004's rule, M16 P = 2) and runs out past the free top end; its root r = 8 - 5H/8 = 6.917 stays clear of the M5 tap drill (r 2.1) in the boss. V = the tier-05 part - (10/P) V_turn, V_turn one turn of the groove within the boss (m as in 001); the bbox is the part's. Later tiers build on the part before this step and 11-cumulative-parts adds the thread last","body_count": 1,- "volume_mm3": 53208.190964337,+ "volume_mm3": 53181.215815383,"bbox": {"min": [0,diff --git a/tests/kernel-cases/ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder/expected.json b/tests/kernel-cases/ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder/expected.jsonindex aedbb7a806..f4f76dfff4 100644--- a/tests/kernel-cases/ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder/expected.json+++ b/tests/kernel-cases/ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder/expected.json@@ -2,9 +2,9 @@"sources": [],"what": "a modelled S20x4 buttress thread on a d20 shaft down to a d30 shoulder, the steep flank toward the thread's end (up, the default): the 3 deg wall faces the shoulder","source": "analytic",- "method": "DIN 513-1 S20x4: 3 deg load flank, 30 deg clearance flank, flats (P - 0.75 P (tan3 + tan30))/2 = 0.26384 P, external minor d3 = d - 2 x 0.86777 P = 13.058. steep_flank end puts the 3 deg wall on the groove's side toward the shoulder (z = 10); the groove stops with its section clear of the shoulder, its centre 0.571741 above it (the section's extent that way at r = 10.2, 0.05 P past the crest, the tool's outer edge), and runs out a pitch past the free top end. V = pi 15^2 10 + pi 10^2 30 - the groove 2 pi int_0^T (int int r dA of the section within the shaft) dt (2507.160140; a straight screw sweep, Pappus turn by turn, with the free end's partial turn integrated). 025 and 026 differ by where the groove stops",+ "method": "DIN 513-1 S20x4: 3 deg load flank, 30 deg clearance flank, flats (P - 0.75 P (tan3 + tan30))/2 = 0.26384 P, external minor d3 = d - 2 x 0.86777 P = 13.058. steep_flank end puts the 3 deg wall on the groove's side toward the shoulder (z = 10); the groove runs on past the shoulder's plane and is trimmed there, and runs out a pitch past the free top end, so every slice of the shaft along the axis loses the same. V = pi 15^2 10 + pi 10^2 30 - (30/P) V_turn, V_turn = 2 pi int_(d3/2)^(d/2) r w(r) dr = 347.540474, w(r) = P - 0.26384 P - (d/2 - r)(tan3 + tan30) the groove's width. 025 and 026 are the same volume, the flanks swapped","body_count": 1,- "volume_mm3": 13986.201291602,+ "volume_mm3": 13886.807873931,"bbox": {"min": [-15,diff --git a/tests/kernel-cases/ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder/expected.json b/tests/kernel-cases/ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder/expected.jsonindex 3f73e3ee1f..ea9beb3c15 100644--- a/tests/kernel-cases/ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder/expected.json+++ b/tests/kernel-cases/ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder/expected.json@@ -2,9 +2,9 @@"sources": [],"what": "a modelled S20x4 buttress thread on a d20 shaft down to a d30 shoulder, the steep flank toward the thread's start (down): the 30 deg wall faces the shoulder","source": "analytic",- "method": "DIN 513-1 S20x4: 3 deg load flank, 30 deg clearance flank, flats (P - 0.75 P (tan3 + tan30))/2 = 0.26384 P, external minor d3 = d - 2 x 0.86777 P = 13.058. steep_flank start puts the 30 deg wall on the groove's side toward the shoulder (z = 10); the groove stops with its section clear of the shoulder, its centre 2.498847 above it (the section's extent that way at r = 10.2, 0.05 P past the crest, the tool's outer edge), and runs out a pitch past the free top end. V = pi 15^2 10 + pi 10^2 30 - the groove 2 pi int_0^T (int int r dA of the section within the shaft) dt (2439.158513; a straight screw sweep, Pappus turn by turn, with the free end's partial turn integrated). 025 and 026 differ by where the groove stops",+ "method": "DIN 513-1 S20x4: 3 deg load flank, 30 deg clearance flank, flats (P - 0.75 P (tan3 + tan30))/2 = 0.26384 P, external minor d3 = d - 2 x 0.86777 P = 13.058. steep_flank start puts the 30 deg wall on the groove's side toward the shoulder (z = 10); the groove runs on past the shoulder's plane and is trimmed there, and runs out a pitch past the free top end, so every slice of the shaft along the axis loses the same. V = pi 15^2 10 + pi 10^2 30 - (30/P) V_turn, V_turn = 2 pi int_(d3/2)^(d/2) r w(r) dr = 347.540474, w(r) = P - 0.26384 P - (d/2 - r)(tan3 + tan30) the groove's width. 025 and 026 are the same volume, the flanks swapped","body_count": 1,- "volume_mm3": 14054.202918026,+ "volume_mm3": 13886.807873931,"bbox": {"min": [-15,diff --git a/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.json b/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.jsonindex c41d8e04a9..b0ae3c5ebb 100644--- a/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.json+++ b/tests/kernel-cases/ladder/11-cumulative-parts/003-threaded-flange/expected.json@@ -2,9 +2,9 @@"sources": [],"what": "the flange with a modelled M30 thread on its hub, between the round and the chamfer, and M8 tapped holes in the disk","source": "analytic",- "method": "the hub's cylinder (r15) runs from the r3 round at its root (z 13) to the 1.5 chamfer at its top (z 28.5): the M30 groove (P 3.5) stops w = 1.632286 clear of the round, a shoulder (06/007's rule), and runs out through the chamfer, a free end (06/006's): it removes the stock less 2 pi int int r m(r) dr dz over z 13 + w..28.5 at r 15 and the chamfer (r 15 - (z - 28.5)); the bore r8 is inside the root r 13.1. The M8 tap drills (6.8, the tap maker's) go through the 10 mm disk at r 28, 90 deg + k 120, clear of the bolt holes (30 deg apart): 3 pi 3.4^2 10. Bbox: the flange's",+ "method": "the hub's cylinder (r15) runs from the r3 round at its root (z 13) to the 1.5 chamfer at its top (z 28.5): the M30 groove (P 3.5) runs on past the plane where the round starts and is trimmed there, the round whole (06/007's rule), and runs out through the chamfer, a free end (06/006's): it removes the stock less 2 pi int int r m(r) dr dz over z 13..28.5 at r 15 and the chamfer (r 15 - (z - 28.5)); the bore r8 is inside the root r 13.1. The M8 tap drills (6.8, the tap maker's) go through the 10 mm disk at r 28, 90 deg + k 120, clear of the bolt holes (30 deg apart): 3 pi 3.4^2 10. Bbox: the flange's","body_count": 1,- "volume_mm3": 52962.097548983,+ "volume_mm3": 52806.59870975,"bbox": {"min": [-40,diff --git a/tests/kernel-cases/ladder/golden.json b/tests/kernel-cases/ladder/golden.jsonindex 1767529f3e..e1b3c034dd 100644--- a/tests/kernel-cases/ladder/golden.json+++ b/tests/kernel-cases/ladder/golden.json@@ -878,14 +878,14 @@},"ladder/06-threads/004-external-m10-to-shoulder": {"measured": {- "area_mm2": 2047.0229463264673,+ "area_mm2": 2070.374916609214,"body_count": 1,- "edges": 213,- "faces": 74,- "vertices": 142,- "volume_mm3": 3648.5299214318684+ "edges": 219,+ "faces": 76,+ "vertices": 146,+ "volume_mm3": 3639.157043325919},- "seconds": 2.202216156,+ "seconds": 5.739657892,"status": "pass"},"ladder/06-threads/005-internal-m10-through": {@@ -914,14 +914,14 @@},"ladder/06-threads/007-external-m10-at-filleted-shoulder": {"measured": {- "area_mm2": 2018.7759940693177,+ "area_mm2": 2042.128006779366,"body_count": 1,- "edges": 203,- "faces": 71,- "vertices": 135,- "volume_mm3": 3668.971297386959+ "edges": 214,+ "faces": 75,+ "vertices": 142,+ "volume_mm3": 3659.598361255103},- "seconds": 2.249734845,+ "seconds": 5.496053349,"status": "pass"},"ladder/06-threads/008-multi-start-thread": {@@ -950,14 +950,14 @@},"ladder/06-threads/010-part-threaded-boss": {"measured": {- "area_mm2": 13318.766397751697,+ "area_mm2": 13370.25800424205,"body_count": 1,- "edges": 111,- "faces": 41,- "vertices": 74,- "volume_mm3": 53208.190621080044+ "edges": 120,+ "faces": 44,+ "vertices": 80,+ "volume_mm3": 53181.215541289486},- "seconds": 1.239079404,+ "seconds": 2.7871945240000002,"status": "pass"},"ladder/06-threads/011-external-tr20x4": {@@ -1130,26 +1130,26 @@},"ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder": {"measured": {- "area_mm2": 5883.043222895581,+ "area_mm2": 6009.162011983694,"body_count": 1,- "edges": 102,- "faces": 37,- "vertices": 68,- "volume_mm3": 13986.200396963923+ "edges": 108,+ "faces": 39,+ "vertices": 72,+ "volume_mm3": 13886.806724574824},- "seconds": 1.1821016069999999,+ "seconds": 3.113976484,"status": "pass"},"ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder": {"measured": {- "area_mm2": 5793.407884066657,+ "area_mm2": 6009.162011488332,"body_count": 1,- "edges": 99,- "faces": 36,- "vertices": 66,- "volume_mm3": 14054.201923138782+ "edges": 108,+ "faces": 39,+ "vertices": 72,+ "volume_mm3": 13886.806673641227},- "seconds": 1.147335109,+ "seconds": 3.47044052,"status": "pass"},"ladder/06-threads/027-external-m10-chamfered-start": {@@ -1810,14 +1810,14 @@},"ladder/11-cumulative-parts/003-threaded-flange": {"measured": {- "area_mm2": 17357.359407146,+ "area_mm2": 17528.149663462264,"body_count": 1,- "edges": 104,- "faces": 38,- "vertices": 69,- "volume_mm3": 52962.097419669546+ "edges": 112,+ "faces": 41,+ "vertices": 74,+ "volume_mm3": 52806.59825789034},- "seconds": 3.757525087,+ "seconds": 7.150208538,"status": "pass"},"ladder/11-cumulative-parts/004-housing": {@@ -2001,5 +2001,5 @@"status": "pass"}},- "reason": "04-spline-profiles/009 and 012 re-recorded, an extruded spline or ellipse sweeps one wall (one-curve extrude): 009 makes 3 faces, 3 edges and 2 vertices (8, 18 and 12 per span before); 012 makes 28 faces, 78 edges and 52 vertices (31, 86 and 57 before); every other case as before. Before: recorded at solidcore 8ddce9016: 06-threads/018 makes 606 edges and 404 vertices (486 and 324 at 97ed188db), its 204 faces, area and volume the same to 1e-11; every other case as before. Before: recorded on solidcore, the only kernel since the C++ SMLib kernel was removed (the golden before was C++ SMLib v1.1.0-alpha, a18bbe5): 07-fillets/012 passes (the variable round no longer gains the End at the smooth vertex: 8 faces, 18 edges, 12 vertices, 47755.12 mm3); 07-fillets/021 has 24 edges and 15 vertices (no End cap edge); 07-fillets/013 removes 47325.53 mm3; 06-threads/018 makes 486 edges and 324 vertices every run, so it is no longer marked unstable"+ "reason": "a modelled external thread running a whole face to a shoulder now runs on through the plane of the face end and is trimmed there (#11610): 06-threads/004, 007, 010, 025, 026 and 11-cumulative-parts/003 gain the faces of the trimmed last turn, their volumes worked out again by hand; every other case as before. Before: 04-spline-profiles/009 and 012 re-recorded, an extruded spline or ellipse sweeps one wall (one-curve extrude): 009 makes 3 faces, 3 edges and 2 vertices (8, 18 and 12 per span before); 012 makes 28 faces, 78 edges and 52 vertices (31, 86 and 57 before); every other case as before. Before: recorded at solidcore 8ddce9016: 06-threads/018 makes 606 edges and 404 vertices (486 and 324 at 97ed188db), its 204 faces, area and volume the same to 1e-11; every other case as before. Before: recorded on solidcore, the only kernel since the C++ SMLib kernel was removed (the golden before was C++ SMLib v1.1.0-alpha, a18bbe5): 07-fillets/012 passes (the variable round no longer gains the End at the smooth vertex: 8 faces, 18 edges, 12 vertices, 47755.12 mm3); 07-fillets/021 has 24 edges and 15 vertices (no End cap edge); 07-fillets/013 removes 47325.53 mm3; 06-threads/018 makes 486 edges and 324 vertices every run, so it is no longer marked unstable"}diff --git a/tests/kernel-cases/ladder/ladder.json b/tests/kernel-cases/ladder/ladder.jsonindex ad863ba923..637f19051e 100644--- a/tests/kernel-cases/ladder/ladder.json+++ b/tests/kernel-cases/ladder/ladder.json@@ -111,9 +111,6 @@"ladder/06-threads/020-external-g-1-2","ladder/06-threads/015-internal-tr20x4-nut","ladder/06-threads/014-external-buttress-asme-1.5-8",- "ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder",- "ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder",- "ladder/06-threads/010-part-threaded-boss","ladder/06-threads/003-external-m10-partial-length","ladder/06-threads/028-external-tr20x4-chamfer-30-deg-2.5-deep","ladder/06-threads/024-internal-rc-1-2-taper",@@ -122,15 +119,18 @@"ladder/06-threads/005-internal-m10-through","ladder/06-threads/023-external-1-2-npt","ladder/06-threads/009-thread-runout-length",- "ladder/06-threads/004-external-m10-to-shoulder",- "ladder/06-threads/007-external-m10-at-filleted-shoulder","ladder/06-threads/016-external-m10-left-hand","ladder/06-threads/001-external-m10-full","ladder/06-threads/006-external-m10-into-chamfer",+ "ladder/06-threads/010-part-threaded-boss","ladder/06-threads/027-external-m10-chamfered-start",+ "ladder/06-threads/025-external-s20x4-steep-flank-end-to-shoulder","ladder/06-threads/017-external-m10-chamfered-tip",+ "ladder/06-threads/026-external-s20x4-steep-flank-start-to-shoulder","ladder/06-threads/002-external-m10x1-fine","ladder/06-threads/008-multi-start-thread",+ "ladder/06-threads/007-external-m10-at-filleted-shoulder",+ "ladder/06-threads/004-external-m10-to-shoulder","ladder/06-threads/018-external-m10-both-hands"],"tier": "06-threads",@@ -216,8 +216,8 @@"cases": ["ladder/11-cumulative-parts/001-bracket","ladder/11-cumulative-parts/002-flange",- "ladder/11-cumulative-parts/003-threaded-flange",- "ladder/11-cumulative-parts/004-housing"+ "ladder/11-cumulative-parts/004-housing",+ "ladder/11-cumulative-parts/003-threaded-flange"],"tier": "11-cumulative-parts","what": "parts combining every tier"