From a817a624403ec17c861d9da0a23d3d8ba7bb7577 Mon Sep 17 00:00:00 2001 From: Irakli Kourtis Date: Tue, 13 Oct 2026 15:19:06 -0400 Subject: [PATCH] Meshing test corpus built with SolidCraft; assembly placement in open_design (#11) * geometry: build designs from SolidCraft command scripts (feature scripts) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm * geometry: place component bodies through their occurrences when opening a design An assembly's instances were missing and moved components sat at their own origin. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm * Meshing test corpus: 16 SolidCraft recipes, analytic shapes, loader and runner modelcraft-testkit holds the corpus (tests/corpus//recipe.json run through SolidCraft's engine, then opened as a design) and the runner binary behind cargo xtask corpus. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm * docs: corpus results, test corpus architecture and the scripts feature; licences Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm * corpus: measure each body once, check stage widths, simpler loader and runner Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm --------- Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- Cargo.lock | 123 +++ Cargo.toml | 4 + ROADMAP.md | 2 +- THIRD-PARTY-LICENSES.txt | 753 +++++++++++++++++-- crates/geometry/Cargo.toml | 7 + crates/geometry/src/design.rs | 7 +- crates/geometry/src/lib.rs | 34 +- crates/geometry/src/script.rs | 88 +++ crates/testkit/Cargo.toml | 15 + crates/testkit/src/bin/corpus.rs | 30 + crates/testkit/src/corpus.rs | 318 ++++++++ crates/testkit/src/lib.rs | 11 + crates/testkit/src/runner.rs | 182 +++++ docs/adr/0001-libraries.md | 3 + docs/architecture.md | 19 + docs/meshing/corpus.md | 74 ++ tests/corpus/bent-tube/README.md | 1 + tests/corpus/bent-tube/recipe.json | 9 + tests/corpus/bolted-assembly/README.md | 1 + tests/corpus/bolted-assembly/recipe.json | 11 + tests/corpus/cross-cylinders/README.md | 1 + tests/corpus/cross-cylinders/recipe.json | 5 + tests/corpus/filleted-bracket/README.md | 1 + tests/corpus/filleted-bracket/recipe.json | 10 + tests/corpus/i-beam/README.md | 1 + tests/corpus/i-beam/recipe.json | 7 + tests/corpus/loft-transition/README.md | 1 + tests/corpus/loft-transition/recipe.json | 11 + tests/corpus/perforated-plate/README.md | 1 + tests/corpus/perforated-plate/recipe.json | 31 + tests/corpus/pinhole-block/README.md | 1 + tests/corpus/pinhole-block/recipe.json | 23 + tests/corpus/rounded-box/README.md | 1 + tests/corpus/rounded-box/recipe.json | 5 + tests/corpus/shallow-groove/README.md | 1 + tests/corpus/shallow-groove/recipe.json | 5 + tests/corpus/sharp-wedge/README.md | 1 + tests/corpus/sharp-wedge/recipe.json | 7 + tests/corpus/sphere-on-plate/README.md | 1 + tests/corpus/sphere-on-plate/recipe.json | 5 + tests/corpus/spline-vase/README.md | 1 + tests/corpus/spline-vase/recipe.json | 9 + tests/corpus/stepped-block/README.md | 1 + tests/corpus/stepped-block/recipe.json | 7 + tests/corpus/thin-ribs/README.md | 1 + tests/corpus/thin-ribs/recipe.json | 9 + tests/corpus/thin-wall-enclosure/README.md | 1 + tests/corpus/thin-wall-enclosure/recipe.json | 5 + xtask/src/main.rs | 9 + 49 files changed, 1770 insertions(+), 84 deletions(-) create mode 100644 crates/geometry/src/script.rs create mode 100644 crates/testkit/Cargo.toml create mode 100644 crates/testkit/src/bin/corpus.rs create mode 100644 crates/testkit/src/corpus.rs create mode 100644 crates/testkit/src/lib.rs create mode 100644 crates/testkit/src/runner.rs create mode 100644 docs/meshing/corpus.md create mode 100644 tests/corpus/bent-tube/README.md create mode 100644 tests/corpus/bent-tube/recipe.json create mode 100644 tests/corpus/bolted-assembly/README.md create mode 100644 tests/corpus/bolted-assembly/recipe.json create mode 100644 tests/corpus/cross-cylinders/README.md create mode 100644 tests/corpus/cross-cylinders/recipe.json create mode 100644 tests/corpus/filleted-bracket/README.md create mode 100644 tests/corpus/filleted-bracket/recipe.json create mode 100644 tests/corpus/i-beam/README.md create mode 100644 tests/corpus/i-beam/recipe.json create mode 100644 tests/corpus/loft-transition/README.md create mode 100644 tests/corpus/loft-transition/recipe.json create mode 100644 tests/corpus/perforated-plate/README.md create mode 100644 tests/corpus/perforated-plate/recipe.json create mode 100644 tests/corpus/pinhole-block/README.md create mode 100644 tests/corpus/pinhole-block/recipe.json create mode 100644 tests/corpus/rounded-box/README.md create mode 100644 tests/corpus/rounded-box/recipe.json create mode 100644 tests/corpus/shallow-groove/README.md create mode 100644 tests/corpus/shallow-groove/recipe.json create mode 100644 tests/corpus/sharp-wedge/README.md create mode 100644 tests/corpus/sharp-wedge/recipe.json create mode 100644 tests/corpus/sphere-on-plate/README.md create mode 100644 tests/corpus/sphere-on-plate/recipe.json create mode 100644 tests/corpus/spline-vase/README.md create mode 100644 tests/corpus/spline-vase/recipe.json create mode 100644 tests/corpus/stepped-block/README.md create mode 100644 tests/corpus/stepped-block/recipe.json create mode 100644 tests/corpus/thin-ribs/README.md create mode 100644 tests/corpus/thin-ribs/recipe.json create mode 100644 tests/corpus/thin-wall-enclosure/README.md create mode 100644 tests/corpus/thin-wall-enclosure/recipe.json diff --git a/Cargo.lock b/Cargo.lock index eee9dea..571fb92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + [[package]] name = "allocator-api2" version = "0.2.21" @@ -97,6 +103,12 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + [[package]] name = "cc" version = "1.8.0" @@ -248,6 +260,15 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + [[package]] name = "find-msvc-tools" version = "0.1.14" @@ -260,6 +281,8 @@ version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", "zlib-rs", ] @@ -357,6 +380,19 @@ dependencies = [ "cc", ] +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "moxcms", + "num-traits", + "png", +] + [[package]] name = "indexmap" version = "2.14.2" @@ -441,6 +477,26 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + [[package]] name = "modelcraft-cli" version = "0.1.0" @@ -469,7 +525,9 @@ version = "0.1.0" dependencies = [ "modelcraft-model", "quick-xml", + "serde_json", "solidcraft-doc", + "solidcraft-engine", "solidcraft-geom", "solidcraft-io", "solidcraft-kernel", @@ -498,6 +556,25 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "modelcraft-testkit" +version = "0.1.0" +dependencies = [ + "modelcraft-geometry", + "serde_json", + "thiserror 2.0.21", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + [[package]] name = "num-bigint" version = "0.4.8" @@ -581,6 +658,19 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + [[package]] name = "ppv-lite86" version = "0.2.21" @@ -623,6 +713,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + [[package]] name = "quick-xml" version = "0.41.0" @@ -842,6 +938,23 @@ dependencies = [ "web-time", ] +[[package]] +name = "solidcraft-engine" +version = "0.8.0" +source = "git+https://github.com/bherbruck/solidcraft?rev=de1479029dd6821cffd28b70688a58e7f61f0cfd#de1479029dd6821cffd28b70688a58e7f61f0cfd" +dependencies = [ + "log", + "serde", + "serde_json", + "solidcraft-doc", + "solidcraft-geom", + "solidcraft-io", + "solidcraft-kernel", + "solidcraft-render", + "solidcraft-sketch", + "thiserror 2.0.21", +] + [[package]] name = "solidcraft-geom" version = "0.8.0" @@ -884,6 +997,16 @@ dependencies = [ "truck-topology", ] +[[package]] +name = "solidcraft-render" +version = "0.8.0" +source = "git+https://github.com/bherbruck/solidcraft?rev=de1479029dd6821cffd28b70688a58e7f61f0cfd#de1479029dd6821cffd28b70688a58e7f61f0cfd" +dependencies = [ + "image", + "serde", + "solidcraft-geom", +] + [[package]] name = "solidcraft-sketch" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index 1193b67..e1a4340 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ modelcraft-model = { path = "crates/model" } modelcraft-geometry = { path = "crates/geometry" } modelcraft-mesh = { path = "crates/mesh" } modelcraft-engine = { path = "crates/engine" } +modelcraft-testkit = { path = "crates/testkit" } # foundation thiserror = "2" @@ -33,6 +34,9 @@ solidcraft-geom = { git = "https://github.com/bherbruck/solidcraft", rev = "de14 solidcraft-kernel = { git = "https://github.com/bherbruck/solidcraft", rev = "de1479029dd6821cffd28b70688a58e7f61f0cfd" } solidcraft-doc = { git = "https://github.com/bherbruck/solidcraft", rev = "de1479029dd6821cffd28b70688a58e7f61f0cfd" } solidcraft-io = { git = "https://github.com/bherbruck/solidcraft", rev = "de1479029dd6821cffd28b70688a58e7f61f0cfd" } +# Runs SolidCraft command scripts (the test corpus recipes); only behind modelcraft-geometry's +# `scripts` feature. +solidcraft-engine = { git = "https://github.com/bherbruck/solidcraft", rev = "de1479029dd6821cffd28b70688a58e7f61f0cfd" } [workspace.lints.rust] unsafe_code = "forbid" diff --git a/ROADMAP.md b/ROADMAP.md index 1263830..e13718e 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -6,7 +6,7 @@ LS-PrePost, with hexahedral meshing as the centre of gravity, plus its own linea | Milestone | Scope | Status | |---|---|---| | M0 Foundation | Workspace, quality gates (`cargo xtask ci`), FE model, command engine with rollback and panic guard, CLI, geometry boundary on SolidCraft's kernel and tessellator | done | -| M1 Surface preparation | Geometry in: open `.solidcraft` designs, rebuilt by SolidCraft, with persistent face names (done); face-tagged 3MF files (`geometry.import.mesh`, docs/formats/tagged-mesh.md, done); exact predicates (Shewchuk adaptive, symbolic perturbation, indirect LPI/TPI, done); weld, closed/manifold/orientation checks and feature edges on the tessellated boundary; mesh quality metrics and the certified validity gate (`modelcraft-mesh::quality`, `mesh.quality`, done) | in progress | +| M1 Surface preparation | Geometry in: open `.solidcraft` designs, rebuilt by SolidCraft, with persistent face names (done); face-tagged 3MF files (`geometry.import.mesh`, docs/formats/tagged-mesh.md, done); the meshing test corpus: 16 SolidCraft recipes and 5 analytic shapes, `cargo xtask corpus` → docs/meshing/corpus.md (done); exact predicates (Shewchuk adaptive, symbolic perturbation, indirect LPI/TPI, done); weld, closed/manifold/orientation checks and feature edges on the tessellated boundary; mesh quality metrics and the certified validity gate (`modelcraft-mesh::quality`, `mesh.quality`, done) | in progress | | M2 Tetrahedral meshing | Bowyer–Watson Delaunay, robust constrained Delaunay boundary recovery (Diazzi et al. 2023), Delaunay refinement to a size field, ODT smoothing, Klingner–Shewchuk sliver removal; linear and quadratic tets | planned | | M3 Hexahedral meshing (core) | Octree/grid dual all-hex (valid on any input), then hex-dominant by tet recombination, then polycube for blocky parts; see docs/meshing/literature.md | planned | | M4 Model definition | Materials, sections, sets and surfaces, boundary conditions, loads, steps, output requests | planned | diff --git a/THIRD-PARTY-LICENSES.txt b/THIRD-PARTY-LICENSES.txt index bfd8817..157b2ef 100644 --- a/THIRD-PARTY-LICENSES.txt +++ b/THIRD-PARTY-LICENSES.txt @@ -1,9 +1,10 @@ Third-party software in ModelCraft -ModelCraft (the desktop app, modelcraft-cli and the web app) is built from the 122 crates below. +ModelCraft (the desktop app, modelcraft-cli and the web app) is built from the 133 crates below. Generated by `cargo xtask licences` from Cargo.lock and the crates' own licence files. ModelCraft's own licence is in LICENSE-MIT and LICENSE-APACHE, and NOTICE. +adler2 2.0.1 (0BSD OR MIT OR Apache-2.0) allocator-api2 0.2.21 (MIT OR Apache-2.0) android_system_properties 0.1.6 (MIT OR Apache-2.0) approx 0.4.0 (Apache-2.0) @@ -15,6 +16,7 @@ branches 0.3.0 (MIT) bumpalo 3.20.3 (MIT OR Apache-2.0) bytemuck 1.25.2 (Zlib OR Apache-2.0 OR MIT) bytemuck_derive 1.12.1 (Zlib OR Apache-2.0 OR MIT) +byteorder-lite 0.1.0 (Unlicense OR MIT) cfg-if 1.0.5 (MIT OR Apache-2.0) cgmath 0.18.0 (Apache-2.0) chrono 0.4.45 (MIT OR Apache-2.0) @@ -31,6 +33,7 @@ derive_more 0.99.20 (MIT) digest 0.10.7 (MIT OR Apache-2.0) either 1.19.0 (MIT OR Apache-2.0) equivalent 1.0.2 (Apache-2.0 OR MIT) +fdeflate 0.3.7 (MIT OR Apache-2.0) flate2 1.1.10 (MIT OR Apache-2.0) foldhash 0.2.0 (Zlib) futures-core 0.3.34 (MIT OR Apache-2.0) @@ -42,6 +45,7 @@ hashbrown 0.16.1 (MIT OR Apache-2.0) hashbrown 0.17.1 (MIT OR Apache-2.0) iana-time-zone 0.1.65 (MIT OR Apache-2.0) iana-time-zone-haiku 0.1.2 (MIT OR Apache-2.0) +image 0.25.10 (MIT OR Apache-2.0) indexmap 2.14.2 (Apache-2.0 OR MIT) itertools 0.13.0 (MIT OR Apache-2.0) itoa 1.0.18 (MIT OR Apache-2.0) @@ -52,16 +56,21 @@ lock_api 0.4.14 (MIT OR Apache-2.0) log 0.4.34 (MIT OR Apache-2.0) matext4cgmath 0.1.0 (Apache-2.0) memchr 2.8.3 (Unlicense OR MIT) +miniz_oxide 0.8.9 (MIT OR Zlib OR Apache-2.0) +miniz_oxide 0.9.1 (MIT OR Zlib OR Apache-2.0) +moxcms 0.8.1 (BSD-3-Clause OR Apache-2.0) num-complex 0.4.6 (MIT OR Apache-2.0) num-traits 0.2.19 (MIT OR Apache-2.0) once_cell 1.21.4 (MIT OR Apache-2.0) parking_lot 0.12.5 (MIT OR Apache-2.0) parking_lot_core 0.9.12 (MIT OR Apache-2.0) pin-project-lite 0.2.17 (Apache-2.0 OR MIT) +png 0.18.1 (MIT OR Apache-2.0) ppv-lite86 0.2.21 (MIT OR Apache-2.0) proc-macro-error 1.0.4 (MIT OR Apache-2.0) proc-macro-error-attr 1.0.4 (MIT OR Apache-2.0) proc-macro2 1.0.107 (MIT OR Apache-2.0) +pxfm 0.1.30 (BSD-3-Clause OR Apache-2.0) quick-xml 0.41.0 (MIT) quote 1.0.47 (MIT OR Apache-2.0) rand 0.8.8 (MIT OR Apache-2.0) @@ -83,9 +92,11 @@ simd-adler32 0.3.10 (MIT) slab 0.4.12 (MIT) smallvec 1.16.3 (MIT OR Apache-2.0) solidcraft-doc 0.8.0 (MIT OR Apache-2.0) +solidcraft-engine 0.8.0 (MIT OR Apache-2.0) solidcraft-geom 0.8.0 (MIT OR Apache-2.0) solidcraft-io 0.8.0 (MIT OR Apache-2.0) solidcraft-kernel 0.8.0 (MIT OR Apache-2.0) +solidcraft-render 0.8.0 (MIT OR Apache-2.0) solidcraft-sketch 0.8.0 (MIT OR Apache-2.0) spade 2.15.1 (MIT OR Apache-2.0) syn 1.0.109 (MIT OR Apache-2.0) @@ -127,6 +138,261 @@ zlib-rs 0.6.8 (Zlib) zmij 1.0.23 (MIT) zopfli 0.8.4 (Apache-2.0) +================================================================================ +adler2 2.0.1 +================================================================================ + +Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/LICENSE-2.0 + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +================================================================================ +adler2 2.0.1 +================================================================================ + +Copyright (C) Jonas Schievink + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN +AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +================================================================================ +adler2 2.0.1, allocator-api2 0.2.21, itoa 1.0.18, once_cell 1.21.4, pin-project-lite 0.2.17, +proc-macro2 1.0.107, quote 1.0.47, rustc-hash 2.1.3, serde 1.0.229, serde_core 1.0.229, serde_derive +1.0.229, serde_json 1.0.154, syn 1.0.109, syn 2.0.119, syn 3.0.9, thiserror 1.0.69, thiserror +2.0.21, thiserror-impl 1.0.69, thiserror-impl 2.0.21, unicode-ident 1.0.27, wasi +0.11.1+wasi-snapshot-preview1, zmij 1.0.23 +================================================================================ + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + ================================================================================ allocator-api2 0.2.21, itoa 1.0.18, libc 0.2.190, proc-macro2 1.0.107, quote 1.0.47, rustc-hash 2.1.3, serde 1.0.229, serde_core 1.0.229, serde_derive 1.0.229, serde_json 1.0.154, syn 2.0.119, syn @@ -311,37 +577,6 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION END OF TERMS AND CONDITIONS -================================================================================ -allocator-api2 0.2.21, itoa 1.0.18, once_cell 1.21.4, pin-project-lite 0.2.17, proc-macro2 1.0.107, -quote 1.0.47, rustc-hash 2.1.3, serde 1.0.229, serde_core 1.0.229, serde_derive 1.0.229, serde_json -1.0.154, syn 1.0.109, syn 2.0.119, syn 3.0.9, thiserror 1.0.69, thiserror 2.0.21, thiserror-impl -1.0.69, thiserror-impl 2.0.21, unicode-ident 1.0.27, wasi 0.11.1+wasi-snapshot-preview1, zmij 1.0.23 -================================================================================ - -Permission is hereby granted, free of charge, to any -person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the -Software without restriction, including without -limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software -is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice -shall be included in all copies or substantial portions -of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF -ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT -SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. - ================================================================================ android_system_properties 0.1.6 ================================================================================ @@ -596,8 +831,8 @@ arbitrary 1.5.0, bitflags 2.13.2, bumpalo 3.20.3, cfg-if 1.0.5, core-foundation- crossbeam-deque 0.8.8, crossbeam-epoch 0.9.21, crossbeam-utils 0.8.23, derive_arbitrary 1.5.0, either 1.19.0, equivalent 1.0.2, flate2 1.1.10, hashbrown 0.16.1, hashbrown 0.17.1, indexmap 2.14.2, itertools 0.13.0, js-sys 0.3.106, lock_api 0.4.14, log 0.4.34, num-complex 0.4.6, num-traits 0.2.19, -once_cell 1.21.4, parking_lot 0.12.5, parking_lot_core 0.9.12, rayon 1.12.0, rayon-core 1.13.0, -robust 1.2.0, scopeguard 1.2.0, smallvec 1.16.3, syn 1.0.109, ttf-parser 0.25.1, wasi +once_cell 1.21.4, parking_lot 0.12.5, parking_lot_core 0.9.12, png 0.18.1, rayon 1.12.0, rayon-core +1.13.0, robust 1.2.0, scopeguard 1.2.0, smallvec 1.16.3, syn 1.0.109, ttf-parser 0.25.1, wasi 0.11.1+wasi-snapshot-preview1, wasm-bindgen 0.2.129, wasm-bindgen-macro 0.2.129, wasm-bindgen-macro-support 0.2.129, wasm-bindgen-shared 0.2.129 ================================================================================ @@ -1254,6 +1489,61 @@ The above copyright notice and this permission notice (including the next paragr THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +byteorder-lite 0.1.0, memchr 2.8.3 +================================================================================ + +The MIT License (MIT) + +Copyright (c) 2015 Andrew Gallant + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +================================================================================ +byteorder-lite 0.1.0, memchr 2.8.3 +================================================================================ + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to + ================================================================================ cfg-if 1.0.5, js-sys 0.3.106, wasm-bindgen 0.2.129, wasm-bindgen-macro 0.2.129, wasm-bindgen-macro-support 0.2.129, wasm-bindgen-shared 0.2.129 @@ -1999,6 +2289,218 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +================================================================================ +fdeflate 0.3.7, image 0.25.10 +================================================================================ + +MIT License + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + +================================================================================ +fdeflate 0.3.7, image 0.25.10, miniz_oxide 0.8.9, miniz_oxide 0.9.1, pin-project-lite 0.2.17, +truck-meshalgo 0.4.0, truck-shapeops 0.4.0, truck-stepio 0.3.0 +================================================================================ + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + ================================================================================ flate2 1.1.10 ================================================================================ @@ -3120,9 +3622,40 @@ Apache License memchr 2.8.3 ================================================================================ -The MIT License (MIT) +This project is dual-licensed under the Unlicense and MIT licenses. + +You may use this code under the terms of either license. + +================================================================================ +miniz_oxide 0.8.9, miniz_oxide 0.9.1 +================================================================================ + +Copyright 2013-2014 RAD Game Tools and Valve Software +Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC +Copyright (c) 2020 Frommi +Copyright (c) 2017-2024 oyvindln + +This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. + +================================================================================ +miniz_oxide 0.8.9, miniz_oxide 0.9.1 +================================================================================ + +MIT License + +Copyright 2013-2014 RAD Game Tools and Valve Software +Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC +Copyright (c) 2017 Frommi +Copyright (c) 2017-2024 oyvindln -Copyright (c) 2015 Andrew Gallant Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -3131,56 +3664,48 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. ================================================================================ -memchr 2.8.3 +miniz_oxide 0.8.9, miniz_oxide 0.9.1 ================================================================================ -This is free and unencumbered software released into the public domain. +MIT License -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. +Copyright 2013-2014 RAD Game Tools and Valve Software +Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC +Copyright (c) 2017 Frommi +Copyright (c) 2017-2024 oyvindln -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. -For more information, please refer to +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. ================================================================================ -memchr 2.8.3 -================================================================================ - -This project is dual-licensed under the Unlicense and MIT licenses. - -You may use this code under the terms of either license. - -================================================================================ -pin-project-lite 0.2.17, truck-meshalgo 0.4.0, truck-shapeops 0.4.0, truck-stepio 0.3.0 +moxcms 0.8.1, pxfm 0.1.30 ================================================================================ Apache License @@ -3360,6 +3885,92 @@ Apache License END OF TERMS AND CONDITIONS + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2024 Radzivon Bartoshyk + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +================================================================================ +moxcms 0.8.1, pxfm 0.1.30 +================================================================================ + +Copyright (c) Radzivon Bartoshyk. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +================================================================================ +png 0.18.1 +================================================================================ + +Copyright (c) 2015 nwin + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + ================================================================================ ppv-lite86 0.2.21 ================================================================================ @@ -6089,9 +6700,11 @@ array-macro 2.1.8: MIT OR Apache-2.0 (https://codeberg.org/xfix/array-macro) convert_case 0.4.0: MIT (https://github.com/rutrum/convert-case) katexit 0.1.5: MIT OR Apache-2.0 (https://github.com/termoshtt/katexit) solidcraft-doc 0.8.0: MIT OR Apache-2.0 +solidcraft-engine 0.8.0: MIT OR Apache-2.0 solidcraft-geom 0.8.0: MIT OR Apache-2.0 solidcraft-io 0.8.0: MIT OR Apache-2.0 solidcraft-kernel 0.8.0: MIT OR Apache-2.0 +solidcraft-render 0.8.0: MIT OR Apache-2.0 solidcraft-sketch 0.8.0: MIT OR Apache-2.0 truck-base 0.5.0: Apache-2.0 (https://github.com/ricosjp/truck) truck-derivers 0.1.0: Apache-2.0 (https://github.com/ricosjp/truck) diff --git a/crates/geometry/Cargo.toml b/crates/geometry/Cargo.toml index 1cd01e0..92d363b 100644 --- a/crates/geometry/Cargo.toml +++ b/crates/geometry/Cargo.toml @@ -17,3 +17,10 @@ solidcraft-io = { workspace = true } thiserror = { workspace = true } zip = { workspace = true } quick-xml = { workspace = true } +solidcraft-engine = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true } + +[features] +# Build designs from SolidCraft command scripts (`script_design`): the test corpus and tooling. +# Off by default; the library itself only opens designs. +scripts = ["dep:solidcraft-engine", "dep:serde_json"] diff --git a/crates/geometry/src/design.rs b/crates/geometry/src/design.rs index 0569006..b72b197 100644 --- a/crates/geometry/src/design.rs +++ b/crates/geometry/src/design.rs @@ -18,7 +18,8 @@ pub const MAX_DESIGN_BYTES: usize = solidcraft_io::MAX_DESIGN_BYTES; #[derive(Debug, Clone)] pub struct Design { pub name: String, - /// The bodies at the end of the timeline, in the design's order. + /// The bodies at the end of the timeline, in the design's order, placed in the world: bodies of + /// components moved by their occurrences, one body per placement. pub bodies: Vec, /// Features that failed to rebuild. The design still opens with the bodies the rest made, /// as it does in SolidCraft. @@ -63,7 +64,9 @@ pub(crate) fn rebuild(doc: &Document) -> Result { .filter(|r| !r.skipped) .filter_map(|r| r.error.as_ref().map(|e| FeatureError { feature: r.name.clone(), message: e.clone() })) .collect(); - let state = model.state(); + // Placed in the world: a component's bodies through every occurrence of it (an instance is a + // body of its own, named after its occurrence path), as SolidCraft displays and exports them. + let state = guard("place components", || Ok(solidcraft_doc::world_state(doc, &model.state())))?; let mut bodies = Vec::with_capacity(state.bodies.len()); for b in &state.bodies { let faces = guard("name faces", || { diff --git a/crates/geometry/src/lib.rs b/crates/geometry/src/lib.rs index d377eda..99d52cd 100644 --- a/crates/geometry/src/lib.rs +++ b/crates/geometry/src/lib.rs @@ -19,9 +19,13 @@ mod design; pub mod sample; +#[cfg(feature = "scripts")] +mod script; pub use design::{Design, FeatureError, MAX_DESIGN_BYTES, open_design, open_design_file}; pub mod tagged_mesh; +#[cfg(feature = "scripts")] +pub use script::{MAX_SCRIPT_BYTES, script_design}; use solidcraft_kernel::{Body, KernelError, guard}; #[derive(Debug, Clone, PartialEq, thiserror::Error)] @@ -129,6 +133,23 @@ impl Shape { } } +impl SurfaceMesh { + /// The volume the triangles enclose (divergence theorem: the sum of the signed tetrahedra each + /// triangle spans with the origin). Equals the solid's volume for a closed, outward-oriented + /// surface; a triangle with a vertex index out of range counts as nothing. + pub fn enclosed_volume(&self) -> f64 { + let six_v: f64 = self + .triangles + .iter() + .filter_map(|t| { + let [a, b, c] = [self.positions.get(t[0] as usize)?, self.positions.get(t[1] as usize)?, self.positions.get(t[2] as usize)?]; + Some(a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[0] * c[2] - b[2] * c[0]) + a[2] * (b[0] * c[1] - b[1] * c[0])) + }) + .sum(); + six_v / 6.0 + } +} + #[cfg(test)] mod tests { use super::*; @@ -150,17 +171,8 @@ mod tests { faces.sort_unstable(); faces.dedup(); assert_eq!(faces.len(), 6); - // Divergence theorem: the outward-oriented triangles enclose the block's volume. - let p = |i: u32| mesh.positions[i as usize]; - let six_v: f64 = mesh - .triangles - .iter() - .map(|t| { - let (a, b, c) = (p(t[0]), p(t[1]), p(t[2])); - a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[0] * c[2] - b[2] * c[0]) + a[2] * (b[0] * c[1] - b[1] * c[0]) - }) - .sum(); - assert!((six_v / 6.0 - 24.0).abs() < 1e-9, "{}", six_v / 6.0); + // The outward-oriented triangles enclose the block's volume. + assert!((mesh.enclosed_volume() - 24.0).abs() < 1e-9, "{}", mesh.enclosed_volume()); } #[test] diff --git a/crates/geometry/src/script.rs b/crates/geometry/src/script.rs new file mode 100644 index 0000000..66980a0 --- /dev/null +++ b/crates/geometry/src/script.rs @@ -0,0 +1,88 @@ +//! Designs from SolidCraft command scripts (feature `scripts`): the recipes of the test corpus. +//! +//! A script is SolidCraft's own script form, a JSON array of `{"command", "params"}` or an object +//! with a `commands` array, the same file `solidcraft-cli run` takes. [`script_design`] runs it in +//! a SolidCraft session and saves the result as `.solidcraft` file bytes, which then open through +//! [`crate::open_design`] like any design a person saved in SolidCraft. + +use solidcraft_kernel::{KernelError, guard}; + +use crate::{Error, Result}; + +/// Largest script read (SolidCraft's design limit is far larger than any recipe needs). +pub const MAX_SCRIPT_BYTES: usize = 4 << 20; + +/// Run a SolidCraft command script and return the design it builds as `.solidcraft` file bytes. +/// A command that fails stops the script and is the error. +pub fn script_design(script: &str) -> Result> { + if script.len() > MAX_SCRIPT_BYTES { + return Err(Error::Invalid(format!("script is larger than {MAX_SCRIPT_BYTES} bytes"))); + } + let value: serde_json::Value = serde_json::from_str(script).map_err(|e| Error::Invalid(format!("script is not JSON: {e}")))?; + // A failing command is the recipe's error; only a panic is the kernel's. + let doc = guard("run script", || { + let mut session = solidcraft_engine::Session::default(); + Ok(session.run_script(&value).map(|_| session.doc.clone())) + })? + .map_err(|e| Error::Invalid(format!("script: {e}")))?; + guard("save design", || solidcraft_io::write_design_container(&doc).map_err(|e| KernelError::Internal(format!("save design: {e}")))) + .map_err(Error::from) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::open_design; + + #[test] + fn a_script_builds_a_design_that_opens() { + let script = r#"{"commands": [ + {"command": "solid.box", "params": {"length": 10, "width": 20, "height": 30, "body_name": "B"}} + ]}"#; + let design = open_design(&script_design(script).unwrap()).unwrap(); + assert!(design.errors.is_empty(), "{:?}", design.errors); + let m = design.body("B").unwrap().measure().unwrap(); + assert!((m.volume - 6000.0).abs() < 1e-6, "{}", m.volume); + } + + /// Bodies of components come out where the assembly places them: through every occurrence + /// (instances are bodies of their own) and through rotations as well as translations. + #[test] + fn component_bodies_are_placed_by_their_occurrences() { + let script = r#"{"commands": [ + {"command": "component.create", "params": {"name": "Block"}}, + {"command": "solid.box", "params": {"length": 10, "width": 4, "height": 2, "body_name": "B"}}, + {"command": "component.activate", "params": {"component": "root"}}, + {"command": "occurrence.copy", "params": {"component": "Block", "translate": [100, 0, 0]}}, + {"command": "occurrence.move", "params": {"occurrence": "Block:1", "axis": [0, 0, 1], "angle": "90 deg", "translate": [0, 50, 0]}} + ]}"#; + let design = open_design(&script_design(script).unwrap()).unwrap(); + assert!(design.errors.is_empty(), "{:?}", design.errors); + let mut boxes: Vec<([f64; 3], [f64; 3], f64)> = design + .bodies + .iter() + .map(|b| { + let m = b.measure().unwrap(); + (m.bbox_min, m.bbox_max, m.volume) + }) + .collect(); + boxes.sort_by(|a, b| a.0[0].total_cmp(&b.0[0])); + assert_eq!(boxes.len(), 2, "{:?}", design.bodies.iter().map(|b| &b.name).collect::>()); + let close = |a: [f64; 3], b: [f64; 3]| a.iter().zip(&b).all(|(x, y)| (x - y).abs() < 1e-6); + // The first occurrence turned 90 degrees about Z, then moved 50 along Y. + assert!(close(boxes[0].0, [-4.0, 50.0, 0.0]) && close(boxes[0].1, [0.0, 60.0, 2.0]), "{boxes:?}"); + // The instance, moved 100 along X. + assert!(close(boxes[1].0, [100.0, 0.0, 0.0]) && close(boxes[1].1, [110.0, 4.0, 2.0]), "{boxes:?}"); + assert!(boxes.iter().all(|b| (b.2 - 80.0).abs() < 1e-6)); + // Placed bodies keep their persistent face names. + assert!(design.bodies.iter().all(|b| b.faces().len() == 6), "{:?}", design.bodies.iter().map(|b| b.faces().len()).collect::>()); + } + + #[test] + fn hostile_scripts_are_an_error() { + for s in ["", "{", "[1]", "{}", r#"[{"command": "no.such"}]"#, r#"[{"command": "solid.box", "params": {"length": -1e400}}]"#] { + assert!(script_design(s).is_err(), "{s}"); + } + assert!(script_design(&" ".repeat(MAX_SCRIPT_BYTES + 1)).is_err()); + } +} diff --git a/crates/testkit/Cargo.toml b/crates/testkit/Cargo.toml new file mode 100644 index 0000000..fd9298d --- /dev/null +++ b/crates/testkit/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "modelcraft-testkit" +description = "ModelCraft test tooling: the meshing test corpus (SolidCraft recipes and analytic shapes)" +version.workspace = true +edition.workspace = true +license.workspace = true +publish = false + +[lints] +workspace = true + +[dependencies] +modelcraft-geometry = { workspace = true, features = ["scripts"] } +serde_json = { workspace = true } +thiserror = { workspace = true } diff --git a/crates/testkit/src/bin/corpus.rs b/crates/testkit/src/bin/corpus.rs new file mode 100644 index 0000000..f1e1bc5 --- /dev/null +++ b/crates/testkit/src/bin/corpus.rs @@ -0,0 +1,30 @@ +//! `corpus [--part NAME] [--no-write]`: see [`modelcraft_testkit::runner`]; run it as +//! `cargo xtask corpus`. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] +#![forbid(unsafe_code)] + +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = std::env::args().skip(1).collect(); + let mut only = None; + let mut write = true; + let mut it = args.iter(); + while let Some(a) = it.next() { + match a.as_str() { + "--part" => only = it.next().map(String::as_str), + "--no-write" => write = false, + other => { + eprintln!("error: unknown argument `{other}`\nusage: corpus [--part NAME] [--no-write]"); + return ExitCode::FAILURE; + } + } + } + match modelcraft_testkit::runner::run(&modelcraft_testkit::corpus::workspace_root(), only, write) { + Ok(()) => ExitCode::SUCCESS, + Err(e) => { + eprintln!("error: {e}"); + ExitCode::FAILURE + } + } +} diff --git a/crates/testkit/src/corpus.rs b/crates/testkit/src/corpus.rs new file mode 100644 index 0000000..729b6d3 --- /dev/null +++ b/crates/testkit/src/corpus.rs @@ -0,0 +1,318 @@ +//! The meshing test corpus. +//! +//! Two kinds of part, both regenerated on every load (no geometry is stored): +//! - **Recipes**: `tests/corpus//recipe.json`, a SolidCraft command script (the file +//! `solidcraft-cli run` takes) with a `corpus` object beside its `commands` giving the +//! categories it stresses and, when it has one, its closed-form volume; `README.md` beside it is +//! one line on what it stresses. The script runs in SolidCraft's engine, the design is saved and +//! opened again through [`modelcraft_geometry::open_design`], the path a person's design takes. +//! - **Analytic shapes** ([`Analytic`]): sphere, torus, cylinder, thick-walled pipe and a plate +//! with a hole, built in code with their exact volume, the classic solver verification +//! geometries. + +use std::path::{Path, PathBuf}; + +use modelcraft_geometry::{Design, open_design, sample, script_design}; +use serde_json::{Value, json}; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("{0}")] + Io(String), + #[error("{part}: {message}")] + Part { part: String, message: String }, + #[error("{part}: {source}")] + Geometry { part: String, source: modelcraft_geometry::Error }, +} + +pub type Result = std::result::Result; + +/// What a part stresses in a mesher. A recipe names one or more. +pub const CATEGORIES: &[(&str, &str)] = &[ + ("thin-wall", "walls thin against the part's size"), + ("small-feature", "features much smaller than the part"), + ("fillet", "blends between faces"), + ("genus", "through holes (genus > 0)"), + ("sharp", "sharp edges and acute dihedral angles"), + ("near-tangent", "faces meeting at a shallow angle"), + ("boolean", "intersection curves from booleans"), + ("sweepable", "extrusions and sweeps (one-to-one sweep meshing)"), + ("blocky", "axis-aligned blocks (polycube-friendly)"), + ("organic", "free-form, lofted or revolved spline surfaces"), + ("assembly", "several bodies placed by component transforms"), + ("analytic", "closed-form geometry for solver verification"), +]; + +/// Largest recipe or README read. +const MAX_FILE_BYTES: u64 = 4 << 20; +/// Most parts in the corpus directory. +const MAX_PARTS: usize = 10_000; + +/// A part of the corpus. +#[derive(Debug, Clone, PartialEq)] +pub struct Part { + /// The recipe's directory name, or the analytic shape's name (`analytic-…`). + pub name: String, + /// One line on what it stresses. + pub description: String, + /// Entries of [`CATEGORIES`]. + pub categories: Vec, + /// Closed-form volume (mm³), when the part has one. + pub volume: Option, + pub source: Source, +} + +#[derive(Debug, Clone, PartialEq)] +pub enum Source { + /// The script, read from `recipe.json`. + Recipe(String), + Analytic(Analytic), +} + +/// Closed-form shapes (mm). +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Analytic { + Sphere { + radius: f64, + }, + Torus { + major: f64, + minor: f64, + }, + Cylinder { + radius: f64, + height: f64, + }, + /// A thick-walled cylinder (Lamé). + Pipe { + inner: f64, + outer: f64, + length: f64, + }, + /// A plate with a round through hole (Kirsch), built as a parametric design in code. + PlateWithHole(sample::Plate), +} + +impl Analytic { + /// The exact volume. + pub fn volume(&self) -> f64 { + use std::f64::consts::PI; + match *self { + Analytic::Sphere { radius } => 4.0 / 3.0 * PI * radius.powi(3), + Analytic::Torus { major, minor } => 2.0 * PI * PI * major * minor * minor, + Analytic::Cylinder { radius, height } => PI * radius * radius * height, + Analytic::Pipe { inner, outer, length } => PI * (outer * outer - inner * inner) * length, + Analytic::PlateWithHole(p) => (p.width * p.depth - PI * p.hole_diameter * p.hole_diameter / 4.0) * p.thickness, + } + } + + /// The design as `.solidcraft` bytes. + pub fn design(&self) -> modelcraft_geometry::Result> { + let script = match *self { + Analytic::Sphere { radius } => json!([{"command": "solid.sphere", "params": {"radius": radius, "body_name": "Sphere"}}]), + Analytic::Torus { major, minor } => json!([{"command": "solid.torus", "params": {"major": major, "minor": minor, "body_name": "Torus"}}]), + Analytic::Cylinder { radius, height } => { + json!([{"command": "solid.cylinder", "params": {"radius": radius, "height": height, "body_name": "Cylinder"}}]) + } + Analytic::Pipe { inner, outer, length } => json!([ + {"command": "solid.cylinder", "params": {"radius": outer, "height": length, "body_name": "Pipe"}}, + {"command": "solid.cylinder", "params": {"radius": inner, "height": length, "operation": "cut", "targets": ["Pipe"]}} + ]), + Analytic::PlateWithHole(p) => return sample::plate_design(&p), + }; + script_design(&script.to_string()) + } +} + +/// The analytic shapes of the corpus. +pub fn analytic_parts() -> Vec { + let plate = sample::Plate { width: 200.0, depth: 100.0, thickness: 5.0, hole_diameter: 20.0 }; + let shapes: [(&str, &str, &[&str], Analytic); 5] = [ + ("analytic-sphere", "Sphere r 20: curvature everywhere, no edges.", &[], Analytic::Sphere { radius: 20.0 }), + ("analytic-torus", "Torus 30/8: genus 1 with doubly curved faces and no edges.", &["genus"], Analytic::Torus { major: 30.0, minor: 8.0 }), + ( + "analytic-cylinder", + "Cylinder r 10, h 40: the round bar of beam and torsion checks.", + &["sweepable"], + Analytic::Cylinder { radius: 10.0, height: 40.0 }, + ), + ( + "analytic-pipe", + "Thick-walled pipe 20/30, length 60: the Lamé cylinder.", + &["genus", "sweepable"], + Analytic::Pipe { inner: 20.0, outer: 30.0, length: 60.0 }, + ), + ("analytic-plate-hole", "Plate 200 x 100 x 5 with a 20 mm hole: the Kirsch plate.", &["genus", "sweepable"], Analytic::PlateWithHole(plate)), + ]; + shapes + .into_iter() + .map(|(name, description, more, shape)| Part { + name: name.into(), + description: description.into(), + categories: std::iter::once("analytic").chain(more.iter().copied()).map(str::to_string).collect(), + volume: Some(shape.volume()), + source: Source::Analytic(shape), + }) + .collect() +} + +/// The workspace root (this crate is `crates/testkit` in it). +pub fn workspace_root() -> PathBuf { + let here = Path::new(env!("CARGO_MANIFEST_DIR")); + here.ancestors().nth(2).unwrap_or(here).to_path_buf() +} + +/// The workspace's corpus directory, `tests/corpus`. +pub fn corpus_dir() -> PathBuf { + workspace_root().join("tests").join("corpus") +} + +fn read(path: &Path) -> Result { + let io = |e: std::io::Error| Error::Io(format!("{}: {e}", path.display())); + let len = std::fs::metadata(path).map_err(io)?.len(); + if len > MAX_FILE_BYTES { + return Err(Error::Io(format!("{}: larger than {MAX_FILE_BYTES} bytes", path.display()))); + } + std::fs::read_to_string(path).map_err(io) +} + +/// The recipe in `dir` (named after the directory). +pub fn read_recipe(dir: &Path) -> Result { + let name = dir.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); + let bad = |message: String| Error::Part { part: name.clone(), message }; + let script = read(&dir.join("recipe.json"))?; + let value: Value = serde_json::from_str(&script).map_err(|e| bad(format!("recipe.json is not JSON: {e}")))?; + let meta = value.get("corpus").ok_or_else(|| bad("recipe.json has no `corpus` object".into()))?; + let categories: Vec = meta + .get("categories") + .and_then(Value::as_array) + .map(|a| a.iter().filter_map(Value::as_str).map(str::to_string).collect()) + .unwrap_or_default(); + if categories.is_empty() { + return Err(bad("`corpus.categories` names none".into())); + } + if let Some(c) = categories.iter().find(|c| !CATEGORIES.iter().any(|(k, _)| k == c)) { + return Err(bad(format!("unknown category `{c}`"))); + } + let volume = meta + .get("volume_mm3") + .map(|v| v.as_f64().filter(|v| v.is_finite() && *v > 0.0).ok_or_else(|| bad("`corpus.volume_mm3` must be a positive number".into()))) + .transpose()?; + let readme = read(&dir.join("README.md"))?; + let description = readme.lines().map(|l| l.trim_start_matches('#').trim()).find(|l| !l.is_empty()).unwrap_or_default().to_string(); + if description.is_empty() { + return Err(bad("README.md is empty".into())); + } + Ok(Part { name, description, categories, volume, source: Source::Recipe(script) }) +} + +/// Every recipe under `dir`, by name. +pub fn read_recipes(dir: &Path) -> Result> { + let rd = std::fs::read_dir(dir).map_err(|e| Error::Io(format!("{}: {e}", dir.display())))?; + let mut dirs: Vec = rd.flatten().map(|e| e.path()).filter(|p| p.join("recipe.json").is_file()).take(MAX_PARTS + 1).collect(); + if dirs.len() > MAX_PARTS { + return Err(Error::Io(format!("{}: more than {MAX_PARTS} parts", dir.display()))); + } + dirs.sort(); + dirs.iter().map(|d| read_recipe(d)).collect() +} + +/// The whole corpus: the recipes in [`corpus_dir`], then the analytic shapes. +pub fn parts() -> Result> { + let mut parts = read_recipes(&corpus_dir())?; + parts.extend(analytic_parts()); + Ok(parts) +} + +/// Build a part: run its recipe (or generate the shape) and open the design. +pub fn load(part: &Part) -> Result { + let geometry = |source| Error::Geometry { part: part.name.clone(), source }; + let bytes = match &part.source { + Source::Recipe(script) => script_design(script), + Source::Analytic(shape) => shape.design(), + } + .map_err(geometry)?; + open_design(&bytes).map_err(geometry) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn analytic_shapes_have_their_closed_form_volume() { + for part in analytic_parts() { + let design = load(&part).unwrap(); + assert!(design.errors.is_empty(), "{}: {:?}", part.name, design.errors); + let expect = part.volume.unwrap(); + let got: f64 = design.bodies.iter().map(|b| b.measure().unwrap().volume).sum(); + assert!((got - expect).abs() < 1e-3 * expect, "{}: {got} vs {expect}", part.name); + } + } + + /// Every committed recipe builds without a failed feature, and its volume matches the closed + /// form where it states one. + #[test] + fn every_recipe_builds() { + let parts = read_recipes(&corpus_dir()).unwrap(); + assert!(parts.len() >= 15, "{}", parts.len()); + for part in &parts { + let design = load(part).unwrap_or_else(|e| panic!("{e}")); + assert!(design.errors.is_empty(), "{}: {:?}", part.name, design.errors); + assert!(!design.bodies.is_empty(), "{}: no bodies", part.name); + if let Some(expect) = part.volume { + let got: f64 = design.bodies.iter().map(|b| b.measure().unwrap().volume).sum(); + assert!((got - expect).abs() < 1e-3 * expect, "{}: {got} vs {expect}", part.name); + } + } + // Every category is covered. + for (c, _) in CATEGORIES { + assert!(parts.iter().chain(&analytic_parts()).any(|p| p.categories.iter().any(|x| x == c)), "no part covers {c}"); + } + } + + /// The assembly's clamps sit where their occurrences put them: one moved, one instance moved + /// and turned 90 degrees about Z. + #[test] + fn assembly_bodies_are_placed() { + let part = read_recipe(&corpus_dir().join("bolted-assembly")).unwrap(); + let design = load(&part).unwrap(); + let mut boxes: Vec<([f64; 3], [f64; 3])> = design + .bodies + .iter() + .map(|b| { + let m = b.measure().unwrap(); + (m.bbox_min, m.bbox_max) + }) + .collect(); + boxes.sort_by(|a, b| a.0[0].total_cmp(&b.0[0]).then(a.1[0].total_cmp(&b.1[0]))); + let expect = [([0.0, 0.0, 0.0], [100.0, 60.0, 5.0]), ([10.0, 10.0, 5.0], [30.0, 20.0, 13.0]), ([65.0, 5.0, 5.0], [75.0, 25.0, 13.0])]; + assert_eq!(boxes.len(), expect.len()); + for (got, want) in boxes.iter().zip(&expect) { + let close = |a: &[f64; 3], b: &[f64; 3]| a.iter().zip(b).all(|(x, y)| (x - y).abs() < 1e-6); + assert!(close(&got.0, &want.0) && close(&got.1, &want.1), "{got:?} vs {want:?}"); + } + } + + #[test] + fn hostile_recipes_are_an_error() { + let dir = std::env::temp_dir().join(format!("modelcraft-corpus-test-{}", std::process::id())); + let part = dir.join("bad"); + std::fs::create_dir_all(&part).unwrap(); + std::fs::write(part.join("README.md"), "A bad part.\n").unwrap(); + for recipe in [ + "", + "{", + r#"{"commands": []}"#, + r#"{"corpus": {"categories": []}, "commands": []}"#, + r#"{"corpus": {"categories": ["nope"]}, "commands": []}"#, + r#"{"corpus": {"categories": ["blocky"], "volume_mm3": -1}, "commands": []}"#, + ] { + std::fs::write(part.join("recipe.json"), recipe).unwrap(); + assert!(read_recipe(&part).is_err(), "{recipe}"); + } + std::fs::write(part.join("recipe.json"), r#"{"corpus": {"categories": ["blocky"]}, "commands": [{"command": "no.such"}]}"#).unwrap(); + assert!(load(&read_recipe(&part).unwrap()).is_err()); + std::fs::remove_dir_all(&dir).unwrap(); + } +} diff --git a/crates/testkit/src/lib.rs b/crates/testkit/src/lib.rs new file mode 100644 index 0000000..0362ef3 --- /dev/null +++ b/crates/testkit/src/lib.rs @@ -0,0 +1,11 @@ +//! Test tooling (a dev-dependency only, `cargo xtask layers`). +//! +//! [`corpus`] is the meshing test corpus: parts built with SolidCraft from recipes committed in +//! `tests/corpus//recipe.json`, and analytic shapes generated in code with closed-form +//! volumes. Meshing tests load their geometry from here; [`runner`] (the `corpus` binary, +//! `cargo xtask corpus`) builds and meshes every part and writes docs/meshing/corpus.md. +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] +#![forbid(unsafe_code)] + +pub mod corpus; +pub mod runner; diff --git a/crates/testkit/src/runner.rs b/crates/testkit/src/runner.rs new file mode 100644 index 0000000..1647efb --- /dev/null +++ b/crates/testkit/src/runner.rs @@ -0,0 +1,182 @@ +//! The corpus runner behind `cargo xtask corpus [--part NAME] [--no-write]`: build every part of +//! the meshing test corpus ([`crate::corpus`]), tessellate it, run each [`Stage`] on it and write +//! the results table to docs/meshing/corpus.md. +//! +//! The table is a fixed part columns block (bodies, faces, the boundary surface and the time to +//! build it) followed by one column group per stage. A mesher joins the corpus by implementing +//! [`Stage`] over a [`Loaded`] part (its tessellated boundary surfaces are ready in +//! `Loaded::surfaces`) and adding itself to [`stages`]. A stage that fails on a part shows the +//! error in its first column; the run goes on. + +use std::fmt::Write as _; +use std::path::Path; +use std::time::Instant; + +use crate::corpus::{self, CATEGORIES, Part}; +use modelcraft_geometry::{Design, Measure, SurfaceMesh}; + +pub const FILE: &str = "docs/meshing/corpus.md"; +/// Chordal tolerance of the boundary surface, relative to the part's bounding-box diagonal. +const RELATIVE_TOLERANCE: f64 = 1e-3; + +/// A built part with its boundary surfaces. +pub struct Loaded<'a> { + pub part: &'a Part, + pub design: Design, + /// SolidCraft's measures, one per body in the design's order. + pub measures: Vec, + /// One per body, in the design's order. + pub surfaces: Vec, + /// The chordal tolerance the surfaces were made with (mm). + pub tolerance: f64, +} + +/// A column group of the results table: a mesher, a check. +pub trait Stage { + fn headers(&self) -> &'static [&'static str]; + /// One cell per header. + fn run(&self, part: &Loaded) -> Result, String>; +} + +/// The stages, in column order. Meshers add theirs here. +fn stages() -> Vec> { + vec![Box::new(SurfaceVolume)] +} + +/// The boundary surface's enclosed volume against SolidCraft's measured volume and the closed +/// form: a surface that is open, inverted or misplaced shows here first. +struct SurfaceVolume; + +impl Stage for SurfaceVolume { + fn headers(&self) -> &'static [&'static str] { + &["enclosed mm³", "SolidCraft mm³", "rel. diff", "exact mm³"] + } + + fn run(&self, l: &Loaded) -> Result, String> { + let enclosed: f64 = l.surfaces.iter().map(SurfaceMesh::enclosed_volume).sum(); + let measured: f64 = l.measures.iter().map(|m| m.volume).sum(); + let rel = if measured.abs() > 0.0 { (enclosed - measured) / measured } else { f64::NAN }; + Ok(vec![format!("{enclosed:.1}"), format!("{measured:.1}"), format!("{rel:.1e}"), l.part.volume.map_or("–".into(), |v| format!("{v:.1}"))]) + } +} + +fn load(part: &Part) -> Result<(Loaded<'_>, f64), String> { + let start = Instant::now(); + let design = corpus::load(part).map_err(|e| e.to_string())?; + if let Some(e) = design.errors.first() { + return Err(format!("feature {} failed: {}", e.feature, e.message)); + } + let measures = design.bodies.iter().map(|b| b.measure().map_err(|e| format!("measure {}: {e}", b.name))).collect::, _>>()?; + let (mut lo, mut hi) = ([f64::INFINITY; 3], [f64::NEG_INFINITY; 3]); + for m in &measures { + for i in 0..3 { + lo[i] = lo[i].min(m.bbox_min[i]); + hi[i] = hi[i].max(m.bbox_max[i]); + } + } + let diagonal = (0..3).map(|i| (hi[i] - lo[i]).powi(2)).sum::().sqrt(); + let tolerance = RELATIVE_TOLERANCE * if diagonal.is_finite() && diagonal > 0.0 { diagonal } else { 1.0 }; + let surfaces = + design.bodies.iter().map(|b| b.tessellate(tolerance).map_err(|e| format!("tessellate {}: {e}", b.name))).collect::, _>>()?; + let ms = start.elapsed().as_secs_f64() * 1e3; + Ok((Loaded { part, design, measures, surfaces, tolerance }, ms)) +} + +/// A failed part or stage: the error, then blanks to fill `width` cells. +fn error_cells(e: &str, width: usize) -> impl Iterator { + std::iter::once(format!("error: {e}")).chain(std::iter::repeat_n(String::new(), width.saturating_sub(1))) +} + +/// Run the corpus; with `write` (and every part) write [`FILE`] under the workspace `root`. +pub fn run(root: &Path, only: Option<&str>, write: bool) -> Result<(), String> { + let mut parts = corpus::parts().map_err(|e| e.to_string())?; + if let Some(name) = only { + parts.retain(|p| p.name == name); + if parts.is_empty() { + return Err(format!("no corpus part named `{name}`")); + } + } + let stages = stages(); + const PART_COLUMNS: &[&str] = &["part", "categories", "bodies", "faces", "triangles", "tol. mm", "build ms"]; + let mut header = PART_COLUMNS.to_vec(); + for s in &stages { + header.extend_from_slice(s.headers()); + } + let mut rows: Vec> = Vec::new(); + let mut failures = 0; + for part in &parts { + eprintln!("corpus: {}", part.name); + let mut row = vec![part.name.clone(), part.categories.join(", ")]; + match load(part) { + Err(e) => { + failures += 1; + row.extend(error_cells(&e, header.len() - row.len())); + } + Ok((l, ms)) => { + let faces: usize = l.measures.iter().map(|m| m.faces).sum(); + let triangles: usize = l.surfaces.iter().map(|s| s.triangles.len()).sum(); + row.extend([ + l.design.bodies.len().to_string(), + faces.to_string(), + triangles.to_string(), + format!("{:.3}", l.tolerance), + format!("{ms:.0}"), + ]); + for s in &stages { + let width = s.headers().len(); + match s.run(&l) { + Ok(cells) if cells.len() == width => row.extend(cells), + Ok(cells) => { + failures += 1; + row.extend(error_cells(&format!("stage gave {} cells for {width} columns", cells.len()), width)); + } + Err(e) => { + failures += 1; + row.extend(error_cells(&e, width)); + } + } + } + } + } + rows.push(row); + } + let table = markdown_table(&header, &rows); + println!("{table}"); + if write && only.is_none() { + let path = root.join(FILE); + std::fs::write(&path, document(&table, &parts)).map_err(|e| format!("{}: {e}", path.display()))?; + println!("corpus: wrote {FILE}"); + } + if failures > 0 { Err(format!("corpus: {failures} part(s) or stage(s) failed")) } else { Ok(()) } +} + +fn markdown_table(header: &[&str], rows: &[Vec]) -> String { + let mut s = format!("| {} |\n|{}\n", header.join(" | "), "---|".repeat(header.len())); + for r in rows { + let _ = writeln!(s, "| {} |", r.iter().map(|c| c.replace('|', "\\|")).collect::>().join(" | ")); + } + s +} + +fn document(table: &str, parts: &[Part]) -> String { + let mut s = String::from( + "# Meshing test corpus\n\n\ + Generated by `cargo xtask corpus`; do not edit. The parts are our own: SolidCraft recipes in\n\ + `tests/corpus//recipe.json` and analytic shapes generated in code\n\ + (`crates/testkit/src/corpus.rs`). Each run rebuilds every part, tessellates it at a chordal\n\ + tolerance of 1e-3 of its bounding-box diagonal and runs every stage on it. Times are wall\n\ + clock on the machine that ran it; every other column is deterministic.\n\n\ + ## Results\n\n", + ); + s.push_str(table); + s.push_str("\n## Categories\n\n| category | stresses | parts |\n|---|---|---|\n"); + for (c, what) in CATEGORIES { + let n = parts.iter().filter(|p| p.categories.iter().any(|x| x == c)).count(); + let _ = writeln!(s, "| {c} | {what} | {n} |"); + } + s.push_str("\n## Parts\n\n"); + for p in parts { + let _ = writeln!(s, "- `{}`: {}", p.name, p.description); + } + s +} diff --git a/docs/adr/0001-libraries.md b/docs/adr/0001-libraries.md index 341186d..7c6a29f 100644 --- a/docs/adr/0001-libraries.md +++ b/docs/adr/0001-libraries.md @@ -67,6 +67,9 @@ models that come from ABC, GrabCAD or Siemens NX; HexMe's Gmsh-made models are a Thingi10K is not used either (owner decision 2026-10-13: authoring tools unrecorded). **The test corpus is our own:** parts built with SolidCraft (scripts or designs authored in SolidCraft, committed as their recipes so the geometry is regenerated, not stored) and analytic shapes. +Recipes are SolidCraft command scripts run through `solidcraft-engine` (same pinned rev), a +dependency of `modelcraft-geometry` only behind its non-default `scripts` feature, which the test +tooling (`modelcraft-testkit`) enables; the shipped library opens designs without it. **Commercial products** (Abaqus, Nastran, LS-DYNA, LS-PrePost, HyperMesh, ANSA, Femap, Patran, ANSYS) are never run, scripted or used as a source of data. Deck formats come from the vendors' diff --git a/docs/architecture.md b/docs/architecture.md index f807fc1..f7228b9 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -28,6 +28,7 @@ crates in strictly lower layers. | L3 | `modelcraft-io` | `.modelcraft` files, result files. | planned | | L4 | `modelcraft-engine` | Commands (`CommandSpec`), `Session::execute` with rollback and the panic guard, scripts. | started | | L5 | `modelcraft-ui-egui`, `modelcraft-mcp` | Desktop UI, control channel and MCP server. | planned | +| testkit | `modelcraft-testkit` | Test tooling, a dev-dependency only: the meshing test corpus (`tests/corpus/*/recipe.json`, analytic shapes) and its runner (`cargo xtask corpus`). | started | | apps | `modelcraft`, `modelcraft-cli`, `modelcraft-web` | Desktop, command line, browser. | cli started | Rules beyond the layer order: @@ -36,6 +37,9 @@ Rules beyond the layer order: SolidCraft's `[patch.crates-io]` (its fixed truck crates) does not reach dependents, so the workspace repeats it from the same rev; bump both together. - Everything below the apps builds for `wasm32-unknown-unknown`. +- `modelcraft-geometry`'s non-default `scripts` feature builds designs from SolidCraft command + scripts (`script_design`, through `solidcraft-engine`) for the test corpus; the library opens + designs without it. ## Meshing pipeline @@ -43,6 +47,8 @@ Rules beyond the layer order: so feature edges and face-based loads and BCs survive meshing. Faces of an opened design also carry SolidCraft's persistent names (`F2:side:l4`, from the feature and sketch curve that made them), so a load on a named face follows it when the design is edited and opened again. + Bodies of components are placed in the world through their occurrences (one body per + placement), as SolidCraft displays and exports them. 2. **Surface preparation.** Weld coincident vertices, check the surface is closed, manifold and consistently oriented, find feature edges (face boundaries, sharp dihedral angles). 3. **Tetrahedral meshing.** Bowyer–Watson Delaunay on Shewchuk's adaptive predicates (symbolic @@ -66,3 +72,16 @@ Every user-visible action is a `CommandSpec` in `crates/engine/src/cmd/.rs form. `Session::execute` clones the model, runs the command under `catch_unwind`, and restores the model on an error or a panic; commands that changed the model are journalled, so the journal replays as a script. + +## Test corpus + +Meshers are measured on our own parts (`docs/adr/0001-libraries.md`, test geometry). Each part is +a SolidCraft command script in `tests/corpus//recipe.json` (the file `solidcraft-cli run` +takes, plus a `corpus` object with its categories and, when it has one, its closed-form volume) +with a one-line `README.md`; analytic shapes (sphere, torus, cylinder, thick-walled pipe, plate +with a hole) are generated in code. `modelcraft-testkit` runs a recipe in SolidCraft's engine, +saves the design and opens it through `open_design`, the path a person's design takes, so no +geometry is stored. `cargo xtask corpus` (a release build of the testkit's `corpus` binary) +builds every part, tessellates it and runs each stage of `modelcraft_testkit::runner`, writing +docs/meshing/corpus.md. A mesher joins by implementing `runner::Stage` (its columns, and a run +over the part's tessellated surfaces) and adding itself to `runner::stages()`. diff --git a/docs/meshing/corpus.md b/docs/meshing/corpus.md new file mode 100644 index 0000000..f0fe9f5 --- /dev/null +++ b/docs/meshing/corpus.md @@ -0,0 +1,74 @@ +# Meshing test corpus + +Generated by `cargo xtask corpus`; do not edit. The parts are our own: SolidCraft recipes in +`tests/corpus//recipe.json` and analytic shapes generated in code +(`crates/testkit/src/corpus.rs`). Each run rebuilds every part, tessellates it at a chordal +tolerance of 1e-3 of its bounding-box diagonal and runs every stage on it. Times are wall +clock on the machine that ran it; every other column is deterministic. + +## Results + +| part | categories | bodies | faces | triangles | tol. mm | build ms | enclosed mm³ | SolidCraft mm³ | rel. diff | exact mm³ | +|---|---|---|---|---|---|---|---|---|---|---| +| bent-tube | sweepable, thin-wall, genus | 1 | 18 | 4296 | 0.121 | 443 | 4213.1 | 4159.4 | 1.3e-2 | 4159.8 | +| bolted-assembly | assembly, blocky | 3 | 22 | 284 | 0.117 | 53 | 33004.7 | 32999.0 | 1.7e-4 | 32998.9 | +| cross-cylinders | boolean, sharp | 1 | 10 | 1395 | 0.087 | 7912 | 32197.4 | 32357.8 | -5.0e-3 | 32365.8 | +| filleted-bracket | fillet, genus, sweepable | 1 | 13 | 540 | 0.088 | 387 | 32162.3 | 32145.0 | 5.4e-4 | 32144.8 | +| i-beam | sweepable, thin-wall | 1 | 14 | 44 | 0.208 | 3 | 61600.0 | 61600.0 | 0.0e0 | 61600.0 | +| loft-transition | organic | 1 | 6 | 292 | 0.075 | 56 | 56390.2 | 56450.6 | -1.1e-3 | – | +| perforated-plate | genus, thin-wall, sweepable | 1 | 54 | 1644 | 0.144 | 269 | 26822.2 | 26764.6 | 2.2e-3 | 26764.2 | +| pinhole-block | small-feature, genus | 1 | 38 | 4044 | 0.073 | 203 | 49919.4 | 49909.6 | 2.0e-4 | 49909.5 | +| rounded-box | fillet | 1 | 26 | 2540 | 0.054 | 148 | 23325.7 | 23340.5 | -6.3e-4 | 23340.8 | +| shallow-groove | near-tangent, boolean | 1 | 8 | 62 | 0.075 | 11 | 47795.2 | 47782.3 | 2.7e-4 | 47781.5 | +| sharp-wedge | sharp, thin-wall, sweepable | 1 | 5 | 8 | 0.083 | 2 | 3200.0 | 3200.0 | 0.0e0 | 3200.0 | +| sphere-on-plate | near-tangent, boolean | 1 | 12 | 2826 | 0.098 | 687 | 69353.3 | 69509.0 | -2.2e-3 | 69509.7 | +| spline-vase | organic | 1 | 11 | 3890 | 0.106 | 218 | 94891.2 | 94948.5 | -6.0e-4 | – | +| stepped-block | blocky, sharp | 1 | 14 | 96 | 0.078 | 32 | 47000.0 | 47000.0 | 0.0e0 | 47000.0 | +| thin-ribs | thin-wall, blocky | 1 | 26 | 92 | 0.119 | 65 | 32000.0 | 32000.0 | -4.5e-16 | 32000.0 | +| thin-wall-enclosure | thin-wall, blocky | 1 | 11 | 36 | 0.108 | 8 | 15564.0 | 15564.0 | 0.0e0 | 15564.0 | +| analytic-sphere | analytic | 1 | 6 | 2784 | 0.069 | 248 | 33353.4 | 33507.9 | -4.6e-3 | 33510.3 | +| analytic-torus | analytic, genus | 1 | 6 | 7230 | 0.109 | 338 | 37644.1 | 37893.7 | -6.6e-3 | 37899.3 | +| analytic-cylinder | analytic, sweepable | 1 | 4 | 1004 | 0.049 | 25 | 12533.1 | 12564.7 | -2.5e-3 | 12566.4 | +| analytic-pipe | analytic, genus, sweepable | 1 | 6 | 1448 | 0.104 | 42 | 94150.9 | 94238.0 | -9.3e-4 | 94247.8 | +| analytic-plate-hole | analytic, genus, sweepable | 1 | 8 | 112 | 0.224 | 11 | 98449.1 | 98429.5 | 2.0e-4 | 98429.2 | + +## Categories + +| category | stresses | parts | +|---|---|---| +| thin-wall | walls thin against the part's size | 6 | +| small-feature | features much smaller than the part | 1 | +| fillet | blends between faces | 2 | +| genus | through holes (genus > 0) | 7 | +| sharp | sharp edges and acute dihedral angles | 3 | +| near-tangent | faces meeting at a shallow angle | 2 | +| boolean | intersection curves from booleans | 3 | +| sweepable | extrusions and sweeps (one-to-one sweep meshing) | 8 | +| blocky | axis-aligned blocks (polycube-friendly) | 4 | +| organic | free-form, lofted or revolved spline surfaces | 2 | +| assembly | several bodies placed by component transforms | 1 | +| analytic | closed-form geometry for solver verification | 5 | + +## Parts + +- `bent-tube`: A 10 mm tube with a 1 mm wall, bent through R30: a thin-walled sweep along a line-arc-line path. +- `bolted-assembly`: A base plate with a clamp block component placed twice, once turned 90 degrees: bodies placed by component transforms. +- `cross-cylinders`: Two orthogonal R10 cylinders joined: equal radii, so the intersection curves cross at two singular points. +- `filleted-bracket`: An 8 mm L-bracket with an R6 inside fillet and a hole through each leg: a blend beside holes. +- `i-beam`: A 200 mm I-beam with 3 mm flanges and a 2 mm web: a long sweepable prism with thin walls. +- `loft-transition`: A 40 mm square lofted to an R15 circle 50 mm above: a ruled free-form surface between unlike sections. +- `perforated-plate`: A 3 mm plate perforated by a 6 x 4 grid of 6 mm holes: genus 24 in a thin sheet. +- `pinhole-block`: A 50 mm block drilled through by sixteen 0.6 mm pinholes: features 80 times smaller than the part, genus 16. +- `rounded-box`: A 40 x 30 x 20 box with every edge rounded R3: cylinder and sphere blends meeting at the corners. +- `shallow-groove`: A block with a 0.5 mm deep groove cut by an R30 cylinder: groove walls 10 degrees off the top face. +- `sharp-wedge`: A wedge whose faces meet at under 3 degrees: a sharp edge with a needle-thin cross-section. +- `sphere-on-plate`: A sphere sunk 0.1 mm into a plate: the faces meet at under 6 degrees around a 2 mm circle. +- `spline-vase`: A vase revolved from a spline profile: doubly curved faces of varying curvature around a closed axis. +- `stepped-block`: Three stacked blocks with a slot cut through the base: axis-aligned steps for polycube and octree meshers. +- `thin-ribs`: A 4 mm plate carrying five 0.8 mm ribs 20 mm tall: thin walls standing on a thicker base. +- `thin-wall-enclosure`: An 80 x 60 x 40 box shelled to 1 mm walls, open on top: thin walls over a large span. +- `analytic-sphere`: Sphere r 20: curvature everywhere, no edges. +- `analytic-torus`: Torus 30/8: genus 1 with doubly curved faces and no edges. +- `analytic-cylinder`: Cylinder r 10, h 40: the round bar of beam and torsion checks. +- `analytic-pipe`: Thick-walled pipe 20/30, length 60: the Lamé cylinder. +- `analytic-plate-hole`: Plate 200 x 100 x 5 with a 20 mm hole: the Kirsch plate. diff --git a/tests/corpus/bent-tube/README.md b/tests/corpus/bent-tube/README.md new file mode 100644 index 0000000..84a49f3 --- /dev/null +++ b/tests/corpus/bent-tube/README.md @@ -0,0 +1 @@ +A 10 mm tube with a 1 mm wall, bent through R30: a thin-walled sweep along a line-arc-line path. diff --git a/tests/corpus/bent-tube/recipe.json b/tests/corpus/bent-tube/recipe.json new file mode 100644 index 0000000..00a3c3f --- /dev/null +++ b/tests/corpus/bent-tube/recipe.json @@ -0,0 +1,9 @@ +{"corpus": {"categories": ["sweepable", "thin-wall", "genus"], "volume_mm3": 4159.829982}, + "commands": [ + {"command": "sketch.create", "params": {"plane": "XY", "name": "Path"}}, + {"command": "sketch.line", "params": {"points": [[0, 0], [50, 0]], "ids": ["l1"]}}, + {"command": "sketch.arc.center_point", "params": {"center": [50, 30], "start": "l1.end", "sweep": 90, "id": "a1"}}, + {"command": "sketch.line", "params": {"points": ["a1.end", [80, 80]], "ids": ["l2"]}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.pipe", "params": {"path_sketch": "Path", "path": ["l1", "a1", "l2"], "diameter": 10, "wall": 1, "body_name": "Tube"}} + ]} diff --git a/tests/corpus/bolted-assembly/README.md b/tests/corpus/bolted-assembly/README.md new file mode 100644 index 0000000..0b8f58d --- /dev/null +++ b/tests/corpus/bolted-assembly/README.md @@ -0,0 +1 @@ +A base plate with a clamp block component placed twice, once turned 90 degrees: bodies placed by component transforms. diff --git a/tests/corpus/bolted-assembly/recipe.json b/tests/corpus/bolted-assembly/recipe.json new file mode 100644 index 0000000..2ec67aa --- /dev/null +++ b/tests/corpus/bolted-assembly/recipe.json @@ -0,0 +1,11 @@ +{"corpus": {"categories": ["assembly", "blocky"], "volume_mm3": 32998.93807}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 100, "width": 60, "height": 5, "body_name": "Base"}}, + {"command": "component.create", "params": {"name": "Clamp"}}, + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 20, "width": 10, "height": 8, "body_name": "Clamp body"}}, + {"command": "solid.hole", "params": {"position": [10, 5, 8], "diameter": 4}}, + {"command": "component.activate", "params": {"component": "root"}}, + {"command": "occurrence.move", "params": {"occurrence": "Clamp:1", "translate": [10, 10, 5]}}, + {"command": "occurrence.copy", "params": {"component": "Clamp", "translate": [50, 0, 0]}}, + {"command": "occurrence.move", "params": {"occurrence": "Clamp:2", "axis": [0, 0, 1], "angle": "90 deg", "origin": [70, 15, 5]}} + ]} diff --git a/tests/corpus/cross-cylinders/README.md b/tests/corpus/cross-cylinders/README.md new file mode 100644 index 0000000..54e2fad --- /dev/null +++ b/tests/corpus/cross-cylinders/README.md @@ -0,0 +1 @@ +Two orthogonal R10 cylinders joined: equal radii, so the intersection curves cross at two singular points. diff --git a/tests/corpus/cross-cylinders/recipe.json b/tests/corpus/cross-cylinders/recipe.json new file mode 100644 index 0000000..6a606fb --- /dev/null +++ b/tests/corpus/cross-cylinders/recipe.json @@ -0,0 +1,5 @@ +{"corpus": {"categories": ["boolean", "sharp"], "volume_mm3": 32365.77851}, + "commands": [ + {"command": "solid.cylinder", "params": {"base": [-30, 0, 0], "axis": "X", "radius": 10, "height": 60, "body_name": "Cross"}}, + {"command": "solid.cylinder", "params": {"base": [0, -30, 0], "axis": "Y", "radius": 10, "height": 60, "operation": "join", "targets": ["Cross"]}} + ]} diff --git a/tests/corpus/filleted-bracket/README.md b/tests/corpus/filleted-bracket/README.md new file mode 100644 index 0000000..399db45 --- /dev/null +++ b/tests/corpus/filleted-bracket/README.md @@ -0,0 +1 @@ +An 8 mm L-bracket with an R6 inside fillet and a hole through each leg: a blend beside holes. diff --git a/tests/corpus/filleted-bracket/recipe.json b/tests/corpus/filleted-bracket/recipe.json new file mode 100644 index 0000000..7839305 --- /dev/null +++ b/tests/corpus/filleted-bracket/recipe.json @@ -0,0 +1,10 @@ +{"corpus": {"categories": ["fillet", "genus", "sweepable"], "volume_mm3": 32144.778925}, + "commands": [ + {"command": "sketch.create", "params": {"plane": "XY", "name": "Profile"}}, + {"command": "sketch.line", "params": {"points": [[0, 0], [60, 0], [60, 8], [8, 8], [8, 50], [0, 50]], "closed": true}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.extrude", "params": {"distance": 40, "body_name": "Bracket"}}, + {"command": "solid.fillet", "params": {"edges": [[8, 8, 20]], "radius": 6}}, + {"command": "solid.hole", "params": {"position": [40, 8, 20], "diameter": 8}}, + {"command": "solid.hole", "params": {"position": [8, 32, 20], "diameter": 8}} + ]} diff --git a/tests/corpus/i-beam/README.md b/tests/corpus/i-beam/README.md new file mode 100644 index 0000000..6a413c9 --- /dev/null +++ b/tests/corpus/i-beam/README.md @@ -0,0 +1 @@ +A 200 mm I-beam with 3 mm flanges and a 2 mm web: a long sweepable prism with thin walls. diff --git a/tests/corpus/i-beam/recipe.json b/tests/corpus/i-beam/recipe.json new file mode 100644 index 0000000..04aae14 --- /dev/null +++ b/tests/corpus/i-beam/recipe.json @@ -0,0 +1,7 @@ +{"corpus": {"categories": ["sweepable", "thin-wall"], "volume_mm3": 61600}, + "commands": [ + {"command": "sketch.create", "params": {"plane": "XY", "name": "Section"}}, + {"command": "sketch.line", "params": {"points": [[-20, 0], [20, 0], [20, 3], [1, 3], [1, 37], [20, 37], [20, 40], [-20, 40], [-20, 37], [-1, 37], [-1, 3], [-20, 3]], "closed": true}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.extrude", "params": {"distance": 200, "body_name": "Beam"}} + ]} diff --git a/tests/corpus/loft-transition/README.md b/tests/corpus/loft-transition/README.md new file mode 100644 index 0000000..2d899e4 --- /dev/null +++ b/tests/corpus/loft-transition/README.md @@ -0,0 +1 @@ +A 40 mm square lofted to an R15 circle 50 mm above: a ruled free-form surface between unlike sections. diff --git a/tests/corpus/loft-transition/recipe.json b/tests/corpus/loft-transition/recipe.json new file mode 100644 index 0000000..215716e --- /dev/null +++ b/tests/corpus/loft-transition/recipe.json @@ -0,0 +1,11 @@ +{"corpus": {"categories": ["organic"]}, + "commands": [ + {"command": "sketch.create", "params": {"plane": "XY", "name": "Bottom"}}, + {"command": "sketch.rectangle.center", "params": {"center": [0, 0], "corner": [20, 20]}}, + {"command": "sketch.finish", "params": {}}, + {"command": "construct.plane.offset", "params": {"base": "XY", "offset": "50 mm", "name": "TopPlane"}}, + {"command": "sketch.create", "params": {"plane": "TopPlane", "name": "Top"}}, + {"command": "sketch.circle.center", "params": {"center": [0, 0], "radius": 15}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.loft", "params": {"sections": [{"sketch": "Bottom"}, {"sketch": "Top"}], "body_name": "Transition"}} + ]} diff --git a/tests/corpus/perforated-plate/README.md b/tests/corpus/perforated-plate/README.md new file mode 100644 index 0000000..bb228e9 --- /dev/null +++ b/tests/corpus/perforated-plate/README.md @@ -0,0 +1 @@ +A 3 mm plate perforated by a 6 x 4 grid of 6 mm holes: genus 24 in a thin sheet. diff --git a/tests/corpus/perforated-plate/recipe.json b/tests/corpus/perforated-plate/recipe.json new file mode 100644 index 0000000..ff5d660 --- /dev/null +++ b/tests/corpus/perforated-plate/recipe.json @@ -0,0 +1,31 @@ +{"corpus": {"categories": ["genus", "thin-wall", "sweepable"], "volume_mm3": 26764.24796}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 120, "width": 80, "height": 3, "body_name": "Plate"}}, + {"command": "sketch.create", "params": {"plane": "XY", "name": "Perforation"}}, + {"command": "sketch.circle.center", "params": {"center": [15, 13], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [15, 31], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [15, 49], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [15, 67], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [33, 13], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [33, 31], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [33, 49], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [33, 67], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [51, 13], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [51, 31], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [51, 49], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [51, 67], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [69, 13], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [69, 31], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [69, 49], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [69, 67], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [87, 13], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [87, 31], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [87, 49], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [87, 67], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [105, 13], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [105, 31], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [105, 49], "diameter": 6}}, + {"command": "sketch.circle.center", "params": {"center": [105, 67], "diameter": 6}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.extrude", "params": {"distance": 3, "operation": "cut"}} + ]} diff --git a/tests/corpus/pinhole-block/README.md b/tests/corpus/pinhole-block/README.md new file mode 100644 index 0000000..5f6e46e --- /dev/null +++ b/tests/corpus/pinhole-block/README.md @@ -0,0 +1 @@ +A 50 mm block drilled through by sixteen 0.6 mm pinholes: features 80 times smaller than the part, genus 16. diff --git a/tests/corpus/pinhole-block/recipe.json b/tests/corpus/pinhole-block/recipe.json new file mode 100644 index 0000000..d86bea4 --- /dev/null +++ b/tests/corpus/pinhole-block/recipe.json @@ -0,0 +1,23 @@ +{"corpus": {"categories": ["small-feature", "genus"], "volume_mm3": 49909.522132}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 50, "width": 50, "height": 20, "body_name": "Block"}}, + {"command": "sketch.create", "params": {"plane": "XY", "name": "Pinholes"}}, + {"command": "sketch.circle.center", "params": {"center": [10, 10], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [10, 20], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [10, 30], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [10, 40], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [20, 10], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [20, 20], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [20, 30], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [20, 40], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [30, 10], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [30, 20], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [30, 30], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [30, 40], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [40, 10], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [40, 20], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [40, 30], "diameter": 0.6}}, + {"command": "sketch.circle.center", "params": {"center": [40, 40], "diameter": 0.6}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.extrude", "params": {"distance": 20, "operation": "cut"}} + ]} diff --git a/tests/corpus/rounded-box/README.md b/tests/corpus/rounded-box/README.md new file mode 100644 index 0000000..b1c921f --- /dev/null +++ b/tests/corpus/rounded-box/README.md @@ -0,0 +1 @@ +A 40 x 30 x 20 box with every edge rounded R3: cylinder and sphere blends meeting at the corners. diff --git a/tests/corpus/rounded-box/recipe.json b/tests/corpus/rounded-box/recipe.json new file mode 100644 index 0000000..30bb776 --- /dev/null +++ b/tests/corpus/rounded-box/recipe.json @@ -0,0 +1,5 @@ +{"corpus": {"categories": ["fillet"], "volume_mm3": 23340.849375}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 40, "width": 30, "height": 20, "body_name": "Box"}}, + {"command": "solid.fillet", "params": {"edges": [[0, 0, 10.0], [0, 30, 10.0], [40, 0, 10.0], [40, 30, 10.0], [0, 15.0, 0], [0, 15.0, 20], [40, 15.0, 0], [40, 15.0, 20], [20.0, 0, 0], [20.0, 0, 20], [20.0, 30, 0], [20.0, 30, 20]], "radius": 3}} + ]} diff --git a/tests/corpus/shallow-groove/README.md b/tests/corpus/shallow-groove/README.md new file mode 100644 index 0000000..ee7f288 --- /dev/null +++ b/tests/corpus/shallow-groove/README.md @@ -0,0 +1 @@ +A block with a 0.5 mm deep groove cut by an R30 cylinder: groove walls 10 degrees off the top face. diff --git a/tests/corpus/shallow-groove/recipe.json b/tests/corpus/shallow-groove/recipe.json new file mode 100644 index 0000000..7caa19e --- /dev/null +++ b/tests/corpus/shallow-groove/recipe.json @@ -0,0 +1,5 @@ +{"corpus": {"categories": ["near-tangent", "boolean"], "volume_mm3": 47781.459517}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 60, "width": 40, "height": 20, "body_name": "Block"}}, + {"command": "solid.cylinder", "params": {"base": [0, 20, 49.5], "axis": "X", "radius": 30, "height": 60, "operation": "cut", "targets": ["Block"]}} + ]} diff --git a/tests/corpus/sharp-wedge/README.md b/tests/corpus/sharp-wedge/README.md new file mode 100644 index 0000000..0654221 --- /dev/null +++ b/tests/corpus/sharp-wedge/README.md @@ -0,0 +1 @@ +A wedge whose faces meet at under 3 degrees: a sharp edge with a needle-thin cross-section. diff --git a/tests/corpus/sharp-wedge/recipe.json b/tests/corpus/sharp-wedge/recipe.json new file mode 100644 index 0000000..ccdcd68 --- /dev/null +++ b/tests/corpus/sharp-wedge/recipe.json @@ -0,0 +1,7 @@ +{"corpus": {"categories": ["sharp", "thin-wall", "sweepable"], "volume_mm3": 3200.0}, + "commands": [ + {"command": "sketch.create", "params": {"plane": "XY", "name": "Profile"}}, + {"command": "sketch.line", "params": {"points": [[0, 0], [80, 0], [80, 4]], "closed": true}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.extrude", "params": {"distance": 20, "body_name": "Wedge"}} + ]} diff --git a/tests/corpus/sphere-on-plate/README.md b/tests/corpus/sphere-on-plate/README.md new file mode 100644 index 0000000..eb622cf --- /dev/null +++ b/tests/corpus/sphere-on-plate/README.md @@ -0,0 +1 @@ +A sphere sunk 0.1 mm into a plate: the faces meet at under 6 degrees around a 2 mm circle. diff --git a/tests/corpus/sphere-on-plate/recipe.json b/tests/corpus/sphere-on-plate/recipe.json new file mode 100644 index 0000000..1de9dd5 --- /dev/null +++ b/tests/corpus/sphere-on-plate/recipe.json @@ -0,0 +1,5 @@ +{"corpus": {"categories": ["near-tangent", "boolean"], "volume_mm3": 69509.694367}, + "commands": [ + {"command": "solid.box", "params": {"corner": [-30, -30, -10], "length": 60, "width": 60, "height": 10, "body_name": "Plate"}}, + {"command": "solid.sphere", "params": {"center": [0, 0, 19.9], "radius": 20, "operation": "join", "targets": ["Plate"]}} + ]} diff --git a/tests/corpus/spline-vase/README.md b/tests/corpus/spline-vase/README.md new file mode 100644 index 0000000..9f8153a --- /dev/null +++ b/tests/corpus/spline-vase/README.md @@ -0,0 +1 @@ +A vase revolved from a spline profile: doubly curved faces of varying curvature around a closed axis. diff --git a/tests/corpus/spline-vase/recipe.json b/tests/corpus/spline-vase/recipe.json new file mode 100644 index 0000000..a37bf4b --- /dev/null +++ b/tests/corpus/spline-vase/recipe.json @@ -0,0 +1,9 @@ +{"corpus": {"categories": ["organic"]}, + "commands": [ + {"command": "sketch.create", "params": {"plane": "XZ", "name": "Profile"}}, + {"command": "sketch.line", "params": {"points": [[0, 0], [20, 0]], "ids": ["base"]}}, + {"command": "sketch.spline.fit_point", "params": {"points": ["base.end", [28, 20], [14, 45], [18, 70]]}}, + {"command": "sketch.line", "params": {"points": [[18, 70], [0, 70], [0, 0]]}}, + {"command": "sketch.finish", "params": {}}, + {"command": "solid.revolve", "params": {"axis": "Z", "body_name": "Vase"}} + ]} diff --git a/tests/corpus/stepped-block/README.md b/tests/corpus/stepped-block/README.md new file mode 100644 index 0000000..756664a --- /dev/null +++ b/tests/corpus/stepped-block/README.md @@ -0,0 +1 @@ +Three stacked blocks with a slot cut through the base: axis-aligned steps for polycube and octree meshers. diff --git a/tests/corpus/stepped-block/recipe.json b/tests/corpus/stepped-block/recipe.json new file mode 100644 index 0000000..33abb2a --- /dev/null +++ b/tests/corpus/stepped-block/recipe.json @@ -0,0 +1,7 @@ +{"corpus": {"categories": ["blocky", "sharp"], "volume_mm3": 47000}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 60, "width": 40, "height": 10, "body_name": "Steps"}}, + {"command": "solid.box", "params": {"corner": [0, 0, 10], "length": 40, "width": 40, "height": 10, "operation": "join", "targets": ["Steps"]}}, + {"command": "solid.box", "params": {"corner": [0, 0, 20], "length": 20, "width": 40, "height": 10, "operation": "join", "targets": ["Steps"]}}, + {"command": "solid.box", "params": {"corner": [45, 15, 0], "length": 10, "width": 10, "height": 10, "operation": "cut", "targets": ["Steps"]}} + ]} diff --git a/tests/corpus/thin-ribs/README.md b/tests/corpus/thin-ribs/README.md new file mode 100644 index 0000000..88fdb67 --- /dev/null +++ b/tests/corpus/thin-ribs/README.md @@ -0,0 +1 @@ +A 4 mm plate carrying five 0.8 mm ribs 20 mm tall: thin walls standing on a thicker base. diff --git a/tests/corpus/thin-ribs/recipe.json b/tests/corpus/thin-ribs/recipe.json new file mode 100644 index 0000000..2ec46ef --- /dev/null +++ b/tests/corpus/thin-ribs/recipe.json @@ -0,0 +1,9 @@ +{"corpus": {"categories": ["thin-wall", "blocky"], "volume_mm3": 32000.0}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 100, "width": 60, "height": 4, "body_name": "Plate"}}, + {"command": "solid.box", "params": {"corner": [0, 9.6, 4], "length": 100, "width": 0.8, "height": 20, "operation": "join", "targets": ["Plate"]}}, + {"command": "solid.box", "params": {"corner": [0, 19.6, 4], "length": 100, "width": 0.8, "height": 20, "operation": "join", "targets": ["Plate"]}}, + {"command": "solid.box", "params": {"corner": [0, 29.6, 4], "length": 100, "width": 0.8, "height": 20, "operation": "join", "targets": ["Plate"]}}, + {"command": "solid.box", "params": {"corner": [0, 39.6, 4], "length": 100, "width": 0.8, "height": 20, "operation": "join", "targets": ["Plate"]}}, + {"command": "solid.box", "params": {"corner": [0, 49.6, 4], "length": 100, "width": 0.8, "height": 20, "operation": "join", "targets": ["Plate"]}} + ]} diff --git a/tests/corpus/thin-wall-enclosure/README.md b/tests/corpus/thin-wall-enclosure/README.md new file mode 100644 index 0000000..5d37cfa --- /dev/null +++ b/tests/corpus/thin-wall-enclosure/README.md @@ -0,0 +1 @@ +An 80 x 60 x 40 box shelled to 1 mm walls, open on top: thin walls over a large span. diff --git a/tests/corpus/thin-wall-enclosure/recipe.json b/tests/corpus/thin-wall-enclosure/recipe.json new file mode 100644 index 0000000..b231adb --- /dev/null +++ b/tests/corpus/thin-wall-enclosure/recipe.json @@ -0,0 +1,5 @@ +{"corpus": {"categories": ["thin-wall", "blocky"], "volume_mm3": 15564}, + "commands": [ + {"command": "solid.box", "params": {"corner": [0, 0, 0], "length": 80, "width": 60, "height": 40, "body_name": "Enclosure"}}, + {"command": "solid.shell", "params": {"faces": [[40, 30, 40]], "thickness": 1}} + ]} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 33bd207..c13f9cf 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -25,6 +25,9 @@ commands: test [CARGO ARGS] [-- TEST ARGS] build the tests with the ci profile, then run every test binary at once (and the doc tests alongside) + corpus [--part NAME] [--no-write] + build every meshing test corpus part (tests/corpus, analytic shapes), tessellate + and mesh it, and write the results to docs/meshing/corpus.md (release build) wasm cargo check every library crate for wasm32-unknown-unknown ci fmt --check, assets, licences --check, layers, clippy -D warnings, then the tests with the wasm check alongside (stops at the first failing step) @@ -42,6 +45,12 @@ fn main() -> ExitCode { test::run(cargo_args, test_args, vec![test::doc_tests(cargo_args, test_args)]) } Some("ci") => cmd_ci(), + Some("corpus") => { + // A binary of the testkit, so xtask itself stays free of SolidCraft. + let mut c = cargo(); + c.args(["run", "--release", "-p", "modelcraft-testkit", "--bin", "corpus", "--"]).args(&rest); + run(c, "corpus") + } Some("wasm") => cmd_wasm(), Some("-h" | "--help" | "help") | None => { print!("{USAGE}");