Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43f6ee6a98 | |||
| 0690ee5875 | |||
| 1dd921fc52 | |||
| 1d387d3f21 | |||
| 51d237829a | |||
| df4f9d3529 | |||
| ef2f485e15 | |||
| a43cd99e55 | |||
| 8f26457487 | |||
| 07ef94e102 | |||
| 02f276e296 | |||
| 9602587b0d | |||
| f8a98eed33 | |||
| 7629421375 | |||
| d034633265 | |||
| fc51df3b01 | |||
| 8f4d7959df | |||
| 338fa197d3 | |||
| 727bb23c7e | |||
| 8d6c45f640 | |||
| 6d16fae4ed | |||
| ef92f35b16 | |||
| 232a902680 | |||
| cfc4908291 | |||
| 1432131e95 | |||
| 35bc04847a | |||
| 06def2231d | |||
| d39fd6c397 | |||
| 4faf63e48a | |||
| 91ecea8cfd | |||
| c8c0c28fc8 | |||
| f91db06904 | |||
| 9df9d1fbdc | |||
| 8068e8f4b8 | |||
| 863b0777da | |||
| 80889762ce | |||
| a3f293c987 | |||
| e27d17c421 | |||
| 52bc27aaf6 | |||
| c357b1565e | |||
| de9a2bc846 | |||
| 6b6bd26648 | |||
| 8239b914ba | |||
| e95946ac82 | |||
| 46ce12b7f0 | |||
| aba00427fa | |||
| cccf8c1ece | |||
| fb80454368 | |||
| f92e16fa25 | |||
| dcbedbd805 | |||
| 9bb216a357 | |||
| fd9b3fd9f2 | |||
| 6488a540c9 | |||
| 3e70ad9876 | |||
| 30842efb22 | |||
| 549aef17a5 | |||
| 4d738cd210 | |||
| 1cfe77bb85 | |||
| e3f99de8af | |||
| 40b1b70dec | |||
| 0862f1679a | |||
| 2cd54b6af9 | |||
| c9c063620a | |||
| 9060abc83e | |||
| bec762fb2b | |||
| 826fce68eb | |||
| 73f50d7bb4 | |||
| d1927aac25 | |||
| b224ad6dae | |||
| ca10e02573 | |||
| 5500681d6a | |||
| fabeaa329a |
@@ -1,6 +1,6 @@
|
||||
# While a new geometry kernel is evaluated, new issues and discussions about kernel work, and new
|
||||
# pull requests that change the kernel directories, are labelled `kernel-paused` for a maintainer to
|
||||
# answer (CONTRIBUTING.md, "Kernel work is paused"). The logic is in scripts/kernel-paused/ (tested
|
||||
# answer (CONTRIBUTING.md, "Kernel work goes to solidcore"). The logic is in scripts/kernel-paused/ (tested
|
||||
# in ci.yml).
|
||||
name: Kernel paused
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
SolidCraft is a clean-room, pure-Rust parametric 3D CAD app (sketch solver, feature timeline, B-rep kernel, an egui UI that agents drive). This file is a router: the hard rules, then the skill to read for your task. Humans: CONTRIBUTING.md.
|
||||
|
||||
## Start here
|
||||
Work: ROADMAP.md, "Where help is wanted most" in CONTRIBUTING.md, issues labelled `help wanted`, `good first issue`, `needs-triage`; architecture in `docs/architecture.md`. Act when the code, docs and rules settle a question; ask only when it changes what users see. Local `plan/` notes are optional.
|
||||
Work: ROADMAP.md, "Where help is wanted most" in CONTRIBUTING.md, issues labelled `help wanted`, `good first issue`, `needs-triage`; architecture in `docs/architecture.md`. Act when the code, docs and rules settle a question; ask only when it changes what users see.
|
||||
|
||||
## Hard rules (what enforces each)
|
||||
- Independent: never copy another product's code, icons, text or templates; never drive or take data from commercial CAD. `skills/solidcraft-ground-rules/SKILL.md`.
|
||||
@@ -11,7 +11,7 @@ Work: ROADMAP.md, "Where help is wanted most" in CONTRIBUTING.md, issues labelle
|
||||
- Every asset is original or openly licensed with a row in ATTRIBUTION.md; read `assets/AGENTS.md` before icon work: `cargo xtask assets`, `cargo xtask icons`.
|
||||
- Never crash: no unwrap/expect/panic/unsafe in non-test code (unsafe allowlist in crash-safety), errors are `Result`, input is hostile: clippy `-D warnings`, `hostile_params_never_panic`.
|
||||
- Model decisions (what an operation does, which bodies it touches, which face or edge a point or name means, depths, nearness) use exact geometry; a mesh is for display, export, previews and mesh bodies (`xtask/mesh-decisions.txt` only shrinks): `cargo xtask mesh-decisions`.
|
||||
- New kernel cases go to solidcore: `cargo xtask lists`.
|
||||
- Kernel ops and math go to solidcore; features call its API: `cargo xtask lists`.
|
||||
- Everything is a command and programmatic calls never open dialogs: `skills/solidcraft-commands/SKILL.md`.
|
||||
- Layering (geom, sketch/kernel/render, doc, io, engine, ui-egui, apps); only `crates/kernel` uses truck: `cargo xtask layers`.
|
||||
- One outer UI container, one camera path (`navigation::handle`), colours from theme tokens: `cargo xtask ui-containers`.
|
||||
@@ -31,7 +31,7 @@ Work: ROADMAP.md, "Where help is wanted most" in CONTRIBUTING.md, issues labelle
|
||||
## Working on X: read the skill first
|
||||
| Working on | Read |
|
||||
|---|---|
|
||||
| A PR, a claim, review, CI or evidence | `skills/solidcraft-contributing/SKILL.md` |
|
||||
| A feature, PR, claim, review, CI, evidence | `skills/solidcraft-contributing/SKILL.md` |
|
||||
| Licences, assets, clean-room, the name | `skills/solidcraft-ground-rules/SKILL.md` |
|
||||
| Non-test Rust, hostile input, a crash report | `skills/solidcraft-crash-safety/SKILL.md` |
|
||||
| A command, a crate boundary | `skills/solidcraft-commands/SKILL.md` |
|
||||
|
||||
@@ -317,7 +317,6 @@ Editable drawing code, native projects and shipped exports are collected under `
|
||||
| assets/icons/ui/design/svg/model/circle_ttt.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/model/coil.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/model/colored_components.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/model/colored_components_off.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/model/combine.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
|
||||
| assets/icons/ui/design/svg/model/component.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 |
|
||||
|
||||
@@ -787,6 +786,18 @@ Original SolidCraft drawings, Open for owner review; no runtime assignments.
|
||||
| assets/locales/pending/theme-blur-ui.json | SolidCraft contributors | Original blur controls, notices and translations | MIT OR Apache-2.0 |
|
||||
| crates/ui-egui/tests/fixtures/theme-blur.json | SolidCraft contributors | Original theme for blur option scenarios and manager review | MIT OR Apache-2.0 |
|
||||
| assets/locales/ka.json | David Machakhelidze (devius) | Original Georgian translation of SolidCraft's English catalog, written with Claude Code from the meaning of each English string; terminology and doubtful strings decided by a native Georgian speaker; no commercial CAD text used | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-mark.svg | SolidCraft contributors | static SolidCraft mark: the five faces and gradients of assets/icons/app/macos/source/SolidCraft.icon/Assets/03-solid-blue-cutout.svg (the final frame of assets/styles/web/loading-logo.svg), cropped to the mark's bounds; original artwork | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-mark-mono-black.svg | SolidCraft contributors | one-colour (black) version of assets/branding/logo/solidcraft-mark.svg, same paths; original artwork | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-mark-mono-white.svg | SolidCraft contributors | one-colour (white) version of assets/branding/logo/solidcraft-mark.svg, same paths; original artwork | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-mark-512.png | SolidCraft contributors | transparent 512 px render of assets/branding/logo/solidcraft-mark.svg (cairosvg); original artwork | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-mark-1024.png | SolidCraft contributors | transparent 1024 px render of assets/branding/logo/solidcraft-mark.svg (cairosvg); original artwork | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-mark-2048.png | SolidCraft contributors | transparent 2048 px render of assets/branding/logo/solidcraft-mark.svg (cairosvg); original artwork | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-wordmark.svg | SolidCraft contributors | the name SolidCraft set like the loading logo's wordmark (bold, +0.02 em tracking, #15499e) in IBM Plex Sans Bold from assets/fonts/ibm-plex-sans (SIL OFL 1.1, IBM Corp.), outlined to paths; no font file is embedded | MIT OR Apache-2.0 |
|
||||
| assets/branding/logo/solidcraft-lockup-horizontal.svg | SolidCraft contributors | assets/branding/logo/solidcraft-mark.svg beside assets/branding/logo/solidcraft-wordmark.svg, in the proportions of assets/branding/web/source/og.png; original artwork | MIT OR Apache-2.0 |
|
||||
| assets/styles/ui/themes/onyx.json | SolidCraft contributors | original Onyx stone-grey palette, option overlays and semantic icon-role mapping; existing SolidCraft artwork is unchanged | MIT OR Apache-2.0 |
|
||||
| docs/book/src/media/ui-tour/window.png | SolidCraft contributors | screenshot of SolidCraft 0.29.0 itself (`solidcraft --sample`, default dark theme, software renderer, 1280x800) with original numbered callouts (digits set in DejaVu Sans Bold), captured with examples/demo/doc_shots.py | MIT OR Apache-2.0 |
|
||||
| docs/book/src/media/ui-tour/navigate.mp4 | SolidCraft contributors | original screen recording of the actual SolidCraft 0.29.0 English desktop UI (`--sample`, default dark theme, software renderer) orbiting, panning and zooming, with the original drawn pointer of examples/demo/overlay.py and labels set in DejaVu Sans Bold, captured with examples/demo/doc_shots.py | MIT OR Apache-2.0 |
|
||||
| assets/locales/pending/sketch-tool-hints.json | carlymx | Original sketch tool hints and engine error translations | MIT OR Apache-2.0 |
|
||||
|
||||
## Code adapted from sibling projects
|
||||
|
||||
@@ -838,7 +849,7 @@ into THIRD-PARTY-LICENSES.txt when `main` regenerates it.
|
||||
## FreeCAD and Rhino import library
|
||||
|
||||
FreeCAD `.FCStd` and Rhino `.3dm` files are read with [cadmpeg](https://github.com/cadmpeg/cadmpeg)
|
||||
0.6.3 (Apache-2.0), linked as the crates `cadmpeg-core`, `cadmpeg-ir`, `cadmpeg-registry`,
|
||||
0.6.7 (Apache-2.0), linked as the crates `cadmpeg-core`, `cadmpeg-ir`, `cadmpeg-registry`,
|
||||
`cadmpeg-container`, `cadmpeg-codec-freecad`, `cadmpeg-codec-rhino` and `cadmpeg-codec-step`
|
||||
in native and browser builds (`crates/io/src/native_cad.rs`). Only those open-format codecs are built: no
|
||||
default features, so cadmpeg's codecs for commercial CAD formats and its ShapeManager/ACIS
|
||||
|
||||
@@ -17,15 +17,27 @@ Before choosing a task, check the [command inventory](docs/features.md) and
|
||||
|
||||
Questions, ideas or want to say what you're working on? Join the [Discord](https://discord.gg/FtU4NQNVDH).
|
||||
|
||||
## Kernel work is paused
|
||||
## Kernel work goes to solidcore
|
||||
|
||||
We're moving to a new geometry kernel. Until that's done, please don't open pull requests that
|
||||
change `crates/kernel/`, `crates/geom/` or `vendor/truck*`, or issues and discussions about kernel
|
||||
work: booleans, fillets, chamfers, shell, offsets, sweeps and lofts, threads and holes, STEP/IGES
|
||||
import and export, or tessellation. The pinned issue on the tracker explains it. New ones get the
|
||||
`kernel-paused` label (`.github/workflows/kernel-paused.yml`) and a maintainer answers them. Crashes
|
||||
and data loss are still taken as issues. Pull requests outside those directories carry on as normal,
|
||||
including the dialogs and tools for these features.
|
||||
Since 0.40, SolidCraft's geometry kernel is [solidcore](https://github.com/tangency-labs/solidcore),
|
||||
and the kernel operations still in this repository are migrating there. The split:
|
||||
|
||||
- **SolidCraft** is the application: commands, the timeline, sketches, the UI, file handling. A new
|
||||
feature calls the solidcore API and builds on the operations it offers.
|
||||
- **solidcore** holds the geometry: evaluators, intersections, booleans, blends, shells, sweeps,
|
||||
tessellation and the rest of the math. If a feature needs kernel functionality solidcore does not
|
||||
have yet, add it to solidcore first (its own issue and PR), then use it here.
|
||||
|
||||
So pull requests that add geometry math to SolidCraft (`crates/kernel/`, `crates/geom/`, or a new
|
||||
evaluator or solver anywhere else) are not taken; they get the `kernel-paused` label
|
||||
(`.github/workflows/kernel-paused.yml`) and a maintainer points them to solidcore. Crashes and data
|
||||
loss are still taken as issues here, and the dialogs and tools for kernel features carry on as
|
||||
normal.
|
||||
|
||||
Work started before 0.40 was written against the earlier kernel. It is still welcome: port it onto
|
||||
today's code, calling solidcore for the geometry, before it can land. Expect a substantial rework
|
||||
for anything that touched the kernel. Designs keep opening and rebuilding on the new kernel; where a
|
||||
result changes, the PR says so and why.
|
||||
|
||||
## Get it running (about 10 minutes on a fast machine)
|
||||
|
||||
@@ -329,8 +341,11 @@ and a fresh CI run:
|
||||
|
||||
1. Work is tracked in [GitHub issues](https://github.com/tangency-labs/solidcraft/issues), labelled
|
||||
by area (`area:kernel`, `area:sketch`, `area:doc`, `area:ui`, `area:infra`). For anything
|
||||
bigger than a bug fix that has no issue yet, open one first. **Claim the issue with a draft
|
||||
PR** before you start, so two people don't build the same thing:
|
||||
bigger than a bug fix that has no issue yet, discuss it on [Discord](https://discord.gg/FtU4NQNVDH)
|
||||
first, then open an issue. Before you start, search **all** issues and pull requests, open and
|
||||
closed, for similar work (`gh issue list -R tangency-labs/solidcraft --state all --search "<words>"`,
|
||||
and the same with `gh pr list`). **Claim the issue with a draft PR** before you start, so two
|
||||
people don't build the same thing:
|
||||
- Check nobody has it: `gh pr list -R tangency-labs/solidcraft --state open --search "#N"`.
|
||||
- Branch from the latest `main`, commit `git commit --allow-empty -m "claim: #N"`, push, and
|
||||
open a **draft** PR titled `<summary> (#N)`, e.g. `Fillet: variable radius along a chain (#123)`.
|
||||
@@ -443,7 +458,7 @@ correct them freely and it won't put them back.
|
||||
|
||||
## Where help is wanted most
|
||||
|
||||
**Kernel speed (slow fillets, booleans, STEP):** please don't rewrite the current kernel code for speed; it is being replaced by [solidcore](https://github.com/bherbruck/solidcore) ([progress](https://tangency-labs.github.io/solidcore/)). Report slow cases with a file under the `kernel-perf` label, and put kernel effort into solidcore instead. See [#1597](https://github.com/tangency-labs/solidcraft/issues/1597).
|
||||
**Kernel speed (slow fillets, booleans, STEP):** please don't rewrite the current kernel code for speed; the kernel is [solidcore](https://github.com/tangency-labs/solidcore) ([progress](https://tangency-labs.github.io/solidcore/)). Report slow cases with a file under the `kernel-perf` label, and put kernel effort into solidcore instead. See [#1597](https://github.com/tangency-labs/solidcraft/issues/1597).
|
||||
|
||||
See the [`help wanted`](https://github.com/tangency-labs/solidcraft/labels/help%20wanted) and
|
||||
[`good first issue`](https://github.com/tangency-labs/solidcraft/labels/good%20first%20issue) labels.
|
||||
@@ -472,6 +487,16 @@ the same area), first resolve the command registry and source conflicts, then ru
|
||||
The generator tests cover stable ordering and additions that leave existing lines
|
||||
unchanged. The initial switch to sorted rows is a one-time larger diff.
|
||||
|
||||
## Pictures in the user guide
|
||||
|
||||
The user guide's screenshots and short clips (`docs/book/src/media/`) are captured from the real
|
||||
app by `examples/demo/doc_shots.py`, one function per figure. Each run starts a fresh app with its
|
||||
own settings, so your preferences never show. When a change makes a figure out of date, run
|
||||
`python3 examples/demo/doc_shots.py <page or shot>` (it needs Xvfb, ffmpeg, Pillow and a release
|
||||
build) and commit the new file. A new figure is a new function there, an ATTRIBUTION row in
|
||||
`attribution/pending/`, and a `<video>` (clips) or image link on the page. Keep a still under
|
||||
about 250 KB and a clip under about 1 MB.
|
||||
|
||||
## Licence
|
||||
|
||||
By contributing you agree that your contribution is licensed as MIT OR Apache-2.0, like the rest
|
||||
|
||||
@@ -564,9 +564,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
||||
|
||||
[[package]]
|
||||
name = "cadmpeg-codec-freecad"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c4a8fa61748cbb3ce80838b00a8cebfe553460583941f5aba6e2b97c16b4d37"
|
||||
checksum = "6fe0ed1935ace2c203b87107a064818dec2bb2ec2f250c4ad121767f3da75d1b"
|
||||
dependencies = [
|
||||
"cadmpeg-container",
|
||||
"cadmpeg-core",
|
||||
@@ -580,9 +580,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cadmpeg-codec-rhino"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7af41440d4c1d69e88e612de02cc3c9bad79d03429531e640ac924fef53c6bf"
|
||||
checksum = "7dd2b76bd1d9301c949fbd731fd22cff9d37d10d1f481c754b557c2187bd0171"
|
||||
dependencies = [
|
||||
"cadmpeg-container",
|
||||
"cadmpeg-core",
|
||||
@@ -599,9 +599,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cadmpeg-codec-step"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35e1b6d17cf26b31f59f2edab8ef5c29d2a33216c581fd913f012ad4869bd559"
|
||||
checksum = "f3cbce33ed681a28b62d8b01ae64cca2b01f11f31b9a3e5e2455b9ffde915712"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"cadmpeg-container",
|
||||
@@ -616,9 +616,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cadmpeg-container"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ab7bcef48ac7480b4917820272d85cd2c9533e17904e15b0e4d22f19a6045bd"
|
||||
checksum = "03f0d1c22b875294c5fbf4a4738aec8f8c0a4ad035eb28ece404f1dec21f371a"
|
||||
dependencies = [
|
||||
"cadmpeg-core",
|
||||
"crc32fast",
|
||||
@@ -628,9 +628,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cadmpeg-core"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e86bb7a40521832504bb1f5953a1c706b2c52aad73bf6d84e1b35e5cb0beae3f"
|
||||
checksum = "795bdc6e2a10ecc0627138874c17e2948a3925cd22c6c6b0c2e4f6621d92f89c"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"memchr",
|
||||
@@ -643,9 +643,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cadmpeg-ir"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b570a1a8c579e407a9fd7bb10fa1900f8827f1d578b8fcb4ea2a056b5f323c72"
|
||||
checksum = "5592036516aaf2574b159a86a3d1ae872dc245261de86e4c0ce6773fed00a249"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"cadmpeg-core",
|
||||
@@ -658,9 +658,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cadmpeg-registry"
|
||||
version = "0.6.3"
|
||||
version = "0.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2be23469a9bca0b684f1811118fffb581ebd32ded08e6cc8b0716a41f8c1377"
|
||||
checksum = "fc163233d5f664337267192848505854de6aeed4843181adf87f58baddcee9a0"
|
||||
dependencies = [
|
||||
"cadmpeg-codec-freecad",
|
||||
"cadmpeg-codec-rhino",
|
||||
|
||||
@@ -81,9 +81,9 @@ gethostname = "1"
|
||||
# Pinned: its IR and codec APIs change between minor versions. Open formats only: no default
|
||||
# features, so cadmpeg's codecs for commercial formats (f3d, sldprt, inventor, catia, creo, nx)
|
||||
# and its ShapeManager/ACIS `sat` codec are not compiled in. `step` is the writer we restate through.
|
||||
cadmpeg-core = "=0.6.3"
|
||||
cadmpeg-ir = "=0.6.3"
|
||||
cadmpeg-registry = { version = "=0.6.3", default-features = false, features = ["fcstd", "rhino", "step"] }
|
||||
cadmpeg-core = "=0.6.7"
|
||||
cadmpeg-ir = "=0.6.7"
|
||||
cadmpeg-registry = { version = "=0.6.7", default-features = false, features = ["fcstd", "rhino", "step"] }
|
||||
|
||||
# fonts (sketch text outlines; MIT OR Apache-2.0, pure Rust)
|
||||
ttf-parser = { version = "0.25", default-features = false, features = ["std", "variable-fonts"] }
|
||||
|
||||
@@ -57,13 +57,13 @@ bytemuck_derive 1.12.1 (Zlib OR Apache-2.0 OR MIT)
|
||||
byteorder 1.5.0 (Unlicense OR MIT)
|
||||
byteorder-lite 0.1.0 (Unlicense OR MIT)
|
||||
bytes 1.12.1 (MIT)
|
||||
cadmpeg-codec-freecad 0.6.3 (Apache-2.0)
|
||||
cadmpeg-codec-rhino 0.6.3 (Apache-2.0)
|
||||
cadmpeg-codec-step 0.6.3 (Apache-2.0)
|
||||
cadmpeg-container 0.6.3 (Apache-2.0)
|
||||
cadmpeg-core 0.6.3 (Apache-2.0)
|
||||
cadmpeg-ir 0.6.3 (Apache-2.0)
|
||||
cadmpeg-registry 0.6.3 (Apache-2.0)
|
||||
cadmpeg-codec-freecad 0.6.7 (Apache-2.0)
|
||||
cadmpeg-codec-rhino 0.6.7 (Apache-2.0)
|
||||
cadmpeg-codec-step 0.6.7 (Apache-2.0)
|
||||
cadmpeg-container 0.6.7 (Apache-2.0)
|
||||
cadmpeg-core 0.6.7 (Apache-2.0)
|
||||
cadmpeg-ir 0.6.7 (Apache-2.0)
|
||||
cadmpeg-registry 0.6.7 (Apache-2.0)
|
||||
calloop 0.13.0 (MIT)
|
||||
calloop 0.14.5 (MIT)
|
||||
calloop-wayland-source 0.3.0 (MIT)
|
||||
@@ -15978,13 +15978,13 @@ accesskit_windows 0.32.1: MIT OR Apache-2.0 (https://github.com/AccessKit/access
|
||||
accesskit_winit 0.32.2: Apache-2.0 (https://github.com/AccessKit/accesskit)
|
||||
block2 0.5.1: MIT (https://github.com/madsmtm/objc2)
|
||||
block2 0.6.2: MIT (https://github.com/madsmtm/objc2)
|
||||
cadmpeg-codec-freecad 0.6.3: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-codec-rhino 0.6.3: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-codec-step 0.6.3: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-container 0.6.3: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-core 0.6.3: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-ir 0.6.3: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-registry 0.6.3: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-codec-freecad 0.6.7: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-codec-rhino 0.6.7: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-codec-step 0.6.7: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-container 0.6.7: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-core 0.6.7: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-ir 0.6.7: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
cadmpeg-registry 0.6.7: Apache-2.0 (https://github.com/cadmpeg/cadmpeg)
|
||||
clipboard-win 5.4.1: BSL-1.0 (https://github.com/DoumanAsh/clipboard-win)
|
||||
dispatch 0.2.0: MIT (http://github.com/SSheldon/rust-dispatch)
|
||||
dispatch2 0.3.1: Zlib OR Apache-2.0 OR MIT (https://github.com/madsmtm/objc2)
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
//! Runs the same [`solidcraft_ui_egui::SolveApp`] as the desktop app through eframe's web runner
|
||||
//! (wgpu: WebGPU where available, WebGL2 otherwise). Build with `trunk build --release` from this
|
||||
//! directory (output in `dist/web`). URL flags: `?webgl` forces WebGL2 (remembered until
|
||||
//! `?webgpu`), `?sample` opens the sample part.
|
||||
//! `?webgpu`), `?sample` opens the sample part, `?embed=editor` runs it as an editing embed in a
|
||||
//! host page (no application bar or start page; nothing kept in the browser; #8517).
|
||||
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
@@ -42,6 +43,8 @@ fn query_flag(query: &str, name: &str) -> bool {
|
||||
struct Launch {
|
||||
open: Option<String>,
|
||||
embed: bool,
|
||||
/// `?embed=editor` (#8517): an editing embed in a host page that keeps the files itself.
|
||||
editor: bool,
|
||||
}
|
||||
|
||||
#[cfg(any(target_arch = "wasm32", test))]
|
||||
@@ -52,16 +55,19 @@ impl Launch {
|
||||
for (key, value) in url::form_urlencoded::parse(query.trim_start_matches('?').as_bytes()) {
|
||||
match key.as_ref() {
|
||||
"open" if launch.open.is_none() => launch.open = Some(value.into_owned()),
|
||||
"embed" if value == "editor" => launch.editor = true,
|
||||
"embed" => embed = true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
launch.embed = embed && launch.open.is_some();
|
||||
launch.embed = embed && launch.open.is_some() && !launch.editor;
|
||||
launch
|
||||
}
|
||||
|
||||
/// The browser's own storage (designs, autosave, recovery, preferences) is used: not when
|
||||
/// embedded, where the host keeps what is kept.
|
||||
fn persists(&self) -> bool {
|
||||
!self.embed
|
||||
!self.embed && !self.editor
|
||||
}
|
||||
|
||||
fn full_app_url(&self, mut url: url::Url) -> String {
|
||||
@@ -928,7 +934,7 @@ mod web {
|
||||
}
|
||||
let (panel, opener, saver, shown) = (files.clone(), files.clone(), files.clone(), files.clone());
|
||||
let (restorable, restorer) = (files.clone(), files.clone());
|
||||
let services = if launch.embed { Services::default() } else { Services {
|
||||
let services = if !launch.persists() { Services::default() } else { Services {
|
||||
// Open shows the browser's open dialog for a design where it has one
|
||||
// (the file keeps its handle, so Save writes back to it), else the
|
||||
// browser's files window. A command that reads another kind of file
|
||||
@@ -972,6 +978,7 @@ mod web {
|
||||
let (sender, receiver) = std::sync::mpsc::channel();
|
||||
let mut app = SolveApp::new(Session::default(), services).with_control(receiver);
|
||||
app.embedded = launch.embed;
|
||||
app.embed_editor = launch.editor;
|
||||
// Listening before reading: settings another tab writes from now on are
|
||||
// newer than those read here.
|
||||
let other_tab_prefs = PrefsInbox::default();
|
||||
@@ -1082,6 +1089,17 @@ mod tests {
|
||||
assert!(full.fragment().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn embed_editor_needs_no_design_link_and_keeps_nothing_in_the_browser() {
|
||||
let editor = Launch::parse("?embed=editor");
|
||||
assert!(editor.editor && !editor.embed && !editor.persists());
|
||||
let linked = Launch::parse("?embed=editor&open=https://example.org/a.sc");
|
||||
assert!(linked.editor && !linked.embed, "an editing embed may open a linked design, still editable");
|
||||
let viewer = Launch::parse("?embed=viewer&open=https://example.org/a.sc");
|
||||
assert!(viewer.embed && !viewer.editor, "any other value is the viewer embed, as before");
|
||||
assert!(!Launch::parse("?other=editor").editor);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn design_links_refuse_hostile_schemes_credentials_and_sizes() {
|
||||
assert!(design_url("https://example.org/arm.solidcraft?download=1", "http://solidcraft.io").is_ok());
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//! Is the file chooser that opens the desktop's own? (#10159)
|
||||
//!
|
||||
//! `rfd` opens the file chooser through the XDG desktop portal; without the portal it falls
|
||||
//! back to zenity, a window that does not belong to the app and that the app never mentions.
|
||||
//! The desktop's own chooser is the portal one, so the app has to know when it is not the one
|
||||
//! that opens, and say so in the session log.
|
||||
//!
|
||||
//! The session bus is asked once, on a thread of its own: a bus that answers late must not
|
||||
//! hold the window. What it answered is kept, and read when a file is opened.
|
||||
|
||||
use std::sync::atomic::{AtomicBool, AtomicU8, Ordering};
|
||||
|
||||
/// The portal's bus name: the desktop's own file chooser lives behind it.
|
||||
const PORTAL: &str = "org.freedesktop.portal.Desktop";
|
||||
|
||||
/// The bus has not answered yet.
|
||||
const UNKNOWN: u8 = 0;
|
||||
/// There is no session bus to reach the portal on.
|
||||
const NO_SESSION_BUS: u8 = 1;
|
||||
/// The bus is there but the portal does not answer on it.
|
||||
const NO_PORTAL_SERVICE: u8 = 2;
|
||||
/// The bus is there and the portal answers on it.
|
||||
const PORTAL_THERE: u8 = 3;
|
||||
|
||||
/// What the session bus said about the portal.
|
||||
static BUS: AtomicU8 = AtomicU8::new(UNKNOWN);
|
||||
/// A file chooser is opening: whether it is the desktop's own is to be said.
|
||||
static OPENING: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// Ask the session bus, on a thread of its own, whether the portal is there.
|
||||
pub fn start(ctx: &egui::Context) {
|
||||
let thread_ctx = ctx.clone();
|
||||
let probe = move || {
|
||||
let answer = match session_bus() {
|
||||
None => NO_SESSION_BUS,
|
||||
Some(connection) => match portal_on(&connection) {
|
||||
true => PORTAL_THERE,
|
||||
false => NO_PORTAL_SERVICE,
|
||||
},
|
||||
};
|
||||
BUS.store(answer, Ordering::Relaxed);
|
||||
// The answer is in: a file chooser waiting for it can be told now.
|
||||
thread_ctx.request_repaint();
|
||||
};
|
||||
if let Err(e) = std::thread::Builder::new().name("desktop-chooser".into()).spawn(probe) {
|
||||
log::warn!("file chooser: no thread to ask the session bus: {e}");
|
||||
// Nothing will answer: the desktop's own chooser cannot be told apart from the start.
|
||||
BUS.store(PORTAL_THERE, Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
/// The session bus, when there is one to talk to.
|
||||
fn session_bus() -> Option<zbus::blocking::Connection> {
|
||||
zbus::blocking::Connection::session().ok()
|
||||
}
|
||||
|
||||
/// Whether the portal answers on the bus: it is either running on it or waiting to be started.
|
||||
fn portal_on(connection: &zbus::blocking::Connection) -> bool {
|
||||
let Ok(bus) = zbus::blocking::fdo::DBusProxy::new(connection) else { return false };
|
||||
let named = |names: Vec<zbus::names::OwnedBusName>| names.iter().any(|name| name.as_str() == PORTAL);
|
||||
// A portal that is running is on the bus; one that is not running yet is still there when
|
||||
// the bus can start it, which is what the portal's service file is for.
|
||||
match (bus.list_names().map(named), bus.list_activatable_names().map(named)) {
|
||||
(Ok(running), Ok(startable)) => running || startable,
|
||||
(Ok(running), Err(_)) => running,
|
||||
(Err(_), Ok(startable)) => startable,
|
||||
// The bus does not answer: nothing answers on it.
|
||||
(Err(_), Err(_)) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// A file chooser is opening: ask for a frame, so that the reason it is not the desktop's own
|
||||
/// is said (#10159).
|
||||
pub fn note_opening(ctx: &egui::Context) {
|
||||
OPENING.store(true, Ordering::Relaxed);
|
||||
ctx.request_repaint();
|
||||
}
|
||||
|
||||
/// The reason the file chooser that is opening is not the desktop's own, if it is not.
|
||||
///
|
||||
/// The decision is the one the test states: without a session bus there is no bus to reach the
|
||||
/// portal on; with a bus but no portal on it, `rfd` falls back to zenity; and under XWayland the
|
||||
/// window is an X11 one while the session is a Wayland one, which the portal refuses to parent
|
||||
/// its chooser to.
|
||||
pub fn take_reason() -> Option<&'static str> {
|
||||
if !OPENING.load(Ordering::Relaxed) {
|
||||
return None;
|
||||
}
|
||||
let (dbus_session, portal_service) = match BUS.load(Ordering::Relaxed) {
|
||||
NO_SESSION_BUS => (false, false),
|
||||
NO_PORTAL_SERVICE => (true, false),
|
||||
PORTAL_THERE => (true, true),
|
||||
// The bus has not answered yet: wait for it, and say nothing yet.
|
||||
_ => return None,
|
||||
};
|
||||
OPENING.store(false, Ordering::Relaxed);
|
||||
let wayland_display = std::env::var_os("WAYLAND_DISPLAY").is_some();
|
||||
let x11_display = super::window_system_now() == Some("x11");
|
||||
super::desktop_chooser_fallback(dbus_session, portal_service, wayland_display, x11_display)
|
||||
}
|
||||
@@ -23,6 +23,8 @@ mod app_icon;
|
||||
mod come_forward;
|
||||
mod control_server;
|
||||
#[cfg(target_os = "linux")]
|
||||
mod desktop_chooser;
|
||||
#[cfg(target_os = "linux")]
|
||||
mod desktop_theme;
|
||||
#[cfg(any(target_os = "windows", target_os = "macos"))]
|
||||
mod desktop_transparency;
|
||||
@@ -242,6 +244,12 @@ impl eframe::App for App {
|
||||
menu.tick(&mut self.solve, ctx);
|
||||
}
|
||||
self.solve.logic(ctx);
|
||||
// The file chooser that opened is not the desktop's own: the user has to be told (#10159).
|
||||
#[cfg(target_os = "linux")]
|
||||
if let Some(reason) = desktop_chooser::take_reason() {
|
||||
let text = self.solve.tr(reason).to_string();
|
||||
self.solve.set_status(text, false);
|
||||
}
|
||||
self.dialog_folder.design(self.solve.session.path.as_deref());
|
||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||
if !self.solve.file_picker_busy() {
|
||||
@@ -471,12 +479,19 @@ fn fullscreen_content_insets(raw: &mut egui::RawInput, title_height: f32, zoom:
|
||||
|
||||
fn services(cc: &eframe::CreationContext<'_>, folder: &DialogFolder) -> Services {
|
||||
let parent = rfd::AsyncFileDialog::new().set_parent(cc);
|
||||
// The file chooser that opens may not be the desktop's own: the user is told when it does
|
||||
// not (#10159).
|
||||
#[cfg(target_os = "linux")]
|
||||
let chooser_ctx = cc.egui_ctx.clone();
|
||||
let open_parent = parent.clone();
|
||||
let program_parent = parent.clone();
|
||||
let file_parent = parent.clone();
|
||||
let (open_folder, file_folder, save_folder) = (folder.clone(), folder.clone(), folder.clone());
|
||||
Services {
|
||||
pick_open: Some(Box::new(move |first: &[&str]| {
|
||||
// The chooser that opens may not be the desktop's own (#10159).
|
||||
#[cfg(target_os = "linux")]
|
||||
desktop_chooser::note_opening(&chooser_ctx);
|
||||
// The file type the command reads comes first, so the picker opens on it (#1801).
|
||||
let mut dialog = open_folder.start(open_parent.clone());
|
||||
if !first.is_empty() {
|
||||
@@ -785,6 +800,28 @@ fn graphics() -> Option<serde_json::Value> {
|
||||
graphics_path().and_then(|p| std::fs::read_to_string(p).ok()).and_then(|s| serde_json::from_str::<serde_json::Value>(&s).ok())
|
||||
}
|
||||
|
||||
fn restore_preferences(app: &mut SolveApp, stored_ui: Option<&str>, saved_graphics: Option<&serde_json::Value>, safe_mode: bool) {
|
||||
if let Some(p) = stored_ui.filter(|_| !safe_mode) {
|
||||
app.load_prefs(p);
|
||||
}
|
||||
// Even safe mode edits the real graphics.json. Keep its choices in Preferences so an
|
||||
// anti-aliasing change cannot erase them; safe mode's renderer still uses its own defaults.
|
||||
restore_graphics_preferences(app, saved_graphics);
|
||||
}
|
||||
|
||||
/// Restore startup choices after loading the separately saved UI preferences.
|
||||
fn restore_graphics_preferences(app: &mut SolveApp, saved: Option<&serde_json::Value>) {
|
||||
app.preferences.graphics_adapter = saved.and_then(|v| v.get("adapter").and_then(serde_json::Value::as_str)).unwrap_or_default().to_string();
|
||||
// graphics.json chooses the window before app.ron is loaded. Reflect that saved choice,
|
||||
// not the current session's window system (which an environment override may change).
|
||||
app.preferences.window_system = saved
|
||||
.and_then(|v| v.get("window_system").and_then(serde_json::Value::as_str))
|
||||
.map(str::trim)
|
||||
.filter(|choice| matches!(*choice, "wayland" | "x11"))
|
||||
.unwrap_or("auto")
|
||||
.to_string();
|
||||
}
|
||||
|
||||
/// The graphics backend preference (`graphics.json`'s `backend`: `auto`, `dx12`, `vulkan`, `gl`).
|
||||
fn backend_preference() -> Option<String> {
|
||||
graphics().and_then(|v| v.get("backend").and_then(serde_json::Value::as_str).map(str::to_string))
|
||||
@@ -1003,6 +1040,8 @@ fn main() -> eframe::Result {
|
||||
solidcraft_engine::crash::install(dir, build)
|
||||
})
|
||||
.unwrap_or_default();
|
||||
// The recovery folder also holds the reopen guard marker (#5064); read once, reused below.
|
||||
let recovery_dir = solidcraft_engine::recovery::default_dir();
|
||||
// A crash in native code (a graphics driver) says where it happened: the exception or signal
|
||||
// and the module on Windows and macOS, and on every system the startup step the app was in.
|
||||
#[cfg(target_os = "windows")]
|
||||
@@ -1085,6 +1124,10 @@ fn main() -> eframe::Result {
|
||||
solidcraft_ui_egui::fonts::load_system_fonts_in_background(&cc.egui_ctx);
|
||||
mark("fonts");
|
||||
let dialog_folder = DialogFolder::default();
|
||||
// The file chooser that opens may not be the desktop's own: the session bus is asked
|
||||
// now, so the answer is there when a file is opened (#10159).
|
||||
#[cfg(target_os = "linux")]
|
||||
desktop_chooser::start(&cc.egui_ctx);
|
||||
let mut app = SolveApp::new(Session::default(), services(cc, &dialog_folder));
|
||||
app.apply_off_thread = Some(solidcraft_ui_egui::dialogs::APPLY_AT_ONCE);
|
||||
app.custom_titlebar = custom_titlebar;
|
||||
@@ -1105,9 +1148,8 @@ fn main() -> eframe::Result {
|
||||
app.integrated_titlebar = cfg!(target_os = "macos");
|
||||
app.cpu_meshing = safe_mode;
|
||||
app.graphics_fallback = fallback_note.clone();
|
||||
if let Some(p) = cc.storage.and_then(|s| solidcraft_ui_egui::prefs::stored(|k| s.get_string(k))).filter(|_| !safe_mode) {
|
||||
app.load_prefs(&p);
|
||||
}
|
||||
let stored_ui = cc.storage.and_then(|s| solidcraft_ui_egui::prefs::stored(|k| s.get_string(k)));
|
||||
restore_preferences(&mut app, stored_ui.as_deref(), graphics().as_ref(), safe_mode);
|
||||
if let Some(path) = &theme_file
|
||||
&& let Err(e) = solidcraft_ui_egui::prefs::follow_theme_file_for_run(&mut app, path)
|
||||
{
|
||||
@@ -1120,10 +1162,6 @@ fn main() -> eframe::Result {
|
||||
lost_at: None,
|
||||
reason: String::new(),
|
||||
});
|
||||
if !safe_mode {
|
||||
app.preferences.graphics_adapter =
|
||||
graphics().and_then(|v| v.get("adapter").and_then(serde_json::Value::as_str).map(str::to_string)).unwrap_or_default();
|
||||
}
|
||||
if let Some(rs) = &cc.wgpu_render_state {
|
||||
app.services.graphics_adapters = rs
|
||||
.available_adapters
|
||||
@@ -1196,8 +1234,25 @@ fn main() -> eframe::Result {
|
||||
};
|
||||
// No design given: the designs open at the last quit, when the preference asks (#5542).
|
||||
// Not when driven over the control channel, whose clients expect a fresh design.
|
||||
let files =
|
||||
if files.is_empty() && !sample && control_port.is_none() { solidcraft_ui_egui::documents::designs_to_reopen(&app) } else { files };
|
||||
// A design that stopped the last session while it was being reopened is skipped this
|
||||
// time, so one bad file cannot brick every launch (#5064).
|
||||
app.reopen_guard_dir = recovery_dir.clone();
|
||||
let files = if files.is_empty() && !sample && control_port.is_none() {
|
||||
let (reopen, skipped) = solidcraft_ui_egui::documents::reopen_plan(&app, recovery_dir.as_deref());
|
||||
if !skipped.is_empty() {
|
||||
let names: Vec<String> = skipped
|
||||
.iter()
|
||||
.map(|p| std::path::Path::new(p).file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_else(|| p.clone()))
|
||||
.collect();
|
||||
notes.push(format!(
|
||||
"The last session stopped while reopening {}. It was not reopened this time; open it yourself if you need it.",
|
||||
names.join(", ")
|
||||
));
|
||||
}
|
||||
reopen
|
||||
} else {
|
||||
files
|
||||
};
|
||||
for f in &files {
|
||||
app.open_path_async(f);
|
||||
}
|
||||
@@ -1213,9 +1268,9 @@ fn main() -> eframe::Result {
|
||||
app.home.show(rev);
|
||||
}
|
||||
// Autosave, and offer what crashed sessions left behind.
|
||||
if let Some(dir) = solidcraft_engine::recovery::default_dir() {
|
||||
if let Some(dir) = recovery_dir.as_ref() {
|
||||
let every = if app.autosave_minutes > 0.0 { app.autosave_minutes * 60.0 } else { f64::MAX / 4.0 };
|
||||
solidcraft_ui_egui::recovery_ui::start(&mut app, &dir, std::time::Duration::from_secs_f64(every.min(1e9)));
|
||||
solidcraft_ui_egui::recovery_ui::start(&mut app, dir, std::time::Duration::from_secs_f64(every.min(1e9)));
|
||||
// Safe mode keeps autosaving but offers nothing: the entries wait for a normal start.
|
||||
if safe_mode {
|
||||
app.recoverable.clear();
|
||||
@@ -1403,6 +1458,47 @@ fn prefer_x11(display: bool, wayland_display: bool, desktop: Option<&str>, wayla
|
||||
display && !(niri && wayland_display)
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
const CHOOSER_NO_SESSION_BUS: &str = "file.open.portal_fallback.no_session_bus";
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
const CHOOSER_NO_PORTAL_SERVICE: &str = "file.open.portal_fallback.no_portal_service";
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
const CHOOSER_XWAYLAND: &str = "file.open.portal_fallback.xwayland";
|
||||
|
||||
/// Whether the chooser that opens is NOT the desktop's own, and why.
|
||||
///
|
||||
/// `rfd` opens the file chooser through the XDG desktop portal; when the portal is not there it
|
||||
/// falls back to zenity, which opens a window that does not belong to SolidCraft and that the
|
||||
/// application never mentions. The application has to know that: this decision is what the warning
|
||||
/// is built on.
|
||||
///
|
||||
/// * `dbus_session`: the session bus is there (`DBUS_SESSION_BUS_ADDRESS`).
|
||||
/// * `portal_service`: the file chooser portal answers on it.
|
||||
/// * `wayland_display`: a Wayland session runs (`WAYLAND_DISPLAY`).
|
||||
/// * `x11_display`: the window is an X11 one (`DISPLAY`, or XWayland).
|
||||
///
|
||||
/// `None` means the desktop's own chooser is the one that opens and there is nothing to say;
|
||||
/// `Some` carries the reason to report.
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
|
||||
fn desktop_chooser_fallback(dbus_session: bool, portal_service: bool, wayland_display: bool, x11_display: bool) -> Option<&'static str> {
|
||||
// Without a session bus there is no bus to reach the portal on, so the chooser is not the
|
||||
// desktop's own whatever else is there.
|
||||
if !dbus_session {
|
||||
return Some(CHOOSER_NO_SESSION_BUS);
|
||||
}
|
||||
// The bus is there but the portal does not answer on it: `rfd` falls back to zenity.
|
||||
if !portal_service {
|
||||
return Some(CHOOSER_NO_PORTAL_SERVICE);
|
||||
}
|
||||
// Under XWayland the window is an X11 one while the session is a Wayland one, and the portal
|
||||
// refuses to parent its chooser to an X11 window: `rfd` falls back to zenity.
|
||||
if wayland_display && x11_display {
|
||||
return Some(CHOOSER_XWAYLAND);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(all(test, unix, not(target_os = "macos")))]
|
||||
mod backend_tests {
|
||||
use super::prefer_x11;
|
||||
@@ -1438,6 +1534,30 @@ mod backend_tests {
|
||||
assert!(prefer_x11(true, true, Some("niri"), over(Some("x11"))));
|
||||
}
|
||||
|
||||
/// The file chooser must say when it is NOT the desktop's own: `rfd` falls back to zenity
|
||||
/// when the XDG portal is not there, and the user gets a foreign window with no explanation.
|
||||
#[test]
|
||||
fn the_file_picker_says_when_it_is_not_the_desktops_own_chooser() {
|
||||
use super::desktop_chooser_fallback;
|
||||
// The normal case: the portal is there, the desktop's own chooser opens, nothing to say.
|
||||
assert_eq!(desktop_chooser_fallback(true, true, true, false), None);
|
||||
// No session bus: the portal can not be reached at all, so `rfd` falls back to zenity.
|
||||
assert!(
|
||||
desktop_chooser_fallback(false, true, true, false).is_some(),
|
||||
"without a D-Bus session bus the file chooser is not the desktop's own: the user has to be told"
|
||||
);
|
||||
// The bus is there but the portal service is not: same fallback, same warning.
|
||||
assert!(
|
||||
desktop_chooser_fallback(true, false, true, false).is_some(),
|
||||
"without the desktop portal service the file chooser is not the desktop's own: the user has to be told"
|
||||
);
|
||||
// XWayland: the parent window is an X11 one and the portal refuses it, so `rfd` falls back.
|
||||
assert!(
|
||||
desktop_chooser_fallback(true, true, true, true).is_some(),
|
||||
"under XWayland the portal rejects the parent window: the user has to be told"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_desktops_title_bar_only_when_asked_for() {
|
||||
use super::titlebar_choice;
|
||||
@@ -1715,6 +1835,88 @@ mod viewport_tests {
|
||||
|
||||
#[cfg(test)]
|
||||
mod msaa_tests {
|
||||
/// Safe mode uses default UI settings but edits the real graphics.json for the next start.
|
||||
#[test]
|
||||
fn safe_mode_preserves_graphics_choices_when_changing_antialiasing() {
|
||||
use serde_json::{Value, json};
|
||||
use solidcraft_ui_egui::scenario::Harness;
|
||||
|
||||
for choice in ["wayland", "x11"] {
|
||||
let mut h = Harness::new();
|
||||
let path = h.dir.join("graphics.json");
|
||||
let saved = json!({"window_system": choice, "adapter": "Selected GPU", "backend": "vulkan", "msaa": 8});
|
||||
std::fs::write(&path, saved.to_string()).unwrap();
|
||||
h.app.services.graphics_path = Some(path.to_string_lossy().into_owned());
|
||||
let defaults = h.app.preferences.clone();
|
||||
let stored_ui = json!({"preferences": {"window_system": "auto", "graphics_adapter": "Stale GPU", "msaa": 2,
|
||||
"display_quality": "fine"}})
|
||||
.to_string();
|
||||
super::restore_preferences(&mut h.app, Some(&stored_ui), Some(&saved), true);
|
||||
|
||||
assert_eq!(h.app.preferences.window_system, choice);
|
||||
assert_eq!(h.app.preferences.graphics_adapter, "Selected GPU");
|
||||
assert_eq!(h.app.preferences.msaa, defaults.msaa, "safe mode ignores saved anti-aliasing");
|
||||
assert_eq!(h.app.preferences.display_quality, defaults.display_quality, "safe mode ignores saved UI settings");
|
||||
assert_eq!(serde_json::from_str::<Value>(&std::fs::read_to_string(&path).unwrap()).unwrap(), saved, "startup does not write settings");
|
||||
|
||||
assert_eq!(h.call("ui.prefs", json!({"open": "Graphics"}))["ok"], true);
|
||||
assert_eq!(h.call("ui.prefs", json!({"msaa": 1}))["ok"], true);
|
||||
assert_eq!(h.call("ui.prefs", json!({"button": "ok"}))["ok"], true);
|
||||
let after: Value = serde_json::from_str(&std::fs::read_to_string(&path).unwrap()).unwrap();
|
||||
assert_eq!(after, json!({"window_system": choice, "adapter": "Selected GPU", "backend": "vulkan", "msaa": 1}));
|
||||
|
||||
let mut normal = Harness::new();
|
||||
super::restore_preferences(&mut normal.app, Some(&stored_ui), Some(&after), false);
|
||||
assert_eq!(normal.app.preferences.window_system, choice);
|
||||
assert_eq!(normal.app.preferences.graphics_adapter, "Selected GPU");
|
||||
assert_eq!(normal.app.preferences.display_quality, "fine", "normal startup still restores UI settings");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_or_invalid_startup_window_system_uses_automatic() {
|
||||
use serde_json::json;
|
||||
|
||||
for saved in [None, Some(json!(null)), Some(json!({})), Some(json!({"window_system": 7})), Some(json!({"window_system": "unknown"}))] {
|
||||
let mut app = super::SolveApp::new(super::Session::default(), super::Services::default());
|
||||
app.preferences.window_system = "wayland".into();
|
||||
super::restore_graphics_preferences(&mut app, saved.as_ref());
|
||||
assert_eq!(app.preferences.window_system, "auto", "{saved:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A manual graphics.json choice wins over stale app.ron preferences and survives an
|
||||
/// unrelated graphics edit (#10116), including on a fresh launch with no saved UI state.
|
||||
#[test]
|
||||
fn startup_window_system_survives_changing_antialiasing() {
|
||||
use serde_json::{Value, json};
|
||||
use solidcraft_ui_egui::scenario::Harness;
|
||||
|
||||
for choice in ["wayland", "x11", "auto", " wayland ", " x11 "] {
|
||||
for stale in [None, Some("auto"), Some("wayland"), Some("x11")] {
|
||||
let mut h = Harness::new();
|
||||
if let Some(stale) = stale {
|
||||
h.app.load_prefs(&json!({"preferences": {"window_system": stale}}).to_string());
|
||||
}
|
||||
let path = h.dir.join("graphics.json");
|
||||
std::fs::write(&path, json!({"window_system": choice, "backend": "vulkan", "adapter": "Selected GPU", "msaa": 4}).to_string())
|
||||
.unwrap();
|
||||
h.app.services.graphics_path = Some(path.to_string_lossy().into_owned());
|
||||
let saved: Value = serde_json::from_str(&std::fs::read_to_string(&path).unwrap()).unwrap();
|
||||
super::restore_graphics_preferences(&mut h.app, Some(&saved));
|
||||
|
||||
let result = h.call("ui.prefs", json!({"msaa": 2}));
|
||||
assert_eq!(result["ok"], true, "{result}");
|
||||
let after: Value = serde_json::from_str(&std::fs::read_to_string(&path).unwrap()).unwrap();
|
||||
assert_eq!(after["window_system"], choice.trim(), "saved choice {choice:?}, stale UI choice {stale:?}");
|
||||
assert_eq!(result["result"]["window_system"], choice.trim());
|
||||
assert_eq!(after["msaa"], 2);
|
||||
assert_eq!(after["backend"], "vulkan");
|
||||
assert_eq!(after["adapter"], "Selected GPU");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn first_launch_adopts_the_previous_release_settings() {
|
||||
let d = std::env::temp_dir().join(format!("solidcraft-adopt-settings-{}", std::process::id()));
|
||||
|
||||
@@ -17,6 +17,7 @@ assets/
|
||||
ui/design/tools/ # authoring bases, checks and included review app
|
||||
ui/source/ # Rust viewport glyphs, markers and navigation
|
||||
branding/web/source/og.png # shared social preview card
|
||||
branding/logo/ # print/web logo files; guide in branding/README.md
|
||||
styles/ui/palettes.rs # light/dark defaults
|
||||
styles/web/loading.css # web loading/canvas styles
|
||||
appearances/library.rs # built-in visual presets
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# SolidCraft brand kit
|
||||
|
||||
Logo files for stickers, shirts, the web and social posts. Everything in `logo/` is drawn
|
||||
from the app icon (`assets/icons/app/macos/source/SolidCraft.icon/Assets/03-solid-blue-cutout.svg`),
|
||||
which is also the last frame of the loading animation (`assets/styles/web/loading-logo.svg`).
|
||||
The SVGs are plain paths: no scripts, fonts, animation or external links, so any printer can use them.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Use it for |
|
||||
|---|---|
|
||||
| `logo/solidcraft-mark.svg` | The mark in full colour. First choice for stickers, print and the web. |
|
||||
| `logo/solidcraft-mark-mono-black.svg` | One-colour print on light material: screen-printed shirts, stamps, engraving, vinyl. |
|
||||
| `logo/solidcraft-mark-mono-white.svg` | One-colour print on dark material, such as a white print on a dark shirt. |
|
||||
| `logo/solidcraft-mark-512.png`, `-1024.png`, `-2048.png` | Transparent square PNGs for places that don't take SVG: avatars, social posts, slides, print shops that ask for a bitmap (send the 2048). |
|
||||
| `logo/solidcraft-wordmark.svg` | The name on its own, outlined to paths. |
|
||||
| `logo/solidcraft-lockup-horizontal.svg` | Mark and name side by side: headers, banners, shirt fronts, wide stickers. |
|
||||
| `web/source/og.png` | The existing link preview card for the docs site. |
|
||||
|
||||
The gaps between the faces are part of the logo. In the colour and one-colour files they are
|
||||
transparent, so the material shows through. For a die-cut sticker, cut around the outer shape
|
||||
and let the backing colour (white is best) fill the gaps.
|
||||
|
||||
## Colours
|
||||
|
||||
The mark's five faces each use a two-stop gradient from the icon source:
|
||||
|
||||
| Face | From | To |
|
||||
|---|---|---|
|
||||
| Top | `#51adff` | `#2b83f1` |
|
||||
| Left | `#258df5` | `#1461da` |
|
||||
| Right | `#1b66cf` | `#124596` |
|
||||
| Lower step (top) | `#459fff` | `#2379e7` |
|
||||
| Upper step (inner side) | `#1d63c6` | `#15499e` |
|
||||
|
||||
Other colours, all already used in the project:
|
||||
|
||||
| Colour | Hex | Where it comes from |
|
||||
|---|---|---|
|
||||
| Wordmark blue | `#15499e` | loading logo `--word` |
|
||||
| Interface accent | `#2678da` | light theme `accent` token (`assets/styles/ui/palettes.rs`) |
|
||||
| Light background | `#e8ebf0` | web loading screen (`assets/styles/web/loading.css`) |
|
||||
| Dark background | `#1f232b` | dark theme `file_background` token |
|
||||
| Black / white | `#000000` / `#ffffff` | one-colour versions only |
|
||||
|
||||
If a printer can't do gradients, use the one-colour files, or fill every face with `#2678da`.
|
||||
|
||||
## Clear space and size
|
||||
|
||||
- Keep empty space around the mark of at least one fifth of its height on every side. Treat
|
||||
the lockup the same way, measured from the mark.
|
||||
- Smallest mark: 16 px tall on screen, 12 mm tall in print. Below that the gaps fill in.
|
||||
- Smallest lockup: 120 px wide on screen, 40 mm wide in print.
|
||||
|
||||
## Don'ts
|
||||
|
||||
- Don't recolour it outside the colours above.
|
||||
- Don't stretch, squash, rotate, skew or crop it. Scale it evenly.
|
||||
- Don't add shadows, outlines, glows, bevels or other effects.
|
||||
- Don't fill or close the gaps between the faces, or move the faces apart.
|
||||
- Don't rearrange the lockup, retype the name in another font, or put the mark on a busy
|
||||
background where it loses contrast.
|
||||
|
||||
## Name and logo
|
||||
|
||||
The SolidCraft code and these files are licensed MIT OR Apache-2.0 (see the [README](../../README.md#licence)),
|
||||
so you may copy and change them. The name SolidCraft and this logo identify the SolidCraft
|
||||
project. Use them to refer to the project, for example in an article, a talk, or a sticker for a
|
||||
meetup. If you publish a fork or a modified build, give it its own name and logo so people
|
||||
don't mistake it for SolidCraft.
|
||||
|
||||
The wordmark is set in IBM Plex Sans Bold (SIL Open Font License 1.1, the interface font in
|
||||
`assets/fonts/ibm-plex-sans/`) and outlined, so you don't need the font to print it.
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="116.406 53.364 2748.71 904.436" width="2749" height="904" role="img"><title>SolidCraft</title><defs><linearGradient id="sc1" x1="619.14" y1="179.734" x2="694.687" y2="396.761" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#1d63c6"/><stop offset="1" stop-color="#15499e"/></linearGradient><linearGradient id="sc2" x1="619.14" y1="413.244" x2="790.839" y2="605.547" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#459fff"/><stop offset="1" stop-color="#2379e7"/></linearGradient><linearGradient id="sc3" x1="632.876" y1="399.508" x2="783.971" y2="968.175" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#1b66cf"/><stop offset="1" stop-color="#124596"/></linearGradient><linearGradient id="sc4" x1="207.063" y1="303.357" x2="426.837" y2="968.175" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#258df5"/><stop offset="1" stop-color="#1461da"/></linearGradient><linearGradient id="sc5" x1="385.63" y1="53.364" x2="522.989" y2="510.769" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#51adff"/><stop offset="1" stop-color="#2b83f1"/></linearGradient></defs><g><path d="M547.883 282.66 L709.797 188.211 L709.797 375.985 Z" fill="url(#sc1)"/><path d="M727.797 593.626 L727.797 407.136 L889.571 500.381 Z" fill="url(#sc2)"/><path d="M530 521.17 L691.797 427.912 L691.797 655.928 L907.594 531.545 L907.594 740.159 L530 957.8 Z" fill="url(#sc3)"/><path d="M116.406 510.769 L116.406 303.529 L494 521.17 L494 957.8 L314.203 854.167 L314.203 624.777 Z" fill="url(#sc4)"/><path d="M134.374 272.334 L512 53.364 L691.828 157.015 L476.117 282.846 L673.752 396.761 L512 489.993 Z" fill="url(#sc5)"/></g><path fill="#15499e" transform="translate(1092.78 632.20) scale(0.36281)" d="M303 12Q212 12 147.5 -20Q83 -52 38 -101L138 -202Q173 -162 217.5 -142Q262 -122 313 -122Q369 -122 396 -145Q423 -168 423 -206Q423 -225 416.5 -240.5Q410 -256 392.5 -266.5Q375 -277 342 -281L273 -290Q200 -300 152.5 -326.5Q105 -353 82 -396.5Q59 -440 59 -498Q59 -561 90.5 -608.5Q122 -656 180.5 -683Q239 -710 321 -710Q400 -710 460 -684.5Q520 -659 563 -612L462 -510Q437 -539 401.5 -557.5Q366 -576 312 -576Q261 -576 236 -558Q211 -540 211 -508Q211 -484 219.5 -469Q228 -454 246.5 -446Q265 -438 294 -433L363 -422Q435 -411 482 -385Q529 -359 552 -317Q575 -275 575 -215Q575 -148 543.5 -97Q512 -46 451 -17Q390 12 303 12ZM926 12Q849 12 794 -21.5Q739 -55 709.5 -117Q680 -179 680 -263Q680 -348 709.5 -409Q739 -470 794 -503.5Q849 -537 926 -537Q1003 -537 1058 -503.5Q1113 -470 1142.5 -409Q1172 -348 1172 -263Q1172 -179 1142.5 -117Q1113 -55 1058 -21.5Q1003 12 926 12ZM926 -105Q970 -105 994 -132.5Q1018 -160 1018 -209V-316Q1018 -366 994 -393Q970 -420 926 -420Q883 -420 858.5 -393Q834 -366 834 -316V-209Q834 -160 858.5 -132.5Q883 -105 926 -105ZM1511 0H1444Q1368 0 1332.5 -37Q1297 -74 1297 -144V-740H1445V-115H1511ZM1694 -581Q1649 -581 1628.5 -602Q1608 -623 1608 -654V-676Q1608 -708 1628.5 -728.5Q1649 -749 1694 -749Q1739 -749 1759.5 -728.5Q1780 -708 1780 -676V-654Q1780 -623 1759.5 -602Q1739 -581 1694 -581ZM1620 0V-525H1768V0ZM2248 0V-88H2243Q2232 -45 2192.5 -16.5Q2153 12 2102 12Q2036 12 1991 -19.5Q1946 -51 1923 -112.5Q1900 -174 1900 -263Q1900 -352 1923 -413Q1946 -474 1991 -505.5Q2036 -537 2102 -537Q2153 -537 2192.5 -509Q2232 -481 2243 -437H2248V-740H2396V0ZM2151 -108Q2179 -108 2201 -117Q2223 -126 2235.5 -143.5Q2248 -161 2248 -185V-340Q2248 -364 2235.5 -381.5Q2223 -399 2201 -408Q2179 -417 2151 -417Q2109 -417 2081.5 -387.5Q2054 -358 2054 -308V-217Q2054 -168 2081.5 -138Q2109 -108 2151 -108ZM2844 12Q2750 12 2680.5 -28Q2611 -68 2573 -147Q2535 -226 2535 -344Q2535 -462 2573 -543.5Q2611 -625 2680.5 -667.5Q2750 -710 2844 -710Q2940 -710 3003.5 -670Q3067 -630 3105 -546L2974 -478Q2961 -522 2930.5 -548.5Q2900 -575 2844 -575Q2777 -575 2736.5 -531.5Q2696 -488 2696 -405V-293Q2696 -211 2736.5 -167Q2777 -123 2844 -123Q2900 -123 2933.5 -153.5Q2967 -184 2983 -227L3107 -155Q3068 -76 3004 -32Q2940 12 2844 12ZM3373 0H3225V-525H3373V-411H3378Q3384 -440 3400 -466Q3416 -492 3443.5 -508.5Q3471 -525 3512 -525H3538V-387H3501Q3458 -387 3429.5 -379.5Q3401 -372 3387 -355Q3373 -338 3373 -307ZM4105 0H4023Q3996 0 3972.5 -13.5Q3949 -27 3935 -53.5Q3921 -80 3921 -117V-130L3953 -92H3917Q3905 -41 3864 -14.5Q3823 12 3763 12Q3684 12 3642 -30.5Q3600 -73 3600 -141Q3600 -197 3627.5 -233Q3655 -269 3705.5 -287Q3756 -305 3825 -305H3908V-338Q3908 -376 3888 -398.5Q3868 -421 3821 -421Q3777 -421 3751 -402Q3725 -383 3708 -359L3620 -437Q3652 -484 3701 -510.5Q3750 -537 3832 -537Q3943 -537 3999.5 -487.5Q4056 -438 4056 -345V-115H4105ZM3908 -221H3836Q3793 -221 3771 -206Q3749 -191 3749 -162V-147Q3749 -119 3767 -105Q3785 -91 3818 -91Q3843 -91 3863 -98Q3883 -105 3895.5 -120Q3908 -135 3908 -159ZM4250 0V-410H4176V-525H4250V-587Q4250 -663 4290.5 -701.5Q4331 -740 4407 -740H4503V-625H4398V-525H4503V-410H4398V0ZM4877 0H4789Q4713 0 4673 -39Q4633 -78 4633 -153V-410H4559V-525H4596Q4626 -525 4637 -539.5Q4648 -554 4648 -581V-667H4781V-525H4885V-410H4781V-115H4877Z"/></svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 193 KiB |
|
After Width: | Height: | Size: 32 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="116.406 53.364 791.188 904.436" width="791" height="904" role="img"><title>SolidCraft</title><g fill="#000000"><path d="M547.883 282.66 L709.797 188.211 L709.797 375.985 Z"/><path d="M727.797 593.626 L727.797 407.136 L889.571 500.381 Z"/><path d="M530 521.17 L691.797 427.912 L691.797 655.928 L907.594 531.545 L907.594 740.159 L530 957.8 Z"/><path d="M116.406 510.769 L116.406 303.529 L494 521.17 L494 957.8 L314.203 854.167 L314.203 624.777 Z"/><path d="M134.374 272.334 L512 53.364 L691.828 157.015 L476.117 282.846 L673.752 396.761 L512 489.993 Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 612 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="116.406 53.364 791.188 904.436" width="791" height="904" role="img"><title>SolidCraft</title><g fill="#ffffff"><path d="M547.883 282.66 L709.797 188.211 L709.797 375.985 Z"/><path d="M727.797 593.626 L727.797 407.136 L889.571 500.381 Z"/><path d="M530 521.17 L691.797 427.912 L691.797 655.928 L907.594 531.545 L907.594 740.159 L530 957.8 Z"/><path d="M116.406 510.769 L116.406 303.529 L494 521.17 L494 957.8 L314.203 854.167 L314.203 624.777 Z"/><path d="M134.374 272.334 L512 53.364 L691.828 157.015 L476.117 282.846 L673.752 396.761 L512 489.993 Z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 612 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="116.406 53.364 791.188 904.436" width="791" height="904" role="img"><title>SolidCraft</title><defs><linearGradient id="sc1" x1="619.14" y1="179.734" x2="694.687" y2="396.761" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#1d63c6"/><stop offset="1" stop-color="#15499e"/></linearGradient><linearGradient id="sc2" x1="619.14" y1="413.244" x2="790.839" y2="605.547" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#459fff"/><stop offset="1" stop-color="#2379e7"/></linearGradient><linearGradient id="sc3" x1="632.876" y1="399.508" x2="783.971" y2="968.175" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#1b66cf"/><stop offset="1" stop-color="#124596"/></linearGradient><linearGradient id="sc4" x1="207.063" y1="303.357" x2="426.837" y2="968.175" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#258df5"/><stop offset="1" stop-color="#1461da"/></linearGradient><linearGradient id="sc5" x1="385.63" y1="53.364" x2="522.989" y2="510.769" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#51adff"/><stop offset="1" stop-color="#2b83f1"/></linearGradient></defs><g><path d="M547.883 282.66 L709.797 188.211 L709.797 375.985 Z" fill="url(#sc1)"/><path d="M727.797 593.626 L727.797 407.136 L889.571 500.381 Z" fill="url(#sc2)"/><path d="M530 521.17 L691.797 427.912 L691.797 655.928 L907.594 531.545 L907.594 740.159 L530 957.8 Z" fill="url(#sc3)"/><path d="M116.406 510.769 L116.406 303.529 L494 521.17 L494 957.8 L314.203 854.167 L314.203 624.777 Z" fill="url(#sc4)"/><path d="M134.374 272.334 L512 53.364 L691.828 157.015 L476.117 282.846 L673.752 396.761 L512 489.993 Z" fill="url(#sc5)"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="38.0 -749.0 4847.0 761.0" width="4847" height="761" role="img"><title>SolidCraft</title><path fill="#15499e" d="M303 12Q212 12 147.5 -20Q83 -52 38 -101L138 -202Q173 -162 217.5 -142Q262 -122 313 -122Q369 -122 396 -145Q423 -168 423 -206Q423 -225 416.5 -240.5Q410 -256 392.5 -266.5Q375 -277 342 -281L273 -290Q200 -300 152.5 -326.5Q105 -353 82 -396.5Q59 -440 59 -498Q59 -561 90.5 -608.5Q122 -656 180.5 -683Q239 -710 321 -710Q400 -710 460 -684.5Q520 -659 563 -612L462 -510Q437 -539 401.5 -557.5Q366 -576 312 -576Q261 -576 236 -558Q211 -540 211 -508Q211 -484 219.5 -469Q228 -454 246.5 -446Q265 -438 294 -433L363 -422Q435 -411 482 -385Q529 -359 552 -317Q575 -275 575 -215Q575 -148 543.5 -97Q512 -46 451 -17Q390 12 303 12ZM926 12Q849 12 794 -21.5Q739 -55 709.5 -117Q680 -179 680 -263Q680 -348 709.5 -409Q739 -470 794 -503.5Q849 -537 926 -537Q1003 -537 1058 -503.5Q1113 -470 1142.5 -409Q1172 -348 1172 -263Q1172 -179 1142.5 -117Q1113 -55 1058 -21.5Q1003 12 926 12ZM926 -105Q970 -105 994 -132.5Q1018 -160 1018 -209V-316Q1018 -366 994 -393Q970 -420 926 -420Q883 -420 858.5 -393Q834 -366 834 -316V-209Q834 -160 858.5 -132.5Q883 -105 926 -105ZM1511 0H1444Q1368 0 1332.5 -37Q1297 -74 1297 -144V-740H1445V-115H1511ZM1694 -581Q1649 -581 1628.5 -602Q1608 -623 1608 -654V-676Q1608 -708 1628.5 -728.5Q1649 -749 1694 -749Q1739 -749 1759.5 -728.5Q1780 -708 1780 -676V-654Q1780 -623 1759.5 -602Q1739 -581 1694 -581ZM1620 0V-525H1768V0ZM2248 0V-88H2243Q2232 -45 2192.5 -16.5Q2153 12 2102 12Q2036 12 1991 -19.5Q1946 -51 1923 -112.5Q1900 -174 1900 -263Q1900 -352 1923 -413Q1946 -474 1991 -505.5Q2036 -537 2102 -537Q2153 -537 2192.5 -509Q2232 -481 2243 -437H2248V-740H2396V0ZM2151 -108Q2179 -108 2201 -117Q2223 -126 2235.5 -143.5Q2248 -161 2248 -185V-340Q2248 -364 2235.5 -381.5Q2223 -399 2201 -408Q2179 -417 2151 -417Q2109 -417 2081.5 -387.5Q2054 -358 2054 -308V-217Q2054 -168 2081.5 -138Q2109 -108 2151 -108ZM2844 12Q2750 12 2680.5 -28Q2611 -68 2573 -147Q2535 -226 2535 -344Q2535 -462 2573 -543.5Q2611 -625 2680.5 -667.5Q2750 -710 2844 -710Q2940 -710 3003.5 -670Q3067 -630 3105 -546L2974 -478Q2961 -522 2930.5 -548.5Q2900 -575 2844 -575Q2777 -575 2736.5 -531.5Q2696 -488 2696 -405V-293Q2696 -211 2736.5 -167Q2777 -123 2844 -123Q2900 -123 2933.5 -153.5Q2967 -184 2983 -227L3107 -155Q3068 -76 3004 -32Q2940 12 2844 12ZM3373 0H3225V-525H3373V-411H3378Q3384 -440 3400 -466Q3416 -492 3443.5 -508.5Q3471 -525 3512 -525H3538V-387H3501Q3458 -387 3429.5 -379.5Q3401 -372 3387 -355Q3373 -338 3373 -307ZM4105 0H4023Q3996 0 3972.5 -13.5Q3949 -27 3935 -53.5Q3921 -80 3921 -117V-130L3953 -92H3917Q3905 -41 3864 -14.5Q3823 12 3763 12Q3684 12 3642 -30.5Q3600 -73 3600 -141Q3600 -197 3627.5 -233Q3655 -269 3705.5 -287Q3756 -305 3825 -305H3908V-338Q3908 -376 3888 -398.5Q3868 -421 3821 -421Q3777 -421 3751 -402Q3725 -383 3708 -359L3620 -437Q3652 -484 3701 -510.5Q3750 -537 3832 -537Q3943 -537 3999.5 -487.5Q4056 -438 4056 -345V-115H4105ZM3908 -221H3836Q3793 -221 3771 -206Q3749 -191 3749 -162V-147Q3749 -119 3767 -105Q3785 -91 3818 -91Q3843 -91 3863 -98Q3883 -105 3895.5 -120Q3908 -135 3908 -159ZM4250 0V-410H4176V-525H4250V-587Q4250 -663 4290.5 -701.5Q4331 -740 4407 -740H4503V-625H4398V-525H4503V-410H4398V0ZM4877 0H4789Q4713 0 4673 -39Q4633 -78 4633 -153V-410H4559V-525H4596Q4626 -525 4637 -539.5Q4648 -554 4648 -581V-667H4781V-525H4885V-410H4781V-115H4877Z"/></svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
@@ -60,7 +60,6 @@ circle_ttt false
|
||||
close false
|
||||
coil false
|
||||
colored_components false
|
||||
colored_components_off false
|
||||
combine false
|
||||
compare false
|
||||
component false
|
||||
@@ -161,6 +160,7 @@ min_radius false
|
||||
mirror false
|
||||
motion_link false
|
||||
move false
|
||||
nav_settings false
|
||||
new false
|
||||
normal false
|
||||
offset false
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<title>Disable component colors</title>
|
||||
<path d="M9.235 17.706L15.059 20.882L15.059 48.941L9.235 44.926Z" fill="#328bd3"/>
|
||||
<path d="M35.176 9.235L15.059 20.882L15.059 48.941L36.765 35.139Z" fill="#236ead"/>
|
||||
<path d="M29.046 5L35.176 8.176L15.196 19.718L9.066 16.541Z" fill="#b9ddf8"/>
|
||||
<path d="M29.046 5.529L35.176 8.706L35.176 36.235L15.059 49.471L9.235 45.765L9.066 17.071Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M9.066 17.6L15.059 20.882L34.647 9.235" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.059 20.882L15.059 47.067" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M32.222 18.595L44.949 25.944L44.949 51.122L32.222 43.774Z" fill="#328bd3"/>
|
||||
<path d="M54.934 20.173L44.949 25.944L44.949 51.122L54.934 45.352Z" fill="#236ead"/>
|
||||
<path d="M42.059 12.412L54.934 20.173L44.949 25.944L32 17.706Z" fill="#b9ddf8"/>
|
||||
<path d="M41.159 11.766L54.934 20.173L54.934 45.352L44.949 51.122L31.164 42.715L31.164 17.536Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M32.222 18.595L44.949 25.944L54.934 20.173" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M44.949 25.944L44.949 51.122" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M18.299 39.062L31.015 46.411L31.015 59L18.299 51.652Z" fill="#328bd3"/>
|
||||
<path d="M41.921 40.121L31.015 46.411L31.015 59L41.921 52.711Z" fill="#236ead"/>
|
||||
<path d="M29.194 32.773L41.921 40.121L31.015 46.411L18.299 39.062Z" fill="#b9ddf8"/>
|
||||
<path d="M29.194 32.773L41.921 40.121L41.921 52.711L31.015 59L18.299 51.652L18.299 39.062Z" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M18.299 39.062L31.015 46.411L41.921 40.121" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M31.015 46.411L31.015 59" fill="none" stroke="#34465b" stroke-width="2.55" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.3 KiB |
@@ -85,6 +85,7 @@
|
||||
"Bottom Right": "أسفل اليمين",
|
||||
"Boundary": "الحد",
|
||||
"Bounding box": "الصندوق المحيط",
|
||||
"Bridge": "جسر",
|
||||
"CHECK": "تحقق",
|
||||
"COMPONENTS": "المكوّنات",
|
||||
"CONFIGURATIONS": "التكوينات",
|
||||
@@ -963,8 +964,7 @@
|
||||
"cmd.inspect_analysis": "تحليل العرض",
|
||||
"cmd.inspect_center_of_mass": "مركز الكتلة",
|
||||
"cmd.inspect_clearance": "الخلوص",
|
||||
"cmd.inspect_colored_components": "تفعيل ألوان المكوّنات",
|
||||
"cmd.inspect_colored_components_disable": "تعطيل ألوان المكوّنات",
|
||||
"cmd.inspect_colored_components": "ألوان المكوّنات",
|
||||
"cmd.inspect_compare": "مقارنة الأجسام",
|
||||
"cmd.inspect_compare_picture": "مقارنة بصورة مرجعية",
|
||||
"cmd.inspect_continuity": "تحليل الاستمرارية",
|
||||
@@ -1296,6 +1296,7 @@
|
||||
"cmd.timeline_stop": "إيقاف السجل",
|
||||
"cmd.timeline_suppress": "تعطيل الميزة",
|
||||
"cmd.ui.assistant": "إظهار المساعد أو إخفاؤه",
|
||||
"cmd.view.navigator": "متصفح العرض المخصص",
|
||||
"cmd.view.render_browser": "متصفح التصيير",
|
||||
"cmd.view.render_dock": "نقل لوحة التصيير",
|
||||
"cmd.view.render_focus": "عرض تركيز التصيير",
|
||||
@@ -1445,6 +1446,9 @@
|
||||
"each rail's curves must be in one sketch": "يجب أن تكون منحنيات كل دليل في رسم واحد",
|
||||
"feature computation ended without a result": "انتهى حساب الميزة دون نتيجة",
|
||||
"file.open.drawing_filter": "التصاميم وملفات CAD والشبكات والرسومات",
|
||||
"file.open.portal_fallback.no_portal_service": "منتقي الملفات الذي فُتح ليس تابعًا لسطح المكتب: خدمة منتقي الملفات في سطح المكتب غير متاحة.",
|
||||
"file.open.portal_fallback.no_session_bus": "منتقي الملفات الذي فُتح ليس تابعًا لسطح المكتب: لا يوجد ناقل جلسات D-Bus.",
|
||||
"file.open.portal_fallback.xwayland": "منتقي الملفات الذي فُتح ليس تابعًا لسطح المكتب: في XWayland ترفض البوابة النافذة الأصلية.",
|
||||
"file_load.built": "بُني حتى الآن: {built} من {total} ميزة.",
|
||||
"file_load.converting": "تحويل الجسم الصلب {done} من {total}",
|
||||
"file_load.inserting": "إدراج الهندسة",
|
||||
@@ -1605,7 +1609,7 @@
|
||||
"help.parts.resize": "يغيّر مقاس قطعة قياسية مدرجة أو طولها ويعيد بناءها، وتبقيها مفاصلها مثبتة في مكانها. استخدمه عندما يتبين أن برغيًا أطول من اللازم أو أن ثقبًا يحتاج إلى مقاس آخر.",
|
||||
"help.plastic.assign_rule": "يعيّن قاعدة بلاستيك لأجسام، فتأخذ ميزاتها البلاستيكية ميلها وخلوصها منها كقيم افتراضية. استخدمه لإعداد قطعة مقولبة مرة واحدة لكل ميزاتها.",
|
||||
"help.plastic.boss": "يضيف نتوءًا لمسمار على وجه: عمودًا مع ثقب اختياري وميل وتقويس عند الجذر وأضلاع تقوية. استخدمه لنقاط البراغي في الهياكل المقولبة أو المطبوعة.",
|
||||
"help.plastic.lip": "يضيف شفة أو أخدودًا مطابقًا على طول حافة جسم مفرَّغ. استخدمه ليتمركز نصفا الهيكل أحدهما على الآخر ويُغلقا بإحكام.",
|
||||
"help.plastic.lip": "يضيف شفة أو أخدودًا مطابقًا على طول إطار جسم مفرَّغ (فرّغ الجسم بفتح أحد وجوهه أولًا، ثم اختر الإطار المحيط بتلك الفتحة). استخدمه ليتمركز نصفا الهيكل أحدهما على الآخر ويُغلقا بإحكام.",
|
||||
"help.plastic.manage_rules": "ينشئ قواعد البلاستيك ويعدّلها: المادة وسماكة الجدار وأنصاف الأقطار والخلوص والميل. استخدمها للحفاظ على اتساق ميزات القطعة المقولبة.",
|
||||
"help.plastic.rest": "يضيف مسندًا على وجه: وسادة مستديرة أو مستطيلة، مصمتة أو مجوفة، مع ميل. استخدمه كدعامة أو مُباعِد في هيكل مقولب.",
|
||||
"help.plastic.snap_fit": "يضيف خطاف وصلة كبس على وجه، بطوله وسماكته ونتوء التثبيت. استخدمه لتثبيت القطع معًا بلا براغي.",
|
||||
@@ -2035,6 +2039,8 @@
|
||||
"nav.blender.help": "السحب بالزر الأوسط يدوّر العرض، وShift مع الأوسط يُزيحه، وCtrl مع الأوسط يكبّره؛ والسحب بالأيمن لا يحرك الكاميرا",
|
||||
"nav.creo.help": "السحب بالزر الأوسط يدوّر العرض، وShift مع الأوسط يُزيحه، وCtrl مع السحب العمودي بالأوسط يكبّره أو يصغّره (السحب لأسفل للتكبير)؛ وتدوير العجلة يكبّره أو يصغّره",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "يستمر السحب بالزر الأوسط أو الأيمن في التدوير أو التحريك أو التكبير كما بدأ حتى تحرير الزر، مهما ضُغطت المفاتيح أو حُرّرت في أثناء ذلك. عند الإيقاف: تقرر المفاتيح المضغوطة في كل لحظة من السحب.",
|
||||
"nav.drag_keeps_mode.label": "يحتفظ السحب بطريقة التنقل التي بدأ بها",
|
||||
"nav.free_orbit.help": "الفأرة والفأرة ثلاثية الأبعاد تدوّران العرض عبر القطبين وتحافظان على اللف. يُعطَّل التقاط المحاور بـ Shift.",
|
||||
"nav.free_orbit.label": "تدوير حر",
|
||||
"nav.free_orbit.snap_help": "الفأرة والفأرة ثلاثية الأبعاد تدوّران العرض عبر القطبين وتحافظان على اللف. اضغط مطولًا على Shift أثناء سحب التدوير لالتقاط اتجاه العرض واللف.",
|
||||
@@ -2337,8 +2343,8 @@
|
||||
"prefs.dialogs_edge": "عند حافة العرض",
|
||||
"prefs.dialogs_left_column": "في العمود الأيسر",
|
||||
"prefs.dialogs_note": "مكان فتح حوارات الأوامر: مثبتة عند حافة العرض، أو في العمود الأيسر مكان المستعرض والسجل، اللذين يعودان كما كانا عند إغلاق الحوار.",
|
||||
"prefs.dimension_step_angle": "ما تضيفه أسهم النافذة وأعلى/أسفل والعجلة إلى الزاوية",
|
||||
"prefs.dimension_step_length": "ما تضيفه أسهم النافذة وأعلى/أسفل والعجلة إلى الطول",
|
||||
"prefs.dimension_step_angle": "ما تضيفه أسهم النافذة والسهمان لأعلى ولأسفل والعجلة إلى الزاوية",
|
||||
"prefs.dimension_step_length": "ما تضيفه أسهم النافذة والسهمان لأعلى ولأسفل والعجلة إلى الطول",
|
||||
"prefs.dimension_steps": "خطوات النافذة",
|
||||
"prefs.dimension_values": "قيم الأبعاد",
|
||||
"prefs.dimension_values_note": "مكان كتابة قيمة البعد. للنافذة أسهم تغيّرها بخطوات؛ تضع أداة البعد النص أولًا.",
|
||||
@@ -2554,6 +2560,8 @@
|
||||
"prefs.section_hatch_by_part": "حسب الجزء",
|
||||
"prefs.section_hatch_one": "نمط واحد",
|
||||
"prefs.select": "تحديد",
|
||||
"prefs.select_hidden_edges": "تحديد الحواف المخفية في العرض المظلل مع الحواف المخفية",
|
||||
"prefs.select_hidden_edges_help": "يتيح تحديد الحواف عبر الأسطح عند تفعيل العرض المظلل مع الحواف المخفية، بما في ذلك استخدام أداة Fillet. يحافظ إيقافه على سلوك التحديد في v0.30.1. تظل الأجسام المخفية غير قابلة للتحديد.",
|
||||
"prefs.select_one_item": "تحديد عنصر واحد",
|
||||
"prefs.select_other_hidden": "تحديد العناصر الهندسية المخفية باستخدام «تحديد عنصر آخر»",
|
||||
"prefs.select_other_hidden_help": "عند التفعيل: تضمين الأجسام والمخططات المخفية والحواف المحجوبة قرب المؤشر. عند التعطيل: استخدام القائمة الأصلية للعناصر الهندسية المرئية أسفل المؤشر.",
|
||||
@@ -2578,6 +2586,8 @@
|
||||
"prefs.sketch.click_selects": "النقر يحدد",
|
||||
"prefs.sketch.conflict_colour": "لون التعارض",
|
||||
"prefs.sketch.drawing": "الرسم",
|
||||
"prefs.sketch.ellipse_axes": "رسم القطوع الناقصة مع محاورها",
|
||||
"prefs.sketch.ellipse_axes_note": "المحوران الأكبر والأصغر كخطوط مساعدة، لتحديد أبعاد أنصاف المحاور والمحاور. عند الإيقاف: القطع الناقص وحده، ويعطي D عليه نصف قطره الأصغر أينما سُحبت القيمة، مرسومًا ومُعلَّمًا بـ R كما في السابق.",
|
||||
"prefs.sketch.exit_keep": "إبقاء",
|
||||
"prefs.sketch.exit_previous": "العودة إلى العرض السابق",
|
||||
"prefs.sketch.exit_unless_rotated": "إلا إذا تم التدوير",
|
||||
@@ -4117,7 +4127,7 @@
|
||||
"settings.display_quality_note": "المستويات الأدق ترسم الأوجه والحواف المنحنية بنعومة أكبر وتستغرق وقتًا أطول لإنشاء الشبكة. يتغير العرض فقط، لا التصميم ولا الملفات المصدّرة.",
|
||||
"settings.double_click_components": "النقر المزدوج على مكوّن لتنشيطه",
|
||||
"settings.frame_rate_details_note": "يضيف رسمًا لأزمنة الإطارات الأخيرة مع المثلثات المرسومة فوقه، ومدرّجًا تكراريًا لأزمنة الإطارات، وما رسمته وحدة GPU. انقر معدل الإطارات في العرض لإظهارها أو إخفائها.",
|
||||
"settings.frame_rate_note": "يعرض الإطارات في الثانية في الزاوية اليمنى السفلية من العرض. أثناء تفعيله يُعاد رسم العرض باستمرار.",
|
||||
"settings.frame_rate_note": "يعرض الإطارات في الثانية في الزاوية اليمنى السفلية من العرض.",
|
||||
"settings.insert_lists_open_designs": "إدراج تصميم يسرد التصاميم المفتوحة أولًا",
|
||||
"settings.measure_axis_distances": "مسافات المحاور في القياس",
|
||||
"settings.measure_axis_distances_help": "إظهار مركّبات الأبعاد على محاور العالم بجانب المسافة الكلية أثناء فتح أداة القياس.",
|
||||
@@ -4168,6 +4178,32 @@
|
||||
"sketch.dof_left": "تبقّت {count} درجات حرية",
|
||||
"sketch.dof_left_one": "تبقّت {count} درجة حرية",
|
||||
"sketch.draw_curves": "الرسم كـ {linetype}",
|
||||
"sketch.error.closed_curve_two_crossings": "a closed curve needs two crossings to trim",
|
||||
"sketch.error.nothing_to_break": "nothing to break here",
|
||||
"sketch.error.offset_fillet_chamfer": "`{id}` is an offset, and its corners follow its source curves: round or cut the source corners before offsetting, or break the offset association first",
|
||||
"sketch.error.offset_trim": "`{id}` is an offset, and its ends follow its source curves: edit the source curves instead, or break the offset association first",
|
||||
"sketch.hint.arc.center_point": "Arc: click center and start, go round either way and click the end, or type a signed sweep",
|
||||
"sketch.hint.arc.three_point": "Arc: click start, end, then a point on the arc",
|
||||
"sketch.hint.arc3d": "3D Arc: click start, end, then a point on the arc (points may leave the sketch plane)",
|
||||
"sketch.hint.break": "Break: click a curve where it should split",
|
||||
"sketch.hint.circle.center": "Circle: click the center, then a point on the circle",
|
||||
"sketch.hint.constraint.generic": "Constraint: pick the sketch entities",
|
||||
"sketch.hint.constraint.horizontal_vertical": "Horizontal/Vertical: pick a line, two points, or a point and a line; hold Shift to pick a line midpoint",
|
||||
"sketch.hint.constraint.midpoint": "MidPoint: pick a point and a line, or two lines to center the second on the first",
|
||||
"sketch.hint.dimension": "Dimension: pick one or two entities and type the value (or click to place it first); click a dimension to edit it; Enter applies",
|
||||
"sketch.hint.extend": "Extend: click a curve near the end to extend (Shift: click two curves to extend both to where they meet)",
|
||||
"sketch.hint.fallback": "Click in the sketch",
|
||||
"sketch.hint.line": "Line: click points; right-click or Esc to finish",
|
||||
"sketch.hint.line3d": "3D Line: click world points; right-click or Esc to finish (points may leave the sketch plane)",
|
||||
"sketch.hint.open_done": "Open done",
|
||||
"sketch.hint.point3d": "3D Point: click where a 3D point goes",
|
||||
"sketch.hint.rectangle.center": "Center rectangle: click the center, then a corner",
|
||||
"sketch.hint.rectangle.rounded": "Rounded rectangle: click two opposite corners (Tab to the radius box to type the corner radius)",
|
||||
"sketch.hint.rectangle.three_point": "3-point rectangle: click two points of one edge, then the width",
|
||||
"sketch.hint.rectangle.two_point": "Rectangle: click two opposite corners",
|
||||
"sketch.hint.slot": "Slot: click both ends, then the width",
|
||||
"sketch.hint.spline3d": "3D Spline: click fit points in 3D; right-click or Esc to finish",
|
||||
"sketch.hint.trim": "Trim: click the piece of a curve to remove, or drag across the pieces to remove",
|
||||
"sketch.make_selection": "تحويل التحديد إلى {linetype}",
|
||||
"sketch.open_ends": "مفتوحة {count}",
|
||||
"sketch.status_conflict": "تعارض القيود",
|
||||
@@ -5017,6 +5053,7 @@
|
||||
"ui.heading_construct": "إنشاء مرجعي",
|
||||
"ui.heading_create": "إنشاء",
|
||||
"ui.heading_create_sketch": "إنشاء رسم",
|
||||
"ui.heading_custom_view_navigator": "متصفح العرض المخصص",
|
||||
"ui.heading_cylinder": "أسطوانة",
|
||||
"ui.heading_design": "التصميم",
|
||||
"ui.heading_draft": "ميل السحب",
|
||||
@@ -5328,6 +5365,8 @@
|
||||
"ui.repeat_nothing": "لا يوجد ما يُكرَّر بعد: ابدأ أداة أو مربع حوار أولًا.",
|
||||
"ui.replace_with_link_done": "أصبحت النسخ الآن مواضع للتصميم المرتبط.",
|
||||
"ui.report_a_bug": "الإبلاغ عن خطأ",
|
||||
"ui.report_characters_left_one": "الأحرف المتبقية: {count}",
|
||||
"ui.report_characters_left_other": "الأحرف المتبقية: {count}",
|
||||
"ui.reset": "إعادة تعيين",
|
||||
"ui.reset_all": "إعادة تعيين الكل",
|
||||
"ui.reset_the_settings_on_this_page": "إعادة تعيين إعدادات هذه الصفحة",
|
||||
@@ -5612,6 +5651,14 @@
|
||||
"values must be numbers or expressions": "يجب أن تكون القيم أعدادًا أو تعابير",
|
||||
"view.auto_ortho_faces": "منظوري أثناء التدوير، ومتعامد على الأوجه",
|
||||
"view.render_inspector": "مفتش التصيير",
|
||||
"view_gizmo.arrows": "أسهم التدوير",
|
||||
"view_gizmo.home": "زر العرض الرئيسي",
|
||||
"view_gizmo.no_such_body": "لا يوجد في هذا التصميم جسم بهذا الاسم.",
|
||||
"view_gizmo.note": "اختر جسمًا في العرض. يُحفظ مع تفضيلاتك وملفات تعريف الإعدادات، ويظهر في كل تصميم. انقر أحد أوجهه للنظر إليه مباشرة.",
|
||||
"view_gizmo.texture": "الخامة",
|
||||
"view_gizmo.themed": "حسب السمة",
|
||||
"view_gizmo.too_detailed": "مفصّل أكثر مما يناسب متصفح العرض (أكثر من 10,000 مثلث)",
|
||||
"view_gizmo.too_thin": "طويل ورفيع أكثر مما يناسب متصفح العرض: يجب ألا يقل أرفع جانب عن خُمس أطول جانب",
|
||||
"web.files.insert_drawings_hint": "ملفات CAD أو شبكات أو DXF أو SVG إلى التصميم المفتوح",
|
||||
"web.files.insert_stored_drawings_hint": "إلى التصميم المفتوح (ملفات CAD، شبكات، DXF، SVG)",
|
||||
"web.open_full": "فتح في SolidCraft",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Analiza dostupnosti",
|
||||
"cmd.inspect_center_of_mass": "Centar mase",
|
||||
"cmd.inspect_clearance": "Provjera zazora",
|
||||
"cmd.inspect_colored_components": "Omogući boje komponenti",
|
||||
"cmd.inspect_colored_components_disable": "Onemogući boje komponenti",
|
||||
"cmd.inspect_compare": "Uporedi tijela",
|
||||
"cmd.inspect_compare_picture": "Uporedi sliku",
|
||||
"cmd.inspect_continuity": "Analiza kontinuiteta",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Analýza přístupnosti",
|
||||
"cmd.inspect_center_of_mass": "Těžiště",
|
||||
"cmd.inspect_clearance": "Vůle",
|
||||
"cmd.inspect_colored_components": "Zapnout barvy komponent",
|
||||
"cmd.inspect_colored_components_disable": "Vypnout barvy komponent",
|
||||
"cmd.inspect_compare": "Porovnat tělesa",
|
||||
"cmd.inspect_compare_picture": "Porovnat obrázek",
|
||||
"cmd.inspect_continuity": "Analýza spojitosti",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Tilgængelighedsanalyse",
|
||||
"cmd.inspect_center_of_mass": "Massecentrum",
|
||||
"cmd.inspect_clearance": "Frigangskontrol",
|
||||
"cmd.inspect_colored_components": "Aktivér komponentfarver",
|
||||
"cmd.inspect_colored_components_disable": "Deaktivér komponentfarver",
|
||||
"cmd.inspect_compare": "Sammenlign emner",
|
||||
"cmd.inspect_compare_picture": "Sammenlign billede",
|
||||
"cmd.inspect_continuity": "Kontinuitetsanalyse",
|
||||
|
||||
@@ -960,8 +960,6 @@
|
||||
"cmd.inspect_accessibility": "Zugänglichkeitsanalyse",
|
||||
"cmd.inspect_center_of_mass": "Massenschwerpunkt",
|
||||
"cmd.inspect_clearance": "Freiraum",
|
||||
"cmd.inspect_colored_components": "Komponentenfarben einschalten",
|
||||
"cmd.inspect_colored_components_disable": "Komponentenfarben ausschalten",
|
||||
"cmd.inspect_compare": "Körper vergleichen",
|
||||
"cmd.inspect_continuity": "Kontinuitätsprüfung",
|
||||
"cmd.inspect_curvature_comb": "Krümmungskamm-Analyse",
|
||||
@@ -1291,6 +1289,7 @@
|
||||
"cmd.timeline_stop": "Verlauf anhalten",
|
||||
"cmd.timeline_suppress": "Merkmal unterdrücken",
|
||||
"cmd.ui.assistant": "Assistenten ein-/ausblenden",
|
||||
"cmd.view.navigator": "Eigener Ansichtsnavigator",
|
||||
"cmd.view.render_browser": "Render-Browser",
|
||||
"cmd.view.render_dock": "Render-Panel verschieben",
|
||||
"cmd.view.render_focus": "Render-Fokusansicht",
|
||||
@@ -1439,6 +1438,9 @@
|
||||
"each rail's curves must be in one sketch": "die Kurven jeder Führungskurve müssen in derselben Skizze liegen",
|
||||
"feature computation ended without a result": "die Berechnung des Merkmals wurde ohne Ergebnis beendet",
|
||||
"file.open.drawing_filter": "Designs, CAD-Dateien, Netze und Zeichnungen",
|
||||
"file.open.portal_fallback.no_portal_service": "Die geöffnete Dateiauswahl ist nicht die des Desktops: Der Dateiauswahl-Dienst des Desktops ist nicht verfügbar.",
|
||||
"file.open.portal_fallback.no_session_bus": "Die geöffnete Dateiauswahl ist nicht die des Desktops: Es gibt keinen D-Bus-Sitzungsbus.",
|
||||
"file.open.portal_fallback.xwayland": "Die geöffnete Dateiauswahl ist nicht die des Desktops: Unter XWayland lehnt das Portal das Elternfenster ab.",
|
||||
"file_load.built": "Bisher erstellt: {built} von {total} Merkmalen.",
|
||||
"file_load.converting": "Volumenkörper {done} von {total} wird konvertiert",
|
||||
"file_load.inserting": "Geometrie wird eingefügt",
|
||||
@@ -2017,6 +2019,8 @@
|
||||
"nav.blender.help": "Mittlere Maustaste dreht, Umschalt+Mitte verschiebt, Strg+Mitte zoomt; rechtes Ziehen lässt die Kamera unverändert",
|
||||
"nav.creo.help": "Ziehen mit der mittleren Maustaste dreht, Umschalt+Mitte verschiebt, Strg+Mitte zoomt beim vertikalen Ziehen (nach unten zum Vergrößern); das Mausrad zoomt",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "Ein Ziehen mit der mittleren oder rechten Taste dreht, verschiebt oder zoomt weiter wie begonnen, bis die Taste losgelassen wird, egal welche Tasten dabei gedrückt oder losgelassen werden. Aus: Die gehaltenen Tasten entscheiden in jedem Moment des Ziehens.",
|
||||
"nav.drag_keeps_mode.label": "Ziehen behält die Navigation bei, mit der es begann",
|
||||
"nav.free_orbit.help": "Maus und 3D-Maus drehen über beide Pole hinweg und behalten die Rollneigung bei. Das Einrasten mit Umschalt ist deaktiviert.",
|
||||
"nav.free_orbit.label": "Freie Drehung",
|
||||
"nav.free_orbit.snap_help": "Maus und 3D-Maus drehen über beide Pole hinweg und behalten die Rollausrichtung bei. Halten Sie beim Ziehen zum Drehen die Umschalttaste gedrückt, um Blickrichtung und Rollausrichtung einrasten zu lassen.",
|
||||
@@ -2531,6 +2535,8 @@
|
||||
"prefs.search": "Einstellungen suchen",
|
||||
"prefs.search_empty": "Keine passenden Einstellungen",
|
||||
"prefs.select": "Auswählen",
|
||||
"prefs.select_hidden_edges": "Verdeckte Kanten in der schattierten Ansicht mit verdeckten Kanten auswählen",
|
||||
"prefs.select_hidden_edges_help": "Kanten durch Flächen auswählen, wenn die schattierte Ansicht mit verdeckten Kanten aktiv ist, auch zum Verrunden. Aus behält das Auswahlverhalten von v0.30.1 bei. Ausgeblendete Körper bleiben ausgeschlossen.",
|
||||
"prefs.select_one_item": "Ein Element auswählen",
|
||||
"prefs.select_other_hidden": "Verborgene Geometrie mit „Andere auswählen“ auswählen",
|
||||
"prefs.select_other_hidden_help": "Ein: Verborgene Körper, Skizzen und verdeckte Kanten nahe dem Zeiger einbeziehen. Aus: Die ursprüngliche Liste sichtbarer Geometrie direkt unter dem Zeiger verwenden.",
|
||||
@@ -2555,6 +2561,8 @@
|
||||
"prefs.sketch.click_selects": "Klick wählt",
|
||||
"prefs.sketch.conflict_colour": "Konfliktfarbe",
|
||||
"prefs.sketch.drawing": "Zeichnen",
|
||||
"prefs.sketch.ellipse_axes": "Ellipsen mit ihren Achsen zeichnen",
|
||||
"prefs.sketch.ellipse_axes_note": "Haupt- und Nebenachse als Konstruktionslinien, damit Halbachsen und Achsen bemaßt werden können. Aus: nur die Ellipse, und D darauf ergibt ihren Nebenradius, wohin der Wert auch gezogen wird, gezeichnet und mit R beschriftet wie bisher.",
|
||||
"prefs.sketch.exit_keep": "Beibehalten",
|
||||
"prefs.sketch.exit_previous": "Zur Ansicht davor zurückkehren",
|
||||
"prefs.sketch.exit_unless_rotated": "Außer bei Drehung",
|
||||
@@ -4989,6 +4997,7 @@
|
||||
"ui.heading_construct": "KONSTRUKTION",
|
||||
"ui.heading_create": "ERSTELLEN",
|
||||
"ui.heading_create_sketch": "SKIZZE ERSTELLEN",
|
||||
"ui.heading_custom_view_navigator": "EIGENER ANSICHTSNAVIGATOR",
|
||||
"ui.heading_cylinder": "ZYLINDER",
|
||||
"ui.heading_design": "DESIGN",
|
||||
"ui.heading_draft": "ABZIEHEN",
|
||||
@@ -5296,6 +5305,8 @@
|
||||
"ui.repeat_nothing": "Noch nichts zu wiederholen: Starten Sie zuerst ein Werkzeug oder einen Dialog.",
|
||||
"ui.replace_with_link_done": "Die Kopien sind jetzt Platzierungen des verknüpften Designs.",
|
||||
"ui.report_a_bug": "Fehler melden",
|
||||
"ui.report_characters_left_one": "{count} Zeichen übrig",
|
||||
"ui.report_characters_left_other": "{count} Zeichen übrig",
|
||||
"ui.reset": "Zurücksetzen",
|
||||
"ui.reset_all": "Alle zurücksetzen",
|
||||
"ui.reset_the_settings_on_this_page": "Einstellungen auf dieser Seite zurücksetzen",
|
||||
@@ -5577,6 +5588,14 @@
|
||||
"values must be numbers or expressions": "Werte müssen Zahlen oder Ausdrücke sein",
|
||||
"view.auto_ortho_faces": "Perspektivisch beim Drehen, orthografisch auf Flächen",
|
||||
"view.render_inspector": "Render-Inspektor",
|
||||
"view_gizmo.arrows": "Drehpfeile",
|
||||
"view_gizmo.home": "Schaltfläche „Ausgangsansicht“",
|
||||
"view_gizmo.no_such_body": "Diese Konstruktion hat keinen Körper mit diesem Namen.",
|
||||
"view_gizmo.note": "Wählen Sie einen Körper in der Ansicht. Er wird mit Ihren Einstellungen und Einstellungsprofilen gespeichert und in jeder Konstruktion angezeigt. Klicken Sie auf eine seiner Flächen, um direkt darauf zu blicken.",
|
||||
"view_gizmo.texture": "Textur",
|
||||
"view_gizmo.themed": "Design",
|
||||
"view_gizmo.too_detailed": "Zu detailliert für den Ansichtsnavigator (über 10.000 Dreiecke)",
|
||||
"view_gizmo.too_thin": "Zu lang und dünn für den Ansichtsnavigator: Die dünnste Seite muss mindestens ein Fünftel der längsten sein",
|
||||
"web.files.insert_drawings_hint": "CAD-Dateien, Netze, DXF oder SVG in das geöffnete Design",
|
||||
"web.files.insert_stored_drawings_hint": "In das geöffnete Design (CAD-Dateien, Netze, DXF, SVG)",
|
||||
"web.open_full": "In SolidCraft öffnen",
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
"cmd.component_cycle_color": "Cycle Component Colour",
|
||||
"cmd.construct_point_center": "Point At Centre Of Circle/Sphere/Torus",
|
||||
"cmd.inspect_center_of_mass": "Centre of Mass",
|
||||
"cmd.inspect_colored_components": "Enable Component Colours",
|
||||
"cmd.inspect_colored_components_disable": "Disable Component Colours",
|
||||
"cmd.inspect_colored_components": "Component Colours",
|
||||
"cmd.parameters_favorite": "Favourite Parameter",
|
||||
"cmd.render_aging_describe": "Layered Surface Aging",
|
||||
"cmd.render_effects_describe": "Lens and Creative Effects",
|
||||
@@ -87,6 +86,7 @@
|
||||
"prefs.max_file_size_web": "The web app opens STEP and import files up to 512 MB and designs up to 256 MB: a browser tab can't hold larger files. The desktop app can raise these limits.",
|
||||
"prefs.megabytes": "MB",
|
||||
"prefs.network_locations_note": "For organisations that keep designs on file servers. Off: only servers you allow.",
|
||||
"prefs.select_hidden_edges_help": "Select edges through faces when Shaded with hidden edges is active, including for Fillet. Off keeps v0.30.1 selection behaviour. Hidden bodies stay unselectable.",
|
||||
"prefs.sketch.center_arc": "Centre-point arc follows the cursor",
|
||||
"prefs.sketch.conflict_colour": "Conflict colour",
|
||||
"prefs.sketch.tracking_guides": "Centre and midpoint guides",
|
||||
@@ -235,6 +235,10 @@
|
||||
"render.studio_area_help": "Up to four one-sided rectangles. Orthogonal half-edges U and V define size; U × V faces the lit side. Coordinates are world-space millimetres.",
|
||||
"render.studio_center": "Centre X, Y, Z (mm)",
|
||||
"render.studio_hdr_help": "Radiance .hdr, 2:1 panorama, up to 2048 × 1024. EXR is unavailable. The colour assumption applies only when primaries are unspecified.",
|
||||
"sketch.hint.arc.center_point": "Arc: click centre and start, go round either way and click the end, or type a signed sweep",
|
||||
"sketch.hint.circle.center": "Circle: click the centre, then a point on the circle",
|
||||
"sketch.hint.constraint.midpoint": "MidPoint: pick a point and a line, or two lines to centre the second on the first",
|
||||
"sketch.hint.rectangle.center": "Centre rectangle: click the centre, then a corner",
|
||||
"sketch_text.align_center": "Centre",
|
||||
"ui.3d_mouse_kind_cap": "Return to Centre",
|
||||
"ui.3d_mouse_looks_like_cap": "The reading stays put while you hold it, the way a Return to Centre device does.",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"Bottom Right": "Bottom Right",
|
||||
"Boundary": "Boundary",
|
||||
"Bounding box": "Bounding box",
|
||||
"Bridge": "Bridge",
|
||||
"CHECK": "CHECK",
|
||||
"COMPONENTS": "COMPONENTS",
|
||||
"CONFIGURATIONS": "CONFIGURATIONS",
|
||||
@@ -963,8 +964,7 @@
|
||||
"cmd.inspect_analysis": "View Analysis",
|
||||
"cmd.inspect_center_of_mass": "Center of Mass",
|
||||
"cmd.inspect_clearance": "Clearance",
|
||||
"cmd.inspect_colored_components": "Enable Component Colors",
|
||||
"cmd.inspect_colored_components_disable": "Disable Component Colors",
|
||||
"cmd.inspect_colored_components": "Component Colors",
|
||||
"cmd.inspect_compare": "Compare Bodies",
|
||||
"cmd.inspect_compare_picture": "Compare Picture",
|
||||
"cmd.inspect_continuity": "Continuity Analysis",
|
||||
@@ -1172,7 +1172,7 @@
|
||||
"cmd.sketch_arc_tangent": "Tangent Arc",
|
||||
"cmd.sketch_arc_three_point": "3-Point Arc",
|
||||
"cmd.sketch_auto_constrain": "AutoConstrain",
|
||||
"cmd.sketch_auto_constrain_from_datum": "AutoConstrain from datum",
|
||||
"cmd.sketch_auto_constrain_from_datum": "AutoConstrain from Datum",
|
||||
"cmd.sketch_auto_project": "Auto-Project Edges on Reference",
|
||||
"cmd.sketch_blend_curve": "Blend Curve",
|
||||
"cmd.sketch_cancel": "Cancel Sketch",
|
||||
@@ -1186,7 +1186,7 @@
|
||||
"cmd.sketch_circle_two_point": "2-Point Circle",
|
||||
"cmd.sketch_circle_two_tangent": "2-Tangent Circle",
|
||||
"cmd.sketch_constrainer": "Sketch Constrainer",
|
||||
"cmd.sketch_constraint_fix": "Fix/UnFix",
|
||||
"cmd.sketch_constraint_fix": "Fix/Unfix",
|
||||
"cmd.sketch_constraint_midpoint": "MidPoint",
|
||||
"cmd.sketch_construction": "Normal/Construction",
|
||||
"cmd.sketch_copy": "Copy Sketch Entities",
|
||||
@@ -1296,6 +1296,7 @@
|
||||
"cmd.timeline_stop": "Stop History",
|
||||
"cmd.timeline_suppress": "Suppress Feature",
|
||||
"cmd.ui.assistant": "Toggle Assistant",
|
||||
"cmd.view.navigator": "Custom View Navigator",
|
||||
"cmd.view.render_browser": "Render Browser",
|
||||
"cmd.view.render_dock": "Move Render Dock",
|
||||
"cmd.view.render_focus": "Render Focus View",
|
||||
@@ -1311,13 +1312,13 @@
|
||||
"cmd.view_front": "Front View",
|
||||
"cmd.view_graphics_preset": "Graphics Preset",
|
||||
"cmd.view_grid": "Grid",
|
||||
"cmd.view_ground_shadow": "Ground shadow",
|
||||
"cmd.view_home": "Home view",
|
||||
"cmd.view_ground_shadow": "Ground Shadow",
|
||||
"cmd.view_home": "Home View",
|
||||
"cmd.view_isometric": "Isometric View",
|
||||
"cmd.view_left": "Left View",
|
||||
"cmd.view_list": "List Named Views",
|
||||
"cmd.view_navigate": "Navigate View",
|
||||
"cmd.view_navigation_bar": "Navigation bar",
|
||||
"cmd.view_navigation_bar": "Navigation Bar",
|
||||
"cmd.view_next_tab": "Next Tab",
|
||||
"cmd.view_normal_to": "Normal to Selection",
|
||||
"cmd.view_previous_tab": "Previous Tab",
|
||||
@@ -1326,10 +1327,10 @@
|
||||
"cmd.view_right": "Right View",
|
||||
"cmd.view_save": "New Named View",
|
||||
"cmd.view_shots_strip": "Shots Strip",
|
||||
"cmd.view_spin": "Continuous orbit",
|
||||
"cmd.view_tool": "Navigation tool",
|
||||
"cmd.view_spin": "Continuous Orbit",
|
||||
"cmd.view_tool": "Navigation Tool",
|
||||
"cmd.view_top": "Top View",
|
||||
"cmd.view_visual_style": "Visual style",
|
||||
"cmd.view_visual_style": "Visual Style",
|
||||
"color.blue": "Blue",
|
||||
"color.copy": "Click to copy color values",
|
||||
"color.edit": "Click to edit color",
|
||||
@@ -1445,6 +1446,9 @@
|
||||
"each rail's curves must be in one sketch": "each rail's curves must be in one sketch",
|
||||
"feature computation ended without a result": "feature computation ended without a result",
|
||||
"file.open.drawing_filter": "Designs, CAD files, meshes and drawings",
|
||||
"file.open.portal_fallback.no_portal_service": "The file chooser that opened is not the desktop's own: the desktop portal service is not available.",
|
||||
"file.open.portal_fallback.no_session_bus": "The file chooser that opened is not the desktop's own: there is no D-Bus session bus.",
|
||||
"file.open.portal_fallback.xwayland": "The file chooser that opened is not the desktop's own: under XWayland the portal refuses the parent window.",
|
||||
"file_load.built": "Built so far: {built} of {total} features.",
|
||||
"file_load.converting": "Converting solid {done} of {total}",
|
||||
"file_load.inserting": "Inserting geometry",
|
||||
@@ -2035,6 +2039,8 @@
|
||||
"nav.blender.help": "Middle drag orbits, Shift+middle pans, Ctrl+middle zooms; right drag leaves the camera alone",
|
||||
"nav.creo.help": "Middle drag orbits, Shift+middle pans, Ctrl+middle drag vertically zooms (down to zoom in); scroll the wheel to zoom",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "A middle or right drag goes on orbiting, panning or zooming as it began until the button is released, whatever keys are pressed or let go meanwhile. Off: the keys held decide at every moment of the drag.",
|
||||
"nav.drag_keeps_mode.label": "A drag keeps the navigation it started with",
|
||||
"nav.free_orbit.help": "Mouse and 3D mouse rotate through both poles and preserve roll. Shift axis snapping is disabled.",
|
||||
"nav.free_orbit.label": "Free orbit",
|
||||
"nav.free_orbit.snap_help": "Mouse and 3D mouse rotate through both poles and preserve roll. Hold Shift during an orbit drag to snap the view direction and roll.",
|
||||
@@ -2554,6 +2560,8 @@
|
||||
"prefs.section_hatch_by_part": "By part",
|
||||
"prefs.section_hatch_one": "One style",
|
||||
"prefs.select": "Select",
|
||||
"prefs.select_hidden_edges": "Select hidden edges in Shaded with hidden edges",
|
||||
"prefs.select_hidden_edges_help": "Select edges through faces when Shaded with hidden edges is active, including for Fillet. Off keeps v0.30.1 selection behavior. Hidden bodies stay unselectable.",
|
||||
"prefs.select_one_item": "Select one item",
|
||||
"prefs.select_other_hidden": "Select hidden geometry with Select Other",
|
||||
"prefs.select_other_hidden_help": "On: include hidden bodies, sketches and occluded edges near the pointer. Off: use the original list of visible geometry under the pointer.",
|
||||
@@ -2578,6 +2586,8 @@
|
||||
"prefs.sketch.click_selects": "Click selects",
|
||||
"prefs.sketch.conflict_colour": "Conflict color",
|
||||
"prefs.sketch.drawing": "Drawing",
|
||||
"prefs.sketch.ellipse_axes": "Draw ellipses with their axes",
|
||||
"prefs.sketch.ellipse_axes_note": "The major and minor axes as construction lines, so the half-axes and axes can be dimensioned. Off: the ellipse alone, and D on it gives its minor radius wherever the value is pulled, drawn and labelled R as before.",
|
||||
"prefs.sketch.exit_keep": "Keep",
|
||||
"prefs.sketch.exit_previous": "Return to the view before",
|
||||
"prefs.sketch.exit_unless_rotated": "Unless turned",
|
||||
@@ -4168,6 +4178,32 @@
|
||||
"sketch.dof_left": "{count} degrees of freedom left",
|
||||
"sketch.dof_left_one": "{count} degree of freedom left",
|
||||
"sketch.draw_curves": "Draw as {linetype}",
|
||||
"sketch.error.closed_curve_two_crossings": "a closed curve needs two crossings to trim",
|
||||
"sketch.error.nothing_to_break": "nothing to break here",
|
||||
"sketch.error.offset_fillet_chamfer": "`{id}` is an offset, and its corners follow its source curves: round or cut the source corners before offsetting, or break the offset association first",
|
||||
"sketch.error.offset_trim": "`{id}` is an offset, and its ends follow its source curves: edit the source curves instead, or break the offset association first",
|
||||
"sketch.hint.arc.center_point": "Arc: click center and start, go round either way and click the end, or type a signed sweep",
|
||||
"sketch.hint.arc.three_point": "Arc: click start, end, then a point on the arc",
|
||||
"sketch.hint.arc3d": "3D Arc: click start, end, then a point on the arc (points may leave the sketch plane)",
|
||||
"sketch.hint.break": "Break: click a curve where it should split",
|
||||
"sketch.hint.circle.center": "Circle: click the center, then a point on the circle",
|
||||
"sketch.hint.constraint.generic": "Constraint: pick the sketch entities",
|
||||
"sketch.hint.constraint.horizontal_vertical": "Horizontal/Vertical: pick a line, two points, or a point and a line; hold Shift to pick a line midpoint",
|
||||
"sketch.hint.constraint.midpoint": "MidPoint: pick a point and a line, or two lines to center the second on the first",
|
||||
"sketch.hint.dimension": "Dimension: pick one or two entities and type the value (or click to place it first); click a dimension to edit it; Enter applies",
|
||||
"sketch.hint.extend": "Extend: click a curve near the end to extend (Shift: click two curves to extend both to where they meet)",
|
||||
"sketch.hint.fallback": "Click in the sketch",
|
||||
"sketch.hint.line": "Line: click points; right-click or Esc to finish",
|
||||
"sketch.hint.line3d": "3D Line: click world points; right-click or Esc to finish (points may leave the sketch plane)",
|
||||
"sketch.hint.open_done": "Open done",
|
||||
"sketch.hint.point3d": "3D Point: click where a 3D point goes",
|
||||
"sketch.hint.rectangle.center": "Center rectangle: click the center, then a corner",
|
||||
"sketch.hint.rectangle.rounded": "Rounded rectangle: click two opposite corners (Tab to the radius box to type the corner radius)",
|
||||
"sketch.hint.rectangle.three_point": "3-point rectangle: click two points of one edge, then the width",
|
||||
"sketch.hint.rectangle.two_point": "Rectangle: click two opposite corners",
|
||||
"sketch.hint.slot": "Slot: click both ends, then the width",
|
||||
"sketch.hint.spline3d": "3D Spline: click fit points in 3D; right-click or Esc to finish",
|
||||
"sketch.hint.trim": "Trim: click the piece of a curve to remove, or drag across the pieces to remove",
|
||||
"sketch.make_selection": "Convert the selection to {linetype}",
|
||||
"sketch.open_ends": "Open {count}",
|
||||
"sketch.status_conflict": "constraints conflict",
|
||||
@@ -5017,6 +5053,7 @@
|
||||
"ui.heading_construct": "CONSTRUCT",
|
||||
"ui.heading_create": "CREATE",
|
||||
"ui.heading_create_sketch": "CREATE SKETCH",
|
||||
"ui.heading_custom_view_navigator": "CUSTOM VIEW NAVIGATOR",
|
||||
"ui.heading_cylinder": "CYLINDER",
|
||||
"ui.heading_design": "DESIGN",
|
||||
"ui.heading_draft": "DRAFT",
|
||||
@@ -5328,6 +5365,8 @@
|
||||
"ui.repeat_nothing": "Nothing to repeat yet: start a tool or dialog first.",
|
||||
"ui.replace_with_link_done": "The copies are now placements of the linked design.",
|
||||
"ui.report_a_bug": "Report a bug",
|
||||
"ui.report_characters_left_one": "{count} character left",
|
||||
"ui.report_characters_left_other": "{count} characters left",
|
||||
"ui.reset": "Reset",
|
||||
"ui.reset_all": "Reset All",
|
||||
"ui.reset_the_settings_on_this_page": "Reset the settings on this page",
|
||||
@@ -5612,6 +5651,14 @@
|
||||
"values must be numbers or expressions": "values must be numbers or expressions",
|
||||
"view.auto_ortho_faces": "Perspective while orbiting, ortho on faces",
|
||||
"view.render_inspector": "Render Inspector",
|
||||
"view_gizmo.arrows": "Rotation arrows",
|
||||
"view_gizmo.home": "Home button",
|
||||
"view_gizmo.no_such_body": "This design has no body of that name.",
|
||||
"view_gizmo.note": "Pick a body in the view. It is kept with your preferences and settings profiles, and shown in every design. Click one of its faces to look straight at it.",
|
||||
"view_gizmo.texture": "Texture",
|
||||
"view_gizmo.themed": "Themed",
|
||||
"view_gizmo.too_detailed": "Too detailed for the view navigator (over 10,000 triangles)",
|
||||
"view_gizmo.too_thin": "Too long and thin for the view navigator: its thinnest side must be at least a fifth of its longest",
|
||||
"web.files.insert_drawings_hint": "CAD files, meshes, DXF or SVG into the open design",
|
||||
"web.files.insert_stored_drawings_hint": "Into the open design (CAD files, meshes, DXF, SVG)",
|
||||
"web.open_full": "Open in SolidCraft",
|
||||
|
||||
@@ -956,8 +956,6 @@
|
||||
"cmd.inspect_accessibility": "Analyse d'accessibilité",
|
||||
"cmd.inspect_center_of_mass": "Centre de gravité",
|
||||
"cmd.inspect_clearance": "Jeu",
|
||||
"cmd.inspect_colored_components": "Activer les couleurs des composants",
|
||||
"cmd.inspect_colored_components_disable": "Désactiver les couleurs des composants",
|
||||
"cmd.inspect_compare": "Comparer les corps",
|
||||
"cmd.inspect_compare_picture": "Comparer les images",
|
||||
"cmd.inspect_continuity": "Analyse de continuité",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Análise de accesibilidade",
|
||||
"cmd.inspect_center_of_mass": "Centro de masas",
|
||||
"cmd.inspect_clearance": "Folga",
|
||||
"cmd.inspect_colored_components": "Activar as cores dos compoñentes",
|
||||
"cmd.inspect_colored_components_disable": "Desactivar as cores dos compoñentes",
|
||||
"cmd.inspect_compare": "Comparar corpos",
|
||||
"cmd.inspect_compare_picture": "Comparar a imaxe",
|
||||
"cmd.inspect_continuity": "Análise de continuidade",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"Bottom Right": "למטה מימין",
|
||||
"Boundary": "גבול",
|
||||
"Bounding box": "תיבה תוחמת",
|
||||
"Bridge": "גשר",
|
||||
"CHECK": "בדיקה",
|
||||
"COMPONENTS": "רכיבים",
|
||||
"CONFIGURATIONS": "תצורות",
|
||||
@@ -963,8 +964,7 @@
|
||||
"cmd.inspect_analysis": "ניתוח תצוגה",
|
||||
"cmd.inspect_center_of_mass": "מרכז מסה",
|
||||
"cmd.inspect_clearance": "מרווח",
|
||||
"cmd.inspect_colored_components": "הפעלת צבעי רכיבים",
|
||||
"cmd.inspect_colored_components_disable": "ביטול צבעי רכיבים",
|
||||
"cmd.inspect_colored_components": "צבעי רכיבים",
|
||||
"cmd.inspect_compare": "השוואת גופים",
|
||||
"cmd.inspect_compare_picture": "השוואה לתמונת ייחוס",
|
||||
"cmd.inspect_continuity": "ניתוח רציפות",
|
||||
@@ -1296,6 +1296,7 @@
|
||||
"cmd.timeline_stop": "עצירת ציר הזמן",
|
||||
"cmd.timeline_suppress": "השבתת פיצ'ר",
|
||||
"cmd.ui.assistant": "הצגה או הסתרה של העוזר",
|
||||
"cmd.view.navigator": "ניווט תצוגה מותאם אישית",
|
||||
"cmd.view.render_browser": "דפדפן רינדור",
|
||||
"cmd.view.render_dock": "הזז את עגינת הרינדור",
|
||||
"cmd.view.render_focus": "תצוגת מיקוד רינדור",
|
||||
@@ -1445,6 +1446,9 @@
|
||||
"each rail's curves must be in one sketch": "עקומות כל מסילה חייבות להיות בסקיצה אחת",
|
||||
"feature computation ended without a result": "חישוב הפיצ'ר הסתיים ללא תוצאה",
|
||||
"file.open.drawing_filter": "תכנים, קובצי CAD, רשתות משולשים ושרטוטים",
|
||||
"file.open.portal_fallback.no_portal_service": "בורר הקבצים שנפתח אינו של שולחן העבודה: שירות בחירת הקבצים של שולחן העבודה אינו זמין.",
|
||||
"file.open.portal_fallback.no_session_bus": "בורר הקבצים שנפתח אינו של שולחן העבודה: אין אוטובוס הפעלה של D-Bus.",
|
||||
"file.open.portal_fallback.xwayland": "בורר הקבצים שנפתח אינו של שולחן העבודה: תחת XWayland הפורטל דוחה את חלון האב.",
|
||||
"file_load.built": "נבנו עד כה: {built} מתוך {total} פיצ'רים.",
|
||||
"file_load.converting": "המרת גוף מוצק {done} מתוך {total}",
|
||||
"file_load.inserting": "הוספת גאומטריה",
|
||||
@@ -2035,6 +2039,8 @@
|
||||
"nav.blender.help": "גרירה אמצעית מסובבת, Shift וגרירה אמצעית מזיזים, Ctrl וגרירה אמצעית מבצעים זום; גרירה ימנית לא מזיזה את המצלמה",
|
||||
"nav.creo.help": "גרירה בלחצן האמצעי מסובבת את התצוגה, Shift והלחצן האמצעי מזיזים אותה, Ctrl וגרירה אנכית בלחצן האמצעי משנים את הזום (גרירה מטה להגדלה); גלילת הגלגלת משנה גם היא את הזום",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "גרירה בכפתור האמצעי או הימני ממשיכה לסובב, להזיז או לשנות זום כפי שהתחילה עד שמשחררים את הכפתור, בלי קשר למקשים שנלחצים או משתחררים בינתיים. כבוי: המקשים הלחוצים קובעים בכל רגע של הגרירה.",
|
||||
"nav.drag_keeps_mode.label": "גרירה שומרת על הניווט שבו התחילה",
|
||||
"nav.free_orbit.help": "העכבר והעכבר התלת־ממדי מסובבים דרך שני הקטבים ושומרים על הגלגול. הצמדת הצירים עם Shift מושבתת.",
|
||||
"nav.free_orbit.label": "סיבוב חופשי",
|
||||
"nav.free_orbit.snap_help": "העכבר והעכבר התלת־ממדי מסובבים דרך שני הקטבים ושומרים על הגלגול. יש להחזיק את Shift בזמן גרירת סיבוב כדי להצמיד את כיוון התצוגה ואת הגלגול.",
|
||||
@@ -2554,6 +2560,8 @@
|
||||
"prefs.section_hatch_by_part": "לפי חלק",
|
||||
"prefs.section_hatch_one": "סגנון אחד",
|
||||
"prefs.select": "בחירה",
|
||||
"prefs.select_hidden_edges": "בחירת קצוות מוסתרים בתצוגה מוצללת עם קצוות מוסתרים",
|
||||
"prefs.select_hidden_edges_help": "מאפשר לבחור קצוות דרך פאות בתצוגה מוצללת עם קצוות מוסתרים, גם עבור Fillet. כיבוי שומר על אופן הבחירה של v0.30.1. גופים שהוסתרו עדיין אינם ניתנים לבחירה.",
|
||||
"prefs.select_one_item": "בחירת פריט אחד",
|
||||
"prefs.select_other_hidden": "בחירת גאומטריה מוסתרת באמצעות בחירה אחרת",
|
||||
"prefs.select_other_hidden_help": "מופעל: כולל גופים, סקיצות וקצוות מוסתרים בקרבת הסמן. כבוי: שימוש ברשימה המקורית של גאומטריה גלויה מתחת לסמן.",
|
||||
@@ -2578,6 +2586,8 @@
|
||||
"prefs.sketch.click_selects": "לחיצה בוחרת",
|
||||
"prefs.sketch.conflict_colour": "צבע התנגשות",
|
||||
"prefs.sketch.drawing": "שרטוט",
|
||||
"prefs.sketch.ellipse_axes": "שרטוט אליפסות עם הצירים שלהן",
|
||||
"prefs.sketch.ellipse_axes_note": "הציר הראשי והציר המשני כקווי עזר, כדי שאפשר יהיה לתת מידות לחצאי הצירים ולצירים. כבוי: האליפסה בלבד, ו-D עליה נותן את הרדיוס המשני שלה בכל מקום שאליו נגרר הערך, משורטט ומסומן R כמו קודם.",
|
||||
"prefs.sketch.exit_keep": "שמירה",
|
||||
"prefs.sketch.exit_previous": "חזרה לתצוגה הקודמת",
|
||||
"prefs.sketch.exit_unless_rotated": "אלא אם סובבה",
|
||||
@@ -4168,6 +4178,32 @@
|
||||
"sketch.dof_left": "נותרו {count} דרגות חופש",
|
||||
"sketch.dof_left_one": "נותרה {count} דרגת חופש",
|
||||
"sketch.draw_curves": "שרטוט כ־{linetype}",
|
||||
"sketch.error.closed_curve_two_crossings": "a closed curve needs two crossings to trim",
|
||||
"sketch.error.nothing_to_break": "nothing to break here",
|
||||
"sketch.error.offset_fillet_chamfer": "`{id}` is an offset, and its corners follow its source curves: round or cut the source corners before offsetting, or break the offset association first",
|
||||
"sketch.error.offset_trim": "`{id}` is an offset, and its ends follow its source curves: edit the source curves instead, or break the offset association first",
|
||||
"sketch.hint.arc.center_point": "Arc: click center and start, go round either way and click the end, or type a signed sweep",
|
||||
"sketch.hint.arc.three_point": "Arc: click start, end, then a point on the arc",
|
||||
"sketch.hint.arc3d": "3D Arc: click start, end, then a point on the arc (points may leave the sketch plane)",
|
||||
"sketch.hint.break": "Break: click a curve where it should split",
|
||||
"sketch.hint.circle.center": "Circle: click the center, then a point on the circle",
|
||||
"sketch.hint.constraint.generic": "Constraint: pick the sketch entities",
|
||||
"sketch.hint.constraint.horizontal_vertical": "Horizontal/Vertical: pick a line, two points, or a point and a line; hold Shift to pick a line midpoint",
|
||||
"sketch.hint.constraint.midpoint": "MidPoint: pick a point and a line, or two lines to center the second on the first",
|
||||
"sketch.hint.dimension": "Dimension: pick one or two entities and type the value (or click to place it first); click a dimension to edit it; Enter applies",
|
||||
"sketch.hint.extend": "Extend: click a curve near the end to extend (Shift: click two curves to extend both to where they meet)",
|
||||
"sketch.hint.fallback": "Click in the sketch",
|
||||
"sketch.hint.line": "Line: click points; right-click or Esc to finish",
|
||||
"sketch.hint.line3d": "3D Line: click world points; right-click or Esc to finish (points may leave the sketch plane)",
|
||||
"sketch.hint.open_done": "Open done",
|
||||
"sketch.hint.point3d": "3D Point: click where a 3D point goes",
|
||||
"sketch.hint.rectangle.center": "Center rectangle: click the center, then a corner",
|
||||
"sketch.hint.rectangle.rounded": "Rounded rectangle: click two opposite corners (Tab to the radius box to type the corner radius)",
|
||||
"sketch.hint.rectangle.three_point": "3-point rectangle: click two points of one edge, then the width",
|
||||
"sketch.hint.rectangle.two_point": "Rectangle: click two opposite corners",
|
||||
"sketch.hint.slot": "Slot: click both ends, then the width",
|
||||
"sketch.hint.spline3d": "3D Spline: click fit points in 3D; right-click or Esc to finish",
|
||||
"sketch.hint.trim": "Trim: click the piece of a curve to remove, or drag across the pieces to remove",
|
||||
"sketch.make_selection": "המרת הבחירה ל־{linetype}",
|
||||
"sketch.open_ends": "קצוות פתוחים: {count}",
|
||||
"sketch.status_conflict": "אילוצים סותרים",
|
||||
@@ -5017,6 +5053,7 @@
|
||||
"ui.heading_construct": "עזר",
|
||||
"ui.heading_create": "יצירה",
|
||||
"ui.heading_create_sketch": "יצירת סקיצה",
|
||||
"ui.heading_custom_view_navigator": "ניווט תצוגה מותאם אישית",
|
||||
"ui.heading_cylinder": "גליל",
|
||||
"ui.heading_design": "תכן",
|
||||
"ui.heading_draft": "שיפוע יציקה",
|
||||
@@ -5328,6 +5365,8 @@
|
||||
"ui.repeat_nothing": "אין עדיין מה לחזור עליו: התחל קודם כלי או תיבת דו־שיח.",
|
||||
"ui.replace_with_link_done": "העותקים הם עכשיו מיקומים של התכן המקושר.",
|
||||
"ui.report_a_bug": "דיווח על באג",
|
||||
"ui.report_characters_left_one": "תווים שנותרו: {count}",
|
||||
"ui.report_characters_left_other": "תווים שנותרו: {count}",
|
||||
"ui.reset": "איפוס",
|
||||
"ui.reset_all": "איפוס הכול",
|
||||
"ui.reset_the_settings_on_this_page": "איפוס ההגדרות בדף זה",
|
||||
@@ -5612,6 +5651,14 @@
|
||||
"values must be numbers or expressions": "הערכים חייבים להיות מספרים או ביטויים",
|
||||
"view.auto_ortho_faces": "פרספקטיבה בזמן סיבוב, אורתוגרפי על פאות",
|
||||
"view.render_inspector": "מפקח רינדור",
|
||||
"view_gizmo.arrows": "חיצי סיבוב",
|
||||
"view_gizmo.home": "לחצן תצוגת בית",
|
||||
"view_gizmo.no_such_body": "אין בעיצוב הזה גוף בשם הזה.",
|
||||
"view_gizmo.note": "בחרו גוף בתצוגה. הוא נשמר עם ההעדפות ופרופילי ההגדרות שלכם ומוצג בכל עיצוב. לחצו על אחת מפאותיו כדי להביט בה ישירות.",
|
||||
"view_gizmo.texture": "מרקם",
|
||||
"view_gizmo.themed": "לפי ערכת הנושא",
|
||||
"view_gizmo.too_detailed": "מפורט מדי לניווט התצוגה (יותר מ-10,000 משולשים)",
|
||||
"view_gizmo.too_thin": "ארוך ודק מדי לניווט התצוגה: הצד הדק ביותר חייב להיות לפחות חמישית מהצד הארוך ביותר",
|
||||
"web.files.insert_drawings_hint": "קובצי CAD, רשתות משולשים, DXF או SVG אל התכן הפתוח",
|
||||
"web.files.insert_stored_drawings_hint": "אל התכן הפתוח (קובצי CAD, רשתות משולשים, DXF, SVG)",
|
||||
"web.open_full": "פתיחה ב־SolidCraft",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Analiza dostupnosti",
|
||||
"cmd.inspect_center_of_mass": "Središte mase",
|
||||
"cmd.inspect_clearance": "Provjera zazora",
|
||||
"cmd.inspect_colored_components": "Omogući boje komponenti",
|
||||
"cmd.inspect_colored_components_disable": "Onemogući boje komponenti",
|
||||
"cmd.inspect_compare": "Usporedi tijela",
|
||||
"cmd.inspect_compare_picture": "Usporedi sliku",
|
||||
"cmd.inspect_continuity": "Analiza kontinuiteta",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Hozzáférhetőség-elemzés",
|
||||
"cmd.inspect_center_of_mass": "Tömegközéppont",
|
||||
"cmd.inspect_clearance": "Hézag",
|
||||
"cmd.inspect_colored_components": "Komponensszínek bekapcsolása",
|
||||
"cmd.inspect_colored_components_disable": "Komponensszínek kikapcsolása",
|
||||
"cmd.inspect_compare": "Testek összehasonlítása",
|
||||
"cmd.inspect_compare_picture": "Kép összehasonlítása",
|
||||
"cmd.inspect_continuity": "Folytonosságelemzés",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Analisis Aksesibilitas",
|
||||
"cmd.inspect_center_of_mass": "Pusat Massa",
|
||||
"cmd.inspect_clearance": "Kelonggaran",
|
||||
"cmd.inspect_colored_components": "Aktifkan Warna Komponen",
|
||||
"cmd.inspect_colored_components_disable": "Nonaktifkan Warna Komponen",
|
||||
"cmd.inspect_compare": "Bandingkan Bodi",
|
||||
"cmd.inspect_compare_picture": "Bandingkan dengan Gambar",
|
||||
"cmd.inspect_continuity": "Analisis Kontinuitas",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Analisi di accessibilità",
|
||||
"cmd.inspect_center_of_mass": "Centro di massa",
|
||||
"cmd.inspect_clearance": "Distanza libera",
|
||||
"cmd.inspect_colored_components": "Attiva colori dei componenti",
|
||||
"cmd.inspect_colored_components_disable": "Disattiva colori dei componenti",
|
||||
"cmd.inspect_compare": "Confronta corpi",
|
||||
"cmd.inspect_compare_picture": "Confronta immagine",
|
||||
"cmd.inspect_continuity": "Analisi di continuità",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"Bottom Right": "右下",
|
||||
"Boundary": "境界",
|
||||
"Bounding box": "境界ボックス",
|
||||
"Bridge": "ブリッジ",
|
||||
"CHECK": "チェック",
|
||||
"COMPONENTS": "コンポーネント",
|
||||
"CONFIGURATIONS": "構成",
|
||||
@@ -963,8 +964,7 @@
|
||||
"cmd.inspect_analysis": "表示解析",
|
||||
"cmd.inspect_center_of_mass": "重心",
|
||||
"cmd.inspect_clearance": "クリアランス",
|
||||
"cmd.inspect_colored_components": "コンポーネントの色分けを有効化",
|
||||
"cmd.inspect_colored_components_disable": "コンポーネントの色分けを無効化",
|
||||
"cmd.inspect_colored_components": "コンポーネントの色分け",
|
||||
"cmd.inspect_compare": "ボディを比較",
|
||||
"cmd.inspect_compare_picture": "参考画像と比較",
|
||||
"cmd.inspect_continuity": "連続性解析",
|
||||
@@ -1296,6 +1296,7 @@
|
||||
"cmd.timeline_stop": "履歴を停止",
|
||||
"cmd.timeline_suppress": "フィーチャーを抑制",
|
||||
"cmd.ui.assistant": "アシスタントの表示切り替え",
|
||||
"cmd.view.navigator": "カスタム ビューナビゲーター",
|
||||
"cmd.view.render_browser": "Renderブラウザー",
|
||||
"cmd.view.render_dock": "レンダードックを移動",
|
||||
"cmd.view.render_focus": "Renderフォーカス表示",
|
||||
@@ -1445,6 +1446,9 @@
|
||||
"each rail's curves must be in one sketch": "各レールの曲線は1つのスケッチ内にある必要があります",
|
||||
"feature computation ended without a result": "フィーチャーの計算が結果なしで終了しました",
|
||||
"file.open.drawing_filter": "デザイン、CADファイル、メッシュ、図面",
|
||||
"file.open.portal_fallback.no_portal_service": "開いたファイル選択はデスクトップのものではありません。デスクトップのファイル選択サービスが利用できません。",
|
||||
"file.open.portal_fallback.no_session_bus": "開いたファイル選択はデスクトップのものではありません。D-Bus セッションがありません。",
|
||||
"file.open.portal_fallback.xwayland": "開いたファイル選択はデスクトップのものではありません。XWayland ではポータルが親ウィンドウを拒否します。",
|
||||
"file_load.built": "構築済み: 全{total}フィーチャー中{built}件。",
|
||||
"file_load.converting": "ソリッドを変換中: {done}/{total}",
|
||||
"file_load.inserting": "ジオメトリを挿入中",
|
||||
@@ -2035,6 +2039,8 @@
|
||||
"nav.blender.help": "中ドラッグで回転、Shift+中ドラッグでパン、Ctrl+中ドラッグでズーム。右ドラッグではカメラは動きません。",
|
||||
"nav.creo.help": "マウスの中ボタンドラッグで回転、Shift+中ボタンで平行移動、Ctrl+中ボタンの上下ドラッグでズーム(下方向で拡大)。ホイールの回転でもズーム",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "中ボタンまたは右ボタンのドラッグは、途中でキーを押したり離したりしても、ボタンを離すまで開始時の回転・パン・ズームを続けます。オフにすると、ドラッグ中の各時点で押しているキーによって決まります。",
|
||||
"nav.drag_keeps_mode.label": "ドラッグは開始時のナビゲーションを維持",
|
||||
"nav.free_orbit.help": "マウスと3Dマウスで、極点を越えて回転し、ロールを保ちます。\nShiftによる軸スナップは無効になります。",
|
||||
"nav.free_orbit.label": "自由回転",
|
||||
"nav.free_orbit.snap_help": "マウスと3Dマウスで両極を越えて回転でき、ロールも保持されます。オービットのドラッグ中にShiftを押すと、視線方向とロールがスナップします。",
|
||||
@@ -2554,6 +2560,8 @@
|
||||
"prefs.section_hatch_by_part": "部品ごと",
|
||||
"prefs.section_hatch_one": "単一スタイル",
|
||||
"prefs.select": "選択",
|
||||
"prefs.select_hidden_edges": "隠線表示で隠れた辺を選択する",
|
||||
"prefs.select_hidden_edges_help": "「Shaded with hidden edges」で面の向こうの辺を選択し、Filletにも使用できます。オフではv0.30.1相当の選択動作になります。非表示のボディは選択対象になりません。",
|
||||
"prefs.select_one_item": "項目を 1 つ選択",
|
||||
"prefs.select_other_hidden": "「他を選択」で非表示のジオメトリを選択",
|
||||
"prefs.select_other_hidden_help": "オン: ポインター付近の非表示のボディやスケッチ、遮られたエッジを含めます。オフ: ポインター直下の表示中のジオメトリだけを元のリストに表示します。",
|
||||
@@ -2578,6 +2586,8 @@
|
||||
"prefs.sketch.click_selects": "クリックで選択",
|
||||
"prefs.sketch.conflict_colour": "競合色",
|
||||
"prefs.sketch.drawing": "作図",
|
||||
"prefs.sketch.ellipse_axes": "楕円を軸と一緒に描く",
|
||||
"prefs.sketch.ellipse_axes_note": "長軸と短軸をコンストラクション線として描き、半軸と軸に寸法を付けられるようにします。オフ: 楕円のみを描き、D で短半径を寸法にします。値をどこへ引いても、これまでどおり R 付きで描かれます。",
|
||||
"prefs.sketch.exit_keep": "維持",
|
||||
"prefs.sketch.exit_previous": "開始前のビューに戻る",
|
||||
"prefs.sketch.exit_unless_rotated": "回転した場合を除く",
|
||||
@@ -4168,6 +4178,32 @@
|
||||
"sketch.dof_left": "残り自由度 {count}",
|
||||
"sketch.dof_left_one": "残り自由度 {count}",
|
||||
"sketch.draw_curves": "{linetype}として描く",
|
||||
"sketch.error.closed_curve_two_crossings": "a closed curve needs two crossings to trim",
|
||||
"sketch.error.nothing_to_break": "nothing to break here",
|
||||
"sketch.error.offset_fillet_chamfer": "`{id}` is an offset, and its corners follow its source curves: round or cut the source corners before offsetting, or break the offset association first",
|
||||
"sketch.error.offset_trim": "`{id}` is an offset, and its ends follow its source curves: edit the source curves instead, or break the offset association first",
|
||||
"sketch.hint.arc.center_point": "Arc: click center and start, go round either way and click the end, or type a signed sweep",
|
||||
"sketch.hint.arc.three_point": "Arc: click start, end, then a point on the arc",
|
||||
"sketch.hint.arc3d": "3D Arc: click start, end, then a point on the arc (points may leave the sketch plane)",
|
||||
"sketch.hint.break": "Break: click a curve where it should split",
|
||||
"sketch.hint.circle.center": "Circle: click the center, then a point on the circle",
|
||||
"sketch.hint.constraint.generic": "Constraint: pick the sketch entities",
|
||||
"sketch.hint.constraint.horizontal_vertical": "Horizontal/Vertical: pick a line, two points, or a point and a line; hold Shift to pick a line midpoint",
|
||||
"sketch.hint.constraint.midpoint": "MidPoint: pick a point and a line, or two lines to center the second on the first",
|
||||
"sketch.hint.dimension": "Dimension: pick one or two entities and type the value (or click to place it first); click a dimension to edit it; Enter applies",
|
||||
"sketch.hint.extend": "Extend: click a curve near the end to extend (Shift: click two curves to extend both to where they meet)",
|
||||
"sketch.hint.fallback": "Click in the sketch",
|
||||
"sketch.hint.line": "Line: click points; right-click or Esc to finish",
|
||||
"sketch.hint.line3d": "3D Line: click world points; right-click or Esc to finish (points may leave the sketch plane)",
|
||||
"sketch.hint.open_done": "Open done",
|
||||
"sketch.hint.point3d": "3D Point: click where a 3D point goes",
|
||||
"sketch.hint.rectangle.center": "Center rectangle: click the center, then a corner",
|
||||
"sketch.hint.rectangle.rounded": "Rounded rectangle: click two opposite corners (Tab to the radius box to type the corner radius)",
|
||||
"sketch.hint.rectangle.three_point": "3-point rectangle: click two points of one edge, then the width",
|
||||
"sketch.hint.rectangle.two_point": "Rectangle: click two opposite corners",
|
||||
"sketch.hint.slot": "Slot: click both ends, then the width",
|
||||
"sketch.hint.spline3d": "3D Spline: click fit points in 3D; right-click or Esc to finish",
|
||||
"sketch.hint.trim": "Trim: click the piece of a curve to remove, or drag across the pieces to remove",
|
||||
"sketch.make_selection": "選択を{linetype}にする",
|
||||
"sketch.open_ends": "開放 {count}",
|
||||
"sketch.status_conflict": "拘束が競合しています",
|
||||
@@ -5017,6 +5053,7 @@
|
||||
"ui.heading_construct": "構築",
|
||||
"ui.heading_create": "作成",
|
||||
"ui.heading_create_sketch": "スケッチを作成",
|
||||
"ui.heading_custom_view_navigator": "カスタム ビューナビゲーター",
|
||||
"ui.heading_cylinder": "円柱",
|
||||
"ui.heading_design": "デザイン",
|
||||
"ui.heading_draft": "勾配",
|
||||
@@ -5328,6 +5365,8 @@
|
||||
"ui.repeat_nothing": "まだ繰り返すものがありません。先にツールかダイアログを開始してください。",
|
||||
"ui.replace_with_link_done": "コピーはリンクされたデザインの配置になりました。",
|
||||
"ui.report_a_bug": "不具合を報告",
|
||||
"ui.report_characters_left_one": "残り {count} 文字",
|
||||
"ui.report_characters_left_other": "残り {count} 文字",
|
||||
"ui.reset": "リセット",
|
||||
"ui.reset_all": "すべてリセット",
|
||||
"ui.reset_the_settings_on_this_page": "このページの設定をリセット",
|
||||
@@ -5612,6 +5651,14 @@
|
||||
"values must be numbers or expressions": "値は数値または式にしてください",
|
||||
"view.auto_ortho_faces": "回転中は透視投影、面を正面に見ると平行投影",
|
||||
"view.render_inspector": "レンダーインスペクター",
|
||||
"view_gizmo.arrows": "回転矢印",
|
||||
"view_gizmo.home": "ホーム ボタン",
|
||||
"view_gizmo.no_such_body": "このデザインにその名前のボディはありません。",
|
||||
"view_gizmo.note": "ビューでボディを選択してください。ボディは環境設定と設定プロファイルに保存され、すべてのデザインで表示されます。面をクリックすると、その面を正面から見ます。",
|
||||
"view_gizmo.texture": "テクスチャ",
|
||||
"view_gizmo.themed": "テーマ",
|
||||
"view_gizmo.too_detailed": "ビューナビゲーターには細かすぎます (10,000 三角形を超えています)",
|
||||
"view_gizmo.too_thin": "ビューナビゲーターには細長すぎます: 最も薄い辺が最も長い辺の 5 分の 1 以上である必要があります",
|
||||
"web.files.insert_drawings_hint": "CADファイル、メッシュ、DXF、SVGを開いているデザインに挿入",
|
||||
"web.files.insert_stored_drawings_hint": "開いているデザインに挿入(CADファイル、メッシュ、DXF、SVG)",
|
||||
"web.open_full": "SolidCraft で開く",
|
||||
|
||||
@@ -963,8 +963,7 @@
|
||||
"cmd.inspect_analysis": "ანალიზის ნახვა",
|
||||
"cmd.inspect_center_of_mass": "მასის ცენტრი",
|
||||
"cmd.inspect_clearance": "ღრეჩო",
|
||||
"cmd.inspect_colored_components": "კომპონენტების ფერების ჩართვა",
|
||||
"cmd.inspect_colored_components_disable": "კომპონენტების ფერების გამორთვა",
|
||||
"cmd.inspect_colored_components": "კომპონენტების ფერები",
|
||||
"cmd.inspect_compare": "სხეულების შედარება",
|
||||
"cmd.inspect_compare_picture": "სურათთან შედარება",
|
||||
"cmd.inspect_continuity": "უწყვეტობის ანალიზი",
|
||||
|
||||
@@ -1133,6 +1133,7 @@
|
||||
"cmd.timeline_stop": "기록 재생 중지",
|
||||
"cmd.timeline_suppress": "특성 비활성화",
|
||||
"cmd.ui.assistant": "도우미 표시 전환",
|
||||
"cmd.view.navigator": "사용자 지정 뷰 탐색기",
|
||||
"cmd.view.render_browser": "렌더 브라우저",
|
||||
"cmd.view.render_dock": "렌더 도크 이동",
|
||||
"cmd.view.render_focus": "렌더 집중 보기",
|
||||
@@ -1240,6 +1241,9 @@
|
||||
"dxf.tolerance_help": "표시된 바디와 스케치만 내보내며 곡선은 직선 구간으로 근사합니다. 허용 오차가 작을수록 곡선이 매끄러워지지만 처리 시간과 메모리 사용량이 늘어납니다.",
|
||||
"each rail's curves must be in one sketch": "각 레일의 곡선은 하나의 스케치 안에 있어야 합니다",
|
||||
"feature computation ended without a result": "특성 계산이 결과 없이 끝났습니다",
|
||||
"file.open.portal_fallback.no_portal_service": "열린 파일 선택은 데스크톱의 것이 아닙니다: 데스크톱의 파일 선택 서비스를 사용할 수 없습니다.",
|
||||
"file.open.portal_fallback.no_session_bus": "열린 파일 선택은 데스크톱의 것이 아닙니다: D-Bus 세션 버스가 없습니다.",
|
||||
"file.open.portal_fallback.xwayland": "열린 파일 선택은 데스크톱의 것이 아닙니다: XWayland에서는 포털이 부모 창을 거부합니다.",
|
||||
"file_load.built": "지금까지 빌드됨: 피처 {total}개 중 {built}개.",
|
||||
"file_load.converting": "솔리드 변환 중 {done}/{total}",
|
||||
"file_load.inserting": "기하 삽입 중",
|
||||
@@ -1461,6 +1465,8 @@
|
||||
"nav.blender.help": "가운데 드래그는 회전, Shift+가운데 드래그는 이동, Ctrl+가운데 드래그는 확대/축소입니다. 오른쪽 드래그는 카메라에 영향을 주지 않습니다",
|
||||
"nav.creo.help": "가운데 버튼을 끌면 회전, Shift+가운데 버튼은 이동, Ctrl+가운데 버튼을 위아래로 끌면 확대/축소합니다(아래로 끌면 확대). 휠을 굴려도 확대/축소합니다",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "가운데 또는 오른쪽 버튼 드래그는 도중에 키를 누르거나 떼어도 버튼을 놓을 때까지 시작할 때의 회전, 이동 또는 확대/축소를 계속합니다. 끄면 드래그하는 동안 누르고 있는 키가 매 순간 결정합니다.",
|
||||
"nav.drag_keeps_mode.label": "드래그는 시작할 때의 탐색 방식을 유지",
|
||||
"nav.free_orbit.help": "마우스와 3D 마우스로 롤을 유지하며 양 극점을 넘어 회전합니다. Shift 축 스냅은 비활성화됩니다.",
|
||||
"nav.free_orbit.label": "자유 회전",
|
||||
"nav.free_orbit.snap_help": "마우스와 3D 마우스로 양쪽 극점을 지나 회전할 수 있으며 롤 각도가 유지됩니다. 궤도 회전 드래그 중 Shift를 누르면 보기 방향과 롤 각도가 스냅됩니다.",
|
||||
@@ -1889,6 +1895,8 @@
|
||||
"prefs.search": "설정 검색",
|
||||
"prefs.search_empty": "일치하는 설정이 없습니다",
|
||||
"prefs.select": "선택",
|
||||
"prefs.select_hidden_edges": "숨은 모서리가 표시된 음영 뷰에서 숨은 모서리 선택",
|
||||
"prefs.select_hidden_edges_help": "숨은 모서리가 표시된 음영 뷰에서 면 뒤의 모서리를 선택하여 필렛에 사용할 수 있습니다. 끄면 v0.30.1의 선택 동작을 유지합니다. 숨긴 바디는 선택되지 않습니다.",
|
||||
"prefs.select_one_item": "항목 하나 선택",
|
||||
"prefs.select_other_hidden": "다른 항목 선택으로 숨겨진 형상 선택",
|
||||
"prefs.select_other_hidden_help": "켜짐: 포인터 근처의 숨겨진 바디, 스케치 및 가려진 모서리를 포함합니다. 꺼짐: 포인터 바로 아래에 보이는 형상만 포함하는 기존 목록을 사용합니다.",
|
||||
@@ -1913,6 +1921,8 @@
|
||||
"prefs.sketch.click_selects": "클릭으로 선택",
|
||||
"prefs.sketch.conflict_colour": "충돌 색상",
|
||||
"prefs.sketch.drawing": "그리기",
|
||||
"prefs.sketch.ellipse_axes": "타원을 축과 함께 그리기",
|
||||
"prefs.sketch.ellipse_axes_note": "장축과 단축을 구성선으로 그려 반축과 축에 치수를 지정할 수 있습니다. 끄면: 타원만 그리며, D는 값을 어디로 끌든 단반경을 주며, 이전처럼 R로 표시되어 그려집니다.",
|
||||
"prefs.sketch.exit_keep": "유지",
|
||||
"prefs.sketch.exit_previous": "이전 뷰로 돌아가기",
|
||||
"prefs.sketch.exit_unless_rotated": "회전하지 않았다면",
|
||||
@@ -3784,6 +3794,7 @@
|
||||
"ui.heading_construct": "구성",
|
||||
"ui.heading_create": "만들기",
|
||||
"ui.heading_create_sketch": "스케치 만들기",
|
||||
"ui.heading_custom_view_navigator": "사용자 지정 뷰 탐색기",
|
||||
"ui.heading_cylinder": "원통",
|
||||
"ui.heading_design": "디자인",
|
||||
"ui.heading_draft": "구배",
|
||||
@@ -4311,5 +4322,13 @@
|
||||
"values must be finite numbers": "값은 유한한 숫자여야 합니다",
|
||||
"values must be numbers or expressions": "값은 숫자 또는 식이어야 합니다",
|
||||
"view.render_inspector": "렌더 검사기",
|
||||
"view_gizmo.arrows": "회전 화살표",
|
||||
"view_gizmo.home": "홈 버튼",
|
||||
"view_gizmo.no_such_body": "이 디자인에 그런 이름의 바디가 없습니다.",
|
||||
"view_gizmo.note": "뷰에서 바디를 선택하십시오. 바디는 환경설정과 설정 프로필에 저장되어 모든 디자인에 표시됩니다. 면을 클릭하면 그 면을 정면으로 봅니다.",
|
||||
"view_gizmo.texture": "텍스처",
|
||||
"view_gizmo.themed": "테마",
|
||||
"view_gizmo.too_detailed": "뷰 탐색기에 너무 세밀합니다 (삼각형 10,000개 초과)",
|
||||
"view_gizmo.too_thin": "뷰 탐색기에 너무 가늘고 깁니다: 가장 얇은 변이 가장 긴 변의 5분의 1 이상이어야 합니다",
|
||||
"↑ ↓ choose · Enter / Tab complete · Esc dismiss": "↑ ↓ 선택 · Enter / Tab 완성 · Esc 닫기"
|
||||
}
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Analisis Kebolehcapaian",
|
||||
"cmd.inspect_center_of_mass": "Pusat Jisim",
|
||||
"cmd.inspect_clearance": "Kelegaan",
|
||||
"cmd.inspect_colored_components": "Aktifkan Warna Komponen",
|
||||
"cmd.inspect_colored_components_disable": "Nyahaktifkan Warna Komponen",
|
||||
"cmd.inspect_compare": "Bandingkan Jasad",
|
||||
"cmd.inspect_compare_picture": "Banding dengan Imej",
|
||||
"cmd.inspect_continuity": "Analisis Keselanjaran",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Tilgjengelighetsanalyse",
|
||||
"cmd.inspect_center_of_mass": "Massesenter",
|
||||
"cmd.inspect_clearance": "Klaring",
|
||||
"cmd.inspect_colored_components": "Aktiver komponentfarger",
|
||||
"cmd.inspect_colored_components_disable": "Deaktiver komponentfarger",
|
||||
"cmd.inspect_compare": "Sammenlign kropper",
|
||||
"cmd.inspect_compare_picture": "Sammenlign bilde",
|
||||
"cmd.inspect_continuity": "Kontinuitetsanalyse",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Toegankelijkheidsanalyse",
|
||||
"cmd.inspect_center_of_mass": "Zwaartepunt",
|
||||
"cmd.inspect_clearance": "Speling",
|
||||
"cmd.inspect_colored_components": "Componentkleuren inschakelen",
|
||||
"cmd.inspect_colored_components_disable": "Componentkleuren uitschakelen",
|
||||
"cmd.inspect_compare": "Lichamen vergelijken",
|
||||
"cmd.inspect_compare_picture": "Afbeelding vergelijken",
|
||||
"cmd.inspect_continuity": "Continuïteitsanalyse",
|
||||
|
||||
@@ -934,8 +934,6 @@
|
||||
"cmd.inspect_accessibility": "Analiza dostępności",
|
||||
"cmd.inspect_center_of_mass": "Środek masy",
|
||||
"cmd.inspect_clearance": "Prześwit",
|
||||
"cmd.inspect_colored_components": "Włącz kolory komponentów",
|
||||
"cmd.inspect_colored_components_disable": "Wyłącz kolory komponentów",
|
||||
"cmd.inspect_compare": "Porównaj bryły",
|
||||
"cmd.inspect_continuity": "Analiza ciągłości",
|
||||
"cmd.inspect_curvature_comb": "Analiza grzebienia krzywizny",
|
||||
@@ -1986,6 +1984,8 @@
|
||||
"prefs.shortcuts": "Skróty",
|
||||
"prefs.single_surface_analysis": "Używaj jednej analizy powierzchni",
|
||||
"prefs.single_surface_analysis_help": "Gdy wyłączone, cieniowanie powierzchni i Ciągłość mogą być włączone jednocześnie. Włączenie zachowuje ostatnio uruchomioną lub zmienioną analizę.",
|
||||
"prefs.sketch.ellipse_axes": "Rysuj elipsy z osiami",
|
||||
"prefs.sketch.ellipse_axes_note": "Oś wielka i mała jako linie konstrukcyjne, aby można było wymiarować półosie i osie. Wyłączone: sama elipsa, a D na niej daje promień małej półosi, gdziekolwiek przeciągnąć wartość, rysowany i oznaczony R jak dotąd.",
|
||||
"prefs.sketch_align_points": "Wyrównuj do innych punktów szkicu podczas rysowania",
|
||||
"prefs.sketch_align_points_note": "Podczas rysowania punkt wyrównuje się jednocześnie poziomo z jednym punktem szkicu i pionowo z innym, z kropkowaną linią pomocniczą, a kliknięcie zachowuje oba wyrównania. Wyłączone: tylko z poprzednim punktem, po jednej osi.",
|
||||
"prefs.sketch_conflict_colour": "Geometria w konflikcie w kolorze konfliktu",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Analiza accesibilității",
|
||||
"cmd.inspect_center_of_mass": "Centru de masă",
|
||||
"cmd.inspect_clearance": "Joc",
|
||||
"cmd.inspect_colored_components": "Activează culorile componentelor",
|
||||
"cmd.inspect_colored_components_disable": "Dezactivează culorile componentelor",
|
||||
"cmd.inspect_compare": "Compară corpurile",
|
||||
"cmd.inspect_compare_picture": "Compară imaginea",
|
||||
"cmd.inspect_continuity": "Analiza continuității",
|
||||
|
||||
@@ -956,8 +956,6 @@
|
||||
"cmd.inspect_accessibility": "Анализ доступности",
|
||||
"cmd.inspect_center_of_mass": "Центр масс",
|
||||
"cmd.inspect_clearance": "Зазор",
|
||||
"cmd.inspect_colored_components": "Включить цвета компонентов",
|
||||
"cmd.inspect_colored_components_disable": "Отключить цвета компонентов",
|
||||
"cmd.inspect_compare": "Сравнить тела",
|
||||
"cmd.inspect_compare_picture": "Сравнить с изображением",
|
||||
"cmd.inspect_continuity": "Анализ непрерывности",
|
||||
@@ -1722,7 +1720,7 @@
|
||||
"help.view.tool": "Закрепляет инструмент камеры (орбиту, панорамирование или масштаб), так что перетаскивание левой кнопкой мыши двигает вид, пока вы его не отключите. Используйте на трекпаде или без средней кнопки мыши.",
|
||||
"help.view.visual_style": "Переключает способ отрисовки модели: тонированная с рёбрами или без них, каркас или со скрытыми рёбрами. Используйте каркас, чтобы заглянуть внутрь, а тонированный вид — для чистого вида.",
|
||||
"history.sketch_under_constrained": "Недоопределён (степеней свободы: {count})",
|
||||
"history.sketch_under_constrained_one": "Недоопределён (степеней свободы: {count})",
|
||||
"history.sketch_under_constrained_one": "Недоопределён ({count} степень свободы)",
|
||||
"hole_presets.confirm_delete": "Подтвердить удаление",
|
||||
"hole_presets.delete": "Удалить",
|
||||
"hole_presets.delete_prompt": "Удалить этот личный пресет? Существующие отверстия не изменятся.",
|
||||
@@ -2135,7 +2133,7 @@
|
||||
"prefs.applies_on_restart": "Применяется после перезапуска",
|
||||
"prefs.assistant": "Ассистент",
|
||||
"prefs.auto_operation": "Выбирать операцию автоматически",
|
||||
"prefs.auto_operation_note": "Окна операций сами выбирают «Объединить», «Новое тело» или «Вырезать» в зависимости от того, чего касается новый материал, пока вы не выберете операцию вручную. Выкл.: окна сохраняют ту операцию, с которой открылись.",
|
||||
"prefs.auto_operation_note": "Выбор «Объединить», «Новое тело» или «Вырезать» по тому, чего касается материал.",
|
||||
"prefs.axes": "Оси",
|
||||
"prefs.axis": "Ось",
|
||||
"prefs.bodies_folders": "Папки тел",
|
||||
@@ -2374,7 +2372,7 @@
|
||||
"prefs.stand_up_unknown.ask": "Спрашивать в диалоговом окне",
|
||||
"prefs.stand_up_unknown.note": "Показывать уведомление",
|
||||
"prefs.stand_up_unknown.off": "Не предлагать",
|
||||
"prefs.stand_up_unknown_note": "Как делается предложение, когда в заголовке файла не указана программа, о которой известно, что она сохраняет с осью Y вверх. Уведомление показывается, только если файл, судя по всему, лежит на спине; «Спрашивать в диалоговом окне» спрашивает о каждом таком файле, как раньше.",
|
||||
"prefs.stand_up_unknown_note": "Как делается предложение, когда в файле не указана известная программа.",
|
||||
"prefs.status_bar": "Строка состояния",
|
||||
"prefs.status_bar_note": "Тонкая полоса вдоль нижнего края окна показывает, что изменяется, состояние открытого эскиза его цветом и единицы дизайна; щелчок по единицам изменяет их. Состояние эскиза при этом больше не показывается в углу вида.",
|
||||
"prefs.status_done": "Готово",
|
||||
@@ -3878,7 +3876,7 @@
|
||||
"status.navigation": "Назначение кнопок мыши: {mapping}",
|
||||
"status.navigation_tip": "Как мышь двигает вид. Щёлкните, чтобы выбрать другое назначение",
|
||||
"status.under_constrained": "Недоопределён (степеней свободы: {count})",
|
||||
"status.under_constrained_one": "Недоопределён (степеней свободы: {count})",
|
||||
"status.under_constrained_one": "Недоопределён ({count} степень свободы)",
|
||||
"status.units_tip": "Единицы дизайна. Щёлкните, чтобы изменить",
|
||||
"the angle must be a number": "угол должен быть числом",
|
||||
"the curves must be in one sketch": "кривые должны быть в одном эскизе",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Анализа доступности",
|
||||
"cmd.inspect_center_of_mass": "Центар масе",
|
||||
"cmd.inspect_clearance": "Провера зазора",
|
||||
"cmd.inspect_colored_components": "Омогући боје компоненти",
|
||||
"cmd.inspect_colored_components_disable": "Онемогући боје компоненти",
|
||||
"cmd.inspect_compare": "Упореди тела",
|
||||
"cmd.inspect_compare_picture": "Упореди слику",
|
||||
"cmd.inspect_continuity": "Анализа континуитета",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Tillgänglighetsanalys",
|
||||
"cmd.inspect_center_of_mass": "Masscentrum",
|
||||
"cmd.inspect_clearance": "Frigång",
|
||||
"cmd.inspect_colored_components": "Aktivera komponentfärger",
|
||||
"cmd.inspect_colored_components_disable": "Inaktivera komponentfärger",
|
||||
"cmd.inspect_compare": "Jämför kroppar",
|
||||
"cmd.inspect_compare_picture": "Jämför bild",
|
||||
"cmd.inspect_continuity": "Kontinuitetsanalys",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "Erişilebilirlik analizi",
|
||||
"cmd.inspect_center_of_mass": "Kütle merkezi",
|
||||
"cmd.inspect_clearance": "Açıklık",
|
||||
"cmd.inspect_colored_components": "Bileşen Renklerini Etkinleştir",
|
||||
"cmd.inspect_colored_components_disable": "Bileşen Renklerini Devre Dışı Bırak",
|
||||
"cmd.inspect_compare": "Gövdeleri karşılaştır",
|
||||
"cmd.inspect_compare_picture": "Görüntüyle karşılaştır",
|
||||
"cmd.inspect_continuity": "Süreklilik kontrolü",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"Bottom Right": "Dưới cùng bên phải",
|
||||
"Boundary": "Biên dạng bao",
|
||||
"Bounding box": "Hộp bao ngoài",
|
||||
"Bridge": "Cầu nối",
|
||||
"CHECK": "KIỂM TRA",
|
||||
"COMPONENTS": "CHI TIẾT",
|
||||
"CONFIGURATIONS": "CẤU HÌNH",
|
||||
@@ -963,8 +964,7 @@
|
||||
"cmd.inspect_analysis": "Phân tích khung nhìn",
|
||||
"cmd.inspect_center_of_mass": "Trọng tâm",
|
||||
"cmd.inspect_clearance": "Khoảng cách an toàn",
|
||||
"cmd.inspect_colored_components": "Bật màu cụm chi tiết",
|
||||
"cmd.inspect_colored_components_disable": "Tắt màu cụm chi tiết",
|
||||
"cmd.inspect_colored_components": "Màu cụm chi tiết",
|
||||
"cmd.inspect_compare": "So sánh các thân khối",
|
||||
"cmd.inspect_compare_picture": "So sánh với ảnh tham chiếu",
|
||||
"cmd.inspect_continuity": "Phân tích độ liên tục mặt",
|
||||
@@ -1296,6 +1296,7 @@
|
||||
"cmd.timeline_stop": "Dừng lịch sử",
|
||||
"cmd.timeline_suppress": "Tạm nén tính năng",
|
||||
"cmd.ui.assistant": "Bật/tắt trợ lý",
|
||||
"cmd.view.navigator": "Khối điều hướng góc nhìn tùy chỉnh",
|
||||
"cmd.view.render_browser": "Trình duyệt kết xuất",
|
||||
"cmd.view.render_dock": "Di chuyển neo kết xuất",
|
||||
"cmd.view.render_focus": "Chế độ xem tập trung kết xuất",
|
||||
@@ -1445,6 +1446,9 @@
|
||||
"each rail's curves must be in one sketch": "các đường cong của mỗi đường dẫn hướng phải nằm trong cùng một phác thảo",
|
||||
"feature computation ended without a result": "việc tính toán đặc trưng kết thúc mà không có kết quả",
|
||||
"file.open.drawing_filter": "Thiết kế, tệp CAD, lưới đa giác và bản vẽ",
|
||||
"file.open.portal_fallback.no_portal_service": "Bộ chọn tệp đã mở không phải của riêng desktop: dịch vụ chọn tệp của desktop không khả dụng.",
|
||||
"file.open.portal_fallback.no_session_bus": "Bộ chọn tệp đã mở không phải của riêng desktop: không có bus phiên D-Bus.",
|
||||
"file.open.portal_fallback.xwayland": "Bộ chọn tệp đã mở không phải của riêng desktop: dưới XWayland, portal từ chối cửa sổ cha.",
|
||||
"file_load.built": "Đã dựng được: {built} trên {total} tính năng.",
|
||||
"file_load.converting": "Đang chuyển đổi khối đặc {done} trên {total}",
|
||||
"file_load.inserting": "Đang chèn hình học",
|
||||
@@ -2035,6 +2039,8 @@
|
||||
"nav.blender.help": "Kéo chuột giữa để xoay, Shift+chuột giữa để trượt, Ctrl+chuột giữa để thu phóng; kéo chuột phải giữ nguyên camera",
|
||||
"nav.creo.help": "Kéo nút giữa để xoay, Shift+nút giữa để di chuyển, Ctrl+kéo nút giữa theo chiều dọc để thu phóng (kéo xuống để phóng to); lăn con lăn để thu phóng",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "Kéo bằng nút giữa hoặc nút phải sẽ tiếp tục xoay, di chuyển hoặc thu phóng như lúc bắt đầu cho đến khi nhả nút, dù trong lúc đó có nhấn hay nhả phím nào. Tắt: các phím đang giữ quyết định ở mọi thời điểm của thao tác kéo.",
|
||||
"nav.drag_keeps_mode.label": "Thao tác kéo giữ nguyên kiểu điều hướng lúc bắt đầu",
|
||||
"nav.free_orbit.help": "Chuột và chuột 3D xoay tự do qua cả hai cực và giữ nguyên độ lăn nghiêng (Roll). Bắt dính trục bằng phím Shift sẽ bị tắt.",
|
||||
"nav.free_orbit.label": "Xoay góc nhìn tự do",
|
||||
"nav.free_orbit.snap_help": "Chuột và chuột 3D xoay qua cả hai cực và giữ nguyên góc nghiêng cuộn. Giữ Shift trong khi kéo xoay quỹ đạo để bắt dính hướng nhìn và góc nghiêng cuộn.",
|
||||
@@ -2554,6 +2560,8 @@
|
||||
"prefs.section_hatch_by_part": "Theo chi tiết",
|
||||
"prefs.section_hatch_one": "Một kiểu",
|
||||
"prefs.select": "Chọn",
|
||||
"prefs.select_hidden_edges": "Chọn cạnh bị che trong chế độ tô bóng có cạnh ẩn",
|
||||
"prefs.select_hidden_edges_help": "Cho phép chọn cạnh xuyên qua bề mặt khi dùng chế độ tô bóng có cạnh ẩn, kể cả cho lệnh Fillet. Tắt để giữ cách chọn của v0.30.1. Các khối đã ẩn vẫn không thể chọn.",
|
||||
"prefs.select_one_item": "Chọn một mục",
|
||||
"prefs.select_other_hidden": "Chọn hình học ẩn bằng Chọn đối tượng khác",
|
||||
"prefs.select_other_hidden_help": "Bật: bao gồm các khối, bản phác thảo ẩn và cạnh bị che gần con trỏ. Tắt: dùng danh sách ban đầu chỉ gồm hình học đang hiển thị ngay dưới con trỏ.",
|
||||
@@ -2578,6 +2586,8 @@
|
||||
"prefs.sketch.click_selects": "Nhấp để chọn",
|
||||
"prefs.sketch.conflict_colour": "Màu xung đột",
|
||||
"prefs.sketch.drawing": "Vẽ",
|
||||
"prefs.sketch.ellipse_axes": "Vẽ hình elip kèm các trục",
|
||||
"prefs.sketch.ellipse_axes_note": "Trục lớn và trục nhỏ dưới dạng đường gióng dựng hình, để có thể ghi kích thước bán trục và trục. Tắt: chỉ vẽ hình elip, và D trên nó cho bán kính nhỏ dù kéo giá trị đến đâu, được vẽ và ghi nhãn R như trước.",
|
||||
"prefs.sketch.exit_keep": "Giữ nguyên",
|
||||
"prefs.sketch.exit_previous": "Trở về góc nhìn trước đó",
|
||||
"prefs.sketch.exit_unless_rotated": "Trừ khi đã xoay",
|
||||
@@ -4168,6 +4178,32 @@
|
||||
"sketch.dof_left": "Còn {count} bậc tự do",
|
||||
"sketch.dof_left_one": "Còn {count} bậc tự do",
|
||||
"sketch.draw_curves": "Vẽ dưới dạng {linetype}",
|
||||
"sketch.error.closed_curve_two_crossings": "a closed curve needs two crossings to trim",
|
||||
"sketch.error.nothing_to_break": "nothing to break here",
|
||||
"sketch.error.offset_fillet_chamfer": "`{id}` is an offset, and its corners follow its source curves: round or cut the source corners before offsetting, or break the offset association first",
|
||||
"sketch.error.offset_trim": "`{id}` is an offset, and its ends follow its source curves: edit the source curves instead, or break the offset association first",
|
||||
"sketch.hint.arc.center_point": "Arc: click center and start, go round either way and click the end, or type a signed sweep",
|
||||
"sketch.hint.arc.three_point": "Arc: click start, end, then a point on the arc",
|
||||
"sketch.hint.arc3d": "3D Arc: click start, end, then a point on the arc (points may leave the sketch plane)",
|
||||
"sketch.hint.break": "Break: click a curve where it should split",
|
||||
"sketch.hint.circle.center": "Circle: click the center, then a point on the circle",
|
||||
"sketch.hint.constraint.generic": "Constraint: pick the sketch entities",
|
||||
"sketch.hint.constraint.horizontal_vertical": "Horizontal/Vertical: pick a line, two points, or a point and a line; hold Shift to pick a line midpoint",
|
||||
"sketch.hint.constraint.midpoint": "MidPoint: pick a point and a line, or two lines to center the second on the first",
|
||||
"sketch.hint.dimension": "Dimension: pick one or two entities and type the value (or click to place it first); click a dimension to edit it; Enter applies",
|
||||
"sketch.hint.extend": "Extend: click a curve near the end to extend (Shift: click two curves to extend both to where they meet)",
|
||||
"sketch.hint.fallback": "Click in the sketch",
|
||||
"sketch.hint.line": "Line: click points; right-click or Esc to finish",
|
||||
"sketch.hint.line3d": "3D Line: click world points; right-click or Esc to finish (points may leave the sketch plane)",
|
||||
"sketch.hint.open_done": "Open done",
|
||||
"sketch.hint.point3d": "3D Point: click where a 3D point goes",
|
||||
"sketch.hint.rectangle.center": "Center rectangle: click the center, then a corner",
|
||||
"sketch.hint.rectangle.rounded": "Rounded rectangle: click two opposite corners (Tab to the radius box to type the corner radius)",
|
||||
"sketch.hint.rectangle.three_point": "3-point rectangle: click two points of one edge, then the width",
|
||||
"sketch.hint.rectangle.two_point": "Rectangle: click two opposite corners",
|
||||
"sketch.hint.slot": "Slot: click both ends, then the width",
|
||||
"sketch.hint.spline3d": "3D Spline: click fit points in 3D; right-click or Esc to finish",
|
||||
"sketch.hint.trim": "Trim: click the piece of a curve to remove, or drag across the pieces to remove",
|
||||
"sketch.make_selection": "Chuyển đổi vùng chọn sang {linetype}",
|
||||
"sketch.open_ends": "Đầu hở: {count}",
|
||||
"sketch.status_conflict": "ràng buộc xung đột",
|
||||
@@ -5017,6 +5053,7 @@
|
||||
"ui.heading_construct": "DỰNG HÌNH",
|
||||
"ui.heading_create": "TẠO MỚI",
|
||||
"ui.heading_create_sketch": "TẠO PHÁC THẢO",
|
||||
"ui.heading_custom_view_navigator": "KHỐI ĐIỀU HƯỚNG GÓC NHÌN TÙY CHỈNH",
|
||||
"ui.heading_cylinder": "HÌNH TRỤ",
|
||||
"ui.heading_design": "THIẾT KẾ",
|
||||
"ui.heading_draft": "ĐỘ DỐC THOÁT KHUÔN",
|
||||
@@ -5328,6 +5365,8 @@
|
||||
"ui.repeat_nothing": "Chưa có gì để lặp lại: hãy bắt đầu một công cụ hoặc hộp thoại trước.",
|
||||
"ui.replace_with_link_done": "Các bản sao hiện đã trở thành các vị trí đặt của thiết kế liên kết.",
|
||||
"ui.report_a_bug": "Báo cáo lỗi",
|
||||
"ui.report_characters_left_one": "Còn {count} ký tự",
|
||||
"ui.report_characters_left_other": "Còn {count} ký tự",
|
||||
"ui.reset": "Đặt lại",
|
||||
"ui.reset_all": "Đặt lại tất cả",
|
||||
"ui.reset_the_settings_on_this_page": "Đặt lại các cài đặt trên trang này",
|
||||
@@ -5612,6 +5651,14 @@
|
||||
"values must be numbers or expressions": "các giá trị phải là số hoặc biểu thức",
|
||||
"view.auto_ortho_faces": "Phối cảnh khi xoay quỹ đạo, trực giao khi nhìn trực diện mặt",
|
||||
"view.render_inspector": "Bảng thuộc tính kết xuất",
|
||||
"view_gizmo.arrows": "Mũi tên xoay",
|
||||
"view_gizmo.home": "Nút góc nhìn mặc định (Home)",
|
||||
"view_gizmo.no_such_body": "Thiết kế này không có thân khối nào mang tên đó.",
|
||||
"view_gizmo.note": "Chọn một thân khối trong khung nhìn. Thân khối được lưu cùng tùy chọn và hồ sơ cài đặt của bạn, và hiển thị trong mọi thiết kế. Nhấp vào một mặt của nó để nhìn thẳng vào mặt đó.",
|
||||
"view_gizmo.texture": "Kết cấu",
|
||||
"view_gizmo.themed": "Theo chủ đề",
|
||||
"view_gizmo.too_detailed": "Quá chi tiết cho khối điều hướng góc nhìn (hơn 10.000 tam giác)",
|
||||
"view_gizmo.too_thin": "Quá dài và mảnh cho khối điều hướng góc nhìn: cạnh mỏng nhất phải ít nhất bằng một phần năm cạnh dài nhất",
|
||||
"web.files.insert_drawings_hint": "Tệp CAD, lưới đa giác, DXF hoặc SVG vào thiết kế đang mở",
|
||||
"web.files.insert_stored_drawings_hint": "Vào thiết kế đang mở (tệp CAD, lưới đa giác, DXF, SVG)",
|
||||
"web.open_full": "Mở trong SolidCraft",
|
||||
|
||||
@@ -957,8 +957,6 @@
|
||||
"cmd.inspect_accessibility": "可達性分析",
|
||||
"cmd.inspect_center_of_mass": "質心",
|
||||
"cmd.inspect_clearance": "間隙",
|
||||
"cmd.inspect_colored_components": "啟用元件顏色",
|
||||
"cmd.inspect_colored_components_disable": "停用元件顏色",
|
||||
"cmd.inspect_compare": "比較實體",
|
||||
"cmd.inspect_compare_picture": "與圖片比較",
|
||||
"cmd.inspect_continuity": "連續性分析",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
"Bottom Right": "右下",
|
||||
"Boundary": "边界",
|
||||
"Bounding box": "边界框",
|
||||
"Bridge": "桥接",
|
||||
"CHECK": "检查",
|
||||
"COMPONENTS": "组件",
|
||||
"CONFIGURATIONS": "配置",
|
||||
@@ -963,8 +964,7 @@
|
||||
"cmd.inspect_analysis": "视图分析",
|
||||
"cmd.inspect_center_of_mass": "质心",
|
||||
"cmd.inspect_clearance": "间隙",
|
||||
"cmd.inspect_colored_components": "启用组件颜色",
|
||||
"cmd.inspect_colored_components_disable": "禁用组件颜色",
|
||||
"cmd.inspect_colored_components": "组件颜色",
|
||||
"cmd.inspect_compare": "比较实体",
|
||||
"cmd.inspect_compare_picture": "比较参考图",
|
||||
"cmd.inspect_continuity": "连续性分析",
|
||||
@@ -1296,6 +1296,7 @@
|
||||
"cmd.timeline_stop": "停止历史播放",
|
||||
"cmd.timeline_suppress": "抑制特征",
|
||||
"cmd.ui.assistant": "切换助手显示",
|
||||
"cmd.view.navigator": "自定义视图导航器",
|
||||
"cmd.view.render_browser": "渲染浏览器",
|
||||
"cmd.view.render_dock": "移动渲染停靠面板",
|
||||
"cmd.view.render_focus": "渲染专注视图",
|
||||
@@ -1445,6 +1446,9 @@
|
||||
"each rail's curves must be in one sketch": "每条导轨的曲线必须位于同一个草图中",
|
||||
"feature computation ended without a result": "特征计算结束时没有返回结果",
|
||||
"file.open.drawing_filter": "设计、CAD 文件、网格和图纸",
|
||||
"file.open.portal_fallback.no_portal_service": "打开的文件选择器并非桌面自带:桌面的文件选择服务不可用。",
|
||||
"file.open.portal_fallback.no_session_bus": "打开的文件选择器并非桌面自带:没有 D-Bus 会话总线。",
|
||||
"file.open.portal_fallback.xwayland": "打开的文件选择器并非桌面自带:在 XWayland 下,门户会拒绝父窗口。",
|
||||
"file_load.built": "已构建:{built}/{total} 个特征。",
|
||||
"file_load.converting": "正在转换实体 {done}/{total}",
|
||||
"file_load.inserting": "正在插入几何体",
|
||||
@@ -2035,6 +2039,8 @@
|
||||
"nav.blender.help": "中键拖动旋转,Shift+中键拖动平移,Ctrl+中键拖动缩放;右键拖动不会移动相机",
|
||||
"nav.creo.help": "中键拖动旋转,Shift+中键平移,Ctrl+中键上下拖动缩放(向下放大);滚动滚轮也可缩放",
|
||||
"nav.creo.label": "Creo",
|
||||
"nav.drag_keeps_mode.help": "中键或右键拖动会保持开始时的旋转、平移或缩放,直到松开按键,期间按下或松开任何键都不会改变。关闭后:拖动的每一刻都由当时按住的键决定。",
|
||||
"nav.drag_keeps_mode.label": "拖动保持开始时的导航方式",
|
||||
"nav.free_orbit.help": "鼠标和3D鼠标可保持滚转并越过两个极点旋转。Shift轴吸附将被禁用。",
|
||||
"nav.free_orbit.label": "自由旋转",
|
||||
"nav.free_orbit.snap_help": "鼠标和3D鼠标可越过两极旋转,并保留画面旋转角度。在拖动环绕时按住Shift,可吸附视图方向和画面旋转角度。",
|
||||
@@ -2554,6 +2560,8 @@
|
||||
"prefs.section_hatch_by_part": "按零件",
|
||||
"prefs.section_hatch_one": "单一样式",
|
||||
"prefs.select": "选择",
|
||||
"prefs.select_hidden_edges": "在带隐藏边线的着色视图中选择隐藏边",
|
||||
"prefs.select_hidden_edges_help": "在带隐藏边线的着色视图中,可穿过面选择边并用于圆角。关闭时保留v0.30.1的选择行为。隐藏的实体仍不可选择。",
|
||||
"prefs.select_one_item": "选择一个项目",
|
||||
"prefs.select_other_hidden": "使用“选择其他”选择隐藏几何体",
|
||||
"prefs.select_other_hidden_help": "开启:包括指针附近的隐藏实体、草图和被遮挡的边。关闭:恢复原来的列表,仅包含指针正下方的可见几何体。",
|
||||
@@ -2578,6 +2586,8 @@
|
||||
"prefs.sketch.click_selects": "单击选择",
|
||||
"prefs.sketch.conflict_colour": "冲突颜色",
|
||||
"prefs.sketch.drawing": "绘制",
|
||||
"prefs.sketch.ellipse_axes": "绘制椭圆时带上轴线",
|
||||
"prefs.sketch.ellipse_axes_note": "将长轴和短轴绘制为构造线,以便标注半轴和轴。关闭:仅绘制椭圆,对其按 D 得到短半径,无论将数值拖到何处,都像以前一样绘制并标注 R。",
|
||||
"prefs.sketch.exit_keep": "保持",
|
||||
"prefs.sketch.exit_previous": "返回之前的视图",
|
||||
"prefs.sketch.exit_unless_rotated": "除非已旋转",
|
||||
@@ -4168,6 +4178,32 @@
|
||||
"sketch.dof_left": "剩余 {count} 个自由度",
|
||||
"sketch.dof_left_one": "剩余 {count} 个自由度",
|
||||
"sketch.draw_curves": "绘制为 {linetype}",
|
||||
"sketch.error.closed_curve_two_crossings": "a closed curve needs two crossings to trim",
|
||||
"sketch.error.nothing_to_break": "nothing to break here",
|
||||
"sketch.error.offset_fillet_chamfer": "`{id}` is an offset, and its corners follow its source curves: round or cut the source corners before offsetting, or break the offset association first",
|
||||
"sketch.error.offset_trim": "`{id}` is an offset, and its ends follow its source curves: edit the source curves instead, or break the offset association first",
|
||||
"sketch.hint.arc.center_point": "Arc: click center and start, go round either way and click the end, or type a signed sweep",
|
||||
"sketch.hint.arc.three_point": "Arc: click start, end, then a point on the arc",
|
||||
"sketch.hint.arc3d": "3D Arc: click start, end, then a point on the arc (points may leave the sketch plane)",
|
||||
"sketch.hint.break": "Break: click a curve where it should split",
|
||||
"sketch.hint.circle.center": "Circle: click the center, then a point on the circle",
|
||||
"sketch.hint.constraint.generic": "Constraint: pick the sketch entities",
|
||||
"sketch.hint.constraint.horizontal_vertical": "Horizontal/Vertical: pick a line, two points, or a point and a line; hold Shift to pick a line midpoint",
|
||||
"sketch.hint.constraint.midpoint": "MidPoint: pick a point and a line, or two lines to center the second on the first",
|
||||
"sketch.hint.dimension": "Dimension: pick one or two entities and type the value (or click to place it first); click a dimension to edit it; Enter applies",
|
||||
"sketch.hint.extend": "Extend: click a curve near the end to extend (Shift: click two curves to extend both to where they meet)",
|
||||
"sketch.hint.fallback": "Click in the sketch",
|
||||
"sketch.hint.line": "Line: click points; right-click or Esc to finish",
|
||||
"sketch.hint.line3d": "3D Line: click world points; right-click or Esc to finish (points may leave the sketch plane)",
|
||||
"sketch.hint.open_done": "Open done",
|
||||
"sketch.hint.point3d": "3D Point: click where a 3D point goes",
|
||||
"sketch.hint.rectangle.center": "Center rectangle: click the center, then a corner",
|
||||
"sketch.hint.rectangle.rounded": "Rounded rectangle: click two opposite corners (Tab to the radius box to type the corner radius)",
|
||||
"sketch.hint.rectangle.three_point": "3-point rectangle: click two points of one edge, then the width",
|
||||
"sketch.hint.rectangle.two_point": "Rectangle: click two opposite corners",
|
||||
"sketch.hint.slot": "Slot: click both ends, then the width",
|
||||
"sketch.hint.spline3d": "3D Spline: click fit points in 3D; right-click or Esc to finish",
|
||||
"sketch.hint.trim": "Trim: click the piece of a curve to remove, or drag across the pieces to remove",
|
||||
"sketch.make_selection": "将选择转换为 {linetype}",
|
||||
"sketch.open_ends": "开放 {count}",
|
||||
"sketch.status_conflict": "约束冲突",
|
||||
@@ -5017,6 +5053,7 @@
|
||||
"ui.heading_construct": "构造",
|
||||
"ui.heading_create": "创建",
|
||||
"ui.heading_create_sketch": "创建草图",
|
||||
"ui.heading_custom_view_navigator": "自定义视图导航器",
|
||||
"ui.heading_cylinder": "圆柱体",
|
||||
"ui.heading_design": "设计",
|
||||
"ui.heading_draft": "拔模",
|
||||
@@ -5328,6 +5365,8 @@
|
||||
"ui.repeat_nothing": "还没有可重复的操作:请先启动一个工具或对话框。",
|
||||
"ui.replace_with_link_done": "这些副本现在是链接设计的放置。",
|
||||
"ui.report_a_bug": "报告缺陷",
|
||||
"ui.report_characters_left_one": "剩余 {count} 个字符",
|
||||
"ui.report_characters_left_other": "剩余 {count} 个字符",
|
||||
"ui.reset": "重置",
|
||||
"ui.reset_all": "全部重置",
|
||||
"ui.reset_the_settings_on_this_page": "重置此页面上的设置",
|
||||
@@ -5612,6 +5651,14 @@
|
||||
"values must be numbers or expressions": "值必须是数字或表达式",
|
||||
"view.auto_ortho_faces": "旋转时透视,正对表面时正交",
|
||||
"view.render_inspector": "渲染检查器",
|
||||
"view_gizmo.arrows": "旋转箭头",
|
||||
"view_gizmo.home": "主页按钮",
|
||||
"view_gizmo.no_such_body": "此设计中没有该名称的实体。",
|
||||
"view_gizmo.note": "在视图中选择一个实体。它随首选项和设置配置文件保存,并在每个设计中显示。单击它的一个面即可正视该面。",
|
||||
"view_gizmo.texture": "纹理",
|
||||
"view_gizmo.themed": "主题",
|
||||
"view_gizmo.too_detailed": "对视图导航器而言过于精细(超过 10,000 个三角形)",
|
||||
"view_gizmo.too_thin": "对视图导航器而言过于细长:最薄的一边至少要有最长一边的五分之一",
|
||||
"web.files.insert_drawings_hint": "将 CAD 文件、网格、DXF 或 SVG 插入当前设计",
|
||||
"web.files.insert_stored_drawings_hint": "插入当前设计(CAD 文件、网格、DXF、SVG)",
|
||||
"web.open_full": "在 SolidCraft 中打开",
|
||||
|
||||
@@ -366,6 +366,13 @@ fn fs_ao_depth(i: TOut, @builtin(front_facing) front: bool) -> AoDepth {
|
||||
return opaque_depth(i, front);
|
||||
}
|
||||
|
||||
// The virtual ground preserves the viewport background; only contact occlusion is blended.
|
||||
@fragment
|
||||
fn fs_ground_ao(i: TOut) -> @location(0) vec4<f32> {
|
||||
if (clipped(i.wp)) { discard; }
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0 - occlusion(i));
|
||||
}
|
||||
|
||||
/// The AO prepass's depth of an opaque surface's fragment.
|
||||
fn opaque_depth(i: TOut, front: bool) -> AoDepth {
|
||||
if (clipped(i.wp) || length(i.n) < 0.5) { discard; }
|
||||
|
||||
@@ -0,0 +1,667 @@
|
||||
{
|
||||
"order": 260,
|
||||
"provenance": "Original SolidCraft stone-grey palette and semantic icon-role mapping",
|
||||
"format": "solidcraft-theme/1",
|
||||
"name": "Onyx",
|
||||
"base": "dark",
|
||||
"colors": {
|
||||
"accent": "#9eafbd",
|
||||
"accent_soft": "#3b4852",
|
||||
"agent_busy": "#9eafbd",
|
||||
"agent_ok": "#a5b9a5",
|
||||
"app_bar": "#1c1e20",
|
||||
"app_bar_hover": "#dededc16",
|
||||
"app_bar_hover_button": "#dededc1c",
|
||||
"app_bar_hover_strong": "#dededc28",
|
||||
"app_bar_hover_subtle": "#dededc0c",
|
||||
"app_bar_separator": "#383c3f",
|
||||
"app_bar_tab_active": "#303235",
|
||||
"app_bar_text": "#dededc",
|
||||
"axis_x": "#d7938f",
|
||||
"axis_y": "#a5b9a5",
|
||||
"axis_z": "#98b2c8",
|
||||
"bend_down": "#b8a7c3",
|
||||
"bend_up": "#a5b9a5",
|
||||
"body": "#93989c",
|
||||
"body_edge": "#60666b",
|
||||
"body_selected": "#3b4852",
|
||||
"border": "#3d4145",
|
||||
"box_window": "#9eafbd",
|
||||
"chip": "#758b9b",
|
||||
"construction_geom": "#b9a78e",
|
||||
"construction_plane": "#b9a78e24",
|
||||
"continuity": [
|
||||
"#a5b9a5",
|
||||
"#98b2c8",
|
||||
"#c7b28b",
|
||||
"#b8a7c3"
|
||||
],
|
||||
"control_border": "#4a4f54",
|
||||
"control_fill": "#303235",
|
||||
"cube_border": "#50565b",
|
||||
"cube_face": "#34373a",
|
||||
"cube_hover": "#53616c",
|
||||
"cube_text": "#dededc",
|
||||
"dialog_bg": "#2b2d2f",
|
||||
"dialog_body": "#2b2d2f",
|
||||
"dialog_border": "#3d4145",
|
||||
"dialog_footer": "#27292b",
|
||||
"dialog_label": "#dededc",
|
||||
"dialog_rule": "#383c3f",
|
||||
"dimension": "#c7b28b",
|
||||
"dimension_driven": "#a59474",
|
||||
"error": "#d7938f",
|
||||
"field": "#1c1e20",
|
||||
"form_accent": "#9d8faa",
|
||||
"form_dim": "#c6c8c9",
|
||||
"form_error": "#d7938f",
|
||||
"form_error_fill": "#493334",
|
||||
"form_fill": "#b9abc5",
|
||||
"form_ink": "#dededc",
|
||||
"form_primary": "#9eafbd",
|
||||
"form_primary_fill": "#9eafbd",
|
||||
"form_soft": "#343039",
|
||||
"form_success": "#a5b9a5",
|
||||
"form_success_fill": "#344139",
|
||||
"form_tab_ink": "#b9abc5",
|
||||
"glyph_bg": "#34373a",
|
||||
"glyph_edge": "#d7938f",
|
||||
"glyph_text": "#d7938f",
|
||||
"grid": "#252729",
|
||||
"grid_major": "#2e3235",
|
||||
"hover": "#3b4852",
|
||||
"hover_edge": "#b1c1ce",
|
||||
"hover_edge_halo": "#181a1c",
|
||||
"hover_profile": "#9eafbd30",
|
||||
"hover_profile_edge": "#b1c1ce",
|
||||
"icon": "#dededc",
|
||||
"icons.agent": "#b8a7c3",
|
||||
"icons.highlight": "#dededc",
|
||||
"icons.marker_halo": "#1c1e20cc",
|
||||
"interference": "#d7938f",
|
||||
"joint_axis": "#98b2c8",
|
||||
"joint_manipulator": "#9eafbd",
|
||||
"logo": [
|
||||
"#c9d4dc",
|
||||
"#9eafbd",
|
||||
"#647986"
|
||||
],
|
||||
"manipulator": "#9eafbd",
|
||||
"mesh_accent": "#a29772",
|
||||
"mesh_fill": "#beb48d",
|
||||
"mesh_ink": "#beb48d",
|
||||
"mesh_soft": "#34332b",
|
||||
"nav_dim": "#b5b7b8",
|
||||
"nav_field": "#1c1e20",
|
||||
"nav_hover": "#43494f",
|
||||
"nav_press": "#59636c",
|
||||
"nav_tip": "#2b2d2f",
|
||||
"nav_tip_ink": "#dededc",
|
||||
"nav_tip_key_border": "#3b3e41",
|
||||
"nav_viewport": "#27292b",
|
||||
"on_accent": "#17191b",
|
||||
"origin_plane": "#b9a78e2c",
|
||||
"origin_plane_edge": "#b9a78e94",
|
||||
"origin_plane_hover": "#9eafbd60",
|
||||
"origin_point": "#b5b7b8",
|
||||
"overlay": "#2b2d2f",
|
||||
"panel": "#2b2d2f",
|
||||
"panel_header": "#303235",
|
||||
"preview_add": "#9eafbd",
|
||||
"preview_cut": "#d7938f68",
|
||||
"preview_new": "#c7b28b",
|
||||
"preview_sketch": "#a5b9a5",
|
||||
"profile_fill": "#9eafbd28",
|
||||
"render_accent": "#a88e88",
|
||||
"render_fill": "#c1a49e",
|
||||
"render_ink": "#c1a49e",
|
||||
"render_soft": "#38302f",
|
||||
"rubber_band": "#9eafbd",
|
||||
"section_cap": "#c7b28b",
|
||||
"sel_edge": "#b1c1ce",
|
||||
"sel_edge_rim": "#d0d9df",
|
||||
"sel_face": "#3b4852",
|
||||
"sel_profile": "#3b4852",
|
||||
"sel_profile_edge": "#b1c1ce",
|
||||
"sel_vertex": "#9eafbd",
|
||||
"selected_bg": "#3b4852",
|
||||
"selected_ink": "#dededc",
|
||||
"sheet_fill": "#9eb9bd",
|
||||
"sheet_ink": "#9eb9bd",
|
||||
"sheet_soft": "#29363a",
|
||||
"sketch": "#9eafbd",
|
||||
"sketch_accent": "#b2b995",
|
||||
"sketch_centerline": "#b5b7b8",
|
||||
"sketch_conflict": "#d7938f",
|
||||
"sketch_construction": "#b5b7b8",
|
||||
"sketch_fixed": "#dededc",
|
||||
"sketch_halo": "#181a1c",
|
||||
"sketch_ink": "#b2b995",
|
||||
"sketch_locked": "#a5b9a5",
|
||||
"sketch_lost": "#d7938f",
|
||||
"sketch_point": "#dededc",
|
||||
"sketch_point_free": "#9eafbd",
|
||||
"sketch_projected": "#b8a7c3",
|
||||
"sketch_soft": "#32352c",
|
||||
"surface_accent": "#a6947d",
|
||||
"surface_fill": "#c0ae96",
|
||||
"surface_ink": "#c0ae96",
|
||||
"surface_soft": "#35322e",
|
||||
"tab_on_fill_dark": "#17191b",
|
||||
"text": "#dededc",
|
||||
"text_dim": "#c6c8c9",
|
||||
"timeline": "#2b2d2f",
|
||||
"timeline_item": "#303235",
|
||||
"timeline_item_error": "#493334",
|
||||
"timeline_marker": "#b5b7b8",
|
||||
"toolbar": "#2b2d2f",
|
||||
"viewport_bottom": "#1b1d1f",
|
||||
"viewport_top": "#222426",
|
||||
"warning": "#c7b28b"
|
||||
},
|
||||
"radii": {
|
||||
"radius_sm": 3,
|
||||
"radius_md": 6,
|
||||
"radius_lg": 8,
|
||||
"radius_xl": 10,
|
||||
"control_radius": 4,
|
||||
"sketch_mode_radius": 6
|
||||
},
|
||||
"icon_palette": {
|
||||
"ink": "#1b1d1f",
|
||||
"line": "#d7d9d8",
|
||||
"passive-1": "#b9bdc0",
|
||||
"passive-2": "#8d9398",
|
||||
"passive-3": "#646c72",
|
||||
"guide": "#a2a8ac",
|
||||
"solid": [
|
||||
"#c9d4dc",
|
||||
"#b2c1cc",
|
||||
"#9eafbd"
|
||||
],
|
||||
"surface": [
|
||||
"#d6cab8",
|
||||
"#c0ae96",
|
||||
"#a6947d"
|
||||
],
|
||||
"mesh": [
|
||||
"#d4ccad",
|
||||
"#beb48d",
|
||||
"#a29772"
|
||||
],
|
||||
"form": [
|
||||
"#d0c5d9",
|
||||
"#b9abc5",
|
||||
"#9d8faa"
|
||||
],
|
||||
"sketch": [
|
||||
"#c9cfb3",
|
||||
"#b2b995",
|
||||
"#979f78"
|
||||
],
|
||||
"constraint": [
|
||||
"#e1b7b2",
|
||||
"#d7938f",
|
||||
"#b77875"
|
||||
],
|
||||
"construction": [
|
||||
"#d2c6b4",
|
||||
"#b9a78e",
|
||||
"#9f8c73"
|
||||
]
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"id": "opacity",
|
||||
"type": "range",
|
||||
"default": 80,
|
||||
"min": 60,
|
||||
"max": 100
|
||||
},
|
||||
{
|
||||
"id": "blur",
|
||||
"type": "range",
|
||||
"default": 60,
|
||||
"max": 60
|
||||
},
|
||||
{
|
||||
"id": "tab_colours",
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"id": "tab_fade_ms",
|
||||
"type": "range",
|
||||
"default": 240
|
||||
},
|
||||
{
|
||||
"id": "accent",
|
||||
"type": "choice",
|
||||
"default": "slate",
|
||||
"label": {
|
||||
"en": "Accent",
|
||||
"de": "Akzent",
|
||||
"ja": "アクセント",
|
||||
"ko": "강조색",
|
||||
"zh": "强调色"
|
||||
},
|
||||
"help": {
|
||||
"en": "Selection, highlights and Model controls; workspace and status colours keep their meaning.",
|
||||
"de": "Auswahl, Hervorhebungen und Modell-Steuerung; Arbeitsbereichs- und Statusfarben behalten ihre Bedeutung.",
|
||||
"ja": "選択・強調・モデルの操作色。ワークスペースや状態の色の意味は変えません。",
|
||||
"ko": "선택, 강조 및 모델 조작의 색상입니다. 작업 공간과 상태 색상의 의미는 유지됩니다.",
|
||||
"zh": "更改选择、高亮与模型控件的色调;工作空间和状态色保持原有含义。"
|
||||
},
|
||||
"values": [
|
||||
{
|
||||
"id": "slate",
|
||||
"label": {
|
||||
"en": "Slate blue",
|
||||
"de": "Schieferblau",
|
||||
"ja": "石板の青",
|
||||
"ko": "슬레이트 블루",
|
||||
"zh": "岩蓝"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "silver",
|
||||
"label": {
|
||||
"en": "Silver",
|
||||
"de": "Silber",
|
||||
"ja": "シルバー",
|
||||
"ko": "은색",
|
||||
"zh": "银灰"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "sage",
|
||||
"label": {
|
||||
"en": "Sage",
|
||||
"de": "Salbei",
|
||||
"ja": "セージ",
|
||||
"ko": "세이지",
|
||||
"zh": "鼠尾草绿"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "contrast",
|
||||
"type": "choice",
|
||||
"default": "soft",
|
||||
"label": {
|
||||
"en": "Contrast",
|
||||
"de": "Kontrast",
|
||||
"ja": "コントラスト",
|
||||
"ko": "대비",
|
||||
"zh": "对比度"
|
||||
},
|
||||
"help": {
|
||||
"en": "Soft stone layers or stronger separation between panels and fields.",
|
||||
"de": "Weiche Steinschichten oder stärkere Trennung von Flächen und Feldern.",
|
||||
"ja": "柔らかな石の階調か、パネルと入力欄を明確に分ける階調を選びます。",
|
||||
"ko": "부드러운 석재 톤 또는 패널과 입력란을 더 뚜렷하게 구분합니다.",
|
||||
"zh": "选择柔和的石色层次,或增强面板与输入框的区分。"
|
||||
},
|
||||
"values": [
|
||||
{
|
||||
"id": "soft",
|
||||
"label": {
|
||||
"en": "Soft",
|
||||
"de": "Weich",
|
||||
"ja": "ソフト",
|
||||
"ko": "부드럽게",
|
||||
"zh": "柔和"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "defined",
|
||||
"label": {
|
||||
"en": "Defined",
|
||||
"de": "Deutlich",
|
||||
"ja": "くっきり",
|
||||
"ko": "뚜렷하게",
|
||||
"zh": "分明"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "brightness",
|
||||
"type": "range",
|
||||
"effect": "surface_brightness",
|
||||
"default": 100,
|
||||
"min": 60,
|
||||
"max": 120,
|
||||
"step": 1,
|
||||
"unit": "%",
|
||||
"label": {
|
||||
"en": "Brightness",
|
||||
"de": "Helligkeit",
|
||||
"ja": "明るさ",
|
||||
"ko": "밝기",
|
||||
"zh": "亮度"
|
||||
},
|
||||
"help": {
|
||||
"en": "Adjust stone surfaces, viewport backgrounds and grid brightness. 100% keeps the authored tones; text and semantic colours stay unchanged.",
|
||||
"de": "Helligkeit von Steinflächen, Ansichtsflächen und Raster. 100% erhält die ursprünglichen Töne; Text und Bedeutungsfarben bleiben unverändert.",
|
||||
"ja": "石調の面・ビューポート背景・グリッドの明るさを調整します。100%は元の階調です。文字と意味のある色は変えません。",
|
||||
"ko": "석재 표면·뷰포트 배경·격자의 밝기를 조절합니다. 100%는 원래 톤을 유지하며 글자와 의미 색상은 바꾸지 않습니다.",
|
||||
"zh": "调整石色表面、视口背景和网格的亮度。100%保留原有色调;文字和语义颜色保持不变。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "foreground_colours",
|
||||
"type": "choice",
|
||||
"default": "vibrant",
|
||||
"label": {
|
||||
"en": "Foreground colours",
|
||||
"de": "Vordergrundfarben",
|
||||
"ja": "前景の色",
|
||||
"ko": "전경 색상",
|
||||
"zh": "前景颜色"
|
||||
},
|
||||
"help": {
|
||||
"en": "Vibrant strengthens axes, icons and guides. Muted keeps the original quiet palette. Accent controls selection.",
|
||||
"de": "Leuchtend verstärkt Achsen, Symbole und Hilfen. Gedämpft behält die ruhige ursprüngliche Palette. Akzent steuert die Auswahl.",
|
||||
"ja": "鮮やかは軸・アイコン・作図ガイドを強調します。落ち着いた配色は元の控えめな色を保ちます。選択の色はアクセントで設定します。",
|
||||
"ko": "선명함은 축·아이콘·가이드를 강조합니다. 차분함은 기존의 은은한 팔레트를 유지합니다. 선택 색상은 강조색 설정을 따릅니다.",
|
||||
"zh": "鲜艳增强轴、图标和辅助线的色彩。柔和保留原有的沉静配色。选择颜色仍由强调色控制。"
|
||||
},
|
||||
"values": [
|
||||
{
|
||||
"id": "muted",
|
||||
"label": {
|
||||
"en": "Muted",
|
||||
"de": "Gedämpft",
|
||||
"ja": "落ち着いた",
|
||||
"ko": "차분함",
|
||||
"zh": "柔和"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "vibrant",
|
||||
"label": {
|
||||
"en": "Vibrant",
|
||||
"de": "Leuchtend",
|
||||
"ja": "鮮やか",
|
||||
"ko": "선명함",
|
||||
"zh": "鲜艳"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"overlays": [
|
||||
{
|
||||
"when": {
|
||||
"opt": "contrast",
|
||||
"eq": "defined"
|
||||
},
|
||||
"colors": {
|
||||
"app_bar": "#151719",
|
||||
"panel": "#25282a",
|
||||
"dialog_bg": "#25282a",
|
||||
"dialog_body": "#25282a",
|
||||
"dialog_footer": "#202325",
|
||||
"panel_header": "#373b3e",
|
||||
"field": "#171a1c",
|
||||
"control_fill": "#383d41",
|
||||
"border": "#4e555b",
|
||||
"dialog_border": "#4e555b",
|
||||
"dialog_rule": "#444b51",
|
||||
"control_border": "#626c73",
|
||||
"text": "#eeeeec",
|
||||
"text_dim": "#ced1d2",
|
||||
"form_ink": "#eeeeec",
|
||||
"form_dim": "#ced1d2",
|
||||
"dialog_label": "#eeeeec",
|
||||
"toolbar": "#25282a",
|
||||
"timeline": "#25282a"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"opt": "accent",
|
||||
"eq": "silver"
|
||||
},
|
||||
"colors": {
|
||||
"accent": "#b7bdc2",
|
||||
"manipulator": "#b7bdc2",
|
||||
"joint_manipulator": "#b7bdc2",
|
||||
"preview_add": "#b7bdc2",
|
||||
"rubber_band": "#b7bdc2",
|
||||
"box_window": "#b7bdc2",
|
||||
"form_primary": "#b7bdc2",
|
||||
"form_primary_fill": "#b7bdc2",
|
||||
"sketch": "#b7bdc2",
|
||||
"sketch_point_free": "#b7bdc2",
|
||||
"sel_vertex": "#b7bdc2",
|
||||
"accent_soft": "#454b50",
|
||||
"hover": "#454b50",
|
||||
"selected_bg": "#454b50",
|
||||
"sel_face": "#454b50",
|
||||
"sel_profile": "#454b50",
|
||||
"body_selected": "#454b50",
|
||||
"sel_edge": "#d5dadf",
|
||||
"sel_profile_edge": "#d5dadf",
|
||||
"hover_edge": "#d5dadf",
|
||||
"hover_profile_edge": "#d5dadf",
|
||||
"sel_edge_rim": "#dde0e3",
|
||||
"hover_profile": "#b7bdc230",
|
||||
"origin_plane_hover": "#b7bdc260",
|
||||
"profile_fill": "#b7bdc228",
|
||||
"cube_hover": "#454b50",
|
||||
"chip": "#b7bdc2",
|
||||
"logo": [
|
||||
"#dde0e3",
|
||||
"#c9cfd4",
|
||||
"#b7bdc2"
|
||||
]
|
||||
},
|
||||
"icon_palette": {
|
||||
"solid": [
|
||||
"#dde0e3",
|
||||
"#c9cfd4",
|
||||
"#b7bdc2"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"opt": "accent",
|
||||
"eq": "sage"
|
||||
},
|
||||
"colors": {
|
||||
"accent": "#aabcae",
|
||||
"manipulator": "#aabcae",
|
||||
"joint_manipulator": "#aabcae",
|
||||
"preview_add": "#aabcae",
|
||||
"rubber_band": "#aabcae",
|
||||
"box_window": "#aabcae",
|
||||
"form_primary": "#aabcae",
|
||||
"form_primary_fill": "#aabcae",
|
||||
"sketch": "#aabcae",
|
||||
"sketch_point_free": "#aabcae",
|
||||
"sel_vertex": "#aabcae",
|
||||
"accent_soft": "#414d45",
|
||||
"hover": "#414d45",
|
||||
"selected_bg": "#414d45",
|
||||
"sel_face": "#414d45",
|
||||
"sel_profile": "#414d45",
|
||||
"body_selected": "#414d45",
|
||||
"sel_edge": "#c2d2c5",
|
||||
"sel_profile_edge": "#c2d2c5",
|
||||
"hover_edge": "#c2d2c5",
|
||||
"hover_profile_edge": "#c2d2c5",
|
||||
"sel_edge_rim": "#d1ddd4",
|
||||
"hover_profile": "#aabcae30",
|
||||
"origin_plane_hover": "#aabcae60",
|
||||
"profile_fill": "#aabcae28",
|
||||
"cube_hover": "#414d45",
|
||||
"chip": "#aabcae",
|
||||
"logo": [
|
||||
"#d1ddd4",
|
||||
"#becec2",
|
||||
"#aabcae"
|
||||
]
|
||||
},
|
||||
"icon_palette": {
|
||||
"solid": [
|
||||
"#d1ddd4",
|
||||
"#becec2",
|
||||
"#aabcae"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"opt": "foreground_colours",
|
||||
"eq": "vibrant"
|
||||
},
|
||||
"colors": {
|
||||
"axis_x": "#ff6d79",
|
||||
"axis_y": "#4fd681",
|
||||
"axis_z": "#4da7ff",
|
||||
"agent_busy": "#4da7ff",
|
||||
"agent_ok": "#4fd681",
|
||||
"warning": "#ffd166",
|
||||
"error": "#ff6d79",
|
||||
"form_error": "#ff6d79",
|
||||
"form_success": "#4fd681",
|
||||
"glyph_edge": "#ff6d79",
|
||||
"glyph_text": "#ff6d79",
|
||||
"interference": "#ff6d79",
|
||||
"sketch_conflict": "#ff6d79",
|
||||
"sketch_lost": "#ff6d79",
|
||||
"sketch_locked": "#4fd681",
|
||||
"sketch_projected": "#c78bff",
|
||||
"dimension": "#ffd166",
|
||||
"dimension_driven": "#ffb166",
|
||||
"construction_geom": "#ffb166",
|
||||
"sketch_centerline": "#b5b7b8",
|
||||
"sketch_construction": "#b5b7b8",
|
||||
"joint_axis": "#42d9dd",
|
||||
"bend_down": "#c78bff",
|
||||
"bend_up": "#4fd681",
|
||||
"preview_cut": "#ff6d7968",
|
||||
"preview_new": "#ffd166",
|
||||
"preview_sketch": "#4fd681",
|
||||
"section_cap": "#ffd166",
|
||||
"sketch_accent": "#4fd681",
|
||||
"sketch_ink": "#4fd681",
|
||||
"surface_accent": "#ffb166",
|
||||
"surface_fill": "#ffb166",
|
||||
"surface_ink": "#ffb166",
|
||||
"mesh_accent": "#ffd166",
|
||||
"mesh_fill": "#ffd166",
|
||||
"mesh_ink": "#ffd166",
|
||||
"form_accent": "#c78bff",
|
||||
"form_fill": "#c78bff",
|
||||
"form_tab_ink": "#c78bff",
|
||||
"sheet_fill": "#63cbd5",
|
||||
"sheet_ink": "#63cbd5",
|
||||
"render_accent": "#ff6d79",
|
||||
"render_fill": "#ff6d79",
|
||||
"render_ink": "#ff6d79",
|
||||
"icons.agent": "#c78bff",
|
||||
"continuity": [
|
||||
"#4fd681",
|
||||
"#4da7ff",
|
||||
"#ffd166",
|
||||
"#c78bff"
|
||||
],
|
||||
"origin_plane_edge": "#ffb16694",
|
||||
"sheet_soft": "#283a3e"
|
||||
},
|
||||
"icon_palette": {
|
||||
"ink": "#1b1d1f",
|
||||
"line": "#d7d9d8",
|
||||
"passive-1": "#d3d8dc",
|
||||
"passive-2": "#b2bbc2",
|
||||
"passive-3": "#929fa9",
|
||||
"guide": "#b4c8d6",
|
||||
"solid": [
|
||||
"#82c1ff",
|
||||
"#62b2ff",
|
||||
"#4da7ff"
|
||||
],
|
||||
"surface": [
|
||||
"#ffc894",
|
||||
"#ffba78",
|
||||
"#ffb166"
|
||||
],
|
||||
"mesh": [
|
||||
"#ffdf94",
|
||||
"#ffd778",
|
||||
"#ffd166"
|
||||
],
|
||||
"form": [
|
||||
"#d8aeff",
|
||||
"#ce99ff",
|
||||
"#c78bff"
|
||||
],
|
||||
"sketch": [
|
||||
"#84e2a7",
|
||||
"#64db90",
|
||||
"#4fd681"
|
||||
],
|
||||
"constraint": [
|
||||
"#ff99a1",
|
||||
"#ff7f89",
|
||||
"#ff6d79"
|
||||
],
|
||||
"construction": [
|
||||
"#ffc894",
|
||||
"#ffba78",
|
||||
"#ffb166"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"tabs": {
|
||||
"MODEL": {
|
||||
"viewport_top": "#24292d",
|
||||
"viewport_bottom": "#1b2023",
|
||||
"panel": "#303438"
|
||||
},
|
||||
"SURFACE": {
|
||||
"viewport_top": "#292622",
|
||||
"viewport_bottom": "#211e1b",
|
||||
"panel": "#36332f"
|
||||
},
|
||||
"MESH": {
|
||||
"viewport_top": "#282820",
|
||||
"viewport_bottom": "#202019",
|
||||
"panel": "#35352e"
|
||||
},
|
||||
"FORM": {
|
||||
"viewport_top": "#26232b",
|
||||
"viewport_bottom": "#1e1b22",
|
||||
"panel": "#343137"
|
||||
},
|
||||
"SHEET METAL": {
|
||||
"viewport_top": "#22282a",
|
||||
"viewport_bottom": "#1b2022",
|
||||
"panel": "#303638"
|
||||
},
|
||||
"RENDER": {
|
||||
"viewport_top": "#2b2423",
|
||||
"viewport_bottom": "#221c1b",
|
||||
"panel": "#373130"
|
||||
},
|
||||
"SKETCH": {
|
||||
"viewport_top": "#252921",
|
||||
"viewport_bottom": "#1d211a",
|
||||
"panel": "#33362f"
|
||||
}
|
||||
},
|
||||
"borders": {
|
||||
"primary_inset": {
|
||||
"width": 0.5,
|
||||
"gap": 1,
|
||||
"color": "#dce2e70e"
|
||||
}
|
||||
},
|
||||
"requires": 2
|
||||
}
|
||||
@@ -2,6 +2,46 @@
|
||||
use crate::{DocError, Document, Mat, ModelBody, ModelState, Result};
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
/// A profile moved into the component receiving its own body is read through the recorded
|
||||
/// transfer frame. Reading its live placement would move the source geometry when that
|
||||
/// component moves, then move the transferred body a second time. All outputs of a constructor
|
||||
/// must reach the sketch's component through the same frame; independent cross-component
|
||||
/// references retain their ordinary live placement.
|
||||
pub(crate) fn profile_frame(doc: &Document, feature: &crate::Feature, sketch: u64) -> Option<Mat> {
|
||||
if !matches!(
|
||||
feature.kind,
|
||||
crate::FeatureKind::Extrude { operation: crate::Operation::NewBody, .. }
|
||||
| crate::FeatureKind::Revolve { operation: crate::Operation::NewBody, .. }
|
||||
) || feature.body_names.is_empty()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let owner = doc.feature(sketch)?.component;
|
||||
if owner == feature.component {
|
||||
return None;
|
||||
}
|
||||
let mut frames: std::collections::BTreeMap<&str, (u64, Mat)> =
|
||||
feature.body_names.iter().map(|name| (name.as_str(), (feature.component, crate::IDENTITY))).collect();
|
||||
let start = doc.feature_index(feature.id)?.saturating_add(1);
|
||||
for step in doc.features.iter().take(doc.marker.unwrap_or(usize::MAX)).skip(start).filter(|step| !step.suppressed) {
|
||||
let crate::FeatureKind::BodyTransfer { bodies, from, to, transform } = &step.kind else { continue };
|
||||
for name in bodies {
|
||||
if let Some((component, frame)) = frames.get_mut(name.as_ref()) {
|
||||
if *component != *from || !valid_transfer_matrix(transform) {
|
||||
return None;
|
||||
}
|
||||
*component = *to;
|
||||
*frame = crate::mat_mul(transform, frame);
|
||||
}
|
||||
}
|
||||
if frames.values().all(|(component, _)| *component == owner) {
|
||||
let (_, first) = frames.values().next()?;
|
||||
return frames.values().all(|(_, frame)| frame == first).then(|| crate::mat_inverse(first)).flatten();
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn valid_transfer_matrix(m: &Mat) -> bool {
|
||||
crate::is_placement(m)
|
||||
}
|
||||
|
||||
@@ -89,20 +89,45 @@ pub fn format_value(value: f64, kind: expr::Kind, unit: &str, decimals: u8, f: &
|
||||
if unit_kind != kind {
|
||||
return Err(DocError::Invalid("number display unit has a different kind".into()));
|
||||
}
|
||||
format_display(value / scale, scale, decimals, f)
|
||||
format_display(value / scale, scale, decimals, f, None)
|
||||
}
|
||||
|
||||
/// Format a unit-less number with the same validation and decimal rounding policy.
|
||||
pub fn format_number(x: f64, decimals: u8, f: &NumberFormat) -> Result<Shown> {
|
||||
format_display(x, 1.0, decimals, f)
|
||||
format_display(x, 1.0, decimals, f, None)
|
||||
}
|
||||
|
||||
fn format_display(x: f64, scale: f64, decimals: u8, f: &NumberFormat) -> Result<Shown> {
|
||||
/// Format an internal value with a rounding step in the selected display unit.
|
||||
/// The step is a shortest round-trip decimal, finite, positive and at most 1e6.
|
||||
/// Input decimal preparation precedes step rounding; requested decimal precision follows it.
|
||||
/// Both rounding operations use `f.ties`. The original value is never changed.
|
||||
/// The exact snapped display magnitude must be at most 1e12. An out-of-range snap
|
||||
/// returns [`DocError::Invalid`] before final decimal-place rounding, even if that
|
||||
/// final rounding would bring the displayed value back into range.
|
||||
pub fn format_value_with_step(value: f64, kind: expr::Kind, unit: &str, decimals: u8, step: f64, f: &NumberFormat) -> Result<Shown> {
|
||||
let (unit_kind, scale) = expr::unit_info(unit).ok_or_else(|| DocError::Invalid("unknown number display unit".into()))?;
|
||||
if unit_kind != kind {
|
||||
return Err(DocError::Invalid("number display unit has a different kind".into()));
|
||||
}
|
||||
format_display(value / scale, scale, decimals, f, Some(step))
|
||||
}
|
||||
|
||||
/// Format a unit-less number with the step policy of [`format_value_with_step`].
|
||||
/// Decimal precision can round a step multiple again; `Shown.value` always matches the text.
|
||||
/// Out-of-range snapped magnitudes are rejected before final decimal-place rounding.
|
||||
pub fn format_number_with_step(x: f64, decimals: u8, step: f64, f: &NumberFormat) -> Result<Shown> {
|
||||
format_display(x, 1.0, decimals, f, Some(step))
|
||||
}
|
||||
|
||||
fn format_display(x: f64, scale: f64, decimals: u8, f: &NumberFormat, step: Option<f64>) -> Result<Shown> {
|
||||
// The unit table supplies a positive finite scale. Its decimal step must be at most
|
||||
// 1e-9 internal units; the precision floor can make the effective tie window narrower.
|
||||
let unit_resolution = (scale.log10() + 9.0).ceil().max(0.0) as usize;
|
||||
let resolution = unit_resolution.max(usize::from(decimals) + 3);
|
||||
let (rounded, value) = round_decimal(x, decimals, resolution, f.ties)?;
|
||||
let (rounded, value) = match step {
|
||||
Some(step) => round_decimal_step(x, step, decimals, resolution, f.ties)?,
|
||||
None => round_decimal(x, decimals, resolution, f.ties)?,
|
||||
};
|
||||
let (integer, fraction) = rounded.split_once('.').unwrap_or((&rounded, ""));
|
||||
let fraction = if f.trailing_zeros { fraction } else { fraction.trim_end_matches('0') };
|
||||
let integer = if !f.leading_zero && integer == "0" && !fraction.is_empty() { "" } else { integer };
|
||||
@@ -121,16 +146,25 @@ fn format_display(x: f64, scale: f64, decimals: u8, f: &NumberFormat) -> Result<
|
||||
Ok(Shown { text, value })
|
||||
}
|
||||
|
||||
/// Prepare a bounded magnitude, then round decimal digits, never a binary tie comparison.
|
||||
fn round_decimal(x: f64, decimals: u8, resolution: usize, ties: Ties) -> Result<(String, f64)> {
|
||||
/// Validate and prepare the magnitude once, identically for both rounding paths.
|
||||
fn prepare_decimal(x: f64, decimals: u8, resolution: usize) -> Result<String> {
|
||||
if decimals > 8 {
|
||||
return Err(DocError::Invalid("number precision must be at most 8 decimal places".into()));
|
||||
}
|
||||
if !x.is_finite() || x.abs() > 1e12 {
|
||||
return Err(DocError::Invalid("display value must be finite with magnitude at most 1e12".into()));
|
||||
}
|
||||
let prepared = format!("{:.*}", resolution, x.abs());
|
||||
let (integer, fraction) = prepared.split_once('.').unwrap_or((&prepared, ""));
|
||||
Ok(format!("{:.*}", resolution, x.abs()))
|
||||
}
|
||||
|
||||
/// Prepare a bounded magnitude, then round decimal digits, never a binary tie comparison.
|
||||
fn round_decimal(x: f64, decimals: u8, resolution: usize, ties: Ties) -> Result<(String, f64)> {
|
||||
let prepared = prepare_decimal(x, decimals, resolution)?;
|
||||
round_prepared(&prepared, x.is_sign_negative(), decimals, ties)
|
||||
}
|
||||
|
||||
fn round_prepared(prepared: &str, negative: bool, decimals: u8, ties: Ties) -> Result<(String, f64)> {
|
||||
let (integer, fraction) = prepared.split_once('.').unwrap_or((prepared, ""));
|
||||
let places = usize::from(decimals);
|
||||
let mut digits: Vec<u8> = integer.bytes().chain(fraction.bytes().take(places)).collect();
|
||||
let discarded = fraction.as_bytes().get(places..).unwrap_or_default();
|
||||
@@ -166,10 +200,81 @@ fn round_decimal(x: f64, decimals: u8, resolution: usize, ties: Ties) -> Result<
|
||||
}
|
||||
let rounded = String::from_utf8(digits).map_err(|_| DocError::Invalid("invalid prepared digits".into()))?;
|
||||
let magnitude = rounded.parse::<f64>().map_err(|_| DocError::Invalid("invalid rounded number".into()))?;
|
||||
let negative = x.is_sign_negative() && magnitude != 0.0;
|
||||
let negative = negative && magnitude != 0.0;
|
||||
Ok((rounded, if negative { -magnitude } else { magnitude }))
|
||||
}
|
||||
|
||||
/// Divide decimal digits by a small decimal coefficient, retaining the full quotient.
|
||||
/// A shortest f64 coefficient has at most 17 significant digits. With the unit table's
|
||||
/// resolution <= 15, a scaled divisor is <= 1e21, so remainder * 10 fits u128.
|
||||
/// At most 324 appended zeros are needed, even for the smallest positive subnormal.
|
||||
fn round_decimal_step(x: f64, step: f64, decimals: u8, resolution: usize, ties: Ties) -> Result<(String, f64)> {
|
||||
if !step.is_finite() || step <= 0.0 || step > 1e6 {
|
||||
return Err(DocError::Invalid("number rounding step must be finite, positive and at most 1e6".into()));
|
||||
}
|
||||
let prepared = prepare_decimal(x, decimals, resolution)?;
|
||||
let scientific = format!("{step:e}");
|
||||
let (mantissa, exponent) = scientific.split_once('e').ok_or_else(|| DocError::Invalid("invalid decimal step".into()))?;
|
||||
let fraction = mantissa.split_once('.').map_or(0, |(_, f)| f.len());
|
||||
let coefficient = mantissa.replace('.', "").parse::<u128>().map_err(|_| DocError::Invalid("invalid step coefficient".into()))?;
|
||||
let exponent = exponent.parse::<i32>().map_err(|_| DocError::Invalid("invalid step exponent".into()))? - fraction as i32;
|
||||
let shift = exponent + resolution as i32;
|
||||
let divisor = if shift > 0 { 10_u128.checked_pow(shift as u32).and_then(|n| coefficient.checked_mul(n)) } else { Some(coefficient) }
|
||||
.ok_or_else(|| DocError::Invalid("rounding step scale overflow".into()))?;
|
||||
let mut remainder = 0_u128;
|
||||
let mut quotient = Vec::new();
|
||||
for digit in prepared.bytes().filter(|d| *d != b'.').chain(std::iter::repeat_n(b'0', (-shift).max(0) as usize)) {
|
||||
remainder = remainder * 10 + u128::from(digit - b'0');
|
||||
quotient.push((remainder / divisor) as u8);
|
||||
remainder %= divisor;
|
||||
}
|
||||
let up = remainder * 2 > divisor
|
||||
|| (remainder * 2 == divisor && (ties == Ties::HalfAwayFromZero || quotient.last().is_some_and(|d| !d.is_multiple_of(2))));
|
||||
// Exact quotient * coefficient, with the rounding increment folded into the carry.
|
||||
let mut carry = if up { coefficient } else { 0 };
|
||||
let mut product = Vec::new();
|
||||
for digit in quotient.iter().rev() {
|
||||
let n = u128::from(*digit) * coefficient + carry;
|
||||
product.push(b'0' + (n % 10) as u8);
|
||||
carry = n / 10;
|
||||
}
|
||||
while carry > 0 {
|
||||
product.push(b'0' + (carry % 10) as u8);
|
||||
carry /= 10;
|
||||
}
|
||||
product.reverse();
|
||||
let product = String::from_utf8(product).map_err(|_| DocError::Invalid("invalid step digits".into()))?;
|
||||
let mut magnitude = product.trim_start_matches('0').to_string();
|
||||
if magnitude.is_empty() {
|
||||
magnitude.push('0');
|
||||
}
|
||||
if exponent >= 0 {
|
||||
if magnitude != "0" {
|
||||
magnitude.extend(std::iter::repeat_n('0', exponent as usize));
|
||||
}
|
||||
} else {
|
||||
let places = (-exponent) as usize;
|
||||
if magnitude.len() <= places {
|
||||
magnitude = format!("{}{}", "0".repeat(places + 1 - magnitude.len()), magnitude);
|
||||
}
|
||||
magnitude.insert(magnitude.len() - places, '.');
|
||||
}
|
||||
let (integer, fraction) = magnitude.split_once('.').unwrap_or((&magnitude, ""));
|
||||
let whole = integer.parse::<u64>().map_err(|_| DocError::Invalid("rounded display magnitude overflow".into()))?;
|
||||
if whole > 1_000_000_000_000 || (whole == 1_000_000_000_000 && fraction.bytes().any(|d| d != b'0')) {
|
||||
return Err(DocError::Invalid("rounded display magnitude must be at most 1e12".into()));
|
||||
}
|
||||
// round_prepared needs at least the requested fraction digits, including for integer steps.
|
||||
let missing = usize::from(decimals).saturating_sub(fraction.len());
|
||||
if missing > 0 {
|
||||
if !magnitude.contains('.') {
|
||||
magnitude.push('.');
|
||||
}
|
||||
magnitude.extend(std::iter::repeat_n('0', missing));
|
||||
}
|
||||
round_prepared(&magnitude, x.is_sign_negative(), decimals, ties)
|
||||
}
|
||||
|
||||
fn grouped_digits(text: &mut String, digits: &str, integer: bool, groups: bool) {
|
||||
for (i, digit) in digits.chars().enumerate() {
|
||||
if groups && digits.len() >= 5 && i > 0 && if integer { (digits.len() - i).is_multiple_of(3) } else { i.is_multiple_of(3) } {
|
||||
@@ -471,6 +576,214 @@ mod number_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_ties_and_decimal_fractions() {
|
||||
for (x, step, dp, even, away) in [
|
||||
(1.25, 0.5, 1, "1.0", "1.5"),
|
||||
(1.75, 0.5, 1, "2.0", "2.0"),
|
||||
(12.5, 5.0, 0, "10", "15"),
|
||||
(25.0, 10.0, 0, "20", "30"),
|
||||
(0.125, 0.05, 2, "0.10", "0.15"),
|
||||
(0.375, 0.25, 2, "0.50", "0.50"),
|
||||
(0.15, 0.1, 1, "0.2", "0.2"),
|
||||
(0.25, 0.1, 1, "0.2", "0.3"),
|
||||
(1.25, 0.5, 0, "1", "2"),
|
||||
] {
|
||||
for (ties, expected) in [(Ties::HalfEven, even), (Ties::HalfAwayFromZero, away)] {
|
||||
let f = NumberFormat { ties, ..NumberFormat::default() };
|
||||
for sign in [1.0, -1.0] {
|
||||
let shown = format_number_with_step(sign * x, dp, step, &f).unwrap();
|
||||
assert_eq!(shown.text, if sign < 0.0 { format!("−{expected}") } else { expected.into() });
|
||||
assert_eq!(shown.value, sign * expected.parse::<f64>().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_prepares_display_before_division_and_keeps_boundary_neighbors() {
|
||||
for ties in [Ties::HalfEven, Ties::HalfAwayFromZero] {
|
||||
let f = NumberFormat { ties, ..NumberFormat::default() };
|
||||
for x in [1.75_f64.next_down(), 1.75, 1.75_f64.next_up(), 1.7499999996] {
|
||||
assert_eq!(format_number_with_step(x, 1, 0.5, &f).unwrap().text, "2.0");
|
||||
}
|
||||
for x in [1.25_f64.next_down(), 1.25, 1.25_f64.next_up()] {
|
||||
let expected = if ties == Ties::HalfEven { "1.0" } else { "1.5" };
|
||||
assert_eq!(format_number_with_step(x, 1, 0.5, &f).unwrap().text, expected);
|
||||
assert_eq!(format_number_with_step(-x, 1, 0.5, &f).unwrap().text, format!("−{expected}"));
|
||||
}
|
||||
assert_eq!(format_number_with_step(1.7499999994, 1, 0.5, &f).unwrap().text, "1.5");
|
||||
assert_eq!(format_number_with_step(1.7500000006, 1, 0.5, &f).unwrap().text, "2.0");
|
||||
}
|
||||
let f = NumberFormat::default();
|
||||
// The precision floor narrows the preparation window at eight decimals.
|
||||
assert_eq!(format_number_with_step(1.7499999996, 8, 0.5, &f).unwrap().text, "1.50000000");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_tiny_values_large_magnitudes_and_exact_final_digits() {
|
||||
let f = NumberFormat::default();
|
||||
for step in [f64::from_bits(1), f64::MIN_POSITIVE, 1e-200, 1e-20, 1e-8] {
|
||||
for x in [0.0, -0.0, f64::from_bits(1), -1e11, 1e11, 34947628153.461784] {
|
||||
let shown = format_number_with_step(x, 5, step, &f).unwrap();
|
||||
assert!(shown.value.is_finite());
|
||||
assert_eq!(shown.value, shown.text.replace('−', "-").parse::<f64>().unwrap());
|
||||
}
|
||||
}
|
||||
assert_eq!(format_number_with_step(1e12, 8, f64::from_bits(1), &f).unwrap().text, "1000000000000.00000000");
|
||||
assert_eq!(format_number_with_step(34947628153.461784, 5, 1e-8, &f).unwrap().text, "34947628153.46178");
|
||||
// A tiny step can move an exact decimal tie by less than any f64 ULP.
|
||||
// Keep those digits through the second rounding rather than parsing the snap to f64.
|
||||
assert_eq!(format_number_with_step(1.25, 1, 3e-323, &f).unwrap().text, "1.3");
|
||||
assert_eq!(format_number_with_step(-1.25, 1, 3e-323, &f).unwrap().text, "−1.3");
|
||||
for step in [0.5, 10.0, 1e6] {
|
||||
for x in [-0.0, -0.1] {
|
||||
let shown = format_number_with_step(x, 2, step, &f).unwrap();
|
||||
assert_eq!(shown.text, "0.00");
|
||||
assert_eq!(shown.value.to_bits(), 0.0_f64.to_bits());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_extreme_coefficients_have_independent_expected_digits() {
|
||||
// Shortest decimals: largest subnormal = 2225073858507201 * 10^-323,
|
||||
// smallest normal = 22250738585072014 * 10^-324. For x=1.25, integer
|
||||
// division leaves remainders 2221948386734081 and 354296156594724.
|
||||
// Twice the first is above its divisor, twice the second below: the
|
||||
// snap is just above/below 1.25, so final rounding gives 1.3/1.2 in BOTH modes.
|
||||
// Other expected digits were calculated with independent rational arithmetic.
|
||||
for (step, quarter) in [(f64::MIN_POSITIVE.next_down(), "1.3"), (f64::MIN_POSITIVE, "1.2")] {
|
||||
for ties in [Ties::HalfEven, Ties::HalfAwayFromZero] {
|
||||
let f = NumberFormat { ties, ..NumberFormat::default() };
|
||||
for (x, dp, expected) in [
|
||||
(1.25, 1, quarter),
|
||||
(99999999999.75, 0, "100000000000"),
|
||||
(99999999999.75, 1, "99999999999.7"),
|
||||
(99999999999.75, 2, "99999999999.75"),
|
||||
(34947628153.461784, 2, "34947628153.46"),
|
||||
(34947628153.461784, 5, "34947628153.46178"),
|
||||
] {
|
||||
for sign in [1.0, -1.0] {
|
||||
let shown = format_number_with_step(sign * x, dp, step, &f).unwrap();
|
||||
let text = if sign < 0.0 { format!("−{expected}") } else { expected.into() };
|
||||
assert_eq!(shown.text, text, "x={x:?}, step={step:e}, dp={dp}, ties={ties:?}");
|
||||
assert_eq!(shown.value, sign * expected.parse::<f64>().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_and_final_decimal_rounding_carry_independently() {
|
||||
// 9.975 / .05 = 199.5: both modes increment the step index to 200.
|
||||
// 9.96 / .03 = 332 exactly: only the final rounding carries to 10.0.
|
||||
// 1.26 / .1 = 12.6: the snap is 1.3, then zero decimals give 1 (not 1.26).
|
||||
// 1.49 / .5 = 2.98: the snap is 1.5, then zero decimals give 2 (not 1).
|
||||
for (x, step, dp, even, away) in [
|
||||
(9.975, 0.05, 2, "10.00", "10.00"),
|
||||
(9.96, 0.03, 1, "10.0", "10.0"),
|
||||
(1.26, 0.1, 0, "1", "1"),
|
||||
(1.49, 0.5, 0, "2", "2"),
|
||||
(100000000000.25, 0.1, 0, "100000000000", "100000000000"),
|
||||
(100000000000.25, 0.1, 1, "100000000000.2", "100000000000.3"),
|
||||
(100000000000.25, 0.1, 2, "100000000000.20", "100000000000.30"),
|
||||
(999999999999.75, 0.25, 0, "1000000000000", "1000000000000"),
|
||||
] {
|
||||
for (ties, expected) in [(Ties::HalfEven, even), (Ties::HalfAwayFromZero, away)] {
|
||||
let f = NumberFormat { ties, ..NumberFormat::default() };
|
||||
for sign in [1.0, -1.0] {
|
||||
let shown = format_number_with_step(sign * x, dp, step, &f).unwrap();
|
||||
assert_eq!(shown.text, if sign < 0.0 { format!("−{expected}") } else { expected.into() });
|
||||
assert_eq!(shown.value, sign * expected.parse::<f64>().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_rejects_invalid_inputs_and_out_of_range_snap() {
|
||||
let f = NumberFormat::default();
|
||||
for step in [0.0, -0.0, -0.5, f64::NAN, f64::INFINITY, f64::NEG_INFINITY, 1e6_f64.next_up()] {
|
||||
assert!(matches!(format_number_with_step(1.0, 2, step, &f), Err(DocError::Invalid(_))));
|
||||
assert!(matches!(format_value_with_step(1.0, Length, "mm", 2, step, &f), Err(DocError::Invalid(_))));
|
||||
}
|
||||
for x in [f64::NAN, f64::INFINITY, f64::NEG_INFINITY, 1e12_f64.next_up(), -1e12_f64.next_up()] {
|
||||
assert!(matches!(format_number_with_step(x, 2, 0.5, &f), Err(DocError::Invalid(_))));
|
||||
}
|
||||
for dp in [9, 255] {
|
||||
assert!(matches!(format_number_with_step(1.0, dp, 0.5, &f), Err(DocError::Invalid(_))));
|
||||
}
|
||||
for x in [1e12, -1e12] {
|
||||
for ties in [Ties::HalfEven, Ties::HalfAwayFromZero] {
|
||||
let f = NumberFormat { ties, ..f };
|
||||
for step in [600_000.0, 0.6] {
|
||||
// The .6 snap has magnitude 1e12 + .2: reject it even though
|
||||
// zero decimal places would otherwise bring it back to 1e12.
|
||||
assert!(matches!(format_number_with_step(x, 0, step, &f), Err(DocError::Invalid(_))));
|
||||
}
|
||||
}
|
||||
assert_eq!(format_number_with_step(x, 0, 1e6, &f).unwrap().value, x);
|
||||
}
|
||||
for (kind, unit) in [(Length, "deg"), (Angle, "mm"), (Length, "unknown")] {
|
||||
assert!(matches!(format_value_with_step(1.0, kind, unit, 2, 0.5, &f), Err(DocError::Invalid(_))));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_units_options_and_input_preservation() {
|
||||
let f = NumberFormat::default();
|
||||
let input: f64 = 25.4 * 1.25;
|
||||
let bits = input.to_bits();
|
||||
assert_eq!(format_value_with_step(input, Length, "in", 1, 0.5, &f).unwrap().text, "1.0");
|
||||
assert_eq!(input.to_bits(), bits);
|
||||
assert_eq!(format_value_with_step(std::f64::consts::PI / 6.0, Angle, "deg", 1, 5.0, &f).unwrap().text, "30.0");
|
||||
assert_eq!(format_value_with_step(1e15, Length, "m", 1, 10.0, &f).unwrap().value, 1e12);
|
||||
let styled = NumberFormat { marker: DecimalMarker::Comma, groups: true, ..f };
|
||||
assert_eq!(format_number_with_step(-12345.25, 2, 0.5, &styled).unwrap().text, "−12\u{202f}345,00");
|
||||
let trim = NumberFormat { leading_zero: false, trailing_zeros: false, ..styled };
|
||||
assert_eq!(format_number_with_step(-0.6, 3, 0.5, &trim).unwrap().text, "−,5");
|
||||
assert_eq!(format_number_with_step(1.23456789, 8, 1e-8, &styled).unwrap().text, "1,234\u{202f}567\u{202f}89");
|
||||
for (distance, expected) in [(0.4, "1.0"), (0.6, "0.5")] {
|
||||
assert_eq!(format_value_with_step((0.75 - distance * 1e-4) * 1e-6, Length, "nm", 1, 0.5, &f).unwrap().text, expected);
|
||||
}
|
||||
for step in [1e6_f64.next_down(), 0.12345678901234567, 2.2250738585072014e-308] {
|
||||
let shown = format_number_with_step(12345.6789, 8, step, &f).unwrap();
|
||||
assert_eq!(shown.value, shown.text.parse::<f64>().unwrap());
|
||||
}
|
||||
// Explicitly keep both historical policies, including their different decimal ties.
|
||||
assert_eq!(format_number(2.665, 2, &f).unwrap().text, "2.66");
|
||||
assert_eq!(length_number(2.665, "mm", 2), "2.67");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn step_seeded_integer_reference_and_hostile_domain() {
|
||||
let mut seed = 0x4896_1138_0abc_def1;
|
||||
for _ in 0..20_000 {
|
||||
// Independent bounded integer oracle: x and step are thousandths; dp=3.
|
||||
let n = random(&mut seed) % 1_000_000;
|
||||
let s = random(&mut seed) % 100_000 + 1;
|
||||
for ties in [Ties::HalfEven, Ties::HalfAwayFromZero] {
|
||||
let f = NumberFormat { ties, ..NumberFormat::default() };
|
||||
let q = n / s;
|
||||
let r = n % s;
|
||||
let up = 2 * r > s || (2 * r == s && (ties == Ties::HalfAwayFromZero || q % 2 == 1));
|
||||
let expected = (q + u64::from(up)) * s;
|
||||
let text = format!("{}.{:03}", expected / 1000, expected % 1000);
|
||||
let shown = format_number_with_step(n as f64 / 1000.0, 3, s as f64 / 1000.0, &f).unwrap();
|
||||
assert_eq!(shown.text, text);
|
||||
// Exercise arbitrary positive subnormals and normal steps without quotient overflow.
|
||||
let step = f64::from_bits(random(&mut seed));
|
||||
if step.is_finite() && step > 0.0 && step <= 1e6 {
|
||||
let shown = format_number_with_step(n as f64, 3, step, &f).unwrap();
|
||||
assert!(shown.value.is_finite() && shown.value >= 0.0);
|
||||
assert_eq!(shown.value, shown.text.parse::<f64>().unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn random(state: &mut u64) -> u64 {
|
||||
*state ^= *state << 13;
|
||||
*state ^= *state >> 7;
|
||||
|
||||
@@ -2410,6 +2410,12 @@ pub enum HoleKind {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[walk(angle = "Tip angle")]
|
||||
tip_angle: Option<Expr>,
|
||||
/// Printing aid: two bridge layers this thick below the counterbore's floor (a slot along
|
||||
/// X, then a square), so a printer bridges the step instead of sagging into it. Absent:
|
||||
/// a plain counterbore.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[walk(length = "Bridge layer")]
|
||||
bridge: Option<Expr>,
|
||||
},
|
||||
Countersink {
|
||||
#[walk(length = "Countersink diameter")]
|
||||
|
||||
@@ -1650,6 +1650,13 @@ fn placement_digest(doc: &Document, f: &Feature, st: Option<&ModelState>) -> u64
|
||||
for (sketch, _) in f.kind.profile_sels() {
|
||||
if doc.feature(sketch).is_some_and(|s| s.component != f.component) {
|
||||
reads.sketch(doc, sketch);
|
||||
// A later transfer can preserve this profile's historical frame. Changes to that
|
||||
// boundary (including suppression and rollback) must invalidate the constructor.
|
||||
if let Some(relative) = crate::body_transfer::profile_frame(doc, f, sketch) {
|
||||
"transferred profile".hash(&mut h);
|
||||
sketch.hash(&mut h);
|
||||
hash_placement(&relative, &mut h);
|
||||
}
|
||||
}
|
||||
}
|
||||
let path = match &f.kind {
|
||||
@@ -2930,13 +2937,67 @@ fn clear_tools_as_one(tools: Vec<Traced>) -> Result<Vec<Traced>> {
|
||||
return Ok(tools);
|
||||
}
|
||||
let bodies: Vec<Body> = tools.iter().map(|t| t.body.clone()).collect();
|
||||
Ok(match kernel::union_apart(&bodies)? {
|
||||
let one = match kernel::union_apart(&bodies)? {
|
||||
Some(one) => Some(one),
|
||||
// The kernel only compares the tools' boxes, so copies of a through hole close together
|
||||
// on a circle (their boxes overlap) seem to meet (#9007). Their exact shapes may still
|
||||
// be apart.
|
||||
None if tools_clearly_apart(&bodies) => kernel::join_apart(&bodies).ok().flatten(),
|
||||
None => None,
|
||||
};
|
||||
#[cfg(test)]
|
||||
cost_tests::count(|c| c.cut_tools += one.as_ref().map_or(tools.len(), |_| 1));
|
||||
Ok(match one {
|
||||
// Each piece's faces keep the names of the tool it is.
|
||||
Some(one) => vec![Traced::step(one, &tools.iter().collect::<Vec<_>>())],
|
||||
None => tools,
|
||||
})
|
||||
}
|
||||
|
||||
/// Most pairs of tools whose boxes meet that [`tools_clearly_apart`] tests.
|
||||
const MAX_CLOSE_TOOL_PAIRS: usize = 4096;
|
||||
|
||||
/// Whether no two of `bodies` meet or touch, decided on their exact shapes. Only pairs whose
|
||||
/// exact boxes, grown by twice the bodies' tolerances (as [`kernel::apart`] grows them), meet
|
||||
/// are tested, by [`apart_by_union`]. `false` whenever that cannot be shown: a mesh body, a body
|
||||
/// without an exact box, too many pairs to test, a union that fails.
|
||||
fn tools_clearly_apart(bodies: &[Body]) -> bool {
|
||||
if bodies.len() < 2 || bodies.len() > 10_000 || bodies.iter().any(Body::is_mesh) {
|
||||
return false;
|
||||
}
|
||||
let Some(boxes) = bodies.iter().map(more::exact_box).collect::<Option<Vec<_>>>() else { return false };
|
||||
let mut order: Vec<usize> = (0..boxes.len()).collect();
|
||||
order.sort_by(|&i, &j| boxes.get(i).map_or(0.0, |b| b.min.x).total_cmp(&boxes.get(j).map_or(0.0, |b| b.min.x)));
|
||||
let mut close = Vec::new();
|
||||
for (k, &i) in order.iter().enumerate() {
|
||||
let Some(a) = boxes.get(i) else { return false };
|
||||
for &j in order.iter().skip(k + 1) {
|
||||
let Some(b) = boxes.get(j) else { return false };
|
||||
if b.min.x > a.max.x {
|
||||
break;
|
||||
}
|
||||
if more::boxes_apart(&Some(*a), &Some(*b)) {
|
||||
continue;
|
||||
}
|
||||
if close.len() == MAX_CLOSE_TOOL_PAIRS {
|
||||
return false;
|
||||
}
|
||||
close.push((i, j));
|
||||
}
|
||||
}
|
||||
close.into_iter().all(|(i, j)| matches!((bodies.get(i), bodies.get(j)), (Some(a), Some(b)) if apart_by_union(a, b)))
|
||||
}
|
||||
|
||||
/// Whether the exact union of `a` and `b` comes out in two pieces that share no face, edge or
|
||||
/// vertex. Crossing and nested bodies come out in one piece, touching ones in one or in two that
|
||||
/// share an edge or a face.
|
||||
fn apart_by_union(a: &Body, b: &Body) -> bool {
|
||||
match kernel::boolean(a, b, BoolOp::Union) {
|
||||
Ok(Some(u)) => u.record().material_regions().len() == 2 && u.region_contacts().is_ok_and(|c| c.is_empty()),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// An intersect never deletes a body by accident (#5295): it is refused when nothing of a named
|
||||
/// target would remain, when nothing of any target would remain, or when the tools meet a target
|
||||
/// and the boolean still came out empty. Only an unnamed target the tools miss altogether is
|
||||
@@ -4635,18 +4696,41 @@ fn hole_tools_and_prisms(
|
||||
match hole {
|
||||
HoleKind::Simple => tools.extend(bore(None)?),
|
||||
HoleKind::Drilled { tip_angle } => tools.extend(bore(Some(tip_angle))?),
|
||||
HoleKind::Counterbore { cb_diameter, cb_depth, tip_angle } => {
|
||||
HoleKind::Counterbore { cb_diameter, cb_depth, tip_angle, bridge } => {
|
||||
let (rc, dc) = (val(vals, cb_diameter, Kind::Length)? / 2.0, val(vals, cb_depth, Kind::Length)?);
|
||||
if !(rc > r && dc > 0.0 && -dc > bottom) {
|
||||
return Err(DocError::Invalid("the counterbore must be wider than the hole and shallower than it".into()));
|
||||
}
|
||||
// Wide and shallow first: the narrow hole then crosses the pocket floor.
|
||||
tools.push(cyl(rc, -dc, top, "cbore")?);
|
||||
if let Some(layer) = bridge {
|
||||
let layer = val(vals, layer, Kind::Length)?;
|
||||
tools.extend(bridge_tools(&plane, r, rc, dc, bottom, layer)?);
|
||||
// Through all, `bottom` is the tool's reach, not the material's: the second layer
|
||||
// must end inside a body (exact classification), short of the exit face.
|
||||
if depth.is_none() {
|
||||
let past = *position + dir * (dc + 2.0 * layer + size * 1e-6);
|
||||
let classes = st.bodies.iter().map(|b| b.body.classify_point(past)).collect::<std::result::Result<Vec<_>, _>>()?;
|
||||
if !classes.contains(&kernel::PointClass::Inside) {
|
||||
return Err(bridge_too_deep(layer, "make the counterbore shallower or the bridge thinner"));
|
||||
}
|
||||
}
|
||||
}
|
||||
tools.extend(bore(tip_angle.as_ref())?);
|
||||
}
|
||||
HoleKind::Countersink { cs_diameter, cs_angle, tip_angle } => {
|
||||
let (rc, half) = (val(vals, cs_diameter, Kind::Length)? / 2.0, val(vals, cs_angle, Kind::Angle)? / 2.0);
|
||||
if !(rc > r && half > 1e-3 && half < std::f64::consts::FRAC_PI_2) {
|
||||
// The angle and the width are told apart: an angle out of range is not a countersink
|
||||
// too narrow (#9625). The cone's length grows as 1 / tan(half), so a near-flat angle
|
||||
// is refused at a floor the message names, rather than built kilometres long.
|
||||
const MIN_ANGLE_DEG: f64 = 0.115;
|
||||
if !(2.0 * half > MIN_ANGLE_DEG.to_radians() && half < std::f64::consts::FRAC_PI_2) {
|
||||
return Err(DocError::Invalid(format!(
|
||||
"the countersink angle must be more than {MIN_ANGLE_DEG}° and less than 180°, not {}°",
|
||||
((2.0 * half).to_degrees() * 1e6).round() / 1e6
|
||||
)));
|
||||
}
|
||||
if !(rc > r) {
|
||||
return Err(DocError::Invalid("the countersink must be wider than the hole".into()));
|
||||
}
|
||||
// One revolved tool: the cone from its rim on the face to just inside the hole
|
||||
@@ -4670,6 +4754,59 @@ fn hole_tools_and_prisms(
|
||||
Ok(tools)
|
||||
}
|
||||
|
||||
/// How much wider than the hole a bridged counterbore's slot and square are, in mm.
|
||||
const BRIDGE_CLEARANCE: f64 = 0.02;
|
||||
|
||||
/// Why a bridged counterbore's two layers of `layer` were refused: they reach past the hole, and
|
||||
/// `fix` says what to change.
|
||||
fn bridge_too_deep(layer: f64, fix: &str) -> DocError {
|
||||
DocError::Invalid(format!("the two bridge layers ({:.3} mm) must fit in the hole below the counterbore: {fix}", 2.0 * layer))
|
||||
}
|
||||
|
||||
/// The bridge layers of a counterbore printed opening down: below its floor, a slot across the
|
||||
/// whole counterbore, along X (one `layer` thick), then a square (one more), both
|
||||
/// [`BRIDGE_CLEARANCE`] wider than the hole, so each layer spans between supported edges.
|
||||
/// `plane` is the hole's, its normal out of the material; the bore crosses both layers, clear of
|
||||
/// their sides.
|
||||
fn bridge_tools(plane: &Plane, r: f64, rc: f64, dc: f64, bottom: f64, layer: f64) -> Result<Vec<(Traced, Option<more::PrimitivePrism>)>> {
|
||||
if !(layer > 0.0 && layer.is_finite()) {
|
||||
return Err(DocError::Invalid("the bridge layer must be a positive length, such as 0.2 mm".into()));
|
||||
}
|
||||
let (t1, t2) = (-dc - layer, -dc - 2.0 * layer);
|
||||
if t2 <= bottom {
|
||||
return Err(bridge_too_deep(layer, "make the hole deeper or the bridge thinner"));
|
||||
}
|
||||
// Both a hair wider than the hole, so the bore's rim doesn't touch their sides.
|
||||
let q = r + BRIDGE_CLEARANCE / 2.0;
|
||||
// The slot's ends need room on the counterbore's wall past that.
|
||||
if !(rc >= q + BRIDGE_CLEARANCE / 2.0) {
|
||||
return Err(DocError::Invalid(format!("a bridged counterbore must be at least {} mm wider than the hole", 2.0 * BRIDGE_CLEARANCE)));
|
||||
}
|
||||
// The slot along world X where the axis allows it, else along the hole plane's own x.
|
||||
let n = plane.normal();
|
||||
let x = (Vec3::X - n * Vec3::X.dot(n)).normalized().filter(|_| Vec3::X.dot(n).abs() < 0.99).unwrap_or(plane.x);
|
||||
let bp = Plane::new(plane.origin, x, n.cross(x)).ok_or_else(|| DocError::Invalid("hole axis".into()))?;
|
||||
// The slot ends on the counterbore's wall: two lines and two arcs of its circle.
|
||||
let a = (rc * rc - q * q).sqrt();
|
||||
let phi = q.atan2(a);
|
||||
let slot = solidcore_record::Loop2 {
|
||||
segs: vec![
|
||||
solidcore_record::Seg2::Line { a: Vec2::new(-a, -q), b: Vec2::new(a, -q) },
|
||||
solidcore_record::Seg2::Arc { center: Vec2::ZERO, radius: rc, start: -phi, sweep: 2.0 * phi },
|
||||
solidcore_record::Seg2::Line { a: Vec2::new(a, q), b: Vec2::new(-a, q) },
|
||||
solidcore_record::Seg2::Arc { center: Vec2::ZERO, radius: rc, start: std::f64::consts::PI - phi, sweep: 2.0 * phi },
|
||||
],
|
||||
};
|
||||
let square = solidcore_record::Loop2::polygon(&[Vec2::new(-q, -q), Vec2::new(q, -q), Vec2::new(q, q), Vec2::new(-q, q)]);
|
||||
let mut tools = Vec::new();
|
||||
for (outline, lo, hi) in [(slot, t1, -dc), (square, t2, t1)] {
|
||||
let region = Region2 { outer: outline, holes: vec![] };
|
||||
let tool = kernel::extrude(&bp, &[region], lo, hi)?.pop().ok_or_else(|| DocError::Invalid("hole tool".into()))?;
|
||||
tools.push((crate::lineage::part_tool(tool, "bridge"), None));
|
||||
}
|
||||
Ok(tools)
|
||||
}
|
||||
|
||||
/// The angular interval used by both the solid and its interactive extent handles.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct RevolveExtent {
|
||||
@@ -4798,6 +4935,22 @@ struct ExtrudeConstructor {
|
||||
interval: (f64, f64),
|
||||
}
|
||||
|
||||
/// How far from its sketch plane an extrude may reach, in mm. It mirrors the limit the kernel's
|
||||
/// `finite` check in `crates/kernel/src/build.rs` puts on an extrusion's start and end (a literal
|
||||
/// there, not exported), so a too-long extrusion is refused here, by name, before the kernel is
|
||||
/// called: the kernel's own message, `end = 1000000000`, names no field (#9625).
|
||||
const MAX_EXTRUDE_REACH: f64 = 1e7;
|
||||
|
||||
/// Refuse an extrusion whose ends lie past [`MAX_EXTRUDE_REACH`] from the sketch plane.
|
||||
fn extrude_within_reach(ends: [f64; 2]) -> Result<()> {
|
||||
match ends.into_iter().find(|x| x.abs() >= MAX_EXTRUDE_REACH) {
|
||||
Some(x) => Err(DocError::Invalid(format!(
|
||||
"the extrusion is too long: its end is {x} mm from the sketch plane, past the limit of {MAX_EXTRUDE_REACH} mm"
|
||||
))),
|
||||
None => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct planar caps locally before placing the completed tool.
|
||||
fn centered_extrude(
|
||||
plane: &Plane,
|
||||
@@ -4905,10 +5058,10 @@ fn feature_tools_with_constructor(
|
||||
let unnamed = |bodies: Vec<Body>| -> Vec<Traced> { bodies.into_iter().map(Traced::unnamed).collect() };
|
||||
match &f.kind {
|
||||
FeatureKind::Extrude { sketch, profiles, extent, operation, targets, thin } => {
|
||||
let ss = sketch_in_feature_frame(
|
||||
let ss = constructor_profile_in_frame(
|
||||
doc,
|
||||
st.sketch(sketch.0).ok_or_else(|| DocError::Unknown(format!("sketch {sketch} (it must come earlier in the timeline)")))?,
|
||||
f.component,
|
||||
f,
|
||||
)?;
|
||||
let regions = match thin {
|
||||
Some(thin) => thin_regions(vals, &ss, thin)?,
|
||||
@@ -4981,6 +5134,7 @@ fn feature_tools_with_constructor(
|
||||
Some(e) => val(vals, e, Kind::Length)?,
|
||||
None => 0.0,
|
||||
};
|
||||
extrude_within_reach([base, base + sign * len])?;
|
||||
let start_plane = ss.plane.offset(base);
|
||||
let caps = [
|
||||
Some(crate::lineage::extrude_cap_role(base)),
|
||||
@@ -5050,6 +5204,7 @@ fn feature_tools_with_constructor(
|
||||
lo = hs.iter().cloned().fold(lo, f64::min) - margin;
|
||||
}
|
||||
}
|
||||
extrude_within_reach([lo + off, hi + off])?;
|
||||
let untrimmed = extent.to.is_none() && extent.from.is_none() && !extent.through_all;
|
||||
let mut tools = Vec::new();
|
||||
for r in ®ions {
|
||||
@@ -5130,10 +5285,10 @@ fn feature_tools_with_constructor(
|
||||
Ok(tools)
|
||||
}
|
||||
FeatureKind::Revolve { sketch, profiles, axis, angle, angle2, symmetric, convention, to, .. } => {
|
||||
let ss = sketch_in_feature_frame(
|
||||
let ss = constructor_profile_in_frame(
|
||||
doc,
|
||||
st.sketch(sketch.0).ok_or_else(|| DocError::Unknown(format!("sketch {sketch} (it must come earlier in the timeline)")))?,
|
||||
f.component,
|
||||
f,
|
||||
)?;
|
||||
let regions = solidcraft_sketch::merge_regions(&select_profiles(&ss, profiles)?);
|
||||
let (o, d) =
|
||||
@@ -5538,16 +5693,27 @@ fn sketch_in_feature_frame(doc: &Document, sketch: &SolvedSketch, consumer: u64)
|
||||
profile_in_frame(doc, sketch, consumer)
|
||||
}
|
||||
|
||||
fn constructor_profile_in_frame(doc: &Document, sketch: &SolvedSketch, feature: &Feature) -> Result<SolvedSketch> {
|
||||
match crate::body_transfer::profile_frame(doc, feature, sketch.feature) {
|
||||
Some(relative) => profile_with_transform(sketch, &relative),
|
||||
None => sketch_in_feature_frame(doc, sketch, feature.component),
|
||||
}
|
||||
}
|
||||
|
||||
fn profile_in_frame(doc: &Document, sketch: &SolvedSketch, consumer: u64) -> Result<SolvedSketch> {
|
||||
let owner = doc.feature(sketch.feature).map(|feature| feature.component).unwrap_or(0);
|
||||
let inverse =
|
||||
crate::mat_inverse(&doc.component_transform(consumer)).ok_or_else(|| DocError::Invalid("profile consumer frame is invalid".into()))?;
|
||||
let relative = crate::mat_mul(&inverse, &doc.component_transform(owner));
|
||||
profile_with_transform(sketch, &relative)
|
||||
}
|
||||
|
||||
fn profile_with_transform(sketch: &SolvedSketch, relative: &Mat) -> Result<SolvedSketch> {
|
||||
let mut mapped = sketch.clone();
|
||||
mapped.plane = Plane::new(
|
||||
crate::apply_point(&relative, sketch.plane.origin),
|
||||
crate::apply_vector(&relative, sketch.plane.x),
|
||||
crate::apply_vector(&relative, sketch.plane.y),
|
||||
crate::apply_point(relative, sketch.plane.origin),
|
||||
crate::apply_vector(relative, sketch.plane.x),
|
||||
crate::apply_vector(relative, sketch.plane.y),
|
||||
)
|
||||
.ok_or_else(|| DocError::Invalid("profile sketch frame is invalid".into()))?;
|
||||
Ok(mapped)
|
||||
@@ -6075,7 +6241,6 @@ fn path_at(segs: &[kernel::PathSeg], d: f64) -> (Vec3, Vec3) {
|
||||
(Vec3::ZERO, Vec3::X)
|
||||
}
|
||||
|
||||
/// Whether a copy has no material to cut in any of its eligible targets.
|
||||
/// The bodies a hole cuts: those its feature names, else its component's and its own (as
|
||||
/// `apply_traced` picks a cut's targets).
|
||||
fn hole_targets<'a>(st: &'a ModelState, f: &Feature) -> Vec<&'a ModelBody> {
|
||||
@@ -6105,18 +6270,120 @@ fn hole_misses(st: &ModelState, f: &Feature, tool: &Body) -> bool {
|
||||
targets.iter().all(|b| more::boxes_apart(&tool_box, &b.body.exact_bounds().ok()))
|
||||
}
|
||||
|
||||
fn copy_misses(st: &ModelState, f: &Feature, targets: &[String], tools: &[Traced]) -> bool {
|
||||
/// The bodies a pattern's cut copies are checked against for missing them ([`copy_misses`]).
|
||||
fn miss_scope<'a>(st: &'a ModelState, f: &'a Feature, targets: &'a [String]) -> impl Iterator<Item = &'a ModelBody> + 'a {
|
||||
let targets = if targets.is_empty() { &f.participants } else { targets };
|
||||
let all = targets.len() == 1 && targets.first().is_some_and(|t| t == "*");
|
||||
st.bodies
|
||||
.iter()
|
||||
.filter(|b| all || if targets.is_empty() { b.component == f.component || b.feature == f.id } else { targets.contains(&b.name) })
|
||||
.all(|b| {
|
||||
tools.iter().all(|t| {
|
||||
// An inconclusive probe is not a miss: it must not reject an otherwise valid cut.
|
||||
matches!(kernel::boolean(&b.body, &t.body, BoolOp::Intersect), Ok(None))
|
||||
})
|
||||
.filter(move |b| all || if targets.is_empty() { b.component == f.component || b.feature == f.id } else { targets.contains(&b.name) })
|
||||
}
|
||||
|
||||
/// Whether a copy has no material to cut in any of its eligible targets.
|
||||
fn copy_misses(st: &ModelState, f: &Feature, targets: &[String], tools: &[Traced]) -> bool {
|
||||
miss_scope(st, f, targets).all(|b| {
|
||||
tools.iter().all(|t| {
|
||||
#[cfg(test)]
|
||||
cost_tests::count(|c| c.miss_intersects += 1);
|
||||
// An inconclusive probe is not a miss: it must not reject an otherwise valid cut.
|
||||
matches!(kernel::boolean(&b.body, &t.body, BoolOp::Intersect), Ok(None))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// How many of a pattern's cut copies (`instances`, ranges of `copies`) remove no material, and
|
||||
/// how many copies there are. [`copy_misses`] intersects a copy with every target, which on a
|
||||
/// body with many holes costs far more than cutting the copy (#9007). A copy that a point test
|
||||
/// shows takes material from a target ([`shares_material`]) is not a miss, and skips it; only
|
||||
/// copies the test cannot place (in an earlier hole, on the edge, thinner than its samples) are
|
||||
/// intersected.
|
||||
fn count_copy_misses(
|
||||
st: &ModelState,
|
||||
f: &Feature,
|
||||
targets: &[String],
|
||||
copies: &[Traced],
|
||||
instances: &[std::ops::Range<usize>],
|
||||
axes: &[Vec<(Vec3, Vec3)>],
|
||||
) -> (usize, usize) {
|
||||
let scope: Vec<&ModelBody> = miss_scope(st, f, targets).collect();
|
||||
let (mut missed, mut total) = (0, 0);
|
||||
for (k, tools) in instances.iter().enumerate().filter_map(|(k, i)| Some((k, copies.get(i.clone())?))) {
|
||||
total += 1;
|
||||
let lines = axes.get(k).map_or(&[][..], Vec::as_slice);
|
||||
let takes = tools.iter().any(|t| scope.iter().any(|b| shares_material(&b.body, &t.body, lines)));
|
||||
if !takes && copy_misses(st, f, targets, tools) {
|
||||
missed += 1;
|
||||
}
|
||||
}
|
||||
(missed, total)
|
||||
}
|
||||
|
||||
/// Whether some point lies in the material of both B-rep bodies `target` and `tool`, by their
|
||||
/// exact point classification (a point on either's boundary does not count). Tried along
|
||||
/// `lines` (a hole's axis: through the wall it drills into, however thin and slanted), along the
|
||||
/// axes of the tool's round faces (a cylinder's axis, the middle of a slot's ends) and along the
|
||||
/// three lines parallel to the axes through the middle of the box both exact boxes hold (the
|
||||
/// axis of a straight hole through a plate), within that box. `false` says nothing.
|
||||
fn shares_material(target: &Body, tool: &Body, lines: &[(Vec3, Vec3)]) -> bool {
|
||||
if target.is_mesh() || tool.is_mesh() {
|
||||
return false;
|
||||
}
|
||||
let (Some(a), Some(b)) = (more::exact_box(target), more::exact_box(tool)) else { return false };
|
||||
let both = a.intersection(&b);
|
||||
if both.is_empty() {
|
||||
return false;
|
||||
}
|
||||
let c = both.center();
|
||||
let mut all = lines.to_vec();
|
||||
all.extend(round_face_axes(tool, MAX_PROBED_FACES));
|
||||
all.extend([(c, Vec3::X), (c, Vec3::Y), (c, Vec3::Z)]);
|
||||
let inside = |b: &Body, p: Vec3| matches!(b.classify_point(p), Ok(kernel::PointClass::Inside));
|
||||
all.iter().any(|&(o, d)| {
|
||||
let Some((lo, hi)) = line_in_box(&both, o, d) else { return false };
|
||||
(0..SAMPLES_PER_LINE).any(|k| {
|
||||
let p = o + d * (lo + (hi - lo) * (k as f64 + 0.5) / SAMPLES_PER_LINE as f64);
|
||||
inside(tool, p) && inside(target, p)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Points tried on each line by [`shares_material`].
|
||||
const SAMPLES_PER_LINE: usize = 16;
|
||||
/// Most faces of a tool whose surfaces [`shares_material`] looks along.
|
||||
const MAX_PROBED_FACES: usize = 32;
|
||||
|
||||
/// The axes of the round faces among the first `max` faces of `body`, from their exact surfaces:
|
||||
/// a cylinder's, a cone's and a torus's axis, and the lines along X, Y and Z through a sphere's
|
||||
/// centre.
|
||||
fn round_face_axes(body: &Body, max: usize) -> Vec<(Vec3, Vec3)> {
|
||||
let mut lines = Vec::new();
|
||||
for face in 0..body.face_count().min(max) {
|
||||
match kernel::face_surface(body, face) {
|
||||
Some(kernel::FaceSurface::Cylinder { origin, axis, .. }) => lines.push((origin, Vec3::from(axis))),
|
||||
Some(kernel::FaceSurface::Cone { apex, axis, .. }) => lines.push((apex, Vec3::from(axis))),
|
||||
Some(kernel::FaceSurface::Torus { center, axis, .. }) => lines.push((center, Vec3::from(axis))),
|
||||
Some(kernel::FaceSurface::Sphere { center, .. }) => lines.extend([(center, Vec3::X), (center, Vec3::Y), (center, Vec3::Z)]),
|
||||
Some(kernel::FaceSurface::Plane { .. }) | None => {}
|
||||
}
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
/// The stretch of the line `o + t d` inside `b`, as the range of `t`; `None` when it misses.
|
||||
fn line_in_box(b: &solidcraft_geom::Aabb3, o: Vec3, d: Vec3) -> Option<(f64, f64)> {
|
||||
let (mut lo, mut hi) = (f64::NEG_INFINITY, f64::INFINITY);
|
||||
for (o, d, min, max) in [(o.x, d.x, b.min.x, b.max.x), (o.y, d.y, b.min.y, b.max.y), (o.z, d.z, b.min.z, b.max.z)] {
|
||||
if d.abs() < 1e-12 {
|
||||
if o < min || o > max {
|
||||
return None;
|
||||
}
|
||||
} else {
|
||||
let (a, c) = ((min - o) / d, (max - o) / d);
|
||||
lo = lo.max(a.min(c));
|
||||
hi = hi.min(a.max(c));
|
||||
}
|
||||
}
|
||||
(lo.is_finite() && hi.is_finite() && lo <= hi).then_some((lo, hi))
|
||||
}
|
||||
|
||||
/// The deepest a pattern or mirror reaches through patterns and mirrors of features (#395).
|
||||
@@ -6358,6 +6625,9 @@ fn replay(
|
||||
let targets = if present.is_empty() { targets } else { present };
|
||||
let mut copies = Vec::new();
|
||||
let mut instances = Vec::with_capacity(mats.len());
|
||||
// Each hole copy's axes (spot and direction), where the check for copies that miss looks
|
||||
// for material first.
|
||||
let mut axes: Vec<Vec<(Vec3, Vec3)>> = Vec::new();
|
||||
if let FeatureKind::Hole { diameter, depth, hole, to, .. } = &src.kind {
|
||||
// A hole is drilled again at each copy of its spot (found on the surface there), so
|
||||
// a blind hole's depth counts from the face at the copy, not from the bottom of the
|
||||
@@ -6366,8 +6636,10 @@ fn replay(
|
||||
for (k, m) in mats.iter().enumerate() {
|
||||
let d = crate::apply_vector(m, dir).normalized().ok_or_else(|| DocError::Invalid("hole direction".into()))?;
|
||||
let start = copies.len();
|
||||
let mut on = Vec::with_capacity(spots.len());
|
||||
for p in &spots {
|
||||
let at = hole_on_surface(st, crate::apply_point(m, *p), d, hole_scope(src));
|
||||
on.push((at, d));
|
||||
let to = to.map(|t| crate::apply_point(m, t.0));
|
||||
let depth = hole_depth_to(st, &at, d, &to, depth)?;
|
||||
// Each copy's faces are named as the hole's, with the instance.
|
||||
@@ -6378,6 +6650,7 @@ fn replay(
|
||||
);
|
||||
}
|
||||
instances.push(start..copies.len());
|
||||
axes.push(on);
|
||||
}
|
||||
} else if let FeatureKind::Rib { .. } = &src.kind {
|
||||
// A rib is built again at each copy of its sketch, against the bodies there (#4593):
|
||||
@@ -6404,12 +6677,9 @@ fn replay(
|
||||
}
|
||||
}
|
||||
if op == Operation::Cut {
|
||||
for instance in &instances {
|
||||
if let Some(tools) = copies.get(instance.clone()) {
|
||||
total += 1;
|
||||
missed += usize::from(copy_misses(st, f, &targets, tools));
|
||||
}
|
||||
}
|
||||
let (m, t) = count_copy_misses(st, f, &targets, &copies, &instances, &axes);
|
||||
missed += m;
|
||||
total += t;
|
||||
}
|
||||
// Copies of a cut through sheet metal are cut-outs of its flat pattern, as the cut is
|
||||
// (#6841): each machined into the sheets in turn, then cut from the other targets.
|
||||
|
||||
@@ -18,8 +18,10 @@ use crate::*;
|
||||
|
||||
/// Work counted on this thread: bodies moved, STEP texts digested, joint faces and bodies
|
||||
/// measured, bodies searched for by name, features searched for by id, bodies a cut (or
|
||||
/// intersect) ran its booleans on, bodies searched for the cylinder a tap marking lies on, and
|
||||
/// bodies whose faces a tapped hole read for its wall.
|
||||
/// intersect) ran its booleans on, bodies searched for the cylinder a tap marking lies on,
|
||||
/// bodies whose faces a tapped hole read for its wall, intersects run to find a pattern's copies
|
||||
/// that cut nothing, and the tools a cut of many tools is made with (one when they are cut in one
|
||||
/// go).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub(super) struct Counts {
|
||||
pub moved: usize,
|
||||
@@ -31,6 +33,8 @@ pub(super) struct Counts {
|
||||
pub cut: usize,
|
||||
pub cylinder_search: usize,
|
||||
pub tapped_wall: usize,
|
||||
pub miss_intersects: usize,
|
||||
pub cut_tools: usize,
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
@@ -45,6 +49,8 @@ thread_local! {
|
||||
cut: 0,
|
||||
cylinder_search: 0,
|
||||
tapped_wall: 0,
|
||||
miss_intersects: 0,
|
||||
cut_tools: 0,
|
||||
})
|
||||
};
|
||||
}
|
||||
@@ -1484,3 +1490,150 @@ fn a_hole_into_a_rim_still_bores_its_sheet_beside_far_ones() {
|
||||
let bore = std::f64::consts::PI * (d / 2.0).powi(2) * 60.0;
|
||||
assert!((removed - bore).abs() < 0.02 * bore, "removed {removed} of {bore}");
|
||||
}
|
||||
|
||||
/// A 1.5 mm disc of 50 mm radius with a 3.5 mm through hole at `radius` on X, patterned `count`
|
||||
/// times around Z (#9007). The pattern's id.
|
||||
fn disc_with_hole_pattern(doc: &mut Document, radius: f64, count: usize) -> u64 {
|
||||
let disc = FeatureKind::Cylinder {
|
||||
base: point_expr(Vec3::ZERO),
|
||||
axis: Dir(Vec3::Z),
|
||||
radius: "50".into(),
|
||||
height: "1.5".into(),
|
||||
operation: Operation::NewBody,
|
||||
references: Vec::new(),
|
||||
};
|
||||
doc.add_feature(disc, Some("Disc")).unwrap();
|
||||
let hole: FeatureKind = serde_json::from_value(serde_json::json!({
|
||||
"type": "hole", "position": [radius, 0, 1.5], "direction": [0, 0, -1], "diameter": "3.5",
|
||||
}))
|
||||
.unwrap();
|
||||
let hole = doc.add_feature(hole, Some("Hole")).unwrap();
|
||||
hole_pattern(doc, hole, count)
|
||||
}
|
||||
|
||||
fn hole_pattern(doc: &mut Document, hole: u64, count: usize) -> u64 {
|
||||
let pattern: FeatureKind = serde_json::from_value(serde_json::json!({
|
||||
"type": "pattern", "features": [hole],
|
||||
"pattern": {"type": "circular", "origin": [0, 0, 0], "axis": [0, 0, 1], "count": count.to_string(), "angle": "360 deg"},
|
||||
}))
|
||||
.unwrap();
|
||||
doc.add_feature(pattern, None).unwrap()
|
||||
}
|
||||
|
||||
fn disc_volume(model: &Model) -> f64 {
|
||||
let st = model.state();
|
||||
assert_eq!(st.bodies.len(), 1);
|
||||
kernel::measure(&st.bodies[0].body).unwrap().volume
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_circular_pattern_of_a_through_hole_cuts_its_copies_at_once() {
|
||||
// The copies' tools run twice the disc's size along Z, so the kernel's box test, which
|
||||
// grows each box by a share of the tool's size, finds them meeting (#9007); they are still
|
||||
// 4.3 mm apart, centre to centre, and are cut in one go. No copy is intersected with the
|
||||
// disc to see whether it takes material: each passes through the disc's material.
|
||||
let mut doc = Document::new("sieve");
|
||||
let pattern = disc_with_hole_pattern(&mut doc, 20.0, 29);
|
||||
let mut model = Model::new();
|
||||
let work = counted(|| model.evaluate(&doc));
|
||||
assert!(model.results.iter().all(|r| r.error.is_none() && r.warning.is_none()), "{:?}", model.results);
|
||||
assert_eq!((work.cut_tools, work.miss_intersects), (1, 0), "{work:?}");
|
||||
let hole = std::f64::consts::PI * 1.75 * 1.75 * 1.5;
|
||||
let disc = std::f64::consts::PI * 2500.0 * 1.5;
|
||||
let v = disc_volume(&model);
|
||||
assert!((v - (disc - 29.0 * hole)).abs() < 1e-3 * hole, "{v}");
|
||||
// The same copies again, landing in the holes cut already: each is intersected, and each
|
||||
// still counts as a copy that removes no material.
|
||||
let hole_id = doc.features.iter().find(|f| f.name == "Hole").unwrap().id;
|
||||
hole_pattern(&mut doc, hole_id, 29);
|
||||
let work = counted(|| model.evaluate(&doc));
|
||||
let again = model.results.last().unwrap();
|
||||
assert!(again.error.is_none(), "{again:?}");
|
||||
// (The kernel may add a note on a retry of a boolean on faces that lie on each other.)
|
||||
assert!(again.warning.as_deref().is_some_and(|w| w.starts_with("28 of 28 cut copies remove no material")), "{again:?}");
|
||||
assert_eq!(work.miss_intersects, 28, "{work:?}");
|
||||
assert!((disc_volume(&model) - v).abs() < 1e-3 * hole);
|
||||
assert!(model.results.iter().any(|r| r.id == pattern && r.warning.is_none()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copies_of_a_hole_that_come_close_are_cut_one_by_one() {
|
||||
// At 8.5 mm radius, 16 copies of a 3.5 mm hole overlap their neighbours: they are not apart,
|
||||
// and each is cut on its own, as before.
|
||||
let mut doc = Document::new("crowded");
|
||||
disc_with_hole_pattern(&mut doc, 8.5, 16);
|
||||
let mut model = Model::new();
|
||||
let work = counted(|| model.evaluate(&doc));
|
||||
assert!(model.results.iter().all(|r| r.error.is_none() && r.warning.is_none()), "{:?}", model.results);
|
||||
assert_eq!((work.cut_tools, work.miss_intersects), (15, 0), "{work:?}");
|
||||
// At 9 mm they come within 0.012 mm of each other without touching: their exact shapes are
|
||||
// apart, so they are cut in one go, and all 16 holes are cut.
|
||||
let mut doc = Document::new("close");
|
||||
disc_with_hole_pattern(&mut doc, 9.0, 16);
|
||||
let mut model = Model::new();
|
||||
let work = counted(|| model.evaluate(&doc));
|
||||
assert!(model.results.iter().all(|r| r.error.is_none() && r.warning.is_none()), "{:?}", model.results);
|
||||
assert_eq!((work.cut_tools, work.miss_intersects), (1, 0), "{work:?}");
|
||||
let hole = std::f64::consts::PI * 1.75 * 1.75 * 1.5;
|
||||
let disc = std::f64::consts::PI * 2500.0 * 1.5;
|
||||
let v = disc_volume(&model);
|
||||
assert!((v - (disc - 16.0 * hole)).abs() < 1e-3 * hole, "{v}");
|
||||
}
|
||||
|
||||
/// A ring (25 mm outside, 16 mm bore, 55 mm high) with a blind groove, 8 mm wide and 30 mm deep,
|
||||
/// cut into its bore from below, in a circular pattern of ten about Z: their boxes, grown as the
|
||||
/// kernel grows them, meet, their exact shapes are 1.9 mm apart. The ring's faces counted as its
|
||||
/// surfaces are, and the work.
|
||||
fn grooved_ring_faces() -> (usize, Counts) {
|
||||
let mut doc = Document::new("grooves");
|
||||
let cylinder = |base: Vec3, radius: &str, height: &str, operation: Operation| FeatureKind::Cylinder {
|
||||
base: point_expr(base),
|
||||
axis: Dir(Vec3::Z),
|
||||
radius: radius.into(),
|
||||
height: height.into(),
|
||||
operation,
|
||||
references: Vec::new(),
|
||||
};
|
||||
doc.add_feature(cylinder(Vec3::ZERO, "25", "55", Operation::NewBody), Some("Ring")).unwrap();
|
||||
doc.add_feature(cylinder(Vec3::new(0.0, 0.0, -1.0), "16", "57", Operation::Cut), Some("Bore")).unwrap();
|
||||
let groove = doc.add_feature(cylinder(Vec3::new(16.0, 0.0, -1.0), "4", "31", Operation::Cut), Some("Groove")).unwrap();
|
||||
hole_pattern(&mut doc, groove, 10);
|
||||
let mut model = Model::new();
|
||||
let work = counted(|| model.evaluate(&doc));
|
||||
assert!(model.results.iter().all(|r| r.error.is_none() && r.warning.is_none()), "{:?}", model.results);
|
||||
let st = model.state();
|
||||
assert_eq!(st.bodies.len(), 1);
|
||||
(kernel::measure(&st.bodies[0].body).unwrap().merged.faces, work)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn copies_that_notch_the_same_round_face_cut_at_once_leave_the_faces_of_one_by_one() {
|
||||
// The ten grooves notch the same round bore. Cut all in one go, they leave it in as many
|
||||
// faces as cutting them one after another does (#9007).
|
||||
let (patterned, work) = grooved_ring_faces();
|
||||
let cut = |a: kernel::Body, b: &kernel::Body| kernel::boolean(&a, b, kernel::BoolOp::Cut).unwrap().unwrap();
|
||||
let ring =
|
||||
cut(kernel::cylinder(Vec3::ZERO, Vec3::Z, 25.0, 55.0).unwrap(), &kernel::cylinder(Vec3::new(0.0, 0.0, -1.0), Vec3::Z, 16.0, 57.0).unwrap());
|
||||
let groove = kernel::cylinder(Vec3::new(16.0, 0.0, -1.0), Vec3::Z, 4.0, 31.0).unwrap();
|
||||
let one_by_one = (0..10).fold(ring, |ring, k| {
|
||||
let copy = kernel::transform(&groove, Vec3::ZERO, Vec3::ZERO, Vec3::Z, (36.0 * k as f64).to_radians()).unwrap();
|
||||
cut(ring, ©)
|
||||
});
|
||||
assert_eq!(patterned, kernel::measure(&one_by_one).unwrap().merged.faces);
|
||||
assert_eq!(work.cut_tools, 1, "{work:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tools_are_apart_only_when_they_neither_meet_nor_nest() {
|
||||
let rod = |x: f64, y: f64, r: f64| kernel::cylinder(Vec3::new(x, y, -100.0), Vec3::Z, r, 200.0).unwrap();
|
||||
// Long rods whose boxes, grown as the kernel grows them, meet: 0.5 mm apart.
|
||||
assert!(super::tools_clearly_apart(&[rod(0.0, 0.0, 1.0), rod(2.5, 0.0, 1.0)]));
|
||||
// Touching, crossing and nested rods are not apart.
|
||||
assert!(!super::tools_clearly_apart(&[rod(0.0, 0.0, 1.0), rod(2.0, 0.0, 1.0)]));
|
||||
assert!(!super::tools_clearly_apart(&[rod(0.0, 0.0, 1.0), rod(1.5, 0.0, 1.0)]));
|
||||
assert!(!super::tools_clearly_apart(&[rod(0.0, 0.0, 3.0), rod(0.5, 0.0, 1.0)]));
|
||||
let tube = kernel::boolean(&rod(0.0, 0.0, 5.0), &rod(0.0, 0.0, 4.0), kernel::BoolOp::Cut).unwrap().unwrap();
|
||||
assert!(!super::tools_clearly_apart(&[tube.clone(), rod(0.0, 0.0, 4.5)]));
|
||||
// A rod in the tube's bore, clear of its wall, is apart from it.
|
||||
assert!(super::tools_clearly_apart(&[tube, rod(0.0, 0.0, 3.0)]));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
//! A counterbore hole may save a `bridge` length: two printing layers that thick below the
|
||||
//! counterbore's floor (a slot as wide as the hole along X, then a square) so a 3D printer bridges
|
||||
//! the step. An older design has none and keeps a plain counterbore. The last release refuses a
|
||||
//! design that has it (it asks for an update) instead of opening it without the bridge layers.
|
||||
@@ -0,0 +1,6 @@
|
||||
//! A new-body extrusion or revolve whose outputs transfer into its source sketch's component
|
||||
//! reads the profile through the recorded transfer frame. Capturing that component's position
|
||||
//! therefore moves the body once, as the pending preview does. Existing designs use their
|
||||
//! saved transfer transforms without rewriting fields; independent cross-component references
|
||||
//! keep their live placement. The last release refuses the newer design-format number rather
|
||||
//! than reopening the design with the former double-placement behavior.
|
||||
@@ -769,6 +769,8 @@ impl Model {
|
||||
let mut exact = true;
|
||||
let mut prev = 0;
|
||||
let mut results = Vec::with_capacity(features.len());
|
||||
let mut construction = HashMap::new();
|
||||
let mut prepared_states = std::collections::HashSet::new();
|
||||
for (i, (f, r)) in doc.features.iter().zip(features).enumerate() {
|
||||
let saved = unhex(r.get("fingerprint").unwrap_or(&Json::Null))?;
|
||||
// A fingerprint reads the state before its feature (where the bodies it takes lie).
|
||||
@@ -780,8 +782,26 @@ impl Model {
|
||||
}
|
||||
let ms = r.get("ms").and_then(Json::as_f64).filter(|ms| ms.is_finite()).ok_or_else(|| bad("saved model: time"))?;
|
||||
// A file without room for every state keeps some features without one (#3220).
|
||||
let state =
|
||||
r.get("state").map(|s| states.get(index(Some(s), states.len())?).cloned().ok_or_else(|| bad("saved model: state"))).transpose()?;
|
||||
let state = r.get("state").map(|s| index(Some(s), states.len())).transpose()?;
|
||||
if let Some(at) = state
|
||||
&& prepared_states.insert(at)
|
||||
{
|
||||
let original = matches!(
|
||||
&f.kind,
|
||||
FeatureKind::Box { operation: Operation::NewBody, .. } | FeatureKind::Extrude { operation: Operation::NewBody, .. }
|
||||
);
|
||||
let current = states.get_mut(at).ok_or_else(|| bad("saved model: state"))?;
|
||||
// Each state is prepared before its first shared clone. Record and NameCell
|
||||
// identity prove this is still the original geometry and its exact names.
|
||||
for body in &mut Arc::make_mut(current).bodies {
|
||||
let key = (std::ptr::from_ref(body.body.record()).addr(), body.names.id());
|
||||
if original && body.feature == f.id && before.body(&body.name).is_none() {
|
||||
construction.insert(key, f.id);
|
||||
}
|
||||
body.names.cached_construction = construction.get(&key).copied();
|
||||
}
|
||||
}
|
||||
let state = state.map(|at| states.get(at).cloned().ok_or_else(|| bad("saved model: state"))).transpose()?;
|
||||
let result = FeatureResult {
|
||||
id: f.id,
|
||||
name: f.name.clone(),
|
||||
|
||||
@@ -9,15 +9,19 @@
|
||||
//! that uses it fails, asking for the reference to be picked again
|
||||
//! ([`crate::DocError::Reselect`]). A face whose name was worked out from geometry, found where
|
||||
//! the reference's point no longer lies, is reported: only geometry decided.
|
||||
//! Saved numbered Project links also have a compatibility check for a whole face that
|
||||
//! contains the saved pick and comes directly from its original construction feature.
|
||||
//! This check is local to manual sketch projection.
|
||||
|
||||
use solidcore_record::Vec3;
|
||||
use solidcraft_geom::Mesh;
|
||||
use solidcraft_geom::brep::eval::SurfaceEval;
|
||||
use solidcraft_geom::prelude::*;
|
||||
|
||||
use crate::history_names::{Match, Names};
|
||||
use crate::naming::{self, closest, edge_names, face_names, strip_piece};
|
||||
use crate::piece_names::strip_edge_number;
|
||||
use crate::{ModelBody, ModelState};
|
||||
use crate::{FeatureKind, ModelBody, ModelState, Operation};
|
||||
|
||||
/// The mark on a name saved before format 14 (`?F2:top#2`). Those names were worked out from
|
||||
/// geometry, and some of them name a face that exact history names differently (a tube's outer
|
||||
@@ -433,6 +437,84 @@ pub(crate) fn locate_on(body: &ModelBody, name: &str, p: Vec3) -> Option<FaceHit
|
||||
locate_in(std::iter::once((0, body)), name, p).ok()
|
||||
}
|
||||
|
||||
/// Find a saved manual Project face in its body. Older designs can name a numbered piece of
|
||||
/// a face that now evaluates whole. Recover it only when the original feature directly made
|
||||
/// the exact whole face and the face contains the
|
||||
/// old pick. Other face references still require the stored name as picked.
|
||||
pub(crate) fn locate_projected_face(body: &ModelBody, name: &str, p: Vec3) -> Option<(usize, Vec3)> {
|
||||
if body.body.is_mesh() {
|
||||
return None;
|
||||
}
|
||||
match locate_in(std::iter::once((0, body)), name, p) {
|
||||
Ok(hit) => Some((hit.face, hit.point)),
|
||||
Err(Miss::Gone) => recover_numbered_projected_face(body, name, p),
|
||||
Err(Miss::Several) => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Bound the quadratic scan in remove_faces, which takes the list of faces to remove.
|
||||
const MAX_PROJECTION_RECOVERY_FACES: usize = 1024;
|
||||
|
||||
fn recover_numbered_projected_face(body: &ModelBody, name: &str, pick: Vec3) -> Option<(usize, Vec3)> {
|
||||
let (stem, number) = name.rsplit_once('#')?;
|
||||
let count = body.body.face_count();
|
||||
if count > MAX_PROJECTION_RECOVERY_FACES
|
||||
|| !pick.is_finite()
|
||||
|| stem.is_empty()
|
||||
|| strip_piece(stem) != stem
|
||||
|| number.is_empty()
|
||||
|| number.starts_with('0')
|
||||
|| !number.bytes().all(|digit| digit.is_ascii_digit())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
// A changed body may keep the same face name while the face absorbs a smaller piece.
|
||||
// Projecting that larger face could silently grow a downstream feature's material.
|
||||
let producer = stem.strip_prefix('F')?.split_once(':')?.0.parse::<u64>().ok()?;
|
||||
let live_construction = body.names.origin.as_ref().is_some_and(|origin| {
|
||||
producer == origin.feature.id
|
||||
&& matches!(
|
||||
&origin.feature.kind,
|
||||
FeatureKind::Box { operation: Operation::NewBody, .. } | FeatureKind::Extrude { operation: Operation::NewBody, .. }
|
||||
)
|
||||
&& origin.before.body(&body.name).is_none()
|
||||
});
|
||||
if producer != body.feature || !(live_construction || body.names.cached_construction == Some(producer)) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let candidates = faces_with_stem(body, stem);
|
||||
let &[face] = candidates.as_slice() else { return None };
|
||||
let names = naming::names(body);
|
||||
let info = names.info.get(face)?;
|
||||
if names.faces.get(face)?.as_str() != stem || !info.verified || info.aliases.iter().any(|alias| strip_piece(alias) != stem) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let record = body.body.record().faces.get(face)?;
|
||||
let [[u0, u1], [v0, v1]] = record.domain;
|
||||
let surface = SurfaceEval::new(record.parameters()).ok()?;
|
||||
let tolerance = (body.body.size() * 1e-3).max(1e-3);
|
||||
if !tolerance.is_finite() {
|
||||
return None;
|
||||
}
|
||||
let point = surface.point(surface.project(pick, Some([u0.midpoint(u1), v0.midpoint(v1)]), tolerance)?)?;
|
||||
if !point.is_finite() || !(point.dist(pick) <= tolerance) {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Isolate the face so a point on another face of the same surface cannot pass the trim test.
|
||||
let others: Vec<_> = (0..count).filter(|index| *index != face).collect();
|
||||
let isolated;
|
||||
let trimmed = if others.is_empty() {
|
||||
&body.body
|
||||
} else {
|
||||
isolated = solidcraft_kernel::remove_faces(&body.body, &others).ok()?;
|
||||
&isolated
|
||||
};
|
||||
matches!(trimmed.classify_point(point), Ok(solidcraft_kernel::PointClass::OnBoundary)).then_some((face, point))
|
||||
}
|
||||
|
||||
/// The one face a name `model.faces` lists finds, on the body called `body` or, without one, on
|
||||
/// any body. `Err` says why there is no such face, or why the name does not name just one (the
|
||||
/// pieces of a split face, or the same face on several bodies): a command that takes a face by
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{Document, ModelBody, ModelState};
|
||||
use solidcore_record::{Plane, Vec3};
|
||||
use solidcore_record::{Plane, Vec2, Vec3};
|
||||
use solidcraft_geom::prelude::*;
|
||||
use solidcraft_sketch::{LinkKind, LinkSource, Sketch};
|
||||
use std::collections::BTreeMap;
|
||||
@@ -49,3 +49,197 @@ fn named_manual_projection_keeps_its_body_and_face_at_shared_boundaries() {
|
||||
assert_eq!(sketch.links[0].id, link);
|
||||
assert!(matches!(&sketch.links[0].source,LinkSource::Face{body,..} if body=="Source"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numbered_manual_projection_rebuilds_from_the_whole_planar_face() {
|
||||
let mut doc = Document::default();
|
||||
doc.set_param("size", "5", Some("mm"), None).unwrap();
|
||||
let kind = serde_json::from_value(serde_json::json!({
|
||||
"type": "box", "corner": [0, 0, 0], "length": "size", "width": "size", "height": "10"
|
||||
}))
|
||||
.unwrap();
|
||||
let feature = doc.add_feature(kind, None).unwrap();
|
||||
doc.feature_mut(feature).unwrap().body_names = vec!["Source".into()];
|
||||
let mut model = crate::Model::new();
|
||||
model.evaluate(&doc);
|
||||
let plane = Plane::XY.offset(20.);
|
||||
let source = LinkSource::Face { body: "Source".into(), at: Vec3::new(2., 2., 10.) };
|
||||
let resolved = crate::project::resolve(&doc, &BTreeMap::new(), &model.state(), &plane, LinkKind::Project, &source).unwrap();
|
||||
let mut sketch = Sketch::default();
|
||||
let link = sketch.add_link(LinkKind::Project, source, &resolved.geom).unwrap();
|
||||
let numbered = format!("F{feature}:+z#1");
|
||||
sketch.links[0].face_name = Some(numbered.clone());
|
||||
|
||||
doc.set_param("size", "20", Some("mm"), None).unwrap();
|
||||
model.evaluate(&doc);
|
||||
assert!(crate::project::refresh_links(&doc, &BTreeMap::new(), &model.state(), &plane, &mut sketch).unwrap().is_empty());
|
||||
assert!(!sketch.links[0].lost);
|
||||
assert_eq!(sketch.links[0].face_name.as_deref(), Some(numbered.as_str()));
|
||||
assert_eq!(sketch.link_curves(&link).len(), 4);
|
||||
assert!(sketch.points.iter().any(|point| point.pos.x > 19. && point.pos.y > 19.));
|
||||
|
||||
let saved = model.saved(&doc).unwrap();
|
||||
let reopened = crate::format::read(&doc.to_json()).unwrap();
|
||||
let cached = crate::Model::adopt(&reopened, &saved).unwrap();
|
||||
let state = cached.state();
|
||||
assert!(state.body("Source").unwrap().names.origin.is_none());
|
||||
assert_eq!(state.body("Source").unwrap().names.cached_construction, Some(feature));
|
||||
assert!(crate::project::refresh_links(&reopened, &BTreeMap::new(), &state, &plane, &mut sketch).unwrap().is_empty());
|
||||
assert!(!sketch.links[0].lost);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numbered_round_face_projection_recovers_the_whole_face() {
|
||||
let doc = Document {
|
||||
features: serde_json::from_value(serde_json::json!([
|
||||
{
|
||||
"id": 1, "name": "Sketch1", "type": "sketch", "plane": {"name": "XY", "type": "origin"},
|
||||
"sketch": {
|
||||
"points": [{"fixed": true, "id": "origin", "pos": [0., 0.]}, {"fixed": false, "id": "c1.center", "pos": [0., 0.]}],
|
||||
"curves": [{"c": 1, "construction": false, "id": "c1", "r": 20., "type": "circle"}],
|
||||
"constraints": [{"id": "k1", "p": 0, "q": 1, "type": "coincident"}],
|
||||
"counters": {"k": 1, "l": 0, "p": 1}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2, "name": "Extrude1", "type": "extrude", "body_names": ["Body1"],
|
||||
"extent": {"convention": "total_distance", "direction": "positive", "distance": "10"},
|
||||
"operation": "new_body", "profiles": {"loops": [["c1"]], "type": "curves"}, "sketch": 1
|
||||
},
|
||||
{
|
||||
"id": 3, "name": "Sketch2", "type": "sketch", "plane": {"name": "YZ", "type": "origin"},
|
||||
"sketch": {
|
||||
"points": [
|
||||
{"fixed": true, "id": "origin", "pos": [0., 0.]},
|
||||
{"fixed": false, "id": "p1", "pos": [-20., 0.]},
|
||||
{"fixed": false, "id": "p2", "pos": [20., 0.]},
|
||||
{"fixed": false, "id": "p3", "pos": [-20., 10.]},
|
||||
{"fixed": false, "id": "p4", "pos": [20., 10.]}
|
||||
],
|
||||
"curves": [
|
||||
{"a": 1, "b": 2, "construction": false, "id": "l1", "link": "j1", "type": "line"},
|
||||
{"a": 3, "b": 4, "construction": false, "id": "l2", "link": "j1", "type": "line"}
|
||||
],
|
||||
"constraints": [],
|
||||
"counters": {"k": 0, "l": 2, "p": 4},
|
||||
"links": [{
|
||||
"face_name": "F2:side:c1#1", "id": "j1", "kind": "project",
|
||||
"source": {"at": [-19.87, -2.3, 6.], "body": "Body1", "type": "face"}
|
||||
}]
|
||||
}
|
||||
}
|
||||
]))
|
||||
.unwrap(),
|
||||
..Document::default()
|
||||
};
|
||||
let doc = crate::format::read(&doc.to_json()).unwrap();
|
||||
let mut model = crate::Model::new();
|
||||
model.evaluate(&doc);
|
||||
let state = model.state();
|
||||
let body = state.body("Body1").unwrap();
|
||||
assert!(crate::naming::face_names(body).iter().any(|name| name == "F2:side:c1"));
|
||||
let result = model.result(3).unwrap();
|
||||
assert!(result.error.is_none(), "{result:?}");
|
||||
let projected = &state.sketch(3).expect("the saved projection should rebuild").sketch;
|
||||
assert_eq!(projected.links[0].face_name.as_deref(), Some("F2:side:c1#1"));
|
||||
assert_eq!(projected.link_curves("j1").len(), 2);
|
||||
|
||||
// The edge-on projection of the round wall can retain its saved geometry with a warning.
|
||||
// The numbered reference must evaluate the same way as the whole face's existing name.
|
||||
let mut exact_doc = doc.clone();
|
||||
exact_doc.sketch_mut(3).unwrap().links[0].face_name = Some("F2:side:c1".into());
|
||||
let mut exact_model = crate::Model::new();
|
||||
exact_model.evaluate(&exact_doc);
|
||||
let exact_state = exact_model.state();
|
||||
let exact = &exact_state.sketch(3).unwrap().sketch;
|
||||
assert_eq!(result.warning, exact_model.result(3).unwrap().warning);
|
||||
assert_eq!(projected.links[0].lost, exact.links[0].lost);
|
||||
assert_eq!(projected.curves, exact.curves);
|
||||
assert_eq!(projected.points, exact.points);
|
||||
|
||||
let saved = model.saved(&doc).expect("the healthy projection should save its model cache");
|
||||
let mut reopened = crate::format::read(&doc.to_json()).unwrap();
|
||||
let mut reopened_model = crate::Model::adopt(&reopened, &saved).unwrap();
|
||||
assert!(reopened_model.state().body("Body1").unwrap().names.origin.is_none());
|
||||
assert_eq!(reopened_model.state().body("Body1").unwrap().names.cached_construction, Some(2));
|
||||
let crate::FeatureKind::Sketch { plane, .. } = &mut reopened.feature_mut(3).unwrap().kind else { panic!("projection sketch") };
|
||||
*plane = crate::PlaneRef::Custom { plane: Plane::YZ.offset(0.1) };
|
||||
reopened_model.evaluate(&reopened);
|
||||
assert!(reopened_model.result(3).unwrap().error.is_none(), "{:?}", reopened_model.result(3));
|
||||
let pick = Vec3::new(-19.87, -2.3, 6.);
|
||||
assert!(crate::naming::face_on_body(body, "F2:side:c1#1", pick).is_none(), "ordinary lookup stays strict");
|
||||
let mut split = body.clone();
|
||||
let mut names = crate::naming::face_names(body).as_ref().clone();
|
||||
*names.iter_mut().find(|name| name.as_str() != "F2:side:c1").unwrap() = "F2:side:c1#2#[wall]".into();
|
||||
let origin = split.names.origin.clone();
|
||||
split.names = crate::naming::NameCell::known(Arc::new(names));
|
||||
split.names.origin = origin;
|
||||
assert!(crate::naming::face_on_body(&split, "F2:side:c1#1", pick).is_none());
|
||||
assert!(crate::name_lookup::locate_projected_face(&split, "F2:side:c1#1", pick).is_none(), "another piece still exists");
|
||||
|
||||
let mut outside = doc.sketch(3).unwrap().clone();
|
||||
outside.links[0].source = LinkSource::Face { body: "Body1".into(), at: Vec3::new(-19.87, -2.3, 12.) };
|
||||
let error = crate::project::refresh_links(&doc, &BTreeMap::new(), &state, &Plane::YZ, &mut outside).unwrap_err();
|
||||
assert!(matches!(&error, crate::DocError::Reselect { reference, .. } if reference == "F2:side:c1#1"), "{error}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numbered_projection_refuses_modified_or_moved_cached_sources() {
|
||||
for (kind, pick) in [
|
||||
(serde_json::json!({"type": "shell", "body": "Source", "faces": [[10, 10, 10]], "thickness": "1"}), Vec3::new(0., 5., 5.)),
|
||||
(serde_json::json!({"type": "move", "bodies": ["Source"], "translate": ["1", "0", "0"]}), Vec3::new(1., 5., 5.)),
|
||||
] {
|
||||
let mut doc = Document::default();
|
||||
let source = doc
|
||||
.add_feature(
|
||||
serde_json::from_value(serde_json::json!({
|
||||
"type": "box", "corner": [0, 0, 0], "length": "20", "width": "20", "height": "10"
|
||||
}))
|
||||
.unwrap(),
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
doc.feature_mut(source).unwrap().body_names = vec!["Source".into()];
|
||||
doc.add_feature(serde_json::from_value(kind).unwrap(), None).unwrap();
|
||||
let mut model = crate::Model::new();
|
||||
model.evaluate(&doc);
|
||||
assert!(model.results.iter().all(|result| result.error.is_none()));
|
||||
let saved = model.saved(&doc).unwrap();
|
||||
let reopened = crate::format::read(&doc.to_json()).unwrap();
|
||||
let cached = crate::Model::adopt(&reopened, &saved).unwrap();
|
||||
let state = cached.state();
|
||||
let body = state.body("Source").unwrap();
|
||||
let whole = format!("F{source}:-x");
|
||||
let numbered = format!("{whole}#1");
|
||||
assert!(crate::naming::face_on_body(body, &whole, pick).is_some());
|
||||
assert!(crate::naming::face_on_body(body, &numbered, pick).is_none());
|
||||
assert!(body.names.origin.is_none());
|
||||
assert_eq!(body.names.cached_construction, None);
|
||||
assert!(crate::name_lookup::locate_projected_face(body, &numbered, pick).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn numbered_projection_refuses_a_pick_inside_a_hole_in_the_named_face() {
|
||||
let mut doc = Document::default();
|
||||
let mut sketch = Sketch::new();
|
||||
sketch.add_circle(Vec2::ZERO, 10., Some(0), Some("c1")).unwrap();
|
||||
sketch.add_circle(Vec2::ZERO, 2., Some(0), Some("c2")).unwrap();
|
||||
let profile = doc.add_feature(crate::FeatureKind::Sketch { plane: crate::PlaneRef::Origin { name: "XY".into() }, sketch }, None).unwrap();
|
||||
let kind = serde_json::from_value(serde_json::json!({
|
||||
"type": "extrude", "sketch": profile, "profiles": {"type": "curves", "loops": [["c1"]]}, "extent": {"distance": "5"}
|
||||
}))
|
||||
.unwrap();
|
||||
let feature = doc.add_feature(kind, None).unwrap();
|
||||
let mut model = crate::Model::new();
|
||||
model.evaluate(&doc);
|
||||
let state = model.state();
|
||||
let body = state.body("Body1").unwrap();
|
||||
let whole = format!("F{feature}:top");
|
||||
let top = crate::naming::face_names(body).iter().position(|name| name == &whole).unwrap();
|
||||
let numbered = format!("{whole}#1");
|
||||
|
||||
let pick = |x| crate::name_lookup::locate_projected_face(body, &numbered, Vec3::new(x, 0., 5.));
|
||||
assert_eq!(pick(5.).map(|(index, _)| index), Some(top));
|
||||
assert!(pick(0.).is_none(), "the pick is on the plane but inside the hole");
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ pub struct NamingOrigin {
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct NameCell {
|
||||
pub origin: Option<Arc<NamingOrigin>>,
|
||||
/// Direct construction verified from identical cached body/name cells during adoption.
|
||||
/// Used only by manual Project compatibility, independently of general naming history.
|
||||
pub(crate) cached_construction: Option<u64>,
|
||||
/// What the body's faces came from, when the feature that made it reports it.
|
||||
lineage: Option<Arc<Lineage>>,
|
||||
names: Arc<OnceLock<Arc<Names>>>,
|
||||
@@ -57,7 +60,7 @@ impl NameCell {
|
||||
}
|
||||
/// Names of a body made by `origin`'s feature, following `lineage` where it is known.
|
||||
pub(crate) fn traced(origin: Option<Arc<NamingOrigin>>, lineage: Option<Arc<Lineage>>) -> Self {
|
||||
NameCell { origin, lineage, names: Arc::new(OnceLock::new()), copy_of: None, saved_depth: None }
|
||||
NameCell { origin, cached_construction: None, lineage, names: Arc::new(OnceLock::new()), copy_of: None, saved_depth: None }
|
||||
}
|
||||
/// Names already known, taken as they are.
|
||||
pub fn known(names: Arc<Vec<String>>) -> Self {
|
||||
@@ -98,7 +101,7 @@ impl NameCell {
|
||||
fn shared(names: Arc<Names>) -> Self {
|
||||
let cell = OnceLock::new();
|
||||
let _ = cell.set(names);
|
||||
NameCell { origin: None, lineage: None, names: Arc::new(cell), copy_of: None, saved_depth: None }
|
||||
NameCell { origin: None, cached_construction: None, lineage: None, names: Arc::new(cell), copy_of: None, saved_depth: None }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1034,8 +1034,16 @@ fn refresh_links_in(
|
||||
if !l.auto_face
|
||||
&& let (Some(name), LinkSource::Face { body, at }) = (&l.face_name, &mut source)
|
||||
{
|
||||
let (index, p) =
|
||||
st.body(body).and_then(|target| crate::naming::face_on_body(target, name, *at)).ok_or_else(|| DocError::reselect(name.as_str()))?;
|
||||
let (index, p) = st
|
||||
.body(body)
|
||||
.and_then(|target| {
|
||||
if l.kind == LinkKind::Project {
|
||||
crate::name_lookup::locate_projected_face(target, name, *at)
|
||||
} else {
|
||||
crate::naming::face_on_body(target, name, *at)
|
||||
}
|
||||
})
|
||||
.ok_or_else(|| DocError::reselect(name.as_str()))?;
|
||||
*at = p;
|
||||
named_face = Some((body.clone(), index, p));
|
||||
}
|
||||
|
||||
@@ -451,6 +451,9 @@ pub struct RuleValues {
|
||||
pub angle_display: AngleDisplay,
|
||||
}
|
||||
|
||||
/// A sheet rule's thickness is less than this (mm).
|
||||
const MAX_SHEET_THICKNESS: f64 = 1e4;
|
||||
|
||||
impl Document {
|
||||
/// A rule by name, the active one, or the default steel rule.
|
||||
pub fn sheet_rule(&self, name: Option<&str>) -> SheetRule {
|
||||
@@ -474,8 +477,8 @@ impl Document {
|
||||
Some(t) => t,
|
||||
None => expr::eval_with(&r.thickness, &look)?.to_kind(Kind::Length)?,
|
||||
};
|
||||
if !(t > 0.0 && t < 1e4) {
|
||||
return Err(DocError::Invalid("the sheet thickness must be positive".into()));
|
||||
if !(t > 0.0 && t < MAX_SHEET_THICKNESS) {
|
||||
return Err(DocError::Invalid("the sheet thickness must be more than 0 and less than 10000 mm".into()));
|
||||
}
|
||||
let with_t = |e: &str, k: Kind| -> Result<f64> {
|
||||
let f = |n: &str| if n == "Thickness" && !vals.contains_key("Thickness") { Ok(Value::length(t)) } else { look(n) };
|
||||
@@ -496,8 +499,12 @@ impl Document {
|
||||
angle_display: AngleDisplay::parse(&r.angle_display)
|
||||
.ok_or_else(|| DocError::Invalid(format!("unknown bend angle display `{}` (bend or included)", r.angle_display)))?,
|
||||
};
|
||||
if !(0.0..=1.0).contains(&v.k_factor) || v.bend_radius < 0.0 {
|
||||
return Err(DocError::Invalid("the K-factor must be 0…1 and the bend radius positive".into()));
|
||||
// Each value named on its own: a sharp bend (radius 0) is allowed (#9625).
|
||||
if !(0.0..=1.0).contains(&v.k_factor) {
|
||||
return Err(DocError::Invalid("the K-factor must be between 0 and 1".into()));
|
||||
}
|
||||
if !(v.bend_radius >= 0.0) {
|
||||
return Err(DocError::Invalid("the bend radius must not be negative".into()));
|
||||
}
|
||||
Ok(v)
|
||||
}
|
||||
@@ -2538,6 +2545,123 @@ impl SheetBody {
|
||||
.sum()
|
||||
}
|
||||
|
||||
/// Include the physical holes that perforation fields leave out of the B-rep measurement.
|
||||
/// `placement` maps this sheet's geometry into the measurement's frame. Hole cylinders
|
||||
/// lie on panels, clear of bends; their volume moments follow each panel's current fold.
|
||||
/// Bounding boxes and B-rep topology are unchanged by these interior holes.
|
||||
pub fn correct_perforation_properties(&self, measured: &mut kernel::BodyMeasure, placement: &Mat) -> Result<()> {
|
||||
let (mut removed, mut area_delta, mut moment_delta) = (0.0, 0.0, Vec3::ZERO);
|
||||
self.visit_perforation_cylinders(placement, |center, volume, area, _| {
|
||||
removed += volume;
|
||||
area_delta += area;
|
||||
// Use distances from the measured centre, including far-away placements.
|
||||
moment_delta += (measured.centroid - center) * volume;
|
||||
})?;
|
||||
if removed == 0.0 {
|
||||
return Ok(());
|
||||
}
|
||||
let volume = measured.volume - removed;
|
||||
let area = measured.area + area_delta;
|
||||
let centroid = measured.centroid + moment_delta / volume;
|
||||
if !(volume.is_finite() && volume > 0.0 && area.is_finite() && area >= 0.0 && centroid.is_finite()) {
|
||||
return Err(DocError::Invalid(format!("invalid perforation physical properties for `{}`", self.body)));
|
||||
}
|
||||
measured.volume = volume;
|
||||
measured.area = area;
|
||||
measured.centroid = centroid;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Remove the same hole cylinders from the inertia spread as from volume and centroid.
|
||||
/// The input and output tensors are at unit density, about their respective centroids.
|
||||
pub fn correct_perforation_mass_properties(&self, measured: &mut solidcraft_geom::MassProperties, placement: &Mat) -> Result<()> {
|
||||
use solidcraft_geom::inertia;
|
||||
let (mut removed, mut moment_delta, mut removed_inertia) = (0.0, Vec3::ZERO, [[0.0; 3]; 3]);
|
||||
self.visit_perforation_cylinders(placement, |center, volume, _, own| {
|
||||
let delta = measured.centroid - center;
|
||||
removed += volume;
|
||||
moment_delta += delta * volume;
|
||||
let about_center = inertia::shifted(&own, volume, delta);
|
||||
for (row, hole) in removed_inertia.iter_mut().zip(about_center) {
|
||||
for (value, h) in row.iter_mut().zip(hole) {
|
||||
*value += h;
|
||||
}
|
||||
}
|
||||
})?;
|
||||
if removed == 0.0 {
|
||||
return Ok(());
|
||||
}
|
||||
let volume = measured.volume - removed;
|
||||
let delta = moment_delta / volume;
|
||||
let centroid = measured.centroid + delta;
|
||||
let mut tensor = measured.inertia;
|
||||
for (row, hole) in tensor.iter_mut().zip(removed_inertia) {
|
||||
for (value, h) in row.iter_mut().zip(hole) {
|
||||
*value -= h;
|
||||
}
|
||||
}
|
||||
// Move from the old centre to the new one, reversing the parallel-axis term.
|
||||
let tensor = inertia::shifted(&tensor, -volume, delta);
|
||||
if !(volume.is_finite() && volume > 0.0 && centroid.is_finite() && tensor.iter().flatten().all(|v| v.is_finite())) {
|
||||
return Err(DocError::Invalid(format!("invalid perforation inertia for `{}`", self.body)));
|
||||
}
|
||||
measured.volume = volume;
|
||||
measured.centroid = centroid;
|
||||
measured.inertia = tensor;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Analytic cylinders at each panel's current fold, in the requested measurement frame.
|
||||
fn visit_perforation_cylinders(&self, placement: &Mat, mut visit: impl FnMut(Vec3, f64, f64, solidcraft_geom::inertia::Tensor3)) -> Result<()> {
|
||||
if self.perforations.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let invalid = || DocError::Invalid(format!("invalid perforation physical properties for `{}`", self.body));
|
||||
if !(self.t.is_finite() && self.t > 0.0) || placement.iter().flatten().any(|v| !v.is_finite()) {
|
||||
return Err(invalid());
|
||||
}
|
||||
let isometry = |m: &Mat| {
|
||||
let [x, y, z] = [0, 1, 2].map(|i| Vec3::new(m[i][0], m[i][1], m[i][2]));
|
||||
m.iter().flatten().all(|v| v.is_finite())
|
||||
&& m[0][3] == 0.0
|
||||
&& m[1][3] == 0.0
|
||||
&& m[2][3] == 0.0
|
||||
&& m[3][3] == 1.0
|
||||
&& [x, y, z].iter().all(|a| (a.dot(*a) - 1.0).abs() < 1e-9)
|
||||
&& x.dot(y).abs() < 1e-9
|
||||
&& x.dot(z).abs() < 1e-9
|
||||
&& y.dot(z).abs() < 1e-9
|
||||
};
|
||||
let panels: Vec<_> = self.panels().into_iter().map(|(i, region)| (mat_mul(placement, &self.world(i)), region)).collect();
|
||||
let flat = mat_mul(placement, &self.world(None));
|
||||
if !isometry(&flat) || panels.iter().any(|(world, _)| !isometry(world)) {
|
||||
return Err(DocError::Invalid("not supported yet: perforation physical properties under scale or shear".into()));
|
||||
}
|
||||
for p in &self.perforations {
|
||||
if !([p.diameter, p.pitch, p.margin].iter().all(|v| v.is_finite()) && p.diameter > 0.0 && p.pitch > p.diameter && p.margin >= 0.0) {
|
||||
return Err(invalid());
|
||||
}
|
||||
let holes = self.perforation_holes(p)?;
|
||||
let disk = std::f64::consts::PI * (p.diameter / 2.0).powi(2);
|
||||
let volume = disk * self.t;
|
||||
let area_delta = std::f64::consts::PI * p.diameter * self.t - 2.0 * disk;
|
||||
let radius2 = (p.diameter / 2.0).powi(2);
|
||||
let transverse = volume * (3.0 * radius2 + self.t * self.t) / 12.0;
|
||||
let own = [[transverse, 0.0, 0.0], [0.0, transverse, 0.0], [0.0, 0.0, volume * radius2 / 2.0]];
|
||||
for hole in holes {
|
||||
let world = if self.flat || panels.len() == 1 {
|
||||
&flat
|
||||
} else {
|
||||
&panels.iter().find(|(_, region)| region.contains(hole)).ok_or_else(invalid)?.0
|
||||
};
|
||||
let center = apply_point(world, v3(hole) + Vec3::Z * (self.t / 2.0));
|
||||
let rotation = [0, 1, 2].map(|i| [0, 1, 2].map(|j| world[j][i]));
|
||||
visit(center, volume, area_delta, solidcraft_geom::inertia::transformed(&own, &rotation));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Topology counted by faces and loops: a round hole is one face bounded by two closed circular
|
||||
/// edges (one vertex each), where the sewn solid splits it into arcs. Returns the change to
|
||||
/// the sewn (faces, edges, vertices).
|
||||
@@ -3537,7 +3661,11 @@ impl SheetBody {
|
||||
return Err("the gap would cut a panel away".into());
|
||||
}
|
||||
}
|
||||
// The flat pattern must stay one sheet without overlaps.
|
||||
// The flat pattern must stay one sheet without overlaps: closing must not make the two
|
||||
// overlap, nor add to what either already overlaps of another flange. A flange can lie
|
||||
// over another one in the flat away from this corner (the walls on either side of a
|
||||
// notch's inner corner both unfold into the notch, and a return on one of them lies over
|
||||
// the other), and the corner is still closed then (#8823).
|
||||
let [new_a, new_b] = new;
|
||||
let pieces = |s: &SheetBody, f: &SheetFlange| {
|
||||
let mut v = vec![corners_of(&s.zone(f))];
|
||||
@@ -3547,13 +3675,19 @@ impl SheetBody {
|
||||
v
|
||||
};
|
||||
let mine = [pieces(self, &new_a), pieces(self, &new_b)];
|
||||
let was = [pieces(self, &fa), pieces(self, &fb)];
|
||||
let overlap = |p: &[Vec<Vec2>], q: &[Vec<Vec2>]| p.iter().any(|a| q.iter().any(|b| pieces_overlap(a, b)));
|
||||
let shared = |p: &[Vec<Vec2>], q: &[Vec<Vec2>]| p.iter().map(|a| q.iter().map(|b| convex_overlap(a, b)).sum::<f64>()).sum::<f64>();
|
||||
let perimeter =
|
||||
|p: &[Vec<Vec2>]| p.iter().flat_map(|c| (0..c.len()).filter_map(move |i| Some(c.get(i)?.dist(*c.get((i + 1) % c.len())?)))).sum::<f64>();
|
||||
let [mine_a, mine_b] = &mine;
|
||||
let clash = overlap(mine_a, mine_b)
|
||||
|| self.flanges.iter().enumerate().any(|(j, g)| {
|
||||
j != k.a && j != k.b && g.shape.is_none() && {
|
||||
let other = pieces(self, g);
|
||||
mine.iter().any(|p| overlap(p, &other))
|
||||
mine.iter().zip(&was).any(|(p, q)| {
|
||||
overlap(p, &other) && shared(p, &other) > shared(q, &other) + FLAT_SLIVER * perimeter(p).max(perimeter(&other)).max(1.0)
|
||||
})
|
||||
}
|
||||
});
|
||||
if clash {
|
||||
|
||||
@@ -60,7 +60,7 @@ mod occurrence_tests;
|
||||
pub static COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec::new("component.cycle_color", "Cycle Component Color", cycle_color)
|
||||
.icon("colored_components").doc_only()
|
||||
.params("component: id or name; saves the next identification colour and enables Component Colors; shared by every instance, separate from appearances"),
|
||||
.params("component: id or name; saves the next identification colour and turns Component Colors on; shared by every instance, separate from appearances"),
|
||||
CommandSpec::new("component.hide_history", "Hide Component History", hide_history)
|
||||
.icon("eye").doc_only()
|
||||
.params("component: id or name; keeps the component's features in the design but leaves them out of the History bar (#10393)"),
|
||||
@@ -175,7 +175,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.params("component (or occurrence): what to place again; path?: validates selected occurrence; parent?: component (default: the same parent); translate?: [x,y,z]; in_place?: bool (default false: the selected transform within the parent; true: where the selected placement is in the world, translate in world axes; a parent placed more than once is placed by parent_path?, else the active placement, and every instance gets the copy). Copies the selected effective transform, including pending moves"),
|
||||
CommandSpec::new("component.paste_new", "Paste New", paste_new).icon("paste").params("component: independently copy its nested definition graph and history, materials and styles; occurrence?, path?: selected source placement; parent?: component the copy goes in (default: the source placement's; not the component or one inside it); in_place?, parent_path?: as occurrence.copy; translate?: [x,y,z]. Reassigned external bodies become base geometry; retained external links and omitted boundary joints are reported"),
|
||||
CommandSpec::new("occurrence.move", "Move Occurrence", move_occurrence).icon("move")
|
||||
.params("occurrence; path?: exact placement; space?: local|world (default local); translate?: [x,y,z]; axis?: [x,y,z], angle?: radians or \"30 deg\", origin?: [x,y,z]; matrix?: [12 or 16 numbers] (instead of translate/axis/angle/origin: a rigid move as a row-major 3x4 rotation-and-translation or 4x4 matrix, flat or as rows; one that is a rotation only up to rounding is orthonormalised, a scale, shear or mirror is refused); tolerance?: largest accepted |RᵀR − I| (default 1e-9, at most 1e-3); capture?: bool (default true; false keeps it pending until Capture Position); move_grounded?: bool (default false: a grounded occurrence refuses; true moves it and it stays grounded). Nested occurrence definitions remain shared"),
|
||||
.params("occurrence; path?: exact placement; space?: local|world (default local); translate?: [x,y,z]; axis?: [x,y,z], angle?: radians or \"30 deg\", origin?: [x,y,z]; matrix?: [12 or 16 numbers] (instead of translate/axis/angle/origin: a rigid move as a row-major 3x4 rotation-and-translation or 4x4 matrix, flat or as rows; one that is a rotation only up to rounding is orthonormalised, a scale, shear or mirror is refused); tolerance?: largest accepted |RᵀR − I| (default 1e-9, at most 1e-3); capture?: bool (default true; false keeps it pending until Capture Position); move_grounded?: bool (default false: a grounded occurrence refuses; true moves it and it stays grounded). Nested occurrence definitions remain shared. Replies {occurrence, transform, pending}; when joints hold it to something fixed and put it back, transform is where it is and the reply adds reverted: true and a warning naming the joint"),
|
||||
CommandSpec::new("occurrence.drag", "Drag Occurrence", drag::drag).icon("move").params(
|
||||
"occurrence or path: exact placement; at: [x,y,z] world point on it; point: [x,y,z] where it goes. Moves the placement by \
|
||||
point - at (with any chain of joints it is in that is joined to nothing grounded) and captures its position; other pending \
|
||||
@@ -730,6 +730,9 @@ fn move_occurrence(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if let Some(x) = s.doc_mut().occurrences.iter_mut().find(|x| x.id == id) {
|
||||
x.transform = next;
|
||||
}
|
||||
if !s.doc.assembly.joints.is_empty() {
|
||||
return Ok(after_joints(s, p, id, next, cmd));
|
||||
}
|
||||
} else {
|
||||
s.pending_moves.insert(id, next);
|
||||
s.revision += 1;
|
||||
@@ -737,6 +740,46 @@ fn move_occurrence(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({"occurrence": id, "transform": next, "pending": !bool_(p, "capture").unwrap_or(true)}))
|
||||
}
|
||||
|
||||
/// The reply to a captured move once the joints are solved (#11723): a part its joints hold to
|
||||
/// something fixed is put back by that solve, so the reply gives where it is now, says
|
||||
/// `reverted`, and names the joint and what to change instead.
|
||||
fn after_joints(s: &mut Session, p: &Value, id: u64, moved: Mat, cmd: &str) -> Value {
|
||||
s.refresh();
|
||||
let now = s.doc.occurrences.iter().find(|o| o.id == id).map_or(moved, |o| o.transform);
|
||||
let same = now.iter().flatten().zip(moved.iter().flatten()).all(|(a, b)| (a - b).abs() <= 1e-6);
|
||||
if same {
|
||||
return json!({"occurrence": id, "transform": now, "pending": false});
|
||||
}
|
||||
let name = s.doc.occurrences.iter().find(|o| o.id == id).map(|o| o.name.clone()).unwrap_or_default();
|
||||
// The placement the caller named, else the first one: a part in a component placed more
|
||||
// than once has no path of its own, and its joints hold it alike in every placement.
|
||||
let path = if p.get("path").is_some() {
|
||||
occurrence_path(s, p, id, cmd).ok()
|
||||
} else {
|
||||
let parent = s.doc.occurrences.iter().find(|o| o.id == id).map_or(0, |o| o.parent);
|
||||
let mut path = s.doc.first_path(parent);
|
||||
path.push(id);
|
||||
Some(path)
|
||||
};
|
||||
let why = path.and_then(|path| s.drag_group(&path).err()).map(|e| format!("{e}. ")).unwrap_or_else(|| {
|
||||
// No one joint to blame (a hinge's stored value, say): name the joints on the part.
|
||||
let on: Vec<&str> = s
|
||||
.doc
|
||||
.assembly
|
||||
.joints
|
||||
.iter()
|
||||
.filter(|j| !j.suppressed && (j.a.occurrence == id || j.b.occurrence == id))
|
||||
.map(|j| j.name.as_str())
|
||||
.collect();
|
||||
if on.is_empty() { String::new() } else { format!("Joints on {name}: {}. ", on.join(", ")) }
|
||||
});
|
||||
let warning = format!(
|
||||
"{why}The joints put {name} back where they hold it. To move it, change the joint (joint.edit for its offset or angle, \
|
||||
joint.drive for a hinge or slider value), move what it is held to, or use joint.reach"
|
||||
);
|
||||
json!({"occurrence": id, "transform": now, "pending": false, "reverted": true, "warning": warning})
|
||||
}
|
||||
|
||||
fn ground(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "occurrence.ground";
|
||||
let id = occurrence(s, p, cmd)?;
|
||||
|
||||
@@ -287,3 +287,66 @@ fn a_unique_part_can_drag_a_chain_through_a_shared_peer() {
|
||||
run(&mut s, "joint.solve", json!({}));
|
||||
assert_eq!(s.doc.to_json(), before);
|
||||
}
|
||||
|
||||
/// #11723: Move Occurrence on a part that rigid joints hold to something grounded is put back by
|
||||
/// the joint solve after it. The move still succeeds, but its reply says it was put back, gives
|
||||
/// where the part is, and names the joint. A free chain follows the move, as before, and says
|
||||
/// nothing.
|
||||
#[test]
|
||||
fn a_move_its_joints_undo_says_so() {
|
||||
let setups: [(&str, fn(&mut Session, u64, u64, u64)); 4] = [
|
||||
("free chain", |_, _, _, _| {}),
|
||||
("plate held to base", |s, base, plate, _| {
|
||||
run(s, "joint.as_built", json!({"type": "rigid", "a": base, "b": plate, "name": "Mount"}));
|
||||
}),
|
||||
("motor held to base", |s, base, _, motor| {
|
||||
run(s, "joint.as_built", json!({"type": "rigid", "a": base, "b": motor, "name": "Mount"}));
|
||||
}),
|
||||
("motor grounded", |s, _, _, motor| {
|
||||
run(s, "occurrence.ground", json!({"occurrence": motor, "grounded": true}));
|
||||
}),
|
||||
];
|
||||
for (case, setup) in setups {
|
||||
let mut s = Session::default();
|
||||
let (_, base) = part(&mut s, "Base", [0.0, 0.0, 0.0]);
|
||||
let (_, plate) = part(&mut s, "Plate", [20.0, 0.0, 0.0]);
|
||||
let (_, motor) = part(&mut s, "Motor", [20.0, 0.0, 10.0]);
|
||||
run(&mut s, "joint.as_built", json!({"type": "rigid", "a": plate, "b": motor, "name": "Bolted"}));
|
||||
setup(&mut s, base, plate, motor);
|
||||
let (plate_at, motor_at) = (origin(&s, &[plate]), origin(&s, &[motor]));
|
||||
let r = run(&mut s, "occurrence.move", json!({"occurrence": plate, "space": "world", "translate": [0, 0, 30]}));
|
||||
let reply_at = [r["transform"][3][0].as_f64().unwrap(), r["transform"][3][1].as_f64().unwrap(), r["transform"][3][2].as_f64().unwrap()];
|
||||
near(reply_at, origin(&s, &[plate]));
|
||||
if case == "free chain" {
|
||||
near(origin(&s, &[plate]), [plate_at[0], plate_at[1], plate_at[2] + 30.0]);
|
||||
near(origin(&s, &[motor]), [motor_at[0], motor_at[1], motor_at[2] + 30.0]);
|
||||
assert!(r.get("reverted").is_none() && r.get("warning").is_none(), "{case}: {r}");
|
||||
continue;
|
||||
}
|
||||
near(origin(&s, &[plate]), plate_at);
|
||||
assert_eq!(r["reverted"], json!(true), "{case}: {r}");
|
||||
let warning = r["warning"].as_str().unwrap_or_default();
|
||||
let holder = if case == "motor grounded" { "Bolted" } else { "Mount" };
|
||||
assert!(warning.contains(holder) && warning.contains("joint.reach") && warning.contains("joint.edit"), "{case}: {warning}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #11723: a part inside an assembly placed twice has no path of its own. When its joints put it
|
||||
/// back, the warning still names the joint that holds it.
|
||||
#[test]
|
||||
fn a_move_its_joints_undo_names_the_joint_in_a_repeated_assembly() {
|
||||
let mut s = Session::default();
|
||||
let (_, base) = part(&mut s, "Base", [0.0, 0.0, 0.0]);
|
||||
let arm = run(&mut s, "component.create", json!({"name": "Arm"}));
|
||||
let (arm_component, arm_at) = (arm["component"].as_u64().unwrap(), arm["occurrence"].as_u64().unwrap());
|
||||
run(&mut s, "component.activate", json!({"component": arm_component}));
|
||||
let plate = run(&mut s, "component.create", json!({"name": "Plate"}))["occurrence"].as_u64().unwrap();
|
||||
run(&mut s, "solid.box", json!({"length": 10, "width": 10, "height": 10, "corner": [20, 0, 0]}));
|
||||
run(&mut s, "component.activate", json!({"component": "root"}));
|
||||
run(&mut s, "joint.as_built", json!({"type": "rigid", "a": base, "b": plate, "name": "Mount"}));
|
||||
run(&mut s, "occurrence.copy", json!({"occurrence": arm_at, "translate": [0, 50, 0]}));
|
||||
let r = run(&mut s, "occurrence.move", json!({"occurrence": plate, "translate": [0, 0, 30]}));
|
||||
assert_eq!(r["reverted"], json!(true), "{r}");
|
||||
let warning = r["warning"].as_str().unwrap_or_default();
|
||||
assert!(warning.contains("Mount"), "the warning names the joint: {warning}");
|
||||
}
|
||||
|
||||
@@ -234,7 +234,12 @@ fn properties(s: &Session, doc: &Document, selected: &[u64], descendants: bool,
|
||||
#[cfg(test)]
|
||||
work::count(|w| w.spreads += spread_bodies.len());
|
||||
let spreads = solidcraft_kernel::map_on_threads(&spread_bodies, 16, |&i| {
|
||||
state.bodies.get(i).and_then(|b| solidcraft_io::mass_properties(&b.body).ok().flatten()).and_then(|m| m.gyration())
|
||||
let body = state.bodies.get(i)?;
|
||||
let mut measured = solidcraft_io::mass_properties(&body.body).ok().flatten()?;
|
||||
if let Some(sheet) = state.sheets.iter().find(|sheet| sheet.body == body.definition_name()) {
|
||||
sheet.correct_perforation_mass_properties(&mut measured, &solidcraft_doc::IDENTITY).ok()?;
|
||||
}
|
||||
measured.gyration()
|
||||
});
|
||||
let spread: BTreeMap<usize, Tensor3> = spread_bodies.into_iter().zip(spreads).filter_map(|(i, g)| Some((i, g.flatten()?))).collect();
|
||||
// A window waiting for the result (the Properties window) sees how far it is and can stop it.
|
||||
@@ -254,7 +259,17 @@ fn properties(s: &Session, doc: &Document, selected: &[u64], descendants: bool,
|
||||
}
|
||||
done += 1;
|
||||
let transform: Mat = doc.model_body_offset(body).map(|offset| solidcraft_doc::mat_mul(&transform, offset)).unwrap_or(transform);
|
||||
let measured = measure_placed(body, transform)?;
|
||||
let mut measured = measure_placed(body, transform)?;
|
||||
if let Some(sheet) = state.sheets.iter().find(|sheet| sheet.body == body.definition_name() && !sheet.perforations.is_empty()) {
|
||||
let mut corrected = body.measure()?;
|
||||
corrected.volume = measured.volume;
|
||||
corrected.area = measured.area;
|
||||
corrected.centroid = measured.centroid;
|
||||
sheet.correct_perforation_properties(&mut corrected, &transform)?;
|
||||
measured.volume = corrected.volume;
|
||||
measured.area = corrected.area;
|
||||
measured.centroid = corrected.centroid;
|
||||
}
|
||||
let density = doc.density(&body.name);
|
||||
let body_mass = measured.volume * density / 1000.0;
|
||||
let closed = measured.closed;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::Session;
|
||||
use serde_json::{Value, json};
|
||||
use solidcore_record::Vec2;
|
||||
use solidcraft_geom::prelude::*;
|
||||
|
||||
fn run(s: &mut Session, cmd: &str, params: Value) -> Value {
|
||||
@@ -89,6 +90,252 @@ fn body_reassignment_offsets_preserve_world_properties() {
|
||||
close(&r["total"]["center_of_mass"][0], 5.0);
|
||||
}
|
||||
|
||||
fn panel_blank(s: &mut Session, width: f64, height: f64) {
|
||||
run(s, "sheet.manage_rules", json!({"name": "Panel 0.8", "thickness": "0.8", "active": true}));
|
||||
run(s, "sketch.create", json!({"plane": "XY", "name": "Blank"}));
|
||||
run(s, "sketch.rectangle.two_point", json!({"p0": [0, 0], "p1": [width, height]}));
|
||||
run(s, "sketch.finish", json!({}));
|
||||
run(s, "sheet.flange", json!({"sketch": "Blank", "body_name": "Panel"}));
|
||||
}
|
||||
|
||||
fn perforated_panel(s: &mut Session) {
|
||||
panel_blank(s, 20.0, 10.0);
|
||||
run(s, "sheet.perforate", json!({"diameter": "2", "pitch": "10", "margin": "1", "pattern": "square"}));
|
||||
run(s, "material.assign", json!({"bodies": ["Panel"], "material": "Steel"}));
|
||||
}
|
||||
|
||||
/// Two radius-1 holes centred at (2, 2) and (12, 2), through a 20 x 10 x 0.8 blank.
|
||||
fn perforated_panel_expected() -> (f64, f64, [f64; 3]) {
|
||||
let removed = 2.0 * std::f64::consts::PI * 0.8;
|
||||
let volume = 160.0 - removed;
|
||||
let area = 448.0 - 0.8 * std::f64::consts::PI;
|
||||
(volume, area, [(160.0 * 10.0 - removed * 7.0) / volume, (160.0 * 5.0 - removed * 2.0) / volume, 0.4])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perforated_sheet_properties_include_holes_and_their_off_centre_volume_moment() {
|
||||
let mut s = Session::default();
|
||||
perforated_panel(&mut s);
|
||||
let (volume, area, center) = perforated_panel_expected();
|
||||
let density = s.doc.density("Panel");
|
||||
let doc = s.doc.clone();
|
||||
let undo = s.undo.len();
|
||||
for command in ["component.properties", "inspect.measure"] {
|
||||
let result = run(&mut s, command, json!({}));
|
||||
close(&result["total"]["volume_mm3"], volume);
|
||||
close(&result["total"]["mass_g"], volume * density / 1000.0);
|
||||
close(&result["total"]["area_mm2"], area);
|
||||
for (axis, expected) in center.iter().enumerate() {
|
||||
close(&result["bodies"][0]["center_of_mass"][axis], *expected);
|
||||
}
|
||||
}
|
||||
let inspected = run(&mut s, "document.inspect", json!({"measure": true}));
|
||||
close(&inspected["bodies"][0]["volume_mm3"], volume);
|
||||
close(&inspected["bodies"][0]["area_mm2"], area);
|
||||
for key in ["faces", "edges", "vertices"] {
|
||||
assert_eq!(inspected["bodies"][0][key], inspected["bodies"][0]["kernel"][key], "document.inspect retains kernel {key}");
|
||||
}
|
||||
assert!(inspected["bodies"][0].get("sheet_metal").is_none());
|
||||
let picked = run(&mut s, "inspect.measure", json!({"items": [{"type": "body", "name": "Panel"}]}));
|
||||
close(&picked["items"][0]["volume_mm3"], volume);
|
||||
assert!(std::sync::Arc::ptr_eq(&s.doc, &doc));
|
||||
assert_eq!(s.undo.len(), undo, "measuring must not add an undo step");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perforated_sheet_instances_keep_physical_properties_in_nested_world_placements() {
|
||||
let mut s = Session::default();
|
||||
let parent = run(&mut s, "component.create", json!({"name": "Subassembly", "grounded": false}));
|
||||
let child = run(&mut s, "component.create", json!({"name": "Sheet", "grounded": false}));
|
||||
perforated_panel(&mut s);
|
||||
let sheet_density = s.doc.density("Panel");
|
||||
run(&mut s, "component.activate", json!({"component": "root"}));
|
||||
let copy = run(&mut s, "occurrence.copy", json!({"component": parent["component"], "translate": [40, 0, 0]}));
|
||||
run(
|
||||
&mut s,
|
||||
"occurrence.move",
|
||||
json!({"occurrence": parent["occurrence"], "translate": [20, 0, 10], "axis": [0, 0, 1], "angle": "90 deg", "capture": false}),
|
||||
);
|
||||
box_in(&mut s, "Ballast");
|
||||
let ballast_body = s.model.state().bodies.last().unwrap().name.clone();
|
||||
run(&mut s, "material.assign", json!({"bodies": [ballast_body], "material": "Aluminum"}));
|
||||
let ballast_mass = s.doc.density(&ballast_body);
|
||||
let (volume, area, center) = perforated_panel_expected();
|
||||
let sheet_mass = volume * sheet_density / 1000.0;
|
||||
let first = [20.0 - center[1], center[0], 10.0 + center[2]];
|
||||
let second = [40.0 + center[0], center[1], center[2]];
|
||||
let doc = s.doc.clone();
|
||||
let moves = s.pending_moves.clone();
|
||||
let undo = s.undo.len();
|
||||
for (parent_occurrence, expected) in [(&parent["occurrence"], first), (©["occurrence"], second)] {
|
||||
let properties =
|
||||
run(&mut s, "occurrence.properties", json!({"occurrence": child["occurrence"], "path": [parent_occurrence, child["occurrence"]]}));
|
||||
close(&properties["total"]["volume_mm3"], volume);
|
||||
close(&properties["total"]["mass_g"], sheet_mass);
|
||||
close(&properties["total"]["area_mm2"], area);
|
||||
for (axis, coordinate) in expected.iter().enumerate() {
|
||||
close(&properties["total"]["center_of_mass"][axis], *coordinate);
|
||||
}
|
||||
}
|
||||
let properties = run(&mut s, "component.properties", json!({"component": "root"}));
|
||||
let mass = 2.0 * sheet_mass + ballast_mass;
|
||||
close(&properties["total"]["volume_mm3"], 2.0 * volume + 1000.0);
|
||||
close(&properties["total"]["mass_g"], mass);
|
||||
for axis in 0..3 {
|
||||
close(&properties["total"]["center_of_mass"][axis], (sheet_mass * (first[axis] + second[axis]) + ballast_mass * 5.0) / mass);
|
||||
}
|
||||
let measured = run(&mut s, "inspect.measure", json!({}));
|
||||
close(&measured["total"]["volume_mm3"], 2.0 * volume + 1000.0);
|
||||
close(&measured["total"]["mass_g"], mass);
|
||||
assert_eq!(measured["bodies"].as_array().unwrap().iter().filter(|b| b["sheet_metal"] == true).count(), 2);
|
||||
assert!(std::sync::Arc::ptr_eq(&s.doc, &doc));
|
||||
assert_eq!(s.pending_moves, moves);
|
||||
assert_eq!(s.undo.len(), undo);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perforated_sheet_centroid_follows_a_folded_panel_and_unfolds() {
|
||||
use std::f64::consts::{FRAC_PI_2, PI};
|
||||
let mut s = Session::default();
|
||||
panel_blank(&mut s, 30.0, 10.0);
|
||||
run(
|
||||
&mut s,
|
||||
"sheet.fold",
|
||||
json!({"points": [[10, 0, 0], [10, 10, 0]], "angle": "90 deg", "radius": "0.8", "position": "centerline", "fixed": [2, 5, 0]}),
|
||||
);
|
||||
let before = run(&mut s, "component.properties", json!({"component": "root"}));
|
||||
run(&mut s, "sheet.perforate", json!({"diameter": "2", "pitch": "10", "margin": "0", "pattern": "square"}));
|
||||
let sheet = &s.model.state().sheets[0];
|
||||
let holes = sheet.perforation_holes(&sheet.perforations[0]).unwrap();
|
||||
assert_eq!(holes.len(), 2);
|
||||
// Fold boundaries carry kernel roundoff; keep the analytic centres and the
|
||||
// same sub-micrometre tolerance used by the property checks below.
|
||||
for (hole, expected) in holes.iter().zip([Vec2::new(1.0, 1.0), Vec2::new(21.0, 1.0)]) {
|
||||
assert!(hole.dist(expected) < 1e-6, "{hole:?} != {expected:?}");
|
||||
}
|
||||
// The right panel turns up by 90 degrees about a y-parallel bend axis at
|
||||
// z = radius + thickness. Its mid-plane is radius + thickness/2 from that axis.
|
||||
let allowance = FRAC_PI_2 * (0.8 + 0.44 * 0.8);
|
||||
let bend_start = 10.0 - allowance / 2.0;
|
||||
let right_hole = [bend_start + 1.2, 1.0, 1.6 + 21.0 - bend_start - allowance];
|
||||
let old_volume = before["total"]["volume_mm3"].as_f64().unwrap();
|
||||
let hole_volume = PI * 0.8;
|
||||
let volume = old_volume - 2.0 * hole_volume;
|
||||
let result = run(&mut s, "component.properties", json!({"component": "root"}));
|
||||
close(&result["total"]["volume_mm3"], volume);
|
||||
for (axis, left) in [1.0, 1.0, 0.4].iter().enumerate() {
|
||||
let old = before["total"]["center_of_mass"][axis].as_f64().unwrap();
|
||||
close(&result["total"]["center_of_mass"][axis], old + hole_volume * (2.0 * old - left - right_hole[axis]) / volume);
|
||||
}
|
||||
run(&mut s, "sheet.unfold", json!({}));
|
||||
let result = run(&mut s, "component.properties", json!({"component": "root"}));
|
||||
let volume = 240.0 - 2.0 * hole_volume;
|
||||
close(&result["total"]["volume_mm3"], volume);
|
||||
for (axis, expected) in [(240.0 * 15.0 - 2.0 * hole_volume * 11.0) / volume, (240.0 * 5.0 - 2.0 * hole_volume) / volume, 0.4].iter().enumerate() {
|
||||
close(&result["total"]["center_of_mass"][axis], *expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perforated_sheet_correction_rejects_invalid_metadata_without_partial_changes() {
|
||||
let mut s = Session::default();
|
||||
perforated_panel(&mut s);
|
||||
let state = s.model.state();
|
||||
let measured = solidcraft_kernel::measure(&state.bodies[0].body).unwrap();
|
||||
for pitch in [0.0, -1.0, f64::NAN, f64::INFINITY] {
|
||||
let mut sheet = state.sheets[0].clone();
|
||||
sheet.perforations[0].pitch = pitch;
|
||||
let mut actual = measured.clone();
|
||||
assert!(sheet.correct_perforation_properties(&mut actual, &solidcraft_doc::IDENTITY).is_err());
|
||||
assert_eq!(actual.volume, measured.volume);
|
||||
assert_eq!(actual.area, measured.area);
|
||||
assert_eq!(actual.centroid, measured.centroid);
|
||||
}
|
||||
let mut scaled = solidcraft_doc::IDENTITY;
|
||||
scaled[0][0] = 2.0;
|
||||
let mut sheared = solidcraft_doc::IDENTITY;
|
||||
sheared[0][1] = 0.5;
|
||||
for placement in [scaled, sheared] {
|
||||
let mut actual = measured.clone();
|
||||
assert!(state.sheets[0].correct_perforation_properties(&mut actual, &placement).is_err());
|
||||
assert_eq!((actual.volume, actual.area, actual.centroid), (measured.volume, measured.area, measured.centroid));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perforated_sheet_body_transfer_preserves_world_mass_and_centroid() {
|
||||
let mut s = Session::default();
|
||||
perforated_panel(&mut s);
|
||||
let moved = run(&mut s, "component.create", json!({"name": "MovedSheet", "grounded": false}));
|
||||
run(&mut s, "occurrence.move", json!({"occurrence": moved["occurrence"], "translate": [100, 0, 0]}));
|
||||
run(&mut s, "component.move_bodies", json!({"bodies": ["Panel"], "component": moved["component"]}));
|
||||
let (volume, _, center) = perforated_panel_expected();
|
||||
let mass = volume * s.doc.density("Panel") / 1000.0;
|
||||
for command in ["component.properties", "inspect.measure"] {
|
||||
let result = run(&mut s, command, json!({"component": "root"}));
|
||||
close(&result["total"]["volume_mm3"], volume);
|
||||
close(&result["total"]["mass_g"], mass);
|
||||
for (axis, expected) in center.iter().enumerate() {
|
||||
close(&result["bodies"][0]["center_of_mass"][axis], *expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn perforated_sheet_inertia_removes_analytic_hole_cylinders_and_turns_with_the_sheet() {
|
||||
let mut s = Session::default();
|
||||
let c = run(&mut s, "component.create", json!({"name": "Sheet", "grounded": false}));
|
||||
perforated_panel(&mut s);
|
||||
let (volume, _, center) = perforated_panel_expected();
|
||||
let old_center = [10.0, 5.0, 0.4];
|
||||
let mut expected = [[0.0; 3]; 3];
|
||||
let dimensions: [f64; 3] = [20.0, 10.0, 0.8];
|
||||
for i in 0..3 {
|
||||
expected[i][i] = 160.0 * (dimensions[(i + 1) % 3].powi(2) + dimensions[(i + 2) % 3].powi(2)) / 12.0;
|
||||
}
|
||||
let hole_volume = std::f64::consts::PI * 0.8;
|
||||
let own = [hole_volume * (3.0 + 0.64) / 12.0, hole_volume * (3.0 + 0.64) / 12.0, hole_volume / 2.0];
|
||||
for hole in [[2.0, 2.0, 0.4], [12.0, 2.0, 0.4]] {
|
||||
let d = [0, 1, 2].map(|i| hole[i] - old_center[i]);
|
||||
let d2: f64 = d.iter().map(|v| v * v).sum();
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
expected[i][j] -= if i == j { own[i] + hole_volume * d2 } else { 0.0 } - hole_volume * d[i] * d[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
let d = [0, 1, 2].map(|i| center[i] - old_center[i]);
|
||||
let d2: f64 = d.iter().map(|v| v * v).sum();
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
expected[i][j] = (expected[i][j] - volume * (if i == j { d2 } else { 0.0 } - d[i] * d[j])) * s.doc.density("Panel") / 1000.0;
|
||||
}
|
||||
}
|
||||
let first = run(&mut s, "component.properties", json!({}));
|
||||
tensor_close(&first["total"]["inertia_g_mm2"], expected, 1e-9);
|
||||
let verify_assembly = |s: &mut Session, tensor: [[f64; 3]; 3], center: [f64; 3]| {
|
||||
let assembly = run(s, "assembly.mass_properties", json!({}));
|
||||
let occurrence = assembly["occurrences"].as_array().unwrap().iter().find(|o| o["occurrence"] == c["occurrence"]).unwrap();
|
||||
let mass = &occurrence["mass"];
|
||||
assert!((mass["mass_kg"].as_f64().unwrap() - volume * s.doc.density("Panel") * 1e-6).abs() < 1e-12);
|
||||
for (axis, coordinate) in center.iter().enumerate() {
|
||||
close(&mass["center_of_mass_mm"][axis], *coordinate);
|
||||
}
|
||||
tensor_close(&mass["inertia_world_kg_mm2"], tensor.map(|row| row.map(|value| value / 1000.0)), 1e-9);
|
||||
};
|
||||
verify_assembly(&mut s, expected, center);
|
||||
run(
|
||||
&mut s,
|
||||
"occurrence.move",
|
||||
json!({"occurrence": c["occurrence"], "translate": [100, 40, 10], "axis": [0, 0, 1], "angle": "90 deg", "capture": false}),
|
||||
);
|
||||
let turned = run(&mut s, "component.properties", json!({}));
|
||||
let rotation = [[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]];
|
||||
let rotated = solidcraft_geom::inertia::transformed(&expected, &rotation);
|
||||
tensor_close(&turned["total"]["inertia_g_mm2"], rotated, 1e-9);
|
||||
verify_assembly(&mut s, rotated, [100.0 - center[1], 40.0 + center[0], 10.0 + center[2]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn properties_reject_hostile_identifiers_and_options() {
|
||||
let mut s = Session::default();
|
||||
|
||||
@@ -4,6 +4,136 @@ fn run(s: &mut Session, command: &str, params: Value) -> Value {
|
||||
s.execute(command, ¶ms).unwrap()
|
||||
}
|
||||
|
||||
fn transferred_profile(revolve: bool) -> (Session, u64, u64, solidcraft_kernel::Body) {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "sketch.create", json!({"plane":if revolve { "XZ" } else { "XY" },"name":"Profile"}));
|
||||
run(&mut s, "sketch.rectangle.two_point", json!({"p0":[20,0],"p1":[30,5]}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
if revolve {
|
||||
run(&mut s, "solid.revolve", json!({"axis":"y","angle":"360 deg","body_name":"Part"}));
|
||||
} else {
|
||||
run(&mut s, "solid.extrude", json!({"distance":10,"body_name":"Part"}));
|
||||
}
|
||||
let original = s.world_state().unwrap().body("Part").unwrap().body.clone();
|
||||
let created = run(&mut s, "component.from_bodies", json!({"bodies":["Part"]}));
|
||||
let component = created["components"][0]["component"].as_u64().unwrap();
|
||||
let occurrence = s.doc.occurrences.iter().find(|o| o.component == component).unwrap().id;
|
||||
run(&mut s, "component.move_sketches", json!({"sketches":["Profile"],"component":component}));
|
||||
run(&mut s, "occurrence.ground", json!({"occurrence":occurrence,"grounded":false}));
|
||||
(s, component, occurrence, original)
|
||||
}
|
||||
|
||||
fn check_captured_profile_transfer(revolve: bool) {
|
||||
let (mut s, _, occurrence, original) = transferred_profile(revolve);
|
||||
let before = s.doc.to_json();
|
||||
let matrix = solidcraft_doc::rigid(Vec3::new(40.0, 0.0, 0.0), Vec3::ZERO, Vec3::X, std::f64::consts::FRAC_PI_4);
|
||||
let expected = solidcraft_kernel::transform_matrix(&original, matrix).unwrap();
|
||||
let expected_bounds = expected.exact_bounds().unwrap();
|
||||
let assert_pose = |s: &Session| {
|
||||
let state = s.world_state().unwrap();
|
||||
let body = &state.body("Part").unwrap().body;
|
||||
let bounds = body.exact_bounds().unwrap();
|
||||
assert!(bounds.min.dist(expected_bounds.min) < 0.002, "minimum: {bounds:?}, expected {expected_bounds:?}");
|
||||
assert!(bounds.max.dist(expected_bounds.max) < 0.002, "maximum: {bounds:?}, expected {expected_bounds:?}");
|
||||
let measured = solidcraft_kernel::measure(body).unwrap();
|
||||
let expected_measure = solidcraft_kernel::measure(&expected).unwrap();
|
||||
assert!((measured.volume - expected_measure.volume).abs() < 1e-5);
|
||||
assert!(measured.centroid.dist(expected_measure.centroid) < 1e-5);
|
||||
};
|
||||
run(&mut s, "occurrence.move", json!({"occurrence":occurrence,"translate":[40,0,0],"axis":[1,0,0],"angle":"45 deg","capture":false}));
|
||||
assert_pose(&s);
|
||||
let undo = s.undo.len();
|
||||
run(&mut s, "component.capture_position", json!({}));
|
||||
assert_eq!(s.undo.len(), undo + 1);
|
||||
assert!(s.pending_moves.is_empty());
|
||||
assert_pose(&s);
|
||||
let mut reopened = Session { doc: solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap().into(), ..Session::default() };
|
||||
reopened.refresh();
|
||||
assert_pose(&reopened);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_eq!(s.doc.to_json(), before);
|
||||
run(&mut s, "edit.redo", json!({}));
|
||||
assert_pose(&s);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn capture_transferred_extrusion_with_its_source_sketch_moves_once() {
|
||||
check_captured_profile_transfer(false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn capture_transferred_revolve_with_its_source_sketch_moves_once() {
|
||||
check_captured_profile_transfer(true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transferred_profile_frame_follows_transfer_edits_suppression_and_rollback() {
|
||||
let (mut s, component, occurrence, _) = transferred_profile(false);
|
||||
let creator = s.model.state().body("Part").unwrap().feature;
|
||||
let transfer = s.doc.features.iter().find(|f| matches!(f.kind, FeatureKind::BodyTransfer { .. })).unwrap().id;
|
||||
run(&mut s, "occurrence.move", json!({"occurrence":occurrence,"translate":[40,0,0]}));
|
||||
let assert_x = |s: &Session, local: f64, owner: u64| {
|
||||
let source = s.model.result(creator).unwrap().state.body("Part").unwrap().body.exact_bounds().unwrap();
|
||||
assert!((source.min.x - local).abs() < 1e-6, "source frame: {source:?}");
|
||||
let state = s.world_state().unwrap();
|
||||
let body = state.body("Part").unwrap();
|
||||
assert_eq!(body.component, owner);
|
||||
assert!((body.body.exact_bounds().unwrap().min.x - 60.0).abs() < 1e-6);
|
||||
};
|
||||
assert_x(&s, 20.0, component);
|
||||
s.doc_mut().feature_mut(transfer).unwrap().suppressed = true;
|
||||
s.refresh();
|
||||
assert_x(&s, 60.0, 0);
|
||||
s.doc_mut().feature_mut(transfer).unwrap().suppressed = false;
|
||||
s.refresh();
|
||||
assert_x(&s, 20.0, component);
|
||||
let boundary = s.doc.feature_index(transfer);
|
||||
s.doc_mut().marker = boundary;
|
||||
s.refresh();
|
||||
assert_x(&s, 60.0, 0);
|
||||
s.doc_mut().marker = None;
|
||||
s.refresh();
|
||||
assert_x(&s, 20.0, component);
|
||||
if let FeatureKind::BodyTransfer { transform, .. } = &mut s.doc_mut().feature_mut(transfer).unwrap().kind {
|
||||
*transform = solidcraft_doc::rigid(Vec3::new(-7.0, 0.0, 0.0), Vec3::ZERO, Vec3::Z, 0.0);
|
||||
}
|
||||
s.refresh();
|
||||
assert_x(&s, 27.0, component);
|
||||
let mut reopened = Session { doc: solidcraft_doc::Document::from_json(&s.doc.to_json()).unwrap().into(), ..Session::default() };
|
||||
reopened.refresh();
|
||||
assert_x(&reopened, 27.0, component);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn capturing_one_transferred_profile_instance_keeps_its_peer_in_place() {
|
||||
let (mut s, _, occurrence, _) = transferred_profile(false);
|
||||
run(&mut s, "occurrence.copy", json!({"occurrence":occurrence,"translate":[100,0,0]}));
|
||||
run(&mut s, "occurrence.move", json!({"occurrence":occurrence,"translate":[40,0,0],"capture":false}));
|
||||
run(&mut s, "component.capture_position", json!({}));
|
||||
let state = s.world_state().unwrap();
|
||||
let mut xs: Vec<f64> = state.bodies.iter().map(|body| body.body.exact_bounds().unwrap().min.x).collect();
|
||||
xs.sort_by(f64::total_cmp);
|
||||
assert_eq!(xs.len(), 2);
|
||||
assert!((xs[0] - 60.0).abs() < 1e-6 && (xs[1] - 120.0).abs() < 1e-6, "{xs:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_profile_without_a_body_transfer_keeps_its_live_component_frame() {
|
||||
let mut s = Session::default();
|
||||
let created = run(&mut s, "component.create", json!({"name":"Source","grounded":false}));
|
||||
let occurrence = created["occurrence"].as_u64().unwrap();
|
||||
run(&mut s, "sketch.create", json!({"plane":"XY","name":"Profile"}));
|
||||
run(&mut s, "sketch.rectangle.two_point", json!({"p0":[0,0],"p1":[10,20]}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
run(&mut s, "component.activate", json!({"component":0}));
|
||||
run(&mut s, "solid.extrude", json!({"sketch":"Profile","distance":5,"body_name":"Part"}));
|
||||
run(&mut s, "occurrence.move", json!({"occurrence":occurrence,"translate":[40,0,0]}));
|
||||
let state = s.world_state().unwrap();
|
||||
let body = state.body("Part").unwrap();
|
||||
assert_eq!(body.component, 0);
|
||||
assert!((body.body.exact_bounds().unwrap().min.x - 40.0).abs() < 1e-6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recorded_assignment_preserves_sample_joined_material_and_timeline() {
|
||||
let mut s = Session::default();
|
||||
|
||||
@@ -7,15 +7,27 @@ use solidcraft_doc::config::{Column, ConfigRow, MAX_COLUMNS, MAX_ROWS};
|
||||
|
||||
use super::CommandSpec;
|
||||
use crate::params::{bad, bool_, str_, string_list};
|
||||
use crate::schema::config::{ConfigActivation, ConfigRowParams, ConfigTable, ConfigTableParams, ConfigTableReply, ConfigTableRow, ConfigTarget};
|
||||
use crate::schema::config::{
|
||||
ConfigActivation, ConfigColumnParams, ConfigConfigureParams, ConfigRowEditParams, ConfigRowParams, ConfigRuleParams, ConfigTable,
|
||||
ConfigTableParams, ConfigTableReply, ConfigTableRow, ConfigTarget,
|
||||
};
|
||||
use crate::schema::{TypedContract, output_schema_for};
|
||||
use crate::{Result, Session};
|
||||
|
||||
const TABLE_CONTRACT: TypedContract<ConfigTableParams> = TypedContract::new();
|
||||
const ROW_CONTRACT: TypedContract<ConfigRowParams> = TypedContract::new();
|
||||
const CONFIGURE_CONTRACT: TypedContract<ConfigConfigureParams> = TypedContract::new();
|
||||
const COLUMN_CONTRACT: TypedContract<ConfigColumnParams> = TypedContract::new();
|
||||
const ROW_EDIT_CONTRACT: TypedContract<ConfigRowEditParams> = TypedContract::new();
|
||||
const RULE_CONTRACT: TypedContract<ConfigRuleParams> = TypedContract::new();
|
||||
|
||||
pub static COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec::new("config.configure", "Configure", configure).at("SOLID", "CONFIGURE").icon("params").params(
|
||||
CommandSpec::new("config.configure", "Configure", crate::checked!("config.configure", configure))
|
||||
.at("SOLID", "CONFIGURE")
|
||||
.icon("params")
|
||||
.contract(&CONFIGURE_CONTRACT)
|
||||
.output(output_schema_for::<ConfigTableReply>)
|
||||
.params(
|
||||
"params?: [parameter names]; features?: [feature names]; materials?: [body names]; appearances?: [body names] (columns to add; with no rows yet, a \"Default\" row takes the current values)",
|
||||
),
|
||||
CommandSpec::new("config.table", "Display Configuration Table", crate::checked!("config.table", show))
|
||||
@@ -25,8 +37,16 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.contract(&TABLE_CONTRACT)
|
||||
.output(output_schema_for::<ConfigTableReply>)
|
||||
.params("→ columns (param:<name> or suppress:<feature>), rows, the active row and whether the design still matches it"),
|
||||
CommandSpec::new("config.column", "Configuration Column", column).icon("configuration_table").params("param? | feature? | material? | appearance? (target name); delete?: bool"),
|
||||
CommandSpec::new("config.row", "Configuration Row", row).icon("configuration_table").params(
|
||||
CommandSpec::new("config.column", "Configuration Column", crate::checked!("config.column", column))
|
||||
.icon("configuration_table")
|
||||
.contract(&COLUMN_CONTRACT)
|
||||
.output(output_schema_for::<ConfigTableReply>)
|
||||
.params("param? | feature? | material? | appearance? (target name); delete?: bool"),
|
||||
CommandSpec::new("config.row", "Configuration Row", crate::checked!("config.row", row))
|
||||
.icon("configuration_table")
|
||||
.contract(&ROW_EDIT_CONTRACT)
|
||||
.output(output_schema_for::<ConfigTableReply>)
|
||||
.params(
|
||||
"name; from? (row to copy; default current values); values?: {column key: expression, suppression, material name, appearance name or Look object}; rename?; delete?: bool",
|
||||
),
|
||||
CommandSpec::new("config.activate", "Activate Configuration", crate::checked!("config.activate", activate))
|
||||
@@ -40,7 +60,11 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.contract(&ROW_CONTRACT)
|
||||
.output(output_schema_for::<ConfigActivation>)
|
||||
.params("row: name — validates a rebuild without changing the design or history"),
|
||||
CommandSpec::new("config.rule", "Configuration Rule", rule).icon("configuration_table").params(
|
||||
CommandSpec::new("config.rule", "Configuration Rule", crate::checked!("config.rule", rule))
|
||||
.icon("configuration_table")
|
||||
.contract(&RULE_CONTRACT)
|
||||
.output(output_schema_for::<ConfigTableReply>)
|
||||
.params(
|
||||
"rule?: {id,name,enabled,condition,effect}; rules?: [rule…] (added or replaced together, then the rows checked once); id? + delete?; id? + index? (ordered move)",
|
||||
),
|
||||
CommandSpec::new("config.rules", "Configuration Rules", crate::checked!("config.rules", show))
|
||||
|
||||
@@ -105,7 +105,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.at("SOLID", "CREATE")
|
||||
.icon("hole")
|
||||
.key("H")
|
||||
.params("position: [x,y,z] on a face (numbers, or length expressions the hole follows) | sketch + points: [sketch point ids] (one hole each, perpendicular to the sketch, into the material on whichever side of the sketch plane it is) | sketch alone (every sketch point: standalone points and circle centres); flip?: bool (sketch points: drill to the other side); single?: bool (with one sketch point: a Single hole that follows the point, drilled into the face there); direction?: [x,y,z] (default: into the face, against its outward normal; one that leaves the face is mirrored into it; ignored with sketch points unless single); diameter | thread (a tapped hole, drilled with the tap maker's tabulated drill: ISO metric (a custom metric size: major minus pitch), UNC/UNF, G, Rp, Rc 1/16 to 4, NPT 1/16 to 3; a `diameter` given with it chooses another drill, from the thread's minor diameter to 5% over the tap maker's) | clearance: \"M6\" with fit?: close|normal|loose (ISO 273); depth? (default through all) | to?: [x,y,z] (To Object: drill to that face or point); references?: [{edge: [x,y,z] on a straight edge of the face, distance: expr}] (at most two; the centre goes that far from each edge's line, in the face's plane, and follows the edges; with a numeric position only); type?: simple|drilled|counterbore|countersink; tip_angle?; cb_diameter?, cb_depth?; cs_diameter?, cs_angle?; thread?: \"M6\", \"1/4-20 UNC\", \"G 1/4\", \"Rp 1/4\", \"Rc 1/4\" or \"1/4-18 NPT\" (cosmetic unless modeled); hand?: right|left (the tapped thread's hand; default right; needs thread); thread_depth?: positive length independent of drill depth (default: full useful cylindrical wall; must fit that wall); modeled?: bool (needs thread: the tapped thread cut into the wall, the groove between its teeth, as solid.thread's modelled one; default false: listed only); ease_out?: expr|standard|short (modelled tapped threads: the inner end, towards the bottom, fades out over this length, ISO 3508's runout, standard 2.5 P, short 1.25 P; without it the groove stops square at thread_depth, or clear of a blind hole's bottom); targets?: [body] (the bodies to drill; holes at the points of a sketch on a body's face default to that body, found along the holes' direction on it alone; explicit targets or participants override, [\"*\"] every body)"),
|
||||
.params("position: [x,y,z] on a face (numbers, or length expressions the hole follows) | sketch + points: [sketch point ids] (one hole each, perpendicular to the sketch, into the material on whichever side of the sketch plane it is) | sketch alone (every sketch point: standalone points and circle centres); flip?: bool (sketch points: drill to the other side); single?: bool (with one sketch point: a Single hole that follows the point, drilled into the face there); direction?: [x,y,z] (default: into the face, against its outward normal; one that leaves the face is mirrored into it; ignored with sketch points unless single); diameter | thread (a tapped hole, drilled with the tap maker's tabulated drill: ISO metric (a custom metric size: major minus pitch), UNC/UNF, G, Rp, Rc 1/16 to 4, NPT 1/16 to 3; a `diameter` given with it chooses another drill, from the thread's minor diameter to 5% over the tap maker's) | clearance: \"M6\" with fit?: close|normal|loose (ISO 273); depth? (default through all) | to?: [x,y,z] (To Object: drill to that face or point); references?: [{edge: [x,y,z] on a straight edge of the face, distance: expr}] (at most two; the centre goes that far from each edge's line, in the face's plane, and follows the edges; with a numeric position only); type?: simple|drilled|counterbore|countersink; tip_angle?; cb_diameter?, cb_depth?, bridge?: length (counterbore: two 3D-printing bridge layers this thick below its floor, a slot along X then a square; e.g. 0.2 mm); cs_diameter?, cs_angle?; thread?: \"M6\", \"1/4-20 UNC\", \"G 1/4\", \"Rp 1/4\", \"Rc 1/4\" or \"1/4-18 NPT\" (cosmetic unless modeled); hand?: right|left (the tapped thread's hand; default right; needs thread); thread_depth?: positive length independent of drill depth (default: full useful cylindrical wall; must fit that wall); modeled?: bool (needs thread: the tapped thread cut into the wall, the groove between its teeth, as solid.thread's modelled one; default false: listed only); ease_out?: expr|standard|short (modelled tapped threads: the inner end, towards the bottom, fades out over this length, ISO 3508's runout, standard 2.5 P, short 1.25 P; without it the groove stops square at thread_depth, or clear of a blind hole's bottom); targets?: [body] (the bodies to drill; holes at the points of a sketch on a body's face default to that body, found along the holes' direction on it alone; explicit targets or participants override, [\"*\"] every body)"),
|
||||
CommandSpec::new("solid.pipe", "Pipe", crate::checked!("solid.pipe", pipe))
|
||||
.at("SOLID", "CREATE")
|
||||
.icon("pipe")
|
||||
@@ -744,6 +744,8 @@ fn add_feature_in(s: &mut Session, p: &Value, kind: FeatureKind, world: bool) ->
|
||||
names
|
||||
} else if pts.is_empty() {
|
||||
Vec::new()
|
||||
} else if matches!(kind, FeatureKind::Hole { .. }) {
|
||||
hole_face_names(s, p, &kind)?
|
||||
} else {
|
||||
solidcraft_doc::face_point_names(&s.doc, &s.model.state(), &kind, s.active_component)?
|
||||
}
|
||||
@@ -1082,6 +1084,22 @@ fn face_body_reached(s: &Session, sketch: u64) -> Result<Option<String>> {
|
||||
Ok(Some(body.name.clone()))
|
||||
}
|
||||
|
||||
/// A hole's face points, named on the bodies it drills where one of theirs holds the point
|
||||
/// (#7520): a face of another body in the same plane, a hidden one the hole leaves alone, would
|
||||
/// otherwise take the name of the face that was picked. Over every body, as before, elsewhere.
|
||||
fn hole_face_names(s: &Session, p: &Value, kind: &FeatureKind) -> Result<Vec<String>> {
|
||||
let st = s.model.state();
|
||||
let all = solidcraft_doc::face_point_names(&s.doc, &st, kind, s.active_component)?;
|
||||
let drilled = string_list_or_default(p, "participants");
|
||||
if drilled.is_empty() || drilled.iter().any(|b| b == "*") {
|
||||
return Ok(all);
|
||||
}
|
||||
let mut scoped = solidcraft_doc::ModelState::default();
|
||||
scoped.bodies = st.bodies.iter().filter(|b| drilled.contains(&b.name)).cloned().collect();
|
||||
let own = solidcraft_doc::face_point_names(&s.doc, &scoped, kind, s.active_component)?;
|
||||
Ok(own.into_iter().zip(all).map(|(own, any)| if own.is_empty() { any } else { own }).collect())
|
||||
}
|
||||
|
||||
/// The body whose face `sketch` is attached to (on the face itself, not offset from it), when
|
||||
/// it is one the active component works on ([`active_scope`]).
|
||||
fn sketch_face_body(s: &Session, sketch: u64) -> Option<String> {
|
||||
@@ -2600,6 +2618,18 @@ fn split_body(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
add_feature(s, p, FeatureKind::Split { body: BodyName(body), plane, tool: None, sketch: None, line: None })
|
||||
}
|
||||
|
||||
/// The fits [`clearance_diameter`] knows (close, normal, loose, and their older names).
|
||||
const CLEARANCE_FITS: [&str; 6] = ["close", "fine", "normal", "medium", "loose", "coarse"];
|
||||
|
||||
/// A value typed by the user, cut short for a message.
|
||||
fn brief(text: &str) -> String {
|
||||
const MAX: usize = 32;
|
||||
match text.char_indices().nth(MAX) {
|
||||
Some((end, _)) => format!("{}…", &text[..end]),
|
||||
None => text.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
/// ISO 273 clearance hole diameters (close, normal, loose fit) for metric bolts.
|
||||
fn clearance_diameter(size: &str, fit: &str) -> Option<f64> {
|
||||
const TABLE: [(f64, f64, f64, f64); 21] = [
|
||||
@@ -2808,10 +2838,18 @@ fn hole(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let position = if references.is_empty() { position } else { referenced_centre(s, cmd, &references, position, direction)? };
|
||||
// The diameter: given, or a metric-estimate/Unified-table tap drill, or an ISO 273
|
||||
// clearance hole for a bolt size (close, normal or loose fit).
|
||||
// A diameter number out of range says so, rather than that none was given (#9625).
|
||||
if matches!(p.get("diameter"), Some(Value::Number(_))) && expr(p, "diameter").is_none() {
|
||||
return Err(bad(cmd, format!("`diameter` {}", expr_problem(p.get("diameter")))));
|
||||
}
|
||||
let diameter = match (expr(p, "diameter"), &thread, str_(p, "clearance")) {
|
||||
(Some(d), _, _) => d,
|
||||
(None, _, Some(c)) => {
|
||||
let fit = str_(p, "fit").unwrap_or("normal").to_ascii_lowercase();
|
||||
// An unknown fit is not an unknown bolt size (#9625).
|
||||
if !CLEARANCE_FITS.contains(&fit.as_str()) {
|
||||
return Err(bad(cmd, format!("`fit` must be close, normal or loose, not `{}`", brief(&fit))));
|
||||
}
|
||||
let d = clearance_diameter(c, &fit).ok_or_else(|| bad(cmd, format!("no clearance hole for `{c}` ({fit} fit): M1.6 to M64")))?;
|
||||
Expr::new(format!("{d} mm"))
|
||||
}
|
||||
@@ -2838,22 +2876,41 @@ fn hole(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let e = req_expr(cmd, p, k)?;
|
||||
Ok(e)
|
||||
};
|
||||
// Given but unreadable (`true`, a list, an empty text): refused, never a plain counterbore.
|
||||
let bridge = match (expr(p, "bridge"), p.get("bridge")) {
|
||||
(Some(b), _) => Some(b),
|
||||
(None, None | Some(Value::Null)) => None,
|
||||
(None, v) => return Err(bad(cmd, format!("`bridge` {}", expr_problem(v)))),
|
||||
};
|
||||
let kind = match str_(p, "type").unwrap_or("simple") {
|
||||
"simple" => match expr(p, "tip_angle") {
|
||||
Some(t) if depth.is_some() => solidcraft_doc::HoleKind::Drilled { tip_angle: t },
|
||||
_ => solidcraft_doc::HoleKind::Simple,
|
||||
},
|
||||
"drilled" => solidcraft_doc::HoleKind::Drilled { tip_angle: expr(p, "tip_angle").unwrap_or_else(|| "118 deg".into()) },
|
||||
"counterbore" => {
|
||||
solidcraft_doc::HoleKind::Counterbore { cb_diameter: get("cb_diameter")?, cb_depth: get("cb_depth")?, tip_angle: expr(p, "tip_angle") }
|
||||
}
|
||||
"counterbore" => solidcraft_doc::HoleKind::Counterbore {
|
||||
cb_diameter: get("cb_diameter")?,
|
||||
cb_depth: get("cb_depth")?,
|
||||
tip_angle: expr(p, "tip_angle"),
|
||||
bridge: bridge.clone(),
|
||||
},
|
||||
"countersink" => solidcraft_doc::HoleKind::Countersink {
|
||||
cs_diameter: get("cs_diameter")?,
|
||||
cs_angle: expr(p, "cs_angle").unwrap_or_else(|| "90 deg".into()),
|
||||
// The default only when no angle is given: a supplied one out of range is refused (#9625).
|
||||
cs_angle: match p.get("cs_angle") {
|
||||
None | Some(Value::Null) => "90 deg".into(),
|
||||
Some(Value::String(t)) if t.trim().is_empty() => "90 deg".into(),
|
||||
Some(_) => req_expr(cmd, p, "cs_angle")?,
|
||||
},
|
||||
tip_angle: expr(p, "tip_angle"),
|
||||
},
|
||||
other => return Err(bad(cmd, format!("unknown hole type `{other}`"))),
|
||||
};
|
||||
match (&kind, &bridge) {
|
||||
(solidcraft_doc::HoleKind::Counterbore { .. }, Some(b)) => check_expr(s, b, Kind::Length, cmd, "bridge")?,
|
||||
(_, Some(_)) => return Err(bad(cmd, "`bridge` needs `type: counterbore`")),
|
||||
_ => {}
|
||||
}
|
||||
let to = match p.get("to") {
|
||||
Some(v) => Some(vec3(v).ok_or_else(|| bad(cmd, "`to` must be a point [x, y, z] on the face to drill to"))?),
|
||||
None => None,
|
||||
@@ -2876,6 +2933,20 @@ fn hole(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// placed) cuts that body: the pick is already in that body's frame, and the
|
||||
// component's own bodies alone would leave nothing to cut.
|
||||
p["participants"] = json!([body]);
|
||||
} else if let Some(mut shown) = shown_scope(s) {
|
||||
// Like a cut (#3961), a hole leaves hidden bodies alone (#7520): while some are
|
||||
// hidden, it drills the shown ones, stored so showing the others later changes
|
||||
// nothing. The body whose face was picked is drilled though hidden (picked through
|
||||
// Select Other, or hidden with the dialog open): it is the one the hole is for.
|
||||
if !shown.is_empty()
|
||||
&& points.is_none()
|
||||
&& let Some(body) = hidden_body_picked_at(s, position, &shown)
|
||||
{
|
||||
shown.push(body);
|
||||
}
|
||||
if !shown.is_empty() {
|
||||
p["participants"] = json!(shown);
|
||||
}
|
||||
}
|
||||
}
|
||||
add_feature(
|
||||
@@ -2961,16 +3032,36 @@ fn hole_reference_params(s: &Session, p: &Value, cmd: &str) -> Result<Vec<solidc
|
||||
/// component than the active one.
|
||||
fn body_of_other_component_at(s: &Session, p: Vec3) -> Option<String> {
|
||||
let st = s.model.state();
|
||||
let (_, body) = st
|
||||
.bodies
|
||||
let body = body_with_face_at(&st, p, |_| true)?;
|
||||
(s.doc.model_body_component(body) != s.active_component).then(|| body.name.clone())
|
||||
}
|
||||
|
||||
/// The hidden body whose face holds `p`, when no shown body has a face there: a face shared by
|
||||
/// a shown and a hidden body is the shown one's, as a pick in the view would take it (#7520).
|
||||
fn hidden_body_picked_at(s: &Session, p: Vec3, shown: &[String]) -> Option<String> {
|
||||
let st = s.model.state();
|
||||
if body_with_face_at(&st, p, |b| shown.contains(&b.name)).is_some() {
|
||||
return None;
|
||||
}
|
||||
let scope: Vec<&str> = active_scope(s, &st).into_iter().map(|b| b.name.as_str()).collect();
|
||||
body_with_face_at(&st, p, |b| scope.contains(&b.name.as_str())).map(|b| b.name.clone())
|
||||
}
|
||||
|
||||
/// The body, among those `keep` takes, with the face nearest `p` within its pick tolerance.
|
||||
fn body_with_face_at(
|
||||
st: &solidcraft_doc::ModelState,
|
||||
p: Vec3,
|
||||
keep: impl Fn(&solidcraft_doc::ModelBody) -> bool,
|
||||
) -> Option<&solidcraft_doc::ModelBody> {
|
||||
st.bodies
|
||||
.iter()
|
||||
.filter(|b| !b.body.is_mesh())
|
||||
.filter(|b| !b.body.is_mesh() && keep(b))
|
||||
.filter_map(|b| {
|
||||
let (d, _) = solidcraft_doc::appearance::nearest_face(b, p)?;
|
||||
(d <= solidcraft_doc::appearance::pick_tolerance(b)).then_some((d, b))
|
||||
})
|
||||
.min_by(|a, b| a.0.total_cmp(&b.0))?;
|
||||
(s.doc.model_body_component(body) != s.active_component).then(|| body.name.clone())
|
||||
.min_by(|a, b| a.0.total_cmp(&b.0))
|
||||
.map(|(_, b)| b)
|
||||
}
|
||||
|
||||
/// The points of a sketch a hole drills at when only the sketch is given.
|
||||
|
||||
@@ -27,7 +27,7 @@ mod appearance_chain;
|
||||
pub(super) mod appearance_gestures;
|
||||
|
||||
pub static COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec::new("inspect.colored_components", "Enable Component Colors", colored_components)
|
||||
CommandSpec::new("inspect.colored_components", "Component Colors", colored_components)
|
||||
.at("SOLID", "INSPECT").icon("colored_components").noundo()
|
||||
.params("enabled?: bool (omitted: toggle); temporary component colours, without changing appearances"),
|
||||
CommandSpec::new("inspect.measure", "Measure", measure)
|
||||
@@ -128,7 +128,30 @@ pub(crate) fn encloses_volume(body: &solidcraft_kernel::Body) -> bool {
|
||||
}
|
||||
|
||||
pub fn measure_json(b: &solidcraft_doc::ModelBody) -> Value {
|
||||
match b.measure() {
|
||||
measure_sheet_json(b, None)
|
||||
}
|
||||
|
||||
pub(super) fn measure_body(
|
||||
b: &solidcraft_doc::ModelBody,
|
||||
definitions: Option<&solidcraft_doc::ModelState>,
|
||||
) -> Result<solidcraft_kernel::BodyMeasure> {
|
||||
let mut measured = b.measure()?;
|
||||
if let Some(state) = definitions
|
||||
&& let Some(sheet) = state.sheets.iter().find(|sheet| sheet.body == b.definition_name() && !sheet.perforations.is_empty())
|
||||
{
|
||||
let definition = state.body(b.definition_name()).ok_or_else(|| EngineError::Other(format!("missing sheet body `{}`", sheet.body)))?;
|
||||
// A body transfer moves the geometry and sheet metadata together. Apply only
|
||||
// the placement relative to the current definition, so holes move once.
|
||||
let inverse = solidcraft_doc::mat_inverse(&definition.source_transform)
|
||||
.ok_or_else(|| EngineError::Other(format!("invalid sheet placement for `{}`", sheet.body)))?;
|
||||
let placement = solidcraft_doc::mat_mul(&b.source_transform, &inverse);
|
||||
sheet.correct_perforation_properties(&mut measured, &placement)?;
|
||||
}
|
||||
Ok(measured)
|
||||
}
|
||||
|
||||
fn measure_sheet_json(b: &solidcraft_doc::ModelBody, definitions: Option<&solidcraft_doc::ModelState>) -> Value {
|
||||
match measure_body(b, definitions) {
|
||||
Ok(m) => {
|
||||
let closed = encloses_volume(&b.body);
|
||||
json!({
|
||||
@@ -157,6 +180,7 @@ fn measure(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return super::measure_sel::measure_items(s, items);
|
||||
}
|
||||
let want = string_list(cmd, p, "bodies")?;
|
||||
let definitions = s.model.state();
|
||||
let st = s.world_state()?;
|
||||
let selected: Vec<_> = st.bodies.iter().filter(|b| want.is_empty() || want.contains(&b.name)).collect();
|
||||
if !want.is_empty() && selected.len() != want.len() {
|
||||
@@ -167,7 +191,7 @@ fn measure(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return Ok(json!({"body_count": bodies.len(), "bodies": bodies}));
|
||||
}
|
||||
// Each body is measured on its own: on all cores, in body order.
|
||||
let mut bodies: Vec<Value> = solidcraft_kernel::map_on_threads(&selected, 16, |b| measure_json(b))
|
||||
let mut bodies: Vec<Value> = solidcraft_kernel::map_on_threads(&selected, 16, |b| measure_sheet_json(b, Some(&definitions)))
|
||||
.into_iter()
|
||||
.zip(&selected)
|
||||
.map(|(m, b)| m.unwrap_or_else(|| json!({"name": b.name, "error": "measuring this body failed"})))
|
||||
@@ -182,35 +206,13 @@ fn measure(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
b["density_g_cm3"] = json!(rho);
|
||||
b["mass_g"] = json!(v * rho / 1000.0);
|
||||
}
|
||||
}
|
||||
// Sheet metal keeps the edges where bends meet flat faces (so bends stay visible): count its
|
||||
// B-rep faces as they are, without merging coplanar neighbours.
|
||||
let sheets = s.model.state().sheets.clone();
|
||||
for b in &mut bodies {
|
||||
if let Some(sh) = sheets.iter().find(|x| b["name"].as_str() == Some(x.body.as_str())) {
|
||||
let (df, de, dv) = sh.round_hole_correction();
|
||||
for (k, d) in [("faces", df), ("edges", de), ("vertices", dv)] {
|
||||
b[k] = json!(b["kernel"][k].as_i64().unwrap_or(0) + d);
|
||||
// Only Measure exposes sheet boundary counts; document.inspect keeps kernel counts.
|
||||
if let Some(sheet) = definitions.sheets.iter().find(|sheet| sheet.body == source) {
|
||||
let (df, de, dv) = sheet.round_hole_correction();
|
||||
for (key, delta) in [("faces", df), ("edges", de), ("vertices", dv)] {
|
||||
b[key] = json!(b["kernel"][key].as_i64().unwrap_or(0) + delta);
|
||||
}
|
||||
b["sheet_metal"] = json!(true);
|
||||
// A perforation field (#732) is not cut into the B-rep: take its open area out of the volume, the mass
|
||||
// and the area (both faces minus the holes, plus the bores).
|
||||
let open = sh.perforated_area();
|
||||
if open > 0.0 {
|
||||
if let Some(v) = b["volume_mm3"].as_f64() {
|
||||
let nv = v - open * sh.t;
|
||||
if let Some(m) = b["mass_g"].as_f64().filter(|_| v > 0.0) {
|
||||
b["mass_g"] = json!(m * nv / v);
|
||||
}
|
||||
b["volume_mm3"] = json!(nv);
|
||||
}
|
||||
let bores: f64 = sh
|
||||
.perforations
|
||||
.iter()
|
||||
.map(|p| sh.perforation_holes(p).map_or(0.0, |h| h.len() as f64) * std::f64::consts::PI * p.diameter * sh.t)
|
||||
.sum();
|
||||
b["area_mm2"] = json!(b["area_mm2"].as_f64().unwrap_or(0.0) - 2.0 * open + bores);
|
||||
}
|
||||
}
|
||||
}
|
||||
let skipped = bodies.iter().filter(|b| b["closed"] == false).count();
|
||||
@@ -395,9 +397,12 @@ fn inspect(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
let definitions = s.model.state();
|
||||
let with_measure = bool_(p, "measure").unwrap_or(false);
|
||||
// Each body is measured on its own: on all cores, in body order (as `inspect.measure`).
|
||||
let mut measured = if with_measure { solidcraft_kernel::map_on_threads(&st.bodies, 16, measure_json) } else { Vec::new() }.into_iter();
|
||||
let mut measured =
|
||||
if with_measure { solidcraft_kernel::map_on_threads(&st.bodies, 16, |b| measure_sheet_json(b, Some(&definitions))) } else { Vec::new() }
|
||||
.into_iter();
|
||||
let bodies: Vec<Value> = st
|
||||
.bodies
|
||||
.iter()
|
||||
|
||||
@@ -620,12 +620,13 @@ pub(crate) fn joint_id(s: &Session, v: Option<&Value>, cmd: &str) -> Result<u64>
|
||||
/// A joint value: numbers are degrees for angles and mm for distances; text is an expression.
|
||||
pub(crate) fn value(s: &Session, v: &Value, angle: bool, cmd: &str) -> Result<f64> {
|
||||
let kind = if angle { Kind::Angle } else { Kind::Length };
|
||||
// A number out of range says so, rather than that it is not a number (#9625).
|
||||
let e = match v {
|
||||
Value::Number(n) => n.as_f64().filter(|x| x.is_finite() && x.abs() < 1e9).map(|x| x.to_string()),
|
||||
Value::String(t) => Some(t.clone()),
|
||||
_ => None,
|
||||
}
|
||||
.ok_or_else(|| bad(cmd, "values must be numbers or expressions"))?;
|
||||
.ok_or_else(|| bad(cmd, format!("a joint value {}", crate::params::expr_problem(Some(v)))))?;
|
||||
s.doc.eval(&e, kind).map_err(|e| bad(cmd, e.to_string()))
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,27 @@ fn revolute_hinge_turns_about_the_knuckle() {
|
||||
assert!(near(place(&s, "LeafB", p), Vec3::new(20.0, 29.0, 37.0)));
|
||||
}
|
||||
|
||||
/// A joint value too large says so, rather than that it is not a number (#9625).
|
||||
#[test]
|
||||
fn a_joint_value_out_of_range_says_so() {
|
||||
let mut s = Session::default();
|
||||
leaf(&mut s, "LeafA");
|
||||
leaf(&mut s, "LeafB");
|
||||
let o = occ(&s, "LeafA");
|
||||
run(&mut s, "occurrence.ground", json!({"occurrence": o, "grounded": true}));
|
||||
let hinge = json!({"type": "revolute", "a": {"occurrence": "LeafA", "circle": [1, 37, 4]}, "b": {"occurrence": "LeafB", "circle": [1, 37, 4]}, "flip": true, "name": "Hinge"});
|
||||
run(&mut s, "joint.create", hinge);
|
||||
for value in [json!(1e9), json!(-5e15)] {
|
||||
let e = s.execute("joint.drive", &json!({"joint": "Hinge", "value": value})).err().map(|e| e.to_string()).unwrap_or_default();
|
||||
assert!(
|
||||
e.contains("a joint value must be a number between -1e9 and 1e9") && !e.contains("a joint value must be a number or"),
|
||||
"{value}: {e}"
|
||||
);
|
||||
}
|
||||
let e = s.execute("joint.drive", &json!({"joint": "Hinge", "value": true})).err().map(|e| e.to_string()).unwrap_or_default();
|
||||
assert!(e.contains("a joint value must be a number or an expression") && !e.contains("between"), "{e}");
|
||||
}
|
||||
|
||||
/// Two 10 mm cubes in components A (grounded) and B.
|
||||
fn two_cubes() -> Session {
|
||||
let mut s = Session::default();
|
||||
|
||||
@@ -242,9 +242,20 @@ pub fn assembly(doc: &Document, state: &ModelState) -> Result<AssemblyMassResult
|
||||
if !closed {
|
||||
return Ok(Shape { closed, volume: 0.0, centroid: Vec3::ZERO, gyration: None });
|
||||
}
|
||||
let m = solidcraft_kernel::measure_mass(&body.body)?;
|
||||
let gyration = solidcraft_io::mass_properties(&body.body)?.and_then(|p| p.gyration());
|
||||
Ok(Shape { closed, volume: m.volume, centroid: m.centroid, gyration })
|
||||
let sheet = state.sheets.iter().find(|sheet| sheet.body == body.definition_name() && !sheet.perforations.is_empty());
|
||||
let (volume, centroid) = if sheet.is_some() {
|
||||
let measured = super::inspect::measure_body(body, Some(state))?;
|
||||
(measured.volume, measured.centroid)
|
||||
} else {
|
||||
let measured = solidcraft_kernel::measure_mass(&body.body)?;
|
||||
(measured.volume, measured.centroid)
|
||||
};
|
||||
let mut moments = solidcraft_io::mass_properties(&body.body)?;
|
||||
if let (Some(sheet), Some(moments)) = (sheet, moments.as_mut()) {
|
||||
sheet.correct_perforation_mass_properties(moments, &IDENTITY)?;
|
||||
}
|
||||
let gyration = moments.and_then(|p| p.gyration());
|
||||
Ok(Shape { closed, volume, centroid, gyration })
|
||||
});
|
||||
let mut shape: BTreeMap<usize, Shape> = BTreeMap::new();
|
||||
for (i, s) in measured.into_iter().zip(shapes) {
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
//! What a face measures on the surface behind it (#9086).
|
||||
//!
|
||||
//! A curved face's area is the area of the surface it lies on: a cylinder's band is
|
||||
//! r·θ·h and a whole sphere 4πr². The display mesh's triangles run inside a curve, so
|
||||
//! their sum falls short of it.
|
||||
|
||||
use std::f64::consts::PI;
|
||||
|
||||
use solidcore_record::Vec3;
|
||||
use solidcore_record::brep::Curve;
|
||||
use solidcraft_geom::prelude::*;
|
||||
use solidcraft_geom::{Mesh, UnitVec3};
|
||||
use solidcraft_kernel::{Body, FaceSurface};
|
||||
|
||||
/// The area of the patch of faces `patch` of `body`, worked out on the surface behind
|
||||
/// them: a cylinder's band, or a sphere. `None` where the surface does not give one, and
|
||||
/// the caller keeps the measure of the mesh.
|
||||
pub(crate) fn patch_area(body: &Body, mesh: &Mesh, patch: &[usize]) -> Option<f64> {
|
||||
match solidcraft_kernel::face_surface(body, *patch.first()?)? {
|
||||
FaceSurface::Cylinder { origin, axis, radius } => cylinder_band(body, mesh, patch, origin, axis, radius),
|
||||
FaceSurface::Sphere { radius, .. } => sphere(body, patch, radius),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The edges on the border of the patch: the ones a face of the patch shares with a face
|
||||
/// outside it, and the ones it keeps to itself.
|
||||
fn border_edges(mesh: &Mesh, patch: &[usize]) -> Vec<usize> {
|
||||
mesh.edge_faces
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, faces)| {
|
||||
let inside = faces.iter().filter(|f| patch.contains(&(**f as usize))).count();
|
||||
inside > 0 && (faces.len() == 1 || inside < faces.len())
|
||||
})
|
||||
.map(|(edge, _)| edge)
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Whether edge `edge` is a straight line parallel to `axis`.
|
||||
fn straight_along(body: &Body, edge: usize, axis: UnitVec3) -> bool {
|
||||
let Some(e) = body.record().edges.get(edge) else { return false };
|
||||
if !matches!(e.curve, Curve::Line { .. }) {
|
||||
return false;
|
||||
}
|
||||
let Ok(c) = solidcraft_geom::brep::eval::CurveEval::new(e.parameters()) else { return false };
|
||||
let [t0, t1] = e.interval;
|
||||
let (Some(a), Some(b)) = (c.point(t0), c.point(t1)) else { return false };
|
||||
(b - a).normalized().is_some_and(|d| d.dot(axis.vec()).abs() >= 1.0 - 1e-9)
|
||||
}
|
||||
|
||||
/// The area of a cylindrical band: the radius of the surface, the turn the band covers
|
||||
/// and the distance between its two rims.
|
||||
fn cylinder_band(body: &Body, mesh: &Mesh, patch: &[usize], origin: Vec3, axis: UnitVec3, radius: f64) -> Option<f64> {
|
||||
if !(radius.is_finite() && radius > 0.0) {
|
||||
return None;
|
||||
}
|
||||
let tol = radius * 1e-6;
|
||||
// The whole patch lies on one cylinder.
|
||||
for f in patch {
|
||||
match solidcraft_kernel::face_surface(body, *f)? {
|
||||
FaceSurface::Cylinder { origin: o, axis: a, radius: r } => {
|
||||
if (r - radius).abs() > tol || o.dist(origin) > tol || a.vec().dot(axis.vec()).abs() < 1.0 - 1e-9 {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
// The rims of the band: the circles that bound it, each across the axis.
|
||||
let mut rims: Vec<(f64, f64)> = Vec::new();
|
||||
for edge in border_edges(mesh, patch) {
|
||||
// An edge that is not a circle but a straight line along the axis (a seam, a straight
|
||||
// cut along the band) leaves the turn of the band to its rims alone. Any other edge
|
||||
// (the saddle rim of a bore through the wall) cuts the band: not ours to measure.
|
||||
let Some(circle) = solidcraft_kernel::edge_circle(body, edge) else {
|
||||
if straight_along(body, edge, axis) {
|
||||
continue;
|
||||
}
|
||||
return None;
|
||||
};
|
||||
if circle.axis.vec().dot(axis.vec()).abs() < 1.0 - 1e-9 || (circle.radius - radius).abs() > tol {
|
||||
return None;
|
||||
}
|
||||
let d = circle.center - origin;
|
||||
let height = d.dot(axis.vec());
|
||||
if (d - axis.vec() * height).len() > tol {
|
||||
return None;
|
||||
}
|
||||
rims.push((height, circle.angle));
|
||||
}
|
||||
// The two rims: the band runs between them, and both cover the same turn.
|
||||
let mut levels: Vec<(f64, f64)> = Vec::new();
|
||||
for (height, angle) in rims {
|
||||
match levels.iter_mut().find(|(h, _)| (*h - height).abs() <= tol) {
|
||||
Some((_, a)) => *a += angle,
|
||||
None => levels.push((height, angle)),
|
||||
}
|
||||
}
|
||||
if levels.len() != 2 {
|
||||
return None;
|
||||
}
|
||||
levels.sort_by(|a, b| a.0.total_cmp(&b.0));
|
||||
let (low, low_turn) = levels[0];
|
||||
let (high, high_turn) = levels[1];
|
||||
let height = high - low;
|
||||
if !(height > 0.0) || (low_turn - high_turn).abs() > low_turn.max(high_turn) * 1e-6 {
|
||||
return None;
|
||||
}
|
||||
Some(radius * low_turn * height)
|
||||
}
|
||||
|
||||
/// The area of a sphere: 4πr², when the body is the whole of it.
|
||||
fn sphere(body: &Body, patch: &[usize], radius: f64) -> Option<f64> {
|
||||
if !(radius.is_finite() && radius > 0.0) {
|
||||
return None;
|
||||
}
|
||||
// The whole patch lies on one sphere.
|
||||
for f in patch {
|
||||
match solidcraft_kernel::face_surface(body, *f)? {
|
||||
FaceSurface::Sphere { radius: r, .. } if (r - radius).abs() <= radius * 1e-6 => {}
|
||||
_ => return None,
|
||||
}
|
||||
}
|
||||
// The body is the whole sphere: every face of it lies on that sphere and the patch
|
||||
// holds them all. A body with a face of its own (a sphere that was cut) is a piece of
|
||||
// the sphere, whose area this does not work out: the measure of the mesh stands in
|
||||
// for it.
|
||||
for f in 0..body.record().faces.len() {
|
||||
match solidcraft_kernel::face_surface(body, f)? {
|
||||
FaceSurface::Sphere { radius: r, .. } if (r - radius).abs() <= radius * 1e-6 => {}
|
||||
_ => return None,
|
||||
}
|
||||
if !patch.contains(&f) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(4.0 * PI * radius * radius)
|
||||
}
|
||||
@@ -350,7 +350,10 @@ fn describe(s: &Session, st: &solidcraft_doc::ModelState, sel: &Sel) -> Option<I
|
||||
let m = b.mesh();
|
||||
let patch = m.surface_patch(*index);
|
||||
let tris = patch.iter().flat_map(|f| face_tris(&m, *f)).collect::<Vec<_>>();
|
||||
let area: f64 = tris.iter().map(|[a, b, c]| (*b - *a).cross(*c - *a).len() * 0.5).sum();
|
||||
let on_mesh: f64 = tris.iter().map(|[a, b, c]| (*b - *a).cross(*c - *a).len() * 0.5).sum();
|
||||
// A curved face is measured on the surface it lies on, not on the triangles of
|
||||
// the display mesh, which run inside the curve.
|
||||
let area = super::measure_exact::patch_area(&b.body, &m, &patch).unwrap_or(on_mesh);
|
||||
let normals: Vec<UnitVec3> = tris.iter().filter_map(|[a, b, c]| (*b - *a).cross(*c - *a).unit()).collect();
|
||||
let planar = normals.first().copied().filter(|n0| normals.iter().all(|n| n.dot(*n0) > 1.0 - 1e-6));
|
||||
let mut json = json!({"type": "face", "area_mm2": area, "planar": planar.is_some()});
|
||||
@@ -380,7 +383,12 @@ fn describe(s: &Session, st: &solidcraft_doc::ModelState, sel: &Sel) -> Option<I
|
||||
let closed = crate::cmd::inspect::encloses_volume(&body.body);
|
||||
let m = body.mesh();
|
||||
let tris: Vec<[Vec3; 3]> = m.triangles.iter().filter_map(|t| m.tri(t)).collect();
|
||||
let v = m.measure().volume;
|
||||
let definitions = s.model.state();
|
||||
let v = if definitions.sheets.iter().any(|sheet| sheet.body == body.definition_name() && !sheet.perforations.is_empty()) {
|
||||
super::inspect::measure_body(body, Some(&definitions)).ok()?.volume
|
||||
} else {
|
||||
m.measure().volume
|
||||
};
|
||||
plain(Geo::Tris(tris), None, json!({"type": "body", "name": name, "closed": closed, "volume_mm3": closed.then_some(v)}))
|
||||
}
|
||||
Sel::SketchCurve { id, sketch } => sketch_curve(sketch_of(s, st, *sketch, |sk| sk.curve_index(id).is_some())?, id),
|
||||
|
||||
@@ -74,6 +74,7 @@ mod libraries;
|
||||
pub mod mass_properties;
|
||||
mod material_properties;
|
||||
mod materials;
|
||||
mod measure_exact;
|
||||
mod measure_sel;
|
||||
mod measure_shape;
|
||||
mod mesh;
|
||||
@@ -261,16 +262,12 @@ impl CommandSpec {
|
||||
}
|
||||
pub fn info(&self, s: &Session) -> CommandInfo {
|
||||
let e = (self.enabled)(s);
|
||||
let (label, icon) = match self.id {
|
||||
"inspect.colored_components" if s.colored_components.is_some() => ("Disable Component Colors", "colored_components_off"),
|
||||
_ => (self.label, self.icon),
|
||||
};
|
||||
CommandInfo {
|
||||
id: self.id,
|
||||
label,
|
||||
label: self.label,
|
||||
tab: self.tab,
|
||||
panel: self.panel,
|
||||
icon,
|
||||
icon: self.icon,
|
||||
shortcut: self.shortcut,
|
||||
params: self.params,
|
||||
enabled: e.is_ok(),
|
||||
|
||||
@@ -12,9 +12,21 @@ use solidcore_record::Vec3;
|
||||
|
||||
use super::CommandSpec;
|
||||
use crate::params::{bad, num, str_};
|
||||
use crate::schema::parameter_sweep::{
|
||||
FeatureFailed, FeatureWarned, JointFlipped, JointLost, JointSide, MAX_VALUES, ParameterSweep, ParameterSweepParams, SketchFailed, SketchFlipped,
|
||||
SweepChanges, SweepResult, SweepSummary,
|
||||
};
|
||||
use crate::schema::{TypedContract, output_schema_for};
|
||||
use crate::{Result, Session};
|
||||
|
||||
pub static COMMANDS: &[CommandSpec] = &[CommandSpec::new("inspect.parameter_sweep", "Parameter Sweep", sweep).icon("params").noundo().params(
|
||||
const CONTRACT: TypedContract<ParameterSweepParams> = TypedContract::new();
|
||||
|
||||
pub static COMMANDS: &[CommandSpec] = &[CommandSpec::new("inspect.parameter_sweep", "Parameter Sweep", crate::checked!("inspect.parameter_sweep", sweep))
|
||||
.icon("params")
|
||||
.noundo()
|
||||
.contract(&CONTRACT)
|
||||
.output(output_schema_for::<ParameterSweep>)
|
||||
.params(
|
||||
"parameter: name; values: [number | expression] (at most 200) | from, to: numbers, steps? (default 10, at most 199: steps + 1 values) → \
|
||||
for each value, in a copy of the design (the design itself is not changed): {value, ms (the rebuild), ok, failed: [{feature, name, error}], warned: [{feature, name, warning}] \
|
||||
(features that build at the current value and fail or warn at this one), joints_lost: [{joint, name, origin?: a|b, why}], joints_flipped: [{joint, name, origin: a|b, degrees}] \
|
||||
@@ -24,9 +36,6 @@ pub static COMMANDS: &[CommandSpec] = &[CommandSpec::new("inspect.parameter_swee
|
||||
summary: {values, ok, slowest_ms, failed, joints_lost, joints_flipped, sketches_flipped, sketches_failed} (how many values show each)",
|
||||
)];
|
||||
|
||||
/// Values swept by one command, at most.
|
||||
const MAX_VALUES: usize = 200;
|
||||
|
||||
/// A frame's origin and z axis, in its occurrence's coordinates.
|
||||
type Frame = (Vec3, Vec3);
|
||||
|
||||
@@ -85,29 +94,29 @@ fn degrees(a: Vec3, b: Vec3) -> Option<f64> {
|
||||
}
|
||||
|
||||
/// What changed from `base` (the design as it is) to `at` (at one value).
|
||||
fn compare(base: &Look, at: &Look) -> Value {
|
||||
let failed: Vec<Value> = at
|
||||
fn compare(base: &Look, at: &Look) -> SweepChanges {
|
||||
let failed = at
|
||||
.errors
|
||||
.iter()
|
||||
.filter(|(id, _)| !base.errors.contains_key(id))
|
||||
.map(|(id, (name, e))| json!({"feature": id, "name": name, "error": e}))
|
||||
.map(|(id, (name, e))| FeatureFailed { feature: *id, name: name.clone(), error: e.clone() })
|
||||
.collect();
|
||||
let warned: Vec<Value> = at
|
||||
let warned = at
|
||||
.warnings
|
||||
.iter()
|
||||
.filter(|(id, (_, w))| base.warnings.get(id).is_none_or(|(_, b)| b != w) && !at.errors.contains_key(id))
|
||||
.map(|(id, (name, w))| json!({"feature": id, "name": name, "warning": w}))
|
||||
.map(|(id, (name, w))| FeatureWarned { feature: *id, name: name.clone(), warning: w.clone() })
|
||||
.collect();
|
||||
let mut lost = Vec::new();
|
||||
let mut flipped = Vec::new();
|
||||
let mut joints_lost = Vec::new();
|
||||
let mut joints_flipped = Vec::new();
|
||||
for (id, (name, a, b)) in &at.joints {
|
||||
let Some((_, a0, b0)) = base.joints.get(id) else { continue };
|
||||
for (side, now, was) in [("a", a, a0), ("b", b, b0)] {
|
||||
for (side, now, was) in [(JointSide::A, a, a0), (JointSide::B, b, b0)] {
|
||||
match (now, was) {
|
||||
(Err(why), Ok(_)) => lost.push(json!({"joint": id, "name": name, "origin": side, "why": why})),
|
||||
(Err(why), Ok(_)) => joints_lost.push(JointLost { joint: *id, name: name.clone(), origin: Some(side), why: why.clone() }),
|
||||
(Ok(f), Ok(f0)) => {
|
||||
if let Some(d) = degrees(f.1, f0.1).filter(|d| *d > 90.0) {
|
||||
flipped.push(json!({"joint": id, "name": name, "origin": side, "degrees": (d * 10.0).round() / 10.0}));
|
||||
joints_flipped.push(JointFlipped { joint: *id, name: name.clone(), origin: side, degrees: (d * 10.0).round() / 10.0 });
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@@ -117,7 +126,7 @@ fn compare(base: &Look, at: &Look) -> Value {
|
||||
&& a.is_ok()
|
||||
&& b.is_ok()
|
||||
{
|
||||
lost.push(json!({"joint": id, "name": name, "why": why}));
|
||||
joints_lost.push(JointLost { joint: *id, name: name.clone(), origin: None, why: why.clone() });
|
||||
}
|
||||
}
|
||||
let mut sketches_flipped = Vec::new();
|
||||
@@ -125,15 +134,13 @@ fn compare(base: &Look, at: &Look) -> Value {
|
||||
for (id, (name, n, failing, folded)) in &at.sketches {
|
||||
let Some((_, n0, failing0, folded0)) = base.sketches.get(id) else { continue };
|
||||
if let Some(d) = degrees(*n, *n0).filter(|d| *d > 90.0) {
|
||||
sketches_flipped.push(json!({"sketch": id, "name": name, "degrees": (d * 10.0).round() / 10.0}));
|
||||
sketches_flipped.push(SketchFlipped { sketch: *id, name: name.clone(), degrees: (d * 10.0).round() / 10.0 });
|
||||
}
|
||||
if (!failing.is_empty() && failing0.is_empty()) || (!folded.is_empty() && folded0.is_empty()) {
|
||||
sketches_failed.push(json!({"sketch": id, "name": name, "failing": failing, "folded": folded}));
|
||||
sketches_failed.push(SketchFailed { sketch: *id, name: name.clone(), failing: failing.clone(), folded: folded.clone() });
|
||||
}
|
||||
}
|
||||
let ok = failed.is_empty() && lost.is_empty() && flipped.is_empty() && sketches_flipped.is_empty() && sketches_failed.is_empty();
|
||||
json!({"ok": ok, "failed": failed, "warned": warned, "joints_lost": lost, "joints_flipped": flipped,
|
||||
"sketches_flipped": sketches_flipped, "sketches_failed": sketches_failed})
|
||||
SweepChanges { failed, warned, joints_lost, joints_flipped, sketches_flipped, sketches_failed }
|
||||
}
|
||||
|
||||
/// The values to sweep.
|
||||
@@ -175,37 +182,36 @@ fn sweep(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let values = values(p, cmd)?;
|
||||
let base = look(s);
|
||||
let mut results = Vec::new();
|
||||
let mut count: BTreeMap<&str, usize> = BTreeMap::new();
|
||||
let mut slowest: f64 = 0.0;
|
||||
for v in values {
|
||||
let mut summary =
|
||||
SweepSummary { values: 0, ok: 0, slowest_ms: 0.0, failed: 0, joints_lost: 0, joints_flipped: 0, sketches_flipped: 0, sketches_failed: 0 };
|
||||
for value in values {
|
||||
let mut x = s.scratch();
|
||||
let t0 = std::time::Instant::now();
|
||||
let changed = x.execute("parameters.change", &json!({"name": name, "expression": v}));
|
||||
let changed = x.execute("parameters.change", &json!({"name": name, "expression": value}));
|
||||
let ms = (t0.elapsed().as_secs_f64() * 1e4).round() / 10.0;
|
||||
slowest = slowest.max(ms);
|
||||
let mut r = match changed {
|
||||
Ok(_) => compare(&base, &look(&x)),
|
||||
Err(e) => json!({"ok": false, "error": e.to_string()}),
|
||||
};
|
||||
for key in ["failed", "joints_lost", "joints_flipped", "sketches_flipped", "sketches_failed"] {
|
||||
if r[key].as_array().is_some_and(|a| !a.is_empty()) {
|
||||
*count.entry(key).or_default() += 1;
|
||||
summary.slowest_ms = summary.slowest_ms.max(ms);
|
||||
let r = match changed {
|
||||
Ok(_) => {
|
||||
let c = compare(&base, &look(&x));
|
||||
summary.failed += usize::from(!c.failed.is_empty());
|
||||
summary.joints_lost += usize::from(!c.joints_lost.is_empty());
|
||||
summary.joints_flipped += usize::from(!c.joints_flipped.is_empty());
|
||||
summary.sketches_flipped += usize::from(!c.sketches_flipped.is_empty());
|
||||
summary.sketches_failed += usize::from(!c.sketches_failed.is_empty());
|
||||
let ok = c.failed.is_empty()
|
||||
&& c.joints_lost.is_empty()
|
||||
&& c.joints_flipped.is_empty()
|
||||
&& c.sketches_flipped.is_empty()
|
||||
&& c.sketches_failed.is_empty();
|
||||
SweepResult { value, ms, ok, error: None, changes: Some(c) }
|
||||
}
|
||||
}
|
||||
if r["ok"] == json!(true) {
|
||||
*count.entry("ok").or_default() += 1;
|
||||
}
|
||||
r["value"] = v;
|
||||
r["ms"] = json!(ms);
|
||||
Err(e) => SweepResult { value, ms, ok: false, error: Some(e.to_string()), changes: None },
|
||||
};
|
||||
summary.ok += usize::from(r.ok);
|
||||
results.push(r);
|
||||
}
|
||||
let get = |k: &str| count.get(k).copied().unwrap_or(0);
|
||||
Ok(json!({
|
||||
"parameter": name,
|
||||
"results": results,
|
||||
"summary": {"values": results.len(), "ok": get("ok"), "slowest_ms": slowest, "failed": get("failed"), "joints_lost": get("joints_lost"),
|
||||
"joints_flipped": get("joints_flipped"), "sketches_flipped": get("sketches_flipped"), "sketches_failed": get("sketches_failed")},
|
||||
}))
|
||||
summary.values = results.len();
|
||||
serde_json::to_value(ParameterSweep { parameter: name, results, summary, param_warnings: Vec::new() }).map_err(|e| bad(cmd, e.to_string()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -15,27 +15,43 @@ use solidcraft_geom::prelude::*;
|
||||
|
||||
use super::CommandSpec;
|
||||
use crate::params::{bad, num, str_, vec3};
|
||||
use crate::schema::parts::{InsertedPart, PartFamily, PartsInsertParams, PartsLibrary, PartsLibraryParams, PartsResizeParams, ResizedPart};
|
||||
use crate::schema::{TypedContract, output_schema_for};
|
||||
use crate::{EngineError, Result, Session};
|
||||
|
||||
const LIBRARY_CONTRACT: TypedContract<PartsLibraryParams> = TypedContract::new();
|
||||
const INSERT_CONTRACT: TypedContract<PartsInsertParams> = TypedContract::new();
|
||||
const RESIZE_CONTRACT: TypedContract<PartsResizeParams> = TypedContract::new();
|
||||
|
||||
pub static COMMANDS: &[CommandSpec] = &[
|
||||
CommandSpec::new("parts.library", "Standard Parts", library)
|
||||
CommandSpec::new("parts.library", "Standard Parts", crate::checked!("parts.library", library))
|
||||
.icon("library")
|
||||
.noundo()
|
||||
.contract(&LIBRARY_CONTRACT)
|
||||
.output(output_schema_for::<PartsLibrary>)
|
||||
.params("family? → families (name, standard, system: metric|inch, sizes, lengths) and, with family, each size's dimensions (mm)"),
|
||||
CommandSpec::new("parts.fastener", "Insert Fastener", insert_atomic)
|
||||
CommandSpec::new("parts.fastener", "Insert Fastener", crate::checked!("parts.fastener", insert_atomic))
|
||||
.at("SOLID", "INSERT")
|
||||
.icon("fastener")
|
||||
.contract(&INSERT_CONTRACT)
|
||||
.output(output_schema_for::<InsertedPart>)
|
||||
.params("the Insert Part dialog's command (same as parts.insert): family, size, length?, at?|point?+direction?, name?"),
|
||||
CommandSpec::new("parts.insert", "Insert Part", insert_atomic).icon("fastener").params(
|
||||
"family (socket_head_cap_screw | button_head_cap_screw | hex_bolt | hex_nut | washer | set_screw | dowel_pin | bearing | \
|
||||
CommandSpec::new("parts.insert", "Insert Part", crate::checked!("parts.insert", insert_atomic))
|
||||
.icon("fastener")
|
||||
.contract(&INSERT_CONTRACT)
|
||||
.output(output_schema_for::<InsertedPart>)
|
||||
.params(
|
||||
"family (socket_head_cap_screw | button_head_cap_screw | hex_bolt | hex_nut | washer | set_screw | dowel_pin | bearing | \
|
||||
hex_cap_screw_inch | hex_nut_inch | washer_sae | washer_uss); size (\"M6\", \"608\" for bearings, \"1/2-13 UNC\" for inch screws and nuts, \
|
||||
\"1/2\" for inch washers); length? (mm, inch parts too; screws, bolts, set screws, pins; default a standard length near 2.5 d); \
|
||||
at?: [x,y,z] on a hole's rim or wall (the part seats on the hole's face with a rigid joint), or a list of them (one component, \
|
||||
placed and seated once per hole) | point?: [x,y,z] with direction?: [x,y,z] (no joint); name? → component, occurrence, joint?, \
|
||||
and with at: occurrences, joints (one per hole, in pick order)",
|
||||
),
|
||||
CommandSpec::new("parts.resize", "Change Part Size", resize_atomic)
|
||||
),
|
||||
CommandSpec::new("parts.resize", "Change Part Size", crate::checked!("parts.resize", resize_atomic))
|
||||
.icon("scale")
|
||||
.contract(&RESIZE_CONTRACT)
|
||||
.output(output_schema_for::<ResizedPart>)
|
||||
.params("component: id|name of an inserted part; size?; length? — rebuilds it (joints keep it seated)"),
|
||||
];
|
||||
|
||||
@@ -572,7 +588,7 @@ fn build(s: &mut Session, sh: &Shape) -> Result<()> {
|
||||
}
|
||||
|
||||
fn library(_s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let fam = |id: &str| -> Value {
|
||||
let fam = |id: &str| -> PartFamily {
|
||||
let mut sizes: Vec<Value> = match id {
|
||||
"socket_head_cap_screw" => SHCS.iter().map(|r| json!({"size": r.0, "d": metric(r.0).map(|m| m.0), "pitch": metric(r.0).map(|m| m.1), "head_diameter": r.1, "head_height": r.2, "socket": r.3, "socket_depth": r.4})).collect(),
|
||||
"button_head_cap_screw" => BHCS.iter().map(|r| json!({"size": r.0, "d": metric(r.0).map(|m| m.0), "pitch": metric(r.0).map(|m| m.1), "head_diameter": r.1, "head_height": r.2, "socket": r.3, "socket_depth": r.4})).collect(),
|
||||
@@ -612,15 +628,24 @@ fn library(_s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
}
|
||||
let system = if is_inch(id) { "inch" } else { "metric" };
|
||||
json!({"family": id, "name": name, "standard": standard, "system": system, "sizes": sizes, "lengths": lengths})
|
||||
PartFamily { family: id.into(), name: name.into(), standard: standard.into(), system: system.into(), sizes, lengths }
|
||||
};
|
||||
match str_(p, "family") {
|
||||
Some(f) if FAMILIES.iter().any(|x| x.0 == f) => Ok(fam(f)),
|
||||
Some(f) if FAMILIES.iter().any(|x| x.0 == f) => {
|
||||
reply("parts.library", PartsLibrary { families: None, family: Some(fam(f)), param_warnings: Vec::new() })
|
||||
}
|
||||
Some(f) => Err(bad("parts.library", format!("unknown part family `{f}`"))),
|
||||
None => Ok(json!({"families": FAMILIES.iter().map(|f| fam(f.0)).collect::<Vec<_>>()})),
|
||||
None => reply(
|
||||
"parts.library",
|
||||
PartsLibrary { families: Some(FAMILIES.iter().map(|f| fam(f.0)).collect()), family: None, param_warnings: Vec::new() },
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn reply(cmd: &str, reply: impl serde::Serialize) -> Result<Value> {
|
||||
serde_json::to_value(reply).map_err(|e| bad(cmd, e.to_string()))
|
||||
}
|
||||
|
||||
fn part_name(family: &str, size: &str, sh: &Shape) -> String {
|
||||
match sh {
|
||||
Shape::Screw { len, .. } | Shape::Rod { len, .. } => format!("{} {}", label(family), size_with_length(family, size, *len)),
|
||||
@@ -747,14 +772,26 @@ fn insert(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
s.doc_mut().parts.insert(comp, solidcraft_doc::StandardPart { family: family.clone(), size: size.clone(), length: shape_len(&sh) });
|
||||
set_identity(s, comp, identity(&family, &size, &sh), None);
|
||||
run(s, "component.activate", json!({"component": active}))?;
|
||||
let mut out = json!({"component": comp, "occurrence": occ, "name": name});
|
||||
let mut out = InsertedPart {
|
||||
component: comp,
|
||||
occurrence: occ,
|
||||
name: name.clone(),
|
||||
joint: None,
|
||||
occurrences: None,
|
||||
joints: None,
|
||||
param_warnings: Vec::new(),
|
||||
};
|
||||
if !holes.is_empty() {
|
||||
// The first hole has the placement the component came with; each further hole places the
|
||||
// same part again. All are made before any is seated, while each is still at the part's
|
||||
// own origin, where the joint below takes the part's seating point to be.
|
||||
let mut occurrences = vec![json!(occ)];
|
||||
let mut occurrences = vec![occ];
|
||||
for _ in 1..holes.len() {
|
||||
occurrences.push(run(s, "occurrence.copy", json!({"component": comp}))?["occurrence"].clone());
|
||||
occurrences.push(
|
||||
run(s, "occurrence.copy", json!({"component": comp}))?["occurrence"]
|
||||
.as_u64()
|
||||
.ok_or_else(|| bad(cmd, "the copy has no occurrence"))?,
|
||||
);
|
||||
}
|
||||
let mut joints = Vec::new();
|
||||
for (i, ((a, h), o)) in holes.into_iter().zip(&occurrences).enumerate() {
|
||||
@@ -766,11 +803,11 @@ fn insert(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"joint.create",
|
||||
json!({"type": "rigid", "a": {"occurrence": h, "circle": a}, "b": {"occurrence": o, "point": [0, 0, 0], "z": [0, 0, -1]}, "name": seat}),
|
||||
)?;
|
||||
joints.push(j["joint"].clone());
|
||||
joints.push(j["joint"].as_u64().ok_or_else(|| bad(cmd, "the joint has no id"))?);
|
||||
}
|
||||
out["joint"] = joints.first().cloned().unwrap_or(Value::Null);
|
||||
out["occurrences"] = Value::Array(occurrences);
|
||||
out["joints"] = Value::Array(joints);
|
||||
out.joint = joints.first().copied();
|
||||
out.occurrences = Some(occurrences);
|
||||
out.joints = Some(joints);
|
||||
} else if let Some(pt) = p.get("point").and_then(vec3) {
|
||||
// Placed at a point, its +z along `direction`.
|
||||
let dir = p.get("direction").and_then(vec3).and_then(|d| d.normalized()).unwrap_or(Vec3::Z);
|
||||
@@ -789,7 +826,7 @@ fn insert(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
o.transform = m;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
reply(cmd, out)
|
||||
}
|
||||
|
||||
/// The most holes one insert seats a part in.
|
||||
@@ -887,7 +924,7 @@ fn resize(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if let Some(e) = s.model.results.iter().find_map(|r| r.error.clone()) {
|
||||
return Err(EngineError::Other(e));
|
||||
}
|
||||
Ok(json!({"component": comp, "name": name, "size": size, "length": shape_len(&sh)}))
|
||||
reply(cmd, ResizedPart { component: comp, name, size, length: shape_len(&sh), param_warnings: Vec::new() })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -81,13 +81,21 @@ CommandSpec::new("render.preset.apply", "Apply Native Studio", studio_presets::a
|
||||
.params("Same reviewed input as render.preset.resolve, expected_revision required, replace_lighting_and_environment:true and replace_stage:true when an existing stage would change. Re-resolves the complete candidate and publishes one undo or no mutation; camera, optical bindings, geometry and engineering materials are preserved."),
|
||||
CommandSpec::new("render.quality.prepare", "Review Fixed Sampling Budget", studio_presets::quality).icon("settings").noundo().doc_only()
|
||||
.params("id: Q-*; variant:fixed_samples_png; acknowledge_omissions:true. Read-only bounded GPU still-budget projection, not full adaptive/convergence/linear-master quality acceptance. Returns dimensions/samples/depth/seed/denoise and explicit omissions. Never switches executor or mutates a shot."),
|
||||
CommandSpec::new("render.shot.duplicate", "Duplicate Render Shot", shots::duplicate).icon("copy").doc_only()
|
||||
CommandSpec::new("render.shot.duplicate", "Duplicate Render Shot", crate::checked!("render.shot.duplicate", shots::duplicate)).icon("copy").doc_only()
|
||||
.contract(&shots::CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_shots::ShotChange>)
|
||||
.params("name, new_name, expected_revision:u64. Copies exact saved setup and resource references in one undo. Existing destinations refuse; captured jobs and camera navigation are unchanged."),
|
||||
CommandSpec::new("render.shot.rename", "Rename Render Shot", shots::rename).icon("settings").doc_only()
|
||||
CommandSpec::new("render.shot.rename", "Rename Render Shot", crate::checked!("render.shot.rename", shots::rename)).icon("settings").doc_only()
|
||||
.contract(&shots::CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_shots::ShotChange>)
|
||||
.params("name, new_name, expected_revision:u64. Renames exact saved setup in one undo; an existing destination or stale review refuses."),
|
||||
CommandSpec::new("render.shot.remove", "Remove Render Shot", shots::remove).icon("delete").doc_only()
|
||||
CommandSpec::new("render.shot.remove", "Remove Render Shot", crate::checked!("render.shot.remove", shots::remove)).icon("delete").doc_only()
|
||||
.contract(&shots::CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_shots::ShotChange>)
|
||||
.params("name, expected_revision:u64. Removes only that saved setup in one undo; retains resources, geometry and captured results."),
|
||||
CommandSpec::new("render.library.preview", "Inspect Original Surface Map", library::preview).icon("appearance").noundo().doc_only()
|
||||
CommandSpec::new("render.library.preview", "Inspect Original Surface Map", crate::checked!("render.library.preview", library::preview)).icon("appearance").noundo().doc_only()
|
||||
.contract(&library::PREVIEW_CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_library::LibraryPreview>)
|
||||
.params("id: SURF-*. Returns bounded hash-verified original base-color PNG bytes and source-map fidelity label, not a rendered material thumbnail. No external paths, rendering or document edits."),
|
||||
CommandSpec::new("render.library.physical.prepare", "Prepare Physical Reference", physical_library::prepare).icon("inspect").noundo().doc_only()
|
||||
.params("id: named built-in physical profile, name: proposed new material label, acknowledge_reference:true. Read-only loss-aware creation plan using native ValidatedCard admission and one point density; returns source receipts, extended fields and omissions. Does not execute material.create, assign bodies or infer effective-part physics."),
|
||||
@@ -109,11 +117,17 @@ CommandSpec::new("render.library.surface.unbind", "Remove Surface Binding", surf
|
||||
.params("name: setup, target: saved definition/feature/component/occurrence_path, set?: setup patch. Removes only that explicit binding in one undo; no device or current geometry required."),
|
||||
CommandSpec::new("render.result.pin", "Retain Displayed Render Result", jobs::pin).icon("inspect").noundo().doc_only()
|
||||
.params("job?: completed JobId (default selected result), or null to clear selection. Selects within the eight retained completed results; oldest is evicted first. Preserves exact export bytes and original host memory accounting. No design/undo change; preview or foreign jobs refuse."),
|
||||
CommandSpec::new("render.library.targets", "Find Render Library Targets", library::targets).icon("list").noundo()
|
||||
CommandSpec::new("render.library.targets", "Find Render Library Targets", crate::checked!("render.library.targets", library::targets)).icon("list").noundo()
|
||||
.contract(&library::TARGETS_CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_library::LibraryTargets>)
|
||||
.params("query?: exact-name substring; offset?:0; limit?:128 (1..128). Returns a bounded page of captured body ordinals/names, revision and scene bounds. Settles the model through ordinary command handling; never returns a large mesh payload."),
|
||||
CommandSpec::new("render.library.list", "Browse Render Library", library::list).icon("list").noundo().doc_only()
|
||||
CommandSpec::new("render.library.list", "Browse Render Library", crate::checked!("render.library.list", library::list)).icon("list").noundo().doc_only()
|
||||
.contract(&library::LIST_CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_library::LibraryPage>)
|
||||
.params("kind?: surfaces, selene_appearances, hdr, rigs, scenes, materials, lighting, environments, quality, native_scenes, selene_shots or capabilities; query?: bounded search; availability?: all/usable/specification/blocked; offset?:0; limit?:48 (1..128). Returns source status and explicit implemented projections separately. No device, file IO or design change."),
|
||||
CommandSpec::new("render.library.describe", "Inspect Render Library Resource", library::describe).icon("inspect").noundo().doc_only()
|
||||
CommandSpec::new("render.library.describe", "Inspect Render Library Resource", crate::checked!("render.library.describe", library::describe)).icon("inspect").noundo().doc_only()
|
||||
.contract(&library::DESCRIBE_CONTRACT)
|
||||
.output(crate::schema::output_schema_for::<crate::schema::render_library::LibraryDescription>)
|
||||
.params("kind, id: exact authored resource. Returns original specification, runtime projection variants and explicit omissions. A concept is not an executable preset."),
|
||||
CommandSpec::new("render.library.appearance.apply", "Apply Library Opaque Appearance", library::apply_appearance).icon("appearance")
|
||||
.params("id: SURF-* or SELENE-AP-*; variant: uniform_opaque (required); bodies: 1..256 exact body names. Applies the original scalar baseline through ordinary appearance assignment in one undo, preserving physical properties. Spatial maps and advanced target effects are explicitly excluded."),
|
||||
|
||||
@@ -16,8 +16,22 @@ use solidcraft_render::{
|
||||
texture_input::MapRole,
|
||||
};
|
||||
|
||||
use crate::schema::TypedContract;
|
||||
use crate::schema::render_library::{
|
||||
LibraryDescribeParams, LibraryListParams, LibraryPage, LibraryPreview, LibraryPreviewParams, LibraryResource, LibraryTargets,
|
||||
LibraryTargetsParams, Pbr, RenderTarget, ResourceSummary, SceneBounds,
|
||||
};
|
||||
use crate::{Result, Session, params::bad};
|
||||
|
||||
pub(super) const LIST_CONTRACT: TypedContract<LibraryListParams> = TypedContract::new();
|
||||
pub(super) const DESCRIBE_CONTRACT: TypedContract<LibraryDescribeParams> = TypedContract::new();
|
||||
pub(super) const TARGETS_CONTRACT: TypedContract<LibraryTargetsParams> = TypedContract::new();
|
||||
pub(super) const PREVIEW_CONTRACT: TypedContract<LibraryPreviewParams> = TypedContract::new();
|
||||
|
||||
fn reply(command: &str, reply: impl serde::Serialize) -> Result<Value> {
|
||||
serde_json::to_value(reply).map_err(|e| bad(command, e.to_string()))
|
||||
}
|
||||
|
||||
const KINDS: &[&str] = &[
|
||||
"materials",
|
||||
"lighting",
|
||||
@@ -162,28 +176,47 @@ pub(super) fn list(_s: &mut Session, params: &Value) -> Result<Value> {
|
||||
};
|
||||
let values = catalog(&input.kind, command)?;
|
||||
let count = values.iter().filter(matches).count();
|
||||
let items: Vec<_> = values.iter().filter(matches).skip(input.offset).take(input.limit).map(|v| {
|
||||
json!({"id":v["id"],"name":v["name"],"domains":v["domains"],"family":v["family"],"source_status":v.get("status").or_else(|| v.get("state")),"projection":projection(&input.kind,v)})
|
||||
}).collect();
|
||||
let items = values
|
||||
.iter()
|
||||
.filter(matches)
|
||||
.skip(input.offset)
|
||||
.take(input.limit)
|
||||
.map(|v| {
|
||||
let listed = Listed::deserialize(v).map_err(|e| bad(command, format!("built-in catalog {}: {e}", input.kind)))?;
|
||||
Ok(ResourceSummary {
|
||||
id: listed.id,
|
||||
name: listed.name,
|
||||
domains: listed.domains,
|
||||
family: listed.family,
|
||||
source_status: listed.status.or(listed.state),
|
||||
projection: projection(&input.kind, v),
|
||||
})
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
let end = input.offset.saturating_add(items.len());
|
||||
Ok(json!({"kind":input.kind,"total":count,"offset":input.offset,"next_offset":(end < count).then_some(end),"items":items}))
|
||||
let next_offset = (end < count).then_some(end);
|
||||
reply(command, LibraryPage { kind: input.kind, total: count, offset: input.offset, next_offset, items, param_warnings: Vec::new() })
|
||||
}
|
||||
|
||||
/// The fields of a catalog's resource a page lists. Every catalog gives an id and a name; the
|
||||
/// source's status is `status`, or a rig's `state`.
|
||||
#[derive(Deserialize)]
|
||||
#[serde(default, deny_unknown_fields)]
|
||||
struct TargetQuery {
|
||||
query: String,
|
||||
offset: usize,
|
||||
limit: usize,
|
||||
}
|
||||
impl Default for TargetQuery {
|
||||
fn default() -> Self {
|
||||
Self { query: String::new(), offset: 0, limit: 128 }
|
||||
}
|
||||
struct Listed {
|
||||
id: String,
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
domains: Option<Vec<String>>,
|
||||
#[serde(default)]
|
||||
family: Option<String>,
|
||||
#[serde(default)]
|
||||
status: Option<String>,
|
||||
#[serde(default)]
|
||||
state: Option<String>,
|
||||
}
|
||||
|
||||
pub(super) fn targets(s: &mut Session, params: &Value) -> Result<Value> {
|
||||
let command = "render.library.targets";
|
||||
let input: TargetQuery = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
let input: LibraryTargetsParams = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
if input.query.len() > 256
|
||||
|| input.query.chars().any(char::is_control)
|
||||
|| input.limit == 0
|
||||
@@ -202,49 +235,70 @@ pub(super) fn targets(s: &mut Session, params: &Value) -> Result<Value> {
|
||||
.filter(|(_, body)| body.name.to_lowercase().contains(&query))
|
||||
.skip(input.offset)
|
||||
.take(input.limit)
|
||||
.map(|(ordinal, body)| {
|
||||
json!({"ordinal":ordinal,"name":body.name,"color":body.color,"opacity":body.opacity,
|
||||
"pbr":body.surface.map(|v|json!({"metallic":v.metallic(),"roughness":v.roughness(),"dielectric_ior":v.dielectric_ior()}))})
|
||||
.map(|(ordinal, body)| RenderTarget {
|
||||
ordinal,
|
||||
name: body.name.clone(),
|
||||
color: body.color,
|
||||
opacity: body.opacity,
|
||||
pbr: body.surface.map(|v| Pbr { metallic: v.metallic(), roughness: v.roughness(), dielectric_ior: v.dielectric_ior() }),
|
||||
})
|
||||
.collect();
|
||||
let end = input.offset.saturating_add(items.len());
|
||||
Ok(json!({"items":items,"total":count,"offset":input.offset,"next_offset":(end<count).then_some(end),"revision":s.revision,
|
||||
"bounds":if scene.bounds.is_empty(){Value::Null}else{json!({"min":scene.bounds.min,"max":scene.bounds.max})}}))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Identify {
|
||||
kind: String,
|
||||
id: String,
|
||||
let bounds = (!scene.bounds.is_empty()).then(|| SceneBounds { min: scene.bounds.min.into(), max: scene.bounds.max.into() });
|
||||
reply(
|
||||
command,
|
||||
LibraryTargets {
|
||||
items,
|
||||
total: count,
|
||||
offset: input.offset,
|
||||
next_offset: (end < count).then_some(end),
|
||||
revision: s.revision,
|
||||
bounds,
|
||||
param_warnings: Vec::new(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn describe(_s: &mut Session, params: &Value) -> Result<Value> {
|
||||
let command = "render.library.describe";
|
||||
let input: Identify = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
let input: LibraryDescribeParams = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
if input.kind == "physical_profiles" {
|
||||
return super::physical_library::describe(&input.id);
|
||||
}
|
||||
let value = item(&input.kind, &input.id, command)?;
|
||||
let mut reply = json!({"kind":input.kind,"resource":value,"projection":projection(&input.kind,value),"source_manifest_unchanged":true});
|
||||
if matches!(input.kind.as_str(), "materials" | "surfaces") {
|
||||
reply["physical_references"] = super::physical_library::associations(&input.id)?;
|
||||
}
|
||||
Ok(reply)
|
||||
let physical_references =
|
||||
if matches!(input.kind.as_str(), "materials" | "surfaces") { Some(super::physical_library::associations(&input.id)?) } else { None };
|
||||
let projection = projection(&input.kind, value);
|
||||
reply(
|
||||
command,
|
||||
LibraryResource {
|
||||
kind: input.kind,
|
||||
resource: value.as_object().cloned().unwrap_or_default(),
|
||||
projection,
|
||||
source_manifest_unchanged: true,
|
||||
physical_references,
|
||||
param_warnings: Vec::new(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Preview {
|
||||
id: String,
|
||||
}
|
||||
pub(super) fn preview(_s: &mut Session, params: &Value) -> Result<Value> {
|
||||
let command = "render.library.preview";
|
||||
let input: Preview = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
let input: LibraryPreviewParams = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
item("surfaces", &input.id, command)?;
|
||||
let bytes = asset_bytes(&format!("{}/base_color", input.id), 2 * 1024 * 1024, command)?;
|
||||
Ok(json!({"id":input.id,"mime":"image/png","sha256":HdrId::of(&bytes),"bytes":bytes,
|
||||
"fidelity":"authored_base_color_source_map_not_a_render","document_changed":false}))
|
||||
reply(
|
||||
command,
|
||||
LibraryPreview {
|
||||
id: input.id,
|
||||
mime: "image/png".into(),
|
||||
sha256: HdrId::of(&bytes).to_string(),
|
||||
bytes,
|
||||
fidelity: "authored_base_color_source_map_not_a_render".into(),
|
||||
document_changed: false,
|
||||
param_warnings: Vec::new(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// The key is matched against generated constants, never joined to a filesystem path.
|
||||
|
||||
@@ -1,61 +1,65 @@
|
||||
//! Named saved-shot management through the existing RenderSettings authority.
|
||||
//! No captured jobs, camera navigation, external files or engineering data are edited.
|
||||
use crate::schema::TypedContract;
|
||||
use crate::schema::render_shots::{ShotChange, ShotOperation, ShotParams};
|
||||
use crate::{Result, Session, params::bad};
|
||||
use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
use serde_json::Value;
|
||||
use solidcraft_doc::render_settings::RenderSettings;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Named {
|
||||
name: String,
|
||||
#[serde(default)]
|
||||
new_name: Option<String>,
|
||||
expected_revision: u64,
|
||||
}
|
||||
fn change(s: &mut Session, params: &Value, operation: &str) -> Result<Value> {
|
||||
pub(super) const CONTRACT: TypedContract<ShotParams> = TypedContract::new();
|
||||
|
||||
fn change(s: &mut Session, params: &Value, operation: ShotOperation) -> Result<Value> {
|
||||
let command = match operation {
|
||||
"duplicate" => "render.shot.duplicate",
|
||||
"rename" => "render.shot.rename",
|
||||
_ => "render.shot.remove",
|
||||
ShotOperation::Duplicate => "render.shot.duplicate",
|
||||
ShotOperation::Rename => "render.shot.rename",
|
||||
ShotOperation::Remove => "render.shot.remove",
|
||||
};
|
||||
let input: Named = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
let input: ShotParams = serde_json::from_value(params.clone()).map_err(|e| bad(command, e.to_string()))?;
|
||||
if input.expected_revision != s.revision {
|
||||
return Err(bad(command, "saved shot changed after review; refresh before editing"));
|
||||
}
|
||||
RenderSettings::validate_name(&input.name).map_err(|e| bad(command, e.to_string()))?;
|
||||
let source = s.doc.render.setups.get(&input.name).cloned().ok_or_else(|| bad(command, "no saved shot with that name"))?;
|
||||
let mut settings = (*s.doc.render).clone();
|
||||
let output = if operation == "remove" {
|
||||
let output = if operation == ShotOperation::Remove {
|
||||
if input.new_name.is_some() {
|
||||
return Err(bad(command, "remove does not accept a destination name"));
|
||||
}
|
||||
settings.setups.remove(&input.name);
|
||||
Value::Null
|
||||
None
|
||||
} else {
|
||||
let destination = input.new_name.as_ref().ok_or_else(|| bad(command, "new_name is required"))?;
|
||||
RenderSettings::validate_name(destination).map_err(|e| bad(command, e.to_string()))?;
|
||||
if settings.setups.contains_key(destination) {
|
||||
let destination = input.new_name.ok_or_else(|| bad(command, "new_name is required"))?;
|
||||
RenderSettings::validate_name(&destination).map_err(|e| bad(command, e.to_string()))?;
|
||||
if settings.setups.contains_key(&destination) {
|
||||
return Err(bad(command, "destination already exists; saved shots are never overwritten"));
|
||||
}
|
||||
settings.setups.insert(destination.clone(), source);
|
||||
if operation == "rename" {
|
||||
if operation == ShotOperation::Rename {
|
||||
settings.setups.remove(&input.name);
|
||||
}
|
||||
json!(destination)
|
||||
Some(destination)
|
||||
};
|
||||
settings.validate().map_err(|e| bad(command, e.to_string()))?;
|
||||
s.doc_mut().render = Arc::new(settings);
|
||||
Ok(json!({"operation":operation,"source":input.name,"name":output,"resources_preserved":true,
|
||||
"camera_navigation_unchanged":true,"engineering_properties_unchanged":true,"captured_jobs_unchanged":true}))
|
||||
let reply = ShotChange {
|
||||
operation,
|
||||
source: input.name,
|
||||
name: output,
|
||||
resources_preserved: true,
|
||||
camera_navigation_unchanged: true,
|
||||
engineering_properties_unchanged: true,
|
||||
captured_jobs_unchanged: true,
|
||||
param_warnings: Vec::new(),
|
||||
};
|
||||
serde_json::to_value(reply).map_err(|e| bad(command, e.to_string()))
|
||||
}
|
||||
pub(super) fn duplicate(s: &mut Session, params: &Value) -> Result<Value> {
|
||||
change(s, params, "duplicate")
|
||||
change(s, params, ShotOperation::Duplicate)
|
||||
}
|
||||
pub(super) fn rename(s: &mut Session, params: &Value) -> Result<Value> {
|
||||
change(s, params, "rename")
|
||||
change(s, params, ShotOperation::Rename)
|
||||
}
|
||||
pub(super) fn remove(s: &mut Session, params: &Value) -> Result<Value> {
|
||||
change(s, params, "remove")
|
||||
change(s, params, ShotOperation::Remove)
|
||||
}
|
||||
|
||||
@@ -527,6 +527,25 @@ fn rules_are_parameters() {
|
||||
assert!(s.execute("sheet.manage_rules", &json!({"name": "Bad", "k_factor": 3})).is_err());
|
||||
}
|
||||
|
||||
/// A refused rule names the value at fault and its range (#9625): a thickness too large is not
|
||||
/// "not positive", and a negative bend radius is not blamed on the K-factor (or the other way).
|
||||
#[test]
|
||||
fn a_refused_rule_names_the_value_at_fault() {
|
||||
let mut s = Session::default();
|
||||
let refused =
|
||||
|s: &mut Session, p: Value| s.execute("sheet.manage_rules", &p).err().map(|e| e.to_string()).unwrap_or_else(|| panic!("{p} was accepted"));
|
||||
let e = refused(&mut s, json!({"name": "R", "thickness": 10000}));
|
||||
assert!(e.contains("the sheet thickness must be more than 0 and less than 10000 mm") && !e.contains("positive"), "{e}");
|
||||
let e = refused(&mut s, json!({"name": "R", "thickness": 0}));
|
||||
assert!(e.contains("the sheet thickness must be more than 0 and less than 10000 mm"), "{e}");
|
||||
let e = refused(&mut s, json!({"name": "R", "thickness": 2, "bend_radius": -1}));
|
||||
assert!(e.contains("the bend radius must not be negative") && !e.contains("K-factor"), "{e}");
|
||||
let e = refused(&mut s, json!({"name": "R", "thickness": 2, "k_factor": 3}));
|
||||
assert!(e.contains("the K-factor must be between 0 and 1") && !e.contains("bend radius"), "{e}");
|
||||
// A sharp bend (radius 0) is allowed, and the message no longer says otherwise.
|
||||
run(&mut s, "sheet.manage_rules", json!({"name": "R", "thickness": 2, "bend_radius": 0}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn contour_flange_hem_and_tray() {
|
||||
// Oracle 72.
|
||||
@@ -4913,6 +4932,48 @@ fn returns_follow_the_rules_gap_and_stay_open_with_a_warning_when_it_is_zero() {
|
||||
assert!((lengths[4] - lengths[0]).abs() < 1e-9 && (lengths[0] - (120.0 - 6.0 * 55f64.to_radians().tan())).abs() < 1e-6, "{lengths:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn returns_on_a_notched_tray_close_at_the_corner_away_from_the_notch() {
|
||||
// A 500 x 400 tray (#8823) with a 100 x 100 notch out of one corner: walls 20 high on its six
|
||||
// edges, then returns 15 high turned in on all but the notch's side on x = 400. In the flat,
|
||||
// the walls on either side of the notch's inner corner both unfold into the notch, so the
|
||||
// return on y = 300 lies over the wall on x = 400 there whatever happens at its other end.
|
||||
// That overlap used to keep the return's corner at (500, 300) open ("closed, the flanges
|
||||
// would overlap in the flat pattern"), and the two returns ran through each other there.
|
||||
let mut s = Session::default();
|
||||
run(
|
||||
&mut s,
|
||||
"sheet.manage_rules",
|
||||
json!({"name": "AL2", "thickness": "2 mm", "k_factor": 0.5, "bend_radius": "1 mm", "gap": "0.5 mm", "active": true}),
|
||||
);
|
||||
let pts: [(f64, f64); 6] = [(0.0, 0.0), (500.0, 0.0), (500.0, 300.0), (400.0, 300.0), (400.0, 400.0), (0.0, 400.0)];
|
||||
run(&mut s, "sketch.create", json!({"plane": "XY", "name": "Base"}));
|
||||
run(&mut s, "sketch.line", json!({"points": pts.map(|p| [p.0, p.1]), "closed": true}));
|
||||
run(&mut s, "sketch.finish", json!({}));
|
||||
run(&mut s, "sheet.flange", json!({"sketch": "Base"}));
|
||||
// The middle of edge k, `into` in from it (toward the base) and `z` up.
|
||||
let pick = |k: usize, into: f64, z: f64| {
|
||||
let (a, b) = (pts[k], pts[(k + 1) % pts.len()]);
|
||||
let l = (b.0 - a.0).hypot(b.1 - a.1);
|
||||
json!([(a.0 + b.0) / 2.0 - (b.1 - a.1) / l * into, (a.1 + b.1) / 2.0 + (b.0 - a.0) / l * into, z])
|
||||
};
|
||||
let walls: Vec<Value> = (0..6).map(|k| pick(k, 0.0, 2.0)).collect();
|
||||
run(&mut s, "sheet.flange", json!({"edges": walls, "height": 20, "angle": "90 deg"}));
|
||||
let returns: Vec<Value> = [0, 1, 2, 4, 5].iter().map(|&k| pick(k, 2.0, 20.0)).collect();
|
||||
run(&mut s, "sheet.flange", json!({"edges": returns, "height": 15, "angle": "90 deg"}));
|
||||
let warnings: Vec<String> = s.model.results.iter().filter_map(|r| r.warning.clone()).collect();
|
||||
assert!(s.model.results.iter().all(|r| r.error.is_none()) && warnings.is_empty(), "{warnings:?}");
|
||||
// The returns on x = 500 and y = 300 (z 18 … 20) are mitred on the diagonal through their
|
||||
// corner, the rule's gap apart: open on it, material on either side of it.
|
||||
assert!(!contains(&s, [490.0, 290.0, 19.0]), "the returns run through each other at (500, 300)");
|
||||
assert!(contains(&s, [490.0, 285.0, 19.0]) && contains(&s, [485.0, 290.0, 19.0]));
|
||||
// The other corners close as before, and the part is one valid solid.
|
||||
assert!(!contains(&s, [10.0, 10.0, 19.0]) && !contains(&s, [490.0, 10.0, 19.0]) && !contains(&s, [10.0, 390.0, 19.0]));
|
||||
let state = s.model.state();
|
||||
let body = &state.bodies[0].body;
|
||||
assert!(body.validity().is_empty() && body.shell_count() == 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_per_edge_input_is_refused_and_plain_edges_stay_plain() {
|
||||
let mut s = Session::default();
|
||||
|
||||
@@ -141,7 +141,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.params(concat!("p0, p1: overall ends, width", connect_doc!(), created_doc!())),
|
||||
CommandSpec::new("sketch.point", "Point", draw_point).at("SKETCH", "CREATE").icon("point").enabled(in_sketch).params(concat!("point: [x,y] (each a number or an expression over the design's parameters: the point is then fixed where it comes to and follows them) or a snap: \"mid:<line>\" (held at the line's midpoint), \"on:<curve>:x,y\" (on the curve near x,y), {vertex: [x,y,z]} or {on_edge: [x,y,z]} of the model; id?", connect_doc!(), created_doc!())),
|
||||
CommandSpec::new("sketch.dimension", "Sketch Dimension", dimension).at("SKETCH", "CREATE").icon("dimension").key("D").enabled(in_sketch).params(
|
||||
"entities: [refs] (a line midpoint is \"mid:line_id\"; a model edge or vertex, {edge: [x,y,z], body?} or {vertex: [x,y,z], body?}, is projected into the sketch first and measured there: a point against the projected edge measures the distance to it), type?: auto|distance|horizontal|distance_x|vertical|distance_y|length|radius|diameter|angle, value?: number or expression (default: current; a bare number is in the design's units, e.g. 2 means 2 in in an inch design; give a unit such as \"50 mm\" to override), or `name = expression` (e.g. \"width = 40\"; also `#name = expression`), which adds the user parameter `name` with that expression and dimensions with `name` (refused when the name is taken or reserved; the reply's `defined` names it); text_at?: [x, y]. Two points, two midpoints or a line off the axes: with auto, text_at inside the box they span (as opposite corners) or in its outer corners is the distance between them, above or below the box horizontal, beside it vertical. Two lines: the angle between them (acute, or 180° − it when the value is nearer that) unless text_at picks a sector. A line and a circle or arc: the distance from the line to its edge (the gap, or how far the edge reaches past a line that cuts it; 0 is tangent); dimension the centre point for the distance to the centre. A point and a circle or arc: the distance from the point to its edge (or how far within it a point inside lies). Two circles or arcs: the gap between their edges (or how far they overlap when they cross, or the narrowest gap between them when one lies inside the other), or the centre-to-centre distance when they are the two caps of a slot. An arc and one of its end points: the arc's length (type arc_length does it from the arc alone). A dimension the sketch already determines is refused (naming what determines it); if_redundant?: \"driven\" places it as a driven (reference) dimension instead. scale_sketch?: bool (the dimension tool sends true): when this is the sketch's first length dimension and nothing in the sketch fixes a size (no other driving length dimension, nothing fixed or projected), the whole sketch scales about its origin to the value instead of distorting. Returns measured in unit (mm or deg), and scaled: the factor when the sketch was scaled",
|
||||
"entities: [refs] (a line midpoint is \"mid:line_id\"; a model edge or vertex, {edge: [x,y,z], body?} or {vertex: [x,y,z], body?}, is projected into the sketch first and measured there: a point against the projected edge measures the distance to it), type?: auto|distance|horizontal|distance_x|vertical|distance_y|length|radius|diameter|major|minor|angle, value?: number or expression (default: current; a bare number is in the design's units, e.g. 2 means 2 in in an inch design; give a unit such as \"50 mm\" to override), or `name = expression` (e.g. \"width = 40\"; also `#name = expression`), which adds the user parameter `name` with that expression and dimensions with `name` (refused when the name is taken or reserved; the reply's `defined` names it); text_at?: [x, y]. Two points, two midpoints or a line off the axes: with auto, text_at inside the box they span (as opposite corners) or in its outer corners is the distance between them, above or below the box horizontal, beside it vertical. Two lines: the angle between them (acute, or 180° − it when the value is nearer that) unless text_at picks a sector. A line and a circle or arc: the distance from the line to its edge (the gap, or how far the edge reaches past a line that cuts it; 0 is tangent); dimension the centre point for the distance to the centre. A point and a circle or arc: the distance from the point to its edge (or how far within it a point inside lies). Two circles or arcs: the gap between their edges (or how far they overlap when they cross, or the narrowest gap between them when one lies inside the other), or the centre-to-centre distance when they are the two caps of a slot. An ellipse: a half-axis, the distance from the centre to an axis end (major or minor; with auto, text_at pulled across the major axis gives the major half-axis, pulled out past an end of it the minor one, the minor without text_at; previous_axis?: major|minor, the half-axis an earlier placement chose, kept while text_at is near the boundary between them; the reply's axis names the one chosen; with auto, when a driving dimension already holds one half-axis (or its whole axis), the other one, wherever text_at is; without its major axis line the major half-axis goes to the ellipse's own major end, without its minor axis line the minor half-axis is the minor radius); any other type, radius among them, the minor radius; an ellipse's axis line with auto: its length, the whole axis, wherever text_at is; half_axes?: bool (default true; false: with auto, the minor radius wherever text_at is, as before half-axes, which the Dimension tool sends with Draw ellipses with their axes off). An arc and one of its end points: the arc's length (type arc_length does it from the arc alone). A dimension the sketch already determines is refused (naming what determines it); if_redundant?: \"driven\" places it as a driven (reference) dimension instead. scale_sketch?: bool (the dimension tool sends true): when this is the sketch's first length dimension and nothing in the sketch fixes a size (no other driving length dimension, nothing fixed or projected), the whole sketch scales about its origin to the value instead of distorting. Returns measured in unit (mm or deg), and scaled: the factor when the sketch was scaled",
|
||||
),
|
||||
CommandSpec::new("sketch.constraint.horizontal_vertical", "Horizontal/Vertical", c_horizontal_vertical)
|
||||
.at("SKETCH", "CONSTRAINTS")
|
||||
@@ -173,7 +173,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.icon("c_perpendicular")
|
||||
.enabled(in_sketch)
|
||||
.params(concat!("a, b: lines or sketch axes (x / y: the sketch's own axes, unless a curve has that id; an axis becomes a linked construction line on it, reported in created)", model_operand_doc!())),
|
||||
CommandSpec::new("sketch.constraint.fix", "Fix/UnFix", c_fix)
|
||||
CommandSpec::new("sketch.constraint.fix", "Fix/Unfix", c_fix)
|
||||
.at("SKETCH", "CONSTRAINTS")
|
||||
.icon("c_fix")
|
||||
.enabled(in_sketch)
|
||||
@@ -2929,6 +2929,13 @@ fn dimension(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
None => (None, value),
|
||||
};
|
||||
let scale_sketch = bool_(p, "scale_sketch").unwrap_or(false);
|
||||
let previous_axis = str_(p, "previous_axis").map(str::to_ascii_lowercase);
|
||||
let half_axes = match p.get("half_axes") {
|
||||
None | Some(Value::Null) => true,
|
||||
Some(Value::Bool(b)) => *b,
|
||||
Some(_) => return Err(bad(cmd, "`half_axes` must be true or false")),
|
||||
};
|
||||
let mut axis = None;
|
||||
let mut scaled = None;
|
||||
let mut before = None;
|
||||
let (mut residual, mut new_id) = (None, String::new());
|
||||
@@ -2969,7 +2976,10 @@ fn dimension(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
((None, Some(c)), None) if is_line(c) => {
|
||||
let (a, b) = line_pts(sk, c).unwrap_or_default();
|
||||
match auto_orientation(&ty, a, b, text_at) {
|
||||
// An ellipse's axis is a construction axis, not a free line: its length, the
|
||||
// whole axis, wherever the text is.
|
||||
let ty = if ty == "auto" && sk.is_ellipse_axis(c) { "length" } else { ty.as_str() };
|
||||
match auto_orientation(ty, a, b, text_at) {
|
||||
"angle" => {
|
||||
let angle = (b - a).angle();
|
||||
(ConstraintKind::LineAngle { l: c, value: angle }, angle)
|
||||
@@ -2992,9 +3002,27 @@ fn dimension(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let Some(CurveKind::Ellipse { c: cp, m, r }) = sk.curves.get(c).map(|x| x.kind.clone()) else {
|
||||
return Err(bad(cmd, "ellipse"));
|
||||
};
|
||||
if ty == "major" {
|
||||
let d = sk.point(cp).zip(sk.point(m)).map(|(a, b)| a.dist(b)).unwrap_or(0.0);
|
||||
(ConstraintKind::Distance { p: cp, q: m, value: d }, d)
|
||||
// A half-axis, chosen by where the text is: the distance from the centre to an
|
||||
// axis end (the ellipse's own major end when its major axis is gone), or the
|
||||
// minor radius when its minor axis is gone or it never had one.
|
||||
if matches!(ty.as_str(), "major" | "minor") || (ty == "auto" && half_axes) {
|
||||
let (major, minor) = sk.ellipse_axis_lines(c).unwrap_or((None, None));
|
||||
let ends = (m, major.map(|(_, m2)| m2), minor.map(|(_, n1, n2)| [n1, n2]));
|
||||
// With one half-axis already held, the other is the only one left to guess.
|
||||
let ty = match (ty.as_str(), half_axes_held(sk, c, cp, m, major, minor)) {
|
||||
("auto", (true, false)) => "minor".to_string(),
|
||||
("auto", (false, true)) => "major".to_string(),
|
||||
_ => ty.clone(),
|
||||
};
|
||||
let (which, end) = ellipse_half_axis(sk, cp, ends, r, &ty, text_at, previous_axis.as_deref());
|
||||
axis = Some(which);
|
||||
match end {
|
||||
Some(end) => {
|
||||
let d = sk.point(cp).zip(sk.point(end)).map(|(a, b)| a.dist(b)).unwrap_or(0.0);
|
||||
(ConstraintKind::Distance { p: cp, q: end, value: d }, d)
|
||||
}
|
||||
None => (ConstraintKind::Radius { c, value: r }, r),
|
||||
}
|
||||
} else {
|
||||
(ConstraintKind::Radius { c, value: r }, r)
|
||||
}
|
||||
@@ -3193,7 +3221,11 @@ fn dimension(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
// Report what the dimension measures once the sketch is solved, not the geometry before.
|
||||
let current = solved_measure(s, p, cmd).unwrap_or(current);
|
||||
if driven {
|
||||
return Ok(json!({"param": Value::Null, "driven": true, "type": kind_name, "measured": current.0, "unit": current.1, "sketch": info}));
|
||||
let mut out = json!({"param": Value::Null, "driven": true, "type": kind_name, "measured": current.0, "unit": current.1, "sketch": info});
|
||||
if let Some(axis) = axis {
|
||||
out["axis"] = json!(axis);
|
||||
}
|
||||
return Ok(out);
|
||||
}
|
||||
// A dimension the sketch already determines cannot drive it: it is refused, or with
|
||||
// `if_redundant: "driven"` placed as a driven (reference) dimension instead.
|
||||
@@ -3223,6 +3255,9 @@ fn dimension(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if let Some(factor) = scaled {
|
||||
out["scaled"] = json!(round6(factor));
|
||||
}
|
||||
if let Some(axis) = axis {
|
||||
out["axis"] = json!(axis);
|
||||
}
|
||||
if let Some((name, _)) = defines {
|
||||
out["defined"] = json!(name);
|
||||
}
|
||||
@@ -3263,6 +3298,107 @@ fn auto_orientation(ty: &str, a: Vec2, b: Vec2, text_at: Option<Vec2>) -> &str {
|
||||
}
|
||||
}
|
||||
|
||||
/// Inside this band around the boundary between the two half-axes (the ratio of how far the
|
||||
/// text is pulled across the major axis to how far past its end, both scaled by the half-axes),
|
||||
/// a dimension being placed keeps the half-axis it had, so the preview does not flip back and
|
||||
/// forth while the pointer crosses slowly.
|
||||
const HALF_AXIS_DEAD_ZONE: f64 = 1.25;
|
||||
|
||||
/// Whether a driving dimension already holds ellipse `e`'s major and its minor half-axis: a
|
||||
/// half-axis to an axis end (or the minor radius), or the whole axis, along its line or between
|
||||
/// its ends.
|
||||
fn half_axes_held(sk: &Sketch, e: usize, c: usize, m: usize, major: Option<(usize, usize)>, minor: Option<(usize, usize, usize)>) -> (bool, bool) {
|
||||
let pair = |p: usize, q: usize, a: usize, b: usize| (p == a && q == b) || (p == b && q == a);
|
||||
let mut held = (false, false);
|
||||
for k in sk.constraints.iter().filter(|k| !k.driven) {
|
||||
match k.kind {
|
||||
ConstraintKind::Distance { p, q, .. } => {
|
||||
let minor_end = |x: usize| minor.is_some_and(|(_, n1, n2)| x == n1 || x == n2);
|
||||
if pair(p, q, c, m) || major.is_some_and(|(_, m2)| pair(p, q, c, m2) || pair(p, q, m, m2)) {
|
||||
held.0 = true;
|
||||
} else if minor.is_some_and(|(_, n1, n2)| pair(p, q, n1, n2)) || (p == c && minor_end(q)) || (q == c && minor_end(p)) {
|
||||
held.1 = true;
|
||||
}
|
||||
}
|
||||
ConstraintKind::Length { l, .. } => {
|
||||
held.0 |= major.is_some_and(|(line, _)| line == l);
|
||||
held.1 |= minor.is_some_and(|(line, ..)| line == l);
|
||||
}
|
||||
ConstraintKind::Radius { c: on, .. } => held.1 |= on == e,
|
||||
// A horizontal (vertical) distance across an axis holds its length when the axis
|
||||
// lies that way, the distance then being the length; across a slanted axis it is only
|
||||
// a projection.
|
||||
ConstraintKind::DistanceX { p, q, value } | ConstraintKind::DistanceY { p, q, value } => {
|
||||
let length = sk.point(p).zip(sk.point(q)).map(|(a, b)| a.dist(b));
|
||||
if !length.is_some_and(|l| (value.abs() - l).abs() <= 1e-9 * l.max(1.0)) {
|
||||
continue;
|
||||
}
|
||||
if pair(p, q, c, m) || major.is_some_and(|(_, m2)| pair(p, q, c, m2) || pair(p, q, m, m2)) {
|
||||
held.0 = true;
|
||||
} else if minor.is_some_and(|(_, n1, n2)| pair(p, q, n1, n2) || pair(p, q, c, n1) || pair(p, q, c, n2)) {
|
||||
held.1 = true;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
held
|
||||
}
|
||||
|
||||
/// Which half-axis of an ellipse a dimension measures, and the axis end it goes to. `ends` is
|
||||
/// what it has of its axes: the major end (always its own), the point opposite it, the minor
|
||||
/// axis's ends. The choice does not depend on them; the major half-axis goes to the major end
|
||||
/// when the point opposite is missing, and the minor one has no end (the minor radius) when its
|
||||
/// axis line is.
|
||||
/// With `auto` and `text_at` it follows the rule for a line, in the ellipse's own frame: text
|
||||
/// pulled across the major axis measures along it (the major half-axis), text pulled out past
|
||||
/// an end of the major axis measures across it (the minor one). The end is the one on the
|
||||
/// text's side. Without `text_at` it is the minor half-axis, as it always was.
|
||||
fn ellipse_half_axis(
|
||||
sk: &Sketch,
|
||||
c: usize,
|
||||
ends: (usize, Option<usize>, Option<[usize; 2]>),
|
||||
minor: f64,
|
||||
ty: &str,
|
||||
text_at: Option<Vec2>,
|
||||
previous: Option<&str>,
|
||||
) -> (&'static str, Option<usize>) {
|
||||
let (m, m2, minor_ends) = ends;
|
||||
let (pc, pm) = (sk.point(c).unwrap_or_default(), sk.point(m).unwrap_or_default());
|
||||
let d = pm - pc;
|
||||
let major = d.len();
|
||||
let rel = text_at.map(|t| t - pc);
|
||||
let along = rel.map(|v| v.dot(d) / (major * major)).filter(|v| v.is_finite()).unwrap_or(0.0);
|
||||
let across = rel.map(|v| d.cross(v) / (major * minor)).filter(|v| v.is_finite()).unwrap_or(0.0);
|
||||
let which = match ty {
|
||||
"major" => "major",
|
||||
"minor" => "minor",
|
||||
_ => {
|
||||
let (x, y) = (along.abs(), across.abs());
|
||||
match previous {
|
||||
Some(keep @ ("major" | "minor")) if y < x * HALF_AXIS_DEAD_ZONE && x < y * HALF_AXIS_DEAD_ZONE => {
|
||||
if keep == "major" {
|
||||
"major"
|
||||
} else {
|
||||
"minor"
|
||||
}
|
||||
}
|
||||
_ if y > x => "major",
|
||||
_ => "minor",
|
||||
}
|
||||
}
|
||||
};
|
||||
if which == "major" {
|
||||
(which, Some(if along < 0.0 { m2.unwrap_or(m) } else { m }))
|
||||
} else {
|
||||
let end = minor_ends.map(|[n1, n2]| {
|
||||
let side = sk.point(n1).map(|q| d.cross(q - pc)).unwrap_or(1.0);
|
||||
if across * side < 0.0 { n2 } else { n1 }
|
||||
});
|
||||
(which, end)
|
||||
}
|
||||
}
|
||||
|
||||
/// Keep a dimension's text where it was placed (`at`, sketch coordinates), relative to the
|
||||
/// dimension so it follows the geometry.
|
||||
fn place_text(sk: &mut Sketch, id: &str, at: Option<Vec2>) {
|
||||
|
||||
@@ -32,7 +32,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.icon("auto_constrain")
|
||||
.enabled(in_sketch)
|
||||
.params("tolerance?: mm (default 0.01), angle_tolerance?: deg (default 1), dimensions?: bool (default true): infer constraints, then dimension until fully constrained"),
|
||||
CommandSpec::new("sketch.auto_constrain_from_datum", "AutoConstrain from datum", auto_constrain_datum)
|
||||
CommandSpec::new("sketch.auto_constrain_from_datum", "AutoConstrain from Datum", auto_constrain_datum)
|
||||
.at("SKETCH", "CONSTRAINTS")
|
||||
.icon("auto_constrain")
|
||||
.enabled(in_sketch)
|
||||
|
||||
@@ -204,6 +204,26 @@ fn a_fillet_where_a_line_runs_on_smoothly_from_an_arc_is_refused() {
|
||||
assert_eq!(sk(&s).curves.len(), n);
|
||||
}
|
||||
|
||||
/// An ellipse's construction axes take no part in a corner: a line drawn from the major end
|
||||
/// meets the major axis there, and Fillet or Chamfer at that point, or on that pair, is refused
|
||||
/// instead of rounding the line into the axis.
|
||||
#[test]
|
||||
fn an_ellipse_s_axis_is_not_a_side_of_a_corner() {
|
||||
let mut s = new_sketch();
|
||||
let r = run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}));
|
||||
let major = r["created"]["curves"][1].as_str().unwrap().to_string();
|
||||
let l = curves(&run(&mut s, "sketch.line", json!({"points": [format!("{major}.end"), [20, 15]], "infer": false, "connect": false})))[0].clone();
|
||||
let before = sk(&s);
|
||||
for (cmd, size) in [("sketch.fillet", "radius"), ("sketch.chamfer.equal_distance", "distance")] {
|
||||
for corner in [json!({"point": format!("{l}.start")}), json!({"a": l, "b": major})] {
|
||||
let mut p = corner;
|
||||
p[size] = json!(2);
|
||||
assert!(s.execute(cmd, &p).is_err(), "{cmd} {p}: {:?}", sk(&s).curves);
|
||||
assert_eq!(sk(&s), before, "{cmd} {p}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of the constraints driven by the model parameter `name`.
|
||||
fn driven_by(s: &Session, name: &str) -> Vec<String> {
|
||||
sk(s).constraints.iter().filter(|c| c.param.as_deref() == Some(name)).map(|c| c.id.clone()).collect()
|
||||
|
||||
@@ -68,7 +68,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.enabled(in_sketch)
|
||||
.params(concat!("center, start: centre arc start, end: direction of the centre arc end (counter-clockwise) or sweep: degrees (0 < sweep < 360), width; returns centre_arc", created_doc!())),
|
||||
CommandSpec::new("sketch.ellipse", "Ellipse", ellipse).at("SKETCH", "CREATE").icon("ellipse").enabled(in_sketch).params(concat!(
|
||||
"center, major: end of the major axis [x,y], minor: a point the ellipse passes through on the minor side [x,y] | minor_radius",
|
||||
"center, major: end of the major axis [x,y], minor: a point the ellipse passes through on the minor side [x,y] | minor_radius. Also adds its major and minor axes as construction lines through the centre (their ends: the major end and the point opposite it, and the two ends of the minor axis on the ellipse), held by midpoint, perpendicular and point-on-curve constraints, so a half-axis is the distance from the centre to an axis end and an axis line's length is a full axis; axes?: bool (default true; false: the ellipse alone, as the Ellipse tool draws it with Draw ellipses with their axes off)",
|
||||
created_doc!()
|
||||
)),
|
||||
CommandSpec::new("sketch.spline.fit_point", "Fit Point Spline", spline_fit)
|
||||
@@ -626,12 +626,38 @@ fn ellipse(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !(r > 1e-9 && r < 1e8) {
|
||||
return Err(bad(cmd, "the minor radius must be positive"));
|
||||
}
|
||||
let axes = match p.get("axes") {
|
||||
None | Some(Value::Null) => true,
|
||||
Some(Value::Bool(b)) => *b,
|
||||
Some(_) => return Err(bad(cmd, "`axes` must be true or false")),
|
||||
};
|
||||
let (out, info) = edit(s, p, cmd, false, |sk, _| {
|
||||
let ci = sk.add_point(c, None)?;
|
||||
let mi = sk.add_point(m, None)?;
|
||||
let e = sk.add_curve(CurveKind::Ellipse { c: ci, m: mi, r }, None)?;
|
||||
mark_construction(sk, &[e], p);
|
||||
Ok((ids_of(sk, &[e]), Vec::new()))
|
||||
if !axes {
|
||||
return Ok((ids_of(sk, &[e]), Vec::new()));
|
||||
}
|
||||
// Its major and minor axes, construction lines through the centre that bisects both:
|
||||
// the major one ends at the major end, the minor one is perpendicular to it and ends
|
||||
// on the ellipse. Six new coordinates, six equations: the ellipse keeps its 5 degrees
|
||||
// of freedom, and each half-axis is a plain distance from the centre to an end.
|
||||
let n = u.perp() * r;
|
||||
let (m2, n1, n2) = (sk.add_point(c * 2.0 - m, None)?, sk.add_point(c + n, None)?, sk.add_point(c - n, None)?);
|
||||
let (major, minor) = (sk.add_line_pts(m2, mi, None)?, sk.add_line_pts(n2, n1, None)?);
|
||||
for l in [major, minor] {
|
||||
if let Some(cu) = sk.curves.get_mut(l) {
|
||||
cu.construction = true;
|
||||
}
|
||||
}
|
||||
let cons = vec![
|
||||
add_c(sk, ConstraintKind::Midpoint { p: ci, l: major })?,
|
||||
add_c(sk, ConstraintKind::Midpoint { p: ci, l: minor })?,
|
||||
add_c(sk, ConstraintKind::Perpendicular { a: minor, b: major })?,
|
||||
add_c(sk, ConstraintKind::PointOnCurve { p: n1, c: e })?,
|
||||
];
|
||||
Ok((ids_of(sk, &[e]), cons))
|
||||
})?;
|
||||
Ok(result(out, info))
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ const MAX_STEPS: usize = 64;
|
||||
/// After a step fails, the way to it from the last solved state is halved until what is left is
|
||||
/// shorter than a step over this; at most `MAX_STEPS` such solves per drag.
|
||||
const HALVINGS: usize = 16;
|
||||
/// Steps of a drag that isn't live solved at once past a failed step (see [`drag_entity`]).
|
||||
/// Steps of a drag that isn't live solved at once past a failed step, at most (see
|
||||
/// [`drag_entity`] and [`ahead_batch`]).
|
||||
const AHEAD: usize = 8;
|
||||
/// An arc whose sweep gets this close (radians) to 0 or a full turn has run into its start.
|
||||
const SWEEP_EPS: f64 = 1e-6;
|
||||
@@ -206,15 +207,9 @@ pub(super) fn drag_entity(
|
||||
});
|
||||
kept || counted_solve(sk, &hold, Some(&last.pos), Analysis::StatusOnly, Some(&mut *budget)).ok()
|
||||
};
|
||||
let mut step = |sk: &mut Sketch, last: &Geometry, t: f64, solves: &mut Solves| {
|
||||
let mut own = Budget::full();
|
||||
let budget = frame.as_mut().unwrap_or(&mut own);
|
||||
let spent = budget.spent();
|
||||
let ok = held(sk, last, t, budget);
|
||||
solves.count += 1;
|
||||
solves.work += budget.spent() - spent;
|
||||
solves.cut |= budget.exhausted();
|
||||
solves.numeric |= budget.numeric_exhausted();
|
||||
// How a held solve went (`ok`), judged on the sketch it left, which is put back to `last`
|
||||
// unless the step solved.
|
||||
let judge = |sk: &mut Sketch, last: &Geometry, ok: bool| {
|
||||
// A step that shrank a line to a point only met its constraints without that line.
|
||||
let outcome = if !ok || last.shrank(sk) {
|
||||
Step::Failed
|
||||
@@ -228,6 +223,17 @@ pub(super) fn drag_entity(
|
||||
last.restore(sk);
|
||||
outcome
|
||||
};
|
||||
let mut step = |sk: &mut Sketch, last: &Geometry, t: f64, solves: &mut Solves| {
|
||||
let mut own = Budget::full();
|
||||
let budget = frame.as_mut().unwrap_or(&mut own);
|
||||
let spent = budget.spent();
|
||||
let ok = held(sk, last, t, budget);
|
||||
solves.count += 1;
|
||||
solves.work += budget.spent() - spent;
|
||||
solves.cut |= budget.exhausted();
|
||||
solves.numeric |= budget.numeric_exhausted();
|
||||
judge(sk, last, ok)
|
||||
};
|
||||
let mut last = Geometry::default();
|
||||
last.take(sk);
|
||||
// How far along the last solved state is; the first step since it that failed.
|
||||
@@ -260,32 +266,59 @@ pub(super) fn drag_entity(
|
||||
}
|
||||
// Past a failed step, every next one starts from the last solved state again and a failed
|
||||
// one leaves nothing for the one after. Unless the drag is live (its steps share the
|
||||
// frame's budget), the next few are solved at once, on all cores, and those that fail
|
||||
// in a row are taken as tried: the walk goes on where it would have, one by one, at the
|
||||
// first of them that doesn't fail, without the seconds of failing solves before it.
|
||||
// frame's budget), the next few are solved at once, one per core, and taken in order as
|
||||
// the walk would have solved them one by one: those that fail in a row count as tried,
|
||||
// and the first that solves becomes the sketch, so no step is solved twice (#7648). The
|
||||
// walk goes on from there, without the seconds of failing solves before it. With one core
|
||||
// (and in the browser build) the batch would run one step after another, so the walk
|
||||
// solves the steps itself.
|
||||
#[cfg(test)]
|
||||
let ahead = last_drag::ahead();
|
||||
#[cfg(not(test))]
|
||||
let ahead = true;
|
||||
if ahead && !live && failed.is_some() && line_grab.is_none() {
|
||||
let ahead: Vec<f64> =
|
||||
(1..=AHEAD).map(|j| at(base, dt, k + j)).scan(false, |done, t| (!std::mem::replace(done, t >= 1.0)).then_some(t)).collect();
|
||||
let tried = solidcraft_kernel::map_on_threads(&ahead, AHEAD, |&t| {
|
||||
let batch = ahead_batch();
|
||||
if ahead && batch > 1 && !live && failed.is_some() && line_grab.is_none() {
|
||||
let next: Vec<f64> =
|
||||
(1..=batch).map(|j| at(base, dt, k + j)).scan(false, |done, t| (!std::mem::replace(done, t >= 1.0)).then_some(t)).collect();
|
||||
let tried = solidcraft_kernel::map_on_threads(&next, batch, |&t| {
|
||||
let mut sk = sk.clone();
|
||||
let mut budget = Budget::full();
|
||||
let ok = held(&mut sk, &last, t, &mut budget);
|
||||
(ok, budget.spent(), budget.exhausted())
|
||||
let outcome = judge(&mut sk, &last, ok);
|
||||
(outcome, sk, budget.spent(), budget.exhausted() || budget.numeric_exhausted())
|
||||
});
|
||||
let failing = tried.iter().take_while(|r| matches!(r, Some((false, _, false)))).flatten().collect::<Vec<_>>();
|
||||
if !failing.is_empty() {
|
||||
for (_, work, _) in &failing {
|
||||
solves.count += 1;
|
||||
solves.work += work;
|
||||
#[cfg(test)]
|
||||
last_drag::add_ahead(tried.len());
|
||||
let mut used = 0;
|
||||
let mut solved = None;
|
||||
// A step whose solve ran out of budget, or wrapped, is left to the walk, which knows
|
||||
// what to do with it.
|
||||
for (outcome, copy, work, _) in tried.into_iter().map_while(|r| r.filter(|r| !r.3)) {
|
||||
if matches!(outcome, Step::Wrapped) {
|
||||
break;
|
||||
}
|
||||
k += failing.len();
|
||||
solves.count += 1;
|
||||
solves.work += work;
|
||||
used += 1;
|
||||
if matches!(outcome, Step::Solved) {
|
||||
solved = Some(copy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if used > 0 {
|
||||
k += used;
|
||||
t = at(base, dt, k);
|
||||
#[cfg(test)]
|
||||
last_drag::add_skipped(failing.len());
|
||||
last_drag::add_skipped(used - usize::from(solved.is_some()));
|
||||
if let Some(copy) = solved {
|
||||
*sk = copy;
|
||||
#[cfg(test)]
|
||||
last_drag::add_taken(1);
|
||||
(good, failed) = (t, None);
|
||||
if t < 1.0 {
|
||||
last.take(sk);
|
||||
}
|
||||
}
|
||||
continue 'walk;
|
||||
}
|
||||
}
|
||||
@@ -408,6 +441,16 @@ pub(super) struct Solves {
|
||||
pub numeric: bool,
|
||||
}
|
||||
|
||||
/// How many steps past a failed one a drag that isn't live solves at once: one per core, at most
|
||||
/// [`AHEAD`]. The browser build has one thread: there a batch would solve its steps one after
|
||||
/// another, also those the walk never needs.
|
||||
fn ahead_batch() -> usize {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
return 1;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
std::thread::available_parallelism().map(usize::from).unwrap_or(1).min(AHEAD)
|
||||
}
|
||||
|
||||
/// One live frame's decomposition budget (smaller in tests that set one).
|
||||
fn frame_budget() -> Budget {
|
||||
#[cfg(test)]
|
||||
@@ -434,6 +477,8 @@ pub(super) mod last_drag {
|
||||
static NUMERIC: Cell<Option<usize>> = const { Cell::new(None) };
|
||||
static AHEAD: Cell<bool> = const { Cell::new(true) };
|
||||
static SKIPPED: Cell<usize> = const { Cell::new(0) };
|
||||
static AHEAD_SOLVED: Cell<usize> = const { Cell::new(0) };
|
||||
static TAKEN: Cell<usize> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
pub fn set(s: Solves) {
|
||||
@@ -496,6 +541,20 @@ pub(super) mod last_drag {
|
||||
SKIPPED.with(|c| c.set(c.get() + n));
|
||||
}
|
||||
|
||||
/// Steps solved at once past a failed one, and those of them that solved and became the
|
||||
/// sketch, since the last call.
|
||||
pub fn ahead_counts() -> (usize, usize) {
|
||||
(AHEAD_SOLVED.with(|c| c.replace(0)), TAKEN.with(|c| c.replace(0)))
|
||||
}
|
||||
|
||||
pub fn add_ahead(n: usize) {
|
||||
AHEAD_SOLVED.with(|c| c.set(c.get() + n));
|
||||
}
|
||||
|
||||
pub fn add_taken(n: usize) {
|
||||
TAKEN.with(|c| c.set(c.get() + n));
|
||||
}
|
||||
|
||||
/// Restores solving steps ahead when dropped, also when the test panics.
|
||||
struct RestoreAhead(bool);
|
||||
|
||||
@@ -787,8 +846,21 @@ fn plan(sk: &Sketch, e: Ent, from: Vec2, to: Vec2) -> Option<(Path, Hold)> {
|
||||
Path::ConicRho { c, from: rho, to: to_rho }
|
||||
}
|
||||
k => {
|
||||
// Lines and splines slide with the cursor.
|
||||
// Lines and splines slide with the cursor. An ellipse's construction axis
|
||||
// takes the ellipse and the other axis along, keeping their sizes, as a
|
||||
// rectangle's diagonal does through the corners it shares with the edges.
|
||||
let mut ids = k.point_ids();
|
||||
// Whichever axes are left: one may have been deleted.
|
||||
if let Some((e, major, minor)) = (0..sk.curves.len()).find_map(|e| {
|
||||
let (major, minor) = sk.ellipse_axis_lines(e)?;
|
||||
(major.is_some_and(|(l, _)| l == c) || minor.is_some_and(|(l, ..)| l == c)).then_some((e, major, minor))
|
||||
}) && let Some(kind) = sk.curves.get(e).map(|x| &x.kind)
|
||||
{
|
||||
ids.extend(kind.point_ids());
|
||||
ids.extend(major.map(|(_, q)| q));
|
||||
ids.extend(minor.into_iter().flat_map(|(_, n1, n2)| [n1, n2]));
|
||||
hold.radii.push(e);
|
||||
}
|
||||
ids.sort_unstable();
|
||||
ids.dedup();
|
||||
let pts = ids.iter().filter(|q| free(q)).filter_map(|&q| Some((q, sk.point(q)?))).collect();
|
||||
@@ -802,8 +874,9 @@ fn plan(sk: &Sketch, e: Ent, from: Vec2, to: Vec2) -> Option<(Path, Hold)> {
|
||||
}
|
||||
|
||||
/// A selection dragged by one of its entities (`e`, the rest `with`): every free point of all of
|
||||
/// them slides by `d` and the solves hold them all (circles and ellipses keep their radii), so
|
||||
/// the selection moves as one instead of its free ends trailing behind the grabbed entity.
|
||||
/// them slides by `d` and the solves hold them all (circles and ellipses keep their radii, an
|
||||
/// ellipse's axis brings its ellipse), so the selection moves as one instead of its free ends
|
||||
/// trailing behind the grabbed entity.
|
||||
fn plan_group(sk: &Sketch, e: Ent, with: &[Ent], d: Vec2) -> Option<(Path, Hold)> {
|
||||
let mut hold = Hold::default();
|
||||
for e in std::iter::once(&e).chain(with) {
|
||||
@@ -815,6 +888,16 @@ fn plan_group(sk: &Sketch, e: Ent, with: &[Ent], d: Vec2) -> Option<(Path, Hold)
|
||||
if matches!(kind, CurveKind::Circle { .. } | CurveKind::Ellipse { .. }) {
|
||||
hold.radii.push(c);
|
||||
}
|
||||
// An ellipse's axis takes the ellipse and the other axis along, as it does dragged
|
||||
// alone (see `plan`).
|
||||
if let Some(e) = sk.ellipse_of_axis(c)
|
||||
&& let (Some(kind), Some((major, minor))) = (sk.curves.get(e).map(|x| &x.kind), sk.ellipse_axis_lines(e))
|
||||
{
|
||||
hold.points.extend(kind.point_ids());
|
||||
hold.points.extend(major.map(|(_, q)| q));
|
||||
hold.points.extend(minor.into_iter().flat_map(|(_, n1, n2)| [n1, n2]));
|
||||
hold.radii.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,6 +386,30 @@ fn a_drag_with_the_rest_of_a_selection_moves_it_as_one() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A selection dragged by an ellipse's axis takes the ellipse and its other axis along, as the
|
||||
/// axis dragged alone does: the whole ellipse slides by the cursor's move, keeping its size.
|
||||
#[test]
|
||||
fn a_selection_dragged_by_an_ellipse_axis_takes_the_ellipse_along() {
|
||||
for live in [false, true] {
|
||||
let mut s = Session::default();
|
||||
run(&mut s, "sketch.create", json!({"plane": "XY"}));
|
||||
let r = run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}));
|
||||
let e = r["curves"][0].as_str().expect("the ellipse").to_string();
|
||||
run(&mut s, "sketch.line", json!({"points": [[40, -10], [40, 10]], "connect": false}));
|
||||
let sk = s.doc.sketch(s.active_sketch.expect("sketch mode")).expect("the sketch");
|
||||
let Some((Some((major, _)), _)) = sk.ellipse_axis_lines(sk.curve_index(&e).expect("the ellipse")) else { panic!("its axes") };
|
||||
let axis = sk.curves[major].id.clone();
|
||||
let line = sk.curves.last().expect("the line").id.clone();
|
||||
run(&mut s, "sketch.drag", json!({"entity": axis, "with": [line], "from": [10, 0], "to": [10, 15], "live": live}));
|
||||
let sk = s.doc.sketch(s.active_sketch.expect("sketch mode")).expect("the sketch");
|
||||
let ei = sk.curve_index(&e).expect("the ellipse");
|
||||
let solidcraft_sketch::CurveKind::Ellipse { c, m, .. } = sk.curves[ei].kind else { panic!("an ellipse") };
|
||||
let v = solidcore_record::Vec2::new;
|
||||
assert!(sk.point(c).expect("its centre").dist(v(0.0, 15.0)) < 1e-6, "live {live}: the centre follows: {:?}", sk.point(c));
|
||||
assert!(sk.point(m).expect("its major end").dist(v(20.0, 15.0)) < 1e-6, "live {live}: the major end follows: {:?}", sk.point(m));
|
||||
}
|
||||
}
|
||||
|
||||
/// A 5 x 5 square drawn on the top face of a 30 x 20 x 10 box, the face's edges projected into
|
||||
/// its sketch; returns the session and a corner of the square (its id and where it is).
|
||||
fn on_a_face() -> (Session, String, solidcore_record::Vec2) {
|
||||
|
||||
@@ -58,8 +58,12 @@ fn cuts(sk: &Sketch, ci: usize, segs: &[Seg2], only_freeform: bool) -> Vec<(f64,
|
||||
let (t, u) = ((c - a).cross(s) / den, (c - a).cross(r) / den);
|
||||
((-1e-9..=1.0 + 1e-9).contains(&t) && (-1e-9..=1.0 + 1e-9).contains(&u)).then(|| a + r * t)
|
||||
};
|
||||
// An ellipse's own axes end on it and cut it nowhere, as a Center Rectangle's diagonals end
|
||||
// at its corners.
|
||||
let (major, minor) = sk.ellipse_axis_lines(ci).unwrap_or((None, None));
|
||||
let own_axes = [major.map(|(l, _)| l), minor.map(|(l, ..)| l)];
|
||||
for (oi, curve) in sk.curves.iter().enumerate() {
|
||||
if oi == ci || (only_freeform && !curve.kind.is_freeform()) {
|
||||
if oi == ci || (only_freeform && !curve.kind.is_freeform()) || own_axes.contains(&Some(oi)) {
|
||||
continue;
|
||||
}
|
||||
let other = sk.polyline(oi);
|
||||
|
||||
@@ -25,7 +25,7 @@ pub static COMMANDS: &[CommandSpec] = &[
|
||||
.at("SKETCH", "MODIFY")
|
||||
.icon("sketch_fillet")
|
||||
.enabled(in_sketch)
|
||||
.params(concat!("point: corner shared by two curves (\"l1.end\") | points: [corners] (all rounded alike: one radius, the rest equal; a corner is a point reference or {a, b}, the two curves meeting there) | a, b: two lines or arcs meeting at a corner (two lines that share no end are first brought to where they meet: the nearer end of a line that stops short moves there, and a line that runs past is cut there, losing its shorter piece); radius: expr. A corner that dimensions or constraints measure to stays as a virtual sharp corner on both curves' extensions (`virtual_corners`; the moved ones in `moved_to_virtual_corner`)", created_doc!())),
|
||||
.params(concat!("point: corner shared by two curves (\"l1.end\") | points: [corners] (all rounded alike: one radius, the rest equal; a corner is a point reference or {a, b}, the two curves meeting there) | a, b: two lines or arcs meeting at a corner (two lines that share no end are first brought to where they meet: the nearer end of a line that stops short moves there, and a line that runs past is cut there, losing its shorter piece); radius: expr. A corner that dimensions or constraints measure to stays as a virtual sharp corner on both curves' extensions (`virtual_corners`; the moved ones in `moved_to_virtual_corner`). An ellipse's axis line is never a side of a corner (also for the chamfers)", created_doc!())),
|
||||
CommandSpec::new("sketch.chamfer.equal_distance", "Equal Distance Chamfer", chamfer_equal)
|
||||
.at("SKETCH", "MODIFY")
|
||||
.icon("sketch_chamfer")
|
||||
@@ -1780,7 +1780,10 @@ fn corner(sk: &Sketch, p: &Value, cmd: &str) -> Result<(usize, usize, usize, usi
|
||||
};
|
||||
let (la, lb) = if let Some(r) = str_(p, "point") {
|
||||
let q = sk.resolve_point(r).ok_or_else(|| bad(cmd, format!("unknown point `{r}`")))?;
|
||||
let lines: Vec<usize> = (0..sk.curves.len()).filter(|i| ends(*i).is_some_and(|(a, b)| a == q || b == q) && !sk.is_linked_curve(*i)).collect();
|
||||
// An ellipse's construction axis is never a side: it would round a line into the axis.
|
||||
let lines: Vec<usize> = (0..sk.curves.len())
|
||||
.filter(|i| ends(*i).is_some_and(|(a, b)| a == q || b == q) && !sk.is_linked_curve(*i) && !sk.is_ellipse_axis(*i))
|
||||
.collect();
|
||||
// A construction line ending there too (a diagonal that centres something) is not one of
|
||||
// the corner's sides: it keeps its end on the virtual sharp corner (#1026).
|
||||
let sides: Vec<usize> =
|
||||
@@ -1792,6 +1795,9 @@ fn corner(sk: &Sketch, p: &Value, cmd: &str) -> Result<(usize, usize, usize, usi
|
||||
} else {
|
||||
let a = str_(p, "a").and_then(|i| sk.curve_index(i)).ok_or_else(|| bad(cmd, "`a` must be a line"))?;
|
||||
let b = str_(p, "b").and_then(|i| sk.curve_index(i)).ok_or_else(|| bad(cmd, "`b` must be a line"))?;
|
||||
if sk.is_ellipse_axis(a) || sk.is_ellipse_axis(b) {
|
||||
return Err(bad(cmd, "an ellipse's axis is not a side of a corner"));
|
||||
}
|
||||
(a, b)
|
||||
};
|
||||
let (a0, a1) = ends(la).ok_or_else(|| bad(cmd, "fillets and chamfers work on two lines"))?;
|
||||
@@ -2087,7 +2093,9 @@ fn round_corner(sk: &mut Sketch, p: &Value, r: f64, cmd: &str) -> Result<Option<
|
||||
};
|
||||
let (ca, cb, q) = if let Some(rf) = str_(p, "point") {
|
||||
let Some(q) = sk.resolve_point(rf) else { return Ok(None) };
|
||||
let cs: Vec<usize> = (0..sk.curves.len()).filter(|i| ends(*i).is_some_and(|(a, b)| a == q || b == q) && !sk.is_linked_curve(*i)).collect();
|
||||
let cs: Vec<usize> = (0..sk.curves.len())
|
||||
.filter(|i| ends(*i).is_some_and(|(a, b)| a == q || b == q) && !sk.is_linked_curve(*i) && !sk.is_ellipse_axis(*i))
|
||||
.collect();
|
||||
match cs[..] {
|
||||
[a, b] => (a, b, q),
|
||||
_ => return Ok(None),
|
||||
@@ -2097,6 +2105,9 @@ fn round_corner(sk: &mut Sketch, p: &Value, r: f64, cmd: &str) -> Result<Option<
|
||||
return Ok(None);
|
||||
};
|
||||
let (Some((a0, a1)), Some((b0, b1))) = (ends(a), ends(b)) else { return Ok(None) };
|
||||
if sk.is_ellipse_axis(a) || sk.is_ellipse_axis(b) {
|
||||
return Ok(None);
|
||||
}
|
||||
let Some(q) = [a0, a1].into_iter().find(|x| *x == b0 || *x == b1) else { return Ok(None) };
|
||||
(a, b, q)
|
||||
};
|
||||
@@ -3186,6 +3197,28 @@ fn entities(sk: &Sketch, p: &Value, cmd: &str) -> Result<(Vec<usize>, Vec<usize>
|
||||
Ok((cs, ps))
|
||||
}
|
||||
|
||||
/// `cs` with the ellipse of every axis line in it and the axis lines of every ellipse in it: an
|
||||
/// ellipse, or one of its axes, moved, turned or scaled takes the rest along, as a drag does,
|
||||
/// instead of leaving the axes behind its centre or pulling an axis off the ellipse.
|
||||
fn with_ellipse_axes(sk: &Sketch, cs: &mut Vec<usize>) {
|
||||
let ellipses: Vec<usize> = cs.iter().filter_map(|&l| sk.ellipse_of_axis(l)).collect();
|
||||
for e in ellipses {
|
||||
if !cs.contains(&e) {
|
||||
cs.push(e);
|
||||
}
|
||||
}
|
||||
let axes: Vec<usize> = cs
|
||||
.iter()
|
||||
.filter_map(|&e| sk.ellipse_axis_lines(e))
|
||||
.flat_map(|(major, minor)| major.map(|(l, _)| l).into_iter().chain(minor.map(|(l, ..)| l)))
|
||||
.collect();
|
||||
for l in axes {
|
||||
if !cs.contains(&l) {
|
||||
cs.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Points used by curves plus lone points, in a stable order.
|
||||
fn involved_points(sk: &Sketch, cs: &[usize], ps: &[usize]) -> Vec<usize> {
|
||||
let mut v: Vec<usize> = Vec::new();
|
||||
@@ -3513,6 +3546,7 @@ fn move_copy(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
return Ok(ids);
|
||||
}
|
||||
with_ellipse_axes(sk, &mut cs);
|
||||
transform_in_place(sk, &cs, &ps, &f, 1.0, cmd)?;
|
||||
if rotate_constraints {
|
||||
let moved = involved_points(sk, &cs, &ps);
|
||||
@@ -3539,7 +3573,8 @@ fn transform(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
};
|
||||
let t = if p.get("translate").is_some() { req_vec2(cmd, p, "translate")? } else { Vec2::ZERO };
|
||||
let (out, info) = edit(s, p, cmd, false, |sk, doc| {
|
||||
let (cs, ps) = entities(sk, p, cmd)?;
|
||||
let (mut cs, ps) = entities(sk, p, cmd)?;
|
||||
with_ellipse_axes(sk, &mut cs);
|
||||
let c = if p.get("center").is_some() { point_or_ref(sk, p, "center", cmd)? } else { Vec2::ZERO };
|
||||
let rot = rotate(c, ang);
|
||||
let f = move |q: Vec2| rot(c + (q - c) * k) + t;
|
||||
@@ -3612,7 +3647,8 @@ fn scale(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "sketch.scale";
|
||||
let k = num(p, "factor").filter(|k| *k > 1e-9 && *k < 1e6).ok_or_else(|| bad(cmd, "`factor` must be a positive number"))?;
|
||||
let (out, info) = edit(s, p, cmd, false, |sk, _| {
|
||||
let (cs, ps) = entities(sk, p, cmd)?;
|
||||
let (mut cs, ps) = entities(sk, p, cmd)?;
|
||||
with_ellipse_axes(sk, &mut cs);
|
||||
let b = if p.get("base").is_some() { point_or_ref(sk, p, "base", cmd)? } else { Vec2::ZERO };
|
||||
let f = move |q: Vec2| b + (q - b) * k;
|
||||
transform_in_place(sk, &cs, &ps, &f, k, cmd)?;
|
||||
|
||||
@@ -142,7 +142,7 @@ fn explicit_ellipse_break_keeps_closed_profile() {
|
||||
let out = run(&mut s, "sketch.break", json!({"curve": id, "points": [[10,0], [0,4], [10,0]]}));
|
||||
assert_eq!(ids(&out["curves"]).len(), 4, "{out}");
|
||||
let after = sketch(&s);
|
||||
assert!(after.curves.iter().all(|c| matches!(c.kind, CurveKind::Conic { .. })));
|
||||
assert!(after.curves.iter().filter(|c| !c.construction).all(|c| matches!(c.kind, CurveKind::Conic { .. })));
|
||||
assert_eq!(profiles(&s).len(), 1);
|
||||
assert!((profiles(&s)[0] - area).abs() < 1e-6);
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
@@ -174,6 +174,83 @@ fn explicit_break_rejects_bad_points_atomically_and_merges_duplicates() {
|
||||
}
|
||||
}
|
||||
|
||||
/// An axis line moved, turned or scaled on its own takes its ellipse and the other axis along,
|
||||
/// as a drag of the same line does, instead of pulling away from the ellipse.
|
||||
#[test]
|
||||
fn an_ellipse_axis_moved_turned_or_scaled_alone_takes_its_ellipse_along() {
|
||||
for (cmd, params, centre, major) in [
|
||||
("sketch.move", json!({"translate": [0, 30]}), Vec2::new(0.0, 30.0), Vec2::new(20.0, 30.0)),
|
||||
("sketch.move", json!({"angle": 90, "center": [0, 0]}), Vec2::ZERO, Vec2::new(0.0, 20.0)),
|
||||
("sketch.scale", json!({"base": [0, 0], "factor": 2}), Vec2::ZERO, Vec2::new(40.0, 0.0)),
|
||||
("sketch.transform", json!({"translate": [5, 0]}), Vec2::new(5.0, 0.0), Vec2::new(25.0, 0.0)),
|
||||
] {
|
||||
for which in ["major", "minor"] {
|
||||
let mut s = new_sketch();
|
||||
let e = ids(&run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}))["curves"])[0].clone();
|
||||
let sk = sketch(&s);
|
||||
let Some((Some((major_line, _)), Some((minor_line, ..)))) = sk.ellipse_axis_lines(sk.curve_index(&e).unwrap()) else {
|
||||
panic!("its axes")
|
||||
};
|
||||
let axis = sk.curves[if which == "major" { major_line } else { minor_line }].id.clone();
|
||||
let mut p = params.clone();
|
||||
p["entities"] = json!([axis]);
|
||||
let r = run(&mut s, cmd, p);
|
||||
assert_eq!(r["sketch"]["solved"], json!(true), "{cmd} {params} {which}: {r}");
|
||||
let sk = sketch(&s);
|
||||
let ei = sk.curve_index(&e).unwrap();
|
||||
let CurveKind::Ellipse { c, m, .. } = sk.curves[ei].kind else { panic!("an ellipse") };
|
||||
assert!(sk.point(c).unwrap().dist(centre) < 1e-6, "{cmd} {params} {which}: the ellipse's centre follows: {:?}", sk.point(c));
|
||||
assert!(sk.point(m).unwrap().dist(major) < 1e-6, "{cmd} {params} {which}: its major end follows: {:?}", sk.point(m));
|
||||
assert!(sk.ellipse_axis_lines(ei).is_some_and(|(a, b)| a.is_some() && b.is_some()), "{cmd} {params} {which}: still its axes");
|
||||
assert!(ids(&r["curves"]).contains(&e), "{cmd} {params} {which}: the reply lists the ellipse: {r}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An ellipse moved, turned or scaled on its own takes its axes along, as a drag does: they
|
||||
/// stay its axes and nothing is left failing.
|
||||
#[test]
|
||||
fn an_ellipse_moved_turned_or_scaled_alone_takes_its_axes_along() {
|
||||
// With the minor axis deleted, the major axis that is left still goes along.
|
||||
let mut s = new_sketch();
|
||||
let e = ids(&run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}))["curves"])[0].clone();
|
||||
let minor = sketch(&s).curves.iter().rev().find(|c| matches!(c.kind, CurveKind::Line { .. })).unwrap().id.clone();
|
||||
run(&mut s, "sketch.delete", json!({"entities": [minor]}));
|
||||
let r = run(&mut s, "sketch.move", json!({"entities": [e], "translate": [0, 30]}));
|
||||
assert_eq!(r["sketch"]["solved"], json!(true), "{r}");
|
||||
let sk = sketch(&s);
|
||||
let (major, _) = sk.ellipse_axis_lines(sk.curve_index(&e).unwrap()).and_then(|(major, _)| major).expect("its major axis");
|
||||
let CurveKind::Line { a, b } = sk.curves[major].kind else { panic!("a line") };
|
||||
assert!(sk.point(a).unwrap().dist(Vec2::new(-20.0, 30.0)) < 1e-6 && sk.point(b).unwrap().dist(Vec2::new(20.0, 30.0)) < 1e-6);
|
||||
assert!(ids(&r["curves"]).contains(&sk.curves[major].id), "the reply lists the axis moved: {r}");
|
||||
for (cmd, params, centre, major) in [
|
||||
("sketch.move", json!({"translate": [0, 30]}), Vec2::new(0.0, 30.0), Vec2::new(20.0, 30.0)),
|
||||
("sketch.move", json!({"angle": 90, "center": [0, 0]}), Vec2::ZERO, Vec2::new(0.0, 20.0)),
|
||||
("sketch.scale", json!({"base": [0, 0], "factor": 2}), Vec2::ZERO, Vec2::new(40.0, 0.0)),
|
||||
("sketch.transform", json!({"translate": [5, 0]}), Vec2::new(5.0, 0.0), Vec2::new(25.0, 0.0)),
|
||||
] {
|
||||
let mut s = new_sketch();
|
||||
let e = ids(&run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}))["curves"])[0].clone();
|
||||
let mut p = params.clone();
|
||||
p["entities"] = json!([e]);
|
||||
let r = run(&mut s, cmd, p);
|
||||
assert_eq!(r["sketch"]["solved"], json!(true), "{cmd} {params}: {r}");
|
||||
let sk = sketch(&s);
|
||||
let ei = sk.curve_index(&e).unwrap();
|
||||
let Some((Some((major_line, opposite)), Some((minor_line, n1, n2)))) = sk.ellipse_axis_lines(ei) else {
|
||||
panic!("{cmd} {params}: still its axes")
|
||||
};
|
||||
let CurveKind::Ellipse { m, .. } = sk.curves[ei].kind else { panic!("an ellipse") };
|
||||
let ends: Vec<Vec2> = [m, opposite, n1, n2].iter().map(|q| sk.point(*q).unwrap()).collect();
|
||||
assert!(ends[0].dist(major) < 1e-6 && ends[1].dist(centre * 2.0 - major) < 1e-6, "{cmd} {params}: the major axis follows: {ends:?}");
|
||||
assert!(((ends[2] + ends[3]) * 0.5).dist(centre) < 1e-6, "{cmd} {params}: the minor axis follows: {ends:?}");
|
||||
let listed = ids(&r["curves"]);
|
||||
for l in [major_line, minor_line] {
|
||||
assert!(listed.contains(&sk.curves[l].id), "{cmd} {params}: the reply lists the axis lines: {r}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn analytic_trim_and_break_use_freeform_cutters() {
|
||||
let mut s = new_sketch();
|
||||
@@ -190,11 +267,95 @@ fn analytic_trim_and_break_use_freeform_cutters() {
|
||||
let mut s = new_sketch();
|
||||
let circle = ids(&run(&mut s, "sketch.circle.center", json!({"center": [0,0], "radius": 5}))["curves"])[0].clone();
|
||||
run(&mut s, "sketch.ellipse", json!({"center": [0,0], "major": [8,0], "minor": [0,3]}));
|
||||
run(&mut s, "sketch.trim", json!({"curve": circle, "at": [5,0]}));
|
||||
// Picked 15 degrees round from where the major axis crosses the circle: the piece from the
|
||||
// axis to the ellipse's crossing goes, the rest stays. Its construction axes cut too (see
|
||||
// the next test).
|
||||
run(&mut s, "sketch.trim", json!({"curve": circle, "at": [4.8296,1.2941]}));
|
||||
let sk = sketch(&s);
|
||||
let ci = sk.curve_index(&circle).unwrap();
|
||||
assert!(matches!(sk.curves[ci].kind, CurveKind::Arc { .. }));
|
||||
assert!(sk.shape(ci).unwrap().dist(Vec2::new(-5.0, 0.0)) < 1e-6);
|
||||
let CurveKind::Arc { a, b, .. } = sk.curves[ci].kind else { panic!("{:?}", sk.curves[ci].kind) };
|
||||
let crossing = Vec2::new((25.0f64 - 351.0 / 55.0).sqrt(), (351.0f64 / 55.0).sqrt());
|
||||
let mut ends = [sk.point(a).unwrap(), sk.point(b).unwrap()];
|
||||
ends.sort_by(|p, q| p.y.total_cmp(&q.y));
|
||||
assert!(ends[0].dist(Vec2::new(5.0, 0.0)) < 1e-6 && ends[1].dist(crossing) < 1e-6, "{ends:?}");
|
||||
let shape = sk.shape(ci).unwrap();
|
||||
assert!(shape.dist(Vec2::new(-5.0, 0.0)) < 1e-6 && shape.dist(Vec2::new(4.8296, -1.2941)) < 1e-3);
|
||||
assert!(shape.dist(Vec2::new(4.8296, 1.2941)) > 0.5);
|
||||
}
|
||||
|
||||
/// An ellipse's own axes do not cut it (they end on it, where a Center Rectangle's diagonals end
|
||||
/// at its corners): a lone ellipse trims away whole, its axes staying as when it is deleted, and
|
||||
/// a trim of its outline stops where a line crosses, not at an axis end.
|
||||
#[test]
|
||||
fn an_ellipse_s_own_axes_do_not_cut_it() {
|
||||
let mut s = new_sketch();
|
||||
let e = ids(&run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}))["curves"])[0].clone();
|
||||
run(&mut s, "sketch.trim", json!({"curve": e, "at": [0, 8]}));
|
||||
let sk = sketch(&s);
|
||||
assert!(sk.curves.iter().all(|c| c.construction), "the whole ellipse goes: {:?}", sk.curves);
|
||||
assert_eq!(sk.curves.len(), 2, "its two axes stay");
|
||||
|
||||
let mut s = new_sketch();
|
||||
let e = ids(&run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}))["curves"])[0].clone();
|
||||
run(&mut s, "sketch.line", json!({"points": [[10, -10], [10, 10]], "connect": false}));
|
||||
// Clicked 10 degrees round from the major end: the cap right of the line goes, from one
|
||||
// crossing to the other, past the major end.
|
||||
let at = Vec2::new(20.0 * 10f64.to_radians().cos(), 8.0 * 10f64.to_radians().sin());
|
||||
run(&mut s, "sketch.trim", json!({"curve": e, "at": [at.x, at.y]}));
|
||||
let sk = sketch(&s);
|
||||
let left: Vec<usize> =
|
||||
(0..sk.curves.len()).filter(|i| !sk.curves[*i].construction && !matches!(sk.curves[*i].kind, CurveKind::Line { .. })).collect();
|
||||
// What is left of the ellipse comes back as conic pieces; the trim must leave some.
|
||||
assert!(!left.is_empty(), "part of the ellipse is left: {:?}", sk.curves);
|
||||
for i in left {
|
||||
let right = sk.polyline(i).iter().map(|q| q.x).fold(f64::MIN, f64::max);
|
||||
assert!(right < 10.0 + 1e-6, "{}: what is left stays left of the line, reaching x = {right}", sk.curves[i].id);
|
||||
}
|
||||
}
|
||||
|
||||
/// An ellipse's construction axes cut a trim, as a Center Rectangle's construction diagonals
|
||||
/// do: a line inside the ellipse trims back to the minor axis, one inside the rectangle to the
|
||||
/// diagonals.
|
||||
#[test]
|
||||
fn an_ellipse_s_axes_cut_as_a_center_rectangle_s_diagonals_do() {
|
||||
// What is left of the line at y = 1, as x ranges.
|
||||
let lines = |s: &Session| {
|
||||
let sk = sketch(s);
|
||||
let mut ends: Vec<[f64; 2]> = sk
|
||||
.curves
|
||||
.iter()
|
||||
.filter_map(|c| match c.kind {
|
||||
CurveKind::Line { a, b } => {
|
||||
let (a, b) = (sk.point(a).unwrap(), sk.point(b).unwrap());
|
||||
(close(a.y, 1.0) && close(b.y, 1.0)).then(|| [a.x.min(b.x), a.x.max(b.x)])
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
ends.sort_by(|x, y| x[0].total_cmp(&y[0]));
|
||||
ends
|
||||
};
|
||||
let mut s = new_sketch();
|
||||
run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}));
|
||||
let line = ids(&run(&mut s, "sketch.line", json!({"points": [[-3, 1], [3, 1]], "connect": false}))["curves"])[0].clone();
|
||||
run(&mut s, "sketch.trim", json!({"curve": line, "at": [1, 1]}));
|
||||
let ends = lines(&s);
|
||||
assert!(ends.len() == 1 && close(ends[0][0], -3.0) && close(ends[0][1], 0.0), "{ends:?}");
|
||||
|
||||
// Extend stops at them too: a line inside the ellipse reaches the minor axis, not the outline.
|
||||
let mut s = new_sketch();
|
||||
run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}));
|
||||
let line = ids(&run(&mut s, "sketch.line", json!({"points": [[-6, 1], [-3, 1]], "connect": false}))["curves"])[0].clone();
|
||||
run(&mut s, "sketch.extend", json!({"curve": line, "at": [-3, 1]}));
|
||||
let ends = lines(&s);
|
||||
assert!(ends.len() == 1 && close(ends[0][0], -6.0) && close(ends[0][1], 0.0), "{ends:?}");
|
||||
|
||||
let mut s = new_sketch();
|
||||
run(&mut s, "sketch.rectangle.center", json!({"center": [0, 0], "corner": [20, 8]}));
|
||||
let line = ids(&run(&mut s, "sketch.line", json!({"points": [[-3, 1], [3, 1]], "connect": false}))["curves"])[0].clone();
|
||||
run(&mut s, "sketch.trim", json!({"curve": line, "at": [1, 1]}));
|
||||
let ends = lines(&s);
|
||||
assert!(ends.len() == 2 && close(ends[0][1], -2.5) && close(ends[1][0], 2.5), "{ends:?}");
|
||||
}
|
||||
|
||||
/// #10851: an endpoint's tangent must stay with the arc piece that owns that endpoint,
|
||||
@@ -2064,6 +2225,164 @@ fn ellipse_radii_dimensions() {
|
||||
assert!((a - std::f64::consts::PI * 60.0).abs() < 1e-6, "{a}");
|
||||
}
|
||||
|
||||
/// An ellipse comes with its major and minor axes as construction lines through its centre.
|
||||
/// They add no freedom (the ellipse keeps 5 degrees), follow its size, and stay when the
|
||||
/// ellipse is deleted, as a Center Rectangle's construction diagonals stay with its edges gone.
|
||||
#[test]
|
||||
fn an_ellipse_comes_with_its_axes_as_construction_lines() {
|
||||
let axes = |s: &Session| {
|
||||
let sk = sketch(s);
|
||||
let mut lengths: Vec<f64> = sk
|
||||
.curves
|
||||
.iter()
|
||||
.filter_map(|c| match c.kind {
|
||||
CurveKind::Line { a, b } if c.construction => Some(sk.point(a).unwrap().dist(sk.point(b).unwrap())),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
lengths.sort_by(f64::total_cmp);
|
||||
lengths
|
||||
};
|
||||
let mut s = new_sketch();
|
||||
let out = run(&mut s, "sketch.ellipse", json!({"center": [5, 3], "major": [25, 3], "minor_radius": 8}));
|
||||
let e = ids(&out["curves"])[0].clone();
|
||||
assert_eq!(out["created"]["curves"].as_array().map(Vec::len), Some(3), "{out}");
|
||||
assert_eq!(run(&mut s, "sketch.inspect", json!({}))["dof"], json!(5));
|
||||
let lengths = axes(&s);
|
||||
assert!(lengths.len() == 2 && close(lengths[0], 16.0) && close(lengths[1], 40.0), "{lengths:?}");
|
||||
assert!(profiles(&s).len() == 1 && close(profiles(&s)[0], std::f64::consts::PI * 160.0), "{:?}", profiles(&s));
|
||||
// Dragging either axis moves the ellipse and its axes as one, sizes kept, as dragging a
|
||||
// Center Rectangle's diagonal moves the rectangle.
|
||||
let half_axes = |s: &Session| {
|
||||
let sk = sketch(s);
|
||||
let Some(CurveKind::Ellipse { c, m, r }) = sk.curves.iter().map(|x| x.kind.clone()).find(|k| matches!(k, CurveKind::Ellipse { .. })) else {
|
||||
panic!("the ellipse")
|
||||
};
|
||||
(sk.point(c).unwrap(), sk.point(c).unwrap().dist(sk.point(m).unwrap()), r)
|
||||
};
|
||||
let (centre, ..) = half_axes(&s);
|
||||
let (major, minor) = {
|
||||
let sk = sketch(&s);
|
||||
let mut lines: Vec<(f64, String)> = sk
|
||||
.curves
|
||||
.iter()
|
||||
.filter_map(|c| match c.kind {
|
||||
CurveKind::Line { a, b } => Some((sk.point(a).unwrap().dist(sk.point(b).unwrap()), c.id.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
lines.sort_by(|x, y| y.0.total_cmp(&x.0));
|
||||
(lines[0].1.clone(), lines[1].1.clone())
|
||||
};
|
||||
let mut moved = centre;
|
||||
for (line, by) in [(&major, Vec2::new(4.0, 6.0)), (&minor, Vec2::new(-3.0, 2.0))] {
|
||||
let from = moved + if *line == major { Vec2::new(-12.0, 0.0) } else { Vec2::new(0.0, 4.0) };
|
||||
run(&mut s, "sketch.drag", json!({"entity": line, "from": [from.x, from.y], "to": [from.x + by.x, from.y + by.y]}));
|
||||
run(&mut s, "sketch.drag_end", json!({}));
|
||||
moved += by;
|
||||
let (at, a, b) = half_axes(&s);
|
||||
assert!(at.dist(moved) < 1e-6 && close(a, 20.0) && close(b, 8.0), "dragging {line}: centre {at:?}, half-axes {a} {b}");
|
||||
let lengths = axes(&s);
|
||||
assert!(close(lengths[0], 16.0) && close(lengths[1], 40.0), "dragging {line}: {lengths:?}");
|
||||
}
|
||||
// Dragging the outline still sets the minor half-axis, the axes following it.
|
||||
run(&mut s, "sketch.drag", json!({"entity": &e, "from": [moved.x, moved.y + 8.0], "to": [moved.x, moved.y + 10.0]}));
|
||||
run(&mut s, "sketch.drag_end", json!({}));
|
||||
let (at, a, b) = half_axes(&s);
|
||||
assert!(at.dist(moved) < 1e-6 && close(a, 20.0) && close(b, 10.0), "dragging the outline: centre {at:?}, half-axes {a} {b}");
|
||||
let lengths = axes(&s);
|
||||
assert!(close(lengths[0], 20.0) && close(lengths[1], 40.0), "dragging the outline: {lengths:?}");
|
||||
// Sizing the ellipse resizes its axes, and they stay through its centre.
|
||||
run(&mut s, "sketch.dimension", json!({"entities": [&e], "type": "major", "value": 30}));
|
||||
run(&mut s, "sketch.dimension", json!({"entities": [&e], "type": "minor", "value": 10}));
|
||||
let lengths = axes(&s);
|
||||
assert!(close(lengths[0], 20.0) && close(lengths[1], 60.0), "{lengths:?}");
|
||||
assert!(close(profiles(&s)[0], std::f64::consts::PI * 300.0), "{:?}", profiles(&s));
|
||||
// A double-click on the ellipse or on either axis selects all three, as one on a Center
|
||||
// Rectangle's edge or diagonal selects its edges and both diagonals.
|
||||
let curves: Vec<String> = sketch(&s).curves.iter().map(|c| c.id.clone()).collect();
|
||||
for id in &curves {
|
||||
let mut chain = ids(&run(&mut s, "sketch.chain", json!({"curve": id}))["curves"]);
|
||||
chain.sort();
|
||||
assert_eq!(chain, curves, "double-click on {id}");
|
||||
}
|
||||
// Deleting it leaves the two axes, still construction and still perpendicular, and still
|
||||
// bisected by the centre, which stays as a Center Rectangle's centre does.
|
||||
run(&mut s, "sketch.delete", json!({"entities": [&e]}));
|
||||
let sk = sketch(&s);
|
||||
assert_eq!(sk.curves.len(), 2);
|
||||
assert!(sk.curves.iter().all(|c| c.construction && matches!(c.kind, CurveKind::Line { .. })));
|
||||
assert!(sk.constraints.iter().any(|c| matches!(c.kind, ConstraintKind::Perpendicular { .. })));
|
||||
let centres: Vec<usize> =
|
||||
sk.constraints.iter().filter_map(|c| if let ConstraintKind::Midpoint { p, .. } = c.kind { Some(p) } else { None }).collect();
|
||||
assert!(centres.len() == 2 && centres[0] == centres[1], "both axes keep their midpoint on the centre: {:?}", sk.constraints);
|
||||
// The same as a Center Rectangle whose edges are deleted: its diagonals stay.
|
||||
let mut s = new_sketch();
|
||||
let edges = ids(&run(&mut s, "sketch.rectangle.center", json!({"center": [0, 0], "corner": [20, 10]}))["curves"]);
|
||||
assert_eq!(ids(&run(&mut s, "sketch.chain", json!({"curve": &edges[0]}))["curves"]).len(), 6);
|
||||
run(&mut s, "sketch.delete", json!({"entities": edges}));
|
||||
let sk = sketch(&s);
|
||||
assert!(sk.curves.len() == 2 && sk.curves.iter().all(|c| c.construction), "{:?}", sk.curves);
|
||||
// With axes: false (the Sketch preference off), the ellipse alone, as before its axes.
|
||||
let mut s = new_sketch();
|
||||
let r = run(&mut s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8, "axes": false}));
|
||||
let sk = sketch(&s);
|
||||
assert!(sk.curves.len() == 1 && sk.constraints.is_empty(), "{r}");
|
||||
assert_eq!(r["sketch"]["dof"], json!(5));
|
||||
let refused = s.execute("sketch.ellipse", &json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8, "axes": "false"}));
|
||||
assert!(refused.is_err_and(|e| e.to_string().contains("true or false")));
|
||||
}
|
||||
|
||||
/// An ellipse with its axes, the minor one (or the major one) then deleted: the ids of the
|
||||
/// ellipse and of the axis left.
|
||||
fn ellipse_with_one_axis(s: &mut Session, keep_major: bool) -> (String, String) {
|
||||
let e = ids(&run(s, "sketch.ellipse", json!({"center": [0, 0], "major": [20, 0], "minor_radius": 8}))["curves"])[0].clone();
|
||||
let sk = sketch(s);
|
||||
let mut lines: Vec<(f64, String)> = sk
|
||||
.curves
|
||||
.iter()
|
||||
.filter_map(|c| match c.kind {
|
||||
CurveKind::Line { a, b } => Some((sk.point(a).unwrap().dist(sk.point(b).unwrap()), c.id.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
lines.sort_by(|x, y| y.0.total_cmp(&x.0));
|
||||
let (kept, gone) = if keep_major { (&lines[0].1, &lines[1].1) } else { (&lines[1].1, &lines[0].1) };
|
||||
run(s, "sketch.delete", json!({"entities": [gone]}));
|
||||
(e, kept.clone())
|
||||
}
|
||||
|
||||
/// With one of its axes deleted, dragging the other still moves the ellipse with it, sizes kept.
|
||||
#[test]
|
||||
fn an_ellipse_s_remaining_axis_drags_it_along() {
|
||||
for (keep_major, from) in [(true, Vec2::new(-12.0, 0.0)), (false, Vec2::new(0.0, 4.0))] {
|
||||
let mut s = new_sketch();
|
||||
let (_, axis) = ellipse_with_one_axis(&mut s, keep_major);
|
||||
run(&mut s, "sketch.drag", json!({"entity": &axis, "from": [from.x, from.y], "to": [from.x + 4.0, from.y + 6.0]}));
|
||||
run(&mut s, "sketch.drag_end", json!({}));
|
||||
let sk = sketch(&s);
|
||||
let Some(CurveKind::Ellipse { c, m, r }) = sk.curves.iter().map(|x| x.kind.clone()).find(|k| matches!(k, CurveKind::Ellipse { .. })) else {
|
||||
panic!("the ellipse: {:?}", sk.curves)
|
||||
};
|
||||
let (at, a) = (sk.point(c).unwrap(), sk.point(c).unwrap().dist(sk.point(m).unwrap()));
|
||||
assert!(at.dist(Vec2::new(4.0, 6.0)) < 1e-6 && close(a, 20.0) && close(r, 8.0), "major kept {keep_major}: centre {at:?}, half-axes {a} {r}");
|
||||
}
|
||||
}
|
||||
|
||||
/// With one of its axes deleted, a double-click on the ellipse or the other axis selects both.
|
||||
#[test]
|
||||
fn an_ellipse_and_its_remaining_axis_are_one_chain() {
|
||||
let mut s = new_sketch();
|
||||
let (e, major) = ellipse_with_one_axis(&mut s, true);
|
||||
let mut both = vec![e.clone(), major.clone()];
|
||||
both.sort();
|
||||
for id in [&e, &major] {
|
||||
let mut chain = ids(&run(&mut s, "sketch.chain", json!({"curve": id}))["curves"]);
|
||||
chain.sort();
|
||||
assert_eq!(chain, both, "double-click on {id}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #1026: a construction diagonal ending at a rectangle's corner is not one of the corner's
|
||||
/// sides. The corner is rounded, and the diagonal keeps its end on the virtual sharp corner.
|
||||
#[test]
|
||||
@@ -2390,7 +2709,8 @@ fn certified_offset_delete_output_undo_reopen_and_refuse_dependent_source() {
|
||||
run(&mut s, "sketch.delete", json!({"entities":[node]}));
|
||||
assert!(sketch(&s).freeform_offsets.is_empty());
|
||||
assert!(sketch(&s).curve_index(&id).is_none());
|
||||
assert_eq!(sketch(&s).points.len(), 3, "all private derived nodes must be removed");
|
||||
// The origin, the ellipse's centre and major end, and its three other axis ends.
|
||||
assert_eq!(sketch(&s).points.len(), 6, "all private derived nodes must be removed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -161,7 +161,8 @@ fn fixing_curves_holds_their_points_and_radius() {
|
||||
assert_eq!(r["result"]["changed"], 4);
|
||||
assert_eq!(dof(&mut s), free - 17);
|
||||
let si = run(&mut s, "sketch.inspect", json!({}));
|
||||
assert!(si["curves"].as_array().is_some_and(|c| c.iter().all(|c| c["fixed"] == true)), "{si}");
|
||||
// The ellipse's construction axes were not picked.
|
||||
assert!(si["curves"].as_array().is_some_and(|c| c.iter().filter(|c| c["construction"] != true).all(|c| c["fixed"] == true)), "{si}");
|
||||
// A fixed circle keeps centre and radius; a dimension on it conflicts.
|
||||
run(&mut s, "sketch.move_point", json!({"point": "c1.center", "to": [0, 0]}));
|
||||
assert_eq!(pt(&s, "c1.center"), solidcore_record::Vec2::new(10.0, 10.0));
|
||||
@@ -1513,6 +1514,301 @@ fn auto_dimension_orientation_follows_where_its_text_is_placed() {
|
||||
assert!(((end.x - start.x).abs() - 24.0).abs() < 1e-6 && ((end.y - start.y).abs() - 40.0).abs() < 1e-6, "{start:?} {end:?}");
|
||||
}
|
||||
|
||||
/// An ellipse with half-axes 20 and 8, turned by 45 degrees when asked: its id, and its
|
||||
/// construction axis lines, major first.
|
||||
fn ellipse_with_axes(s: &mut Session, turn: bool) -> (String, String, String) {
|
||||
let at = |x: f64, y: f64| if turn { [std::f64::consts::FRAC_1_SQRT_2 * (x - y), std::f64::consts::FRAC_1_SQRT_2 * (x + y)] } else { [x, y] };
|
||||
let e = run(s, "sketch.ellipse", json!({"center": [0, 0], "major": at(20.0, 0.0), "minor_radius": 8}))["curves"][0]
|
||||
.as_str()
|
||||
.expect("the ellipse")
|
||||
.to_string();
|
||||
let sk = sketch(s);
|
||||
let mut lines: Vec<(f64, String)> = sk
|
||||
.curves
|
||||
.iter()
|
||||
.filter_map(|c| match c.kind {
|
||||
solidcraft_sketch::CurveKind::Line { a, b } if c.construction => Some((sk.point(a)?.dist(sk.point(b)?), c.id.clone())),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
lines.sort_by(|x, y| y.0.total_cmp(&x.0));
|
||||
let [(_, major), (_, minor)] = <[(f64, String); 2]>::try_from(lines).expect("two axis lines");
|
||||
(e, major, minor)
|
||||
}
|
||||
|
||||
/// D on an ellipse's outline gives a half-axis, the distance from the centre to an axis end,
|
||||
/// chosen as a line chooses horizontal or vertical, in the ellipse's own frame: text pulled
|
||||
/// across the major axis measures along it, text pulled out past an end of it measures across
|
||||
/// it. Near the boundary a placement keeps the half-axis it had. D on an axis line gives the
|
||||
/// whole axis. An ellipse without axes keeps its minor radius.
|
||||
#[test]
|
||||
fn an_ellipse_half_axis_dimension_follows_where_its_text_is_pulled() {
|
||||
use solidcraft_sketch::ConstraintKind;
|
||||
let dimension = |turn: bool, extra: Value| {
|
||||
let mut s = new_sketch();
|
||||
let (e, ..) = ellipse_with_axes(&mut s, turn);
|
||||
let mut p = json!({"entities": [e]});
|
||||
if let (Some(p), Some(extra)) = (p.as_object_mut(), extra.as_object()) {
|
||||
p.extend(extra.clone());
|
||||
}
|
||||
let r = run(&mut s, "sketch.dimension", p);
|
||||
let sk = sketch(&s);
|
||||
let kind = sk.constraints.iter().find(|c| c.kind.is_dimension()).map(|c| c.kind.clone()).expect("a dimension");
|
||||
let ConstraintKind::Distance { p, q, .. } = kind else { return ("radius".to_string(), 0.0, r) };
|
||||
let (pc, end) = (sk.point(p).expect("centre"), sk.point(q).expect("axis end"));
|
||||
assert!(pc.len() < 1e-9, "measured from the centre: {pc:?}");
|
||||
let which = if (pc.dist(end) - 20.0).abs() < 1e-6 { "major" } else { "minor" };
|
||||
assert_eq!(r["axis"], json!(which), "{r}");
|
||||
// The end on the text's side.
|
||||
let side = extra.get("text_at").and_then(Value::as_array).map(|t| (t[0].as_f64().unwrap_or(0.0), t[1].as_f64().unwrap_or(0.0)));
|
||||
(which.to_string(), side.map_or(1.0, |(x, y)| end.x * x + end.y * y), r)
|
||||
};
|
||||
let turned = |x: f64, y: f64, turn: bool| {
|
||||
if turn { [std::f64::consts::FRAC_1_SQRT_2 * (x - y), std::f64::consts::FRAC_1_SQRT_2 * (x + y)] } else { [x, y] }
|
||||
};
|
||||
for turn in [false, true] {
|
||||
for ((x, y), expected) in [
|
||||
((3.0, 16.0), "major"),
|
||||
((-4.0, -14.0), "major"),
|
||||
((18.0, 12.0), "major"),
|
||||
((30.0, 3.0), "minor"),
|
||||
((-28.0, -2.0), "minor"),
|
||||
((24.0, 6.0), "minor"),
|
||||
] {
|
||||
let (which, side, r) = dimension(turn, json!({"text_at": turned(x, y, turn)}));
|
||||
assert_eq!(which, expected, "turned {turn}, text at ({x}, {y}): {r}");
|
||||
assert!(side > 0.0, "turned {turn}, text at ({x}, {y}): the end on the other side");
|
||||
}
|
||||
// Near the boundary (0.5 of the major half-axis along, 0.55 or 0.45 of the minor
|
||||
// across) the half-axis a placement had is kept, from either side; well past it, it is not.
|
||||
let near = json!(turned(10.0, 4.4, turn));
|
||||
assert_eq!(dimension(turn, json!({"text_at": near})).0, "major");
|
||||
assert_eq!(dimension(turn, json!({"text_at": near, "previous_axis": "minor"})).0, "minor");
|
||||
let near = json!(turned(10.0, 3.6, turn));
|
||||
assert_eq!(dimension(turn, json!({"text_at": near})).0, "minor");
|
||||
assert_eq!(dimension(turn, json!({"text_at": near, "previous_axis": "major"})).0, "major");
|
||||
assert_eq!(dimension(turn, json!({"text_at": turned(16.0, 4.0, turn), "previous_axis": "major"})).0, "minor");
|
||||
}
|
||||
// An explicit type wins; with no text, the minor half-axis; radius, and any other type,
|
||||
// stays the minor radius as on an ellipse without axes.
|
||||
assert_eq!(dimension(false, json!({"type": "major", "text_at": [30, 3]})).0, "major");
|
||||
assert_eq!(dimension(false, json!({"type": "minor", "text_at": [3, 16]})).0, "minor");
|
||||
assert_eq!(dimension(false, json!({})).0, "minor");
|
||||
assert_eq!(dimension(false, json!({"type": "radius", "text_at": [3, 16]})).0, "radius");
|
||||
assert_eq!(dimension(false, json!({"type": "diameter", "text_at": [3, 16]})).0, "radius");
|
||||
assert_eq!(dimension(false, json!({"type": "horizontal", "text_at": [3, 16]})).0, "radius");
|
||||
// With half_axes false (Draw ellipses with their axes off), auto is the minor radius
|
||||
// wherever the text is, as before half-axes; an explicit type still gives its half-axis.
|
||||
for at in [[3.0, 16.0], [30.0, 3.0]] {
|
||||
assert_eq!(dimension(false, json!({"half_axes": false, "text_at": at})).0, "radius", "text at {at:?}");
|
||||
}
|
||||
assert_eq!(dimension(false, json!({"half_axes": false, "type": "major"})).0, "major");
|
||||
let mut s = new_sketch();
|
||||
let (e, ..) = ellipse_with_axes(&mut s, false);
|
||||
assert!(s.execute("sketch.dimension", &json!({"entities": [e], "half_axes": "no"})).is_err());
|
||||
// An axis line is a line: its length is the whole axis.
|
||||
let mut s = new_sketch();
|
||||
let (_, major, minor) = ellipse_with_axes(&mut s, true);
|
||||
assert_eq!(run(&mut s, "sketch.dimension", json!({"entities": [major]}))["measured"], json!(40.0));
|
||||
assert_eq!(run(&mut s, "sketch.dimension", json!({"entities": [minor]}))["measured"], json!(16.0));
|
||||
// Also with the text beside or above the box a turned axis spans, where a free line gives
|
||||
// its horizontal or vertical distance; and it holds that half-axis, so D on the outline
|
||||
// then gives the other one.
|
||||
for (axis, at, whole) in [("major", [30.0, 0.0], 40.0), ("major", [0.0, -30.0], 40.0), ("minor", [20.0, 0.0], 16.0), ("minor", [0.0, 20.0], 16.0)]
|
||||
{
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, true);
|
||||
let line = if axis == "major" { major } else { minor };
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [line], "text_at": at}));
|
||||
assert!(r["measured"].as_f64().is_some_and(|v| (v - whole).abs() < 1e-6), "{axis} axis, text at {at:?}: {r}");
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": [3, 16]}));
|
||||
assert_ne!(r["axis"], json!(axis), "{axis} axis, text at {at:?}: {r}");
|
||||
}
|
||||
// With one axis deleted the half-axis is still chosen by where the text is, as if the axis
|
||||
// were there: the major half-axis to the major end, the minor one to what is left of its axis
|
||||
// or, with that gone, as the minor radius.
|
||||
let placed = |gone: &str, extra: Value| {
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, true);
|
||||
run(&mut s, "sketch.delete", json!({"entities": [if gone == "major" { major } else { minor }]}));
|
||||
let mut p = json!({"entities": [e]});
|
||||
if let (Some(p), Some(extra)) = (p.as_object_mut(), extra.as_object()) {
|
||||
p.extend(extra.clone());
|
||||
}
|
||||
let r = run(&mut s, "sketch.dimension", p);
|
||||
let sk = sketch(&s);
|
||||
let kind = sk.constraints.iter().find(|c| c.kind.is_dimension()).map(|c| c.kind.clone()).expect("a dimension");
|
||||
// Where the dimension ends: the axis end it measures to, none for a radius.
|
||||
let end = match kind {
|
||||
ConstraintKind::Distance { q, .. } => sk.point(q),
|
||||
ConstraintKind::Radius { .. } => None,
|
||||
other => panic!("a half-axis, not {other:?}"),
|
||||
};
|
||||
(r, end)
|
||||
};
|
||||
for gone in ["major", "minor"] {
|
||||
for ((x, y), expected) in [((3.0, 16.0), "major"), ((-4.0, -14.0), "major"), ((30.0, 3.0), "minor"), ((-28.0, -2.0), "minor")] {
|
||||
let at = [std::f64::consts::FRAC_1_SQRT_2 * (x - y), std::f64::consts::FRAC_1_SQRT_2 * (x + y)];
|
||||
let (r, end) = placed(gone, json!({"text_at": at}));
|
||||
assert_eq!(r["axis"], json!(expected), "{gone} axis deleted, text at ({x}, {y}): {r}");
|
||||
let want = if expected == "major" { 20.0 } else { 8.0 };
|
||||
assert!(r["measured"].as_f64().is_some_and(|v| (v - want).abs() < 1e-6), "{gone} axis deleted, text at ({x}, {y}): {r}");
|
||||
// To the axis end on the text's side while there is one: the major end from either
|
||||
// side once the point opposite is gone, a radius once the minor axis is.
|
||||
match (gone, expected) {
|
||||
("minor", "minor") => assert!(end.is_none(), "the minor radius: {r}"),
|
||||
("major", "major") => {
|
||||
let m = solidcore_record::Vec2::new(20.0, 20.0) * std::f64::consts::FRAC_1_SQRT_2;
|
||||
assert!(end.is_some_and(|q| q.dist(m) < 1e-6), "the major end: {r}")
|
||||
}
|
||||
_ => assert!(
|
||||
end.is_some_and(|q| q.x * at[0] + q.y * at[1] > 0.0),
|
||||
"{gone} axis deleted, text at ({x}, {y}): the end on the other side"
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
// With the major axis deleted and no text, the minor half-axis to its axis end, named in
|
||||
// the reply as with both axes.
|
||||
let (r, end) = placed("major", json!({}));
|
||||
assert_eq!((r["axis"].clone(), r["type"].clone()), (json!("minor"), json!("LinearDimension")), "{r}");
|
||||
assert!(end.is_some_and(|q| (q.len() - 8.0).abs() < 1e-6), "{r}");
|
||||
// Without its axes (an older design, or both deleted) the half-axis is still chosen by
|
||||
// where the text is: the major one to the ellipse's own major end, the minor one as its
|
||||
// minor radius; with no text, the minor radius as before.
|
||||
for ((x, y), expected, want) in [((3.0, 16.0), "major", 20.0), ((-4.0, -14.0), "major", 20.0), ((30.0, 3.0), "minor", 8.0)] {
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, false);
|
||||
run(&mut s, "sketch.delete", json!({"entities": [major, minor]}));
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": [x, y]}));
|
||||
assert_eq!(r["axis"], json!(expected), "text at ({x}, {y}): {r}");
|
||||
assert!(r["measured"].as_f64().is_some_and(|v| (v - want).abs() < 1e-6), "text at ({x}, {y}): {r}");
|
||||
}
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, false);
|
||||
run(&mut s, "sketch.delete", json!({"entities": [major, minor]}));
|
||||
run(&mut s, "sketch.dimension", json!({"entities": [e]}));
|
||||
assert!(sketch(&s).constraints.iter().any(|c| matches!(c.kind, ConstraintKind::Radius { .. })));
|
||||
// The mirror of an ellipse has no axes (Mirror copies no midpoints): D on it reaches the
|
||||
// major half-axis as well.
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, false);
|
||||
run(&mut s, "sketch.delete", json!({"entities": [minor]}));
|
||||
let line = run(&mut s, "sketch.line", json!({"points": [[40, -30], [40, 30]], "connect": false}))["curves"][0].as_str().unwrap().to_string();
|
||||
let copy = run(&mut s, "sketch.mirror", json!({"entities": [e, major], "line": line}))["curves"][0].as_str().unwrap().to_string();
|
||||
let sk = sketch(&s);
|
||||
assert!(sk.ellipse_axis_lines(sk.curve_index(©).unwrap()).is_none(), "the mirror has no axes");
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [copy], "text_at": [77, 16]}));
|
||||
assert_eq!((r["axis"].clone(), r["measured"].clone()), (json!("major"), json!(20.0)), "{r}");
|
||||
}
|
||||
|
||||
/// With one half-axis already dimensioned, D on the outline gives the other one wherever the
|
||||
/// text is pulled: guessing the one that is already there would only be refused. Either order,
|
||||
/// with both axes, with one deleted and with none.
|
||||
#[test]
|
||||
fn an_ellipse_s_second_half_axis_is_the_one_not_yet_dimensioned() {
|
||||
for gone in [&[][..], &["major"][..], &["minor"][..], &["major", "minor"][..]] {
|
||||
for (first, at, second) in [("major", [3.0, 16.0], "minor"), ("minor", [30.0, 3.0], "major")] {
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, false);
|
||||
let deleted: Vec<String> = gone.iter().map(|g| if *g == "major" { major.clone() } else { minor.clone() }).collect();
|
||||
if !deleted.is_empty() {
|
||||
run(&mut s, "sketch.delete", json!({"entities": deleted}));
|
||||
}
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": at}));
|
||||
assert_eq!(r["axis"], json!(first), "{gone:?}: {r}");
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": at}));
|
||||
assert_eq!(r["axis"], json!(second), "{gone:?}, {first} first, then text at {at:?} again: {r}");
|
||||
assert!(r["param"].is_string(), "{gone:?}: the second one drives: {r}");
|
||||
}
|
||||
}
|
||||
// The whole axis held counts too: as a distance between its ends, or as its line's length
|
||||
// with the other axis deleted.
|
||||
for axis in ["major", "minor"] {
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, false);
|
||||
let line = if axis == "major" { &major } else { &minor };
|
||||
run(&mut s, "sketch.dimension", json!({"entities": [format!("{line}.start"), format!("{line}.end")], "type": "distance"}));
|
||||
let at = if axis == "major" { [3.0, 16.0] } else { [30.0, 3.0] };
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": at}));
|
||||
assert_ne!(r["axis"], json!(axis), "{axis} held between its ends: {r}");
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, false);
|
||||
let (line, other) = if axis == "major" { (major, minor) } else { (minor, major) };
|
||||
run(&mut s, "sketch.delete", json!({"entities": [other]}));
|
||||
run(&mut s, "sketch.dimension", json!({"entities": [line]}));
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": at}));
|
||||
assert_ne!(r["axis"], json!(axis), "{axis} held by its line, the other axis deleted: {r}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A horizontal dimension across a level major axis is its length, so D on the outline then
|
||||
/// gives the minor half-axis; across a slanted axis it is only a projection, and the major
|
||||
/// half-axis is still free to take.
|
||||
#[test]
|
||||
fn a_horizontal_dimension_across_a_level_major_axis_counts_as_holding_it() {
|
||||
for turn in [false, true] {
|
||||
let mut s = new_sketch();
|
||||
let (e, major, _) = ellipse_with_axes(&mut s, turn);
|
||||
run(&mut s, "sketch.dimension", json!({"entities": [format!("{major}.start"), format!("{major}.end")], "type": "horizontal"}));
|
||||
let at = if turn { [std::f64::consts::FRAC_1_SQRT_2 * (3.0 - 16.0), std::f64::consts::FRAC_1_SQRT_2 * (3.0 + 16.0)] } else { [3.0, 16.0] };
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": at}));
|
||||
let want = if turn { "major" } else { "minor" };
|
||||
assert_eq!(r["axis"], json!(want), "turned {turn}: {r}");
|
||||
assert!(r["param"].is_string(), "turned {turn}: it drives: {r}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The same for the minor axis: a vertical dimension across its ends holds it while it stands
|
||||
/// upright, so D with the text out past the major axis's end then gives the major half-axis.
|
||||
#[test]
|
||||
fn a_vertical_dimension_across_an_upright_minor_axis_counts_as_holding_it() {
|
||||
for turn in [false, true] {
|
||||
let mut s = new_sketch();
|
||||
let (e, _, minor) = ellipse_with_axes(&mut s, turn);
|
||||
run(&mut s, "sketch.dimension", json!({"entities": [format!("{minor}.start"), format!("{minor}.end")], "type": "vertical"}));
|
||||
let at = if turn { [std::f64::consts::FRAC_1_SQRT_2 * (30.0 - 3.0), std::f64::consts::FRAC_1_SQRT_2 * (30.0 + 3.0)] } else { [30.0, 3.0] };
|
||||
let r = run(&mut s, "sketch.dimension", json!({"entities": [e], "text_at": at}));
|
||||
let want = if turn { "minor" } else { "major" };
|
||||
assert_eq!(r["axis"], json!(want), "turned {turn}: {r}");
|
||||
assert!(r["param"].is_string(), "turned {turn}: it drives: {r}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A half-axis and its whole axis are one dimension: whichever comes second is determined by
|
||||
/// the first, so the Dimension tool's `if_redundant: "driven"` adds it as a reference, and
|
||||
/// without it the command refuses it. Both orders, both axes. After the whole axis, D on the
|
||||
/// outline with no type gives the other half-axis, the one not yet held; the same half-axis
|
||||
/// is asked for by its type.
|
||||
#[test]
|
||||
fn an_ellipse_half_axis_and_its_whole_axis_determine_each_other() {
|
||||
for (axis, text_at) in [("major", [3.0, 16.0]), ("minor", [30.0, 3.0])] {
|
||||
for half_first in [true, false] {
|
||||
let mut s = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut s, false);
|
||||
let line = if axis == "major" { major } else { minor };
|
||||
let half = json!({"entities": [e], "text_at": text_at, "type": axis});
|
||||
let whole = json!({"entities": [line]});
|
||||
if !half_first {
|
||||
let mut t = new_sketch();
|
||||
let (e, major, minor) = ellipse_with_axes(&mut t, false);
|
||||
run(&mut t, "sketch.dimension", json!({"entities": [if axis == "major" { major } else { minor }]}));
|
||||
let r = run(&mut t, "sketch.dimension", json!({"entities": [e], "text_at": text_at}));
|
||||
assert_ne!(r["axis"], json!(axis), "{axis}: after the whole axis, the other half-axis: {r}");
|
||||
}
|
||||
let (first, second) = if half_first { (half, whole) } else { (whole, half) };
|
||||
let r = run(&mut s, "sketch.dimension", first);
|
||||
assert!(r["param"].is_string(), "{axis}: the first one drives: {r}");
|
||||
let refused = s.execute("sketch.dimension", &second).expect_err("the second one is determined").to_string();
|
||||
assert!(refused.contains("already determined"), "{axis}: {refused}");
|
||||
let mut second = second;
|
||||
second["if_redundant"] = json!("driven");
|
||||
let r = run(&mut s, "sketch.dimension", second);
|
||||
assert_eq!((r["redundant"].clone(), r["driven"].clone()), (json!(true), json!(true)), "{axis}, half first {half_first}: {r}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A two-link arm (B, elbow E, hand H) hanging off a rigid triangle A B C that only the cluster
|
||||
/// decomposition places: pinned at F by two of its corners and held at G by the third. Every
|
||||
/// line is dimensioned. Without decomposition budget the elbow's seed has nothing to build on.
|
||||
@@ -1616,6 +1912,44 @@ fn a_scripted_drag_solves_the_steps_past_a_failure_at_once_and_ends_where_one_by
|
||||
assert_eq!((solves2.count, solves2.work), (solves1.count, solves1.work));
|
||||
}
|
||||
|
||||
/// #7648: past a failed step, the first step solved ahead that solves becomes the sketch, so the
|
||||
/// walk doesn't solve it again, and a batch holds one step per core. The drag still ends where
|
||||
/// one by one ends it, with the same held solves counted. Out past the arm's reach, and swung
|
||||
/// round through the shoulder's hole and out of it again (a step fails, a later one solves).
|
||||
#[test]
|
||||
fn a_step_solved_ahead_that_solves_is_taken_not_solved_again() {
|
||||
use super::drag::last_drag;
|
||||
let start = hung_arm();
|
||||
let h = pt(&start, "eh.end");
|
||||
let points = |s: &Session| s.doc.sketch(s.active_sketch.unwrap()).unwrap().points.iter().map(|p| (p.id.clone(), p.pos)).collect::<Vec<_>>();
|
||||
let cores = std::thread::available_parallelism().map_or(1, usize::from);
|
||||
let mut taken_all = 0;
|
||||
for (angle, scale) in [(2.0, 1.5), (3.1, 1.0)] {
|
||||
let far = hung_hand_target(&start, angle, scale);
|
||||
let drag = |s: &mut Session| run(s, "sketch.drag", json!({"entity": "eh.end", "from": [h.x, h.y], "to": [far.x, far.y]}));
|
||||
let mut one = hung_arm();
|
||||
let r1 = last_drag::one_by_one(|| drag(&mut one));
|
||||
let solves1 = last_drag::get();
|
||||
assert_eq!(last_drag::ahead_counts(), (0, 0), "one by one solves nothing ahead");
|
||||
last_drag::skipped();
|
||||
let mut ahead = hung_arm();
|
||||
let r2 = drag(&mut ahead);
|
||||
let solves2 = last_drag::get();
|
||||
let (solved_ahead, taken) = last_drag::ahead_counts();
|
||||
let skipped = last_drag::skipped();
|
||||
assert_eq!(r2, r1, "{angle}");
|
||||
assert_eq!(points(&ahead), points(&one), "{angle}");
|
||||
assert_eq!((solves2.count, solves2.work), (solves1.count, solves1.work), "{angle}");
|
||||
// What a batch solved is tried steps, the step taken, and the steps past it, which ran
|
||||
// beside them on other cores.
|
||||
assert!(skipped + taken <= solved_ahead, "{angle}: {solved_ahead} solved ahead, {skipped} tried, {taken} taken");
|
||||
taken_all += taken;
|
||||
}
|
||||
if cores > 1 {
|
||||
assert!(taken_all > 0, "the walk went on from a step solved ahead");
|
||||
}
|
||||
}
|
||||
|
||||
/// All the held solves of one live frame, halvings included, share one decomposition budget:
|
||||
/// together they do at most a frame's work, and one solve's more.
|
||||
#[test]
|
||||
|
||||
@@ -6,12 +6,13 @@ use solidcraft_render::{Camera, StandardView};
|
||||
use super::CommandSpec;
|
||||
use crate::params::{bad, num, req_vec2, req_vec3, vec3};
|
||||
use crate::schema::view_navigation::{
|
||||
CameraReply, NormalToParams, RenderBrowser, RenderFocus, RenderSelect, StandardViewParams, TabStep, TabStepParams,
|
||||
CameraReply, NavigatorParams, NormalToParams, RenderBrowser, RenderFocus, RenderSelect, StandardViewParams, TabStep, TabStepParams,
|
||||
};
|
||||
use crate::schema::{TypedContract, output_schema_for};
|
||||
use crate::{Result, Sel, Session};
|
||||
|
||||
const FOCUS_CONTRACT: TypedContract<RenderFocus> = TypedContract::new();
|
||||
const NAVIGATOR_CONTRACT: TypedContract<NavigatorParams> = TypedContract::new();
|
||||
const BROWSER_CONTRACT: TypedContract<RenderBrowserRequest> = TypedContract::new();
|
||||
const TAB_STEP_CONTRACT: TypedContract<TabStepParams> = TypedContract::new();
|
||||
const STANDARD_VIEW_CONTRACT: TypedContract<StandardViewParams> = TypedContract::new();
|
||||
@@ -50,20 +51,24 @@ CommandSpec::new("view.status_items", "Viewport Status Items", crate::checked!("
|
||||
.params("no parameters → {items}; persistent viewport effects, oldest slot first, with structured settings and executable clear requests; read-only, no model evaluation"),
|
||||
CommandSpec::new("view.fit", "Fit", fit)
|
||||
.icon("fit").key("F6").noundo().doc_only().params("no parameters → frame the active canvas or selection; display only"),
|
||||
CommandSpec::new("view.home", "Home view", home)
|
||||
CommandSpec::new("view.home", "Home View", home)
|
||||
.icon("home").noundo().doc_only().params("no parameters → home orientation framing the active canvas; display only"),
|
||||
CommandSpec::new("view.tool", "Navigation tool", tool)
|
||||
CommandSpec::new("view.tool", "Navigation Tool", tool)
|
||||
.icon("orbit").noundo().doc_only().params("tool: orbit|pan|zoom|none → tool; latch a camera tool, none releases it"),
|
||||
CommandSpec::new("view.spin", "Continuous orbit", spin)
|
||||
CommandSpec::new("view.spin", "Continuous Orbit", spin)
|
||||
.icon("spin").noundo().doc_only().params("on?: bool (omitted: toggle) → on?; continuous orbit until the next click or key"),
|
||||
CommandSpec::new("view.visual_style", "Visual style", visual_style)
|
||||
CommandSpec::new("view.visual_style", "Visual Style", visual_style)
|
||||
.icon("style").noundo().doc_only().params("style: shaded_with_edges|shaded|wireframe|shaded_with_hidden_edges → style, index (0..3 in that order)"),
|
||||
CommandSpec::new("view.grid", "Grid", grid)
|
||||
.icon("style").noundo().doc_only().params("on?: bool (omitted: toggle) → on?; show the viewport grid"),
|
||||
CommandSpec::new("view.ground_shadow", "Ground shadow", ground_shadow)
|
||||
CommandSpec::new("view.ground_shadow", "Ground Shadow", ground_shadow)
|
||||
.icon("style").noundo().doc_only().params("on?: bool (omitted: toggle) → on?; show the ground shadow"),
|
||||
CommandSpec::new("view.navigation_bar", "Navigation bar", navigation_bar)
|
||||
CommandSpec::new("view.navigation_bar", "Navigation Bar", navigation_bar)
|
||||
.icon("pan").noundo().doc_only().params("visible?: bool (omitted: toggle) → visible?; show the navigation bar (window setting)"),
|
||||
CommandSpec::new("view.navigator", "Custom View Navigator", crate::checked!("view.navigator", navigator))
|
||||
.icon("nav_settings").noundo().doc_only()
|
||||
.contract(&NAVIGATOR_CONTRACT).output(output_schema_for::<NavigatorParams>)
|
||||
.params("style?: axes|cube|custom; body?: body name|null; texture?: themed|modeled; arrows?, home?: bool → the navigator as set; the app's view navigator, never saved in the design; never opens a dialog (a toolbar start opens the Custom View Navigator panel)"),
|
||||
CommandSpec::new("view.render_focus", "Render Focus View", crate::checked!("view.render_focus", render_focus))
|
||||
.icon("render_scene").noundo().doc_only()
|
||||
.contract(&FOCUS_CONTRACT).output(output_schema_for::<RenderFocus>)
|
||||
@@ -324,6 +329,18 @@ fn status_items(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!(crate::status_items::StatusItems { items: s.status_items() }))
|
||||
}
|
||||
|
||||
/// The app sets the navigator; the engine checks the parameters and that a named body exists.
|
||||
fn navigator(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "view.navigator";
|
||||
let request: NavigatorParams = serde_json::from_value(if p.is_null() { json!({}) } else { p.clone() }).map_err(|e| bad(cmd, e.to_string()))?;
|
||||
if let Some(Some(name)) = &request.body
|
||||
&& s.world_state()?.body(name).is_none()
|
||||
{
|
||||
return Err(bad(cmd, format!("no body named `{name}`")));
|
||||
}
|
||||
serde_json::to_value(request).map_err(|e| bad(cmd, e.to_string()))
|
||||
}
|
||||
|
||||
fn render_focus(_s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let request: RenderFocus = serde_json::from_value(p.clone()).map_err(|e| bad("view.render_focus", e.to_string()))?;
|
||||
Ok(json!(request))
|
||||
|
||||