Wave 261/509: Format 40: a thread's hand on tapped holes too; v0.24.0's handedness opens as hand (and 3 more)
4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. -4e26dc640jyviko: The command line and the web app link SMLib by default too -826f36a79jyviko: CI and releases fetch SMLib before building -8aea8e5a8jyviko: Format 40: a thread's hand on tapped holes too; v0.24.0's handedness opens as hand -652d3a2cbjyviko: ui: main's browser picks (#4774) read the placed model through session_world Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
1 parent
5a4e482e9c
commit
176202b238
19 files changed
+168
-15
No files matched your search
@@ -350,6 +350,9 @@ jobs:
|
||||
- name: Size parallel compiles to the job's memory
|
||||
run: scripts/ci/build-jobs.sh
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: quick-compile
|
||||
@@ -368,6 +371,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: clippy
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
# Main saves the cache; every other run restores it, read-only.
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
@@ -402,6 +408,9 @@ jobs:
|
||||
- name: Size parallel compiles to the job's memory
|
||||
run: scripts/ci/build-jobs.sh
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
# sccache lives on a Blacksmith sticky disk (an ext4 volume cloned from the last snapshot,
|
||||
# no 10 GB limit and no download). Only main commits it; pull requests, the merge queue and
|
||||
# forks mount a clone and never write back, so nothing they build can reach main's cache.
|
||||
@@ -472,6 +481,9 @@ jobs:
|
||||
- name: Size parallel compiles to the job's memory
|
||||
run: scripts/ci/build-jobs.sh
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
# sccache lives on a Blacksmith sticky disk (an ext4 volume cloned from the last snapshot,
|
||||
# no 10 GB limit and no download). Only main commits it; pull requests, the merge queue and
|
||||
# forks mount a clone and never write back, so nothing they build can reach main's cache.
|
||||
@@ -749,6 +761,9 @@ jobs:
|
||||
- name: Size parallel compiles to the job's memory
|
||||
run: scripts/ci/build-jobs.sh
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
# sccache lives on a Blacksmith sticky disk (an ext4 volume cloned from the last snapshot,
|
||||
# no 10 GB limit and no download). Only main commits it; pull requests, the merge queue and
|
||||
# forks mount a clone and never write back, so nothing they build can reach main's cache.
|
||||
@@ -807,6 +822,9 @@ jobs:
|
||||
- name: Size parallel compiles to the job's memory
|
||||
run: scripts/ci/build-jobs.sh
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
# sccache lives on a Blacksmith sticky disk (an ext4 volume cloned from the last snapshot,
|
||||
# no 10 GB limit and no download). Only main commits it; pull requests, the merge queue and
|
||||
# forks mount a clone and never write back, so nothing they build can reach main's cache.
|
||||
@@ -881,6 +899,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: windows-startup
|
||||
@@ -1002,6 +1023,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: wasm32-unknown-unknown
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh wasm32-unknown-unknown
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: wasm
|
||||
@@ -1024,6 +1048,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: riscv64gc-unknown-linux-gnu
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh riscv64gc-unknown-linux-gnu
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: riscv64
|
||||
@@ -1043,11 +1070,13 @@ jobs:
|
||||
EOF
|
||||
sudo dpkg --add-architecture riscv64
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y gcc-riscv64-linux-gnu libasound2-dev:riscv64 libxkbcommon-dev:riscv64 \
|
||||
sudo apt-get install -y gcc-riscv64-linux-gnu g++-riscv64-linux-gnu libasound2-dev:riscv64 libxkbcommon-dev:riscv64 \
|
||||
libwayland-dev:riscv64 libx11-dev:riscv64 libxrandr-dev:riscv64 libxi-dev:riscv64 libgl1-mesa-dev:riscv64
|
||||
- name: Cargo check on RISC-V
|
||||
env:
|
||||
CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER: riscv64-linux-gnu-gcc
|
||||
# SMLib has no prebuilt library for RISC-V: its sources are compiled with this.
|
||||
CXX_riscv64gc_unknown_linux_gnu: riscv64-linux-gnu-g++
|
||||
PKG_CONFIG_SYSROOT_DIR: /
|
||||
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig:/usr/share/pkgconfig
|
||||
PKG_CONFIG_ALLOW_CROSS: 1
|
||||
|
||||
@@ -49,6 +49,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: wasm32-unknown-unknown
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh wasm32-unknown-unknown
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: docker-web
|
||||
|
||||
@@ -29,6 +29,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
- name: Build the CLI
|
||||
run: cargo build --profile ci -p solidcraft-cli
|
||||
- name: Import and check every entry
|
||||
|
||||
@@ -45,6 +45,9 @@ jobs:
|
||||
# main goes through the merge queue; this deploy key may push past it.
|
||||
ssh-key: ${{ secrets.GENERATED_FILES_DEPLOY_KEY }}
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: generated-files
|
||||
|
||||
@@ -40,6 +40,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: wasm32-unknown-unknown
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh wasm32-unknown-unknown
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
- name: Install mdbook and trunk
|
||||
run: |
|
||||
|
||||
@@ -101,6 +101,9 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: release-icons
|
||||
@@ -140,6 +143,9 @@ jobs:
|
||||
"https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm_${NFPM_VERSION}_${{ matrix.deb }}.deb"
|
||||
sudo dpkg -i "$RUNNER_TEMP/nfpm.deb"
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: release-linux-${{ matrix.arch }}
|
||||
@@ -325,6 +331,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh ${{ matrix.target }}
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: release-macos-${{ matrix.arch }}
|
||||
@@ -423,6 +432,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh ${{ matrix.target }}
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: release-windows-${{ matrix.arch }}
|
||||
@@ -554,6 +566,9 @@ jobs:
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: wasm32-unknown-unknown
|
||||
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
|
||||
shell: bash
|
||||
run: scripts/fetch-smlib.sh wasm32-unknown-unknown
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
|
||||
with:
|
||||
key: release-web
|
||||
|
||||
@@ -20,10 +20,11 @@ name = "solvecraft-cli"
|
||||
path = "src/alias.rs"
|
||||
|
||||
[features]
|
||||
default = ["raytrace-cpu"]
|
||||
default = ["raytrace-cpu", "smlib"]
|
||||
bundled-render-library = ["solidcraft-engine/bundled-render-library"]
|
||||
raytrace-cpu = ["solidcraft-engine/raytrace-cpu"]
|
||||
# Link SMLib into the kernel, for the regression rig's smlib runs (tests/kernel-cases).
|
||||
# Link SMLib into the kernel (solidcraft-engine/smlib; needs scripts/fetch-smlib.sh). SMLib is the
|
||||
# only kernel, so without it the command line models nothing.
|
||||
smlib = ["solidcraft-engine/smlib"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -14,10 +14,11 @@ name = "solidcraft-web"
|
||||
path = "src/main.rs"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["smlib"]
|
||||
bundled-render-library = ["solidcraft-engine/bundled-render-library"]
|
||||
# Link SMLib into the kernel (solidcraft-engine/smlib): needs scripts/fetch-smlib.sh and wasi-sdk in
|
||||
# WASI_SDK_PATH (crates/smlib/build.rs). Off by default until CI has wasi-sdk.
|
||||
# Link SMLib into the kernel (solidcraft-engine/smlib; needs scripts/fetch-smlib.sh
|
||||
# wasm32-unknown-unknown, or the sources and wasi-sdk in WASI_SDK_PATH, crates/smlib/build.rs). SMLib
|
||||
# is the only kernel, so without it the web app models nothing.
|
||||
smlib = ["solidcraft-engine/smlib"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -828,6 +828,9 @@ pub enum FeatureKind {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[walk(length = "Thread depth")]
|
||||
thread_depth: Option<Expr>,
|
||||
/// The tapped thread's hand: right (the default) or left; never both.
|
||||
#[serde(default, skip_serializing_if = "crate::thread_forms::is_default")]
|
||||
hand: crate::thread_forms::ThreadHand,
|
||||
/// To Object: drill down to the face (or point) here instead of `depth`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
to: Option<FacePick>,
|
||||
|
||||
@@ -6279,7 +6279,7 @@ fn eval_feature(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st:
|
||||
let extra: Vec<String> = if *operation == Operation::Join { to_body.into_iter().collect() } else { Vec::new() };
|
||||
apply_traced_with(doc, st, f, tools, *operation, &crate::plain(targets), &extra)
|
||||
}
|
||||
FeatureKind::Hole { thread, thread_depth, diameter, .. } => {
|
||||
FeatureKind::Hole { thread, thread_depth, diameter, hand, .. } => {
|
||||
let thread_depth = thread_depth.as_ref().map(|d| val(vals, d, Kind::Length)).transpose()?;
|
||||
if thread_depth.is_some() && thread.is_none() {
|
||||
return Err(DocError::Invalid("thread depth requires a tapped hole".into()));
|
||||
@@ -6306,7 +6306,7 @@ fn eval_feature(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st:
|
||||
} else {
|
||||
parallel_tapped_wall(st, p, dir, r).unwrap_or(p + dir.any_perp() * r + dir * (r * 0.5))
|
||||
};
|
||||
let ask = thread::ThreadAsk { designation: Some(d), tapped: true, ..Default::default() };
|
||||
let ask = thread::ThreadAsk { designation: Some(d), tapped: true, hand: *hand, ..Default::default() };
|
||||
let mut t = thread_on(st, f.id, wall, &ask)?.info;
|
||||
if let Some(depth) = thread_depth {
|
||||
let available = t.end - t.start;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//! A thread's direction is saved as `hand` on Hole features too (`right`, the default, not
|
||||
//! saved, or `left`), as Thread features already save it (`right`, `left` or `both`). Format 39
|
||||
//! (v0.24.0) saved the direction of both as `handedness: "left"`; this step renames it to
|
||||
//! `hand`, so a left-hand thread or tapped hole opens left-handed, and drops a `handedness:
|
||||
//! "right"`. Older designs have neither and need nothing. The last release refuses a design with
|
||||
//! this change (the newer format number).
|
||||
use serde_json::Value;
|
||||
|
||||
pub fn step(v: &mut Value) -> crate::Result<()> {
|
||||
let Some(Value::Array(features)) = v.get_mut("features") else {
|
||||
return Ok(());
|
||||
};
|
||||
for feature in features {
|
||||
let threaded = matches!(feature.get("type").and_then(Value::as_str), Some("hole" | "thread"));
|
||||
let Some(f) = feature.as_object_mut().filter(|_| threaded) else { continue };
|
||||
match f.remove("handedness") {
|
||||
None => {}
|
||||
Some(Value::String(h)) if h == "right" => {}
|
||||
Some(Value::String(h)) if h == "left" => {
|
||||
f.insert("hand".into(), Value::from("left"));
|
||||
}
|
||||
Some(other) => return Err(crate::DocError::Invalid(format!("a thread's `handedness` must be right or left, not {other}"))),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -69,7 +69,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.at("SOLID", "CREATE")
|
||||
.icon("hole")
|
||||
.key("H")
|
||||
.params("position: [x,y,z] on a face (numbers, or length expressions the hole follows) | sketch + points: [sketch point ids] (one hole each, perpendicular to the sketch, into the material on whichever side of the sketch plane it is) | sketch alone (every sketch point: standalone points and circle centres); flip?: bool (sketch points: drill to the other side); single?: bool (with one sketch point: a Single hole that follows the point, drilled into the face there); direction?: [x,y,z] (default: into the face, against its outward normal; one that leaves the face is mirrored into it; ignored with sketch points unless single); diameter | thread (a tapped hole: metric major minus pitch or tabulated UNC/UNF, G or Rp cut-tap drill) | clearance: \"M6\" with fit?: close|normal|loose (ISO 273); depth? (default through all) | to?: [x,y,z] (To Object: drill to that face or point); references?: [{edge: [x,y,z] on a straight edge of the face, distance: expr}] (at most two; the centre goes that far from each edge's line, in the face's plane, and follows the edges; with a numeric position only); type?: simple|drilled|counterbore|countersink; tip_angle?; cb_diameter?, cb_depth?; cs_diameter?, cs_angle?; thread?: \"M6\" or \"1/4-20 UNC\" (cosmetic); thread_depth?: positive length independent of drill depth (default: full useful cylindrical wall; must fit that wall); targets?: [body] (the bodies to drill; holes at the points of a sketch on a body's face default to that body, found along the holes' direction on it alone; explicit targets or participants override, [\"*\"] every body)"),
|
||||
.params("position: [x,y,z] on a face (numbers, or length expressions the hole follows) | sketch + points: [sketch point ids] (one hole each, perpendicular to the sketch, into the material on whichever side of the sketch plane it is) | sketch alone (every sketch point: standalone points and circle centres); flip?: bool (sketch points: drill to the other side); single?: bool (with one sketch point: a Single hole that follows the point, drilled into the face there); direction?: [x,y,z] (default: into the face, against its outward normal; one that leaves the face is mirrored into it; ignored with sketch points unless single); diameter | thread (a tapped hole: metric major minus pitch or tabulated UNC/UNF, G or Rp cut-tap drill) | clearance: \"M6\" with fit?: close|normal|loose (ISO 273); depth? (default through all) | to?: [x,y,z] (To Object: drill to that face or point); references?: [{edge: [x,y,z] on a straight edge of the face, distance: expr}] (at most two; the centre goes that far from each edge's line, in the face's plane, and follows the edges; with a numeric position only); type?: simple|drilled|counterbore|countersink; tip_angle?; cb_diameter?, cb_depth?; cs_diameter?, cs_angle?; thread?: \"M6\" or \"1/4-20 UNC\" (cosmetic); hand?: right|left (the tapped thread's hand; default right; needs thread); thread_depth?: positive length independent of drill depth (default: full useful cylindrical wall; must fit that wall); targets?: [body] (the bodies to drill; holes at the points of a sketch on a body's face default to that body, found along the holes' direction on it alone; explicit targets or participants override, [\"*\"] every body)"),
|
||||
CommandSpec::new("solid.pipe", "Pipe", pipe)
|
||||
.at("SOLID", "CREATE")
|
||||
.icon("pipe")
|
||||
@@ -2421,6 +2421,14 @@ fn hole(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
_ => None,
|
||||
};
|
||||
let thread = str_(p, "thread").map(|t| t.trim().to_string()).filter(|t| !t.is_empty());
|
||||
let hand = match str_(p, "hand") {
|
||||
None | Some("right") => solidcraft_doc::thread_forms::ThreadHand::Right,
|
||||
Some("left") => solidcraft_doc::thread_forms::ThreadHand::Left,
|
||||
Some(h) => return Err(bad(cmd, format!("unknown hand `{h}` (right or left)"))),
|
||||
};
|
||||
if thread.is_none() && hand != solidcraft_doc::thread_forms::ThreadHand::Right {
|
||||
return Err(bad(cmd, "`hand` needs `thread` (a tapped hole)"));
|
||||
}
|
||||
if let Some(t) = &thread
|
||||
&& solidcraft_doc::parse_tapped_thread(t).is_none()
|
||||
{
|
||||
@@ -2593,6 +2601,7 @@ fn hole(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
points: points.map(|x| x.0),
|
||||
thread,
|
||||
thread_depth,
|
||||
hand,
|
||||
to: to.map(FacePick),
|
||||
references,
|
||||
},
|
||||
|
||||
@@ -711,6 +711,42 @@ fn a_left_handed_thread_turns_the_other_way() {
|
||||
assert!(volumes[2] > want * 1.2 && volumes[2] < 2.0 * want, "{volumes:?}");
|
||||
}
|
||||
|
||||
/// A left-hand thread and tapped hole saved by v0.24.0 (format 39, `handedness: "left"`) open
|
||||
/// left-handed; a tapped hole takes `hand` like a thread, never `both`, and only with a thread.
|
||||
#[test]
|
||||
fn a_format_39_left_hand_thread_and_tapped_hole_open_left_handed() {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.box", json!({"length": 60, "width": 60, "height": 12, "body_name": "Plate"}));
|
||||
run(&mut s, "solid.hole", json!({"position": [20, 30, 12], "thread": "M6", "depth": 8, "hand": "left"}));
|
||||
run(&mut s, "solid.cylinder", json!({"radius": 5, "height": 9, "base": [80, 0, 0], "body_name": "Shaft", "operation": "new"}));
|
||||
run(&mut s, "solid.thread", json!({"face": [85, 0, 4.5], "designation": "M10", "hand": "left"}));
|
||||
let hands = |s: &Session| -> Vec<solidcraft_doc::thread_forms::ThreadHand> {
|
||||
s.model.state().threads.iter().map(|t| t.hand).collect()
|
||||
};
|
||||
let left = solidcraft_doc::thread_forms::ThreadHand::Left;
|
||||
assert_eq!(hands(&s), [left, left]);
|
||||
// What format 39 wrote: the direction as `handedness`, no pending changes.
|
||||
let mut v: Value = serde_json::from_str(&s.doc.to_json()).unwrap();
|
||||
v["format"] = json!("solidcraft/39");
|
||||
v.as_object_mut().unwrap().remove("format_pending");
|
||||
for f in v["features"].as_array_mut().unwrap() {
|
||||
if let Some(h) = f.as_object_mut().unwrap().remove("hand") {
|
||||
f["handedness"] = h;
|
||||
}
|
||||
}
|
||||
let reopened = Session::new(solidcraft_doc::Document::from_json(&v.to_string()).unwrap());
|
||||
assert_eq!(hands(&reopened), [left, left]);
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "solid.box", json!({"length": 60, "width": 60, "height": 12}));
|
||||
for (params, why) in [
|
||||
(json!({"position": [20, 30, 12], "thread": "M6", "depth": 8, "hand": "both"}), "unknown hand"),
|
||||
(json!({"position": [20, 30, 12], "depth": 8, "hand": "left"}), "needs `thread`"),
|
||||
] {
|
||||
let err = s.execute("solid.hole", ¶ms).unwrap_err().to_string();
|
||||
assert!(err.contains(why), "{err}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A trapezoidal nut: the groove from the drilled minor diameter D1 = d - P out to the
|
||||
/// internal root D4 = d + 2 ac (ISO 2904), 2π∫ r w(r) dr per turn.
|
||||
#[test]
|
||||
|
||||
@@ -222,7 +222,7 @@ fn find_group(app: &SolveApp, id: u64) -> Option<&solidcraft_engine::doc::Browse
|
||||
/// World bodies of a component picked in the tree. The root is the whole design; a nested
|
||||
/// component is its own placement, including bodies inside it.
|
||||
pub(crate) fn bodies_of_component(app: &SolveApp, id: u64) -> Vec<String> {
|
||||
let present: Vec<String> = app.session.world_state().bodies.iter().map(|b| b.name.clone()).collect();
|
||||
let present: Vec<String> = crate::open_meshing::session_world(&app.session).bodies.iter().map(|b| b.name.clone()).collect();
|
||||
let mut names = if id == 0 {
|
||||
present.clone()
|
||||
} else {
|
||||
@@ -261,7 +261,7 @@ fn offer_bodies(app: &mut SolveApp, names: &[String], take: Take) -> bool {
|
||||
if !dialog_takes_body(app) {
|
||||
return false;
|
||||
}
|
||||
let world = app.session.world_state();
|
||||
let world = crate::open_meshing::session_world(&app.session);
|
||||
let picked: Vec<Sel> =
|
||||
names.iter().filter(|n| world.body(n).is_some() && !app.session.body_removed_later(n)).map(|n| Sel::Body { name: n.clone() }).collect();
|
||||
if picked.is_empty() {
|
||||
|
||||
@@ -415,6 +415,8 @@ pub struct HoleOpts {
|
||||
/// Use the full useful cylindrical wall, independently of the drill extents.
|
||||
pub thread_full_depth: bool,
|
||||
pub thread_depth: String,
|
||||
/// The tapped thread's hand (right or left).
|
||||
pub hand: solidcraft_engine::doc::thread_forms::ThreadHand,
|
||||
}
|
||||
|
||||
impl Default for HoleOpts {
|
||||
@@ -430,6 +432,7 @@ impl Default for HoleOpts {
|
||||
refs: Default::default(),
|
||||
thread_full_depth: true,
|
||||
thread_depth: "10 mm".into(),
|
||||
hand: solidcraft_engine::doc::thread_forms::ThreadHand::Right,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4403,6 +4406,9 @@ fn dialog_commands(app: &SolveApp, d: &Dialog) -> Result<Vec<(String, Value)>, S
|
||||
if !opts.thread_full_depth {
|
||||
params["thread_depth"] = json!(opts.thread_depth.trim());
|
||||
}
|
||||
if opts.hand != solidcraft_engine::doc::thread_forms::ThreadHand::Right {
|
||||
params["hand"] = json!(opts.hand);
|
||||
}
|
||||
}
|
||||
match *kind {
|
||||
1 => {
|
||||
@@ -5307,7 +5313,7 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia
|
||||
d.extra.insert("pull".into(), pt3(pull.0));
|
||||
d
|
||||
}
|
||||
FeatureKind::Hole { position, at, direction, diameter, depth, hole, points, thread, thread_depth, to, references } => {
|
||||
FeatureKind::Hole { position, at, direction, diameter, depth, hole, points, thread, thread_depth, hand, to, references } => {
|
||||
let mut d = start("solid.hole")?;
|
||||
let mut k = hole_defaults(s);
|
||||
if let Kind::Hole { diameter: dia, depth: dep, kind, cb_diameter, cb_depth, cs_diameter, cs_angle, opts } = &mut k {
|
||||
@@ -5318,6 +5324,7 @@ pub fn for_feature(app: &SolveApp, id: u64, marker: Option<usize>) -> Option<Dia
|
||||
if let Some(th) = thread {
|
||||
opts.tapped = true;
|
||||
opts.thread = th.clone();
|
||||
opts.hand = *hand;
|
||||
}
|
||||
opts.thread_full_depth = thread_depth.is_none();
|
||||
if let Some(depth) = thread_depth {
|
||||
|
||||
@@ -526,6 +526,7 @@ pub(super) fn rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui:
|
||||
});
|
||||
if opts.tapped {
|
||||
enter |= crate::dialogs_thread::hole_rows(ui, &app.session.doc, &mut opts.thread, &mut opts.custom_thread);
|
||||
crate::dialogs_thread::hole_hand_row(ui, &mut opts.hand);
|
||||
ui_kit::checkbox_grid(ui, &mut [("Full thread depth", &mut opts.thread_full_depth)], 1);
|
||||
}
|
||||
// Through all, the tip lies past the part.
|
||||
|
||||
@@ -166,6 +166,8 @@ const FORMS: &[(&str, ThreadForm)] = &[
|
||||
("Buttress (ASME B1.9)", ThreadForm::ButtressAsme),
|
||||
];
|
||||
const HANDS: &[(&str, ThreadHand)] = &[("Right", ThreadHand::Right), ("Left", ThreadHand::Left), ("Both", ThreadHand::Both)];
|
||||
/// A tapped hole's hands: one groove, so never both.
|
||||
const HOLE_HANDS: &[(&str, ThreadHand)] = &[("Right", ThreadHand::Right), ("Left", ThreadHand::Left)];
|
||||
const STARTS: &[(&str, u32)] = &[("1", 1), ("2", 2), ("3", 3), ("4", 4), ("5", 5), ("6", 6), ("7", 7), ("8", 8)];
|
||||
const FULL: usize = 0;
|
||||
const LENGTH: usize = 1;
|
||||
@@ -321,6 +323,11 @@ fn change_form(designation: &mut String, suggested: &mut Option<String>, from: T
|
||||
}
|
||||
|
||||
/// A choice row over typed values.
|
||||
/// The hole dialog's Hand row for a tapped hole, the same choice the thread dialog offers.
|
||||
pub(crate) fn hole_hand_row(ui: &mut egui::Ui, hand: &mut ThreadHand) {
|
||||
pick(ui, "Hand", "hole_hand", hand, HOLE_HANDS);
|
||||
}
|
||||
|
||||
fn pick<T: Copy + PartialEq>(ui: &mut egui::Ui, label: &str, id: &str, value: &mut T, choices: &[(&str, T)]) {
|
||||
let labels: Vec<&str> = choices.iter().map(|c| c.0).collect();
|
||||
let mut index = choices.iter().position(|c| c.1 == *value).unwrap_or(0);
|
||||
|
||||
@@ -35,6 +35,8 @@ enum Extent {
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
struct ThreadOptions {
|
||||
/// `right` or `left`, under the name v0.24.0 saved it with.
|
||||
handedness: String,
|
||||
full_length: bool,
|
||||
depth: Option<String>,
|
||||
#[serde(flatten)]
|
||||
@@ -43,7 +45,7 @@ struct ThreadOptions {
|
||||
|
||||
impl Default for ThreadOptions {
|
||||
fn default() -> Self {
|
||||
Self { full_length: true, depth: None, unknown: BTreeMap::new() }
|
||||
Self { handedness: "right".into(), full_length: true, depth: None, unknown: BTreeMap::new() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +108,7 @@ impl Preset {
|
||||
}
|
||||
if required.into_iter().any(|text| text.trim().is_empty())
|
||||
|| self.thread_options.depth.as_ref().is_some_and(|text| !valid_text(text, MAX_EXPRESSION))
|
||||
|| !["right", "left"].contains(&self.thread_options.handedness.as_str())
|
||||
|| self.thread_options.unknown.len() > 8
|
||||
|| self.thread_options.unknown.iter().any(|(key, value)| {
|
||||
key.is_empty()
|
||||
@@ -183,6 +186,7 @@ impl Preset {
|
||||
thread: opts.thread.clone(),
|
||||
thread_options: if opts.tapped {
|
||||
ThreadOptions {
|
||||
handedness: if opts.hand == solidcraft_engine::doc::thread_forms::ThreadHand::Left { "left".into() } else { "right".into() },
|
||||
full_length: opts.thread_full_depth,
|
||||
depth: if opts.thread_full_depth { None } else { Some(portable_length(&opts.thread_depth, true)?) },
|
||||
unknown: BTreeMap::new(),
|
||||
@@ -262,6 +266,8 @@ impl Preset {
|
||||
opts.thread.clone_from(&self.thread);
|
||||
opts.custom_thread = None;
|
||||
opts.thread_full_depth = self.thread_options.full_length;
|
||||
opts.hand =
|
||||
if self.thread_options.handedness == "left" { solidcraft_engine::doc::thread_forms::ThreadHand::Left } else { solidcraft_engine::doc::thread_forms::ThreadHand::Right };
|
||||
opts.thread_depth = self.thread_options.depth.clone().unwrap_or_else(|| crate::dialogs::HoleOpts::default().thread_depth);
|
||||
// Existing placement picks stay with this dialog. To Object stores its mode only:
|
||||
// recalling it always asks for a fresh destination in the current design.
|
||||
|
||||
@@ -10,8 +10,8 @@ cargo xtask kernel-cases --cli target/release/solidcraft-cli --out /tmp/run #
|
||||
cargo run -p solidcraft-cli --features smlib -- kernel-cases tests/kernel-cases/booleans/<id> # one case
|
||||
```
|
||||
|
||||
The CLI needs `--features smlib` (after `scripts/fetch-smlib.sh`); without it every operation
|
||||
answers that SMLib is not built. The run's output folder (`--out`, default `target/kernel-cases`)
|
||||
The CLI links SMLib by default (`scripts/fetch-smlib.sh` fetches the prebuilt library first);
|
||||
built with `--no-default-features`, every operation answers that SMLib is not built. The run's output folder (`--out`, default `target/kernel-cases`)
|
||||
gets `results.json`, every case's full result, and `dumps/<area>-<case>/`: the inputs of each
|
||||
SMLib call a case failed in, for replay (the CLI's `--dumps=DIR`, which the rig always passes).
|
||||
|
||||
|
||||
Reference in new issue
Block a user