* Viewports keep their own UCS and their other settings through save and copy (part of #1316)
A layout viewport's own UCS and every setting CADCraft doesn't model
were dropped on read, so saving a sheet set lost them for good.
- Viewport::ucs (origin, X/Y axes, elevation, orthographic type, named
and base UCS by name) and ucs_per_viewport (UCSVP), read from and
written as VIEWPORT groups 110-112, 146, 79, 345/346 and 71.
- Viewport::extra: the viewport's other groups as read (snap, grid,
lens and clipping, render mode, plot style sheet, shade plot, visual
style, background, lighting). They belong to the entity, so COPY and
MIRROR carry them; dxf_raw::finish writes them before the xdata and
points their references at what they named (ForeignExtra::tail).
- Not carried raw: the view twist, direction and target (51, 16, 17),
which say where the view centre is measured from; writing them back
while the centre is in drawing coordinates would move the view.
- DWG: the bridge drops 345/346, the plot style sheet, shade plot and
lighting groups, so CADCraft xdata keeps a copy (VPUCS, VPEXTRA) that
the reader falls back on. The visual style, background and shade plot
references are still lost through DWG (file-format-parity.md).
- A UCS with unreadable or zero-length axes is no UCS; a named UCS
that's no longer in the table isn't pointed at.
Tests: another program's viewport read; DXF save and reread; two DWG
round trips; a copied viewport; a deleted named UCS; a viewport without
a UCS written as before; hostile groups (5000 extras, NaN axes, bad
handles); COPY and MIRROR through the engine.
* Viewports: VPEXTRA keeps only a viewport's own groups; a base UCS handle alone is kept
- CADCraft's VPEXTRA xdata copy of a viewport's unmodelled groups is
merged only for groups that can stand inside the AcDbViewport subclass:
a record start (0), handles (5, 105), a subclass (100), a group brace
(102) or xdata (1000 on) from a crafted file are dropped, so a save
can't write records or handles the user didn't draw.
- A VIEWPORT whose only UCS group is its base UCS handle (346) now reads a
UCS, so the base UCS is resolved and written back.
* Viewports: drop structural groups from a record's own extras; index UCS names for the xdata fallback
- A VIEWPORT's own AcDbViewport groups are kept raw only when they can
stand in the subclass, as CADCraft's VPEXTRA copy already was: a second
handle (5, 105) or a group brace (102) written back would give the
record two handles. The record's own pointer groups stay, to be
remapped with it.
- The named and base UCS that CADCraft's xdata names are looked up in a
case-insensitive index built once with the UCS table, not by scanning
every UCS for each viewport.
* Parity checklist: regenerated after merging main
* Parity checklist: regenerated after merging main
* Parity checklist: regenerated after merging main
* xtask: take main's stats.rs (the merge kept a test import Linux clippy rejects)
* Viewport tests built on main set the UCS fields
* WIP row 74: Codex's test edits kept; production normalisation (identity UCS -> None, default-valued extras dropped in dxf_read viewport_ucs/viewport_extra) still to do
* Viewports: a default viewport reads back with no UCS or extra groups (#1484)
A DWG save writes an identity UCS and the default snap, grid, lens, clip,
render and shade groups for every viewport, so a viewport nobody gave a UCS
came back with one and a dozen extras. The DXF reader now reads an unnamed
identity UCS (UCSVP 0) as none, and keeps a group in extra only when it
differs from the defaults, listed in one table. Tests: a_default_viewport_reads_back_without_ucs_or_extras,
a_viewport_with_non_default_snap_keeps_it; layouts_and_paperspace passes.
* Viewports: clippy range patterns; raster_image test builds with the viewport's UCS fields
* Tests: move the viewport UCS suites into the it entry points (#1316)
viewport_ucs_roundtrip.rs and viewport_ucs_copy.rs were separate test
binaries; AGENTS section 30 wants the existing entry points. All 12 DXF/DWG
persistence tests and the COPY/MIRROR tests are kept.
* Tests: move the viewport UCS suites into the it entry points (#1316)
viewport_ucs_roundtrip.rs and viewport_ucs_copy.rs were separate test
binaries; AGENTS section 30 wants the existing entry points. All 12 DXF/DWG
persistence tests and the COPY/MIRROR tests are kept.
---------
Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: SBaksa <18648812+SBaksa@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
A value of nothing but underline and overline toggles (%%u%%u) has no drawn
character, and the box floored the count at one: Aligned over a span of 20
that was a box of 20 by 120 for text that draws nothing. The box is empty
when no character is drawn, for an empty value too.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main now carries #3594 and #3622 (landed through #3692), which rewrote
clip_prim around Limits and the pieces/fill closures. The only conflict is
that block in crates/render/src/viewports.rs: main's clip_prim is kept and
its Clip::Poly fill arm gets this branch's one line, so both truncation
signals stay:
- #3594's whole() in the fill closure marks the list when the clip stops
at the room left or at its own 6,000,000-point stop;
- may_leave_out marks it when the clip region's own triangles stopped at
the fill cap (#3636).
truncated is only ever OR-ed, so neither signal clears or doubles the
other.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main (PR 3679) mirrors the box of Backwards and Upside-down text about the
point the text is placed by. This branch builds the box from a bottom and a
top instead of an offset and a height, so the mirror is applied to those
corner points.
Tests: the two helpers (ours with a vertical justification, main's with the
mirror flags) are one that takes both, and the test of the vertical
justifications also runs with each mirror.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The box took the length of the stored value, control codes included: the
%%u and %%o toggles draw nothing, %%d, %%c, %%p, %%% and %%nnn draw one
character, \U+XXXX draws one, and invisible formatting characters take no
room. So the width was over-estimated again for such text: Aligned
"%%uAB%%u" at height 1 over a span of 20 is drawn 12.5 high in a box of
6.25. The callers now pass the number of drawn characters.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Bottom justification lifts a line by a third of the height it is drawn at.
The box used a third of its own height, which is the most the line can be
drawn at, so the box began above the bottom of the text: "I" over a span of
20 is drawn from 20 to 80 and its box began at 40. The box now runs from
where the shortest possible line would start (from the widest width the
stroke font gives the line) to where the tallest would end.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Two findings from the landing review of #3506.
Text of next to no width is left as it is by the fonts. The box applied
that cutoff with a margin, so for a height of 1e-7 and a width factor of
1e-5 it still scaled the text over its span: a box about a million units
high. It now uses the fonts' cutoff as it is.
Aligned text is scaled by span / shaped width, and the box divided by the
widest width a line can have, so narrow letters were drawn taller than
their box: "I" over a span of 20 is drawn 60 high in a box of 22. The
height now comes from the least width the stroke font gives a line.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A test that the extents of backwards and upside-down text over two
points are the plain text's extents reflected about the first point,
as the drawn text is.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Keeps both sides in text_box (main's fitted height and rotation, this
branch's mirroring) and sets the two flags on the Text literals main
has added since.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
TEXT, ATTDEF and ATTRIB have their own Backwards and Upside down, as AutoCAD's do (DXF group
71: 2 backwards, 4 upside down). New TEXT and attribute definitions take them from their style;
changing the style afterwards leaves existing text as it is. They were the style's only, so
text read from a file with its own flags was drawn as its style said.
- Model: `Text::backwards` and `Text::upside_down` (serde default false).
- DXF: read from 71 (the object's own groups, before an embedded MTEXT) and written when set.
- Render: drawn from the text's flags; the extents box mirrors with them, so zooming to
extents frames mirrored text. Linetype text keeps its style's.
- Properties: a Misc group with Upside down and Backwards (`properties.describe`, and
`properties.set` takes `backwards` and `upsideDown`), for several texts at once with *VARIES*.
- ATTDEF builds its text as TEXT does, so it also takes the style's width factor and obliquing.
- Round trip: #2237's matrices compare both flags, with DXF and DWG cases for them. Its
mirrored-style cases mirror the text by the text's own flags, and each mirrored style
also has text whose flags differ, so a style's flags can't leak into its text's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The extents estimate a line's shaped width; the fonts measure it. Where the
fonts decide by a cutoff the two could differ, so the extents now assume
the real width is within a factor of 4 of the estimate and take the larger
box unless the estimate is clear of the cutoff:
- Fit text counts as stretched only when its fitted factor clears the
fonts' cutoff by that factor; otherwise it is boxed unstretched.
- A line of next to no width is left as it is by the fonts, so its box no
longer reaches for the second point.
- Aligned text shrunk into a short span is boxed at least as tall as its
own height, which narrow characters reach.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Fit text is stretched by scaling its width factor by span / shaped width
and shaping again. With a span that is a tiny part of the text's width the
scaled factor is too small for the fonts, which then draw at a factor of 1:
the text is far wider than its span, and the extents reported only the
span. The extents now take the unstretched width in that case, as they do
for an unusable stored factor.
Test (render, which sees both): the drawn text lies inside the drawing's
extents for a span too short to fit and for one that fits.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Require user-defined spacing to exceed the renderer limit in HATCH and SETVAR. Show the exact default spacing, and use a shared scale rule for rendering and DXF definitions.
Measure the rendered spacing before and after a DXF save at the first supported value.
* Dimension text below the line (\X) and leader text at DIMSCALE (#1055, #1056)
- #1055: in dimension text, `\X` starts the text below the dimension
line (DXF Reference). CADCraft drew only the part before it, and its
*D block held only that part. The part after `\X` is now drawn below
the line, on the other side of it at the same distance (text centred
on the line moves above it), on screen, in plots and in the *D block
as a second MTEXT; text width for the fit is the wider part's.
- #1056: LEADER's annotation was DIMTXT high whatever DIMSCALE said
(0.25 instead of 6.25 beside dimensions at DIMSCALE 25). It is now
DIMTXT × DIMSCALE (the style's, else the drawing's; 1 for annotative
styles), in the style's text style, as AutoCAD's LEADER makes it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Dimension `\X`: measure from the dimension line, not DIMTMOVE 1's leader
The part after `\X` is placed from the dimension line's longest segment, and DIMTMOVE 1's leader
(added by #2015) is drawn as a dimension line too: with the text moved far away, the leader won
and the part below went next to the text. The leader's ends are now kept (`text_leader`) and its
segments skipped. Text moved off its place also leaves the part below at the usual clearance
under the line, instead of as far below as the text is above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* LEADER text of an annotative dimension style: DIMSCALE, and annotative
With an annotative dimension style the leader's text left DIMSCALE out and was not annotative,
so at an annotation scale it stayed small beside the dimensions. It now takes DIMTXT × DIMSCALE
as a dimension of the style does, and is annotative at the current annotation scale.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* LEADER text of an annotative style: the annotation scale replaces DIMSCALE
An annotative dimension takes the annotation scale in DIMSCALE's place (anno_scaled sets its
scale override), so its text is DIMTXT × the annotation scale. The annotative leader text took
DIMTXT × DIMSCALE and then the annotation scale again: twice the dimension text with DIMSCALE 2.
It is now DIMTXT high and annotative; a non-annotative style still takes DIMTXT × DIMSCALE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* DIMTMOVE 1 leader is kept as the text leader again
The merge of main moved the leader into dim/linear.rs without the text_leader record, so the
text below the line was placed over the leader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep `\X` text below a suppressed or extension-line dimension line
With DIMSD1 and DIMSD2 both on, no dimension line segment is drawn, so
the part after `\X` was dropped. The linear dimension now records its
whole dimension line (`dim_axis`) and the `\X` layout falls back to it.
With DIMJUST 3 or 4 the text runs along an extension line, so its normal
is across the dimension line's: the text no longer moves onto the
dimension line at the arrow, and the part below stacks under it in the
text's own frame.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Plot: JIS B4/B5/B6 and Japanese paper sizes
Japanese drafting uses the JIS B series: B4 257×364 mm, B5 182×257 mm and
B6 128×182 mm. The paper table only had the ISO sizes, so a JIS B5 drawing
plotted about 7 mm short in each direction. B4/B5/B6 are now the JIS sizes (the
names Japanese Excel and drawings use) and the ISO ones stay reachable as
`B4 (ISO)`/`B5 (ISO)`; a drawing that stored the ISO sheet keeps its stored
size, and a caller that means ISO B5 says so.
Adds the Japanese papers the table lacked: Japanese Postcard (はがき,
100×148 mm), Japanese Double Postcard (往復はがき, 148×200 mm), Japanese
Envelope #3 (長形3号, 120×235 mm), Japanese Envelope Kaku #2 (角形2号,
240×332 mm) and 四六判 (127×188 mm). A6 was already an ISO sheet.
Paper names resolve case-insensitively and ignore spaces, hyphens, underscores
and parentheses (`B5 (JIS)`, `b5-jis`, `b5jis`), with the Japanese spellings as
aliases too (`はがき`, `往復はがき`, `長形3号`, `角形2号`, `四六判`). The
built-in plotters and the Page Setup/Plot paper combo pick the new sizes up
from PAPER_SIZES, and the PDF plot's MediaBox and the plot preview use them.
Tests: the render paper test pins every new size and alias, the ISO sizes keep
their values and the unknown-name fallback is unchanged; a new io test pins the
PDF MediaBox for each new paper (JIS B5 515.91×728.50 pt, はがき 283.46×419.53 pt,
ISO B4/B5 and the rest), and the plot-preview test checks that `B5` resolves to
JIS B5 and `B5 (ISO)` to ISO B5.
Docs: docs/plotters.md standard sizes and the `pagesetup`/PDFBOOK parameter
notes, and ROADMAP.md progress log + revision history, dated 2026-10-21.
* Plot: B4/B5/B6 stay ISO; JIS sizes by explicit name
Review follow-up: making the bare names mean JIS changed the ISO sizes for
every user. `B4`/`B5` are the ISO sizes again, an ISO B6 row (125×176 mm)
completes the bare series, and the JIS sheets (JIS P 0138, 257×364,
182×257 and 128×182 mm) are reachable only as `B4 (JIS)`/`JIS B4`,
`B5 (JIS)`/`JIS B5` and `B6 (JIS)`/`JIS B6`.
Drop the ambiguous bare `Postcard` and `Double Postcard` aliases; the name
and はがき/往復はがき say which postcard is meant. Drop the ROADMAP.md edit
(ROADMAP.md stays at origin/main's content).
The render and io paper tests, the plot-preview test and docs/plotters.md
follow the new mapping; the Japanese stationery sizes and their はがき/
往復はがき/長形3号/角形2号/四六判 spellings are unchanged.
Still safe for stored papers: a page setup keeps the canonical paper name
with its width/height, DXF groups 44/45 round-trip those sizes, and the ISO
canonical names (and the JIS rows by name) did not change.
* Plot: full-width paper names resolve like their ASCII forms
A Japanese keyboard or IME gives B5 (JIS); fold U+FF01..U+FF5E to ASCII (and the
ideographic space to a space) before the existing normalisation, with a test.
---------
Co-authored-by: midasdf <midasdf@tutamail.com>
triangulate_evenodd stops once its triangles pass 6,000,000 points (or
returns none past 200,000 edges) without telling the caller, so a fill
drawn in part left DisplayList::truncated false.
- fill: triangulate_evenodd_whole also says whether the triangles cover
the whole region. The cap check moves to before the next slab that adds
triangles, so the triangles are unchanged and a region whose last slab
passes the cap counts as whole. triangulate_evenodd keeps its signature.
- Builder::region_tris marks the list truncated when a region is not
whole; hatch fills and backgrounds, MLINE fills, Prim::Fill and WIPEOUT
go through it.
- PolyClip keeps whether its region triangles are whole. A fill crossing
the outline of a capped region is cut against the triangles there are,
so it is drawn too little and never past the outline; may_leave_out
says when that can happen and clip_prim marks the list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts in crates/doc/src/extents.rs and crates/engine/src/select.rs.
extents.rs: main's `Contents` (a block's geometry, its constant attribute
values by tag and its definitions) is what the block caches hold, and it is
measured with the viewport's frozen layers: `contents` takes `frozen` and the
separate `in_drawing` cache, a constant value on a layer frozen in the
viewport is left out as the renderer leaves it out, and a clipped reference
takes the drawing's contents from `in_drawing` (`drawing_contents`).
select.rs: main's file with the viewport laid over it. A block reference is
hit on what is drawn (#3445), so through a viewport on what that viewport
draws (`insert_geometry` and `insert_fill_hits_box` take the frozen layers).
The frame of blank text (#2810) stays in the box a viewport gives. `pick_scanning`
tests its candidates through one `ViewportBounds`.
One test follows #3445: a clipped reference whose frame is hidden
(XCLIPFRAME 0) is no longer hit on its boundary, in any viewport, since the
boundary is not drawn; the window around it still takes it.
Two review findings on the plot style point limit:
- pattern_within kept going after a triangle set `full`; a later
triangle over the pattern cell allowance then returned None, so the
list was not marked truncated and later outlines were still styled.
It now returns as soon as `full` is set; the cells running out first
still keeps the fill solid, as before.
- Viewport contents were styled within the build's whole point limit,
then clipped into the layout's list, which already holds the objects
drawn before the viewport. Outlines that fit the contents' list but
not the layout's stopped the append part-way and spent the build,
dropping the last contents and the layout objects after them. They
are now styled within the room the layout's list has left.
Part of #1603.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in "Start no clipped piece without room; skip viewport scans
once spent" (clip.rs, viewports.rs, tests.rs). No conflicts; the
viewport contents keep both the early return and the pen limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit on #3594 and #3622:
- Pieces started a new piece when the cap had no piece left, so a long
visible run was copied up to the point cap and then dropped. Starting
a piece now stops the pieces there; a piece that fits exactly with
nothing visible after it stays whole. The output is unchanged.
- A layout viewport after the build was spent still scanned model space,
working out each object's bounds before entity() found nothing could
be drawn. contents() now returns first when the build is spent and its
list already says so. A build spent by a list filled exactly still
scans, so the list is marked for what the viewport leaves out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the web build (one allocation at most isize::MAX) two vectors could
still double past 2 GiB and panic with "capacity overflow":
- gpu::build_highlight_mesh grew its quads from empty. It now counts
segments, point markers, fill corners, fill outline segments and
image frame edges first and allocates once, as build_mesh does. Fill
outlines are worked out once, while counting.
- pen::apply turned plot style line ends, joins and fill patterns into
triangles after the build, outside MAX_DISPLAY_POINTS. It now stops
at the list's point limit: from the first primitive whose geometry
doesn't fit, the rest keep their plain line or solid fill and the
list is marked truncated. Layouts and viewport contents use the
build's own limit.
Measured on wasm32 (harness, Node): 40M highlighted points and a plot
of 1,060,000 round-ended lines panicked on the base; now 1.12 GB
allocated once, and 63,999,974 points marked truncated.
Part of #1603.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit review on #3594:
- clip_list started from an empty list, so a list the budgets had
cut came back with truncated false. It now starts with the input's
truncated, undashed and expanded, as viewport contents merge them.
- clip_prim built the whole clipped result before push_raw checked the
list's limits. A fill crossing a clip edge fans to more points, and a
line crossing an outline of many edges splits into a piece per
crossing, so the transient result could pass 2 GiB on wasm32 from a
list within its budgets. clip::Cap and _within variants of the
rectangle and outline clips stop at the room left (Limits::left) and
say so; clip_prim appends what fit and marks the list truncated. A
fill cut there keeps the triangles that fit, as line pieces already
did. The uncapped functions stay as wrappers for their other callers.
PolyClip::clip_triangles' 6,000,000-point stop now marks the list too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* HATCH by internal point keeps the arcs of its boundary (#1167)
The boundary search works on flattened curves, so a hatch made by
picking inside a circle stored 158 chords and AREA came out short
(5025.22 for pi*40^2 = 5026.55).
Each traced edge now keeps the input polyline it came from
(region::Boundary::outer_edges, Island::edges, outline_edges,
enclosing_loop_edges_gap; bridged gaps are None), and each input
polyline is one piece of one object: a line, a circle, an arc or one
segment of a polyline. arcs::with_arcs turns each run of edges on the
same circular piece back into one bulged vertex and moves the corners
onto the exact curves (line-circle or circle-circle crossing nearest the
traced corner, within the reach a shallow crossing needs, else onto the
circle). Nothing is matched by proximity, so a line or an ellipse next
to a circle is never taken for it. The associative refill does the same,
so a hatch keeps its arcs when its objects move.
dedup_loops now merges only loops with the same role: a loop that is one
pick's outer loop and another's island stays twice, as the even-odd fill
needs (one hatch picked inside a circle and around it, or inside a square
within a square, left the inner shape empty once the two loops matched).
A boundary object selected twice is used once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Hatch arcs: origin from the arcs' extents; opposite-role duplicate loops cancel
- HPORIGINMODE's corners came from the loop vertices only, so a circle kept as two half-circles
had no height and its corner origins fell on its centre line. The extents now include each
bulged edge's arc.
- A pick inside a circle and one around it keep the circle as an outer loop and as an island.
The renderer collapsed the two into one loop, so the circle drew empty, and AREA measured them
by nesting. Two loops that are the same boundary now collapse only in the same role (a repeated
loop); in opposite roles they cancel, as they do under the odd-parity fill. AREA measures the
loops the fill keeps (`hatch_fill_loop_indices`), exactly with their arcs.
- Tests: the circle's corner origins, BOUNDARY keeping a circle's and a rounded rectangle's
arcs, and the drawn fill and AREA of the circle inside a square.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Hatch loops: same-role repeats collapse before opposite roles cancel; HATCHEDIT keeps islands
- The renderer cancelled an outer loop and an island as it met them, so the same loops in another
order filled differently (outer, island, outer left a hole; outer, outer, island left none).
Repeats within a role now collapse first, then an outer loop and an island that are the same
boundary cancel, spending the same comparison budget.
- HATCHEDIT adding a boundary the hatch already has (its island) added a second copy, which then
cancelled the island. A boundary already there is no longer added.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* HATCHEDIT: a boundary already there takes the added objects' links
Adding a boundary the hatch already has dropped the added loop, and with it the objects it came
from, so an unlinked island picked with addBoundary stayed unlinked. The objects now join the
loop already there (no second copy is added).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* AREA of a hatch tests nesting at an edge's middle, as the fill does
AREA tested whether a loop is an island at its first vertex, which can lie on the loop around it
(an island touching the outer boundary): the island was then added instead of subtracted. It now
uses the fill's own test point, the middle of the first non-degenerate edge (`hatch_loop_probe`).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Hatch loop dedup: look only at loops that could match, stop when the budget is spent
The comparison budget bounded `same_polygon`, but both passes still walked every kept loop for
each new one, O(n²) in the number of loops however few matched. Loops are now found by (role,
vertex count), so only possible matches are looked at, and once the budget is spent no more are.
A test sorts 40,000 distinct loops.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: hatch gap tolerance (HPGAPTOL) is done, not missing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: BOUNDARY keeps the arcs of what it traces
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Layer 0 puts an attribute on its block reference's layer only when the
attribute takes it from its definition. The DXF writer (and so the DWG
bridge), the renderer, BURST and the attribute editor's current layer
applied that rule to an attribute whose own layer is 0 as well, so it was
saved, drawn and exploded on the reference's layer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflicts in crates/render with #3564 (dash budget) and
#3560 (block-loop cache), keeping every side:
- Builder carries the point, primitive and dash counters and the loop
cache; every part, XCLIP part and viewport-contents builder gets all
of them, shared.
- build_space_within takes the point, primitive and dash limits; the
tests of both PRs pass the other budget's default.
- The clipped appends carry undashed beside truncated, and spend the
build when a piece doesn't fit.
Also test the shared primitive count with a limit no one parallel part
reaches (300 of 600, parts of 256). Since Builder::join limits the
joined list, the limit below one part passed without the shared count.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(io): look up table, multileader and multiline styles without scans
A crafted DXF made several style lookups cost N^2 name comparisons
(#1924, F-04 item 5):
- the reader's TABLESTYLE, MLEADERSTYLE and MLINESTYLE records, each
scanning the styles read so far for an earlier one of its name, and its
VPORT records, each scanning the viewport configurations;
- each table from another writer, scanning the table styles on read;
- each TABLE, MULTILEADER and MLINE on DXF save, for its style's handle
and values;
- render's table_style_of, which a DXF save calls for every table;
- AUDIT's multileader and table style checks, which RECOVER runs on open.
On main, N = 40 000 MLEADERSTYLE or TABLESTYLE records took 65-69 s to
open, and the DXF save of 40 000 multileaders or foreign tables naming a
missing style ran past 300 s. With this change they take 0.4-5.5 s, and
the output is byte-identical.
- ByName (from #3562) moves to dxf_ext.rs and gains position(). The record
dedups go through it, keeping the rule: a later record of a name
replaces the first in place and takes its name. A VPORT record still
adds a tile to the first configuration of its name.
- Drawing::table_styles is a NamedList, like the other style tables.
- The writer's Ctx keeps a ByName beside its table and multileader style
lists. dxf_mline::plan and Plan keep one too. Missing names fall back as
before.
- When no styles are planned (entity_groups, for entget), the multileader
style is still looked up in the drawing.
- AUDIT checks multileader styles against a lower-cased BTreeSet, and
table styles with by_name.
Tests: cost tests for each path, with behaviour checks that also hold on
the old code, and an entity_groups test for the multileader's style.
Part of #1924.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(io): trim a multiline style's name when reading it
A DXF MLINESTYLE named " Road " was kept with its spaces. Its multilines
look their style up trimmed (dxf_mline::plan, Plan::handle,
Drawing::mline_style), so a save missed it, wrote a second Road style and
pointed the multilines at that copy. main did the same: its scan compared
the trimmed query with the untrimmed name. The writer already writes the
name trimmed, and the reader's fill key trims it, so the name is now
trimmed where it is read (CodeRabbit, on #3590).
Test: a_padded_multiline_style_name_is_saved_once (fails without the
trim: the save writes STANDARD, Road and Road).
Part of #1924.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Review on #3594:
- The XCLIP attribute part's `truncated` flag now reaches the parent
list, as the block-contents part's already did. A clipped reference
whose attributes ran out of budget as the last object of a drawing
drew 98 of 105 points and said nothing.
- The parts of a parallel build are joined within the list limits
(Builder::join). Clipped copies are in no shared count, so two XCLIP'd
blocks in different parts could join to 798 primitives against a
limit of 748, unmarked. Parts are appended whole while they fit; at
the first that doesn't, the build is spent and marked truncated. This
is native-only: the web build has no parallel path.
Part of #1603.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On wasm32 a DPrim is 40 bytes and one allocation can take at most
isize::MAX (2 GiB - 1): a list of more than 2^25 primitives panicked
with "capacity overflow" when its vector grew. The 64M-point budget
(#3306) charged a point primitive one point, so it allowed 64M of them;
a 4.5 MB DXF of dotted lines reached 33.56M.
- MAX_DISPLAY_PRIMS, charged once per primitive beside the points and
shared like them: 2^24 on 32-bit targets, equal to MAX_DISPLAY_POINTS
(and not counted) on 64-bit ones, where it can't bind.
- Clipped copies (viewport contents, XCLIP) are appended only while the
list has room within both limits; the append stops at the first piece
that doesn't fit and the build is spent, as when a budget runs out.
Builder::charge checks the same room in its own list.
- Compile-time asserts: the primitive, point, pen, plotted-text and
image vectors stay under isize::MAX bytes at these limits (checked
for wasm32 by the wasm step).
- gpu::build_mesh counts its lines and quads first and allocates each
array once: the quads grew by doubling and passed 1 GiB on large
lists with lineweights shown.
Part of #1603.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e9e4b0e1f made a gaps-only pattern draw nothing past the per-run limit, but
it was still drawn as one continuous line where a pattern with a dash falls
back to continuous: a run shorter than one period, a pattern under
`min_pattern` (sub-pixel), past 50,000 periods with a level of detail, and
a run of one point (review of #3564). On screen that also differed from the
plot of the same run.
apply, apply_as and ranges now return no dashes for a pattern whose elements
are all gaps, before any of those fallbacks. Patterns with a dash or a dot
keep every fallback, and an empty (continuous) pattern is drawn whole. Texts
and shapes in a gaps-only pattern are placed as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #3564:
- A closed run is stretched to round(L / period) periods and laid out from
the period before its anchor to the one after its last, up to half a
period more than the (L / period + 2) elements it was charged. A run of
192 on 127 dashes and a gap (period 128) walked 508 elements for a charge
of 448. It is now charged (round(L / period) + 2) x the pattern's length.
The per-run limit keeps its formula, so runs under it keep their output.
- A pattern of gaps only was refused past the per-run limit, drawn as one
continuous line and counted as undashed, while below the limit it draws
nothing. It now draws nothing at any length, uncharged and unreported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>