Merge develop 322ac259 into solidcore (via ws/develop-sync-1030: SMLib 90aabff test expectations, the closed-sheet offset and cylinder draft ports)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MNXLXkZLQ6T7TSi4wswcmk
This commit is contained in:
Brett LawsonandClaude Opus 5.5 committed 2026-10-30 04:17:44 +01:00
commit 7b0b1f63b7
828 files changed
+39126 -757

No files matched your search

+10
View File
@@ -31,6 +31,8 @@
# `ci` job still runs and reports the commit's real result (see the `ci` job): the merge queue
# reads `ci` from the newest run of a commit, so a run without it would block a PR that passed.
# Cross-compilation is opt-in through Run workflow; release builds remain in release.yml.
# The release gate (release-gate.yml) calls this workflow (workflow_call) as a Run workflow with
# cross-compilation on.
# Every Linux job runs on Blacksmith's Ubuntu 24.04 runners (blacksmith-<N>vcpu-ubuntu-2404), sized
# per job: 32 vCPU for the tests, 16 for Clippy, the GPU path tests, the archive build (nightly) and the merge queue's, 8 for compiles, doc and reference tests, 4 for the light checks, 2 for Select checks and ci.
# The Windows shader job runs on Blacksmith's Windows Server 2025 runners (blacksmith-8vcpu-windows-2025);
@@ -64,6 +66,14 @@ on:
description: "Also check WebAssembly and RISC-V (before a release)"
type: boolean
default: false
# The release gate (release-gate.yml): the event stays the caller's (workflow_dispatch), so a
# call runs exactly what Run workflow runs.
workflow_call:
inputs:
cross_compile:
description: "Also check WebAssembly and RISC-V (before a release)"
type: boolean
default: false
permissions:
contents: read
+234
View File
@@ -0,0 +1,234 @@
# The kernel rig and the complexity ladder as a regression gate. A plan job maps a pull request's
# changed files to the rig areas they can affect (scripts/ci/kernel_rig_plan.py): an area runs
# when a file its tests/kernel-cases/<area>/PATHS lists changes, or one of its cases; every area
# runs when the shared core in tests/kernel-cases/PATHS-ALL changes; the ladder runs whenever any
# area does. One job then builds solidcraft-cli once (release, SMLib prebuilt), checks that every
# registry command has a case or an exemption (tests/kernel-cases/EXEMPT), and hands the CLI to a
# matrix of shards as an artifact, one per selected area plus the ladder, in parallel, so the
# wall time is the build plus the slowest shard. See tests/kernel-cases/README.md.
#
# - An area fails on a regression (a case that fails and its tests/kernel-cases/<area>/KNOWN_FAILING
# does not list) or on a listed case that passes (it is fixed: remove its line in the same pull
# request, so the list only shrinks).
# - The ladder fails on any case whose status or counts differ from
# tests/kernel-cases/ladder/golden.json; a right change is re-recorded (`--record "why"`).
#
# The trigger paths are whole folders that hold every area's PATHS (a self-test,
# scripts/ci/test_kernel_rig_plan.py, checks they do), so a pull request that touches none of
# them (the UI, docs, packaging) starts no runner at all, and a new area needs no edit here: the
# plan finds the areas from the folders. Pushes to main and develop on the same paths, merge groups
# (once the queue is on), the release gate (release-gate.yml, workflow_call) and a run by hand run
# every area; those pushes also commit the compiler cache (a Blacksmith sticky disk) that every
# other run mounts read-only.
name: Kernel rig
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- "crates/kernel/**"
- "crates/geom/**"
- "crates/smlib/**"
- "crates/step/**"
- "crates/io/src/**"
- "crates/doc/src/**"
- "crates/engine/src/**"
- "tests/kernel-cases/**"
# The rig itself: the grading, the runner, the selection and this workflow.
- "apps/solidcraft-cli/src/kernel_cases.rs"
- "xtask/src/kernel_cases.rs"
- "xtask/src/kernel_ladder.rs"
- "scripts/fetch-smlib.sh"
- "scripts/ci/kernel_rig_plan.py"
- "scripts/ci/test_kernel_rig_plan.py"
- ".github/workflows/kernel-rig.yml"
push:
branches: [main, develop]
# The same paths as pull_request.
paths:
- "crates/kernel/**"
- "crates/geom/**"
- "crates/smlib/**"
- "crates/step/**"
- "crates/io/src/**"
- "crates/doc/src/**"
- "crates/engine/src/**"
- "tests/kernel-cases/**"
# The rig itself: the grading, the runner, the selection and this workflow.
- "apps/solidcraft-cli/src/kernel_cases.rs"
- "xtask/src/kernel_cases.rs"
- "xtask/src/kernel_ladder.rs"
- "scripts/fetch-smlib.sh"
- "scripts/ci/kernel_rig_plan.py"
- "scripts/ci/test_kernel_rig_plan.py"
- ".github/workflows/kernel-rig.yml"
merge_group:
workflow_call:
workflow_dispatch:
permissions:
contents: read
concurrency:
# A new push to a pull request replaces its old run.
group: kernel-rig-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
jobs:
plan:
name: Select the rig areas
# Draft pull requests run no CI, as in ci.yml.
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: blacksmith-2vcpu-ubuntu-2404
timeout-minutes: 5
outputs:
# The shard matrix (JSON list of areas and the ladder; [] when nothing is selected).
shards: ${{ steps.plan.outputs.shards }}
# Whether the build job, and with it the coverage check, runs.
build: ${{ steps.plan.outputs.build }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# A pull request's diff needs its base's history.
fetch-depth: ${{ github.event_name == 'pull_request' && '0' || '1' }}
- name: Selection self-test
run: python3 -I scripts/ci/test_kernel_rig_plan.py
- id: plan
name: Map the changed files to areas
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# Pull requests run the areas their diff reaches; pushes, merge groups, the release
# gate and a run by hand run every area.
if [ "$EVENT_NAME" = pull_request ]; then
git diff --no-renames --name-only -z "$BASE_SHA...$HEAD_SHA" > "$RUNNER_TEMP/rig-paths"
python3 -I scripts/ci/kernel_rig_plan.py --paths "$RUNNER_TEMP/rig-paths" --github-output "$GITHUB_OUTPUT"
else
python3 -I scripts/ci/kernel_rig_plan.py --all --github-output "$GITHUB_OUTPUT"
fi
build:
name: Build the CLI
needs: plan
if: needs.plan.outputs.build == 'true'
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 60
env:
CARGO_INCREMENTAL: "0"
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /home/runner/.cache/sccache
SCCACHE_CACHE_SIZE: 10G
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Size parallel compiles to the job's memory
run: scripts/ci/build-jobs.sh
- uses: dtolnay/rust-toolchain@stable
# Only pushes to main and develop commit the cache; pull requests, merge groups and forks
# mount a clone and never write back.
- name: Mount the compiler cache
uses: useblacksmith/stickydisk@3f6be1451e3cad893b778bc93495c80452a5da26 # v1.7.2
continue-on-error: true
with:
key: ${{ github.repository }}-sccache-kernel-rig
path: /home/runner/.cache/sccache
commit: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') && 'on-change' || 'false' }}
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
key: kernel-rig
save-if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') }}
- name: Fetch SMLib (crates/smlib/SMLIB_REV)
shell: bash
run: scripts/fetch-smlib.sh
- name: Set up compiler cache
uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
with:
version: v0.16.0
- name: Build the CLI (release, SMLib) and the rig's runner
run: |
cargo build --release --locked -p solidcraft-cli --features smlib
cargo build --locked -p xtask
# A tar keeps the executable bits, which an artifact drops. xtask finds the repository from
# the path it was built in (CARGO_MANIFEST_DIR), which is the same checkout path in every
# job of this workflow.
# Every registry command is used by a case or listed in tests/kernel-cases/EXEMPT.
- name: Every command has a case
run: target/debug/xtask kernel-cases --coverage --cli target/release/solidcraft-cli
# A coverage-only run (the registry or the cases changed, no area selected) runs no shard.
- name: Pack the binaries
if: needs.plan.outputs.shards != '[]'
run: tar -cf "$RUNNER_TEMP/kernel-rig-bin.tar" -C target release/solidcraft-cli debug/xtask
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: needs.plan.outputs.shards != '[]'
with:
name: kernel-rig-bin
path: ${{ runner.temp }}/kernel-rig-bin.tar
retention-days: 1
- name: Compiler cache statistics
if: always()
run: sccache --show-stats
shard:
name: Kernel rig (${{ matrix.shard }})
needs: [plan, build]
if: needs.plan.outputs.shards != '[]'
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
# The areas of tests/kernel-cases/ the plan selected, and the ladder. On the build box
# (aarch64, 4 cases at a time) the slowest areas took about 1 minute (booleans, 212 s of
# cases with one of 84 s; threads, 161 s) and the ladder, one case at a time, 92 s: no area
# needs splitting.
shard: ${{ fromJSON(needs.plan.outputs.shards) }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: kernel-rig-bin
path: ${{ runner.temp }}
- name: Unpack the binaries
run: mkdir -p target && tar -xf "$RUNNER_TEMP/kernel-rig-bin.tar" -C target
- name: Run the cases against the known-failing list (the ladder against its golden)
env:
SHARD: ${{ matrix.shard }}
run: |
if [ "$SHARD" = ladder ]; then
set -- --ladder --gate
else
set -- --area "$SHARD" --known-failing "tests/kernel-cases/$SHARD/KNOWN_FAILING"
fi
target/debug/xtask kernel-cases "$@" --cli target/release/solidcraft-cli --out "$RUNNER_TEMP/kernel-rig"
- name: Keep the results
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: kernel-rig-results-${{ matrix.shard }}
path: ${{ runner.temp }}/kernel-rig/results.json
if-no-files-found: ignore
# One check for the whole gate, for branch protection and the merge queue.
kernel-rig:
name: kernel-rig
needs: [plan, build, shard]
if: always() && (github.event_name != 'pull_request' || !github.event.pull_request.draft)
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
# A skipped build or shard counts as passed only when the plan selected none.
- name: Every selected job passed
env:
PLAN: ${{ needs.plan.result }}
WANT_BUILD: ${{ needs.plan.outputs.build }}
WANT_SHARDS: ${{ needs.plan.outputs.shards }}
BUILD: ${{ needs.build.result }}
SHARDS: ${{ needs.shard.result }}
run: |
echo "plan=$PLAN build=$BUILD shards=$SHARDS selected=$WANT_SHARDS"
test "$PLAN" = success
if [ "$WANT_BUILD" = true ]; then test "$BUILD" = success; else test "$BUILD" = skipped; fi
if [ "$WANT_SHARDS" != '[]' ]; then test "$SHARDS" = success; else test "$SHARDS" = skipped; fi
+74
View File
@@ -0,0 +1,74 @@
# The release gate: everything, in full and in parallel, on one branch's head, before that branch
# replaces main as a release (develop, rebased onto main). Run it by hand:
# gh workflow run release-gate.yml --ref develop
# It calls the workflows that own each check instead of copying their jobs:
# - ci.yml as Run workflow with cross-compilation: every native suite in full (not scoped), the
# reference tests, the doc tests, the GPU path tests, the action matrix (all 16 shards) and its
# determinism check, the property tests, the repository checks (web-offline among them),
# WebAssembly and RISC-V, Windows D3D12 FXC and Windows app startup;
# - kernel-rig.yml: every rig area against its KNOWN_FAILING and the ladder against its golden;
# - release.yml as a dry run (draft false, packages_only): the Linux, Flatpak, Snap, FreeBSD,
# macOS, Windows and web packages with their smoke tests and package checks, unsigned (no
# secrets are passed, so no signing secret or SignPath quota is used) and without the release
# job (checksums, update signing, publishing).
# The gate passes only when all three pass. Before main is replaced, tag the old main
# (main-before-develop-<date>) and push the tag.
name: Release gate
on:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-gate-${{ github.ref }}
cancel-in-progress: false
jobs:
ci:
name: CI
uses: ./.github/workflows/ci.yml
permissions:
contents: read
# Select checks reads this commit's other runs.
actions: read
with:
cross_compile: true
kernel-rig:
name: Kernel rig
uses: ./.github/workflows/kernel-rig.yml
permissions:
contents: read
packages:
name: Packages
uses: ./.github/workflows/release.yml
# No secrets: the signing steps skip without them. GitHub checks a called workflow's job
# permissions before the run, skipped jobs included, so the release job's contents: write must
# be granted here; packages_only skips that job, and no step that runs writes to the
# repository. actions: read is the Windows job's.
permissions:
contents: write
actions: read
with:
draft: false
packages_only: true
release-gate:
name: release-gate
needs: [ci, kernel-rig, packages]
if: always()
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Every part passed
env:
CI: ${{ needs.ci.result }}
KERNEL_RIG: ${{ needs.kernel-rig.result }}
PACKAGES: ${{ needs.packages.result }}
run: |
echo "ci=$CI kernel-rig=$KERNEL_RIG packages=$PACKAGES"
test "$CI" = success
test "$KERNEL_RIG" = success
test "$PACKAGES" = success
+23 -1
View File
@@ -20,6 +20,8 @@
# releases/latest/download/<name> links in the README keep working across releases.
#
# A dry run: dispatch with draft=false (the default). Only the release branch may create drafts.
# The release gate (release-gate.yml) calls it as such a dry run, without secrets (unsigned) and
# without the release job (packages_only).
# A dry run from any branch also test-signs the Windows files when SIGNPATH_API_TOKEN exists:
# gh workflow run release.yml --ref <branch> -f draft=false [-f signpath_signing_policy=test-signing]
name: Release
@@ -40,6 +42,25 @@ on:
description: "SignPath signing policy for the Windows files (empty: the repository variable, else test-signing)"
type: string
default: ""
# The release gate (release-gate.yml): a dry run (draft false) of every package and its checks.
# The event stays the caller's (workflow_dispatch), so a call runs as a dispatched dry run does.
# The gate passes no secrets, so nothing is signed (the signing steps skip without their
# secrets, as on a fork), and packages_only skips the release job (checksums, update signing,
# publishing).
workflow_call:
inputs:
packages_only:
description: "Build and check every package only: no release job"
type: boolean
default: false
draft:
description: "Create/update a draft (release branch only; off: build artifacts only)"
type: boolean
default: false
signpath_signing_policy:
description: "SignPath signing policy for the Windows files (empty: the repository variable, else test-signing)"
type: string
default: ""
permissions:
contents: read
@@ -587,7 +608,8 @@ jobs:
release:
name: GitHub Release or dry-run artifacts
needs: [version, linux, flatpak, snap, freebsd, macos, windows, web]
if: needs.version.outputs.build == 'true'
# Not for the release gate (packages_only): it builds and checks the packages, nothing more.
if: needs.version.outputs.build == 'true' && !inputs.packages_only
runs-on: ubuntu-latest
permissions:
contents: write
+2 -1
View File
@@ -241,7 +241,8 @@ the surface itself). Expected values are either worked out in closed form
(`tools/oracle-analytic/`) or computed by building the same recipe in FreeCAD, run as a separate
program (`tools/freecad-oracle/`); each file says which. The generated
[reference test report](docs/oracle.md) has the current case count and results. The reference-test
CI job runs `cargo xtask oracle` during full validation; pull-request runs skip it. A case that
CI job runs `cargo xtask oracle` during full validation, and on pull requests that reach
`solidcraft-cli`. A case that
fails because of a known bug names its issue in `expected.json` (`"known_failure": "#123"`);
never change an expected value to match SolidCraft's output.
+601 -4
View File
@@ -258,6 +258,316 @@ fn continuity_order(
Ok((got, ok))
}
/// Where `got` differs from `want`, a part of it: every key of a `want` object in `got` and
/// matching, an array element by element and as long, a whole number exactly, any other number
/// within `rel` of it (relative, at least 1 absolute), anything else equal. `None` where it
/// matches; else the path to the first difference with both values.
fn json_mismatch(got: &Value, want: &Value, rel: f64, abs: f64, path: &str) -> Option<String> {
let differ = || Some(format!("{path}: got {got}, want {want}"));
match (got, want) {
(_, Value::Object(w)) => {
let Value::Object(g) = got else { return differ() };
w.iter().find_map(|(k, wv)| match g.get(k) {
Some(gv) => json_mismatch(gv, wv, rel, abs, &format!("{path}.{k}")),
None => Some(format!("{path}.{k}: missing, want {wv}")),
})
}
(_, Value::Array(w)) => {
let Value::Array(g) = got else { return differ() };
if g.len() != w.len() {
return Some(format!("{path}: {} items, want {}", g.len(), w.len()));
}
g.iter().zip(w).enumerate().find_map(|(i, (gv, wv))| json_mismatch(gv, wv, rel, abs, &format!("{path}[{i}]")))
}
(_, Value::Number(w)) if w.is_i64() || w.is_u64() => (got.as_f64() != w.as_f64()).then(differ).flatten(),
(_, Value::Number(w)) => {
let (g, w) = (got.as_f64(), w.as_f64().unwrap_or(f64::NAN));
(!g.is_some_and(|g| g.is_finite() && (g - w).abs() <= (rel * w.abs().max(1.0)).max(abs))).then(differ).flatten()
}
_ => (got != want).then(differ).flatten(),
}
}
/// The rows of a CSV text (RFC 4180: quoted fields may hold commas, quotes and line breaks) as
/// objects keyed by the header row; a field that reads as a number is one.
fn csv_rows(text: &str) -> Vec<Value> {
let mut records: Vec<Vec<String>> = Vec::new();
let (mut row, mut field, mut quoted, mut chars) = (Vec::new(), String::new(), false, text.chars().peekable());
while let Some(c) = chars.next() {
match (c, quoted) {
('"', true) if chars.peek() == Some(&'"') => {
chars.next();
field.push('"');
}
('"', _) => quoted = !quoted,
(',', false) => row.push(std::mem::take(&mut field)),
('\r', false) => {}
('\n', false) => {
row.push(std::mem::take(&mut field));
records.push(std::mem::take(&mut row));
}
_ => field.push(c),
}
}
if !field.is_empty() || !row.is_empty() {
row.push(field);
records.push(row);
}
let Some((head, rows)) = records.split_first() else { return Vec::new() };
rows.iter()
.map(|r| {
let cell = |v: &String| v.parse::<f64>().ok().filter(|x| x.is_finite()).map_or_else(|| json!(v), |x| json!(x));
Value::Object(head.iter().cloned().zip(r.iter().map(cell)).collect())
})
.collect()
}
/// Per layer of a DXF text's ENTITIES section, how many of each entity it has and the total
/// length of its curves (`length_mm`: lines, arcs, circles, ellipses and polylines; a spline makes
/// the layer's length null, as not measured): `{layer: {"LINE": n, …, "length_mm": l}}`.
fn dxf_layers(text: &str) -> Value {
let lines: Vec<&str> = text.lines().map(str::trim).collect();
let pairs: Vec<(&str, &str)> = lines.chunks(2).filter_map(|p| Some((*p.first()?, *p.get(1)?))).collect();
let start = pairs.windows(2).position(|w| w[0] == ("0", "SECTION") && w[1] == ("2", "ENTITIES")).map_or(pairs.len(), |i| i + 2);
let mut layers = serde_json::Map::new();
let mut i = start;
while let Some(&(code, kind)) = pairs.get(i) {
if code != "0" || kind == "ENDSEC" {
break;
}
let end = pairs.get(i + 1..).and_then(|r| r.iter().position(|p| p.0 == "0")).map_or(pairs.len(), |k| i + 1 + k);
let group = pairs.get(i + 1..end).unwrap_or(&[]);
let num = |c: &str| group.iter().find(|p| p.0 == c).and_then(|p| p.1.parse::<f64>().ok()).unwrap_or(0.0);
let all = |c: &str| group.iter().filter(|p| p.0 == c).filter_map(|p| p.1.parse::<f64>().ok()).collect::<Vec<_>>();
let layer = group.iter().find(|p| p.0 == "8").map_or("0", |p| p.1);
let length = match kind {
"LINE" => Some((num("11") - num("10")).hypot(num("21") - num("20"))),
"CIRCLE" => Some(std::f64::consts::TAU * num("40")),
"ARC" => Some(num("40") * (num("51") - num("50")).rem_euclid(360.0).to_radians()),
"LWPOLYLINE" => {
let mut pts: Vec<(f64, f64)> = all("10").into_iter().zip(all("20")).collect();
if (num("70") as i64) & 1 == 1
&& let Some(&p) = pts.first()
{
pts.push(p);
}
Some(pts.windows(2).map(|w| (w[1].0 - w[0].0).hypot(w[1].1 - w[0].1)).sum())
}
"ELLIPSE" => {
// Arc length of c + cos t·major + sin t·ratio·minor, t from 41 to 42, by Simpson's rule.
let (a, b) = (num("11").hypot(num("21")), num("11").hypot(num("21")) * num("40"));
let (t0, t1) = (num("41"), num("42"));
let sweep = if t1 > t0 { t1 - t0 } else { t1 - t0 + std::f64::consts::TAU };
let n = 4096;
let speed = |t: f64| (a * t.sin()).hypot(b * t.cos());
let h = sweep / n as f64;
let weight = |k: usize| match k {
0 => 1.0,
k if k == n => 1.0,
k if k % 2 == 1 => 4.0,
_ => 2.0,
};
let sum: f64 = (0..=n).map(|k| speed(t0 + k as f64 * h) * weight(k)).sum();
Some(sum * h / 3.0)
}
_ => None,
};
let entry = layers.entry(layer.to_string()).or_insert_with(|| json!({"length_mm": 0.0}));
entry[kind] = json!(entry[kind].as_u64().unwrap_or(0) + 1);
entry["length_mm"] = match (entry["length_mm"].as_f64(), length) {
(Some(l), Some(more)) => json!(l + more),
_ => Value::Null,
};
i = end;
}
Value::Object(layers)
}
/// The `files` check of the files a case wrote to `$OUT` (`out`): each `{path, json | csv | dxf}`
/// read and matched as [`json_mismatch`] does: `json` against the file's JSON, `csv` against its
/// rows ([`csv_rows`]), `dxf` against its layers ([`dxf_layers`]), a count there exact or an
/// inclusive range `[min, max]`. And the `results` check of the commands' own answers: each
/// `{step, pointer?, json, rel?, abs_mm?}`, the answer of the `step`th command (from 1, base
/// commands included), or its part at the JSON `pointer` (RFC 6901), matched against `json`,
/// a number within the entry's `rel` (or the case's) or its `abs_mm`.
fn output_checks(c: &mut Checks, want: &Value, out: &str, results: &[Value], rel: f64) {
for f in want["files"].as_array().into_iter().flatten() {
let path = f["path"].as_str().unwrap_or_default();
let what = format!("file {path}");
let text = match std::fs::read_to_string(std::path::Path::new(out).join(path)) {
Ok(t) => t,
Err(e) => {
c.push(&what, json!(e.to_string()), json!("written"), false);
continue;
}
};
let (got, wanted) = if let Some(w) = f.get("json") {
(serde_json::from_str::<Value>(&text).unwrap_or_else(|e| json!(format!("not JSON: {e}"))), w.clone())
} else if let Some(w) = f.get("csv") {
(Value::Array(csv_rows(&text)), w.clone())
} else if let Some(w) = f.get("dxf") {
let layers = dxf_layers(&text);
// A count given as a range is in it: compare the count itself with the range's bounds.
let mut w = w.clone();
let mut ranged = Vec::new();
for (layer, kinds) in w.as_object_mut().into_iter().flatten() {
for (kind, n) in kinds.as_object_mut().into_iter().flatten() {
if let Some([lo, hi]) = n.as_array().and_then(|r| <[Value; 2]>::try_from(r.clone()).ok()) {
let g = layers[layer.as_str()][kind.as_str()].as_u64().unwrap_or(0);
ranged.push((format!("{layer}.{kind}"), g, lo.clone(), hi.clone()));
*n = json!(g);
}
}
}
for (k, g, lo, hi) in ranged {
let ok = lo.as_u64().is_some_and(|lo| g >= lo) && hi.as_u64().is_some_and(|hi| g <= hi);
c.push(&format!("{what} {k}"), json!(g), json!([lo, hi]), ok);
}
// An entity the case names but the layer lacks counts 0.
let mut got = layers;
for (layer, kinds) in w.as_object().into_iter().flatten() {
for kind in kinds.as_object().into_iter().flatten().map(|(k, _)| k) {
if got[layer.as_str()].get(kind.as_str()).is_none() && kind != "length_mm" {
got[layer.as_str()][kind.as_str()] = json!(0);
}
}
}
(got, w)
} else {
c.push(&what, json!(f), json!("json, csv or dxf"), false);
continue;
};
let miss = json_mismatch(&got, &wanted, rel, 0.0, "");
c.push(&what, json!(miss.clone().unwrap_or_else(|| "matches".into())), wanted, miss.is_none());
}
for r in want["results"].as_array().into_iter().flatten() {
let step = r["step"].as_u64().unwrap_or(0);
let pointer = r["pointer"].as_str().unwrap_or("");
let what = format!("result of step {step}{pointer}");
let (rel, abs) = (r["rel"].as_f64().unwrap_or(rel), r["abs_mm"].as_f64().unwrap_or(0.0));
let got = step.checked_sub(1).and_then(|i| results.get(i as usize));
let miss = match got.map(|g| g.pointer(pointer)) {
Some(Some(g)) => json_mismatch(g, &r["json"], rel, abs, ""),
Some(None) => Some(format!("no {pointer} in step {step}'s answer")),
None => Some(format!("no step {step} of {}", results.len())),
};
c.push(&what, json!(miss.clone().unwrap_or_else(|| "matches".into())), r["json"].clone(), miss.is_none());
}
}
/// The word a `surface_types` check names a face's surface by, as the record holds it: an
/// analytic kind, `bspline` (a B-spline or NURBS surface) or `revolution` (a revolved curve).
fn surface_word(s: &solidcraft_engine::geom::brep::Surface) -> &'static str {
use solidcraft_engine::geom::brep::Surface as S;
match s {
S::Plane { .. } | S::PlaneThrough { .. } => "plane",
S::Cylinder { .. } => "cylinder",
S::Cone { .. } => "cone",
S::Sphere { .. } => "sphere",
S::Torus { .. } => "torus",
S::Spline { .. } | S::RationalSpline { .. } => "bspline",
S::PlacedRevolution { .. } => "revolution",
}
}
/// A B-spline face's two directions as `[degree, spans]` (spans: the distinct knot intervals of
/// the modelled range), the lower first, so a surface parameterised the other way round reads the
/// same. `None` for a surface that is not a B-spline.
fn spline_shape(s: &solidcraft_engine::geom::brep::Surface) -> Option<[[u64; 2]; 2]> {
use solidcraft_engine::geom::brep::Surface as S;
let (u, v, nu, nv) = match s {
S::Spline { u_knots, v_knots, points } => (u_knots, v_knots, points.len(), points.first().map_or(0, Vec::len)),
S::RationalSpline { u_knots, v_knots, homogeneous } => (u_knots, v_knots, homogeneous.len(), homogeneous.first().map_or(0, Vec::len)),
_ => return None,
};
let dir = |k: &[f64], n: usize| -> Option<[u64; 2]> {
let p = k.len().checked_sub(n + 1)?;
let inner = k.get(p..=n)?;
let spans = inner.windows(2).filter(|w| w[1] > w[0]).count();
Some([p as u64, spans as u64])
};
let (a, b) = (dir(u, nu)?, dir(v, nv)?);
Some(if a <= b { [a, b] } else { [b, a] })
}
/// The `splines` check: every B-spline face of the bodies matches one entry of `want` and every
/// entry one face (`{degree: [p, q], spans?: [m, n]}`, in either order of directions; without
/// `spans` only the degrees are graded). `Ok(got)` with what the faces are, `ok` when they match.
fn splines_match(faces: &[[[u64; 2]; 2]], want: &Value) -> Result<(Value, bool), String> {
let list = want.as_array().ok_or("`splines` must be a list of {degree: [p, q], spans?: [m, n]}")?;
let pair = |v: &Value| -> Option<[u64; 2]> { Some([v.get(0)?.as_u64()?, v.get(1)?.as_u64()?]) };
let mut left: Vec<[[u64; 2]; 2]> = faces.to_vec();
let mut ok = true;
for w in list {
let degree = w.get("degree").and_then(pair).ok_or("each `splines` entry needs `degree: [p, q]`")?;
let spans = match w.get("spans").filter(|s| !s.is_null()) {
Some(s) => Some(pair(s).ok_or("`spans` must be [m, n]")?),
None => None,
};
let fits = |f: &[[u64; 2]; 2]| {
let mine = |d: [u64; 2], s: Option<[u64; 2]>| f[0][0] == d[0] && f[1][0] == d[1] && s.is_none_or(|s| f[0][1] == s[0] && f[1][1] == s[1]);
mine(degree, spans) || mine([degree[1], degree[0]], spans.map(|s| [s[1], s[0]]))
};
match left.iter().position(fits) {
Some(i) => {
left.remove(i);
}
None => ok = false,
}
}
let got: Vec<Value> = faces.iter().map(|f| json!({"degree": [f[0][0], f[1][0]], "spans": [f[0][1], f[1][1]]})).collect();
Ok((json!(got), ok && left.is_empty()))
}
/// Largest sine of the angle between a construction's direction (an axis's, a plane's normal)
/// and the case's: either way along it.
const CONSTRUCT_DIR_TOL: f64 = 1e-6;
/// The `construction` check: each named construction plane, axis or point, as the timeline
/// evaluated it, is the case's: a point within `tol` (mm); an axis whose direction is parallel to
/// `dir` (either way) and whose line passes within `tol` of `through`; a plane whose normal is
/// parallel to `normal` (either way) and which passes within `tol` of `through`. An axis or plane
/// is graded as the line or plane it is, never by the origin it happens to keep.
fn check_construction(s: &solidcraft_engine::Session, want: &Value, tol: f64, c: &mut Checks) {
use solidcraft_engine::geom::Vec3;
use solidcraft_engine::view::{construction_axes, construction_planes, construction_points};
let Some(named) = want.as_object() else {
c.push("construction", json!("`construction` must map names to {point} | {axis} | {plane}"), json!("an object"), false);
return;
};
let vec = |v: &Value| v3(v).map(Vec3::from);
let parallel = |a: Vec3, b: Vec3| a.normalized().zip(b.normalized()).is_some_and(|(a, b)| a.cross(b).len() <= CONSTRUCT_DIR_TOL);
for (name, w) in named {
let what = format!("construction {name}");
let (got, ok) = if let Some(p) = w.get("point").and_then(vec) {
match construction_points(s).into_iter().find(|x| &x.1 == name) {
Some((_, _, q)) => (json!({"point": q}), q.dist(p) <= tol),
None => (json!("no such construction point"), false),
}
} else if let Some((through, dir)) = w.get("axis").and_then(|a| vec(&a["through"]).zip(vec(&a["dir"]))) {
match construction_axes(s).into_iter().find(|x| &x.1 == name) {
Some((_, _, o, d)) => {
let off = d.normalized().map(|u| (through - o) - u * (through - o).dot(u)).map_or(f64::INFINITY, Vec3::len);
(json!({"axis": {"origin": o, "dir": d, "through_off_mm": off}}), parallel(d, dir) && off <= tol)
}
None => (json!("no such construction axis"), false),
}
} else if let Some((through, normal)) = w.get("plane").and_then(|p| vec(&p["through"]).zip(vec(&p["normal"]))) {
match construction_planes(s).into_iter().find(|x| &x.1 == name) {
Some((_, _, pl)) => {
let n = pl.normal();
let off = n.normalized().map_or(f64::INFINITY, |u| (through - pl.origin).dot(u).abs());
(json!({"plane": {"origin": pl.origin, "normal": n, "through_off_mm": off}}), parallel(n, normal) && off <= tol)
}
None => (json!("no such construction plane"), false),
}
} else {
(json!("give {point: [x,y,z]}, {axis: {through, dir}} or {plane: {through, normal}}"), false)
};
c.push(&what, got, w.clone(), ok);
}
}
fn unsupported(e: &str) -> bool {
e.contains("not supported yet")
}
@@ -273,6 +583,56 @@ fn case_name(dir: &str) -> (String, String) {
(name(p.parent()), name(Some(p)))
}
/// The area a polygon of `[x, y]` points encloses (shoelace), unsigned.
fn polygon_area(points: &Value) -> f64 {
let pts: Vec<(f64, f64)> = points.as_array().into_iter().flatten().filter_map(|p| Some((p.get(0)?.as_f64()?, p.get(1)?.as_f64()?))).collect();
pts.iter().zip(pts.iter().cycle().skip(1)).map(|(a, b)| a.0 * b.1 - b.0 * a.1).sum::<f64>().abs() / 2.0
}
/// The `flat_pattern` check, against the script's last `sheet.flat_pattern` result: `size_mm`
/// ([w, h] of the outline), `area_mm2` (the outline loops' area less the cut-outs') and
/// `bend_lines` ([[x, y], [x, y]] each, the bends' centre lines in flat coordinates, every one
/// matched to its own one of the result's, either way round, and as many of them).
fn flat_pattern_checks(c: &mut Checks, want: &Value, results: &[Value], rel: f64, abs: f64) {
let Some(got) = results.iter().rev().find(|r| r.get("flat_size_mm").is_some()) else {
c.push("flat_pattern", json!("no sheet.flat_pattern result"), want.clone(), false);
return;
};
if let Some(w) = want.get("size_mm").and_then(Value::as_array) {
let g = &got["flat_size_mm"];
let ok = w.len() == 2
&& (0..2).all(|k| match (g.get(k).and_then(Value::as_f64), w.get(k).and_then(Value::as_f64)) {
(Some(g), Some(w)) => (g - w).abs() <= abs,
_ => false,
});
c.push("flat_pattern.size_mm", json!([g.get(0), g.get(1)]), json!(w), ok);
}
if let Some(w) = want.get("area_mm2").and_then(Value::as_f64) {
let loops = |k: &str| got[k].as_array().into_iter().flatten().map(polygon_area).sum::<f64>();
c.rel("flat_pattern.area_mm2", loops("outline") - loops("cutouts"), Some(w), rel);
}
if let Some(w) = want.get("bend_lines").and_then(Value::as_array) {
let line = |v: &Value| -> Option<[f64; 4]> {
let (a, b) = (v.get(0)?, v.get(1)?);
Some([a.get(0)?.as_f64()?, a.get(1)?.as_f64()?, b.get(0)?.as_f64()?, b.get(1)?.as_f64()?])
};
let mut left: Vec<[f64; 4]> = got["bends"].as_array().into_iter().flatten().filter_map(|b| line(&json!([b["start"], b["end"]]))).collect();
let got_lines = json!(left.iter().map(|l| [[l[0], l[1]], [l[2], l[3]]]).collect::<Vec<_>>());
let near = |p: [f64; 4], q: [f64; 4]| (0..4).all(|k| (p[k] - q[k]).abs() <= abs);
let mut ok = left.len() == w.len();
for l in w.iter().map(line) {
let found = l.and_then(|l| left.iter().position(|g| near(*g, l) || near(*g, [l[2], l[3], l[0], l[1]])));
match found {
Some(i) => {
left.swap_remove(i);
}
None => ok = false,
}
}
c.push("flat_pattern.bend_lines", got_lines, json!(w), ok);
}
}
fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
let (area, name) = case_name(dir);
let mut out = json!({"case": name, "area": area, "kernel": kernel()});
@@ -292,7 +652,15 @@ fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
out["error"] = json!(missing);
return out;
}
let commands = match scratch(&area, &name).and_then(|o| read_json(&format!("{dir}/recipe.json")).and_then(|r| script(dir, &o, &r))) {
let scratch_dir = match scratch(&area, &name) {
Ok(o) => o,
Err(e) => {
out["status"] = json!("fail");
out["error"] = json!(e);
return out;
}
};
let commands = match read_json(&format!("{dir}/recipe.json")).and_then(|r| script(dir, &scratch_dir, &r)) {
Ok(s) => s,
Err(e) => {
out["status"] = json!("fail");
@@ -328,7 +696,7 @@ fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
let ran = s.run_script(&commands);
// The commands' own time, without process start or grading: the ladder's timing golden.
out["seconds"] = json!(clock.elapsed().as_secs_f64());
match (ran, may_refuse) {
let answers = match (ran, may_refuse) {
(Err(e), _) if crashed(&e.to_string()) => {
out["status"] = json!("crash");
out["error"] = json!(e.to_string());
@@ -364,8 +732,8 @@ fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
out["error"] = json!("succeeded where the case expects a refusal");
return out;
}
(Ok(_), _) => {}
}
(Ok(r), _) => r,
};
// Every body in the world, imported components included.
let world = match s.world_state() {
@@ -383,6 +751,17 @@ fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
// body), else one per body.
let want_shells = want["shells"].as_u64();
let mut shells = 0u64;
// What the faces lie on and the edges only one face uses, over every body, as the records
// hold them: for `surface_types`, `splines` and `boundary_edges`.
let (mut kinds, mut spline_faces, mut boundary) = (std::collections::BTreeSet::new(), Vec::new(), 0u64);
for b in &world.bodies {
let record = b.body.record();
for f in &record.faces {
kinds.insert(surface_word(&f.surface));
spline_faces.extend(spline_shape(&f.surface));
}
boundary += record.edges.iter().filter(|e| e.uses.len() == 1).count() as u64;
}
for b in &world.bodies {
let m = match solidcraft_engine::kernel::measure(&b.body) {
Ok(m) => m,
@@ -504,6 +883,28 @@ fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
c.vec("bbox.min", got.bbox.0, want_bbox.map(|b| b.0), abs);
c.vec("bbox.max", got.bbox.1, want_bbox.map(|b| b.1), abs);
}
output_checks(&mut c, &want, &scratch_dir, &answers, rel);
count(&mut c, "boundary_edges", boundary);
if has("surface_types") {
// The set of surface kinds the faces lie on, exactly: none missing, none extra.
let want_kinds: std::collections::BTreeSet<&str> = want["surface_types"].as_array().into_iter().flatten().filter_map(Value::as_str).collect();
let ok = want_kinds == kinds.iter().copied().collect();
c.push("surface_types", json!(kinds), want["surface_types"].clone(), ok);
}
if has("splines") {
match splines_match(&spline_faces, &want["splines"]) {
Ok((got, ok)) => c.push("splines", got, want["splines"].clone(), ok),
Err(e) => c.push("splines", json!(e), want["splines"].clone(), false),
}
}
// With no body and no `bbox` the diagonal is not finite: positions then take ABS_FRAC of 1 mm.
let pos_tol = if abs.is_finite() { abs } else { ABS_FRAC };
if has("construction") {
check_construction(&s, &want["construction"], pos_tol, &mut c);
}
if has("flat_pattern") {
flat_pattern_checks(&mut c, &want["flat_pattern"], &answers, rel, abs);
}
out["status"] = json!(if c.pass { "pass" } else { "fail" });
out["checks"] = json!(c.list);
out
@@ -555,6 +956,8 @@ pub fn run(args: &[String]) -> Result<(), String> {
#[cfg(test)]
mod tests {
use std::f64::consts::PI;
use super::*;
fn case_dir(root: &std::path::Path, name: &str, recipe: &Value) -> String {
@@ -581,6 +984,177 @@ mod tests {
let _ = std::fs::remove_dir_all(&root);
}
/// A bicubic face of 4 × 3 spans and a bilinear one of one span: degrees and spans graded in
/// either order of directions, spans only where given, and every face must be accounted for.
#[test]
fn splines_match_degrees_and_spans_in_either_order() {
use solidcraft_engine::geom::brep::Surface;
let knots = |p: usize, spans: usize| -> Vec<f64> {
let mut k = vec![0.0; p + 1];
k.extend((1..spans).map(|i| i as f64));
k.extend(vec![spans as f64; p + 1]);
k
};
let face = |pu: usize, su: usize, pv: usize, sv: usize| Surface::Spline {
u_knots: knots(pu, su),
v_knots: knots(pv, sv),
points: vec![vec![[0.0; 3]; pv + sv]; pu + su],
};
let faces: Vec<_> = [face(3, 4, 3, 3), face(1, 1, 1, 1)].iter().filter_map(spline_shape).collect();
assert_eq!(faces[0], [[3, 3], [3, 4]]);
let ok = |w: Value| splines_match(&faces, &w).unwrap().1;
assert!(ok(json!([{"degree": [1, 1], "spans": [1, 1]}, {"degree": [3, 3], "spans": [4, 3]}])));
assert!(ok(json!([{"degree": [3, 3]}, {"degree": [1, 1]}])));
assert!(!ok(json!([{"degree": [3, 3], "spans": [4, 4]}, {"degree": [1, 1]}])), "wrong spans");
assert!(!ok(json!([{"degree": [3, 3]}])), "a face left over");
assert!(!ok(json!([{"degree": [3, 3]}, {"degree": [1, 1]}, {"degree": [1, 1]}])), "an entry with no face");
assert!(splines_match(&faces, &json!([{"spans": [1, 1]}])).is_err());
assert_eq!(spline_shape(&Surface::Plane { origin: [0.0; 3], u_axis: [1.0, 0.0, 0.0], v_axis: [0.0, 1.0, 0.0] }), None);
assert_eq!(surface_word(&face(1, 1, 1, 1)), "bspline");
}
#[test]
fn json_parts_match_within_tolerance_and_whole_numbers_exactly() {
let got = json!({"bends": [{"angle_deg": 90.00001, "direction": "up", "count": 3}], "extra": 1});
assert_eq!(json_mismatch(&got, &json!({"bends": [{"angle_deg": 90.0, "direction": "up"}]}), 1e-3, 0.0, ""), None);
assert!(json_mismatch(&got, &json!({"bends": [{"count": 4}]}), 1e-3, 0.0, "").is_some_and(|m| m.contains(".bends[0].count")));
assert!(json_mismatch(&got, &json!({"bends": []}), 1e-3, 0.0, "").is_some_and(|m| m.contains("1 items, want 0")));
assert!(json_mismatch(&got, &json!({"missing": 1}), 1e-3, 0.0, "").is_some_and(|m| m.contains("missing")));
assert!(json_mismatch(&got, &json!({"bends": [{"direction": "down"}]}), 1e-3, 0.0, "").is_some());
}
#[test]
fn csv_rows_are_keyed_by_the_header_and_read_quoted_fields() {
let rows = csv_rows("body,angle_deg,note\r\n\"a, \"\"b\"\"\",90.5,x\r\n\"c\",180,\r\n");
assert_eq!(rows, vec![json!({"body": "a, \"b\"", "angle_deg": 90.5, "note": "x"}), json!({"body": "c", "angle_deg": 180.0, "note": ""})]);
}
#[test]
fn dxf_layers_count_entities_and_measure_their_length() {
let pair = |c: &str, v: &str| format!("{c}\n{v}\n");
let mut t = String::new();
// A circle in the BLOCKS section is not an entity of the drawing.
for (c, v) in [("0", "SECTION"), ("2", "BLOCKS"), ("0", "CIRCLE"), ("8", "CUT"), ("40", "9"), ("0", "ENDSEC")] {
t += &pair(c, v);
}
t += &pair("0", "SECTION");
t += &pair("2", "ENTITIES");
for e in [
vec![("0", "LINE"), ("8", "OUTLINE"), ("10", "0"), ("20", "0"), ("11", "3"), ("21", "4")],
vec![("0", "ARC"), ("8", "OUTLINE"), ("10", "0"), ("20", "0"), ("40", "2"), ("50", "270"), ("51", "0")],
vec![("0", "CIRCLE"), ("8", "CUT"), ("10", "5"), ("20", "5"), ("40", "1")],
vec![("0", "LWPOLYLINE"), ("8", "BEND_UP"), ("90", "2"), ("70", "128"), ("10", "0"), ("20", "1"), ("10", "10"), ("20", "1")],
vec![
("0", "ELLIPSE"),
("8", "CUT"),
("10", "0"),
("20", "0"),
("11", "10"),
("21", "0"),
("40", "1"),
("41", "0"),
("42", "6.283185307179586"),
],
] {
for (c, v) in e {
t += &pair(c, v);
}
}
t += &pair("0", "ENDSEC");
t += &pair("0", "EOF");
let l = dxf_layers(&t);
assert_eq!(l["OUTLINE"]["LINE"], 1);
assert_eq!(l["OUTLINE"]["ARC"], 1);
assert!((l["OUTLINE"]["length_mm"].as_f64().unwrap() - (5.0 + PI)).abs() < 1e-9, "{l}");
assert_eq!(l["CUT"]["CIRCLE"], 1);
assert_eq!(l["CUT"]["ELLIPSE"], 1);
// A circle of radius 1 and an ellipse of ratio 1 (a circle of radius 10).
assert!((l["CUT"]["length_mm"].as_f64().unwrap() - 22.0 * PI).abs() < 1e-6, "{l}");
assert!((l["BEND_UP"]["length_mm"].as_f64().unwrap() - 10.0).abs() < 1e-9, "{l}");
}
#[test]
fn output_checks_read_the_files_and_answers_a_case_names() {
let out = std::env::temp_dir().join(format!("kernel-cases-files-{}", std::process::id()));
std::fs::create_dir_all(&out).unwrap();
std::fs::write(out.join("t.json"), r#"{"bends": [{"angle_deg": 90}]}"#).unwrap();
std::fs::write(out.join("t.csv"), "bend,angle_deg\r\n1,90\r\n").unwrap();
std::fs::write(out.join("t.dxf"), "0\nSECTION\n2\nENTITIES\n0\nLINE\n8\nOUTLINE\n10\n0\n20\n0\n11\n1\n21\n0\n0\nENDSEC\n").unwrap();
let dir = out.to_string_lossy().to_string();
let run = |want: Value| {
let mut c = Checks { list: Vec::new(), pass: true };
output_checks(&mut c, &want, &dir, &[json!({"count": 3})], 1e-3);
c.pass
};
assert!(run(json!({"files": [{"path": "t.json", "json": {"bends": [{"angle_deg": 90.0}]}}]})));
assert!(run(json!({"files": [{"path": "t.csv", "csv": [{"bend": 1, "angle_deg": 90.0}]}]})));
assert!(run(json!({"files": [{"path": "t.dxf", "dxf": {"OUTLINE": {"LINE": [1, 8], "ARC": 0, "length_mm": 1.0}}}]})));
assert!(!run(json!({"files": [{"path": "t.dxf", "dxf": {"OUTLINE": {"LINE": [2, 8]}}}]})));
assert!(!run(json!({"files": [{"path": "t.dxf", "dxf": {"CUT": {"CIRCLE": 1}}}]})));
assert!(!run(json!({"files": [{"path": "none.json", "json": {}}]})));
assert!(run(json!({"results": [{"step": 1, "json": {"count": 3}}]})));
assert!(!run(json!({"results": [{"step": 2, "json": {}}]})));
let _ = std::fs::remove_dir_all(&out);
}
#[test]
fn construction_is_graded_as_the_point_line_or_plane_it_is() {
let mut s = solidcraft_engine::Session::default();
let script = json!({"commands": [
{"command": "construct.point.three_planes", "params": {"a": "XY", "b": "XZ", "c": "YZ", "name": "Pin"}},
{"command": "construct.axis.two_planes", "params": {"a": "XZ", "b": "YZ", "name": "Spine"}},
{"command": "construct.plane.offset", "params": {"base": "XY", "offset": "5 mm", "name": "Shelf"}},
]});
s.run_script(&script).unwrap();
let grade = |want: Value| {
let mut c = Checks { list: Vec::new(), pass: true };
check_construction(&s, &want, 1e-3, &mut c);
c.pass
};
// An axis is its line, either way along it, through any point of it; a plane likewise.
assert!(grade(json!({
"Pin": {"point": [0, 0, 0]},
"Spine": {"axis": {"through": [0, 0, 40], "dir": [0, 0, -1]}},
"Shelf": {"plane": {"through": [7, -3, 5], "normal": [0, 0, 2]}},
})));
assert!(!grade(json!({"Pin": {"point": [0, 0, 0.01]}})));
assert!(!grade(json!({"Spine": {"axis": {"through": [0.01, 0, 0], "dir": [0, 0, 1]}}})));
assert!(!grade(json!({"Spine": {"axis": {"through": [0, 0, 0], "dir": [0, 0.01, 1]}}})));
assert!(!grade(json!({"Shelf": {"plane": {"through": [0, 0, 5.01], "normal": [0, 0, 1]}}})));
assert!(!grade(json!({"Shelf": {"plane": {"through": [0, 0, 5], "normal": [1, 0, 0]}}})));
// A name the timeline has not got, or of another kind, fails.
assert!(!grade(json!({"Pin": {"plane": {"through": [0, 0, 0], "normal": [0, 0, 1]}}})));
assert!(!grade(json!({"Nothing": {"point": [0, 0, 0]}})));
assert!(!grade(json!({"Pin": {"centre": [0, 0, 0]}})));
}
#[test]
fn results_are_read_from_each_commands_reply() {
let replies = [json!({"center": [1.0, 2.0, 3.0], "volume": 24000.0}), json!({"summary": {"worst": "g1"}, "count": 1})];
let grade = |results: Value| {
let mut c = Checks { list: Vec::new(), pass: true };
output_checks(&mut c, &json!({ "results": results }), "", &replies, 1e-3);
c.pass
};
assert!(grade(json!([
{"step": 1, "pointer": "/center", "json": [1.0, 2.0, 3.0]},
{"step": 1, "pointer": "/volume", "json": 24010.0},
{"step": 2, "pointer": "/summary/worst", "json": "g1"},
{"step": 2, "json": {"count": 1}},
])));
assert!(!grade(json!([{"step": 1, "pointer": "/volume", "json": 24100.0}])));
assert!(grade(json!([{"step": 1, "pointer": "/volume", "json": 24100.0, "rel": 0.01}])));
assert!(!grade(json!([{"step": 1, "pointer": "/center", "json": [1.0, 2.0, 3.01]}])));
assert!(grade(json!([{"step": 1, "pointer": "/center", "json": [1.0, 2.0, 3.01], "abs_mm": 0.02}])));
assert!(!grade(json!([{"step": 2, "pointer": "/summary/worst", "json": "g2"}])));
// A whole number is exact: a count.
assert!(!grade(json!([{"step": 2, "pointer": "/count", "json": 2}])));
// A step or a part that is not there fails, as does an entry without a step.
assert!(!grade(json!([{"step": 3, "pointer": "/count", "json": 1}])));
assert!(!grade(json!([{"step": 2, "pointer": "/missing", "json": null}])));
assert!(!grade(json!([{"pointer": "/count", "json": 1}])));
}
#[test]
fn a_base_cycle_is_an_error_not_a_hang() {
let root = std::env::temp_dir().join(format!("kernel-cases-cycle-{}", std::process::id()));
@@ -590,4 +1164,27 @@ mod tests {
assert!(script(&a, "/scratch", &r).unwrap_err().contains("deeper than"));
let _ = std::fs::remove_dir_all(&root);
}
/// The flat pattern is graded on the last `sheet.flat_pattern` result: its size, its outline's
/// area less the cut-outs', and its bend lines matched either way round, one for one.
#[test]
fn flat_pattern_grades_size_area_and_bend_lines() {
let flat = json!({"flat_size_mm": [10.0, 4.0, 2.0],
"outline": [[[0.0, 0.0], [10.0, 0.0], [10.0, 4.0], [0.0, 4.0]]], "cutouts": [[[1.0, 1.0], [2.0, 1.0], [2.0, 2.0], [1.0, 2.0]]],
"bends": [{"start": [5.0, 0.0], "end": [5.0, 4.0]}]});
let results = [json!({"volume_mm3": 1.0}), flat];
let grade = |want: Value| {
let mut c = Checks { list: Vec::new(), pass: true };
flat_pattern_checks(&mut c, &want, &results, 1e-3, 1e-3);
c.pass
};
assert!(grade(json!({"size_mm": [10.0, 4.0], "area_mm2": 39.0, "bend_lines": [[[5.0, 4.0], [5.0, 0.0]]]})));
assert!(!grade(json!({"area_mm2": 40.0})), "the cut-out is not material");
assert!(!grade(json!({"size_mm": [10.0, 5.0]})));
assert!(!grade(json!({"bend_lines": [[[5.0, 0.0], [5.0, 4.0]], [[5.0, 0.0], [5.0, 4.0]]]})), "one bend line matches one only");
assert!(!grade(json!({"bend_lines": [[[6.0, 0.0], [6.0, 4.0]]]})));
let mut c = Checks { list: Vec::new(), pass: true };
flat_pattern_checks(&mut c, &json!({"area_mm2": 1.0}), &results[..1], 1e-3, 1e-3);
assert!(!c.pass, "no flat pattern was made");
}
}
@@ -0,0 +1,30 @@
{
"en": {
"prefs.surface_extrude_symmetric_per_side": "Symmetric surface extrudes go the distance each way (10 mm: 20 mm in all), as before, not the total like solid extrudes",
"prefs.surfaces": "Surfaces"
},
"ar": {
"prefs.surface_extrude_symmetric_per_side": "يمتد بثق السطح المتماثل بالمسافة في كل جانب كما كان من قبل (10 مم: 20 مم إجمالًا)، لا بالمسافة الكلية كبثق المجسم",
"prefs.surfaces": "الأسطح"
},
"he": {
"prefs.surface_extrude_symmetric_per_side": "שליפת משטח סימטרית נשלפת את המרחק לכל צד כמו קודם (10 מ\"מ: 20 מ\"מ בסך הכול), ולא את המרחק הכולל כמו שליפת גוף",
"prefs.surfaces": "משטחים"
},
"ja": {
"prefs.surface_extrude_symmetric_per_side": "対称のサーフェス押し出しを、ソリッドの押し出しのような合計ではなく、以前のように両側にそれぞれその距離だけ押し出す(10 mm: 合計 20 mm)",
"prefs.surfaces": "サーフェス"
},
"zh": {
"prefs.surface_extrude_symmetric_per_side": "对称曲面拉伸像以前一样向两侧各拉伸该距离(10 mm:共 20 mm),而非像实体拉伸那样取总距离",
"prefs.surfaces": "曲面"
},
"de": {
"prefs.surface_extrude_symmetric_per_side": "Symmetrische Flächen-Extrusionen wie bisher um den Abstand nach jeder Seite (10 mm: insgesamt 20 mm), nicht um die Gesamtlänge wie Volumen-Extrusionen",
"prefs.surfaces": "Flächen"
},
"ko": {
"prefs.surface_extrude_symmetric_per_side": "대칭 서피스 돌출을 솔리드 돌출처럼 전체 거리가 아니라 이전처럼 양쪽으로 각각 그 거리만큼 돌출 (10 mm: 총 20 mm)",
"prefs.surfaces": "서피스"
}
}
+9
View File
@@ -5118,6 +5118,15 @@ fn path_points(ps: &SolvedSketch, ids: &[String], start: Vec3) -> Result<Option<
for id in ids {
if let Some(wi) = ps.sketch.wire_index(id) {
pieces.push(match ps.sketch.wires.get(wi) {
// A drawn 3D arc is its circle, from its start counter-clockwise about its normal
// (its three fit points define it; a spline through them is not the arc).
Some(solidcraft_sketch::Wire { arc: Some(arc), .. }) => {
let x = (arc.start - arc.center).normalized().ok_or_else(|| DocError::Invalid("a 3D arc of no radius".into()))?;
let y = arc.normal.cross(x);
let frame = solidcraft_geom::brep::Frame { origin: arc.center.into(), x_axis: x.into(), y_axis: y.into() };
let circle = solidcraft_geom::brep::Curve::Circle { frame, radius: arc.radius };
kernel::PathPiece::Segs(kernel::curve_path(&circle, [0.0, solidcraft_sketch::arc_sweep(arc)])?)
}
Some(w) if w.fit.len() >= 3 => kernel::PathPiece::Spline { fit: w.fit.clone(), reversed: false },
Some(w) if !w.exact.is_empty() => {
let mut segs = Vec::new();
+36 -22
View File
@@ -461,21 +461,40 @@ fn thread_grooves(
format!("this {shown} mm shaft is too thin for a modelled {m} thread: {cut}; make the shaft {} mm for {m}{alt}", show_mm(d))
}));
}
// The section's radial span: from the root out past the surface (external), or from inside
// the hole wall out to the root (internal), so the cut leaves no skin.
// The section: from the root out past the surface (external), or from inside the hole wall
// out to the root (internal), so the cut leaves no skin, its flanks the groove's.
// A taper thread's crests are cut by its major cone (external) or minor cone (internal),
// as the die or tap cuts them ([`taper_envelope`]): its groove reaches just past the crest,
// by as much as narrows the tooth's crest flat by a quarter (NPT's flat is 0.038 P).
let past = |g: &crate::thread_forms::GrooveProfile| 0.25 * g.crest_flat / (g.flank_lo.tan() + g.flank_hi.tan());
let span = |g: &crate::thread_forms::GrooveProfile| match (taper.is_some(), t.internal) {
(true, true) => (g.crest_r - past(g), g.root_r),
(true, false) => (g.root_r, g.crest_r + past(g)),
(false, true) => (radius.min(g.crest_r) - 0.1 * p, g.root_r),
(false, false) => (g.root_r, radius.max(d / 2.0) + 0.05 * p),
// as the die or tap cuts them ([`taper_envelope`]): its groove reaches past the crest by as
// much as narrows the tooth's crest flat by a quarter (NPT's flat is 0.038 P). The cone
// changes 1 in 32 along the axis (`major_at`) across the section's own width, so its edge
// there follows the cone at that margin rather than being cut square: square, its deeper
// corner stops short of the cone and leaves a sliver of each flank.
let cone = taper.map_or(0.0, |_| (major_at(t.start + 1.0) - major_at(t.start)) / 2.0);
let section_of = |g: &crate::thread_forms::GrooveProfile| -> (Vec<Vec2>, f64) {
let (tl, th) = (g.flank_lo.tan(), g.flank_hi.tan());
if taper.is_none() {
let (r0, r1) = if t.internal { (radius.min(g.crest_r) - 0.1 * p, g.root_r) } else { (g.root_r, radius.max(d / 2.0) + 0.05 * p) };
let ((lo0, hi0), (lo1, hi1)) = (g.extents(p, r0), g.extents(p, r1));
let wide = g.width(p, if t.internal { r0 } else { r1 });
return (vec![Vec2::new(r0, -lo0), Vec2::new(r1, -lo1), Vec2::new(r1, hi1), Vec2::new(r0, hi0)], wide);
}
// Depth from the root, out towards the crest: d(z) = dc + q·z along the edge, which
// meets the flanks z = −(h + d·tl) and z = h + d·th.
let o = if t.internal { -1.0 } else { 1.0 };
let q = o * cone;
let h = g.width(p, g.root_r) / 2.0;
let dc = o * (g.crest_r - g.root_r) + 0.25 * g.crest_flat / (tl + th);
let (z_lo, z_hi) = (-(h + dc * tl) / (1.0 + q * tl), (h + dc * th) / (1.0 - q * th));
let r = |z: f64| g.root_r + o * (dc + q * z);
let (root, edge) = ([Vec2::new(g.root_r, -h), Vec2::new(g.root_r, h)], [Vec2::new(r(z_lo), z_lo), Vec2::new(r(z_hi), z_hi)]);
// In the order the square section has: the inner radius's corners first.
let pts = if t.internal { vec![edge[0], root[0], root[1], edge[1]] } else { vec![root[0], edge[0], edge[1], root[1]] };
(pts, z_hi - z_lo)
};
let (r0, r1) = span(&g);
let wide = if t.internal { r0 } else { r1 };
if g.width(p, wide) >= p * 0.98 {
let (mut section, wide) = section_of(&g);
let radii = |s: &[Vec2]| s.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), v| (a.min(v.x), b.max(v.x)));
let (r0, r1) = radii(&section);
if wide >= p * 0.98 {
// The groove would be wider than a pitch: the face is far inside the thread (a hole
// narrower than its minor diameter, a shaft thicker than its major one, #2688).
let (m, dia) = (&t.designation, 2.0 * radius);
@@ -488,9 +507,6 @@ fn thread_grooves(
format!("this {shown} mm shaft is too thick for a modelled {m} thread; make the shaft {} mm for {m}{alt}", show_mm(d))
}));
}
let (lo0, hi0) = g.extents(p, r0);
let (lo1, hi1) = g.extents(p, r1);
let mut section = vec![Vec2::new(r0, -lo0), Vec2::new(r1, -lo1), Vec2::new(r1, hi1), Vec2::new(r0, hi0)];
if !(r0.is_finite() && r1.is_finite() && r0 > 0.0) {
return Err(DocError::Invalid("thread dimensions are out of range".into()));
}
@@ -503,7 +519,8 @@ fn thread_grooves(
// the material (an external thread's away from the axis, past the surface; an internal
// one's towards it, into the hole) as it turns. It lies past the full-form length, up to the
// shoulder's clearance; at a free end, inside the face, the groove reaching nothing there.
let (w_lo, w_hi) = (lo0.max(lo1), hi0.max(hi1));
// How far the section reaches each way along the axis.
let (w_lo, w_hi) = section.iter().fold((0.0_f64, 0.0_f64), |(a, b), v| (a.max(-v.y), b.max(v.y)));
let s0 = match (ends[0], ease[0] > 0.0) {
(End::Free, false) => t.start - p,
(End::Free, true) => t.start,
@@ -528,11 +545,8 @@ fn thread_grooves(
let mut r0 = r0;
let taper_rate = match taper {
Some(_) => {
let gb = profile(major_at(s0));
let (a, b) = span(&gb);
let ((l0, h0), (l1, h1)) = (gb.extents(p, a), gb.extents(p, b));
section = vec![Vec2::new(a, -l0), Vec2::new(b, -l1), Vec2::new(b, h1), Vec2::new(a, h0)];
r0 = a;
section = section_of(&profile(major_at(s0))).0;
r0 = radii(&section).0;
(major_at(s0 + lead) - major_at(s0)) / 2.0
}
None => 0.0,
+104 -14
View File
@@ -366,8 +366,9 @@ fn edge_curves(body: Option<&crate::ModelBody>, e: usize) -> Vec<WireCurve> {
}
/// The sketch segments `segs` of `ss` projected along the sketch normal `normal` (turned toward
/// the face) onto the face of `target` at `at`: SMLib's projection, the pieces that meet end to
/// end joined into one wire each, every wire its points (for display) and its exact curves.
/// the face) onto the face of `target` at `at`: SMLib's projection, the side of the face the
/// projection meets first ([`first_hits`]), the pieces that meet end to end joined into one wire
/// each, every wire its points (for display) and its exact curves.
fn projected_wires(
target: &crate::ModelBody,
at: Vec3,
@@ -378,30 +379,119 @@ fn projected_wires(
) -> Result<(Vec<Vec<Vec3>>, Vec<Vec<WireCurve>>)> {
let from = segs.first().map(|s| ss.plane.to_world(s.start())).unwrap_or(at);
let toward = if (at - from).dot(normal) < 0.0 { normal * -1.0 } else { normal };
joined_wires(crate::kernel::project_onto_face(&target.body, at, &ss.plane, segs, toward)?, size * 1e-6)
let curves = crate::kernel::project_onto_face(&target.body, at, &ss.plane, segs, toward)?;
joined_wires(first_hits(target, curves, toward)?, size * 1e-6)
}
/// Record curves as wires: curves that meet end to end (within `tol`) one wire, each wire its
/// points (for display) and its exact curves.
/// Of the curves a parallel projection along `toward` made on a face of `target`, the ones the
/// projection meets first: SMLib gives every curve where the projecting lines cross the face
/// (both sides of a sphere), and a projection onto a surface is where they first hit it. A curve
/// is kept when the first hit along the line through its middle, on the body's mesh, is the
/// curve itself (within the mesh's chord tolerance, a few times over), not a point of the body
/// in front of it.
fn first_hits(
target: &crate::ModelBody,
curves: Vec<(solidcraft_geom::brep::Curve, [f64; 2])>,
toward: Vec3,
) -> Result<Vec<(solidcraft_geom::brep::Curve, [f64; 2])>> {
let Some(dir) = toward.normalized() else { return Ok(curves) };
let mesh = target.mesh();
let reach = 2.0 * mesh.bounds().diagonal().max(1e-9);
let slack = 4.0 * target.display_tol();
let mut kept = Vec::with_capacity(curves.len());
for (curve, interval) in curves {
let eval = solidcraft_geom::brep::eval::CurveEval::new(&curve).map_err(|e| DocError::Invalid(format!("projected curve: {e}")))?;
let mid = eval.point(0.5 * (interval[0] + interval[1])).ok_or_else(|| DocError::Invalid("projected curve: no middle point".into()))?;
let origin = mid - dir * reach;
let front = mesh.raycast(origin, dir).is_some_and(|(t, _)| t < reach - slack);
if !front {
kept.push((curve, interval));
}
}
Ok(kept)
}
/// Record curves as wires: curves that meet end to end (within `tol`) one wire, in any order and
/// direction they come (a projection split at a sphere's pole into two pieces that both end there
/// joins again there, the second run the other way), each wire its points (for display) and its
/// exact curves.
fn joined_wires(curves: Vec<(solidcraft_geom::brep::Curve, [f64; 2])>, tol: f64) -> Result<(Vec<Vec<Vec3>>, Vec<Vec<WireCurve>>)> {
let (mut wires, mut exact): (Vec<Vec<Vec3>>, Vec<Vec<WireCurve>>) = (Vec::new(), Vec::new());
for (curve, interval) in curves {
let pts = crate::kernel::PathPiece::Segs(crate::kernel::curve_path(&curve, interval)?).points();
let Some(start) = pts.first().copied() else { continue };
match (wires.last_mut(), exact.last_mut()) {
(Some(w), Some(e)) if w.last().is_some_and(|end| end.dist(start) <= tol) => {
w.extend(pts.into_iter().skip(1));
e.push(WireCurve { curve, interval });
}
_ => {
wires.push(pts);
exact.push(vec![WireCurve { curve, interval }]);
if pts.is_empty() {
continue;
}
wires.push(pts);
exact.push(vec![WireCurve { curve, interval }]);
}
// Join a wire onto the one that ends where it starts (or ends, turned round), until no two
// meet: each join removes a wire.
'join: loop {
for i in 0..wires.len() {
for j in 0..wires.len() {
let (Some(a), Some(b)) = (wires.get(i), wires.get(j)) else { continue };
let (Some(end), Some(start), Some(last)) = (a.last(), b.first(), b.last()) else { continue };
let turned = if i == j {
continue;
} else if end.dist(*start) <= tol {
false
} else if end.dist(*last) <= tol && exact.get(j).is_some_and(|e| e.iter().all(|c| reversed(c).is_some())) {
true
} else {
continue;
};
let (mut w, mut e) = (wires.remove(j), exact.remove(j));
if turned {
w.reverse();
e = e.iter().rev().filter_map(reversed).collect();
}
let i = if j < i { i - 1 } else { i };
if let (Some(into), Some(curves)) = (wires.get_mut(i), exact.get_mut(i)) {
into.extend(w.into_iter().skip(1));
curves.extend(e);
}
continue 'join;
}
}
break;
}
Ok((wires, exact))
}
/// `c` run the other way: the same points, its parameter `t` now `c0 + c1 - t` over the curve's
/// own knots (a line's `1 - t`, a circle's or ellipse's angle negated with its y axis turned).
/// Exact; `None` for a curve kind it doesn't turn.
fn reversed(c: &WireCurve) -> Option<WireCurve> {
use solidcraft_geom::brep::{Curve, Frame};
let [t0, t1] = c.interval;
let flip = |frame: &Frame| Frame { origin: frame.origin, x_axis: frame.x_axis, y_axis: frame.y_axis.map(|v| -v) };
let (curve, interval) = match &c.curve {
Curve::Line { start, end } => (Curve::Line { start: *end, end: *start }, [1.0 - t1, 1.0 - t0]),
Curve::Circle { frame, radius } => (Curve::Circle { frame: flip(frame), radius: *radius }, [-t1, -t0]),
Curve::Ellipse { frame, radii } => (Curve::Ellipse { frame: flip(frame), radii: *radii }, [-t1, -t0]),
Curve::Spline { knots, points } => {
let sum = knots.first()? + knots.last()?;
(
Curve::Spline { knots: knots.iter().rev().map(|k| sum - k).collect(), points: points.iter().rev().copied().collect() },
[sum - t1, sum - t0],
)
}
Curve::RationalSpline { knots, homogeneous } => {
let sum = knots.first()? + knots.last()?;
(
Curve::RationalSpline {
knots: knots.iter().rev().map(|k| sum - k).collect(),
homogeneous: homogeneous.iter().rev().copied().collect(),
},
[sum - t1, sum - t0],
)
}
_ => return None,
};
Some(WireCurve { curve, interval })
}
/// Curve `ci` of the solved sketch `ss` as its exact pieces in space, in the order its polyline
/// runs; none where a piece has no record curve.
fn sketch_curves(ss: &crate::eval::SolvedSketch, ci: usize) -> Vec<WireCurve> {
+8 -4
View File
@@ -1047,12 +1047,16 @@ fn edit_feature(s: &mut Session, p: &Value) -> Result<Value> {
resolve_feature_names(&mut v, &s.doc, cmd)?;
let mut nf: Feature = serde_json::from_value(v.clone()).map_err(|e| bad(cmd, format!("invalid feature: {e}")))?;
nf.id = f.id;
if let (FeatureKind::Extrude { extent: old, .. }, FeatureKind::Extrude { extent: new, .. }) = (&f.kind, &mut nf.kind)
// A one-sided extrude made symmetric takes the convention a new one would: its old marker
// never read a symmetric distance.
let maker = if matches!(f.kind, FeatureKind::SurfaceExtrude { .. }) { "surface.extrude" } else { "solid.extrude" };
if let (FeatureKind::Extrude { extent: old, .. }, FeatureKind::Extrude { extent: new, .. })
| (FeatureKind::SurfaceExtrude { extent: old, .. }, FeatureKind::SurfaceExtrude { extent: new, .. }) = (&f.kind, &mut nf.kind)
&& old.direction != solidcraft_doc::Direction::Symmetric
&& new.direction == solidcraft_doc::Direction::Symmetric
&& set.get("extent").and_then(|e| e.get("convention")).is_none()
{
new.convention = solidcraft_doc::ExtrudeConvention::TotalDistance;
new.convention = super::features::default_extrude_convention(s, maker);
}
if std::mem::discriminant(&nf.kind) != std::mem::discriminant(&f.kind) {
return Err(bad(cmd, "the feature type cannot change"));
@@ -1410,10 +1414,10 @@ fn redefine(s: &mut Session, p: &Value) -> Result<Value> {
&& matches!(cid, "solid.extrude" | "surface.extrude")
&& let Some(parameters) = params.as_object_mut()
{
let convention = if cid == "surface.extrude" || extent.direction == solidcraft_doc::Direction::Symmetric {
let convention = if extent.direction == solidcraft_doc::Direction::Symmetric {
extent.convention
} else {
solidcraft_doc::ExtrudeConvention::TotalDistance
super::features::default_extrude_convention(s, cid)
};
parameters.entry("convention").or_insert_with(|| json!(convention));
}
@@ -123,23 +123,102 @@ fn symmetric_extrude_thin_wall_uses_total_distance_and_to_object_remains_one_sid
check(&fixture(json!({"to":[0,0,10]})), 0.0, 10.0);
}
/// The z range of surface body `name`.
fn sheet_z(s: &Session, name: &str) -> (f64, f64) {
assert!(s.model.results.iter().all(|r| r.error.is_none()));
let st = s.model.state();
let bounds = st.body(name).unwrap().mesh().bounds();
(bounds.min.z, bounds.max.z)
}
fn assert_z(s: &Session, name: &str, lo: f64, hi: f64) {
let (z0, z1) = sheet_z(s, name);
assert!((z0 - lo).abs() < 1e-7 && (z1 - hi).abs() < 1e-7, "{name}: {z0}..{z1}, want {lo}..{hi}");
}
/// A symmetric surface extrude reads its distance as a solid one does: the total, split evenly
/// around the start plane, through a redefine and a save.
#[test]
fn surface_extrude_shared_extent_retains_its_existing_per_side_semantics() {
fn surface_extrude_symmetric_distance_is_the_total_like_solid_extrude() {
let mut s = fixture(json!({}));
run(&mut s, "surface.extrude", json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","name":"Sheet","body_name":"Sheet"}));
let check_sheet = |s: &Session| {
let st = s.model.state();
let bounds = st.body("Sheet").unwrap().mesh().bounds();
assert!((bounds.min.z + 10.0).abs() < 1e-7 && (bounds.max.z - 10.0).abs() < 1e-7);
};
check_sheet(&s);
assert_z(&s, "Sheet", -5.0, 5.0);
let FeatureKind::SurfaceExtrude { extent, .. } = &s.doc.find_feature("Sheet").unwrap().kind else { panic!("surface extrude") };
assert_eq!(extent.convention, ExtrudeConvention::TotalDistance);
run(
&mut s,
"timeline.redefine",
json!({"feature":"Sheet","command":"surface.extrude","params":{"sketch":"Square","distance":"10 mm","direction":"symmetric","body_name":"Sheet"}}),
);
check_sheet(&s);
check_sheet(&Session::new(Document::from_json(&s.doc.to_json()).unwrap()));
assert_z(&s, "Sheet", -5.0, 5.0);
assert_z(&Session::new(Document::from_json(&s.doc.to_json()).unwrap()), "Sheet", -5.0, 5.0);
// A one-sided surface extrude made symmetric splits its distance too, as a solid one does.
run(&mut s, "surface.extrude", json!({"sketch":"Square","distance":"10 mm","convention":"legacy_per_side","name":"Wall","body_name":"Wall"}));
assert_z(&s, "Wall", 0.0, 10.0);
run(&mut s, "timeline.edit", json!({"feature":"Wall","set":{"extent":{"direction":"symmetric"}}}));
assert_z(&s, "Wall", -5.0, 5.0);
}
/// Surface extrudes saved before they matched solid ones stored `legacy_per_side` (or, older
/// still, no marker): they rebuild the distance on each side, and keep it through edits.
#[test]
fn older_symmetric_surface_extrudes_keep_the_distance_on_each_side() {
let mut s = fixture(json!({}));
run(
&mut s,
"surface.extrude",
json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","convention":"legacy_per_side","name":"Sheet","body_name":"Sheet"}),
);
assert_z(&s, "Sheet", -10.0, 10.0);
let marked: Value = serde_json::from_str(&s.doc.to_json()).unwrap();
let mut unmarked = marked.clone();
unmarked["format"] = json!("solidcraft/21");
unmarked.as_object_mut().unwrap().remove("format_pending");
for f in unmarked["features"].as_array_mut().unwrap() {
if let Some(extent) = f.get_mut("extent").and_then(Value::as_object_mut) {
extent.remove("convention");
}
}
for saved in [marked, unmarked] {
let mut s = Session::new(Document::from_json(&saved.to_string()).unwrap());
assert_z(&s, "Sheet", -10.0, 10.0);
run(&mut s, "timeline.edit", json!({"feature":"Sheet","set":{"extent":{"distance":"12 mm"}}}));
assert_z(&s, "Sheet", -12.0, 12.0);
run(
&mut s,
"timeline.redefine",
json!({"feature":"Sheet","command":"surface.extrude","params":{"sketch":"Square","distance":"10 mm","direction":"symmetric","body_name":"Sheet"}}),
);
assert_z(&s, "Sheet", -10.0, 10.0);
}
}
/// The preference brings back the per-side reading for new surface extrudes only: solid
/// extrudes and an explicit `convention` are unchanged by it.
#[test]
fn the_per_side_preference_keeps_the_older_surface_extrude_reading() {
let mut s = fixture(json!({}));
s.surface_extrude_symmetric_per_side = true;
run(&mut s, "surface.extrude", json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","name":"Sheet","body_name":"Sheet"}));
assert_z(&s, "Sheet", -10.0, 10.0);
let FeatureKind::SurfaceExtrude { extent, .. } = &s.doc.find_feature("Sheet").unwrap().kind else { panic!("surface extrude") };
assert_eq!(extent.convention, ExtrudeConvention::LegacyPerSide);
run(
&mut s,
"surface.extrude",
json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","convention":"total_distance","name":"Total","body_name":"Total"}),
);
assert_z(&s, "Total", -5.0, 5.0);
run(&mut s, "solid.extrude", json!({"sketch":"Square","distance":"10 mm","direction":"symmetric","operation":"new","body_name":"Solid"}));
assert_z(&s, "Solid", -5.0, 5.0);
// The saved marker, not the preference, decides on reopening.
s.surface_extrude_symmetric_per_side = false;
let reopened = Session::new(Document::from_json(&s.doc.to_json()).unwrap());
assert_z(&reopened, "Sheet", -10.0, 10.0);
// A design opened or started keeps the user's choice.
s.surface_extrude_symmetric_per_side = true;
s.replace_design(Session::default());
assert!(s.surface_extrude_symmetric_per_side);
}
/// A second distance goes the other way from the first side (#2700): along the normal when the
+14 -4
View File
@@ -25,7 +25,7 @@ pub static COMMANDS: &[CommandSpec] = &[
.key("E")
.contract(&EXTRUDE_CONTRACT)
.output(output_schema_for::<FeatureResult>)
.params("distance: expr (or through_all: true); taper?: angle expr (positive: outward, so the far end is larger along the extrusion direction; negative: inward, so the far end is smaller); corner?: preserve_curvature|tangent|round (how a taper closes a sharp corner its offset opens: each wall continues as itself, a line's plane or an arc's cone, until it meets its neighbour; each continues straight along its end tangent; or an arc about the corner. Without it, each profile preserves curvature where every curve is a line or an arc and takes tangent where another curve has a corner, and the feature's warning says so; a corner rule given is kept, and refused where the kernel cannot build it); sketch?: id|name (default: active or last sketch); profiles?: all | [index] | [{curves: [ids]}] (the profile whose outer loop is made of exactly these curves, or pieces of them; found again on every recompute, so it follows parameter changes; islands inside are its holes; an error when no profile or several match) | [{point:[x,y]}] (index and point picks are stored by their curves when that finds the same profile; a pick on a drawn profile that reference geometry, such as the projected outline of the face the sketch is on, cuts into regions takes the whole drawn profile); exact_regions?: bool (each index or point pick is exactly the region it names, as the dialogs send); default: every drawn profile, except that a loop inside another is its hole and a loop inside that hole is material again; face?: [x,y,z] (extrude a planar body face instead of a sketch profile); faces?: [[x,y,z],…] (coplanar faces of one body); face_body?: name (whose face, where faces of several bodies meet at the point); direction?: positive|negative|symmetric (distance is total thickness, split evenly around the start plane); convention?: total_distance|legacy_per_side (default total_distance; legacy preserves older symmetric extents); distance2?: expr (Two Sides: a second distance the other way from the first side, which may be through_all or to; with direction: negative the first side goes against the normal and distance2 along it); start_offset?: expr (along the sketch normal, also with direction: negative); to?: [x,y,z] (To Object: a face, vertex or point; to_offset?: expr past it); from?: [x,y,z] (From Object: start at that face or point); operation?: new|join|cut|intersect|auto (cut into a body, otherwise join existing solids; new in an empty component); touching?: separate|one_body (what a join makes of pieces that share no face: separate, the default, makes each piece that touches another only along an edge or at a point a body of its own and keeps pieces that touch nothing in one body; one_body keeps every piece in one body); targets?: [body] (Join from a face, or from a sketch on a body's face, defaults to that face's body; explicit targets or participants override); name?; body_name?; thin?: true (Thin: a wall along sketch curves instead of the profiles) with curves?: [curve ids] (open chains and closed loops, joined where they meet end to end; default: every drawn curve of the sketch), thickness: expr, side?: center|inside|outside|two_sides (a closed loop's inside is the area it encloses, an open chain's the side it bends toward, a straight line's the left of its first curve as drawn; default center), thickness2?: expr (two_sides: the thickness outside); corners are mitred, crossing walls are one"),
.params("distance: expr (or through_all: true); taper?: angle expr (positive: outward, so the far end is larger along the extrusion direction; negative: inward, so the far end is smaller); corner?: preserve_curvature|tangent|round (how a taper closes a sharp corner its offset opens: each wall continues as itself, a line's plane or an arc's cone, until it meets its neighbour; each continues straight along its end tangent; or an arc about the corner. Without it, each profile preserves curvature where every curve is a line or an arc and takes tangent where another curve has a corner, and the feature's warning says so; a corner rule given is kept, and refused where the kernel cannot build it); sketch?: id|name (default: active or last sketch); profiles?: all | [index] | [{curves: [ids]}] (the profile whose outer loop is made of exactly these curves, or pieces of them; found again on every recompute, so it follows parameter changes; islands inside are its holes; an error when no profile or several match) | [{point:[x,y]}] (index and point picks are stored by their curves when that finds the same profile; a pick on a drawn profile that reference geometry, such as the projected outline of the face the sketch is on, cuts into regions takes the whole drawn profile); exact_regions?: bool (each index or point pick is exactly the region it names, as the dialogs send); default: every drawn profile, except that a loop inside another is its hole and a loop inside that hole is material again; face?: [x,y,z] (extrude a planar body face instead of a sketch profile); faces?: [[x,y,z],…] (coplanar faces of one body); face_body?: name (whose face, where faces of several bodies meet at the point); direction?: positive|negative|symmetric (distance is total thickness, split evenly around the start plane); convention?: total_distance|legacy_per_side (how a symmetric distance is read; default total_distance, split evenly around the start plane; legacy_per_side: the distance on each side, as older symmetric extrudes keep); distance2?: expr (Two Sides: a second distance the other way from the first side, which may be through_all or to; with direction: negative the first side goes against the normal and distance2 along it); start_offset?: expr (along the sketch normal, also with direction: negative); to?: [x,y,z] (To Object: a face, vertex or point; to_offset?: expr past it); from?: [x,y,z] (From Object: start at that face or point); operation?: new|join|cut|intersect|auto (cut into a body, otherwise join existing solids; new in an empty component); touching?: separate|one_body (what a join makes of pieces that share no face: separate, the default, makes each piece that touches another only along an edge or at a point a body of its own and keeps pieces that touch nothing in one body; one_body keeps every piece in one body); targets?: [body] (Join from a face, or from a sketch on a body's face, defaults to that face's body; explicit targets or participants override); name?; body_name?; thin?: true (Thin: a wall along sketch curves instead of the profiles) with curves?: [curve ids] (open chains and closed loops, joined where they meet end to end; default: every drawn curve of the sketch), thickness: expr, side?: center|inside|outside|two_sides (a closed loop's inside is the area it encloses, an open chain's the side it bends toward, a straight line's the left of its first curve as drawn; default center), thickness2?: expr (two_sides: the thickness outside); corners are mitred, crossing walls are one"),
CommandSpec::new("solid.revolve", "Revolve", revolve)
.at("SOLID", "CREATE")
.icon("revolve")
@@ -1120,6 +1120,18 @@ fn thin_regions(s: &Session, ss: &solidcraft_doc::SolvedSketch, thin: &ThinWall)
solidcraft_sketch::thin_wall_regions(&curves, inside, outside).map_err(|e| format!("thin wall: {e}"))
}
/// How a new extent of `cmd` (`solid.extrude` or `surface.extrude`) reads a symmetric distance
/// when the call doesn't say: the total, split evenly around the start plane, for both. A surface
/// extrude reads it on each side, as surface extrudes did before, while the user's preference
/// says so ([`Session::surface_extrude_symmetric_per_side`]).
pub(crate) fn default_extrude_convention(s: &Session, cmd: &str) -> solidcraft_doc::ExtrudeConvention {
if cmd == "surface.extrude" && s.surface_extrude_symmetric_per_side {
solidcraft_doc::ExtrudeConvention::LegacyPerSide
} else {
solidcraft_doc::ExtrudeConvention::TotalDistance
}
}
/// An extrude's extent from its parameters: distance (or through all, or to an object), the
/// side(s), a second distance, a start offset, a taper, and from an object.
pub(super) fn extent_param(s: &Session, p: &Value, cmd: &str) -> Result<Extent> {
@@ -1156,9 +1168,7 @@ pub(super) fn extent_param(s: &Session, p: &Value, cmd: &str) -> Result<Extent>
check_expr(s, d, Kind::Length, cmd, "start_offset")?;
}
let convention = match p.get("convention") {
// Surface Extrude shares Extent but retains its existing per-side distance semantics.
None if cmd == "surface.extrude" => solidcraft_doc::ExtrudeConvention::LegacyPerSide,
None => solidcraft_doc::ExtrudeConvention::TotalDistance,
None => default_extrude_convention(s, cmd),
Some(value) => serde_json::from_value(value.clone()).map_err(|_| bad(cmd, "`convention` must be total_distance or legacy_per_side"))?,
};
Ok(Extent {
+18 -4
View File
@@ -379,14 +379,28 @@ fn three_d_sketch_curves() {
let src = s.doc.features.last().unwrap().id;
run(&mut s, "sketch.create", json!({"plane": "XY"}));
let r = run(&mut s, "sketch.project_to_surface", json!({"curves": [{"sketch": src, "curve": l}], "face": [0, 0, 20]}));
// The line's projection where it first meets the sphere: the arc of the great circle in y = 0
// from x = -10 to 10 over the top (z = √(400 − x²)), one wire though SMLib splits it at the
// pole, and no curve on the far side.
assert_eq!(r["links"][0]["wires"].as_array().unwrap().len(), 1, "{r}");
let wid = r["links"][0]["wires"][0].as_str().unwrap().to_string();
let st = s.model.state();
let sk = &st.sketch(s.active_sketch.unwrap()).unwrap().sketch;
let w = &sk.wires[sk.wire_index(&wid).unwrap()];
assert!(w.pts.len() > 20);
for p in &w.pts {
assert!((p.len() - 20.0).abs() < 0.1, "{p:?}");
assert!(p.z > 0.0);
assert!(!w.exact.is_empty());
// SMLib makes projected curves to a millionth of the body's size (the sphere's 40 mm box).
let tol = 40.0 * 1e-6;
let ends = [*w.pts.first().unwrap(), *w.pts.last().unwrap()];
let top = 300f64.sqrt();
assert!(ends.iter().all(|e| (e.x.abs() - 10.0).abs() < tol && e.y.abs() < tol && (e.z - top).abs() < tol), "{ends:?}");
assert!((ends[0].x + ends[1].x).abs() < tol, "{ends:?}");
// Along its exact curves (the wire's points are its spans' polygon), on the sphere's top.
for c in &w.exact {
let eval = solidcraft_geom::brep::eval::CurveEval::new(&c.curve).unwrap();
for k in 0..=32 {
let p = eval.point(c.interval[0] + (c.interval[1] - c.interval[0]) * f64::from(k) / 32.0).unwrap();
assert!((p.len() - 20.0).abs() < tol && p.y.abs() < tol && p.z >= top - tol, "{p:?}");
}
}
// Delete the wire.
run(&mut s, "sketch.delete", json!({"entities": [wid]}));
+3 -2
View File
@@ -39,7 +39,7 @@ pub static COMMANDS: &[CommandSpec] = &[
CommandSpec::new("surface.extrude", "Surface Extrude", surface_extrude)
.at("SURFACE", "CREATE")
.icon("surface_extrude")
.params("sketch?: id|name; curves?: [curve ids] (open or closed chains of curves meeting end to end) and/or profiles? (their boundaries; the default when no curves are given); distance: expr; direction?: positive|negative|symmetric; distance2?: expr; start_offset?: expr; name?, body_name? (a surface body: walls only, no caps)"),
.params("sketch?: id|name; curves?: [curve ids] (open or closed chains of curves meeting end to end) and/or profiles? (their boundaries; the default when no curves are given); distance: expr; direction?: positive|negative|symmetric (symmetric: distance is the total, split evenly around the start plane, as solid.extrude); convention?: total_distance|legacy_per_side (as solid.extrude; default total_distance, or legacy_per_side, the distance on each side, under the user's preference for the older reading); distance2?: expr; start_offset?: expr; name?, body_name? (a surface body: walls only, no caps)"),
CommandSpec::new("surface.revolve", "Surface Revolve", surface_revolve)
.at("SURFACE", "CREATE")
.icon("surface_revolve")
@@ -797,7 +797,8 @@ mod tests {
// The line's wall and the half circle's (radius 5): length × height.
let want = (10.0 + std::f64::consts::PI * 5.0) * 4.0;
assert!((area(&s, "Wall") - want).abs() < want * 1e-3, "{} vs {want}", area(&s, "Wall"));
run(&mut s, "surface.extrude", json!({"sketch": "S", "curves": ["l1"], "distance": 2, "direction": "symmetric", "body_name": "Both"}));
// Symmetric: the distance is the total, split evenly around the sketch plane.
run(&mut s, "surface.extrude", json!({"sketch": "S", "curves": ["l1"], "distance": 4, "direction": "symmetric", "body_name": "Both"}));
let bb = solidcraft_kernel::measure(&s.world_state().unwrap().body("Both").unwrap().body).unwrap().bbox;
assert!((bb.min.z + 2.0).abs() < 1e-9 && (bb.max.z - 2.0).abs() < 1e-9, "{bb:?}");
run(&mut s, "edit.undo", json!({}));
+8
View File
@@ -380,6 +380,10 @@ pub struct Session {
/// A new metric tapped hole given no `diameter` drills the major diameter less the pitch,
/// as before the tap maker's drills (a user preference); false: the tap maker's drill.
pub metric_tap_drill_major_less_pitch: bool,
/// A new symmetric surface extrude given no `convention` reads its distance on each side, as
/// surface extrudes did before they matched solid ones (a user preference); false: the total,
/// split evenly around the start plane, as a solid extrude reads it.
pub surface_extrude_symmetric_per_side: bool,
/// How calls that break a command's parameter contract are treated (off by default). It
/// belongs to the session, not the design, so it survives opening and starting designs.
pub param_check: schema::ParamCheck,
@@ -600,6 +604,7 @@ impl Session {
followed: None,
auto_project: true,
metric_tap_drill_major_less_pitch: false,
surface_extrude_symmetric_per_side: false,
param_check: schema::ParamCheck::Off,
easyprint_upload: None,
live_links: None,
@@ -647,6 +652,7 @@ impl Session {
pub fn replace_design(&mut self, fresh: Session) {
let auto_project = self.auto_project;
let metric_tap_drill_major_less_pitch = self.metric_tap_drill_major_less_pitch;
let surface_extrude_symmetric_per_side = self.surface_extrude_symmetric_per_side;
let param_check = self.param_check;
let easyprint_upload = self.easyprint_upload.take();
let render_viewport = self.render_viewport.clone();
@@ -663,6 +669,7 @@ impl Session {
self.command_check = command_check;
self.auto_project = auto_project;
self.metric_tap_drill_major_less_pitch = metric_tap_drill_major_less_pitch;
self.surface_extrude_symmetric_per_side = surface_extrude_symmetric_per_side;
self.param_check = param_check;
self.easyprint_upload = easyprint_upload;
self.render_viewport = render_viewport;
@@ -1406,6 +1413,7 @@ impl Session {
followed: None,
auto_project: self.auto_project,
metric_tap_drill_major_less_pitch: self.metric_tap_drill_major_less_pitch,
surface_extrude_symmetric_per_side: self.surface_extrude_symmetric_per_side,
param_check: self.param_check,
easyprint_upload: self.easyprint_upload.clone(),
live_links: None,
+9 -6
View File
@@ -610,9 +610,10 @@ mod tests {
/// A smooth edge (a round's seam with the face it runs into) has nothing to round: refused
/// before SMLib, saying so. An edge that runs on tangentially into one left out is SMLib's to
/// end: where it cannot (the end face's top edge into the round's end arc) the refusal says
/// why, and rounded with its tangent chain the edge builds; where it can (a vertical edge run
/// on up a top round's end arc into the corner, ladder 07-fillets/018) it builds.
/// end: the end face's top edge into the round's end arc builds, its round run on through the
/// arc's round until it leaves the material (rig fillets/1207-fillet-box-end-edge-into-
/// unblended-round), and with its tangent chain the edge builds too; a vertical edge run on
/// up a top round's end arc into the corner (ladder 07-fillets/018) builds.
#[test]
fn smooth_edges_and_unfinished_tangent_chains_are_refused_saying_why() {
let b = cube();
@@ -620,10 +621,12 @@ mod tests {
// the seam where the r3 round meets the top, 3 in from the old edge
let seam = imp::blend(&rounded, "fillet", Kind::Round, &[Vec3::new(10.0, 17.0, 20.0)], &[1.0]).unwrap_err().to_string();
assert!(seam.contains("is smooth: its faces meet tangentially, so there is nothing to round"), "{seam}");
// the end face's top edge runs on tangentially into the round's end arc
// the end face's top edge runs on tangentially into the round's end arc: its r1 round
// goes on along y through the r3 round until that drops below it, at y = 17 + sqrt(5)
// (the rig case's closed form: 8000 - 20 (9 - 9 pi/4) - 17 (1 - pi/4) - 0.218236)
let top = Vec3::new(0.0, 8.0, 20.0);
let alone = imp::blend(&rounded, "fillet", Kind::Round, &[top], &[1.0]).unwrap_err().to_string();
assert!(alone.contains("continues tangentially"), "{alone}");
let alone = fillet(&rounded, &[top], 1.0).unwrap();
assert!((volume(&alone) - 7957.505202).abs() < 1e-3, "{}", volume(&alone));
let chain = crate::tangent_chain(&rounded, &[top]).unwrap();
assert!(chain.len() > 1, "{chain:?}");
let whole = fillet(&rounded, &chain, 1.0).unwrap();
+10 -4
View File
@@ -280,7 +280,10 @@ fn draft_tilts_faces() {
let side = Vec3::new(40.0, 15.0, 10.0);
let r = crate::draft(&b, &[side], &Plane::XY, Vec3::Z, 5f64.to_radians()).unwrap();
let h = verified(&r, &b, Reach { made: 0.0, moved: 2.0 });
assert_eq!(changes(h), [0, 6, 0, 0, 0]);
// The side tilts about its bottom edge (on the neutral plane z = 0); the top and the two
// faces beside it lose a wedge along their moved edges. The bottom and the opposite side
// are untouched.
assert_eq!(changes(h), [2, 4, 0, 0, 0]);
assert_eq!(with(h, &[face(face_at(&b, side))]).len(), 1);
// Walls of a body that is not convex.
let l = ell();
@@ -596,10 +599,13 @@ mod smlib {
let tilted = with(h, &[face(face_at(&b, side))]);
assert_eq!(tilted.len(), 1, "{h:?}");
assert_eq!(h.faces[tilted[0]].change, Change::Modified);
// A round wall isn't flat; the top isn't parallel to the pull.
// A round wall along the pull leans in the same way: the rod drafts to a frustum, radius
// 5 at the neutral plane and 5 - 10 tan 5 deg at the top. The top isn't parallel to the pull.
let rod = cylinder(Vec3::ZERO, Vec3::Z, 5.0, 10.0).unwrap();
let e = offset_backend::draft(&rod, &[Vec3::new(5.0, 0.0, 5.0)], &Plane::XY, Vec3::Z, 5.0 * deg).unwrap_err();
assert!(e.to_string().contains("not supported yet"), "{e}");
let frustum = offset_backend::draft(&rod, &[Vec3::new(5.0, 0.0, 5.0)], &Plane::XY, Vec3::Z, 5.0 * deg).unwrap();
let top = 5.0 - 10.0 * (5.0 * deg).tan();
let exact = std::f64::consts::PI * 10.0 * (25.0 + 5.0 * top + top * top) / 3.0;
assert!((volume(&frustum) - exact).abs() < 1e-3, "{} vs {exact}", volume(&frustum));
let e = offset_backend::draft(&b, &[Vec3::new(20.0, 15.0, 20.0)], &Plane::XY, Vec3::Z, 5.0 * deg).unwrap_err();
assert!(e.to_string().contains("not supported yet"), "{e}");
}
+22
View File
@@ -73,3 +73,25 @@ fn periodic_step_seam_survives_identity_rotation_and_translation() {
assert_topology(body, &rigid, [[0., 1., 0., 0.], [-1., 0., 0., 0.], [0., 0., 1., 0.], [10., 10., 30., 1.]]);
assert_eq!(crate::step_export(&[body], "source snapshot").unwrap(), unchanged);
}
/// A body mirrored in SMLib reads back from its record as the same valid solid: a plate with a
/// through hole (the hole's cylinder comes out inside out) and a box with two rounds meeting at a
/// corner (their intersection edge has a tolerance of its own, wider than the body's). Read back
/// from the record, the hole's cylinder swept the wrong way about its axis 30 mm off its NURBS,
/// and the rounds' shared edge lost its tolerance to the body's.
#[test]
fn mirrored_bodies_read_back_from_their_records_valid() {
let plate = crate::box_solid(Vec3::ZERO, Vec3::new(30., 40., 20.)).unwrap();
let hole = crate::cylinder(Vec3::new(20., 20., -5.), Vec3::Z, 5.0, 30.0).unwrap();
let holed = crate::boolean(&plate, &hole, crate::BoolOp::Cut).unwrap().unwrap();
let rounded = crate::fillet(&plate, &[Vec3::new(15., 0., 20.), Vec3::new(0., 0., 10.)], 3.0).unwrap();
// The mirror in x = 30.
let mirror = [[-1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [60., 0., 0., 1.]];
for (what, body) in [("holed plate", holed), ("rounded box", rounded)] {
let mirrored = transform_matrix(&body, mirror).unwrap();
let read_back = Body::from_record(mirrored.record().clone()).unwrap();
assert!(matches!(crate::validity(&read_back).smlib, Some(crate::SmlibCheck::Valid)), "{what}: {:?}", crate::validity(&read_back).smlib);
let (want, got) = (crate::measure(&body).unwrap().volume, crate::measure(&read_back).unwrap().volume);
assert!((got - want).abs() < 1e-6 * want, "{what}: volume {got}, expected {want}");
}
}
+15 -8
View File
@@ -43,13 +43,19 @@ fn check_volume(body: &Body, lo: f64, hi: f64) {
#[test]
fn shell_of_a_revolved_barrel() {
let barrel = barrel();
let side = (0..barrel.face_count())
.find_map(|i| match face_surface(&barrel, i) {
Some(s @ FaceSurface::Torus { major, minor, .. }) if (major - CENTRE).abs() < 1e-6 && (minor - RADIUS).abs() < 1e-6 => Some(s),
_ => None,
})
.expect("barrel side is the inner sheet of a spindle torus");
assert!(side.nearest(Vec3::new(15.0, 0.0, HALF_HEIGHT)).unwrap().dist(Vec3::new(14.0, 0.0, HALF_HEIGHT)) < 1e-6);
// The side is the inner (lemon) zone of a spindle torus: SMLib's torus describes only its
// outer zone, so the side is the exact rational surface of revolution of the arc. Two flat
// caps and that side; the solid is the closed-form barrel, 14 mm round at mid height (`contains` asks the display mesh, so a margin round it).
assert_eq!(barrel.face_count(), 3);
let planes = (0..barrel.face_count()).filter(|i| matches!(face_surface(&barrel, *i), Some(FaceSurface::Plane { .. }))).count();
assert_eq!(planes, 2, "two caps and the curved side");
let full = integral(RADIUS, 2.0 * HALF_HEIGHT) - integral(RADIUS, 0.0);
let volume = measure(&barrel).unwrap().volume;
assert!((volume - full).abs() < full * 1e-3, "{volume} vs {full}");
for turn in [0.0, 1.0, 2.5, 4.0] {
let (c, s) = (f64::cos(turn), f64::sin(turn));
assert!(barrel.contains(Vec3::new(13.8 * c, 13.8 * s, HALF_HEIGHT)) && !barrel.contains(Vec3::new(14.2 * c, 14.2 * s, HALF_HEIGHT)));
}
let result = shell(&barrel, &[Vec3::new(0.0, 0.0, 2.0 * HALF_HEIGHT)], 2.0).unwrap();
assert!(result.validity().is_empty(), "{:?}", result.validity());
assert_eq!(result.shell_count(), 1);
@@ -62,7 +68,8 @@ fn shell_of_a_revolved_barrel() {
check_volume(&result, 2.0, 2.0 * HALF_HEIGHT);
let history = result.history().expect("exact shell face history");
assert_eq!(history.operands, 1);
assert_eq!(history.faces.iter().filter(|f| matches!(f.origins.as_slice(), [FaceOrigin::Offset { operand: 0, .. }])).count(), 4);
// The inner wall and the inner floor, offsets of the barrel's side and bottom (the top opened).
assert_eq!(history.faces.iter().filter(|f| matches!(f.origins.as_slice(), [FaceOrigin::Offset { operand: 0, .. }])).count(), 2);
let step = step_export(&[&result], "barrel shell").unwrap();
let imported = step_import(&step).unwrap();
assert_eq!(imported.bodies.len(), 1);
+8 -8
View File
@@ -1,10 +1,10 @@
# Rust target, SHA-256 of smlib-<target>.tar.gz in the release prebuilt-<SMLIB_REV> of
# tangency-labs/smlib. Written by scripts/fetch-smlib.sh --pin; never edited by hand.
aarch64-apple-darwin d5f9ee5b49f2b1b9777a27942401516a59384105c2dce58a6bd571efe7d77aa8
aarch64-pc-windows-msvc d5df522ed4459dad9ffba4d5b22c05f8bebcf4d5ba217f62395c2ea689492f14
aarch64-unknown-linux-gnu b7849d6dbdb358380b7352742dccfd33a71bc423e1fda18566fcd58a0b406ff3
i686-pc-windows-msvc 6b7cb77f7fd05f5f458689e49547ec9d9d4920f28cd79f5c16ae44fa8682bc46
wasm32-unknown-unknown 63f9c65ae041d1db4b8ffb7306bd6a4f4b7f125f6fb1772ca5dcc14763c76bd6
x86_64-apple-darwin 99a5e32ae73c82f9020a046245312cb5352974069a464af3ac9da1f624800ad1
x86_64-pc-windows-msvc 828211a338c42be882eb9084fef89087479b713dd641bb3aa0b3b2b70a2b3bfa
x86_64-unknown-linux-gnu f69203a49aa1c1a4272364cb13585c84557c466f4863adc66cb1a5f623462289
aarch64-apple-darwin 0288998e1d7e0bc14149f7abc2cd7e44852a66af43b187a700981cffdfbc89dc
aarch64-pc-windows-msvc 51992eb16f529c0969a22d9c852c65c582dd48a8ca5febf28a5f28186dbec000
aarch64-unknown-linux-gnu 9d0b96bbaf7ae255c0bcd8828fb3cbb0b3ffda053de47bca73edf8429efcffad
i686-pc-windows-msvc 26f130fc69f57bd0aa0552b653dde5120a6526525145f4f1cf91b8c0914de95f
wasm32-unknown-unknown a5a0b287078e4d1f216e8d78194cbb839fcd65a2ad9cb93b491ee5aa46902f7d
x86_64-apple-darwin 83768b97779df83aa11319668be3c78dad1d84f21e20ea6d923ff2a7bf352889
x86_64-pc-windows-msvc 21f688d0d3d4c5d9e1e3cb33fb2991701a1172299d36bb6342238836a11cb85e
x86_64-unknown-linux-gnu 5c6145e288a3e7cd741d1f3f2b96a5a39016c9ceac950b1e05ae75a5f4cb5f53
+1 -1
View File
@@ -1 +1 @@
7e917f0a308d620491fdbc07c5e07fb29a2b8300
90aabff7937853f94ab1ddb9115382844f369793
+104 -10
View File
@@ -6,14 +6,17 @@
//!
//! As there, every operation works on a copy of its body (`SmApiBrepCopy`) and picks faces by
//! point; the shell and the offsets are `SmApiShellBrepFull` and `SmApiOffsetBrepFull`, with
//! convex edges extended and the results merged.
//! convex edges extended and the results merged. A sheet offset takes faces that close into a
//! solid as the capi does since tangency-labs/smlib#17.
//!
//! What the capi asks of SMLib code that solidcore does not have is [`Error::Unsupported`],
//! refused where the capi would first reach it, so every error before it is the C++ path's: a
//! face move (`SmOffsetFacesExecutive`, fork a96ce9f, solidcore#1060).
//!
//! A draft's tilted faces go in through solidcore's `SmBrep::LocalOperation`
//! ([`local_operation`]); the capi's check that it moved some face (`moved_faces`) needs face
//! A draft tilts planes and, since tangency-labs/smlib#27, turns a cylinder about the pull into
//! a cone (solidcore's `Cone::lean_cylinder`, solidcore#1545); a cone that is not a cylinder
//! (smlib#53) is [`Error::Unsupported`]. A draft's tilted faces go in through solidcore's
//! `SmBrep::LocalOperation` ([`local_operation`]); the capi's check that it moved some face (`moved_faces`) needs face
//! history solidcore does not report (solidcore#1462) and is not made.
use solidcore::EntityRef;
@@ -33,7 +36,8 @@ use solidcore::offset::offset_executive::p2::{
};
use solidcore::query::api_queries::{BrepRef, face_bounding_box, face_classify_uv, face_closest_point_in_shape, face_internal_point};
use solidcore::query::brep::{BrepIdentity, BrepQuery, LiveBrepObjects};
use solidcore::surface::surface::SurfaceKind;
use solidcore::surface::cone::Cone;
use solidcore::surface::surface::{Surface, SurfaceKind};
use solidcore::sweep::topology_sweep::store::SweepIdentities;
use solidcore::topology::brep::local_operation::local_operation;
use solidcore::topology::brep::{p1 as brep_p1, p2 as brep_p2, p3 as brep_p3};
@@ -509,16 +513,18 @@ pub(crate) fn thicken(body: &Body, thickness: f64, symmetric: bool) -> Result<Bo
}
/// `smlib_offset_sheet`: every face of a sheet moved onto its surface's offset by `distance`
/// along its normal; a closed solid is [`Error::Argument`].
/// along its normal; faces that close into a solid (a sphere's one face, a block's six) give the
/// offset solid (tangency-labs/smlib#17, which dropped the capi's refusal of a closed solid).
pub(crate) fn offset_sheet(body: &Body, distance: f64) -> Result<Body> {
if !distance_ok(distance) {
return Err(Error::Argument);
}
on_copy("smlib_offset_sheet", body, |k, mut w| {
if brep_p2::is_manifold_solid(&w)? {
return Ok(Err(Error::Argument));
// `take`: a result without faces (a sphere moved in to its centre) is SMLIB_ERR_EMPTY.
match called(offset_brep_full(k, &mut w, distance))? {
Ok(r) => finish(r, false),
Err(e) => Ok(Err(e)),
}
called(offset_brep_full(k, &mut w, distance))
})
}
@@ -533,10 +539,83 @@ fn unit(v: [f64; 3]) -> Option<Vec3> {
(len > 1e-12 && len.is_finite()).then(|| u * (1.0 / len))
}
/// `outward_normal`: the outward normal of face `f` (its outer faceuse `fu`) at `at`, a point on
/// it: its surface's normal there, turned with the outer faceuse. `None` where SMLib cannot place
/// the point on the surface (the capi's `STEPInversionAnswered` also takes a point outside the
/// domain or off the surface by more than its tolerance; solidcore's inversion answers those with
/// a status, so they are `None` here: the face's own internal point is neither).
fn outward_normal(k: &Kernel, b: &Brep, f: FaceId, fu: FaceuseId, at: Point3) -> solidcore::Result<Option<Vec3>> {
let Some(surf) = b.face(f)?.surface.as_ref() else { return Ok(None) };
let Some((step, _)) = answer(surf.step_inversion(k, &surf.step_uv_domain(), at, 1e6, None))? else { return Ok(None) };
let Some(nurb) = answer(surf.convert_uv_from_step_to_nurbs(k, step))? else { return Ok(None) };
let Some(mut n) = answer(surf.evaluate_normal(k, nurb, Side::Left, Side::Left))? else { return Ok(None) };
if b.faceuse(fu)?.orientation != OrientType::Same {
n = -n;
}
Ok(Some(n))
}
/// `drafted_cone` (tangency-labs/smlib#27): the cone a face on the cylinder `cyl` about the pull
/// (its outward normal `n` at `inside`) becomes drafted by `angle` about its circle on the neutral
/// plane (through `origin`, normal `normal`), so that it leans in going along `pull`: its radius
/// R - s h tan(angle) at height h along the pull from that circle, s = 1 where the face looks
/// away from the axis (a pin), -1 where it looks towards it (a hole). The capi moves the
/// cylinder's NURB control points radially and lets `CopyAndAddAnalytics` find the cone;
/// solidcore's `Cone::lean_cylinder` (solidcore#1545) is that edit, keeping the cylinder's
/// parameters so the face's UV trims stay valid. [`Error::Unsupported`] when the pull does not
/// run along the axis, the axis lies in the neutral plane, or the cone would close within the
/// face's span. A cone that is not a cylinder (`drafted_cone`'s turned generators,
/// tangency-labs/smlib#53) is [`Error::Unsupported`] too: `lean_cylinder` takes cylinders only.
#[allow(clippy::too_many_arguments)] // the capi's drafted_cone
fn drafted_cone(
k: &Kernel,
cyl: &Cone,
n: Vec3,
inside: Point3,
origin: Point3,
normal: Vec3,
pull: Vec3,
angle: f64,
) -> solidcore::Result<Out<Cone>> {
let bot = cyl.bot_radius();
if (bot - cyl.top_radius()).abs() > 1e-12 * (1.0 + bot) {
return Ok(Err(Error::Unsupported));
}
let frame = cyl.canonical().origin;
let z = frame.x_axis().cross(frame.y_axis());
let len = z.length();
if !(len > 0.0 && len.is_finite()) {
return Ok(Err(Error::Unsupported));
}
let z = z * (1.0 / len);
let sense = z.dot(pull);
if (sense.abs() - 1.0).abs() > 1e-9 {
return Ok(Err(Error::Unsupported));
}
let axis = frame.origin();
let toward = z.dot(normal);
if toward.abs() < 1e-12 {
return Ok(Err(Error::Unsupported));
}
// The hinge circle's centre: the axis on the neutral plane, at the cylinder's height v0.
let v0 = (origin - axis).dot(normal) / toward;
let centre = axis + z * v0;
let radial = (inside - centre) - pull * (inside - centre).dot(pull);
let s = if radial.dot(n) >= 0.0 { 1.0 } else { -1.0 };
// The radius changes by -s tan(angle) per unit along the pull, so by -s tan(angle) (z . pull)
// per unit of the cylinder's height, from its radius at v0.
let slope = -s * angle.tan() * sense;
if !slope.is_finite() {
return Ok(Err(Error::Unsupported));
}
Ok(answer(cyl.lean_cylinder(k, slope, v0))?.ok_or(Error::Unsupported))
}
/// `smlib_draft`: its checks, the solid check, the pick, then `draft_faces`: each picked face (a
/// plane parallel to the pull) gets a copy of its plane turned by `angle` about its line on the
/// neutral plane, and `SmBrep::LocalOperation` extends or trims the faces around them to meet
/// the tilted planes.
/// neutral plane, and a cylinder about the pull the cone `drafted_cone` gives
/// (tangency-labs/smlib#27); `SmBrep::LocalOperation` extends or trims the faces around them to
/// meet the tilted surfaces.
pub(crate) fn draft(
body: &Body,
points: &[[f64; 3]],
@@ -572,6 +651,21 @@ pub(crate) fn draft(
let (Some(surf), Some(fu)) = (face.surface.as_ref(), fu) else {
return Ok(Err(Error::Status(INVALID_INPUT)));
};
// A cylinder about the pull drafted becomes a cone (`drafted_cone`).
if let SurfaceKind::Cone(c) = surf.kind_with_nurb(k)? {
let cyl = (**c).clone();
let Some(inside) = answer(face_internal_point(k, &mut w, f))? else {
return Ok(Err(Error::Status(INVALID_INPUT)));
};
let Some(n) = outward_normal(k, &w, f, fu, inside)? else {
return Ok(Err(Error::Status(INVALID_INPUT)));
};
match drafted_cone(k, &cyl, n, inside, p3(neutral_origin), normal, along, angle)? {
Ok(cone) => surfaces.push(Surface::from(cone)),
Err(e) => return Ok(Err(e)),
}
continue;
}
let SurfaceKind::Plane(plane) = surf.kind_with_nurb(k)? else {
return Ok(Err(Error::Unsupported));
};
+34 -8
View File
@@ -19,7 +19,7 @@ use solidcore::primitive::api_curves::create_line_segment;
use solidcore::sweep::api_brep::create_linear_sweep;
use super::offset::{draft, offset_faces, offset_sheet, shell, thicken};
use super::{Body, area, bounds, counts, make_box, make_cylinder, run, to_arrays, volume};
use super::{Body, area, bounds, counts, make_box, make_cylinder, make_sphere, run, to_arrays, volume};
use crate::export::native;
use crate::{BooleanOp, Error};
@@ -33,6 +33,7 @@ const TOL: f64 = 0.01;
enum Shape {
Box([f64; 3], [f64; 3]),
Cylinder([f64; 3], f64, f64),
Sphere([f64; 3], f64),
/// A sheet: the line from the first point to the second swept along `dir` by `dist`.
LineSheet([f64; 3], [f64; 3], [f64; 3], f64),
/// A sheet: the arc about +Z through `center` of `radius` from 0 to `degrees`, swept along
@@ -52,6 +53,7 @@ impl Shape {
match self {
Shape::Box(o, s) => make_box(o, s).unwrap(),
Shape::Cylinder(o, r, h) => make_cylinder(o, r, h).unwrap(),
Shape::Sphere(o, r) => make_sphere(o, r).unwrap(),
Shape::LineSheet(a, b, dir, dist) => run("sheet", |k| {
let c = Curve::from(create_line_segment(v3(a), v3(b))?);
create_linear_sweep(k, &[Some(&c)], v3(dir), dist, false)
@@ -97,6 +99,8 @@ enum Expect {
Volume(f64),
/// A solid of this volume whose bounds along z are these.
Slab(f64, f64, f64),
/// A solid of this volume (relative 1e-9) whose bounds are these.
Solid(f64, [f64; 3], [f64; 3]),
/// A sheet of this area (relative 1e-9) whose bounds are these.
Sheet(f64, [f64; 3], [f64; 3]),
/// This error.
@@ -119,6 +123,8 @@ const FRONT: [f64; 3] = [15.0, 0.0, 5.0];
const Z: [f64; 3] = [0.0, 0.0, 1.0];
/// A 30 x 20 sheet in z = 0: the x axis from 0 to 30 swept 20 along y.
const PLATE: Shape = Shape::LineSheet([0.0; 3], [30.0, 0.0, 0.0], [0.0, 1.0, 0.0], 20.0);
/// A sphere of radius 10 about the origin.
const BALL: Shape = Shape::Sphere([0.0; 3], 10.0);
/// A quarter of a cylinder of radius 5 about the z axis, 10 high.
const QUARTER: Shape = Shape::ArcSheet([0.0; 3], 5.0, 90.0, 10.0);
@@ -151,10 +157,17 @@ fn case(name: &str) -> Case {
"thicken_a_solid" => c(Op::Thicken(BLOCK, 2.0, false), Expect::Fails(Error::Argument)),
// The plate moved 3 along its normal (+z: the x axis swept along y): still 600, at z = 3.
"offset_sheet_plate" => c(Op::OffsetSheet(PLATE, 3.0), Expect::Sheet(600.0, [0.0, 0.0, 3.0], [30.0, 20.0, 3.0])),
// A sphere's one face closes on itself (tangency-labs/smlib fix #17): r = 10 moved out 2 is
// the ball of radius 12, (4/3) π 12³; moved in 10, to its centre, nothing is left.
"offset_sheet_a_sphere" => c(Op::OffsetSheet(BALL, 2.0), Expect::Volume(4.0 / 3.0 * PI * 12.0f64.powi(3))),
"offset_sheet_a_sphere_to_its_centre" => c(Op::OffsetSheet(BALL, -10.0), Expect::Fails(Error::Empty)),
// The quarter cylinder moved 2 along its normal (outward: the arc's tangent swept along
// z): radius 7, area (π/2) 7 · 10.
"offset_sheet_quarter_cylinder" => c(Op::OffsetSheet(QUARTER, 2.0), Expect::Sheet(PI / 2.0 * 7.0 * 10.0, [0.0, 0.0, 0.0], [7.0, 7.0, 10.0])),
"offset_sheet_a_solid" => c(Op::OffsetSheet(BLOCK, 1.0), Expect::Fails(Error::Argument)),
// A closed sheet offsets as an open one (tangency-labs/smlib fix #17, develop 9d0fb564):
// each face moved out 1 along its normal, the convex edges extended, gives the block
// (a + 2d)(b + 2d)(c + 2d) of six planes, from -d to (a, b, c) + d.
"offset_sheet_a_solid" => c(Op::OffsetSheet(BLOCK, 1.0), Expect::Solid(32.0 * 22.0 * 12.0, [-1.0, -1.0, -1.0], [31.0, 21.0, 11.0])),
// The top moved out 2: abc + d·ab.
"offset_faces_top_out" => c(Op::OffsetFaces(BLOCK, vec![TOP], 2.0), Expect::Volume(ABC + 2.0 * 600.0)),
// The top moved in 10, as deep as the block: nothing left behind it.
@@ -188,11 +201,17 @@ fn case(name: &str) -> Case {
let s = (5.0f64).to_radians().tan();
c(Op::Draft(BLOCK, vec![FRONT], [0.0, 0.0, 10.0], Z, Z, 5f64.to_radians()), Expect::Volume(ABC + 30.0 * 100.0 * s / 2.0))
}
// A cylinder's side is not flat.
"draft_a_curved_face" => c(
Op::Draft(Shape::Cylinder([0.0; 3], 5.0, 10.0), vec![[5.0, 0.0, 5.0]], [0.0; 3], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], 0.1),
Expect::Fails(Error::Unsupported),
),
// A cylinder along the pull drafts to a cone (tangency-labs/smlib fix #27, develop
// 9d0fb564): R = 5, h = 10, θ = 0.1 about the bottom, leaning in: a frustum of radii R
// and r = R - h tanθ (a cone and its two caps): V = π h (R² + R r + r²) / 3.
"draft_a_curved_face" => {
let (big, h) = (5.0, 10.0);
let small = big - h * 0.1f64.tan();
c(
Op::Draft(Shape::Cylinder([0.0; 3], big, h), vec![[5.0, 0.0, 5.0]], [0.0; 3], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], 0.1),
Expect::Volume(PI * h * (big * big + big * small + small * small) / 3.0),
)
}
// The top is square to the pull, not along it.
"draft_a_face_across_the_pull" => {
c(Op::Draft(BLOCK, vec![TOP], [0.0; 3], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], 0.1), Expect::Fails(Error::Unsupported))
@@ -277,6 +296,10 @@ fn judge(name: &str, who: &str, expect: &Expect, got: Got) -> Got {
let (a, b) = (m.bounds.0[2], m.bounds.1[2]);
assert!((a - lo).abs() < 1e-6 && (b - hi).abs() < 1e-6, "{name}: {who} z from {a} to {b}, expected {lo} to {hi}");
}
(Expect::Solid(v, lo, hi), Ok(m)) => {
assert!(rel(m.size, *v) < 1e-9, "{name}: {who} volume {} vs analytic {v}", m.size);
assert!(near(m.bounds.0, *lo) && near(m.bounds.1, *hi), "{name}: {who} bounds {:?}, expected {lo:?} {hi:?}", m.bounds);
}
(Expect::Sheet(s, lo, hi), Ok(m)) => {
assert!(rel(m.size, *s) < 1e-9, "{name}: {who} area {} vs analytic {s}", m.size);
assert!(near(m.bounds.0, *lo) && near(m.bounds.1, *hi), "{name}: {who} bounds {:?}, expected {lo:?} {hi:?}", m.bounds);
@@ -313,6 +336,7 @@ fn cpp_case(name: &str) -> Got {
match s {
Shape::Box(o, z) => ffi::make_box(&o, &z).map(Brep::made).unwrap(),
Shape::Cylinder(o, r, h) => ffi::make_cylinder(&o, r, h).map(Brep::made).unwrap(),
Shape::Sphere(o, r) => ffi::make_sphere(&o, r).map(Brep::made).unwrap(),
Shape::LineSheet(a, b, dir, dist) => Brep::extrude(&[line(a, b)], dir, dist, 0.0, DraftCorner::default(), false).unwrap(),
Shape::ArcSheet(o, r, degrees, h) => {
let arc = crate::sweeps::Curve::Arc {
@@ -411,13 +435,15 @@ cases!(
offset_sheet_plate,
offset_sheet_quarter_cylinder: ignore = "solidcore#1477: the quarter arc sweeps to an SmSurfOfExtrusion, whose offset exports as a spline, where the fork's 12918e9 sweeps an SmCylinder (solidcore#1477)",
offset_sheet_a_solid,
offset_sheet_a_sphere,
offset_sheet_a_sphere_to_its_centre,
offset_faces_top_out: ignore = "no SmOffsetFacesExecutive, fork a96ce9f (solidcore#1060)",
offset_faces_through,
draft_box_sides,
draft_one_side,
draft_one_side_out,
draft_one_side_hinged_at_the_top,
draft_a_curved_face,
draft_a_curved_face: ignore = "solidcore#1606: Cone::lean_cylinder keeps its cylinder flag, so under cylinder_rebuild_mean_radius the rebuild refuses the cone",
draft_a_face_across_the_pull,
);
+5 -1
View File
@@ -937,8 +937,12 @@ pub fn for_feature(app: &SolveApp, kind: &FeatureKind, frame: &Mat) -> Option<(K
if let Some(input) = ins.first_mut() {
input.items = sels;
}
// A symmetric extrude keeps the reading it was made with; a one-sided one made
// symmetric here takes a new one's (timeline.redefine fills it in either way).
let mut extra = Map::new();
extra.insert("convention".into(), json!(extent.convention));
if extent.direction == Direction::Symmetric {
extra.insert("convention".into(), json!(extent.convention));
}
return Some((Kind::Surface(k), ins, extra));
}
FeatureKind::Patch { sketch, edges, crown, continuity, points, .. } => {
+1
View File
@@ -159,6 +159,7 @@ fn swap_in(app: &mut SolveApp, mut slot: DocSlot) -> DocSlot {
// Preferences the session holds go with the user, not the tab (#680).
app.session.auto_project = out.session.auto_project;
app.session.metric_tap_drill_major_less_pitch = out.session.metric_tap_drill_major_less_pitch;
app.session.surface_extrude_symmetric_per_side = out.session.surface_extrude_symmetric_per_side;
// So does the host's pre-command check: every tab is held to it.
app.session.set_command_check(out.session.command_check());
// Views cache by revision: the incoming design must not look unchanged.
+3 -1
View File
@@ -978,8 +978,10 @@ impl SolveApp {
if matches!(id, "file.save_mesh" | "file.send_to_slicer") {
solidcraft_engine::slicers::set_chosen_programs(&self.preferences.custom_slicers);
}
// The preference the hole command reads, current even before the next frame applies it.
// The preferences the hole and surface extrude commands read, current even before the
// next frame applies them.
self.session.metric_tap_drill_major_less_pitch = self.preferences.metric_tap_drill_major_less_pitch;
self.session.surface_extrude_symmetric_per_side = self.preferences.surface_extrude_symmetric_per_side;
let t0 = now_ms();
let r = self.session.execute(id, &params).map_err(|e| e.to_string());
self.big_operation |= now_ms() - t0 >= recovery_ui::BIG_OPERATION_MS;
+35 -1
View File
@@ -643,6 +643,10 @@ preference_settings! {
/// kernel the routing table gives it), `smlib` or `solidcore` for all. Applied through
/// `diagnostics.kernel`; `SOLIDCRAFT_KERNEL`, when set, wins.
geometry_kernel: String = "routed".into(), PAGE_DESIGN;
/// New symmetric surface extrudes go their distance each way, as before they matched solid
/// extrudes; off by default: the distance is the total, split evenly around the start plane.
/// Saved designs keep the reading they stored either way.
surface_extrude_symmetric_per_side: bool = false, PAGE_DESIGN => check_id("prefs.surface_extrude_symmetric_per_side");
/// Reopen the saved designs that were open when the app was last closed (#5542).
reopen_designs: bool = true, PAGE_GENERAL;
/// Those designs' files, in tab order, as the last quit left them.
@@ -1134,8 +1138,10 @@ fn defaults(app: &mut SolveApp, page: usize) {
/// the interface scale.
pub fn apply(app: &mut SolveApp, ctx: &egui::Context) {
apply_network(&app.preferences);
// The hole command reads the metric tapped drill rule from the session.
// The hole command reads the metric tapped drill rule from the session, Surface Extrude its
// symmetric reading.
app.session.metric_tap_drill_major_less_pitch = app.preferences.metric_tap_drill_major_less_pitch;
app.session.surface_extrude_symmetric_per_side = app.preferences.surface_extrude_symmetric_per_side;
// The profiler records while the preference is on (switched when it changes; at start-up only
// when on, so SOLIDCRAFT_PROFILE=1 is not undone by the default).
let profile = app.preferences.profile_operations;
@@ -2538,6 +2544,34 @@ mod tests {
assert!(h.app.session.metric_tap_drill_major_less_pitch);
}
/// New symmetric surface extrudes read their distance as the total, as solid extrudes do; the
/// preference brings back the distance on each side they took before. It reaches the command
/// whether set through the control channel or the Preferences page, and survives a new design.
#[test]
fn the_surface_extrude_preference_keeps_the_distance_on_each_side() {
use serde_json::json;
let height = |h: &mut crate::scenario::Harness, name: &str| {
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.run("sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[10,10]})).unwrap();
h.app.run("sketch.finish", json!({})).unwrap();
h.app.run("surface.extrude", json!({"distance":"10 mm","direction":"symmetric","body_name":name})).unwrap();
let st = h.app.session.world_state().unwrap();
let b = st.body(name).unwrap().mesh().bounds();
b.max.z - b.min.z
};
let mut h = crate::scenario::Harness::new();
h.frames(1);
assert!(!h.app.preferences.surface_extrude_symmetric_per_side, "off by default");
assert!((height(&mut h, "Total") - 10.0).abs() < 1e-7);
let mut h = crate::scenario::Harness::new();
h.call("ui.prefs", json!({"surface_extrude_symmetric_per_side": true}));
h.frames(2);
assert!(h.app.session.surface_extrude_symmetric_per_side);
assert!((height(&mut h, "Each") - 20.0).abs() < 1e-7);
h.app.run("file.new", json!({})).unwrap();
assert!(h.app.session.surface_extrude_symmetric_per_side);
}
#[test]
fn the_ghost_position_defaults_round_trips_and_reads_tolerantly() {
use super::SpaceMouseGhost::{LeftViewport as Current, LeftWindow as Left, RightViewport as Right};
+4
View File
@@ -40,6 +40,10 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
let check = setting::metric_tap_drill_major_less_pitch(app, ui);
crate::scenario::publish_handle("prefs:metric_tap_drill_major_less_pitch", check.rect.center());
});
ui_kit::settings_section(ui, "surfaces", app.tr("prefs.surfaces"), |ui| {
let check = setting::surface_extrude_symmetric_per_side(app, ui);
crate::scenario::publish_handle("prefs:surface_extrude_symmetric_per_side", check.rect.center());
});
ui_kit::settings_section(ui, "orientation", app.tr("prefs.orientation"), |ui| {
ui.horizontal_wrapped(|ui| {
for (id, label, y_up) in [("z", "Z up", false), ("y", "Y up", true)] {
+6 -6
View File
@@ -8567,10 +8567,10 @@ mod tests {
let b = st.bodies.first().unwrap();
let mesh = b.mesh();
assert_eq!(mesh.edges.len(), 1536);
// Of the 512 wall joins, the offset curves' pieces meet with one curvature at 400; at the
// other 112 the curvature jumps by 0.9-3.6% (the offsets' pieces meet only tangentially)
// and the join is drawn.
assert_eq!(mesh.smooth_edges.iter().filter(|f| **f).count(), 400);
// SMLib sweeps each piece of the offset curves as itself (none is taken for a circle
// near it), so the pieces meet with one curvature at all 512 wall joins (the largest
// curvature jump 4.2e-7) and no join is drawn.
assert_eq!(mesh.smooth_edges.iter().filter(|f| **f).count(), 512);
let smooth = mesh.smooth_edges.iter().position(|f| *f).unwrap();
let expected = mesh.edges.iter().enumerate().filter(|(i, _)| mesh.shaded_edge_visible(*i)).map(|(_, e)| e.len() - 1).sum::<usize>();
let shaded = build_scene(&app).merged();
@@ -8578,8 +8578,8 @@ mod tests {
assert!(!shaded.tris.is_empty());
app.ui.visual_style = 2;
let wire = build_scene(&app).merged();
// The wireframe draws every edge but seams, and a seam measured as a crease (the offset
// ellipse's pieces meet at small real creases) is no seam.
// The wireframe draws every edge but seams, the smooth wall joins among them: they are
// edges between faces, hidden only when shaded.
let expected_wire = mesh.edges.iter().enumerate().filter(|(i, _)| mesh.edge_visible(*i)).map(|(_, e)| e.len() - 1).sum::<usize>();
assert_eq!(wire.lines.len() / crate::gpu::LINE_SIZE, expected_wire);
assert!(expected_wire > expected);
+166 -135
View File
@@ -12,13 +12,14 @@ The **frontier** is the first case of a tier, in ladder order, that fails (fail,
| 02-booleans | booleans in the degeneracy classes, and cuts that end in a single line | 25 | 25 pass | – |
| 03-analytic-profiles | extrudes and revolves of line-and-arc profiles | 10 | 10 pass | – |
| 04-spline-profiles | spline profiles, sweeps and lofts | 12 | 12 pass | – |
| 05-holes-and-taps | holes and tapped holes | 13 | 13 pass | – |
| 06-threads | modelled threads | 19 | 19 pass | – |
| 07-fillets | constant, variable and corner fillets | 18 | 17 pass, 1 unsupported | – |
| 05-holes-and-taps | holes and tapped holes | 17 | 17 pass | – |
| 06-threads | modelled threads | 30 | 1 fail, 29 pass | 023-external-1-2-npt |
| 07-fillets | constant, variable and corner fillets | 19 | 19 pass | – |
| 08-chamfers | chamfers | 8 | 8 pass | – |
| 09-shells-and-offsets | shells and offsets | 15 | 15 pass | – |
| 10-patterns-and-mirrors | patterns and mirrors | 8 | 8 pass | – |
| 11-cumulative-parts | parts combining every tier | 4 | 4 pass | – |
| 12-sheet-metal | sheet metal: flanges, closed corners, reliefs, hems, folds and the flat pattern | 14 | 14 pass | – |
Cases where SMLib's check gave no verdict on a body (SMLib can't take the record yet), so only the record's checks graded validity: 0.
@@ -28,141 +29,171 @@ Times are the commands' own, in seconds, from the case's process; **golden** is
| Case | What | Answer | Result | s | golden s | changes |
|---|---|---|---|---|---|---|
| ladder/01-primitives/005-sphere | a sphere r10 | analytic | pass | 0.003 | 0.003 | |
| ladder/01-primitives/001-box | a 60x40x20 box: the stock every later tier starts from | analytic | pass | 0.004 | 0.004 | |
| ladder/01-primitives/004-frustum | a cone frustum r10 -> r5, h20 (revolved trapezoid) | analytic | pass | 0.017 | 0.017 | |
| ladder/01-primitives/003-cone | a cone r10 h30 (no cone primitive: a revolved right triangle, its axis a sketch line) | analytic | pass | 0.025 | 0.025 | |
| ladder/01-primitives/002-cylinder | a cylinder r10 h30 | analytic | pass | 0.032 | 0.032 | |
| ladder/01-primitives/006-torus | a torus R20 r5 | analytic | pass | 0.575 | 0.575 | |
| ladder/02-booleans/001-coincident-face-join | a 60x40x10 box joined exactly on the stock's top face: one 60x40x30 box | analytic | pass | 0.006 | 0.006 | |
| ladder/02-booleans/019-notch-flush-with-end-face | a notch 40x20 through the height, its end flush with the stock's end face: a U | analytic | pass | 0.007 | 0.007 | |
| ladder/02-booleans/004-edge-on-edge-no-overlap | a cut tool that shares only the top front edge of the stock | analytic | pass | 0.010 | 0.010 | |
| ladder/02-booleans/015-knife-edge-wedge-cut | a triangular prism cut whose slope meets the bottom face along one line (a knife edge), its other faces on the stock's | analytic | pass | 0.011 | 0.011 | |
| ladder/02-booleans/014-cut-through-sphere-pole | a 4x4 square post cut off the top of a sphere r10 through its pole | analytic | pass | 0.012 | 0.012 | |
| ladder/02-booleans/016-v-groove-pinches-bottom-to-line | a V groove whose apex touches the bottom face along a line, cut through: two pieces | analytic | pass | 0.012 | 0.012 | |
| ladder/02-booleans/020-part-back-wall | the running part: a 60x10x15 back wall joined on the stock's top, flush with its back and ends | analytic | pass | 0.013 | 0.013 | |
| ladder/01-primitives/005-sphere | a sphere r10 | analytic | pass | 0.005 | 0.005 | |
| ladder/01-primitives/003-cone | a cone r10 h30 (no cone primitive: a revolved right triangle, its axis a sketch line) | analytic | pass | 0.037 | 0.037 | |
| ladder/01-primitives/004-frustum | a cone frustum r10 -> r5, h20 (revolved trapezoid) | analytic | pass | 0.041 | 0.041 | |
| ladder/01-primitives/002-cylinder | a cylinder r10 h30 | analytic | pass | 0.043 | 0.043 | |
| ladder/01-primitives/006-torus | a torus R20 r5 | analytic | pass | 0.172 | 0.172 | |
| ladder/02-booleans/004-edge-on-edge-no-overlap | a cut tool that shares only the top front edge of the stock | analytic | pass | 0.011 | 0.011 | |
| ladder/02-booleans/015-knife-edge-wedge-cut | a triangular prism cut whose slope meets the bottom face along one line (a knife edge), its other faces on the stock's | analytic | pass | 0.012 | 0.012 | |
| ladder/02-booleans/001-coincident-face-join | a 60x40x10 box joined exactly on the stock's top face: one 60x40x30 box | analytic | pass | 0.012 | 0.012 | |
| ladder/02-booleans/016-v-groove-pinches-bottom-to-line | a V groove whose apex touches the bottom face along a line, cut through: two pieces | analytic | pass | 0.013 | 0.013 | |
| ladder/02-booleans/003-pocket-flush-with-top | a 20x20x10 pocket whose tool's top is the stock's top face | analytic | pass | 0.013 | 0.013 | |
| ladder/02-booleans/002-coplanar-overlap-join | two 60x40x20 boxes overlapping 30x20 in plan, tops and bottoms coplanar | analytic | pass | 0.013 | 0.013 | |
| ladder/02-booleans/006-tangent-along-line-no-overlap | a cylinder r10 along X lying on the top face (tangent along a line), cut | analytic | pass | 0.016 | 0.016 | |
| ladder/02-booleans/017-cylinder-tangent-top-and-bottom | a cylinder r10 along X tangent to both the top and bottom faces, cut: two pieces with zero-angle cusps | analytic | pass | 0.023 | 0.023 | |
| ladder/02-booleans/018-hole-tangent-to-side-face | a through hole r10 tangent to the front face: the front face pinched to a line | analytic | pass | 0.026 | 0.026 | |
| ladder/02-booleans/008-near-tangent-gap-1e-6 | a cylinder r10 along X 1e-6 mm above the top face, cut | analytic | pass | 0.028 | 0.028 | |
| ladder/02-booleans/010-near-tangent-overlap-1e-6 | a cylinder r10 along X dipping 1e-6 mm into the top face, cut | invariants | pass | 0.029 | 0.029 | |
| ladder/02-booleans/011-tangent-along-circle-through-hole | a sphere r10 sitting in a through hole r10 at the top edge (tangent along the hole's top circle), cut | analytic | pass | 0.035 | 0.035 | |
| ladder/02-booleans/005-vertex-on-face-no-overlap | an inverted cone whose apex touches the middle of the top face, cut | analytic | pass | 0.043 | 0.043 | |
| ladder/02-booleans/007-near-tangent-gap-1e-3 | a cylinder r10 along X 1e-3 mm above the top face, cut | analytic | pass | 0.044 | 0.044 | |
| ladder/02-booleans/009-near-tangent-overlap-1e-3 | a cylinder r10 along X dipping 1e-3 mm into the top face, cut: a groove 1e-3 deep | analytic | pass | 0.048 | 0.048 | |
| ladder/02-booleans/013-cut-across-cylinder-seam | a 10x4 notch through a cylinder r10 across its +X side (where the seam lies) | analytic | pass | 0.050 | 0.050 | |
| ladder/02-booleans/021-holes-touching-at-a-point | two through holes r5 whose circles touch at one point (30, 20) | analytic | pass | 0.055 | 0.055 | |
| ladder/02-booleans/012-tangent-along-circle-bowl | a blind hole r10 10 deep, then a sphere r10 centred on its floor: the floor disk vanishes exactly | analytic | pass | 0.060 | 0.060 | |
| ladder/02-booleans/022-cylinder-grazing-a-hole-edge | a corner piece (square column minus a quarter disc r1.5, 0.0003 off the axis) cut out of a part with a blind r1.6 hole on the same axis: the tool's r1.5 face sits 0.1 mm inside the hole wall; 'no result' | analytic | pass | 0.061 | 0.061 | |
| ladder/02-booleans/023-lips-1e-4-off-the-walls-joined | two half-annulus lips (r 4..5, from z=2 to 20) joined onto a stadium-ring base (z 0..2, r 3..5 arcs, centres 20 apart) with their cylinder walls 0.0001 mm off the base's: the lip cap touches the base top, leaving a 0.0001 mm crescent overhang. Layout is a hand-built variant of the PR's public reproduction | analytic | pass | 0.132 | 0.132 | |
| ladder/02-booleans/024-wall-halves-merged-into-a-flange | the flange top annulus of a freshly revolved hub (z = 6, r 18..30) picked by a point and extruded 5 mm (the pick found a third of the face: "the selected planar face no longer exists") | analytic | pass | 0.237 | 0.237 | |
| ladder/02-booleans/025-flush-chord-layers-joined | a join of flush layers: a disc r37 (z -1.2..0) carrying 15 of the 19 regions of a sketch of 18 chords (z -3.6..-1.2; four bands left out), on an annulus r35..37 (z -5.6..-3.6) joined to a disc of all the chord regions (z -8..-5.6): SMLib's result came back with 'loop encloses no (u, v) area' though both operands are valid | analytic | pass | 1.355 | 1.355 | |
| ladder/03-analytic-profiles/001-extrude-rect-with-arc-end | a 60x40 profile with a semicircular end r20, extruded 20 | analytic | pass | 0.013 | 0.013 | |
| ladder/03-analytic-profiles/007-revolve-180-touching-axis | a 15x20 rectangle on the axis revolved 180 deg: a half cylinder | analytic | pass | 0.014 | 0.014 | |
| ladder/03-analytic-profiles/006-revolve-partial-90 | a 10x10 rectangle 10 mm off the axis revolved 90 deg | analytic | pass | 0.016 | 0.016 | |
| ladder/03-analytic-profiles/008-extrude-slot | a slot (centres 40 apart, width 20) extruded 10 | analytic | pass | 0.023 | 0.023 | |
| ladder/03-analytic-profiles/003-extrude-tapered-circle | a circle r10 extruded 20 with a -5 deg taper (inward): a cone frustum | analytic | pass | 0.050 | 0.050 | |
| ladder/03-analytic-profiles/002-extrude-annulus | an annulus r20/r10 extruded 15 | analytic | pass | 0.059 | 0.059 | |
| ladder/03-analytic-profiles/004-revolve-full-off-axis | a 10x30 rectangle 10 mm off the Z axis revolved 360 deg: a tube | analytic | pass | 0.065 | 0.065 | |
| ladder/03-analytic-profiles/005-revolve-touching-axis-hemisphere | a quarter disk r20 with an edge on the Z axis revolved 360 deg: a hemisphere | analytic | pass | 0.070 | 0.070 | |
| ladder/03-analytic-profiles/009-part-boss-and-slot | the running part: a revolved boss r8 h10 joined on the top, a slot 15x8 cut through the base | analytic | pass | 0.124 | 0.124 | |
| ladder/03-analytic-profiles/010-revolve-horn-torus-270 | the half disc of radius 14 on the far side of a diameter 14 mm from the axis (the full circle would touch the axis: a horn torus) revolved 270 degrees | analytic | pass | 0.136 | 0.136 | |
| ladder/04-spline-profiles/005-loft-square-frustum | a loft between a 40 square at z=0 and a 20 square at z=30 | analytic | pass | 0.011 | 0.011 | |
| ladder/04-spline-profiles/001-extrude-bezier-arch | a profile closed by a cubic Bezier arch (control-point spline, 4 points), extruded 10 | analytic | pass | 0.015 | 0.015 | |
| ladder/04-spline-profiles/008-loft-square-to-circle | a loft from a 40 square at z=0 to a circle r10 at z=30 | analytic | pass | 0.027 | 0.027 | |
| ladder/04-spline-profiles/009-extrude-periodic-fit-spline | a closed periodic fit-point spline through 6 points, extruded 10 | analytic | pass | 0.035 | 0.035 | |
| ladder/04-spline-profiles/004-sweep-square-along-bezier | a 4x4 square swept along the same Bezier path | analytic | pass | 0.042 | 0.042 | |
| ladder/04-spline-profiles/006-loft-circle-frustum | a loft between circles r20 at z=0 and r10 at z=30 | analytic | pass | 0.059 | 0.059 | |
| ladder/04-spline-profiles/007-loft-three-circles | a smooth loft through circles r20, r10, r20 at z = 0, 20, 40 | analytic | pass | 0.072 | 0.072 | |
| ladder/04-spline-profiles/002-revolve-bezier-profile | a profile with a Bezier side (r from 20 to 15 over z 0..30) revolved 360 deg about Z | analytic | pass | 0.084 | 0.084 | |
| ladder/04-spline-profiles/010-part-bezier-window | the running part: a Bezier-arched window cut through the back wall | analytic | pass | 0.131 | 0.131 | |
| ladder/04-spline-profiles/003-pipe-along-bezier | a pipe d4 along a planar Bezier path | analytic | pass | 0.141 | 0.141 | |
| ladder/04-spline-profiles/012-loft-ribs-joined-to-a-rounded-pad | the same without the top flange: the join fails with 'boolean Union: no result' | analytic | pass | 0.681 | 0.681 | |
| ladder/04-spline-profiles/011-crossing-pleated-loft-skins-joined | a join of two pleated skins (lofts between 24-pleat star outlines, less the same loft moved in 1.1 mm) that cross along a ring near their bottoms: truck panicked ('tolerance must be no less than 1e-6') or gave no result | analytic | pass | 1.376 | 1.376 | |
| ladder/05-holes-and-taps/006-tapped-m6-through | an M6 tapped hole through: the tap drill d5 (major - pitch), cosmetic thread | analytic | pass | 0.017 | 0.017 | |
| ladder/05-holes-and-taps/001-simple-through | a d10 through hole in the stock's top | analytic | pass | 0.033 | 0.033 | |
| ladder/05-holes-and-taps/009-hole-0.5-from-edge | a d10 through hole whose wall is 0.5 mm from the end face | analytic | pass | 0.034 | 0.034 | |
| ladder/05-holes-and-taps/010-hole-tangent-to-end-face | a d10 through hole tangent to the end face x=0 | analytic | pass | 0.036 | 0.036 | |
| ladder/05-holes-and-taps/003-drilled-blind-118 | a d10 drilled hole 10 deep to the shoulder with a 118 deg point | analytic | pass | 0.044 | 0.044 | |
| ladder/05-holes-and-taps/007-tapped-m8-blind | an M8 tapped blind hole 12 deep with a 118 deg drill point | analytic | pass | 0.045 | 0.045 | |
| ladder/05-holes-and-taps/002-simple-blind-flat | a d10 blind hole 10 deep, flat bottom | analytic | pass | 0.046 | 0.046 | |
| ladder/05-holes-and-taps/004-counterbore | a counterbored hole: d6.6 through, d11 x 6.4 counterbore | analytic | pass | 0.051 | 0.051 | |
| ladder/05-holes-and-taps/005-countersink | a countersunk hole: d6.6 through, d12 x 90 deg countersink | analytic | pass | 0.089 | 0.089 | |
| ladder/05-holes-and-taps/011-crossing-holes-steinmetz | two d10 through holes whose axes cross: vertical and along Y at z=10 | analytic | pass | 0.102 | 0.102 | |
| ladder/05-holes-and-taps/012-crossing-tapped-holes-offset | two M6 tapped holes (d5) crossing with axes 2 mm apart | analytic | pass | 0.113 | 0.113 | |
| ladder/05-holes-and-taps/008-tapped-m5-into-curved-face | an M5 tapped hole drilled radially through a cylinder r20 lying along X | analytic | pass | 0.130 | 0.130 | |
| ladder/05-holes-and-taps/013-part-holes | the running part: an M6 tapped through hole, an M5 tapped blind hole in the boss, a d3.3 hole down through wall and base | analytic | pass | 0.280 | 0.280 | |
| ladder/06-threads/012-external-acme-3-4-6 | a modelled 3/4-6 ACME thread (ASME B1.5, general purpose) on a 3/4 in shaft, six turns | analytic | pass | 0.839 | 0.839 | |
| ladder/06-threads/013-external-s20x4 | a modelled metric buttress S20x4 thread (DIN 513, 3/30 deg) on a d20 shaft, six turns | analytic | pass | 0.945 | 0.945 | |
| ladder/06-threads/011-external-tr20x4 | a modelled trapezoidal Tr20x4 thread (ISO 2904) on a d20 shaft, six turns | analytic | pass | 0.956 | 0.956 | |
| 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.088 | 1.088 | |
| 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.200 | 1.200 | |
| 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.347 | 1.347 | |
| ladder/06-threads/010-part-threaded-boss | the running part with a modelled M16 thread on its d16 boss | analytic | pass | 1.462 | 1.462 | |
| ladder/06-threads/016-external-m10-left-hand | 001's modelled M10 thread, left-handed: the same volume, turning the other way | analytic | pass | 1.690 | 1.690 | |
| ladder/06-threads/019-external-tr40x14-p7-two-start | a modelled two-start trapezoidal Tr40x14(P7) thread (ISO 2904, ISO 2903) on a d40 shaft, three leads long | analytic | pass | 1.831 | 1.831 | |
| 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.872 | 1.872 | |
| 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 | 1.920 | 1.920 | |
| 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 | 1.964 | 1.964 | |
| ladder/06-threads/001-external-m10-full | a modelled M10 thread over the whole of a d10 x 30 cylinder | analytic | pass | 2.128 | 2.128 | |
| 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.144 | 2.144 | |
| 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.203 | 2.203 | |
| ladder/06-threads/002-external-m10x1-fine | a modelled fine M10x1 thread over a d10 x 30 cylinder | analytic | pass | 2.626 | 2.626 | |
| 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 minor diameter, cut after the groove | analytic | pass | 3.485 | 3.485 | |
| 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 | 3.706 | 3.706 | |
| 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 | 7.756 | 7.756 | |
| ladder/07-fillets/015-corner-g2-patch | three r5 rounds at a corner with the g2 corner patch | invariants | not supported yet: step 2 (solid.fillet): invalid input: not supported yet: a fillet with G2 corner patches with the SMLib kernel | 0.003 | 0.003 | |
| ladder/07-fillets/006-variable-r5-to-zero | a variable round on the top front edge, r5 at x=0 down to 0 at the x=60 vertex | analytic | pass | 0.009 | 0.009 | |
| ladder/07-fillets/001-single-edge-r5 | an r5 round on the stock's top front edge | analytic | pass | 0.016 | 0.016 | |
| 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.018 | 0.018 | |
| ladder/07-fillets/011-chain-ending-at-corner | r5 rounds on two top edges meeting at a corner whose vertical edge stays sharp | analytic | pass | 0.019 | 0.019 | |
| ladder/02-booleans/020-part-back-wall | the running part: a 60x10x15 back wall joined on the stock's top, flush with its back and ends | analytic | pass | 0.013 | 0.013 | |
| ladder/02-booleans/019-notch-flush-with-end-face | a notch 40x20 through the height, its end flush with the stock's end face: a U | analytic | pass | 0.014 | 0.014 | |
| ladder/02-booleans/002-coplanar-overlap-join | two 60x40x20 boxes overlapping 30x20 in plan, tops and bottoms coplanar | analytic | pass | 0.014 | 0.014 | |
| ladder/02-booleans/014-cut-through-sphere-pole | a 4x4 square post cut off the top of a sphere r10 through its pole | analytic | pass | 0.025 | 0.025 | |
| ladder/02-booleans/007-near-tangent-gap-1e-3 | a cylinder r10 along X 1e-3 mm above the top face, cut | analytic | pass | 0.033 | 0.033 | |
| ladder/02-booleans/006-tangent-along-line-no-overlap | a cylinder r10 along X lying on the top face (tangent along a line), cut | analytic | pass | 0.036 | 0.036 | |
| ladder/02-booleans/010-near-tangent-overlap-1e-6 | a cylinder r10 along X dipping 1e-6 mm into the top face, cut | invariants | pass | 0.037 | 0.037 | |
| ladder/02-booleans/008-near-tangent-gap-1e-6 | a cylinder r10 along X 1e-6 mm above the top face, cut | analytic | pass | 0.037 | 0.037 | |
| ladder/02-booleans/009-near-tangent-overlap-1e-3 | a cylinder r10 along X dipping 1e-3 mm into the top face, cut: a groove 1e-3 deep | analytic | pass | 0.041 | 0.041 | |
| ladder/02-booleans/005-vertex-on-face-no-overlap | an inverted cone whose apex touches the middle of the top face, cut | analytic | pass | 0.045 | 0.045 | |
| ladder/02-booleans/017-cylinder-tangent-top-and-bottom | a cylinder r10 along X tangent to both the top and bottom faces, cut: two pieces with zero-angle cusps | analytic | pass | 0.052 | 0.052 | |
| ladder/02-booleans/018-hole-tangent-to-side-face | a through hole r10 tangent to the front face: the front face pinched to a line | analytic | pass | 0.059 | 0.059 | |
| ladder/02-booleans/013-cut-across-cylinder-seam | a 10x4 notch through a cylinder r10 across its +X side (where the seam lies) | analytic | pass | 0.059 | 0.059 | |
| ladder/02-booleans/012-tangent-along-circle-bowl | a blind hole r10 10 deep, then a sphere r10 centred on its floor: the floor disk vanishes exactly | analytic | pass | 0.069 | 0.069 | |
| ladder/02-booleans/011-tangent-along-circle-through-hole | a sphere r10 sitting in a through hole r10 at the top edge (tangent along the hole's top circle), cut | analytic | pass | 0.076 | 0.076 | |
| ladder/02-booleans/022-cylinder-grazing-a-hole-edge | a corner piece (square column minus a quarter disc r1.5, 0.0003 off the axis) cut out of a part with a blind r1.6 hole on the same axis: the tool's r1.5 face sits 0.1 mm inside the hole wall; 'no result' | analytic | pass | 0.087 | 0.087 | |
| ladder/02-booleans/021-holes-touching-at-a-point | two through holes r5 whose circles touch at one point (30, 20) | analytic | pass | 0.131 | 0.131 | |
| ladder/02-booleans/024-wall-halves-merged-into-a-flange | the flange top annulus of a freshly revolved hub (z = 6, r 18..30) picked by a point and extruded 5 mm (the pick found a third of the face: "the selected planar face no longer exists") | analytic | pass | 0.182 | 0.182 | |
| ladder/02-booleans/023-lips-1e-4-off-the-walls-joined | two half-annulus lips (r 4..5, from z=2 to 20) joined onto a stadium-ring base (z 0..2, r 3..5 arcs, centres 20 apart) with their cylinder walls 0.0001 mm off the base's: the lip cap touches the base top, leaving a 0.0001 mm crescent overhang. Layout is a hand-built variant of the PR's public reproduction | analytic | pass | 0.201 | 0.201 | |
| ladder/02-booleans/025-flush-chord-layers-joined | a join of flush layers: a disc r37 (z -1.2..0) carrying 15 of the 19 regions of a sketch of 18 chords (z -3.6..-1.2; four bands left out), on an annulus r35..37 (z -5.6..-3.6) joined to a disc of all the chord regions (z -8..-5.6): SMLib's result came back with 'loop encloses no (u, v) area' though both operands are valid | analytic | pass | 1.559 | 1.559 | |
| ladder/03-analytic-profiles/006-revolve-partial-90 | a 10x10 rectangle 10 mm off the axis revolved 90 deg | analytic | pass | 0.010 | 0.010 | |
| ladder/03-analytic-profiles/007-revolve-180-touching-axis | a 15x20 rectangle on the axis revolved 180 deg: a half cylinder | analytic | pass | 0.010 | 0.010 | |
| ladder/03-analytic-profiles/008-extrude-slot | a slot (centres 40 apart, width 20) extruded 10 | analytic | pass | 0.011 | 0.011 | |
| ladder/03-analytic-profiles/001-extrude-rect-with-arc-end | a 60x40 profile with a semicircular end r20, extruded 20 | analytic | pass | 0.015 | 0.015 | |
| ladder/03-analytic-profiles/003-extrude-tapered-circle | a circle r10 extruded 20 with a -5 deg taper (inward): a cone frustum | analytic | pass | 0.024 | 0.024 | |
| ladder/03-analytic-profiles/002-extrude-annulus | an annulus r20/r10 extruded 15 | analytic | pass | 0.024 | 0.024 | |
| ladder/03-analytic-profiles/005-revolve-touching-axis-hemisphere | a quarter disk r20 with an edge on the Z axis revolved 360 deg: a hemisphere | analytic | pass | 0.031 | 0.031 | |
| ladder/03-analytic-profiles/004-revolve-full-off-axis | a 10x30 rectangle 10 mm off the Z axis revolved 360 deg: a tube | analytic | pass | 0.042 | 0.042 | |
| ladder/03-analytic-profiles/009-part-boss-and-slot | the running part: a revolved boss r8 h10 joined on the top, a slot 15x8 cut through the base | analytic | pass | 0.060 | 0.060 | |
| ladder/03-analytic-profiles/010-revolve-horn-torus-270 | the half disc of radius 14 on the far side of a diameter 14 mm from the axis (the full circle would touch the axis: a horn torus) revolved 270 degrees | analytic | pass | 0.060 | 0.060 | |
| ladder/04-spline-profiles/005-loft-square-frustum | a loft between a 40 square at z=0 and a 20 square at z=30 | analytic | pass | 0.010 | 0.010 | |
| ladder/04-spline-profiles/001-extrude-bezier-arch | a profile closed by a cubic Bezier arch (control-point spline, 4 points), extruded 10 | analytic | pass | 0.020 | 0.020 | |
| ladder/04-spline-profiles/008-loft-square-to-circle | a loft from a 40 square at z=0 to a circle r10 at z=30 | analytic | pass | 0.021 | 0.021 | |
| ladder/04-spline-profiles/009-extrude-periodic-fit-spline | a closed periodic fit-point spline through 6 points, extruded 10 | analytic | pass | 0.031 | 0.031 | |
| ladder/04-spline-profiles/006-loft-circle-frustum | a loft between circles r20 at z=0 and r10 at z=30 | analytic | pass | 0.036 | 0.036 | |
| ladder/04-spline-profiles/007-loft-three-circles | a smooth loft through circles r20, r10, r20 at z = 0, 20, 40 | analytic | pass | 0.037 | 0.037 | |
| ladder/04-spline-profiles/004-sweep-square-along-bezier | a 4x4 square swept along the same Bezier path | analytic | pass | 0.039 | 0.039 | |
| ladder/04-spline-profiles/002-revolve-bezier-profile | a profile with a Bezier side (r from 20 to 15 over z 0..30) revolved 360 deg about Z | analytic | pass | 0.069 | 0.069 | |
| ladder/04-spline-profiles/010-part-bezier-window | the running part: a Bezier-arched window cut through the back wall | analytic | pass | 0.099 | 0.099 | |
| ladder/04-spline-profiles/003-pipe-along-bezier | a pipe d4 along a planar Bezier path | analytic | pass | 0.110 | 0.110 | |
| ladder/04-spline-profiles/012-loft-ribs-joined-to-a-rounded-pad | the same without the top flange: the join fails with 'boolean Union: no result' | analytic | pass | 0.463 | 0.463 | |
| ladder/04-spline-profiles/011-crossing-pleated-loft-skins-joined | a join of two pleated skins (lofts between 24-pleat star outlines, less the same loft moved in 1.1 mm) that cross along a ring near their bottoms: truck panicked ('tolerance must be no less than 1e-6') or gave no result | analytic | pass | 1.323 | 1.323 | |
| ladder/05-holes-and-taps/001-simple-through | a d10 through hole in the stock's top | analytic | pass | 0.023 | 0.023 | |
| ladder/05-holes-and-taps/010-hole-tangent-to-end-face | a d10 through hole tangent to the end face x=0 | analytic | pass | 0.024 | 0.024 | |
| ladder/05-holes-and-taps/006-tapped-m6-through | an M6 tapped hole through: the tap drill d5 (major - pitch), cosmetic thread | analytic | pass | 0.026 | 0.026 | |
| ladder/05-holes-and-taps/017-tapped-1-4-npt-through | a 1/4-18 NPT tapped hole through the stock (ASME B1.20.1): a straight hole at the tap maker's 10.85 mm, cosmetic thread | analytic | pass | 0.028 | 0.028 | |
| ladder/05-holes-and-taps/016-tapped-rc-1-2-through | an Rc 1/2 tapped hole through the stock (ISO 7-1 internal taper): a straight hole at the tap maker's 17.6 mm, cosmetic thread | analytic | pass | 0.028 | 0.028 | |
| ladder/05-holes-and-taps/002-simple-blind-flat | a d10 blind hole 10 deep, flat bottom | analytic | pass | 0.029 | 0.029 | |
| ladder/05-holes-and-taps/003-drilled-blind-118 | a d10 drilled hole 10 deep to the shoulder with a 118 deg point | analytic | pass | 0.030 | 0.030 | |
| ladder/05-holes-and-taps/007-tapped-m8-blind | an M8 tapped blind hole 12 deep with a 118 deg drill point | analytic | pass | 0.032 | 0.032 | |
| ladder/05-holes-and-taps/015-tapped-1-4-28-unf-blind | a 1/4-28 UNF tapped blind hole 10 deep, flat bottom: drilled 5.45 mm, cosmetic thread | analytic | pass | 0.034 | 0.034 | |
| ladder/05-holes-and-taps/009-hole-0.5-from-edge | a d10 through hole whose wall is 0.5 mm from the end face | analytic | pass | 0.036 | 0.036 | |
| ladder/05-holes-and-taps/014-tapped-1-4-20-unc-through | a 1/4-20 UNC tapped hole through the stock: drilled #7 (0.201 in), cosmetic thread | analytic | pass | 0.041 | 0.041 | |
| ladder/05-holes-and-taps/004-counterbore | a counterbored hole: d6.6 through, d11 x 6.4 counterbore | analytic | pass | 0.049 | 0.049 | |
| ladder/05-holes-and-taps/005-countersink | a countersunk hole: d6.6 through, d12 x 90 deg countersink | analytic | pass | 0.059 | 0.059 | |
| ladder/05-holes-and-taps/011-crossing-holes-steinmetz | two d10 through holes whose axes cross: vertical and along Y at z=10 | analytic | pass | 0.078 | 0.078 | |
| ladder/05-holes-and-taps/012-crossing-tapped-holes-offset | two M6 tapped holes (d5) crossing with axes 2 mm apart | analytic | pass | 0.127 | 0.127 | |
| ladder/05-holes-and-taps/008-tapped-m5-into-curved-face | an M5 tapped hole drilled radially through a cylinder r20 lying along X | analytic | pass | 0.134 | 0.134 | |
| ladder/05-holes-and-taps/013-part-holes | the running part: an M6 tapped through hole, an M5 tapped blind hole in the boss, a d3.3 hole down through wall and base | analytic | pass | 0.256 | 0.256 | |
| ladder/06-threads/030-square-thread-refused | a square thread on a d10 x 30 cylinder: refused, no current standard defines one | invariants | pass | 0.018 | 0.018 | |
| ladder/06-threads/012-external-acme-3-4-6 | a modelled 3/4-6 ACME thread (ASME B1.5, general purpose) on a 3/4 in shaft, six turns | analytic | pass | 0.634 | 0.634 | |
| ladder/06-threads/011-external-tr20x4 | a modelled trapezoidal Tr20x4 thread (ISO 2904) on a d20 shaft, six turns | analytic | pass | 0.648 | 0.648 | |
| ladder/06-threads/029-external-tr20x4-chamfer-needs-depth | 011's Tr20x4 thread with a chamfered tip and no depth: refused, ISO 4753 is for metric threads | invariants | pass | 0.657 | 0.657 | |
| ladder/06-threads/013-external-s20x4 | a modelled metric buttress S20x4 thread (DIN 513, 3/30 deg) on a d20 shaft, six turns | analytic | pass | 0.665 | 0.665 | |
| ladder/06-threads/021-internal-rp-1-2 | a modelled Rp 1/2 parallel internal pipe thread (ISO 7-1) in a d18.631 (its minor) bore through a 40x40 block six turns thick | analytic | pass | 0.685 | 0.685 | |
| 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.695 | 0.695 | |
| 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 | 0.695 | 0.695 | |
| 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 | 0.716 | 0.716 | |
| 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 | 0.746 | 0.746 | |
| ladder/06-threads/010-part-threaded-boss | the running part with a modelled M16 thread on its d16 boss | analytic | pass | 0.774 | 0.774 | |
| 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 | 0.776 | 0.776 | |
| 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 | 0.855 | 0.855 | |
| 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.161 | 1.161 | |
| ladder/06-threads/019-external-tr40x14-p7-two-start | a modelled two-start trapezoidal Tr40x14(P7) thread (ISO 2904, ISO 2903) on a d40 shaft, three leads long | analytic | pass | 1.196 | 1.196 | |
| 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.311 | 1.311 | |
| ladder/06-threads/022-external-r-1-2-taper | a modelled R 1/2 taper pipe thread (ISO 7-1, 55 deg, 1 in 16) on a 21.3 mm pipe (ISO 65), its standard 13.2 mm from the pipe's end | analytic | pass | 1.344 | 1.344 | |
| 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.383 | 1.383 | |
| 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 | 1.403 | 1.403 | |
| 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 | 1.437 | 1.437 | |
| 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 | 1.439 | 1.439 | |
| 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 | **FAIL**: volume_mm3 8227.346353 (want 8226.404942) | 1.619 | 1.619 | |
| ladder/06-threads/016-external-m10-left-hand | 001's modelled M10 thread, left-handed: the same volume, turning the other way | analytic | pass | 1.626 | 1.626 | |
| ladder/06-threads/001-external-m10-full | a modelled M10 thread over the whole of a d10 x 30 cylinder | analytic | pass | 1.690 | 1.690 | |
| 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 | 1.713 | 1.713 | |
| 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 | 2.526 | 2.526 | |
| ladder/06-threads/002-external-m10x1-fine | a modelled fine M10x1 thread over a d10 x 30 cylinder | analytic | pass | 2.534 | 2.534 | |
| 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 | 3.074 | 3.074 | |
| 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.340 | 3.340 | |
| 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 | 6.515 | 6.515 | |
| ladder/07-fillets/001-single-edge-r5 | an r5 round on the stock's top front edge | analytic | pass | 0.008 | 0.008 | |
| 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.009 | 0.009 | |
| ladder/07-fillets/011-chain-ending-at-corner | r5 rounds on two top edges meeting at a corner whose vertical edge stays sharp | analytic | pass | 0.011 | 0.011 | |
| ladder/07-fillets/002-four-vertical-edges-r5 | r5 rounds on the four vertical edges | analytic | pass | 0.017 | 0.017 | |
| ladder/07-fillets/006-variable-r5-to-zero | a variable round on the top front edge, r5 at x=0 down to 0 at the x=60 vertex | analytic | pass | 0.017 | 0.017 | |
| ladder/07-fillets/008-constant-r1e-3 | a constant 1e-3 mm round on the top front edge | analytic | pass | 0.019 | 0.019 | |
| ladder/07-fillets/005-variable-r5-to-r1 | a variable round on the top front edge, r5 at x=0 to r1 at x=60 | analytic | pass | 0.020 | 0.020 | |
| ladder/07-fillets/004-convex-and-concave-r5 | an L block: r5 on its inner (concave) vertical edge and on an outer (convex) one | analytic | pass | 0.021 | 0.021 | |
| ladder/07-fillets/009-corner-three-equal-r5 | r5 rounds on the three edges meeting at the corner (60,40,20): a sphere corner | analytic | pass | 0.023 | 0.023 | |
| ladder/07-fillets/008-constant-r1e-3 | a constant 1e-3 mm round on the top front edge | analytic | pass | 0.024 | 0.024 | |
| ladder/07-fillets/002-four-vertical-edges-r5 | r5 rounds on the four vertical edges | analytic | pass | 0.027 | 0.027 | |
| ladder/07-fillets/010-corner-unequal-r7-r3 | an r7 vertical round at a corner, then r3 along a top edge, which runs on round the r7 arc to the other top edge | analytic | pass | 0.037 | 0.037 | |
| ladder/07-fillets/016-corner-three-sequential-r5-r3-r7 | rounds r5 and r3 on the two top edges at a corner, then r7 on the vertical edge under them: refused, the r7 cannot exist | invariants | pass | 0.046 | 0.046 | |
| ladder/07-fillets/012-variable-into-rounded-corner | a vertical r5 round, then a variable round r1 -> r5 along the top back edge into it | analytic | pass | 0.060 | 0.060 | |
| ladder/07-fillets/014-curved-edge-r2 | an r2 round on the top edge of a cylinder r10 h20 | analytic | pass | 0.078 | 0.078 | |
| ladder/07-fillets/018-corner-three-sequential-r5-r3-r2 | rounds r5 and r3 on the two top edges at a corner, then r2 on the vertical edge under them, run on up into the corner | invariants | pass | 0.080 | 0.080 | |
| ladder/07-fillets/003-tangent-chain-r3 | an r3 round all round the top of the box with r5 vertical rounds: a tangent chain of lines and arcs | analytic | pass | 0.080 | 0.080 | |
| ladder/07-fillets/013-corner-setback | three r5 rounds at the corner (60,40,20) with setbacks of 8 mm along each edge | invariants | pass | 0.117 | 0.117 | |
| ladder/07-fillets/017-part-rounds | the running part: r5 on the front vertical edges, r3 on the back wall's top front edge, r1 where the boss meets the top | analytic | pass | 0.690 | 0.690 | |
| ladder/08-chamfers/005-corner-two-mitred-3 | 3 mm chamfers on two top edges meeting at a corner (mitred) | analytic | pass | 0.008 | 0.008 | |
| ladder/08-chamfers/004-corner-three-equal-3 | 3 mm chamfers on the three edges meeting at a corner | analytic | pass | 0.009 | 0.009 | |
| ladder/08-chamfers/003-distance-angle-5-30 | a chamfer 5 mm at 30 deg on the top front edge | analytic | pass | 0.012 | 0.012 | |
| ladder/07-fillets/010-corner-unequal-r7-r3 | an r7 vertical round at a corner, then r3 along a top edge, which runs on round the r7 arc to the other top edge | analytic | pass | 0.024 | 0.024 | |
| ladder/07-fillets/004-convex-and-concave-r5 | an L block: r5 on its inner (concave) vertical edge and on an outer (convex) one | analytic | pass | 0.025 | 0.025 | |
| ladder/07-fillets/009-corner-three-equal-r5 | r5 rounds on the three edges meeting at the corner (60,40,20): a sphere corner | analytic | pass | 0.032 | 0.032 | |
| ladder/07-fillets/014-curved-edge-r2 | an r2 round on the top edge of a cylinder r10 h20 | analytic | pass | 0.048 | 0.048 | |
| ladder/07-fillets/012-variable-into-rounded-corner | a vertical r5 round, then a variable round r1 -> r5 along the top back edge into it | analytic | pass | 0.051 | 0.051 | |
| ladder/07-fillets/016-corner-three-sequential-r5-r3-r7 | rounds r5 and r3 on the two top edges at a corner, then r7 on the vertical edge under them: refused, the r7 cannot exist | invariants | pass | 0.053 | 0.053 | |
| ladder/07-fillets/018-corner-three-sequential-r5-r3-r2 | rounds r5 and r3 on the two top edges at a corner, then r2 on the vertical edge under them, run on up into the corner | invariants | pass | 0.061 | 0.061 | |
| ladder/07-fillets/013-corner-setback | three r5 rounds at the corner (60,40,20) with setbacks of 8 mm along each edge | invariants | pass | 0.062 | 0.062 | |
| ladder/07-fillets/003-tangent-chain-r3 | an r3 round all round the top of the box with r5 vertical rounds: a tangent chain of lines and arcs | analytic | pass | 0.075 | 0.075 | |
| ladder/07-fillets/017-part-rounds | the running part: r5 on the front vertical edges, r3 on the back wall's top front edge, r1 where the boss meets the top | analytic | pass | 0.480 | 0.480 | |
| ladder/07-fillets/019-concave-corner-g2-patch | three concave r5 rounds at the inner corner of a 20x20x10 notch, with the g2 corner patch | invariants | pass | 2.084 | 2.084 | |
| ladder/07-fillets/015-corner-g2-patch | three r5 rounds at a corner with the g2 corner patch | invariants | pass | 2.173 | 2.173 | |
| ladder/08-chamfers/001-equal-5 | a 5 mm chamfer on the top front edge | analytic | pass | 0.012 | 0.012 | |
| ladder/08-chamfers/002-two-distances-5-3 | a 5 x 3 chamfer on the top front edge | analytic | pass | 0.024 | 0.024 | |
| ladder/08-chamfers/007-chamfer-then-fillets | a 3 mm chamfer on the top front edge, then r2 rounds on the front vertical edges that meet it | analytic | pass | 0.029 | 0.029 | |
| ladder/08-chamfers/006-curved-edge-2 | a 2 mm chamfer on the top edge of a cylinder r10 h20 | analytic | pass | 0.070 | 0.070 | |
| ladder/08-chamfers/008-part-chamfers | the running part: 1 mm on the boss top edge, 2 mm on the back wall's top back edge | analytic | pass | 0.749 | 0.749 | |
| ladder/09-shells-and-offsets/007-offset-top-face-5 | the stock's top face offset 5 mm | analytic | pass | 0.016 | 0.016 | |
| ladder/09-shells-and-offsets/001-box-open-top-t2 | the stock shelled 2 mm, open at the top | analytic | pass | 0.017 | 0.017 | |
| ladder/08-chamfers/003-distance-angle-5-30 | a chamfer 5 mm at 30 deg on the top front edge | analytic | pass | 0.012 | 0.012 | |
| ladder/08-chamfers/002-two-distances-5-3 | a 5 x 3 chamfer on the top front edge | analytic | pass | 0.012 | 0.012 | |
| ladder/08-chamfers/005-corner-two-mitred-3 | 3 mm chamfers on two top edges meeting at a corner (mitred) | analytic | pass | 0.015 | 0.015 | |
| ladder/08-chamfers/004-corner-three-equal-3 | 3 mm chamfers on the three edges meeting at a corner | analytic | pass | 0.018 | 0.018 | |
| ladder/08-chamfers/007-chamfer-then-fillets | a 3 mm chamfer on the top front edge, then r2 rounds on the front vertical edges that meet it | analytic | pass | 0.031 | 0.031 | |
| ladder/08-chamfers/006-curved-edge-2 | a 2 mm chamfer on the top edge of a cylinder r10 h20 | analytic | pass | 0.060 | 0.060 | |
| ladder/08-chamfers/008-part-chamfers | the running part: 1 mm on the boss top edge, 2 mm on the back wall's top back edge | analytic | pass | 0.681 | 0.681 | |
| ladder/09-shells-and-offsets/001-box-open-top-t2 | the stock shelled 2 mm, open at the top | analytic | pass | 0.009 | 0.009 | |
| ladder/09-shells-and-offsets/003-tube-two-open-faces | the stock shelled 2 mm, open top and bottom | analytic | pass | 0.009 | 0.009 | |
| ladder/09-shells-and-offsets/007-offset-top-face-5 | the stock's top face offset 5 mm | analytic | pass | 0.017 | 0.017 | |
| ladder/09-shells-and-offsets/004-thin-wall-0.2 | the stock shelled 0.2 mm, open at the top | analytic | pass | 0.017 | 0.017 | |
| ladder/09-shells-and-offsets/003-tube-two-open-faces | the stock shelled 2 mm, open top and bottom | analytic | pass | 0.018 | 0.018 | |
| ladder/09-shells-and-offsets/012-closed-shell-sealed-void | the stock shelled 2 mm with no face open: a closed body with a sealed void | analytic | pass | 0.018 | 0.018 | |
| ladder/09-shells-and-offsets/009-shell-outside-t2 | the stock shelled 2 mm outward, open at the top | analytic | pass | 0.038 | 0.038 | |
| ladder/09-shells-and-offsets/006-shell-rounds-r1-thinner-than-t2 | the box with r1 vertical rounds shelled 2 mm: the inner corners close sharp | analytic | pass | 0.060 | 0.060 | |
| ladder/09-shells-and-offsets/008-offset-cylinder-wall-2 | a cylinder r10 h20 with its side face offset 2 mm | analytic | pass | 0.075 | 0.075 | |
| ladder/09-shells-and-offsets/002-cylinder-open-top-t1 | a cylinder r10 h30 shelled 1 mm, open at the top | analytic | pass | 0.102 | 0.102 | |
| ladder/09-shells-and-offsets/010-shell-under-rounded-top | the stock with r3 rounds on its four top edges, shelled 2 mm open at the bottom | analytic | pass | 0.105 | 0.105 | |
| ladder/09-shells-and-offsets/014-drafted-box-with-rounds-shelled | a 120x80x40 box drafted 5 degrees with 4 mm rounds on the sloping corners, shelled 2 mm open at the top: the inner rounds' edges must lie on their faces (#3573 reports the same design) | analytic | pass | 0.124 | 0.124 | |
| ladder/09-shells-and-offsets/005-shell-rounds-r5-t2 | the box with r5 vertical rounds shelled 2 mm open at the top: the inner corners r3 | analytic | pass | 0.174 | 0.174 | |
| ladder/09-shells-and-offsets/013-dome-shelled-from-base | a dome r20 shelled 2 mm, open at its flat base: the rim is the circle r18 where the inner sphere meets the base plane | analytic | pass | 0.236 | 0.236 | |
| ladder/09-shells-and-offsets/015-shelled-dome-ring-joined-back | a dome (a quarter disc r20 revolved) shelled 2 mm from its flat base, then the base ring (r 18..20) face-extruded 10 mm back into the dome as a join: ~120 s, then 'boolean Union: no result' | analytic | pass | 0.922 | 0.922 | |
| ladder/09-shells-and-offsets/011-part-shell | the running part shelled 1.5 mm open at the bottom | analytic | pass | 1.078 | 1.078 | |
| ladder/10-patterns-and-mirrors/007-pattern-bodies | a pin r3 h10 patterned 4 times at 10 mm as bodies | analytic | pass | 0.031 | 0.031 | |
| ladder/10-patterns-and-mirrors/004-mirror-body-joined | a 30x40x20 half with a d10 hole mirrored about x=30 and joined: the faces at x=30 coincide | analytic | pass | 0.067 | 0.067 | |
| ladder/09-shells-and-offsets/012-closed-shell-sealed-void | the stock shelled 2 mm with no face open: a closed body with a sealed void | analytic | pass | 0.017 | 0.017 | |
| ladder/09-shells-and-offsets/009-shell-outside-t2 | the stock shelled 2 mm outward, open at the top | analytic | pass | 0.017 | 0.017 | |
| ladder/09-shells-and-offsets/006-shell-rounds-r1-thinner-than-t2 | the box with r1 vertical rounds shelled 2 mm: the inner corners close sharp | analytic | pass | 0.040 | 0.040 | |
| ladder/09-shells-and-offsets/008-offset-cylinder-wall-2 | a cylinder r10 h20 with its side face offset 2 mm | analytic | pass | 0.057 | 0.057 | |
| ladder/09-shells-and-offsets/005-shell-rounds-r5-t2 | the box with r5 vertical rounds shelled 2 mm open at the top: the inner corners r3 | analytic | pass | 0.071 | 0.071 | |
| ladder/09-shells-and-offsets/002-cylinder-open-top-t1 | a cylinder r10 h30 shelled 1 mm, open at the top | analytic | pass | 0.077 | 0.077 | |
| ladder/09-shells-and-offsets/014-drafted-box-with-rounds-shelled | a 120x80x40 box drafted 5 degrees with 4 mm rounds on the sloping corners, shelled 2 mm open at the top: the inner rounds' edges must lie on their faces (#3573 reports the same design) | analytic | pass | 0.077 | 0.077 | |
| ladder/09-shells-and-offsets/010-shell-under-rounded-top | the stock with r3 rounds on its four top edges, shelled 2 mm open at the bottom | analytic | pass | 0.079 | 0.079 | |
| ladder/09-shells-and-offsets/013-dome-shelled-from-base | a dome r20 shelled 2 mm, open at its flat base: the rim is the circle r18 where the inner sphere meets the base plane | analytic | pass | 0.112 | 0.112 | |
| ladder/09-shells-and-offsets/015-shelled-dome-ring-joined-back | a dome (a quarter disc r20 revolved) shelled 2 mm from its flat base, then the base ring (r 18..20) face-extruded 10 mm back into the dome as a join: ~120 s, then 'boolean Union: no result' | analytic | pass | 0.696 | 0.696 | |
| ladder/09-shells-and-offsets/011-part-shell | the running part shelled 1.5 mm open at the bottom | analytic | pass | 0.965 | 0.965 | |
| ladder/10-patterns-and-mirrors/007-pattern-bodies | a pin r3 h10 patterned 4 times at 10 mm as bodies | analytic | pass | 0.035 | 0.035 | |
| ladder/10-patterns-and-mirrors/004-mirror-body-joined | a 30x40x20 half with a d10 hole mirrored about x=30 and joined: the faces at x=30 coincide | analytic | pass | 0.047 | 0.047 | |
| ladder/10-patterns-and-mirrors/005-mirror-feature | a d10 hole in the stock mirrored about x=30 as a feature | analytic | pass | 0.074 | 0.074 | |
| ladder/10-patterns-and-mirrors/001-rect-pattern-holes | a d5 hole patterned 3 x 2 at 20 mm in a 60x40x10 plate | analytic | pass | 0.175 | 0.175 | |
| ladder/10-patterns-and-mirrors/003-overlapping-pattern-leaves-core | six r5 cuts patterned round a circle r6 in a disk r20: they overlap and cut a core free | analytic | pass | 0.315 | 0.315 | |
| ladder/10-patterns-and-mirrors/002-circular-pattern-holes | a d6 hole patterned 8 times round a disk r30 h10 | analytic | pass | 0.351 | 0.351 | |
| ladder/10-patterns-and-mirrors/006-circular-pattern-counterbores | a counterbored hole (d5, d9 x 3) patterned 6 times round a disk r30 h10 | analytic | pass | 0.855 | 0.855 | |
| 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 | 1.765 | 1.765 | |
| ladder/11-cumulative-parts/001-bracket | an L bracket: concave r5 round, 5 mm outer chamfer, a hole in each leg | analytic | pass | 0.088 | 0.088 | |
| 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 | 0.618 | 0.618 | |
| 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 | 1.821 | 1.821 | |
| 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 | 2.307 | 2.307 | |
| ladder/10-patterns-and-mirrors/001-rect-pattern-holes | a d5 hole patterned 3 x 2 at 20 mm in a 60x40x10 plate | analytic | pass | 0.239 | 0.239 | |
| ladder/10-patterns-and-mirrors/003-overlapping-pattern-leaves-core | six r5 cuts patterned round a circle r6 in a disk r20: they overlap and cut a core free | analytic | pass | 0.299 | 0.299 | |
| ladder/10-patterns-and-mirrors/002-circular-pattern-holes | a d6 hole patterned 8 times round a disk r30 h10 | analytic | pass | 0.484 | 0.484 | |
| ladder/10-patterns-and-mirrors/006-circular-pattern-counterbores | a counterbored hole (d5, d9 x 3) patterned 6 times round a disk r30 h10 | analytic | pass | 0.758 | 0.758 | |
| 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 | 1.590 | 1.590 | |
| ladder/11-cumulative-parts/001-bracket | an L bracket: concave r5 round, 5 mm outer chamfer, a hole in each leg | analytic | pass | 0.089 | 0.089 | |
| 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 | 0.673 | 0.673 | |
| 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 | 2.166 | 2.166 | |
| 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 | 2.313 | 2.313 | |
| ladder/12-sheet-metal/001-base-flange | a 100 x 60 base flange, 2 mm sheet | analytic | pass | 0.002 | 0.002 | |
| ladder/12-sheet-metal/002-edge-flange-90 | a 20 mm 90 deg edge flange along the base's front edge | analytic | pass | 0.005 | 0.005 | |
| 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.005 | 0.005 | |
| ladder/12-sheet-metal/009-hem-on-the-back-edge | 002's L with an 8 mm hem on the base's back edge, folded under it with a 1 mm inner radius | analytic | pass | 0.006 | 0.006 | |
| ladder/12-sheet-metal/012-fold-refolded | 011's flat refolded: 010's part again | analytic | pass | 0.008 | 0.008 | |
| ladder/12-sheet-metal/007-corner-relief-rectangular | 003's tray with a rectangular corner relief 4 mm across at each corner | analytic | pass | 0.008 | 0.008 | |
| ladder/12-sheet-metal/011-fold-unfolded | 010's fold unfolded: the flat 100 x 60 plate again | analytic | pass | 0.010 | 0.010 | |
| ladder/12-sheet-metal/004-four-flanges-72-leaning-out | 20 mm flanges at 72 deg on all four edges, made together and closed at the corners, leaning out: the panel ends run on along a slant | analytic | pass | 0.014 | 0.014 | |
| ladder/12-sheet-metal/003-four-flanges-90-closed-corners | 20 mm 90 deg flanges on all four edges, made together: the corners close with the rule's gap, notch relief | analytic | pass | 0.014 | 0.014 | |
| ladder/12-sheet-metal/005-four-flanges-108-leaning-in | 20 mm flanges at 108 deg on all four edges, made together and closed at the corners, leaning in over the base: the panel ends are cut back along a slant where they would overlap | analytic | pass | 0.014 | 0.014 | |
| ladder/12-sheet-metal/006-corner-relief-round | 003's tray with a round corner relief 4 mm across at each corner | analytic | pass | 0.017 | 0.017 | |
| ladder/12-sheet-metal/013-flat-pattern | the flat pattern of 003's tray: its outline's size and area, and its four bend lines | analytic | pass | 0.032 | 0.032 | |
| ladder/12-sheet-metal/008-corner-relief-tear | 003's tray with torn corners: the bends run to the corner and each end is cut straight, in the flat, to where its panel's end starts | analytic | pass | 0.071 | 0.071 | |
| ladder/12-sheet-metal/014-bracket | a bracket: a 30 mm flange on the front edge, a 10 mm lip turned out on its far edge, a d10 hole through the base | analytic | pass | 0.092 | 0.092 | |
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/env python3
"""Select the kernel rig areas a pull request affects (.github/workflows/kernel-rig.yml).
Usage: kernel_rig_plan.py (--all | --paths FILE) [--root DIR] [--github-output FILE]
FILE holds the changed paths relative to the repository root, separated by NUL (git diff -z);
"-" reads standard input. --all selects every area (pushes, merge groups, the release gate, a run
by hand). --root is the repository (default: two folders up from this script).
The areas are the folders of tests/kernel-cases/ (the ladder aside), so a new area joins by
having a folder with its cases, its KNOWN_FAILING and its PATHS. A changed path selects:
- every area, when it matches tests/kernel-cases/PATHS-ALL (the shared core: SMLib, geom, the
kernel's core, the rig's grader and runner, the workflow);
- an area, when it is under tests/kernel-cases/<area>/ or matches that area's PATHS: one git
pathspec glob a line (`*` within a folder, `**` across folders), `#` starts a comment.
The ladder spans every operation: it runs whenever any area does, and on a change under
tests/kernel-cases/ladder/.
The coverage check (`cargo xtask kernel-cases --coverage`) runs in the build job. The build runs
when a shard does, or when the command registry or the cases may have changed (COVERAGE below),
so a new command without a case fails on its own pull request.
Prints and optionally appends to $GITHUB_OUTPUT:
shards=["booleans", ..., "ladder"] the shard matrix, JSON (empty list: no shard runs)
build=true|false the build job (and the coverage check) runs
"""
import argparse
import json
import os
import re
import sys
CASES = "tests/kernel-cases"
LADDER = "ladder"
# Changes here may add or remove a registry command, or the case that covers one: the coverage
# check must see them even when no area runs.
COVERAGE = (
"crates/engine/src/cmd/**",
"tests/kernel-cases/EXEMPT",
"tests/kernel-cases/**/recipe.json",
"xtask/src/kernel_cases.rs",
)
def glob_regex(glob):
"""A git pathspec glob (`:(glob)` magic) as a regular expression over a whole path: `**/`
matches any folders (none too), a trailing `/**` everything below, `*` and `?` stay within
one folder."""
out, i = [], 0
while i < len(glob):
if glob.startswith("**/", i):
out.append("(?:.*/)?")
i += 3
elif glob.startswith("**", i):
out.append(".*")
i += 2
elif glob[i] == "*":
out.append("[^/]*")
i += 1
elif glob[i] == "?":
out.append("[^/]")
i += 1
else:
out.append(re.escape(glob[i]))
i += 1
return re.compile("".join(out) + r"\Z")
def read_globs(path):
"""The globs of a PATHS file: one a line, blank lines and `#` comments skipped."""
with open(path, encoding="utf-8") as f:
lines = [line.strip() for line in f]
globs = [line for line in lines if line and not line.startswith("#")]
for g in globs:
if g.startswith("/") or g.startswith(":") or "\\" in g:
raise SystemExit(f"{path}: `{g}`: a glob is relative to the repository root, with / and no pathspec magic")
return globs
def areas(root):
"""Every area (a folder of tests/kernel-cases/ but the ladder) with its PATHS globs."""
base = os.path.join(root, CASES)
out = {}
for name in sorted(os.listdir(base)):
if name == LADDER or not os.path.isdir(os.path.join(base, name)):
continue
paths = os.path.join(base, name, "PATHS")
if not os.path.isfile(paths):
raise SystemExit(f"{CASES}/{name}/PATHS is missing: every area lists the source files whose change reruns it")
out[name] = read_globs(paths)
return out
def matches(globs, path):
return any(glob_regex(g).match(path) for g in globs)
def select(root, paths, everything=False):
"""Return (shards, build): the areas to run, in order and the ladder last, and whether the
build job runs."""
by_area = areas(root)
if everything:
return [*by_area, LADDER], True
shared = read_globs(os.path.join(root, CASES, "PATHS-ALL"))
hit, ladder = set(), False
for path in paths:
if matches(shared, path):
return [*by_area, LADDER], True
if path.startswith(f"{CASES}/{LADDER}/"):
ladder = True
for area, globs in by_area.items():
if path.startswith(f"{CASES}/{area}/") or matches(globs, path):
hit.add(area)
shards = [a for a in by_area if a in hit]
if shards or ladder:
shards.append(LADDER)
return shards, bool(shards) or any(matches(COVERAGE, p) for p in paths)
def read_paths(src):
data = sys.stdin.buffer.read() if src == "-" else open(src, "rb").read()
return [p.decode() for p in data.split(b"\0") if p]
def main():
ap = argparse.ArgumentParser()
group = ap.add_mutually_exclusive_group(required=True)
group.add_argument("--paths")
group.add_argument("--all", action="store_true")
ap.add_argument("--root", default=os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
ap.add_argument("--github-output")
a = ap.parse_args()
shards, build = select(a.root, [] if a.all else read_paths(a.paths), everything=a.all)
lines = [f"shards={json.dumps(shards)}", f"build={'true' if build else 'false'}"]
print("\n".join(lines))
if a.github_output:
with open(a.github_output, "a", encoding="utf-8") as f:
f.write("\n".join(lines) + "\n")
if __name__ == "__main__":
main()
+156
View File
@@ -0,0 +1,156 @@
#!/usr/bin/env python3
"""Self-test for kernel_rig_plan.py. Run: python3 -I scripts/ci/test_kernel_rig_plan.py (from the
repo root).
Uses a small synthetic tests/kernel-cases/, then the real one: every area has its PATHS and
KNOWN_FAILING, every glob names files that exist, and the workflow's trigger paths cover them all.
"""
import os
import re
import subprocess
import sys
import tempfile
import unittest
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import kernel_rig_plan as plan # noqa: E402
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
WORKFLOW = os.path.join(ROOT, ".github", "workflows", "kernel-rig.yml")
def write(root, rel, text=""):
path = os.path.join(root, rel)
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, "w", encoding="utf-8") as f:
f.write(text)
class Glob(unittest.TestCase):
def test_star_stays_in_a_folder_and_double_star_crosses(self):
self.assertTrue(plan.glob_regex("crates/kernel/src/blend*.rs").match("crates/kernel/src/blend_smlib.rs"))
self.assertFalse(plan.glob_regex("crates/kernel/src/*.rs").match("crates/kernel/src/tess/grid.rs"))
self.assertTrue(plan.glob_regex("crates/kernel/src/tess/**").match("crates/kernel/src/tess/a/b.rs"))
self.assertFalse(plan.glob_regex("crates/kernel/src/tess/**").match("crates/kernel/src/tess.rs"))
self.assertTrue(plan.glob_regex("tests/**/recipe.json").match("tests/recipe.json"))
self.assertTrue(plan.glob_regex("tests/**/recipe.json").match("tests/a/b/recipe.json"))
self.assertFalse(plan.glob_regex("a.rs").match("a.rsx"))
self.assertFalse(plan.glob_regex("a.rs").match("b/a.rs"))
class Synthetic(unittest.TestCase):
def setUp(self):
self.tmp = tempfile.TemporaryDirectory()
r = self.root = self.tmp.name
write(r, "tests/kernel-cases/PATHS-ALL", "# shared\ncrates/geom/**\n\n.github/workflows/kernel-rig.yml\n")
write(r, "tests/kernel-cases/fillets/PATHS", "# blends\ncrates/kernel/src/blend*.rs\n")
write(r, "tests/kernel-cases/shell/PATHS", "crates/kernel/src/offset*.rs\ncrates/kernel/src/blend_smlib.rs\n")
write(r, "tests/kernel-cases/ladder/ladder.json", "{}")
write(r, "tests/kernel-cases/README.md")
def tearDown(self):
self.tmp.cleanup()
def select(self, *paths):
return plan.select(self.root, list(paths))
def test_an_area_runs_on_its_paths_with_the_ladder(self):
self.assertEqual(self.select("crates/kernel/src/blend.rs"), (["fillets", "ladder"], True))
self.assertEqual(self.select("crates/kernel/src/blend_smlib.rs"), (["fillets", "shell", "ladder"], True))
def test_a_change_to_an_areas_cases_runs_it(self):
self.assertEqual(self.select("tests/kernel-cases/shell/1-x/expected.json"), (["shell", "ladder"], True))
self.assertEqual(self.select("tests/kernel-cases/shell/PATHS"), (["shell", "ladder"], True))
self.assertEqual(self.select("tests/kernel-cases/ladder/golden.json"), (["ladder"], True))
def test_the_shared_core_runs_every_area(self):
for p in ["crates/geom/src/brep.rs", ".github/workflows/kernel-rig.yml"]:
self.assertEqual(self.select("docs/a.md", p), (["fillets", "shell", "ladder"], True), p)
def test_unrelated_changes_run_nothing(self):
self.assertEqual(self.select("crates/ui-egui/src/app.rs", "docs/a.md", "tests/kernel-cases/README.md"), ([], False))
def test_a_registry_or_case_change_builds_for_the_coverage_check(self):
self.assertEqual(self.select("crates/engine/src/cmd/view_navigation.rs"), ([], True))
self.assertEqual(self.select("tests/kernel-cases/EXEMPT"), ([], True))
def test_everything_runs_every_area(self):
self.assertEqual(plan.select(self.root, [], everything=True), (["fillets", "shell", "ladder"], True))
def test_a_new_area_joins_from_its_folder(self):
write(self.root, "tests/kernel-cases/surfaces/PATHS", "crates/kernel/src/surface_*.rs\n")
self.assertEqual(self.select("crates/kernel/src/surface_trim.rs"), (["surfaces", "ladder"], True))
self.assertEqual(plan.select(self.root, [], everything=True)[0], ["fillets", "shell", "surfaces", "ladder"])
def test_an_area_without_paths_is_an_error(self):
os.makedirs(os.path.join(self.root, "tests/kernel-cases/plastic"))
with self.assertRaises(SystemExit) as e:
self.select("crates/geom/src/brep.rs")
self.assertIn("plastic/PATHS is missing", str(e.exception))
def trigger_globs():
"""The pull_request trigger paths of the workflow (the push trigger lists the same)."""
with open(WORKFLOW, encoding="utf-8") as f:
text = f.read()
events = {}
for event in ("pull_request", "push"):
block = re.search(rf"^ {event}:\n((?: .*\n|\s*\n)+)", text, re.M)
assert block, event
paths = block.group(1).split("paths:", 1)[1]
events[event] = re.findall(r'^\s+- "([^"]+)"', paths, re.M)
return events
def sample(glob):
"""A path the glob matches: each wildcard filled in."""
return glob.replace("**", "x/y").replace("*", "x").replace("?", "x")
class Real(unittest.TestCase):
def test_every_area_has_its_lists_and_every_glob_names_files(self):
# Tracked files and new ones not yet committed (not the ignored ones).
ls = ["git", "ls-files", "--cached", "--others", "--exclude-standard"]
tracked = subprocess.run(ls, cwd=ROOT, check=True, capture_output=True, text=True).stdout.split("\n")
shared = plan.read_globs(os.path.join(ROOT, plan.CASES, "PATHS-ALL"))
areas = plan.areas(ROOT)
self.assertTrue(areas)
for area, globs in {"PATHS-ALL": shared, **areas}.items():
if area != "PATHS-ALL":
self.assertTrue(os.path.isfile(os.path.join(ROOT, plan.CASES, area, "KNOWN_FAILING")), area)
for g in globs:
with self.subTest(area=area, glob=g):
rx = plan.glob_regex(g)
self.assertTrue(any(rx.match(t) for t in tracked), f"{area}: {g} matches no file")
def test_an_area_names_only_its_own_files(self):
# The shared core is in PATHS-ALL; an area's PATHS repeating it (or a whole crate's
# folder) would only blur what the area is about.
ls = ["git", "ls-files", "--cached", "--others", "--exclude-standard"]
files = subprocess.run(ls, cwd=ROOT, check=True, capture_output=True, text=True).stdout.split("\n")
shared = plan.read_globs(os.path.join(ROOT, plan.CASES, "PATHS-ALL"))
core = {f for f in files if plan.matches(shared, f)}
for area, globs in plan.areas(ROOT).items():
for g in globs:
rx = plan.glob_regex(g)
overlap = sorted(f for f in core if rx.match(f))
with self.subTest(area=area, glob=g):
self.assertFalse(overlap, f"{area}/PATHS: {g} names shared-core files (PATHS-ALL): {overlap[:3]}")
def test_the_workflow_triggers_on_every_glob(self):
events = trigger_globs()
self.assertEqual(events["pull_request"], events["push"])
triggers = [plan.glob_regex(g) for g in events["pull_request"]]
globs = [*plan.read_globs(os.path.join(ROOT, plan.CASES, "PATHS-ALL")), *plan.COVERAGE]
for area, own in plan.areas(ROOT).items():
globs += [*own, f"{plan.CASES}/{area}/**"]
for g in globs:
with self.subTest(glob=g):
self.assertTrue(any(t.match(sample(g)) for t in triggers), f"{g}: not under the workflow's trigger paths")
def test_a_ui_change_runs_nothing(self):
self.assertEqual(plan.select(ROOT, ["crates/ui-egui/src/app.rs", "docs/kernel-cases.md", "README.md"]), ([], False))
if __name__ == "__main__":
unittest.main()
+3 -1
View File
@@ -25,6 +25,8 @@ A failing test without its fix cannot merge: it turns `main` red for everyone. I
## Goldens, matrices and skipped tests
- The reference for what the kernel builds is the kernel-cases ladder (`tests/kernel-cases/ladder/`, `cargo xtask kernel-cases --ladder`, `docs/kernel-ladder.md`).
- Kernel PRs run `kernel-rig.yml`: the areas the diff reaches (`PATHS`) against `KNOWN_FAILING`, the ladder against its golden. In the same PR a fix removes its line, a new failing case adds one, a changed ladder result is re-recorded (`--record "why"`), a new command gets a case or an `EXEMPT` line; see `tests/kernel-cases/README.md`.
- Maintainers' PRs run the native, GPU path and reference tests on the affected packages; others wait for `approved-for-ci`. `release-gate.yml` runs everything in full before develop replaces main.
- The action matrix is a ratchet: record a newly passing action with `cargo xtask action-matrix --bless` (`docs/action-matrix.md`).
- Pull requests skip a few heavy tests, which run in the merge queue, nightly and on `main`. Check that validation after merging. The list is in `.config/nextest.toml` and the testing page.
- Mutation testing finds behaviour the suites miss: `docs/mutation-testing.md`.
- Mutation testing finds what the suites miss: `docs/mutation-testing.md`.
+283
View File
@@ -0,0 +1,283 @@
# Registry commands with no kernel rig case (`cargo xtask kernel-cases --coverage`). Every other
# command of `solidcraft-cli commands` (planned ones aside) must be run by some recipe.json under
# tests/kernel-cases/. One line a command: `<id> <why it has no case>`; `#` starts a comment.
# Each section is sorted, with no id twice.
#
# Commands with no geometry to grade: the view, rendering, appearance, materials, selection, the
# browser, files and saving, documents, diagnostics, and component, parameter and timeline
# bookkeeping. Each is covered by the engine's and the UI's own tests.
appearance.assign appearance only: colours and textures
appearance.library appearance only: colours and textures
appearance.list appearance only: colours and textures
assembly.bom a bill of materials report
body.rename a body name
browser.collapse_all the browser tree: order, groups and folding
browser.expand_all the browser tree: order, groups and folding
browser.group the browser tree: order, groups and folding
browser.move the browser tree: order, groups and folding
browser.order the browser tree: order, groups and folding
browser.rename_group the browser tree: order, groups and folding
browser.ungroup the browser tree: order, groups and folding
canvas.calibrate reference images, and sketches traced from them (sketch only)
canvas.decal reference images, and sketches traced from them (sketch only)
canvas.delete reference images, and sketches traced from them (sketch only)
canvas.edit reference images, and sketches traced from them (sketch only)
canvas.insert reference images, and sketches traced from them (sketch only)
canvas.to_sketch reference images, and sketches traced from them (sketch only)
component.break_link component links
component.copies a listing of identical copies
component.cycle_color component colours
component.delete removes a component: no geometry built
component.links component links
component.list a listing
component.metadata component metadata
component.metadata.set component metadata
component.properties component properties
component.relink component links
component.rename a component name
component.replace_with_link component links
component.unlock component locking
component.update_links component links
diagnostics.crash_report crash reports
diagnostics.crash_reports crash reports
diagnostics.crash_reports.clear crash reports
diagnostics.crash_test crash reports
diagnostics.profile timing: where a command's time goes
doc.open opening and recovering documents
doc.recover opening and recovering documents
doc.recovery_discard opening and recovering documents
doc.recovery_list opening and recovering documents
document.metadata document metadata and revisions
document.metadata.remove document metadata and revisions
document.metadata.set document metadata and revisions
document.revision document metadata and revisions
edit.checkpoint undo, redo and checkpoints: an earlier state restored, no new geometry
edit.redo undo, redo and checkpoints: an earlier state restored, no new geometry
edit.restore_checkpoint undo, redo and checkpoints: an earlier state restored, no new geometry
edit.undo undo, redo and checkpoints: an earlier state restored, no new geometry
engine.commands the command registry itself
engine.describe the command registry itself
explode.delete exploded views: display offsets
explode.list exploded views: display offsets
expr.evaluate expression evaluation
file.open_in_easyprint hands the file to another program
file.save saving the design
file.save_as saving the design
file.save_mesh saving a display mesh
file.send_to_slicer hands the file to a slicer
file.slicers a listing of slicers
frame.profile.list a listing of the profile library
frame.profile.properties a profile's section properties from the library
inspect.accessibility display analysis: shading
inspect.colored_components display: component colours
inspect.curvature_map display analysis: shading
inspect.environment_map display analysis: shading
inspect.silhouette display analysis: outline
inspect.zebra display analysis: shading
library.apply material and appearance libraries
library.export material and appearance libraries
library.inspect material and appearance libraries
material.assign materials and their properties
material.create materials and their properties
material.delete materials and their properties
material.edit materials and their properties
material.inspect materials and their properties
material.list materials and their properties
material.properties.directional materials and their properties
material.properties.validate materials and their properties
model.edges a listing of the model's topology
model.faces a listing of the model's topology
model.threads a listing of the model's topology
motion.delete removes a motion study
motion.export writes a study's results to a file
motion.export_animation writes an animation
motion.list a listing of motion studies
parameters.comment parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.complete parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.delete parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.export parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.favorite parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.graph parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.import parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.list parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.move parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.rename parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parameters.users parameter bookkeeping; a value change that rebuilds is parameters.change, which cases use
parts.library a listing of the parts library
render.aging.describe rendering: images, cameras, stages
render.backends rendering: images, cameras, stages
render.camera.fit rendering: images, cameras, stages
render.camera.get rendering: images, cameras, stages
render.camera.set rendering: images, cameras, stages
render.cancel rendering: images, cameras, stages
render.effects.describe rendering: images, cameras, stages
render.export rendering: images, cameras, stages
render.hdr.inspect rendering: images, cameras, stages
render.library.appearance.apply rendering: images, cameras, stages
render.library.describe rendering: images, cameras, stages
render.library.environment.apply rendering: images, cameras, stages
render.library.list rendering: images, cameras, stages
render.library.physical.prepare rendering: images, cameras, stages
render.library.preview rendering: images, cameras, stages
render.library.studio.apply rendering: images, cameras, stages
render.library.studio.prepare rendering: images, cameras, stages
render.library.surface.bind rendering: images, cameras, stages
render.library.surface.prepare rendering: images, cameras, stages
render.library.surface.unbind rendering: images, cameras, stages
render.library.targets rendering: images, cameras, stages
render.optics.bind rendering: images, cameras, stages
render.optics.unbind rendering: images, cameras, stages
render.preflight rendering: images, cameras, stages
render.preset.apply rendering: images, cameras, stages
render.preset.resolve rendering: images, cameras, stages
render.quality.prepare rendering: images, cameras, stages
render.result.pin rendering: images, cameras, stages
render.result.regrade rendering: images, cameras, stages
render.scene rendering: images, cameras, stages
render.settings.apply rendering: images, cameras, stages
render.settings.capture_hdr rendering: images, cameras, stages
render.settings.get rendering: images, cameras, stages
render.settings.set rendering: images, cameras, stages
render.shot.duplicate rendering: images, cameras, stages
render.shot.remove rendering: images, cameras, stages
render.shot.rename rendering: images, cameras, stages
render.stage.backdrop rendering: images, cameras, stages
render.stage.clear rendering: images, cameras, stages
render.stage.ground rendering: images, cameras, stages
render.start rendering: images, cameras, stages
render.status rendering: images, cameras, stages
select.clear the selection
select.set the selection
selection.delete deletes what is selected through the commands that own each kind
sheet.rules a listing of sheet metal rules
sketch.arc.tangent 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.auto_constrain 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.auto_constrain_from_datum 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.break 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.break_link 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.cancel 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.centerline 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.chain 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.chamfer.distance_angle 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.chamfer.equal_distance 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.chamfer.two_distance 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.circle.three_point 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.circle.three_tangent 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.circle.two_point 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.circle.two_tangent 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constrainer 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.coincident 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.collinear 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.concentric 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.curvature 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.equal 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.midpoint 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.parallel 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.perpendicular 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.polygon 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.constraint.symmetry 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.construction 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.copy 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.cut 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.delete 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.dimension_text 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.drag 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.drag_end 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.draw.dimensioned 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.drawing_bounds 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.edit_text 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.export_dxf 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.extend 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.fillet 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.finish_auto_constrain 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.glyphs 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.infinite 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.insert_dxf 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.insert_svg 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.inspect 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.line.midpoint 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.loose_ends 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.loose_ends.tie 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.mirror 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.move 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.move3d 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.offset 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.offset.break 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.paste 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.pattern.rectangular 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.point3d 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.polygon.edge 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.rectangle.three_point 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.redefine 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.scale 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.slot.arc_center 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.slot.arc_three_point 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.slot.center_point 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.snap 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.solve 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.toggle_driven 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.transform 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.trim 2D sketch only (the sketch solver and engine tests); no kernel operation
sketch.trim.path 2D sketch only (the sketch solver and engine tests); no kernel operation
timeline.dependents a listing of dependents
timeline.export_script writes the history as a script
timeline.inspect a listing of the timeline
timeline.rename a feature name
timeline.rename_group a group name
view.ambient_occlusion the view: camera, layout, display
view.apply the view: camera, layout, display
view.back the view: camera, layout, display
view.bottom the view: camera, layout, display
view.delete the view: camera, layout, display
view.fit the view: camera, layout, display
view.front the view: camera, layout, display
view.graphics_preset the view: camera, layout, display
view.grid the view: camera, layout, display
view.ground_shadow the view: camera, layout, display
view.history_layout the view: camera, layout, display
view.home the view: camera, layout, display
view.isometric the view: camera, layout, display
view.layout the view: camera, layout, display
view.left the view: camera, layout, display
view.list the view: camera, layout, display
view.navigate the view: camera, layout, display
view.navigation_bar the view: camera, layout, display
view.normal_to the view: camera, layout, display
view.perspective the view: camera, layout, display
view.rename the view: camera, layout, display
view.right the view: camera, layout, display
view.save the view: camera, layout, display
view.spin the view: camera, layout, display
view.tool the view: camera, layout, display
view.top the view: camera, layout, display
view.visual_style the view: camera, layout, display
# Commands that make or change geometry and have no case yet. This section only shrinks:
# the pull request that adds a case for one removes its line (the check fails on a listed command
# that a case uses), and a new geometry command gets a case, not a line here.
[to cover]
body.repair repair: the solid a refused or open part becomes
component.move_sketches assemblies: sketches moved between components
component.revert_position assemblies: a placement reverted
file.export_view_dxf drawings: the projection of the model a view DXF holds
inspect.draft inspect: the number or curves it reports
inspect.parameter_sweep inspect: results rebuilt over a parameter range
inspect.section inspect: the number or curves it reports
motion.trace.edit assemblies: motion results
motion.trace.keep assemblies: motion results
parts.fastener standard parts: a fastener body
parts.insert standard parts: a part body
parts.resize standard parts: a part resized
sketch.arc3d sketch: a curve kind no case profiles yet
sketch.auto_project sketch from the model: curves the kernel computes from bodies
sketch.conic sketch: a curve kind no case profiles yet
sketch.fit_curves_to_section sketch from the model: curves the kernel computes from bodies
sketch.include_3d sketch from the model: curves the kernel computes from bodies
sketch.intersect sketch from the model: curves the kernel computes from bodies
sketch.intersection_curve sketch from the model: curves the kernel computes from bodies
sketch.isoparametric_curve sketch from the model: curves the kernel computes from bodies
sketch.project_to_surface sketch from the model: curves the kernel computes from bodies
sketch.spline.control_point_5 sketch: a curve kind no case profiles yet
sketch.spline3d sketch: a curve kind no case profiles yet
sketch.spun_profile sketch from the model: curves the kernel computes from bodies
+58
View File
@@ -0,0 +1,58 @@
# The shared core: a change to any of these reruns every area of the kernel rig and the ladder
# (scripts/ci/kernel_rig_plan.py). One git pathspec glob a line, relative to the repository root:
# `*` stays within a folder, `**` crosses folders. Each area's own sources are in <area>/PATHS.
#
# SMLib: the bindings, the schema 4 record bridge and the pinned revision (SMLIB_REV,
# SMLIB_PREBUILT), and the script that fetches it.
crates/smlib/**
scripts/fetch-smlib.sh
# The geometry every body is made of: B-rep record, curves, surfaces, meshes.
crates/geom/**
# The kernel's core, which every case goes through: bodies, extrude/revolve/primitives, booleans
# and placements, the planar prisms, the SMLib sweeps and booleans, history and provenance, the
# native bridge to SMLib, tessellation, and what the grader measures (measure, validity, counts).
crates/kernel/Cargo.toml
crates/kernel/src/body.rs
crates/kernel/src/boolean_record.rs
crates/kernel/src/build.rs
crates/kernel/src/freeform.rs
crates/kernel/src/heal.rs
crates/kernel/src/history.rs
crates/kernel/src/lib.rs
crates/kernel/src/measure.rs
crates/kernel/src/native.rs
crates/kernel/src/native/**
crates/kernel/src/numbered.rs
crates/kernel/src/ops.rs
crates/kernel/src/par.rs
crates/kernel/src/planar_regularize.rs
crates/kernel/src/planar_sources.rs
crates/kernel/src/plane_fit.rs
crates/kernel/src/prism.rs
crates/kernel/src/prism_curve.rs
crates/kernel/src/prism_measure.rs
crates/kernel/src/profile.rs
crates/kernel/src/provenance.rs
crates/kernel/src/record.rs
crates/kernel/src/shell_groups.rs
crates/kernel/src/smlib_boolean.rs
crates/kernel/src/smlib_sweeps.rs
crates/kernel/src/tess/**
crates/kernel/src/topo.rs
crates/kernel/src/validity.rs
crates/kernel/src/watch.rs
# Timeline evaluation and the model cache, which every feature is evaluated through.
crates/doc/src/eval.rs
crates/doc/src/model_cache.rs
crates/doc/src/walk.rs
# The command registry and the solid feature commands every case starts with (sketches made
# into boxes, cylinders, extrusions, revolutions, combines, moves; fillets, holes, shells, sweeps
# and lofts live there too).
crates/engine/src/cmd/features.rs
crates/engine/src/cmd/mod.rs
# The rig itself: the grader, the runner, the selection and this gate's workflow.
.github/workflows/kernel-rig.yml
apps/solidcraft-cli/src/kernel_cases.rs
scripts/ci/kernel_rig_plan.py
xtask/src/kernel_cases.rs
xtask/src/kernel_ladder.rs
+90 -17
View File
@@ -57,6 +57,16 @@ One directory per area, one per case: `tests/kernel-cases/<area>/<id>/`.
| `crashes` (crashes and hangs inside kernel operations) | booleans/shell/import/crash rig |
| `fillets`, `sweeps`, `threads`, `sheet-metal`, `tessellation` | history rig |
| `continuity` (designed seams of known order, G0 to G4, that prove the continuity measurement itself) | history rig |
| `solids` (cones, scale, align, bounding solids) | tool coverage |
| `frames` (frame members, inserted profiles) | tool coverage |
| `plastic` (boss, lip and groove, rest, snap fit, plastic rules) | tool coverage rig |
| `surfaces` (every `surface.*` tool: offset, ruled, untrim, unstitch, reverse normal, boundary, blend, match, fair, and a normal and an edge case of each of the others) | surfaces rig |
| `construction` (construction planes, axes and points: `construct.*`) | tool coverage rig |
| `inspect` (the inspect commands that return numbers) | tool coverage rig |
| `history` (the timeline's suppress, reorder, delete, roll back, edit and folders; configuration rows, columns and rules; parameters that drive geometry) | tool coverage rig |
| `assemblies` (joints and couplings, motion studies, contact, components and occurrences, interference and clearance between placed parts: placements and answers worked out by hand) | rig coverage |
Each area also has its gate files: `KNOWN_FAILING` and `PATHS` (see [the gate](#the-kernel-rig-gate)).
`<id>` is `<source number>-<short-name>`, such as `1894-prism-cut-touching-walls`.
@@ -112,38 +122,93 @@ the frozen truck-geometry PRs, a `kernel-paused` PR), for the report's coverage
| `faces`, `edges`, `vertices`, `shells`, `body_count` as `[min, max]` | An inclusive range, where the geometry only bounds a count (a modelled thread's faces). |
| `continuity` | `{order, edges}`: every seam `edges` names reaches `order` (`g0` … `g4`), as Continuity Analysis (`inspect.continuity`) measures it: from the faces' exact surfaces, at its default 33 stations a seam and its default tolerances (1 µm, 1°, 0.01 / mm, 0.001 / mm², 0.0001 / mm³), never loosened per case. A failure names the worst seam (lowest order; of those, the one furthest past the next order's tolerance), its faces, the order it reaches and that next order's worst value. `edges`: `blend` (default), every seam of a face a fillet or chamfer made (a round, a chamfer face or a corner patch) with the faces either side of the edge it replaced, and every seam of a corner patch with the rounds it joins: what the blend is built to meet (not where a round runs into an end face, nor where two rounds meet without a patch: that seam is the input's, tangent only where the rounded edges were); `corner`, those of them on a corner patch (a blend made from several replaced edges); or a list of points `[[x,y,z], …]`, the edges nearest them, as Continuity Analysis picks them. `exact: true`: every seam reaches `order` and not the next (a case built to an order proves the measurement reads that order, no more and no less). A constant round meets its faces G1 (curvature jumps by 1 / r), a `curvature` round G2, a chamfer G0; a `corner: g2` patch is built G2 to the rounds and faces round it. |
| `continuity` (older form) | `{near, within_mm, clear_mm, curvature_jump_per_mm}`: over every tangent seam lying wholly within `within_mm` of `near` (a corner's patch and its neighbours), the curvature jump across it (the faces' normal curvatures square to the seam, from their exact surfaces, at 65 stations a seam) is at most `curvature_jump_per_mm` at every station at least `clear_mm` along the seam from a vertex where two of those seams turn (where a neighbour's own G1 seam ends, which no surface is G2 to both sides of). A rolling ball's corner jumps 1 / r everywhere. |
| `surface_types` | The set of kinds the faces' surfaces are, over every body, as the records hold them: `plane`, `cylinder`, `cone`, `sphere`, `torus`, `bspline` (a B-spline or NURBS surface) or `revolution` (a revolved curve). Exact: none missing, none extra. |
| `splines` | `[{degree: [p, q], spans?: [m, n]}, …]`: one entry per B-spline face, each matching one face (directions in either order); `spans`, the distinct knot intervals each way, only where the construction fixes them. |
| `boundary_edges` | The edges only one face uses (a sheet's free boundary), over every body, as the records hold them; exact or `[min, max]`. |
| `flat_pattern` | A sheet metal case's flat pattern, from the script's last `sheet.flat_pattern` result: `size_mm` ([w, h] of the outline), `area_mm2` (the outline's area less the cut-outs', relative tolerance as volume) and `bend_lines` (each `[[x, y], [x, y]]`, a bend's centre line in flat coordinates, matched one for one, either way round, and as many as the result has), positions within the box-diagonal tolerance. |
| `watertight` | `true`: each body's display mesh (chord tolerance `tolerance.mesh_mm`, default 0.01 mm) has no open and no over-shared edges, with vertices closer than `tolerance.weld_mm` (default 1e-4 mm) taken as one. |
| `timeout_s` | A longer timeout for this case than the run's (at most 1800 s), for cases that are slow by nature. A case that only needs it on a loaded machine shouldn't set it. |
| `tolerance` | Optional overrides: `rel`, `abs_mm`, `mesh_mm`, `weld_mm`. |
| `files` | The files the case wrote to `$OUT`, each `{path, json \| csv \| dxf}`, matched as a part of what is there: every key the case gives, an array item by item and as long, a whole number exactly, any other number within `rel`. `json`: the file's JSON; `csv`: its rows, as objects keyed by the header row; `dxf`: per layer of its ENTITIES section, how many of each entity (`{"CUT": {"CIRCLE": 1, "ELLIPSE": 0, "length_mm": 31.416}}`; a count may be a range `[min, max]`) and `length_mm`, the total length of its lines, arcs, circles, ellipses and polylines. |
| `results` | The commands' own answers, each `{step, pointer?, json, rel?, abs_mm?}`: the answer of the `step`th command (from 1, base commands included), or its part at the JSON `pointer` (RFC 6901), matched as `files` matches JSON: a whole number exactly (a count), another within `rel` (the case's relative tolerance unless given) or `abs_mm`, lists item by item. |
| `construction` | `{name: spec}`, a spec being `{point: [x,y,z]}`, `{axis: {through, dir}}` or `{plane: {through, normal}}`: each named construction point, axis or plane as the timeline evaluated it. A point within the position tolerance (`tolerance.abs_mm`, else 1e-3 of the box diagonal, of 1 mm where there is no body); an axis whose direction is parallel to `dir` (either way, sine of the angle at most 1e-6) and whose line passes within it of `through`; a plane likewise with `normal`. An axis or plane is graded as the line or plane it is, not by the origin it keeps. |
| `missing` | A capability SolidCraft has no command or parameter for yet (`"solid.thread has no start count"`): the case is reported **not supported yet** without running, so the gap stays visible. |
## The fillet gate
## The kernel rig gate
The fillet cases are the fillet regression suite: each is one small case of one issue, with its
exact answer. `.github/workflows/fillet-rig.yml` runs them on every pull request (not a draft)
that touches fillet code: `crates/kernel/src/{blend*,fillet*,*corner*,continuity*}.rs`,
`crates/smlib/**` (`SMLIB_REV` and `SMLIB_PREBUILT` included), `crates/doc/src/eval*.rs`,
`crates/engine/src/cmd/features.rs`, `tests/kernel-cases/fillets/**` and the rig's own code
(GitHub filters whole files, so any change to `eval*.rs` or `features.rs` runs it). One release
build of `solidcraft-cli`, then:
Every area is a regression suite: each case is one small case of one issue, with its exact
answer. `.github/workflows/kernel-rig.yml` runs them, and the ladder, on pull requests (not
drafts). A plan job (`scripts/ci/kernel_rig_plan.py`) picks the areas from the changed files, one
job builds `solidcraft-cli` (release, SMLib) and the rig's runner, and a matrix of shards, one per
selected area plus the ladder, runs them in parallel; the `kernel-rig` check passes when every
selected shard does (and when none was selected). Pushes to main and develop, merge groups, the
release gate (`release-gate.yml`) and a run by hand run every area. Each area's shard runs:
```sh
cargo xtask kernel-cases --area fillets --cli target/release/solidcraft-cli \
--known-failing tests/kernel-cases/fillets/KNOWN_FAILING
cargo xtask kernel-cases --area <area> --cli target/release/solidcraft-cli \
--known-failing tests/kernel-cases/<area>/KNOWN_FAILING
```
`fillets/KNOWN_FAILING` lists the cases that fail today, sorted, one a line with its cause
(`<case> <why it fails today>`; `#` starts a comment). The gate fails on a **regression**, a case
that fails (or crashes, hangs, or is not supported yet) and is not listed, and on a **fixed** case,
one listed that passes: a fix removes its line in the same pull request, so the list only shrinks.
A new case that fails today goes in with its line. With `--known-failing` the run writes no
report; `docs/kernel-cases.md` stays the full run's.
`<area>/KNOWN_FAILING` lists the cases of that area that fail today, sorted, one a line with its
cause (`<case> <why it fails today>`; `#` starts a comment; the header names the baseline: the
develop commit and SMLib revision it was taken from). The gate fails on a **regression**, a
case that fails (or crashes, hangs, or is not supported yet) and is not listed, and on a
**fixed** case, one listed that passes. With `--known-failing` the run writes no report;
`docs/kernel-cases.md` stays the full run's.
**Updating a list.** The pull request that changes an outcome changes the list in the same pull
request, so the list only shrinks and never goes stale:
- a fix (yours, or an SMLib pin bump): remove the line of each case the shard reports as
`FIXED`;
- a new case that fails today: add its line, sorted, with the cause from its result
(`results.json` in the shard's `kernel-rig-results-<area>` artifact, or a local run);
- a regression: fix it in the same pull request.
To check a list locally before pushing: `cargo xtask kernel-cases --area <area> --cli
target/release/solidcraft-cli --known-failing tests/kernel-cases/<area>/KNOWN_FAILING`.
### Which areas a pull request runs
- `<area>/PATHS`: the source files whose change reruns that area, one git pathspec glob a line
(`*` within a folder, `**` across folders; `#` starts a comment): the engine command modules,
doc evaluation and kernel files its commands go through. Only the area's own files: never a
file `PATHS-ALL` covers, nor a whole crate (the self-test fails on either).
- `PATHS-ALL`: the shared core, whose change reruns every area: SMLib (`crates/smlib/**`, its pin
included) and `scripts/fetch-smlib.sh`, `crates/geom/**`, the kernel's core (bodies, extrude and
revolve, booleans, the SMLib bridge, tessellation, what the grader measures), timeline
evaluation, the solid feature commands, the grader, the runner and the workflow.
- A change under `<area>/` (a case, its `KNOWN_FAILING`, its `PATHS`) reruns that area.
- The ladder spans every operation: it runs whenever any area does, and on a change under
`ladder/`.
The workflow's trigger paths are whole folders that hold every `PATHS` glob (a self-test,
`scripts/ci/test_kernel_rig_plan.py`, checks it), so a pull request that touches none of them
starts no job at all. To see what a change would run:
`git diff --name-only -z origin/develop... | python3 scripts/ci/kernel_rig_plan.py --paths -`.
**A new area** joins with its folder: its cases, a `KNOWN_FAILING` (empty but for its header
when every case passes), and a `PATHS` listing the files its commands go through. The plan finds
the areas from the folders, so the workflow needs no edit (unless a `PATHS` glob lies outside
the trigger paths, which the self-test reports). Add a row to the table under Layout.
### Every command has a case
`cargo xtask kernel-cases --coverage --cli target/release/solidcraft-cli` (run in the gate's
build job) lists every registry command (`solidcraft-cli commands`, planned ones aside) that no
`recipe.json` here runs, and fails unless `EXEMPT` lists it: one line a command, `<id> <why it
has no case>`, each section sorted. Lines before `[to cover]` have no geometry to grade (the
view, rendering, appearance, files, component and parameter bookkeeping, ...). Lines after it
make geometry and wait for a case: that section only shrinks. The check also fails on a listed
command that a case now uses (remove its line in the same pull request) or that the registry no
longer has. A new geometry command gets a case, not an `EXEMPT` line. The build job runs for this
check on any change to `crates/engine/src/cmd/`, a recipe or `EXEMPT`, even when no area does.
## The complexity ladder
`ladder/` orders kernel operations by complexity instead of by where they went wrong: tiers from
primitives through degenerate booleans, analytic and spline profiles, holes and taps, threads,
fillets, chamfers, shells, patterns, to whole parts. Later tiers build on earlier tiers' shapes (a
fillets, chamfers, shells, patterns, whole parts, and sheet metal. Later tiers build on earlier tiers' shapes (a
running part grows one tier at a time through `base`), so the last case carries everything.
- `ladder/<NN-tier>/<NNN-name>/`: cases in the format above, each a test with its own answer.
@@ -157,9 +222,17 @@ running part grows one tier at a time through `base`), so the last case carries
```sh
cargo xtask kernel-cases --ladder --cli target/release/solidcraft-cli
cargo xtask kernel-cases --ladder --cli target/release/solidcraft-cli --gate
cargo xtask kernel-cases --ladder --cli target/release/solidcraft-cli --record "why"
```
The ladder needs no known-failing list: the golden is the reference. Its shard in the kernel rig
gate runs with `--gate`, which fails on any case whose status or counts differ from the golden,
better or worse, and on a case with no golden; times are not compared there (they are the
machine's). A pull request that changes a ladder result re-records the golden with
`--record "why the golden changes"` and commits `golden.json` and
`ladder.json` with it.
Ladder runs measure one case at a time (unless `--jobs`) and keep their output in
`target/kernel-ladder` (`--out`); `--record` rewrites the golden and sorts each tier by time,
fastest first; commit both files. The report, `docs/kernel-ladder.md`, gives per tier the counts
@@ -0,0 +1,4 @@
# The assemblies cases that fail today, one a line: `<case> <why it fails today>`. Sorted. A gate
# fails on a case that fails and is not listed here, and on a listed case that passes: a fix
# removes its line in the same pull request.
# Baseline: rig-cases-assemblies 45f69c0e5 with SMLib 60b1c6a, aarch64 Linux. None fail today.
+28
View File
@@ -0,0 +1,28 @@
# Source files whose change must rerun the assemblies cases (one git pathspec glob a line).
# Joints, couplings, cams, reach and the solver.
crates/doc/src/joints*.rs
crates/doc/src/assembly.rs
crates/engine/src/cmd/joints.rs
crates/engine/src/cmd/joints_inspect.rs
# Motion studies, plots, traces, interference, sweeps, contact and exploded views.
crates/doc/src/motion.rs
crates/engine/src/cmd/motion.rs
crates/engine/src/cmd/motion_analysis.rs
crates/engine/src/cmd/motion_sweep.rs
crates/engine/src/cmd/motion_trace.rs
crates/engine/src/cmd/contact_sweep.rs
# Components and occurrences (their placement in the world is crates/doc/src/eval.rs: shared core).
crates/engine/src/cmd/component.rs
crates/engine/src/cmd/component_clone.rs
crates/engine/src/cmd/component_clone_assembly.rs
crates/engine/src/cmd/component_drag.rs
crates/engine/src/cmd/component_extract.rs
crates/engine/src/cmd/component_link.rs
crates/engine/src/cmd/component_properties.rs
crates/engine/src/cmd/component_reparent.rs
crates/engine/src/cmd/component_transfer.rs
# Interference and clearance between placed bodies.
crates/engine/src/cmd/clearance.rs
crates/engine/src/cmd/interference.rs
# The cases themselves.
tests/kernel-cases/assemblies/**
@@ -0,0 +1,13 @@
{
"sources": [],
"what": "the body of an arm turned 90 degrees copied to the root",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); hinge driven to 90 puts ArmBox at (0,20,5); its copy in the root stays there: centres (0,0,-5), (0,20,5), (0,20,5): mean (0,13.333,1.667)",
"body_count": 3,
"volume_mm3": 12000.0,
"center_of_mass": [
0,
13.333333,
1.666667
]
}
@@ -0,0 +1,127 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 90
}
},
{
"command": "component.copy_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "root"
}
}
]
}
@@ -0,0 +1,23 @@
{
"sources": [],
"what": "the arm's body copied into the base's component",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); a copy stays where its body is: Base then holds 4000 at (0,0,-5) and 4000 at (20,0,5): 8000, centre (10,0,0); the world has 3 bodies, 12000",
"body_count": 3,
"volume_mm3": 12000.0,
"results": [
{
"step": 9,
"json": {
"total": {
"center_of_mass": [
10.0,
0.0,
0.0
],
"volume_mm3": 8000.0
}
}
}
]
}
@@ -0,0 +1,90 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "component.copy_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Base"
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Base:1"
}
}
]
}
@@ -0,0 +1,8 @@
{
"sources": [],
"what": "component.extract of a component that is already linked",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5), Arm's box built inside Arm; after one extract Arm is linked; extracting it again is refused",
"outcome": "refused",
"refusal": "is linked to a design file already"
}
@@ -0,0 +1,86 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": true
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.activate",
"params": {
"component": "root"
}
},
{
"command": "component.extract",
"params": {
"component": "Arm",
"path": "$OUT/arm.solidcraft"
}
},
{
"command": "component.extract",
"params": {
"component": "Arm",
"path": "$OUT/arm2.solidcraft"
}
}
]
}
@@ -0,0 +1,8 @@
{
"sources": [],
"what": "component.extract of a component whose body was moved in from the root",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Arm's body came in by component.move_bodies, a feature outside it: its history can't move to a design of its own, so extract is refused",
"outcome": "refused",
"refusal": "moves bodies into or out of Arm"
}
@@ -0,0 +1,82 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "component.extract",
"params": {
"component": "Arm",
"path": "$OUT/arm.solidcraft"
}
}
]
}
@@ -0,0 +1,62 @@
{
"sources": [],
"what": "an arm built in its component extracted to a design file, then that file inserted again 50 mm along y",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5), Arm's box built inside Arm; extract keeps Arm where it is (now linked to the file: centre (20,0,5)); the file inserted with translate (0,50,0) holds the same 40x10x10 bar: centre (20,50,5)",
"body_count": 3,
"volume_mm3": 12000.0,
"results": [
{
"step": 8,
"json": {
"bodies": [
"ArmBox"
]
}
},
{
"step": 9,
"json": {
"total": {
"center_of_mass": [
20.0,
0.0,
5.0
],
"volume_mm3": 4000.0
}
}
},
{
"step": 10,
"json": {
"name": "Arm copy"
}
},
{
"step": 11,
"json": {
"total": {
"center_of_mass": [
20.0,
50.0,
5.0
],
"bbox": {
"min": [
0.0,
45.0,
0.0
],
"max": [
40.0,
55.0,
10.0
]
},
"volume_mm3": 4000.0
}
}
}
]
}
@@ -0,0 +1,103 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": true
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.activate",
"params": {
"component": "root"
}
},
{
"command": "component.extract",
"params": {
"component": "Arm",
"path": "$OUT/arm.solidcraft"
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
},
{
"command": "component.insert_design",
"params": {
"path": "$OUT/arm.solidcraft",
"name": "Arm copy",
"translate": [
0,
50,
0
]
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm copy:1"
}
}
]
}
@@ -0,0 +1,36 @@
{
"sources": [],
"what": "component.from_bodies on two root bodies",
"source": "analytic",
"method": "boxes P 10x10x10 from (0,0,0) and Q 20x10x10 from (30,0,0): one component each, named after its body, in place: P:1 (5,5,5), Q:1 (40,5,5)",
"body_count": 2,
"volume_mm3": 3000.0,
"results": [
{
"step": 4,
"json": {
"total": {
"center_of_mass": [
5.0,
5.0,
5.0
],
"volume_mm3": 1000.0
}
}
},
{
"step": 5,
"json": {
"total": {
"center_of_mass": [
40.0,
5.0,
5.0
],
"volume_mm3": 2000.0
}
}
}
]
}
@@ -0,0 +1,55 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 10,
"width": 10,
"height": 10,
"corner": [
0,
0,
0
],
"operation": "new",
"body_name": "P"
}
},
{
"command": "solid.box",
"params": {
"length": 20,
"width": 10,
"height": 10,
"corner": [
30,
0,
0
],
"operation": "new",
"body_name": "Q"
}
},
{
"command": "component.from_bodies",
"params": {
"bodies": [
"P",
"Q"
]
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "P:1"
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Q:1"
}
}
]
}
@@ -0,0 +1,8 @@
{
"sources": [],
"what": "component.from_bodies naming a body that is not there",
"source": "analytic",
"method": "a design with one body P: from_bodies of 'Nope' is refused, naming it",
"outcome": "refused",
"refusal": "Nope"
}
@@ -0,0 +1,22 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 10,
"width": 10,
"height": 10,
"operation": "new",
"body_name": "P"
}
},
{
"command": "component.from_bodies",
"params": {
"bodies": [
"Nope"
]
}
}
]
}
@@ -0,0 +1,57 @@
{
"sources": [],
"what": "a hand-written design (one 30x20x10 box) inserted 100 mm along x",
"source": "analytic",
"method": "plate.solidcraft in the case directory: a box 30x20x10 at the origin; inserted with translate (100,0,0): 6000 mm3, box (100,0,0)-(130,20,10), centre (115,10,5)",
"body_count": 1,
"volume_mm3": 6000.0,
"area_mm2": 2200.0,
"bbox": {
"min": [
100,
0,
0
],
"max": [
130,
20,
10
]
},
"results": [
{
"step": 1,
"json": {
"bodies": [
"Plate"
],
"name": "plate"
}
},
{
"step": 2,
"json": {
"total": {
"center_of_mass": [
115.0,
10.0,
5.0
],
"bbox": {
"min": [
100.0,
0.0,
0.0
],
"max": [
130.0,
20.0,
10.0
]
},
"volume_mm3": 6000.0
}
}
}
]
}
@@ -0,0 +1,11 @@
{
"format": "solidcraft/40",
"name": "plate",
"units": "mm",
"params": [],
"next_id": 2,
"features": [
{"id": 1, "name": "Box1", "type": "box", "suppressed": false, "operation": "new_body", "body_names": ["Plate"],
"corner": [0.0, 0.0, 0.0], "length": "30", "width": "20", "height": "10"}
]
}
@@ -0,0 +1,21 @@
{
"commands": [
{
"command": "component.insert_design",
"params": {
"path": "$CASE/plate.solidcraft",
"translate": [
100,
0,
0
]
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "plate:1"
}
}
]
}
@@ -0,0 +1,25 @@
{
"sources": [],
"what": "the hand-written design inserted twice, the second reusing the first's link",
"source": "analytic",
"method": "plate.solidcraft (box 30x20x10) at (0,0,0) and again with translate (0,50,0): 2 bodies, 12000 mm3, box (0,0,0)-(30,70,10)",
"body_count": 2,
"volume_mm3": 12000.0,
"bbox": {
"min": [
0,
0,
0
],
"max": [
30,
70,
10
]
},
"center_of_mass": [
15,
35,
5
]
}
@@ -0,0 +1,11 @@
{
"format": "solidcraft/40",
"name": "plate",
"units": "mm",
"params": [],
"next_id": 2,
"features": [
{"id": 1, "name": "Box1", "type": "box", "suppressed": false, "operation": "new_body", "body_names": ["Plate"],
"corner": [0.0, 0.0, 0.0], "length": "30", "width": "20", "height": "10"}
]
}
@@ -0,0 +1,22 @@
{
"commands": [
{
"command": "component.insert_design",
"params": {
"path": "$CASE/plate.solidcraft"
}
},
{
"command": "component.insert_design",
"params": {
"path": "$CASE/plate.solidcraft",
"reuse": true,
"translate": [
0,
50,
0
]
}
}
]
}
@@ -0,0 +1,23 @@
{
"sources": [],
"what": "a root body moved into a component placed 100 mm along x",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Holder (empty) moved by (100,0,0), then a box 10x10x10 from (0,20,0) moved into it: the body keeps its world place, centre (5,25,5)",
"body_count": 3,
"volume_mm3": 9000.0,
"results": [
{
"step": 12,
"json": {
"total": {
"center_of_mass": [
5.0,
25.0,
5.0
],
"volume_mm3": 1000.0
}
}
}
]
}
@@ -0,0 +1,124 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "component.create",
"params": {
"name": "Holder",
"parent": "root",
"activate": false
}
},
{
"command": "occurrence.move",
"params": {
"occurrence": "Holder:1",
"translate": [
100,
0,
0
]
}
},
{
"command": "solid.box",
"params": {
"length": 10,
"width": 10,
"height": 10,
"corner": [
0,
20,
0
],
"operation": "new",
"body_name": "Cube"
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"Cube"
],
"component": "Holder"
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Holder:1"
}
}
]
}
@@ -0,0 +1,72 @@
{
"sources": [],
"what": "two bodies moved from the root into a component each",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); moving bodies into components keeps them where they are: Arm (20,0,5), Base (0,0,-5), 4000 mm3 each",
"body_count": 2,
"volume_mm3": 8000.0,
"bbox": {
"min": [
-10,
-10,
-10
],
"max": [
40,
10,
10
]
},
"results": [
{
"step": 8,
"json": {
"total": {
"center_of_mass": [
20.0,
0.0,
5.0
],
"bbox": {
"min": [
0.0,
-5.0,
0.0
],
"max": [
40.0,
5.0,
10.0
]
},
"volume_mm3": 4000.0
}
}
},
{
"step": 9,
"json": {
"total": {
"center_of_mass": [
0.0,
0.0,
-5.0
],
"bbox": {
"min": [
-10.0,
-10.0,
-10.0
],
"max": [
10.0,
10.0,
0.0
]
},
"volume_mm3": 4000.0
}
}
}
]
}
@@ -0,0 +1,87 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Base:1"
}
}
]
}
@@ -0,0 +1,25 @@
{
"sources": [],
"what": "component.paste_new in place of an arm turned 90 degrees, 20 mm up",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); hinge at 90 puts Arm at (0,20,5), box x -5..5, y 0..40; in_place puts the copy where it is in the world, moved (0,0,20): centres (0,0,-5), (0,20,5), (0,20,25): mean (0,13.333,8.333)",
"body_count": 3,
"volume_mm3": 12000.0,
"center_of_mass": [
0,
13.333333,
8.333333
],
"bbox": {
"min": [
-10,
-10,
-10
],
"max": [
10,
40,
30
]
}
}
@@ -0,0 +1,131 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 90
}
},
{
"command": "component.paste_new",
"params": {
"component": "Arm",
"occurrence": "Arm:1",
"in_place": true,
"translate": [
0,
0,
20
]
}
}
]
}
@@ -0,0 +1,25 @@
{
"sources": [],
"what": "component.paste_new of the arm 30 mm along y",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); an independent copy of Arm moved by (0,30,0): centres (0,0,-5), (20,0,5), (20,30,5), 4000 each: total 12000, centre (13.333,10,1.667), box (-10,-10,-10)-(40,35,10)",
"body_count": 3,
"volume_mm3": 12000.0,
"center_of_mass": [
13.333333,
10,
1.666667
],
"bbox": {
"min": [
-10,
-10,
-10
],
"max": [
40,
35,
10
]
}
}
@@ -0,0 +1,86 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "component.paste_new",
"params": {
"component": "Arm",
"translate": [
0,
30,
0
]
}
}
]
}
@@ -0,0 +1,21 @@
{
"sources": [],
"what": "contact.check with the arm driven into the block (contact off for the drive)",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Stop: box 50x10x10 from (-10,30,0), grounded; the arm's corner (40,5) turned \u03b8 reaches y = 40 sin \u03b8 + 5 cos \u03b8, which is 30 at \u03b8 = asin(30/\u221a1625) - atan(5/40) = 40.9676; at 60 the corner reaches y = 40 sin60 + 5 cos60 = 37.14 > 30: the pair overlaps; with the set enabled again contact.check lists it",
"body_count": 3,
"volume_mm3": 13000.0,
"results": [
{
"step": 17,
"json": {
"collisions": [
{
"a": "Arm:1",
"b": "Stop:1"
}
]
}
}
]
}
@@ -0,0 +1,179 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 50,
"width": 10,
"height": 10,
"corner": [
-10,
30,
0
],
"operation": "new",
"body_name": "StopBox"
}
},
{
"command": "component.create",
"params": {
"name": "Stop",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"StopBox"
],
"component": "Stop"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Stop:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Arm",
"Stop"
],
"name": "Stop set"
}
},
{
"command": "contact.disable_all",
"params": {}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 60
}
},
{
"command": "contact.enable_sets",
"params": {}
},
{
"command": "contact.check",
"params": {}
}
]
}
@@ -0,0 +1,39 @@
{
"sources": [],
"what": "contact.check of two blocks touching face to face, then a drive in that set",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Arm stands on Base's top face (z = 0, a 10x10 patch): touching is not passing through, so contact.check lists nothing and a drive to 90 is not stopped",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 11,
"json": {
"collisions": []
}
},
{
"step": 12,
"json": {
"values": [
{
"value": 90.0
}
],
"stopped_by_contact": null
}
},
{
"step": 13,
"json": {
"total": {
"center_of_mass": [
0.0,
20.0,
5.0
]
}
}
}
]
}
@@ -0,0 +1,142 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Base",
"Arm"
],
"name": "Face set"
}
},
{
"command": "contact.enable_sets",
"params": {}
},
{
"command": "contact.check",
"params": {}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"value": 90,
"quiet": true
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,38 @@
{
"sources": [],
"what": "contact.disable_all after a set was enabled, and a 90 degree drive",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Stop: box 50x10x10 from (-10,30,0), grounded; the arm's corner (40,5) turned \u03b8 reaches y = 40 sin \u03b8 + 5 cos \u03b8, which is 30 at \u03b8 = asin(30/\u221a1625) - atan(5/40) = 40.9676; contact off: the drive reaches 90, Arm at (0,20,5) inside the block",
"body_count": 3,
"volume_mm3": 13000.0,
"results": [
{
"step": 16,
"json": {
"enabled": false
}
},
{
"step": 17,
"json": {
"values": [
{
"value": 90.0
}
]
}
},
{
"step": 18,
"json": {
"total": {
"center_of_mass": [
0.0,
20.0,
5.0
]
}
}
}
]
}
@@ -0,0 +1,185 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 50,
"width": 10,
"height": 10,
"corner": [
-10,
30,
0
],
"operation": "new",
"body_name": "StopBox"
}
},
{
"command": "component.create",
"params": {
"name": "Stop",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"StopBox"
],
"component": "Stop"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Stop:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Arm",
"Stop"
],
"name": "Stop set"
}
},
{
"command": "contact.enable_sets",
"params": {}
},
{
"command": "contact.disable_all",
"params": {}
},
{
"command": "contact.list",
"params": {}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 90
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,35 @@
{
"sources": [],
"what": "a contact set stops a 90 degree drive of the arm at the block",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Stop: box 50x10x10 from (-10,30,0), grounded; the arm's corner (40,5) turned \u03b8 reaches y = 40 sin \u03b8 + 5 cos \u03b8, which is 30 at \u03b8 = asin(30/\u221a1625) - atan(5/40) = 40.9676; the drive stops there, fraction \u03b8/90 = 0.45520",
"body_count": 3,
"volume_mm3": 13000.0,
"results": [
{
"step": 15,
"json": {
"values": [
{
"value": 40.966136
}
],
"stopped_by_contact": {
"fraction": 0.455179
}
}
},
{
"step": 16,
"json": {
"total": {
"center_of_mass": [
15.101944,
13.112257,
5.0
]
}
}
}
]
}
@@ -0,0 +1,177 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 50,
"width": 10,
"height": 10,
"corner": [
-10,
30,
0
],
"operation": "new",
"body_name": "StopBox"
}
},
{
"command": "component.create",
"params": {
"name": "Stop",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"StopBox"
],
"component": "Stop"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Stop:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Arm",
"Stop"
],
"name": "Stop set"
}
},
{
"command": "contact.enable_sets",
"params": {}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"value": 90,
"quiet": true
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,22 @@
{
"sources": [],
"what": "contact.edit renaming one set and deleting another",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Stop: box 50x10x10 from (-10,30,0), grounded; the arm's corner (40,5) turned \u03b8 reaches y = 40 sin \u03b8 + 5 cos \u03b8, which is 30 at \u03b8 = asin(30/\u221a1625) - atan(5/40) = 40.9676; two sets made (contact.create turns contact on), the first renamed 'Arm stop', the second deleted: one set left",
"body_count": 3,
"volume_mm3": 13000.0,
"results": [
{
"step": 16,
"json": {
"all": false,
"enabled": true,
"sets": [
{
"name": "Arm stop"
}
]
}
}
]
}
@@ -0,0 +1,152 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 50,
"width": 10,
"height": 10,
"corner": [
-10,
30,
0
],
"operation": "new",
"body_name": "StopBox"
}
},
{
"command": "component.create",
"params": {
"name": "Stop",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"StopBox"
],
"component": "Stop"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Stop:1",
"grounded": true
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Arm",
"Stop"
],
"name": "Stop set"
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Base",
"Arm"
],
"name": "Face set"
}
},
{
"command": "contact.edit",
"params": {
"set": "Stop set",
"name": "Arm stop"
}
},
{
"command": "contact.edit",
"params": {
"set": "Face set",
"delete": true
}
},
{
"command": "contact.list",
"params": {}
}
]
}
@@ -0,0 +1,32 @@
{
"sources": [],
"what": "a suppressed contact set and a 90 degree drive into the block",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Stop: box 50x10x10 from (-10,30,0), grounded; the arm's corner (40,5) turned \u03b8 reaches y = 40 sin \u03b8 + 5 cos \u03b8, which is 30 at \u03b8 = asin(30/\u221a1625) - atan(5/40) = 40.9676; with its only set suppressed nothing stops the drive: 90, Arm at (0,20,5)",
"body_count": 3,
"volume_mm3": 13000.0,
"results": [
{
"step": 16,
"json": {
"values": [
{
"value": 90.0
}
]
}
},
{
"step": 17,
"json": {
"total": {
"center_of_mass": [
0.0,
20.0,
5.0
]
}
}
}
]
}
@@ -0,0 +1,184 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 50,
"width": 10,
"height": 10,
"corner": [
-10,
30,
0
],
"operation": "new",
"body_name": "StopBox"
}
},
{
"command": "component.create",
"params": {
"name": "Stop",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"StopBox"
],
"component": "Stop"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Stop:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Arm",
"Stop"
],
"name": "Stop set"
}
},
{
"command": "contact.enable_sets",
"params": {}
},
{
"command": "contact.edit",
"params": {
"set": "Stop set",
"suppressed": true
}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 90
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,39 @@
{
"sources": [],
"what": "contact.enable_all and a 90 degree drive into the block",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Stop: box 50x10x10 from (-10,30,0), grounded; the arm's corner (40,5) turned \u03b8 reaches y = 40 sin \u03b8 + 5 cos \u03b8, which is 30 at \u03b8 = asin(30/\u221a1625) - atan(5/40) = 40.9676; every occurrence in one set: the block stops the arm at \u03b8 = 40.97 (Base, which Arm only touches, does not)",
"body_count": 3,
"volume_mm3": 13000.0,
"results": [
{
"step": 14,
"json": {
"all": true,
"enabled": true
}
},
{
"step": 15,
"json": {
"values": [
{
"value": 40.966136
}
]
}
},
{
"step": 16,
"json": {
"total": {
"center_of_mass": [
15.101944,
13.112257,
5.0
]
}
}
}
]
}
@@ -0,0 +1,171 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 50,
"width": 10,
"height": 10,
"corner": [
-10,
30,
0
],
"operation": "new",
"body_name": "StopBox"
}
},
{
"command": "component.create",
"params": {
"name": "Stop",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"StopBox"
],
"component": "Stop"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Stop:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "contact.enable_all",
"params": {}
},
{
"command": "contact.list",
"params": {}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 90
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,25 @@
{
"sources": [],
"what": "contact.list after two sets and contact.enable_sets",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Stop: box 50x10x10 from (-10,30,0), grounded; the arm's corner (40,5) turned \u03b8 reaches y = 40 sin \u03b8 + 5 cos \u03b8, which is 30 at \u03b8 = asin(30/\u221a1625) - atan(5/40) = 40.9676; both sets, in the order made, contact enabled for sets, not all",
"body_count": 3,
"volume_mm3": 13000.0,
"results": [
{
"step": 15,
"json": {
"all": false,
"enabled": true,
"sets": [
{
"name": "Stop set"
},
{
"name": "Face set"
}
]
}
}
]
}
@@ -0,0 +1,142 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 50,
"width": 10,
"height": 10,
"corner": [
-10,
30,
0
],
"operation": "new",
"body_name": "StopBox"
}
},
{
"command": "component.create",
"params": {
"name": "Stop",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"StopBox"
],
"component": "Stop"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Stop:1",
"grounded": true
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Arm",
"Stop"
],
"name": "Stop set"
}
},
{
"command": "contact.create",
"params": {
"occurrences": [
"Base",
"Arm"
],
"name": "Face set"
}
},
{
"command": "contact.enable_sets",
"params": {}
},
{
"command": "contact.list",
"params": {}
}
]
}
@@ -0,0 +1,43 @@
{
"sources": [],
"what": "an automatic exploded view of scale 2",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); each occurrence moves scale \u00d7 (its centre - the mean of the centres): centres (0,0,-5) and (20,0,5), mean (10,0,0): Base by (-20,0,-10), Arm by (20,0,10); shown, Arm at (40,0,15)",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 8,
"json": {
"moves": [
{
"translate": [
-20.0,
0.0,
-10.0
]
},
{
"translate": [
20.0,
0.0,
10.0
]
}
]
}
},
{
"step": 10,
"json": {
"total": {
"center_of_mass": [
40.0,
0.0,
15.0
]
}
}
}
]
}
@@ -0,0 +1,94 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "explode.create",
"params": {
"name": "Apart",
"scale": 2
}
},
{
"command": "explode.show",
"params": {
"view": "Apart"
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,36 @@
{
"sources": [],
"what": "an exploded view moving the arm 30 mm up, shown",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); explode.show places Arm by (0,0,30): centre (20,0,35)",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 8,
"json": {
"moves": [
{
"translate": [
0.0,
0.0,
30.0
]
}
]
}
},
{
"step": 10,
"json": {
"total": {
"center_of_mass": [
20.0,
0.0,
35.0
]
}
}
}
]
}
@@ -0,0 +1,103 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "explode.create",
"params": {
"name": "Up",
"moves": [
{
"occurrence": "Arm:1",
"translate": [
0,
0,
30
]
}
]
}
},
{
"command": "explode.show",
"params": {
"view": "Up"
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,21 @@
{
"sources": [],
"what": "inspect.clearance of the arm lifted 5 mm off the base",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Arm moved by (0,0,5): its bottom (z 5) is 5 mm above Base's top (z 0) over x 0..10: distance 5",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 9,
"json": {
"overlaps": [],
"near": [
{
"distance_mm": 5.0
}
]
}
}
]
}
@@ -0,0 +1,92 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "occurrence.move",
"params": {
"occurrence": "Arm:1",
"translate": [
0,
0,
5
]
}
},
{
"command": "inspect.clearance",
"params": {
"clearance": 10
}
}
]
}
@@ -0,0 +1,21 @@
{
"sources": [],
"what": "inspect.clearance between the arm turned 90 degrees and a grounded block",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); a block 10x10x10 from (20,0,0); hinge at 90 puts Arm at x -5..5, y 0..40: the gap to the block's face x = 20 is 15",
"body_count": 3,
"volume_mm3": 9000.0,
"results": [
{
"step": 14,
"json": {
"overlaps": [],
"near": [
{
"distance_mm": 15.0
}
]
}
}
]
}
@@ -0,0 +1,169 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "solid.box",
"params": {
"length": 10,
"width": 10,
"height": 10,
"corner": [
20,
0,
0
],
"operation": "new",
"body_name": "PostBox"
}
},
{
"command": "component.create",
"params": {
"name": "Post",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"PostBox"
],
"component": "Post"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Post:1",
"grounded": true
}
},
{
"command": "joint.create",
"params": {
"type": "revolute",
"name": "Hinge",
"flip": true,
"a": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"b": {
"occurrence": "Arm",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"quiet": true
}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 90
}
},
{
"command": "inspect.clearance",
"params": {
"bodies": [
"ArmBox"
],
"against": [
"PostBox"
],
"clearance": 20
}
}
]
}
@@ -0,0 +1,39 @@
{
"sources": [],
"what": "inspect.interference of the arm sunk 5 mm into the base",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Arm moved by (0,0,-5): it shares x 0..10, y -5..5, z -5..0 with Base: 500 mm3, area 2(100+50+50) = 400, centre (5,0,-2.5)",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 9,
"json": {
"count": 1,
"interferences": [
{
"volume_mm3": 500.0,
"area_mm2": 400.0,
"center": [
5.0,
0.0,
-2.5
],
"bbox": {
"min": [
0.0,
-5.0,
-5.0
],
"max": [
10.0,
5.0,
0.0
]
}
}
]
}
}
]
}
@@ -0,0 +1,90 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "occurrence.move",
"params": {
"occurrence": "Arm:1",
"translate": [
0,
0,
-5
]
}
},
{
"command": "inspect.interference",
"params": {}
}
]
}
@@ -0,0 +1,17 @@
{
"sources": [],
"what": "inspect.interference of the arm standing on the base face to face",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); they meet on a face only: no overlap volume",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 8,
"json": {
"count": 0,
"interferences": []
}
}
]
}
@@ -0,0 +1,79 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "inspect.interference",
"params": {}
}
]
}
@@ -0,0 +1,44 @@
{
"sources": [],
"what": "an as-built revolute on an arm lifted 20 mm, then driven 90 degrees",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); Arm moved by (0,0,20) first, then joint.as_built revolute about z through the origin: it stays at (20,0,25); a drive to 90 turns it to (0,20,25)",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 10,
"json": {
"total": {
"center_of_mass": [
20.0,
0.0,
25.0
]
}
}
},
{
"step": 11,
"json": {
"values": [
{
"value": 90.0
}
]
}
},
{
"step": 12,
"json": {
"total": {
"center_of_mass": [
0.0,
20.0,
25.0
]
}
}
}
]
}
@@ -0,0 +1,129 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "occurrence.move",
"params": {
"occurrence": "Arm:1",
"translate": [
0,
0,
20
]
}
},
{
"command": "joint.as_built",
"params": {
"type": "revolute",
"a": "Base",
"b": "Arm",
"at": {
"occurrence": "Base",
"point": [
0,
0,
0
],
"z": [
0,
0,
1
]
},
"name": "Hinge",
"quiet": true
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
},
{
"command": "joint.drive",
"params": {
"joint": "Hinge",
"quiet": true,
"value": 90
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,44 @@
{
"sources": [],
"what": "an as-built slider along +x with limits -5..5, driven to 20",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); joint.as_built keeps Arm at (20,0,5); 20 is clamped to 5: centre (25,0,5)",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 9,
"json": {
"total": {
"center_of_mass": [
20.0,
0.0,
5.0
]
}
}
},
{
"step": 10,
"json": {
"values": [
{
"value": 5.0
}
]
}
},
{
"step": 11,
"json": {
"total": {
"center_of_mass": [
25.0,
0.0,
5.0
]
}
}
}
]
}
@@ -0,0 +1,124 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"length": 20,
"width": 20,
"height": 10,
"corner": [
-10,
-10,
-10
],
"operation": "new",
"body_name": "BaseBox"
}
},
{
"command": "solid.box",
"params": {
"length": 40,
"width": 10,
"height": 10,
"corner": [
0,
-5,
0
],
"operation": "new",
"body_name": "ArmBox"
}
},
{
"command": "component.create",
"params": {
"name": "Base",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"BaseBox"
],
"component": "Base"
}
},
{
"command": "component.create",
"params": {
"name": "Arm",
"parent": "root",
"activate": false
}
},
{
"command": "component.move_bodies",
"params": {
"bodies": [
"ArmBox"
],
"component": "Arm"
}
},
{
"command": "occurrence.ground",
"params": {
"occurrence": "Base:1",
"grounded": true
}
},
{
"command": "joint.as_built",
"params": {
"type": "slider",
"a": "Base",
"b": "Arm",
"at": {
"occurrence": "Base",
"point": [
0,
0,
5
],
"z": [
1,
0,
0
]
},
"name": "Slide",
"limits": [
[
-5,
5
]
],
"quiet": true
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
},
{
"command": "joint.drive",
"params": {
"joint": "Slide",
"quiet": true,
"value": 20
}
},
{
"command": "occurrence.properties",
"params": {
"occurrence": "Arm:1"
}
}
]
}
@@ -0,0 +1,50 @@
{
"sources": [],
"what": "a ball joint driven to yaw 90 and pitch 90",
"source": "analytic",
"method": "Base: box 20x20x10 from (-10,-10,-10), grounded; Arm: box 40x10x10 from (0,-5,0), centre (20,0,5); ball with frame z = +z, x = +x: M = Rz(yaw)\u00b7Ry(pitch)\u00b7Rz(roll); Ry(90): (x,y,z) -> (z,y,-x), then Rz(90): (x,y) -> (-y,x): (20,0,5) -> (5,0,-20) -> (0,5,-20); box x -5..5, y 0..10, z -40..0",
"body_count": 2,
"volume_mm3": 8000.0,
"results": [
{
"step": 9,
"json": {
"values": [
{
"value": 90.0
},
{
"value": 90.0
},
{
"value": 0.0
}
]
}
},
{
"step": 10,
"json": {
"total": {
"center_of_mass": [
0.0,
5.0,
-20.0
],
"bbox": {
"min": [
-5.0,
0.0,
-40.0
],
"max": [
5.0,
10.0,
0.0
]
}
}
}
}
]
}
Loaded 100 of 828 files, more files were not shown because too many files have changed in this diff. Show more