diff --git a/assets/locales/pending/continuity-words.json b/assets/locales/pending/continuity-words.json new file mode 100644 index 000000000..a388142cc --- /dev/null +++ b/assets/locales/pending/continuity-words.json @@ -0,0 +1,219 @@ +{ + "en": { + "ui.continuity_position": "Position", + "ui.continuity_tangent": "Tangent", + "ui.continuity_curvature": "Curvature", + "ui.continuity_curvature_change": "Curvature change", + "ui.continuity_crease": "Crease", + "ui.continuity_curvature_change_tip": "Curvature change (G3): the curvature also changes smoothly across the seam.", + "ui.continuity_curvature_tip": "Curvature-continuous (G2): reflections run through without a kink.", + "ui.continuity_position_tip": "Position (G0): the surfaces meet, with a crease where they do.", + "ui.continuity_tangent_tip": "Tangent (G1): no crease, though the curvature jumps across the seam." + }, + "ar": { + "ui.continuity_position": "الموضع", + "ui.continuity_tangent": "مماس", + "ui.continuity_curvature": "الانحناء", + "ui.continuity_curvature_change": "تغيّر الانحناء", + "ui.continuity_crease": "تجعّد", + "ui.continuity_curvature_change_tip": "تغيّر الانحناء (G3): يتغير الانحناء أيضًا بسلاسة عبر خط الالتقاء.", + "ui.continuity_curvature_tip": "متصل الانحناء (G2): تمر الانعكاسات دون انكسار.", + "ui.continuity_position_tip": "الموضع (G0): تلتقي الأسطح، مع تجعّد عند التقائها.", + "ui.continuity_tangent_tip": "مماس (G1): لا تجعّد، لكن الانحناء يقفز عبر خط الالتقاء." + }, + "cs": { + "ui.continuity_position": "Poloha", + "ui.continuity_tangent": "Tečnost", + "ui.continuity_curvature": "Křivost", + "ui.continuity_curvature_change": "Změna křivosti", + "ui.continuity_crease": "Hrana" + }, + "da": { + "ui.continuity_position": "Positionskontinuitet", + "ui.continuity_tangent": "Tangentkontinuitet", + "ui.continuity_curvature": "Krumning", + "ui.continuity_curvature_change": "Ændring i krumning", + "ui.continuity_crease": "Knæk" + }, + "de": { + "ui.continuity_position": "Position", + "ui.continuity_tangent": "Tangential", + "ui.continuity_curvature": "Krümmung", + "ui.continuity_curvature_change": "Krümmungsänderung", + "ui.continuity_crease": "Knick", + "ui.continuity_curvature_change_tip": "Krümmungsänderung (G3): Auch die Krümmung ändert sich an der Naht glatt.", + "ui.continuity_curvature_tip": "Krümmungsstetig (G2): Spiegelungen laufen ohne Knick hindurch.", + "ui.continuity_position_tip": "Position (G0): Die Flächen treffen sich, mit einem Knick an der Naht.", + "ui.continuity_tangent_tip": "Tangential (G1): kein Knick, aber die Krümmung springt an der Naht." + }, + "es": { + "ui.continuity_position": "Posición", + "ui.continuity_tangent": "Tangente", + "ui.continuity_curvature": "Curvatura", + "ui.continuity_curvature_change": "Cambio de curvatura", + "ui.continuity_crease": "Arista" + }, + "fr": { + "ui.continuity_position": "Position", + "ui.continuity_tangent": "Tangence", + "ui.continuity_curvature": "Courbure", + "ui.continuity_curvature_change": "Variation de courbure", + "ui.continuity_crease": "Angle vif" + }, + "gl": { + "ui.continuity_position": "Posición", + "ui.continuity_tangent": "Tanxente", + "ui.continuity_curvature": "Curvatura", + "ui.continuity_curvature_change": "Cambio de curvatura", + "ui.continuity_crease": "Aresta" + }, + "he": { + "ui.continuity_position": "מיקום", + "ui.continuity_tangent": "משיק", + "ui.continuity_curvature": "עקמומיות", + "ui.continuity_curvature_change": "שינוי עקמומיות", + "ui.continuity_crease": "שבר", + "ui.continuity_curvature_change_tip": "שינוי עקמומיות (G3): גם העקמומיות משתנה בצורה חלקה לאורך התפר.", + "ui.continuity_curvature_tip": "רציף בעקמומיות (G2): ההשתקפויות עוברות בלי שבר.", + "ui.continuity_position_tip": "מיקום (G0): המשטחים נפגשים, עם שבר במקום המפגש.", + "ui.continuity_tangent_tip": "משיק (G1): אין שבר, אך העקמומיות קופצת לאורך התפר." + }, + "hu": { + "ui.continuity_position": "Pozíció", + "ui.continuity_tangent": "Érintő", + "ui.continuity_curvature": "Görbület", + "ui.continuity_curvature_change": "Görbületváltozás", + "ui.continuity_crease": "Törés" + }, + "id": { + "ui.continuity_position": "Posisi", + "ui.continuity_tangent": "Tangen", + "ui.continuity_curvature": "Kelengkungan", + "ui.continuity_curvature_change": "Perubahan kelengkungan", + "ui.continuity_crease": "Lipatan" + }, + "it": { + "ui.continuity_position": "Posizione", + "ui.continuity_tangent": "Tangente", + "ui.continuity_curvature": "Curvatura", + "ui.continuity_curvature_change": "Variazione di curvatura", + "ui.continuity_crease": "Spigolo vivo" + }, + "ja": { + "ui.continuity_position": "位置", + "ui.continuity_tangent": "接線", + "ui.continuity_curvature": "曲率", + "ui.continuity_curvature_change": "曲率変化", + "ui.continuity_crease": "折れ", + "ui.continuity_curvature_change_tip": "曲率変化 (G3): 境目で曲率の変化もなめらかです。", + "ui.continuity_curvature_tip": "曲率連続 (G2): 映り込みが折れずに通ります。", + "ui.continuity_position_tip": "位置 (G0): 面はつながりますが、境目に折れがあります。", + "ui.continuity_tangent_tip": "接線 (G1): 折れはありませんが、境目で曲率が飛びます。" + }, + "ko": { + "ui.continuity_position": "위치", + "ui.continuity_tangent": "접선", + "ui.continuity_curvature": "곡률", + "ui.continuity_curvature_change": "곡률 변화", + "ui.continuity_crease": "꺾임", + "ui.continuity_curvature_change_tip": "곡률 변화(G3): 이음매에서 곡률의 변화도 부드럽습니다.", + "ui.continuity_curvature_tip": "곡률 연속(G2): 반사가 꺾임 없이 이어집니다.", + "ui.continuity_position_tip": "위치(G0): 면이 만나지만, 만나는 곳에 꺾임이 있습니다.", + "ui.continuity_tangent_tip": "접선(G1): 꺾임은 없지만, 이음매에서 곡률이 급변합니다." + }, + "ms": { + "ui.continuity_position": "Kedudukan", + "ui.continuity_tangent": "Tangen", + "ui.continuity_curvature": "Kelengkungan", + "ui.continuity_curvature_change": "Perubahan kelengkungan", + "ui.continuity_crease": "Lipatan" + }, + "nb": { + "ui.continuity_position": "Posisjon", + "ui.continuity_tangent": "Tangent", + "ui.continuity_curvature": "Krumning", + "ui.continuity_curvature_change": "Krumningsendring", + "ui.continuity_crease": "Knekk" + }, + "nl": { + "ui.continuity_position": "Positie", + "ui.continuity_tangent": "Tangentieel", + "ui.continuity_curvature": "Kromming", + "ui.continuity_curvature_change": "Krommingsverandering", + "ui.continuity_crease": "Knik" + }, + "pl": { + "ui.continuity_position": "Położenie", + "ui.continuity_tangent": "Styczność", + "ui.continuity_curvature": "Krzywizna", + "ui.continuity_curvature_change": "Zmiana krzywizny", + "ui.continuity_crease": "Załamanie" + }, + "pt-BR": { + "ui.continuity_position": "Posição", + "ui.continuity_tangent": "Tangente", + "ui.continuity_curvature": "Curvatura", + "ui.continuity_curvature_change": "Variação de curvatura", + "ui.continuity_crease": "Vinco" + }, + "ro": { + "ui.continuity_position": "Poziție", + "ui.continuity_tangent": "Tangent", + "ui.continuity_curvature": "Curbură", + "ui.continuity_curvature_change": "Variația curburii", + "ui.continuity_crease": "Muchie" + }, + "ru": { + "ui.continuity_position": "Положение", + "ui.continuity_tangent": "Касание", + "ui.continuity_curvature": "Кривизна", + "ui.continuity_curvature_change": "Изменение кривизны", + "ui.continuity_crease": "Излом" + }, + "sv": { + "ui.continuity_position": "Läge", + "ui.continuity_tangent": "Tangent", + "ui.continuity_curvature": "Krökning", + "ui.continuity_curvature_change": "Krökningsändring", + "ui.continuity_crease": "Veck" + }, + "tr": { + "ui.continuity_position": "Konum", + "ui.continuity_tangent": "Teğet", + "ui.continuity_curvature": "Eğrilik", + "ui.continuity_curvature_change": "Eğrilik değişimi", + "ui.continuity_crease": "Kırık" + }, + "uk": { + "ui.continuity_position": "Положення", + "ui.continuity_tangent": "Дотична", + "ui.continuity_curvature": "Кривизна", + "ui.continuity_curvature_change": "Зміна кривини", + "ui.continuity_crease": "Злам" + }, + "vi": { + "ui.continuity_position": "Vị trí liên tục", + "ui.continuity_tangent": "Tiếp tuyến", + "ui.continuity_curvature": "Độ cong", + "ui.continuity_curvature_change": "Thay đổi độ cong", + "ui.continuity_crease": "Nếp gập" + }, + "zh": { + "ui.continuity_position": "位置", + "ui.continuity_tangent": "相切", + "ui.continuity_curvature": "曲率", + "ui.continuity_curvature_change": "曲率变化", + "ui.continuity_crease": "折痕", + "ui.continuity_curvature_change_tip": "曲率变化 (G3):曲率在接缝处的变化也是平滑的。", + "ui.continuity_curvature_tip": "曲率连续 (G2):反射平滑穿过,没有折痕。", + "ui.continuity_position_tip": "位置 (G0):曲面相接,但接缝处有折痕。", + "ui.continuity_tangent_tip": "相切 (G1):没有折痕,但曲率在接缝处突变。" + }, + "zh-TW": { + "ui.continuity_position": "位置", + "ui.continuity_tangent": "相切", + "ui.continuity_curvature": "曲率", + "ui.continuity_curvature_change": "曲率變化", + "ui.continuity_crease": "摺痕" + } +} diff --git a/crates/doc/src/eval_thread.rs b/crates/doc/src/eval_thread.rs index 01fcd35b6..2c21c4743 100644 --- a/crates/doc/src/eval_thread.rs +++ b/crates/doc/src/eval_thread.rs @@ -593,8 +593,12 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap, f: &Feature, /// The chamfered tip of an external thread (ISO 4753, chamfered end CH) at each of its free ends: /// the material outside a cone `angle` to the axis (default 45°) that reaches the diameter -/// d_f = d - 2 `depth` at the face's end (default: the external thread's minor diameter, the -/// largest ISO 4753 allows), as a ring to cut after the groove, so the last teeth taper into it. +/// d_f = d - 2 `depth` at the face's end, as a ring to cut after the groove, so the last teeth +/// taper into it. ISO 4753 bounds d_f by the external thread's minor diameter; the default is +/// that bound, d3 = d - 1.226869 P (ISO 724, the rounded root of the design profile). It lies +/// below the modelled basic root d1, so the cone crosses the root cylinder and leaves a whole +/// ring on the end; one ending on the root itself would pinch to nothing wherever the groove +/// reaches the end. ISO 4753 is for ISO metric threads: other forms give `depth`. fn tip_cones(t: &ThreadInfo, radius: f64, ends: [End; 2], angle: Option, depth: Option) -> Result> { if t.internal { return Err(DocError::Invalid("a chamfered tip is for an external thread (ISO 4753); countersink the hole's entry instead".into())); @@ -605,7 +609,18 @@ fn tip_cones(t: &ThreadInfo, radius: f64, ends: [End; 2], angle: Option, de return Err(DocError::Invalid("the chamfer's angle to the axis must be between 1° and 89°".into())); } let r_top = radius.max(t.major_diameter / 2.0); - let depth = depth.unwrap_or(t.major_diameter / 2.0 - g.root_r); + let depth = match (depth, t.form) { + (Some(d), _) => d, + // ISO 724: d3 = d1 - H/6 = d - 2 (17/24) H. + (None, ThreadForm::Metric) => 17.0 / 24.0 * t.pitch * 3f64.sqrt() / 2.0, + (None, form) => { + return Err(DocError::Invalid(format!( + "ISO 4753's chamfered end is for ISO metric threads: give a {} thread its chamfer depth (its root is {} mm deep)", + form.name(), + show_mm(t.major_diameter / 2.0 - g.root_r) + ))); + } + }; let r_f = t.major_diameter / 2.0 - depth; if !(depth > 0.0 && r_f > 1e-3) { return Err(DocError::Invalid(format!("the chamfer's depth must be between 0 and {} mm", show_mm(t.major_diameter / 2.0)))); diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rs index e35fb138d..20f82c39a 100644 --- a/crates/engine/src/cmd/features.rs +++ b/crates/engine/src/cmd/features.rs @@ -93,7 +93,7 @@ pub static COMMANDS: &[CommandSpec] = &[ CommandSpec::new("solid.thread", "Thread", thread) .at("SOLID", "CREATE") .icon("thread") - .params("face: [x,y,z] on a cylindrical face; form?: metric|trapezoidal|acme|buttress|buttress_asme (default: the one `designation` names, else metric; square is refused: no current standard defines it); designation?: the size, as its standard writes it: metric \"M8\", \"M8x1\", \"M16xPh3P1.5\" (ISO 68-1, ISO 261, ISO 965-1); trapezoidal \"Tr20x4\", \"Tr40x14(P7)\" (ISO 2904, ISO 2903); buttress \"S20x4\", \"S40x14(P7)\" (DIN 513, 3°/30°); acme \"1/2-10 ACME\" (ASME B1.5); buttress_asme \"2.5-8 BUTT\" (ASME B1.9, 7°/45°, basic profile; no size table) (default: the standard size that fits the face, a shaft its major diameter, a hole its drill); hand?: right|left|both (default right; both: a right- and a left-handed groove crossing); steep_flank?: start|end (buttress only, default end: the steep flank of the screw's teeth faces the thread's end, the way its axis points); starts?: 1..8 (lead = starts x pitch: that many grooves, each a turn's starts-th further round; a designation that gives the lead gives the starts); ease_in?, ease_out?: expr|standard|short (modelled threads: the groove fades out over this length, its section moving out of the material as it turns; standard 2.5 P, short 1.25 P per ISO 3508; ease_in at the end the thread starts from (`from`, or the start of its extent), ease_out at the other; it lies past the full-form length, up to a shoulder's clearance; at a free end, inside the face); tip?: none|chamfer (modelled external threads: each free end the thread reaches is chamfered after the groove is cut, ISO 4753's chamfered end, the last teeth tapering into the cone; chamfer_angle?: angle expr to the axis, default 45 deg; chamfer_depth?: expr, radial from the major diameter, default down to the external minor diameter, the largest ISO 4753 allows); extent?: full|length|up_to (default: length when `length` is given, up_to when `up_to` is, else full: the whole face); length?: expr (from the end the thread starts at); up_to?: [x,y,z] (a point, such as on a shoulder face: the thread runs to its place along the axis) | plane name or {origin, normal} (to where the plane crosses the axis); from?: [x,y,z] near the end of the face the thread starts at (default: the face's only free end, the one with no material past it; else the end the `face` point lies within a third of the face of; a pick in the middle of a face whose ends are alike is refused); modeled?: bool (default false). Cosmetic: the model is unchanged, model.threads lists it. Modeled: cuts the thread profile into the body: past a free end the groove runs out a pitch into the air (or through a chamfer); at a shoulder, a head or a blind hole's bottom it stops with its section clear of it, never cutting into it; a shaft thicker than the thread is refused with the size to make it, never turned down"), + .params("face: [x,y,z] on a cylindrical face; form?: metric|trapezoidal|acme|buttress|buttress_asme (default: the one `designation` names, else metric; square is refused: no current standard defines it); designation?: the size, as its standard writes it: metric \"M8\", \"M8x1\", \"M16xPh3P1.5\" (ISO 68-1, ISO 261, ISO 965-1); trapezoidal \"Tr20x4\", \"Tr40x14(P7)\" (ISO 2904, ISO 2903); buttress \"S20x4\", \"S40x14(P7)\" (DIN 513, 3°/30°); acme \"1/2-10 ACME\" (ASME B1.5); buttress_asme \"2.5-8 BUTT\" (ASME B1.9, 7°/45°, basic profile; no size table) (default: the standard size that fits the face, a shaft its major diameter, a hole its drill); hand?: right|left|both (default right; both: a right- and a left-handed groove crossing); steep_flank?: start|end (buttress only, default end: the steep flank of the screw's teeth faces the thread's end, the way its axis points); starts?: 1..8 (lead = starts x pitch: that many grooves, each a turn's starts-th further round; a designation that gives the lead gives the starts); ease_in?, ease_out?: expr|standard|short (modelled threads: the groove fades out over this length, its section moving out of the material as it turns; standard 2.5 P, short 1.25 P per ISO 3508; ease_in at the end the thread starts from (`from`, or the start of its extent), ease_out at the other; it lies past the full-form length, up to a shoulder's clearance; at a free end, inside the face); tip?: none|chamfer (modelled external threads: each free end the thread reaches is chamfered after the groove is cut, ISO 4753's chamfered end, the last teeth tapering into the cone; chamfer_angle?: angle expr to the axis, default 45 deg; chamfer_depth?: expr, radial from the major diameter, default for a metric thread down to the external minor diameter d3 = d - 1.226869 P (ISO 724), the largest ISO 4753 allows; other forms give it); extent?: full|length|up_to (default: length when `length` is given, up_to when `up_to` is, else full: the whole face); length?: expr (from the end the thread starts at); up_to?: [x,y,z] (a point, such as on a shoulder face: the thread runs to its place along the axis) | plane name or {origin, normal} (to where the plane crosses the axis); from?: [x,y,z] near the end of the face the thread starts at (default: the face's only free end, the one with no material past it; else the end the `face` point lies within a third of the face of; a pick in the middle of a face whose ends are alike is refused); modeled?: bool (default false). Cosmetic: the model is unchanged, model.threads lists it. Modeled: cuts the thread profile into the body: past a free end the groove runs out a pitch into the air (or through a chamfer); at a shoulder, a head or a blind hole's bottom it stops with its section clear of it, never cutting into it; a shaft thicker than the thread is refused with the size to make it, never turned down"), CommandSpec::new("solid.shell", "Shell", shell) .at("SOLID", "MODIFY") .icon("shell") diff --git a/crates/engine/src/thread_tests.rs b/crates/engine/src/thread_tests.rs index 1b1178c8e..3ef15e092 100644 --- a/crates/engine/src/thread_tests.rs +++ b/crates/engine/src/thread_tests.rs @@ -521,6 +521,46 @@ fn a_thread_stops_clear_of_a_shoulder() { assert!((got - want).abs() < want * 2e-4, "{got} vs {want}"); } +/// A d10 boss (z 6..22) joined onto a 40x40x6 plate, 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 +/// its 40 40 6 (what lies below z = 6 after the boss is cut away), and without a runout the +/// boss loses (16 - w)/P turns, as at a collar. +#[test] +fn a_thread_on_a_boss_never_cuts_into_the_plate_below() { + let boss = |extra: Value| { + let mut s = Session::default(); + run(&mut s, "solid.box", json!({"corner": [-20, -20, 0], "length": 40, "width": 40, "height": 6, "body_name": "Part"})); + run(&mut s, "solid.cylinder", json!({"base": [0, 0, 6], "radius": 5, "height": 16, "operation": "join", "targets": ["Part"]})); + let mut p = json!({"face": [5, 0, 14], "designation": "M10", "modeled": true}); + if let (Some(p), Value::Object(e)) = (p.as_object_mut(), extra) { + p.extend(e); + } + run(&mut s, "solid.thread", p); + s + }; + let plate_left = |mut s: Session| { + run( + &mut s, + "solid.box", + json!({"corner": [-30, -30, 6], "length": 60, "width": 60, "height": 30, "body_name": "Above", "operation": "new_body"}), + ); + run(&mut s, "solid.combine", json!({"target": "Part", "tools": ["Above"], "operation": "cut"})); + exact_volume(&s, "Part") + }; + let s = boss(json!({})); + let (p, w) = (1.5, ext_half_width(10.0, 1.5)); + let want = 40.0 * 40.0 * 6.0 + PI * 25.0 * 16.0 - (16.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}"); + assert!((plate_left(s) - 9600.0).abs() < 1e-6); + for extra in [json!({"ease_out": "standard"}), json!({"ease_out": "short", "tip": "chamfer"})] { + let s = boss(extra.clone()); + assert!(s.model.state().body("Part").unwrap().body.validity().is_empty(), "{extra}"); + let left = plate_left(s); + assert!((left - 9600.0).abs() < 1e-6, "{extra}: the plate below the boss lost {} mm³", 9600.0 - left); + } +} + /// Rig 602: "from the end nearest the pick" took the head end for a pick a little above the /// middle. A thread of limited length starts at the face's only free end, wherever it is picked. #[test] @@ -823,17 +863,26 @@ fn m10_stock(z0: f64, z1: f64, rmax: impl Fn(f64) -> f64) -> f64 { (0..n).map(|i| z0 + (z1 - z0) * (i as f64 + 0.5) / n as f64).map(|z| 2.0 * PI * ring(rmax(z)) * (z1 - z0) / n as f64).sum() } -/// ISO 4753's chamfered end on both free ends of an M10 stud: a 45° cone down to the minor -/// diameter, cut after the groove; the volume as the stock's chamfered section with the thread's -/// material fraction (as ladder 06/006). +/// ISO 4753's chamfered end on both free ends of an M10 stud: a 45° cone down to the external +/// minor diameter d3 (ISO 724), cut after the groove; the volume as the stock's chamfered section +/// with the thread's material fraction (as ladder 06/006). d3 lies below the modelled root, so +/// each end face is the whole disk of d3, with the cone a whole ring around it, not pinched +/// where the groove reaches the end. #[test] fn a_chamfered_tip_tapers_the_last_teeth() { let mut s = Session::default(); run(&mut s, "solid.cylinder", json!({"radius": 5, "height": 30, "body_name": "Stud"})); run(&mut s, "solid.thread", json!({"face": [5, 0, 15], "designation": "M10", "tip": "chamfer", "modeled": true})); let st = s.model.state(); - assert!(st.body("Stud").unwrap().body.validity().is_empty()); - let rf = 5.0 - 5.0 * 1.5 * 3f64.sqrt() / 16.0; + let stud = &st.body("Stud").unwrap().body; + assert!(stud.validity().is_empty()); + let rf = 5.0 - 17.0 / 24.0 * 1.5 * 3f64.sqrt() / 2.0; + let ends: Vec = + stud.faces(1e-4).unwrap().into_iter().filter(|f| f.plane_normal.is_some_and(|n| n.z.abs() > 0.999)).map(|f| f.area).collect(); + assert_eq!(ends.len(), 2); + for a in ends { + assert!((a - PI * rf * rf).abs() < 1e-3 * a, "each end is a whole disk of d3: {a} vs {}", PI * rf * rf); + } let want = m10_stock(0.0, 30.0, |z| 5f64.min(rf + z).min(rf + 30.0 - z)); let got = exact_volume(&s, "Stud"); assert!((got - want).abs() < want * 1e-4, "{got} vs {want}"); @@ -859,6 +908,16 @@ fn a_chamfered_tip_tapers_the_last_teeth() { .err() .map(|e| e.to_string()); assert!(e.unwrap_or_default().contains("countersink")); + // ISO 4753 is for ISO metric threads: another form names its chamfer depth. + let mut s = Session::default(); + run(&mut s, "solid.cylinder", json!({"radius": 10, "height": 40, "body_name": "Screw"})); + let e = s + .execute("solid.thread", &json!({"face": [10, 0, 20], "designation": "Tr20x4", "tip": "chamfer", "modeled": true})) + .err() + .map(|e| e.to_string()); + assert!(e.unwrap_or_default().contains("chamfer depth")); + run(&mut s, "solid.thread", json!({"face": [10, 0, 20], "designation": "Tr20x4", "tip": "chamfer", "chamfer_depth": 2.5, "modeled": true})); + assert!(s.model.state().body("Screw").unwrap().body.validity().is_empty()); } /// M10's groove section moved `d` out from the axis, clipped at the shaft's radius 5: the cut per diff --git a/crates/ui-egui/src/dialogs_surface.rs b/crates/ui-egui/src/dialogs_surface.rs index 82f09f3dd..3886152a0 100644 --- a/crates/ui-egui/src/dialogs_surface.rs +++ b/crates/ui-egui/src/dialogs_surface.rs @@ -138,12 +138,29 @@ impl Surf { } /// How a patch on edges meets the faces beside its loop (labels, and the `continuity` parameter). -const PATCH_CONTINUITY: [(&str, &str); 3] = [("Position (G0)", "g0"), ("Tangent (G1)", "g1"), ("Curvature (G2)", "g2")]; +/// Labels are plain words; the order's code (G0, G1, G2) is in each one's hover text. +const PATCH_CONTINUITY: [(&str, &str); 3] = [("ui.continuity_position", "g0"), ("ui.continuity_tangent", "g1"), ("ui.continuity_curvature", "g2")]; /// How much of the surface at its edges each end of a blend repeats (labels, and the /// `continuity` words). const BLEND_CONTINUITY: [(&str, &str); 4] = - [("Position (G0)", "g0"), ("Tangent (G1)", "g1"), ("Curvature (G2)", "g2"), ("Curvature change (G3)", "g3")]; + [("ui.continuity_position", "g0"), ("ui.continuity_tangent", "g1"), ("ui.continuity_curvature", "g2"), ("ui.continuity_curvature_change", "g3")]; + +/// Each continuity's hover text, in the order of [`BLEND_CONTINUITY`]: where its code (G0 … G3) +/// is shown. +const CONTINUITY_TIPS: [&str; 4] = + ["ui.continuity_position_tip", "ui.continuity_tangent_tip", "ui.continuity_curvature_tip", "ui.continuity_curvature_change_tip"]; + +/// A Continuity row's segments over `orders` (the segments draw their text as given). +fn continuity_segments(ui: &mut egui::Ui, selected: &mut usize, orders: &[(&str, &str)]) -> egui::Response { + let labels: Vec<&str> = orders.iter().map(|(label, _)| crate::i18n::tr(label)).collect(); + ui.scope(|ui| ui_kit::segmented(ui, selected, &labels, Default::default())).response +} + +/// The hover text of a list of `orders` continuities: a line for each. +fn continuity_tip(orders: usize) -> String { + CONTINUITY_TIPS.iter().take(orders).map(|tip| crate::i18n::tr(tip)).collect::>().join("\n") +} /// What a boundary surface becomes: a body of its own, or part of the body of its edges. const BOUNDARY_OPS: [&str; 2] = ["New Body", "Join"]; @@ -275,31 +292,27 @@ pub fn rows(ui: &mut egui::Ui, k: &mut Surf) -> bool { ui_kit::options(ui, "untrim_options", &mut [("Restore outer boundary", outer), ("In place (surfaces)", in_place)]); } Surf::Patch { continuity } => { - form_row(ui, "Continuity", |ui| { - ui_kit::segmented(ui, continuity, &PATCH_CONTINUITY.map(|(label, _)| label), Default::default()); - }); + form_row(ui, "Continuity", |ui| continuity_segments(ui, continuity, &PATCH_CONTINUITY)) + .on_hover_text(continuity_tip(PATCH_CONTINUITY.len())); } Surf::Blend { continuity, bulge, stitch } => { let [from, to] = continuity; let [from_bulge, to_bulge] = bulge; - form_row(ui, "Start continuity", |ui| { - combo(ui, "bl_cont0", &BLEND_CONTINUITY.map(|(label, _)| label), from); - }); + form_row(ui, "Start continuity", |ui| ui_kit::dropdown(ui, "bl_cont0", from, &BLEND_CONTINUITY.map(|(label, _)| label))) + .on_hover_text(continuity_tip(BLEND_CONTINUITY.len())); form_row(ui, "Start bulge", |ui| { ui_kit::scalar_field(ui, from_bulge, -0.9..=3.0); }); - form_row(ui, "End continuity", |ui| { - combo(ui, "bl_cont1", &BLEND_CONTINUITY.map(|(label, _)| label), to); - }); + form_row(ui, "End continuity", |ui| ui_kit::dropdown(ui, "bl_cont1", to, &BLEND_CONTINUITY.map(|(label, _)| label))) + .on_hover_text(continuity_tip(BLEND_CONTINUITY.len())); form_row(ui, "End bulge", |ui| { ui_kit::scalar_field(ui, to_bulge, -0.9..=3.0); }); ui_kit::options(ui, "blend_options", &mut [("Stitch to both bodies", stitch)]); } Surf::Boundary { continuity, join } => { - form_row(ui, "Continuity", |ui| { - ui_kit::segmented(ui, continuity, &PATCH_CONTINUITY.map(|(label, _)| label), Default::default()); - }); + form_row(ui, "Continuity", |ui| continuity_segments(ui, continuity, &PATCH_CONTINUITY)) + .on_hover_text(continuity_tip(PATCH_CONTINUITY.len())); form_row(ui, "Operation", |ui| { let mut op = usize::from(*join); combo(ui, "bo_op", &BOUNDARY_OPS, &mut op); diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rs index ffcd75693..ccf5ce9db 100644 --- a/crates/ui-egui/src/preselect_tests.rs +++ b/crates/ui-egui/src/preselect_tests.rs @@ -2232,7 +2232,8 @@ fn patch_dialog_takes_continuity_and_points_and_brings_them_back() { #[test] fn patch_dialog_rows_are_translated() { - for (lang, continuity, through) in [("en", "Continuity", "Pass through"), ("de", "Stetigkeit", "Durch Punkte"), ("ja", "連続性", "通過点")] + for (lang, continuity, through, tangent) in + [("en", "Continuity", "Pass through", "Tangent"), ("de", "Stetigkeit", "Durch Punkte", "Tangential"), ("ja", "連続性", "通過点", "接線")] { let mut h = crate::scenario::Harness::new(); h.app.preferences.language = lang.into(); @@ -2241,6 +2242,12 @@ fn patch_dialog_rows_are_translated() { h.frames(3); assert!(h.widget(continuity).is_some(), "{lang}: the Continuity row must show {continuity:?}"); assert!(h.widget(through).is_some(), "{lang}: the points input must show {through:?}"); + // The continuity in the language too, in words (the code is in the hover text). + if let Some(crate::dialogs::Dialog { kind: Kind::Surface(crate::dialogs_surface::Surf::Patch { continuity }), .. }) = h.app.dialog.as_mut() { + *continuity = 1; + } + h.frames(2); + assert!(h.widget(tangent).is_some(), "{lang}: the Tangent segment must show {tangent:?}"); } } diff --git a/crates/ui-egui/src/sketch_continuity_tests.rs b/crates/ui-egui/src/sketch_continuity_tests.rs index b624c8ab6..f62e0e4b9 100644 --- a/crates/ui-egui/src/sketch_continuity_tests.rs +++ b/crates/ui-egui/src/sketch_continuity_tests.rs @@ -21,7 +21,7 @@ fn the_button_shades_every_seam_pins_an_edge_and_turns_off() { assert_eq!(h.app.session.continuity.len(), 12, "every edge of the box"); assert_eq!(h.app.tool.as_ref().map(|t| t.cmd), Some("inspect.continuity")); h.step(&json!({"click": {"world": [10, 0, 20]}})).unwrap(); - assert_eq!(marks(), ["G0 90.000\u{b0}"], "{:?}", h.app.status); + assert_eq!(marks(), ["Crease 90.000\u{b0}"], "{:?}", h.app.status); assert_eq!(h.app.session.continuity.len(), 12, "the clicked edge is measured again, not added twice"); h.step(&json!({"start": "inspect.continuity"})).unwrap(); assert!(h.app.session.continuity.is_empty() && h.app.tool.is_none()); @@ -29,7 +29,7 @@ fn the_button_shades_every_seam_pins_an_edge_and_turns_off() { assert!(marks().is_empty(), "the markers go with the tool"); } -/// A round's tangent seam reads G1 with its curvature jump (1 / 4 mm against the flat side). +/// A round's tangent seam reads Tangent with its curvature jump (1 / 4 mm against the flat side). #[test] fn a_tangent_seam_is_labelled_with_its_curvature_jump() { let mut h = crate::scenario::Harness::new(); @@ -41,7 +41,7 @@ fn a_tangent_seam_is_labelled_with_its_curvature_jump() { h.step(&json!({"click": {"world": [16, 0, 10]}})).unwrap(); let labels = marks(); assert_eq!(labels.len(), 1, "{labels:?} {:?}", h.app.status); - assert!(labels[0].starts_with("G1 0.000\u{b0} \u{394}k 0.2500/mm"), "{labels:?}"); + assert!(labels[0].starts_with("Tangent 0.000\u{b0} \u{394}k 0.2500/mm"), "{labels:?}"); } /// The legend shows while seams are shaded and goes with the analysis. diff --git a/crates/ui-egui/src/sketch_tools.rs b/crates/ui-egui/src/sketch_tools.rs index 1415be77b..6825eeec9 100644 --- a/crates/ui-egui/src/sketch_tools.rs +++ b/crates/ui-egui/src/sketch_tools.rs @@ -181,9 +181,9 @@ fn continuity_label(app: &SolveApp, seam: &Value) -> String { let jump = seam["curvature_jump_per_mm"]["value"].as_f64().map(|k| format!("\u{394}k {k:.4}/mm")).unwrap_or_default(); match seam["verdict"].as_str().unwrap_or_default() { "gap" => format!("Gap {}", seam["gap_mm"]["value"].as_f64().map(|g| crate::prefs::show_mm(app, g, 1)).unwrap_or_default()), - "sharp" => format!("G0 {}", deg("normal_angle_deg")), - "curvature_jump" => format!("G1 {} {jump}", deg("normal_angle_deg")), - "smooth" => format!("G2 {} {jump}", deg("normal_angle_deg")), + "sharp" => format!("{} {}", crate::i18n::tr("ui.continuity_crease"), deg("normal_angle_deg")), + "curvature_jump" => format!("{} {} {jump}", crate::i18n::tr("ui.continuity_tangent"), deg("normal_angle_deg")), + "smooth" => format!("{} {} {jump}", crate::i18n::tr("ui.continuity_curvature"), deg("normal_angle_deg")), other => other.to_string(), } } @@ -198,7 +198,12 @@ fn continuity_legend(app: &SolveApp, painter: &egui::Painter, proj: &Proj) { let [smooth, jump, sharp, gap] = tk.continuity; // Stable ids: this Gap is a hole between faces, not the sheet-metal gap (`ui.sheet_gap`). let tr = crate::i18n::tr; - let rows = [(tr("ui.continuity_g2"), smooth), (tr("ui.continuity_g1"), jump), (tr("ui.continuity_g0"), sharp), (tr("ui.continuity_gap"), gap)]; + let rows = [ + (tr("ui.continuity_curvature"), smooth), + (tr("ui.continuity_tangent"), jump), + (tr("ui.continuity_crease"), sharp), + (tr("ui.continuity_gap"), gap), + ]; let font = egui::FontId::proportional(tk.font_body); let (row, pad, swatch) = (18.0, 8.0, 22.0); let text_width = rows.iter().map(|(label, _)| painter.layout_no_wrap(label.to_string(), font.clone(), tk.text).size().x).fold(0.0, f32::max); @@ -303,10 +308,16 @@ pub fn start_hook(app: &mut SolveApp, id: &str) -> bool { } let Ok(v) = app.run(id, json!({})) else { return false }; let summary = &v["summary"]; - let counts: Vec = [("smooth", "G2"), ("curvature_jump", "G1"), ("sharp", "G0"), ("gap", "gap")] - .iter() - .filter_map(|(key, class)| summary[*key].as_u64().filter(|n| *n > 0).map(|n| format!("{n} {class}"))) - .collect(); + // Each class in the legend's words. + let counts: Vec = [ + ("smooth", "ui.continuity_curvature"), + ("curvature_jump", "ui.continuity_tangent"), + ("sharp", "ui.continuity_crease"), + ("gap", "ui.continuity_gap"), + ] + .iter() + .filter_map(|(key, class)| summary[*key].as_u64().filter(|n| *n > 0).map(|n| format!("{n} {}", crate::i18n::tr(class)))) + .collect(); app.set_status(format!("Continuity: {} (click the button again to turn it off)", counts.join(", ")), false); return true; } diff --git a/docs/book/src/guide/features.md b/docs/book/src/guide/features.md index 6a63551e6..14e698b24 100644 --- a/docs/book/src/guide/features.md +++ b/docs/book/src/guide/features.md @@ -146,7 +146,7 @@ Fillets and chamfers handle straight edges between planar faces, whole smooth lo neighbouring edges with mitred or spherical corners, and closed chains of curved edges (a rolling ball). See the roadmap's known limitations for the rest. -**Curvature (G2)** in the Fillet dialog's **Radius Type** blends straight edges between two +**Curvature continuous** (G2) in the Fillet dialog's **Type** blends straight edges between two planar faces with an exact quintic section. The tangent plane and curvature match each side face: curvature goes to zero at both contact rails, unlike a circular G1 fillet. Each end must meet one planar face; perpendicular and sloped planar ends are supported. Curved @@ -162,6 +162,14 @@ Scripts and MCP use the same command, for example on a 20 mm box: ``` `type: "g2"` is an alias. Existing fillets still default to circular, constant-radius G1 blends. +Where three or more rounded edges meet at a corner, the Fillet dialog shows **Corners**: **Ball** +(the default, a piece of the rolling ball's sphere, tangent (G1) to each round) or **Smooth +patch** (`corner: "g2"`: the corner is set back along each edge and filled with a +curvature-continuous (G2) patch, so reflections run through it without a kink). A smooth patch +takes **Constant radius** and **Exact** fit. Its **Setback** is how far along each edge from the +corner the patch starts, one distance for every corner (`setbacks`); left empty, it is 1.5 × the +radius. + Feature references to faces and edges are stored by name, so an upstream edit that moves geometry keeps them on the right face (see [Persistent naming](../dev/naming.md)). When a reference can't be found, the feature warns instead of silently picking another face. diff --git a/docs/threads.md b/docs/threads.md index 719f1dfeb..3eff6192f 100644 --- a/docs/threads.md +++ b/docs/threads.md @@ -83,9 +83,13 @@ radially. **Tip** (`tip: chamfer`, ISO 4753's chamfered end): at each free end of a modelled external thread, after the groove, the material outside a cone `chamfer_angle` to the axis (45°) reaching -d_f = d − 2 `chamfer_depth` at the end (default the external minor diameter, the largest the -standard allows) is cut, the last teeth tapering into it. An internal thread takes the hole's -countersink instead. +d_f = d − 2 `chamfer_depth` at the end is cut, the last teeth tapering into it. ISO 4753 bounds +d_f by the minor diameter; the default is that bound, the external minor diameter d3 = d − +1.226869 P of ISO 724 (8.160 for M10), which lies below the modelled basic root d1. The cone +therefore crosses the root and leaves the end a whole disk of d3 inside a whole conical ring; a +cone ending on the root itself would pinch to nothing wherever the groove reaches the end. ISO +4753 is for ISO metric threads, so the other forms give `chamfer_depth`. An internal thread takes +the hole's countersink instead. ## Sources @@ -104,4 +108,9 @@ countersink instead. - ASME B1.9 (buttress inch): 7°/45°, basic height of engagement 0.6 P; the flat follows from the fundamental triangle H = P / (tan 7° + tan 45°) = 0.89064 P truncated equally at crest and root. - ISO 3508 (thread runouts) and ISO 4753 (ends of parts with external threads) for the runout and - the chamfered tip. + the chamfered tip. ISO 4753:2011, figure 1 b) (chamfered end CH; the public preview at + ): + the end's diameter "Maximum diameter at the minor thread diameter", the angle ≤ 50°, the + incomplete thread u ≤ 2 P. +- ISO 724 (external minor diameter d3 = d1 − H/6 = d − 1.226869 P, M10x1.5: 8.16), as given at + . diff --git a/tests/kernel-cases/ladder/06-threads/017-external-m10-chamfered-tip/expected.json b/tests/kernel-cases/ladder/06-threads/017-external-m10-chamfered-tip/expected.json index 8d128216b..4a1f80866 100644 --- a/tests/kernel-cases/ladder/06-threads/017-external-m10-chamfered-tip/expected.json +++ b/tests/kernel-cases/ladder/06-threads/017-external-m10-chamfered-tip/expected.json @@ -1,10 +1,10 @@ { "sources": [], - "what": "001's modelled M10 thread with ISO 4753's chamfered end at both free ends: a 45 deg cone down to the minor diameter, cut after the groove", + "what": "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", "source": "analytic", - "method": "ISO 68-1 basic profile (60 deg, root flat P/4 at d - 5H/4 ... minor d1 = d - 1.0825 P, crest flat P/8): a helical groove of fixed section is a screw motion, so averaged over the turn every meridian half-plane holds the same section and V = 2 pi int int r m(r) dr dz over the stock's section, m the material fraction per pitch; the groove runs out past free ends. Tolerance 0.01%: SMLib's exact screw sweep; the chamfer is axisymmetric and cut after the groove, so it only lowers the stock's outer radius: r <= d_f/2 + distance from the end (45 deg), d_f the minor diameter d - 5H/4 = 8.376 (ISO 4753 chamfered end: the end's diameter at most the minor diameter)", + "method": "ISO 68-1 basic profile (60 deg, root flat P/4 at d - 5H/4 ... minor d1 = d - 1.0825 P, crest flat P/8): a helical groove of fixed section is a screw motion, so averaged over the turn every meridian half-plane holds the same section and V = 2 pi int int r m(r) dr dz over the stock's section, m the material fraction per pitch; the groove runs out past free ends. Tolerance 0.01%: SMLib's exact screw sweep; the chamfer is axisymmetric and cut after the groove, so it only lowers the stock's outer radius: r <= d_f/2 + distance from the end (45 deg), d_f the external minor diameter d3 = d - 1.226869 P = 8.160 (ISO 724; ISO 4753 chamfered end: the end's diameter at most the minor diameter), below the modelled root d1", "body_count": 1, - "volume_mm3": 1947.833394596, + "volume_mm3": 1945.354522563, "tolerance": { "rel": 0.0001 } diff --git a/tests/kernel-cases/ladder/golden.json b/tests/kernel-cases/ladder/golden.json index 53aa862d7..9c872fdb9 100644 --- a/tests/kernel-cases/ladder/golden.json +++ b/tests/kernel-cases/ladder/golden.json @@ -986,14 +986,14 @@ }, "ladder/06-threads/017-external-m10-chamfered-tip": { "measured": { - "area_mm2": 1500.75072007837, + "area_mm2": 1492.9858770288445, "body_count": 1, - "edges": 254, + "edges": 258, "faces": 88, - "vertices": 168, - "volume_mm3": 1947.8329205613231 + "vertices": 172, + "volume_mm3": 1945.3543465077544 }, - "seconds": 3.485166487, + "seconds": 3.293720875, "status": "pass" }, "ladder/06-threads/018-external-m10-both-hands": {