Files
CamWight 94d2d95fff Drawing export: a sheet as a vector PDF, geometry only, as a starting point for the PDF work (#4890) (#7626)
* io: the date rule crash reports use, for other writers too (#4890 P1)

civil (seconds since 1970 to a UTC year, month, day, hour, minute and second)
moves from engine::crash down to solidcraft_io, unchanged, so sheet PDFs can
write their dates by the same rule. Crash reports call it from there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Paper scene: a sheet as a vector PDF, geometry only (#4890 P1)

A new writer, io::paper::paper_pdf, beside paper_svg and paper_png, reading
the same walk: one page the sheet's size, its lines, arcs, cubics, parabolas,
fills and dashes. Text follows with P2.

- The file comes from pdf-writer 0.15 (MIT OR Apache-2.0; brings ryu): a
  catalog, one page whose MediaBox is the sheet in points, the content
  deflated with flate2 (already in the tree through zip), and an Info
  dictionary: Producer "SolidCraft <version>", the Title when one is given,
  and CreationDate/ModDate only from PdfOptions::output_time (UTC), never the
  clock, so a scene always gives the same bytes. ISO 32000-1 14.3.3: unknown
  entries are left out, not written empty.
- Numbers: the walk runs on a 10 nm grid (Grid::TEN_NANOMETRES), written as
  millimetres with up to five decimals (Annex C's precision) inside one
  `2.834645669 0 0 2.834645669 0 0 cm`; y is up in both, so nothing flips. The
  SVG writer's number rule moves to io::paper::push_mm, taking the decimals.
- Arcs: each of the walk's quarter-turn pieces is cut into as many 4/3 tan(t/4)
  cubics as keep it within 1e-4 mm, the rounding of control points onto the
  grid included (one cubic a quarter turn would be 2.7e-4 r off). The arc's
  centre comes from Piece::seg, the rule the flattener used, moved onto Piece
  so both read it. Parabolas are raised to cubics.
- Paint: w at the walked width (never 0: 8.4.3.2 says 0 is a device pixel),
  0 J 0 j 4 M as SVG and PNG, d for A5's dashes, each set only when it changes;
  closed outlines `s`, fills even-odd `f*`.
- Refused: a page under 3 pt a side (Annex C), a title over 1,000 characters,
  a date past 9999.
- Dates use io::civil, the crash reports' rule (moved in the commit below).

Tests: the A3 MediaBox; 50 mm on paper is 141.732 pt; the same bytes twice,
dates only from output_time (2000-02-29 and 9999-12-31 23:59:59); every xref
entry at its object; arcs from 0.5 mm to 2 m radius within 1e-4 mm and a
parabola on its cubic, every number at most five decimals; widths, dashes,
closes and fills as the other writers paint them; the refusals. One fuzz scene
now feeds the SVG, PNG and PDF mutation tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(pdf): validate byte offsets and separate page-scale precision

Continue the P1 handoff in #7626 with original commits preserved. Only the existing PDF test module changes. Complete IO library 153/0/2 existing ignored, scoped strict Clippy and wasm pass. Full workspace gate remains unqualified on the limited-memory drawings receiver; see PR evidence.

* fix(pdf): enforce the content budget before buffer growth

Continue P1 in #7626. Four regressions reproduce the previous late-check policy using tightened limits; six budget tests pass with all 159 IO library tests, scoped strict Clippy and wasm. Original A3 output bytes unchanged. The limited-memory full-workspace gate remains explicitly unqualified; no CI changes.

* feat(pdf): group paper objects into optional layers

Continue the existing #7626 handoff with five ordered default-visible optional-content groups, bounded marked content, paint order and style preservation. Original implementation and earlier tests retained; an original five-kind repeated-group fixture adds independent structure and PDFium visibility acceptance.

Focused validation: complete IO 162 passed, 0 failed, 2 existing ignored; all18 PDF cases, strict IO Clippy and wasm passed. Exact native build artifact reused after a preserved private runner drain failure. Full cargo xtask ci, Drawing UI and print acceptance remain unrun; this is saved draft work, not a ready/merge claim.

* feat(pdf): support flat vector output without optional layers

Preserve default layered output and vector paint. Original acceptance covers flat metadata, exact content limits, empty groups and the original 1063-byte A3 pin. Complete IO165/0/2 existing ignored, all21 PDF cases, strict Clippy, wasm and independent five-layer/flat raster checks passed on unchanged final source. An earlier new-test metadata indentation failure is preserved separately and corrected with stricter raw-byte metadata assertions. Full workspace CI and editor/print qualification remain outstanding; saved draft increment in #7626.

* perf(pdf): coalesce adjacent optional-content runs

* Paper PDF: rebased onto drawings, the writer against today's paper scene (#4890 P1)

The sheet PDF writer and @0xlillith's layer, budget and flat-output work,
replayed onto drawings 8a0b1fdfe1. What the replayed commits couldn't hold:

- Geometry only, as before: the scene's text runs (B1b, B2a) and pictures
  (#10926) are passed over; text follows with P2. A group with no stroke or
  fill puts no mark on the page, so it invents no layer and doesn't break a
  run of one kind (`painted`, the one test the layers and the content share).
- Seg2 and Vec2 come from solidcore-record and the vector maths from the
  geom prelude (#11496).
- The tests build scenes with Scene::new (scenes now carry fonts and clips).

Line widths need nothing: the walk already gives each stroke its kind's and
line group's width (#12232). The replayed commits keep their resolutions:
the io paper module keeps PaperColour beside push_mm, and the PDF fuzz test
is built like the SVG and PNG ones, on seed 0x5a7 (0x5a5 is the clip test's).

Test change: flat_pdf_reproduces_the_original_p1_a3_sample_bytes pinned the
whole file, and its Info dictionary names the build ("SolidCraft 0.19.0" then,
0.41.0 now). The same file with 0.19.0 put back has the old SHA-256, so the
drawing's bytes are unchanged. The pin is now the 721 bytes before the Info
dictionary, and the Producer is checked against this build's version, so a
release bump no longer moves it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Paper PDF: an arc piece a little over a quarter turn is written, not refused (#4890 P1)

A drilled plate's iso view failed the sheet PDF with "an arc needs too many cubics", while its SVG
and PNG were fine. The walk's arc pieces are about a quarter turn, but can turn a little more: their
ends are rounded onto the 10 nm grid, and a sliver piece merges into the next. cubics_for refused
anything past a quarter turn plus 1e-9.

cubics_for now takes up to a half turn, and starts from enough cubics that each spans at most a
quarter turn. Any arc it wrote before starts at one cubic as before, so it writes the same bytes:
the byte pins pass unchanged. Piece::Arc's doc says what the walk gives (a comment change only in
geom). The scene caps a sweep at a whole turn plus 1e-12, so the walk's four-piece cap adds
nothing past the old slack.

Found by @DevonHope on #9647, with this fix and its unit test
(an_arc_a_little_over_a_quarter_turn_is_written). The second test walks Ø16 circles at nearby
centres until one gives a piece past a quarter turn, then writes each and checks every cubic lies
on the circle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Paper PDF: the flattener and a grid piece's curve move into io, beside the PNG and PDF writers that use them (#4890 P1)

geom's paper module only shrinks (CONTRIBUTING). Its flattener had one caller, io's PNG
writer, and the stack had added `Piece::seg`, `GridPoint::vec` and a 10 nm grid constant
to geom for io's PDF writer. They now live in io/src/paper/flatten.rs, with the
flattener's tests unchanged except one call form: `flatten`, `seg` (a piece's curve,
which both writers read) and `vec`. The PDF writer makes its own 10 nm grid with
`Grid::new`. Nothing writes different bytes: the PNG and PDF byte pins pass as they were.

geom's walk test for an ellipse's cubics checked them by flattening them. It now samples
each cubic itself, with the same bound, so geom's test needs no io.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Paper PDF: each writer's grid and its number text are one decimals value, and io lists the grids (#4890 P1)

A paper writer's precision was two facts that had to agree: PDF kept PER_MM and
DECIMALS, SVG kept the nanometre grid and its six decimals, and PNG named the
nanometre grid too. Now io/src/paper.rs holds one Decimals value for each: whole
nanometres (SVG's numbers, PNG's grid) and 10 nm (PDF's). Each gives the writer
its grid and writes its numbers.

io lists the writers' grids (writer_grids). The engine's hatch-dot check in
drawing_scene/fill.rs, from @0xlillith's saved fills, loops over that list instead
of keeping its own copy of the PDF grid, so a new writer's grid reaches it too.

Docs: the flattener's notes no longer say PDF flattens curves, and its cap is
MAX_PATH_POINTS, apart from the PNG writer's MAX_POINTS. Two geom doc comments
(grid.rs, cubic_pieces.rs) say what the code does, in the same number of lines,
and the xref check's comment says what its bound is. No bytes change: the PDF and
SVG byte pins pass as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: lillith <35337584+0xlillith@users.noreply.github.com>
2026-11-17 15:31:40 -05:00

214 lines
9.5 KiB
TOML

[workspace]
resolver = "3"
members = ["crates/*", "apps/*", "xtask"]
# Third-party code kept with local fixes (vendor/), and the vendored SolidCore kernel (solidcore/);
# neither is linted as ours. See CONTRIBUTING.md, "How the code is laid out".
exclude = ["solidcore", "vendor"]
[workspace.package]
version = "0.41.0"
edition = "2024"
license = "MIT OR Apache-2.0"
rust-version = "1.95"
authors = ["SolidCraft contributors"]
repository = "https://github.com/bherbruck/solidcraft"
[workspace.dependencies]
robust = "1.2"
# internal
craft-plugin = { path = "crates/craft-plugin" }
craft-plugin-wasm = { path = "crates/craft-plugin-wasm" }
solidcraft-geom = { path = "crates/geom" }
solidcraft-profile = { path = "crates/profile" }
solidcraft-sketch = { path = "crates/sketch" }
solidcraft-kernel = { path = "crates/kernel" }
solidcraft-smlib = { path = "crates/smlib" }
solidcraft-render = { path = "crates/render" }
solidcraft-dynamics = { path = "crates/dynamics" }
solidcraft-gpu = { path = "crates/gpu" }
solidcraft-doc = { path = "crates/doc" }
# Versioned file formats: the format tag, the version registry and its upgrade, a newer file told
solidcraft-format = { path = "crates/format" }
solidcraft-io = { path = "crates/io" }
solidcraft-engine = { path = "crates/engine" }
solidcraft-ui-egui = { path = "crates/ui-egui" }
solidcraft-ui-kit = { path = "crates/ui-kit" }
solidcraft-look = { path = "crates/look" }
solidcraft-ui-registry = { path = "crates/ui-registry" }
solidcraft-color = { path = "crates/color" }
solidcraft-ui-text = { path = "crates/ui-text" }
solidcraft-theme = { path = "crates/theme" }
solidcraft-viewport = { path = "crates/viewport" }
solidcraft-viewport-egui = { path = "crates/viewport-egui" }
solidcraft-viewport-gpu = { path = "crates/viewport-gpu" }
solidcraft-space-mouse = { path = "crates/space-mouse" }
solidcraft-mcp = { path = "crates/mcp" }
solidcraft-mcp-server = { path = "crates/mcp-server" }
solidcraft-control = { path = "crates/control" }
solidcraft-control-egui = { path = "crates/control-egui" }
solidcraft-derive = { path = "crates/derive" }
solidcraft-3dx-client = { path = "crates/threedx-client" }
# The Rust port of NVIDIA's SMLib (Apache-2.0), the B-rep kernel behind crates/smlib. Vendored with
# `git subtree` at solidcore: that tree is the source of truth, and
# .github/workflows/solidcore-mirror.yml pushes changes in it back to its own repository (#13153).
solidcore = { path = "solidcore/crates/solidcore" }
# Geometry as data (solidcore's layers §1, "Record"): the B-rep record, its structural validation
# and the native body file. Vendored with solidcore, in the same subtree.
solidcore-record = { path = "solidcore/crates/solidcore-record" }
# The modelling layer (solidcore's layers §1, "Ops"): the record-level calls SolidCraft makes into the
# kernel, converting through solidcore-convert.
solidcore-ops = { path = "solidcore/crates/solidcore-ops" }
# STEP import and export (vendored with solidcore): the Part 21 parser is solidcore-record's.
solidcore-step = { path = "solidcore/crates/solidcore-step" }
# Geometry made drawable (solidcore's layers §3): the one mesher, SolidCraft's, moved into the
# subtree (RFC 0003, item 1.1), with the display mesh and its levels of detail, the types
# SolidCraft's meshes are. Vendored with solidcore, in the same subtree.
solidcore-tess = { path = "solidcore/crates/solidcore-tess" }
# test tooling: a dev-dependency only (xtask/src/layers.rs)
solidcraft-testkit = { path = "crates/testkit" }
# foundation
thiserror = "2"
serde = { version = "1", features = ["derive", "rc"] }
# derive macros (crates/derive); already in the tree through serde_derive
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
serde_json = { version = "1", features = ["float_roundtrip"] }
# command parameter and result schemas
schemars = "1.2"
serde_path_to_error = "0.1"
log = "0.4"
sha2 = "0.10"
# Provenance: the CBOR manifest encoding (RFC 8949), COSE_Sign1 records (RFC 9052) and Ed25519
# (RFC 8032). All pure Rust and permissive (Apache-2.0; BSD-3-Clause), so the browser build and
# `cargo xtask licences --check` keep working.
ciborium = { version = "0.2", default-features = false, features = ["std"] }
serde_bytes = "0.11"
coset = "0.4"
ed25519-dalek = { version = "2.1", default-features = false, features = ["std", "zeroize"] }
# OpenPGP detached-signature verification (MIT OR Apache-2.0; pure Rust, builds for wasm with
# its `wasm` feature). GnuPG signs for a key on a smartcard; no key material is copied out.
pgp = { version = "=0.21.1", default-features = false, features = ["wasm"] }
moxcms = { version = "0.8.1", default-features = false, features = ["extended_range"] }
semver = "1"
# constrained Delaunay + Ruppert refinement for trimmed faces (MIT OR Apache-2.0).
spade = { version = "2.15", default-features = false, features = ["std"] }
rayon = "1.12"
# Native render-memory admission; RAM-only queries through a safe MIT-licensed API.
sysinfo = { version = "0.40.1", default-features = false, features = ["system"] }
# packages (3MF)
zip = { version = "9", default-features = false, features = ["deflate"] }
quick-xml = "0.41"
# STEP text in a legacy encoding (GBK, Shift_JIS, …) instead of Part 21 escapes (#2344): detect
# and decode it. Both MIT OR Apache-2.0 (encoding_rs adds BSD-3-Clause data); encoding_rs is
# already in the tree through cadmpeg-codec-step.
chardetng = "0.1"
encoding_rs = "0.8"
# glTF 2.0 import (MIT OR Apache-2.0): the document model and GLB container only; buffers are
# read by crates/io itself, so no image decoding or file access comes with it.
gltf = { version = "1.4", default-features = false, features = ["names"] }
# The computer's name in a design's "open elsewhere" lock file (MIT OR Apache-2.0; already in the
# tree through x11rb).
gethostname = "1"
# FreeCAD and Rhino import (Apache-2.0, pure Rust; native and browser builds).
# Pinned: its IR and codec APIs change between minor versions. Open formats only: no default
# features, so cadmpeg's codecs for commercial formats (f3d, sldprt, inventor, catia, creo, nx)
# and its ShapeManager/ACIS `sat` codec are not compiled in. `step` is the writer we restate through.
cadmpeg-core = "=0.6.7"
cadmpeg-ir = "=0.6.7"
cadmpeg-registry = { version = "=0.6.7", default-features = false, features = ["fcstd", "rhino", "step"] }
# fonts (sketch text outlines; MIT OR Apache-2.0, pure Rust)
ttf-parser = { version = "0.25", default-features = false, features = ["std", "variable-fonts"] }
# Ends a process group with the system call (MIT; already in the tree through zip).
nix = { version = "0.31", default-features = false, features = ["signal"] }
# images
image = { version = "0.25", default-features = false, features = ["png", "hdr"] }
png = "0.18.1"
# LZW for GIF animations (MIT OR Apache-2.0, pure Rust; already in the tree through image's tiff).
weezl = "0.1.12"
# sheet PDFs (MIT OR Apache-2.0, pure Rust; brings ryu, Apache-2.0 OR BSL-1.0)
pdf-writer = "0.15"
# deflate for PDF content streams (MIT OR Apache-2.0; already in the tree through zip)
flate2 = "1.1"
# rasterises the UI icon SVGs (BSD-3-Clause, pure Rust, builds for wasm)
tiny-skia = { version = "0.12", default-features = false, features = ["std", "simd"] }
# build scripts: reads the icon palette (MIT OR Apache-2.0)
toml = "1"
# ui
# default_fonts: the built-in Hack is the UI's symbol fallback (#2955); 0.37 no longer turns it on.
egui = { version = "0.37", features = ["default_fonts"] }
eframe = { version = "0.37", default-features = false, features = ["persistence"] }
# Instant/SystemTime that also work in the browser (std panics on wasm32-unknown-unknown).
web-time = "1"
egui-wgpu = "0.37"
# the wgpu egui-wgpu uses, for compute (crates/gpu); backends come from the apps' features
wgpu = { version = "30", default-features = false, features = ["std", "wgsl"] }
naga = { version = "30", default-features = false }
pollster = "0.4"
rfd = "0.17"
[workspace.lints.rust]
unsafe_code = "forbid"
[workspace.lints.clippy]
dbg_macro = "warn"
todo = "warn"
too_many_arguments = "allow"
type_complexity = "allow"
# `!(x > tol)` is our idiom for "not a usable number" (NaN-safe).
neg_cmp_op_on_partial_ord = "allow"
[profile.dev.package."*"]
opt-level = 2
[profile.dev]
opt-level = 1
# Tests and lints (`cargo xtask ci`, GitHub CI): quick to build, quick enough to run. Light
# optimisation, line tables only (file:line in backtraces), no LTO, no debug assertions.
[profile.ci]
inherits = "dev"
opt-level = 1
debug = "line-tables-only"
debug-assertions = false
overflow-checks = true
incremental = false
[profile.ci.package."*"]
opt-level = 2
# No line tables for dependencies: they were over a third of the test archive every CI shard
# downloads. Our own crates keep theirs, so a backtrace still names file:line in them.
debug = false
[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 16
# Line tables only: crash reports name file:line in their backtraces (no runtime cost; a larger
# binary). See docs/crash-reports.md.
debug = "line-tables-only"
# Vendored crates with SolidCraft fixes (see vendor/README.md and ATTRIBUTION.md).
[patch.crates-io]
# Keep OpenGL pipelines, resolve textures and CAD callbacks at the same safe sample count.
egui-wgpu = { path = "vendor/egui-wgpu" }
# Deliver trackpad pinch and rotation gestures on Wayland (zwp_pointer_gestures_v1), which
# winit 0.30 never binds and eframe 0.37 still requires winit 0.30.
winit = { path = "vendor/winit" }
# Mutation testing (cargo-mutants, docs/mutation-testing.md): the ci profile with incremental
# builds, since every mutant rebuilds the crates above the one it changes.
[profile.mutants]
inherits = "ci"
incremental = true