Skip to content

Drawings: a sheet prepares each body once for all its views (#13218) - #13220

Merged
bherbruck merged 6 commits into
tangency-labs:drawingsfrom
CamWight:drawing-prepare-once-13218
Nov 16, 2026
Merged

bherbruck merged 6 commits into
tangency-labs:drawingsfrom
CamWight:drawing-prepare-once-13218

Conversation

@CamWight

@CamWight CamWight commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

A drawing sheet with several views of the same part now exports faster. Before drawing its views, the sheet used to prepare every body for exact hidden lines once per view. Now it prepares each body once, and every view on the sheet uses it.

This is #13218. It stacks on #9399 (views drawn from the model's exact shape), so the diff shows #9399's five commits until #9399 lands in drawings. The one commit of this PR is the last: "Drawing views: prepare each body for exact lines once per sheet (#13218)".

How it works:

  • PreparedBodies holds the bodies one model state's views have prepared for hlr, keyed by each body's place in that state. A body is prepared when the first view that shows it asks, and later views use it.
  • drawing_scene::build keeps one set per assembly state the sheet's views draw (assembled, exploded, a pose). A view of another state prepares its own, so nothing is lent across states.
  • A cancelled prepare keeps nothing. Each view still checks the edges it draws against the body it uses.
  • Both of a view's hlr calls (the model's lines and the reference parts' lines, from Drawings: views are drawn from the model's exact shape, with the mesh only where they can't be (#5866) #9399) use the same set.
  • A single view (the snapshot command, or a one-view job) gets a fresh set.

Cost, measured in the app on 8 Nov on the W23 plate's four views (fresh apps, before, after, after, before): the sheet's SVG export took 152-177 ms before and 71-83 ms after. The SVG is the same size to within a few bytes. Each view's own work (projection, hiding) is unchanged.

Changes a default: no

Validation

On this branch's head, on drawings 864760834f, dev profile:

  • cargo test -p solidcraft-engine --lib -- drawing_view drawing_scene mesh_lines: 266 passed. The one failure is a_cylinders_sides_meet_its_rims_from_every_corner, listed in tests/KNOWN_FAILING_TESTS by Drawings: views are drawn from the model's exact shape, with the mesh only where they can't be (#5866) #9399.
  • New tests: a_sheets_views_prepare_each_body_once (one body prepared for three views; a mesh body beside it still drawn from its mesh in every view; two copies and a pin give two prepared bodies), views_of_one_shown_set_share_their_prepared_bodies, a_view_without_a_parts_first_copy_prepares_the_next and a_cancelled_prepare_keeps_nothing.
  • Four planted faults, each caught: prepared bodies serving every model state, lent bodies ignored, the sheet lending nothing between views, and a view counting lent bodies as its own.
  • cargo fmt --check and cargo clippy -p solidcraft-engine --all-targets -- -D warnings: clean.

Screenshots of the behavior (when observable)

None: nothing drawn changes. Every view draws the same lines; only the time to export a sheet goes down (numbers above).

Integration status

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@bherbruck

Copy link
Copy Markdown
Collaborator

drawings now includes main as of today; please merge drawings into your branch. Thanks!

CamWight and others added 6 commits November 16, 2026 11:16
… edges it draws


mesh_lines::prepare grouped the placed bodies (which placements share one
copy of a definition's geometry, and which are their own group, such as a
mirror image) and chose the edges a view draws inline. Both now live in
their own functions in meshes.rs, `placed` and `drawn_edges`, so the exact
hidden lines can use the same rules. Nothing a view draws changes.

A new test checks the grouping: a copy moved by a rigid transform shares
its original's geometry, and a mirror image is a group of its own.

Part of tangency-labs#5866.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… only for bodies the exact lines can't draw


A drawing view now draws its visible and hidden lines with hlr, from each body's exact faces and edges: straight
edges and circles come out exact, other curves as chords within the asked error. A body falls back to the old mesh
projection when the exact lines can't draw it (mesh bodies, split round faces, faces or trims hlr can't read, a mesh
body that may stand in front of it), and the view's status names how many bodies fell back and why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wn to fail in hlr (tangency-labs#2455)

A cylinder seen from each upper corner at 1:2: each side line must end where a piece of its bottom
rim ends, visible and hidden, to 1e-6 mm. Two corners miss by 0.75 mm on paper: hlr gives the rim no
split where the side line touches it, and the visibility change falls in the first tenth of the
rim's one stretch, which classify_range doesn't search. The other sides are 7.7e-6 mm off, at the
grazing ray's own-face margin.

The test is listed in tests/KNOWN_FAILING_TESTS until hlr splits the rim there; the fix drops the
line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gency-labs#2455)

A reference part's lines now come from a second hidden_lines call, not
from the mesh. That call holds every reference part first, then each
model body that may hide one. So reference lines are tested against
everything, the model still sees through reference parts unless the
view says they hide it, and a reference line on a model line keeps all
of it. Reference lines still stop at the view's boundary: a piece
inside keeps its exact curve, a line is cut exactly, and an arc is cut
on its chords and put back on its circle, as the mesh projection does.

Views with reference parts get faster (83 to 63 ms with one, 103 to
79 ms with three, on a plate with four holes and a boss) and certify
any max_error_mm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angency-labs#2455)

A body with a face split on one cylinder, cone, sphere or torus stays drawn
from its exact curves. Only the split edge, which hidden lines don't draw,
comes from the mesh projection, picked by body and edge. The provenance and
the max_error_mm refusal name those edges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ency-labs#13218)

A sheet's views each prepared every body for hidden-line removal, though
preparing a body does not depend on the view. The sheet now hands its views
one PreparedBodies set, keyed by each body's place in the model state, so a
body is prepared once and later views reuse it. A view of another model state
prepares its own. A cancelled prepare keeps nothing. Each view still checks
the edges it draws against the body it uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CamWight
CamWight force-pushed the drawing-prepare-once-13218 branch from 331bd85 to b5c018e Compare November 16, 2026 11:26
@bherbruck
bherbruck merged commit b190018 into tangency-labs:drawings Nov 16, 2026
30 checks passed
@CamWight
CamWight deleted the drawing-prepare-once-13218 branch November 16, 2026 13:21
CamWight added a commit to CamWight/solidcraft that referenced this pull request Nov 30, 2026
tangency-labs#4892)

tangency-labs#13220's test on main calls draw without the design walk that this branch
added as draw's second argument; it now walks the design once and passes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants