Skip to content

Drawings: views are drawn from the model's exact shape, with the mesh only where they can't be (#5866) - #9399

Closed
CamWight wants to merge 5 commits into
tangency-labs:drawingsfrom
CamWight:drawing-w07-rest-5866
Closed

CamWight wants to merge 5 commits into
tangency-labs:drawingsfrom
CamWight:drawing-w07-rest-5866

Conversation

@CamWight

@CamWight CamWight commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

A drawing view is a 2D picture of the model on a drawing sheet: its outline, its hidden lines and any reference parts. Until now, every view was drawn from the display mesh, so its circles and curves were chains of short straight chords. This PR draws a view's lines from the model's exact shape instead, through the hidden-line module hlr (#2455). Lines stay lines and circles become true arcs. A circle seen at an angle is drawn within the view's chord_mm, by a bound that is proven, not sampled. Part of #5866 (drawing.view) and of #2455 (exact hidden lines).

What's in it, commit by commit:

  1. One place says how a view's bodies share geometry and which edges a view draws (mesh_lines::placed, drawn_edges). Both the mesh projection and the exact lines call it. Nothing drawn changes.
  2. A view's lines come from the exact model, body by body. A body falls back to the mesh only for a named reason: a mesh body, a freeform face, a body a mesh body could hide, a view past the exact lines' work budget, and a few others. Each reason is counted in the view's status.
  3. A test that a cylinder's side lines meet its rims from every corner. It fails today in hlr, so it is listed in tests/KNOWN_FAILING_TESTS. The fix belongs in hlr (Drawing W06a: exact orthographic hidden lines for the analytic subset #2455).
  4. Reference parts are drawn from their exact curves too. A second hidden_lines call draws them against the model, with the same rule the mesh path used: reference lines are tested against everything, and each part keeps its whole outline where it lies on a model line. Where the view's boundary cuts a reference part, its lines stop at the boundary. A cut circle stays one arc.
  5. A body with a face split on one cylinder, cone, sphere or torus stays exact. hlr doesn't draw the split line itself, so only that edge comes from the mesh.

What a user sees:

  • Exact lines and arcs on the sheet, in the SVG and in the PNG. A cylinder stored as two half faces draws one side line per side, not two lines on top of each other.
  • A view reports how it was drawn: status.provenance is hidden_lines, mesh_projection or both, and status.lines is exact, bounded or approximate.
  • max_error_mm now certifies views that are drawn exact, including views with reference parts. It still refuses a view with any mesh lines, and says what came from the mesh (for example "edges drawn from the mesh: 1 for split faces").
  • Edges drawn, tangent edges, hidden lines, reference styles and the boundary rules are unchanged.

Cost: measured in the app on 7 Nov. The box, cylinder and sphere export about 220 ms faster (267 → 45 ms). The plate with four holes is slower (55 → 158 ms): each of its four views prepares the plate for exact lines again. #13220 (a sheet prepares each body once for all its views) removes about 75 ms of that, and goes up after this PR. Views with reference parts got 17-24% faster with commit 4, because nothing is meshed any more.

Known limits, each on the way to a fix:

  • A mirrored body's straight edges are splines from the kernel (a mirror isn't rigid), so they are sampled, about 1e-15 mm from the true line. Such a view reports approximate.
  • In a front view, hlr draws a rim seen edge-on as a short polyline that doubles back about 1.8 mm at one end. It is the same family as the known rim failure in commit 3.
  • Drawing split lines exactly, and fixing the two rim faults, need small changes inside hlr. Where those go is a question for Drawing W06a: exact orthographic hidden lines for the analytic subset #2455.

Changes a default: no

Validation

On this branch's head, on drawings 864760834f, dev profile, the tests these changes reach:

  • cargo test -p solidcraft-engine --lib -- drawing_view: 138 passed. The one failure is a_cylinders_sides_meet_its_rims_from_every_corner, the known failure commit 3 lists.
  • Nearby areas that use reference parts (drawing_scene drawing_picture drawing_balloon drawing_check drawing_dimension drawing_sheet), run after commit 4: 319 passed. The two failures are listed in tests/KNOWN_FAILING_TESTS (Drawing W13, W14: references that survive model edits, and updating drawings when the model changes #4892).
  • Planted faults, each caught by a test besides the known failure: 4 for commits 1-3, 4 for commit 4, 4 for commit 5. The one that first went uncaught (model bodies drawn before reference parts) got a new case in a_reference_line_never_takes_a_stretch_from_a_model_line.
  • cargo fmt --check and cargo clippy -p solidcraft-engine --all-targets -- -D warnings: clean.
  • cargo xtask mesh-decisions: no new mesh decision sites. The exact path takes the drawn edges as data and reads no mesh.

Tests whose expectations changed, each with the reason in its doc comment:

  • a_views_lines_are_the_blocks_outline, each_placements_hole_is_its_own_exact_circle, a_rim_cut_where_its_visibility_changes_is_exact (was _stays_sampled), chords_and_accuracy_checks_out_of_range_are_refused and the cancel test: the lines are now exact.
  • a_scene_draws_reference_parts_thin_under_the_model: reference parts are exact now, so the view certifies.
  • a_split_round_face_is_drawn_from_the_mesh became a_split_round_face_draws_only_its_split_from_the_mesh.

Screenshots of the behavior (when observable)

Sheets exported from the app built at this branch's head, through the control channel (drawing.view.base with hidden lines shown, then drawing.export to PNG at 300 dpi). Each design is new and has no private data. The provenance under each picture is what drawing.view.snapshot reported for the same views.

A plate with four holes (commit 2). Top, front, right and iso at 1:2. The holes show as dashed hidden lines in the front, right and iso views. All four views: hidden_lines, exact.

A plate with four holes in four views, drawn from exact lines with dashed hidden lines

Reference parts (commit 4). A 40 × 40 × 5 plate with two Ø10 reference pins standing on it, at 2:1. The pins are drawn thin. In the top view, the pin inside the view is one exact circle, and the pin over the plate's edge is cut at the view's boundary as one arc. In the front view, the pins stand above the plate, outside the view's boundary, so nothing of them is drawn (the boundary grows only when asked). Top: hidden_lines, approximate (the cut arc is sampled); front and iso: hidden_lines, exact.

A plate with two thin reference pins, top, front and iso views

A split cylinder (commit 5). A Ø20 × 30 cylinder whose side is split across at half height, at 4:1. The split is the one line drawn from the mesh: across the front view, and solid in front and dashed behind in the iso view. The outline and rims are hlr's. Both views: hidden_lines_and_mesh_projection, approximate. max_error_mm 0.01 is refused with "edges drawn from the mesh: 1 for split faces". The small gap at the iso view's lower right, where a side line meets the bottom rim, is the known rim fault of commit 3.

A cylinder split across its side, front and iso views

Integration status

@CamWight
CamWight force-pushed the drawing-w07-rest-5866 branch 3 times, most recently from 0998080 to 8d0eaa9 Compare November 2, 2026 06:06
@CamWight CamWight changed the title Drawing W07: reference items, hidden lines on paper, measurements and exact lines (#5866) Drawings: views show hidden lines and reference parts, take measurements, and draw from the exact shape (#5866) Nov 2, 2026
@CamWight CamWight changed the title Drawings: views show hidden lines and reference parts, take measurements, and draw from the exact shape (#5866) Drawings W07: views show hidden lines and reference parts, take measurements, and draw from the exact shape (#5866) Nov 2, 2026
@CamWight
CamWight force-pushed the drawing-w07-rest-5866 branch from 8d0eaa9 to 04d6eb0 Compare November 3, 2026 05:55
@CamWight CamWight changed the title Drawings W07: views show hidden lines and reference parts, take measurements, and draw from the exact shape (#5866) Drawings: views show hidden lines and reference parts, take measurements, and draw from the exact shape (#5866) Nov 3, 2026
@CamWight
CamWight force-pushed the drawing-w07-rest-5866 branch from 04d6eb0 to f10d55a Compare November 4, 2026 09:00
@coderabbitai

coderabbitai Bot commented Nov 4, 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
Pre-merge checks: Passed 1

Check name Status Explanation
Existing Defaults Unchanged Passed The PR changes how drawing views are drawn, not the UX defaults that the check covers. Evidence from the checked-out branch (HEAD 09c9eb6, diff HEAD~5...HEAD): - No default value, preference, setti…
Full details: Existing Defaults Unchanged

Explanation

The PR changes how drawing views are drawn, not the UX defaults that the check covers. Evidence from the checked-out branch (HEAD 09c9eb6, diff HEAD~5...HEAD): - No default value, preference, setting, shortcut or UI layout changed. The chord constants are unchanged in drawing_view_lines.rs (CHORD_MM = 0.01, CHORD_RANGE = 0.001..=1.0, MIN_MODEL_CHORD_MM = 0.0001). The documented parameter defaults in cmd/drawing_view.rs are unchanged: chord_mm 0.01, tangent_edges hide, visual_style and reference_style visible, reference_shown_percent 0. The only edits to the .params text add new values for max_error_mm and status (exact, hidden_lines). - The changed output is the drawn result for the same inputs. Lines become exact lines and arcs instead of mesh chords. status.lines and status.provenance report the new state. max_error_mm now certifies views that previously were refused. The check excludes changed geometry results from being treated as changed defaults, and this 2D drawing output falls in that class. - The PR description's "Changes a default: no" matches the code. I found no default-value change that would trigger the second failure condition. Caveat: a strict reading of "what a command or tool does when used the usual way" could cover the new default drawing output. I did not apply that reading, because the change alters a result of the same request and does not alter a default the user sets or relies on.

  • 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 3 commits November 15, 2026 12:32
… 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>
CamWight and others added 2 commits November 15, 2026 15:01
…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>
@CamWight CamWight changed the title Drawings: views show hidden lines and reference parts, take measurements, and draw from the exact shape (#5866) Drawings: views are drawn from the model's exact shape, with the mesh only where they can't be (#5866) Nov 15, 2026
@CamWight
CamWight marked this pull request as ready for review November 15, 2026 16:11
@CamWight

Copy link
Copy Markdown
Contributor Author

Closing, as this PR's work is already in drawings: its five commits went in with #13220, which was stacked on them and was merged today. git range-diff shows the same five changes, with only the surrounding lines moved for the flat pattern views (#13033). Thanks @bherbruck for merging the stack.

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