Skip to content

feat(objects): decode VISUALSTYLE on R14, R2000 and R2007 — one field list, four releases - #79

Merged
DrunkOnJava merged 1 commit into
mainfrom
feat/visualstyle-third-layout
Aug 30, 2026
Merged

DrunkOnJava merged 1 commit into
mainfrom
feat/visualstyle-third-layout

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Aug 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

#73 opened on the reading that R14 / R2000 / R2007 write a third generation of the VISUALSTYLE layout, because neither shipped field list closed on any of their 216 records. Derived per band, the answer is narrower and better: there is no third generation. All four pre-R2010 releases write the same 30 flag-less fields in the same order. The 216 misses have two causes, and neither is field order.

All 456 VISUALSTYLE records of the 19-file corpus now decode.

The record distribution, measured first

The issue allowed for R14 predating VISUALSTYLE. It does not. examples/probe_visualstyle_layout.rs with no --spec is the census, and every one of the nineteen corpus files holds exactly 24 records:

Band Files Records
R14 (AC1014) 3 72
R2000 (AC1015) 3 72
R2007 (AC1021) 3 72
the 216 of #73 9 216
R2004 / R2010 / R2013 / R2018 10 240
corpus total 19 456

So the 216 split 72 / 72 / 72, not 108 / 108 / 0.

Band 1 — R14 and R2000: the R2004 list, with §2.11's older colour form

R14 and R2000 write the same 30 fields in the same order as R2004. The whole difference is §2.11: before R2004 a colour is the bare BS index, without the BL true-colour word and RC colour byte R2004 added. Five colour slots × 40 bits is most of the 154-to-170-bit gap between an R2000 record and its R2004 counterpart.

Read the colours that way and the list lands 144 of 144 records of the six R14 / R2000 files exactly on their boundary, delta 0. (On R14 the boundary is the RL object-data-size that release writes inside the common object data rather than in the object prologue.)

The two bands are bit-identical in shape — an R14 file and the R2000 file built from the same drawing give the same 24 budgets: 388, 476, 412, 500, 396, 444, 428, 484, 508, 436, 420, 436, 420, 452, 452, 460, 540, 484, 412, 524, 428, 436, 452, 460 bits.

The two colour encodings agree through the change, on all 144 records:

Slot / style R2004 CMC R14 / R2000 index
every face mono colour but ColorChange 0xC2FFFFFF 7
ColorChange face + edge colour 0xC2808080 8 (ACI dark grey)
Shaded silhouette colour 0xC2787878 8
obscured colour, 22 of 24 styles 0xC8000000 ("none") 257
obscured colour, Shades of Gray + Sketchy 0xC3000007 7

And the non-colour corroboration the issue asked for, all agreeing with R2004 record for record:

  • internal_style_type — the dense enumeration 0 Flat, 1 FlatWithEdges, 2 Gouraud, 3 GouraudWithEdges, 4 2dWireframe, 7 Basic, 9 Conceptual … 27 Shaded;
  • face_opacity — -0.6 on twenty-three styles, +0.5 on X-Ray, sign included;
  • edge_crease_angle — 40 on Hidden / Sketchy / Shades of Gray, 179 on Conceptual, 1 elsewhere;
  • display_brightness — the same BL: -50 Dim, 50 Brighten, 0 on the other twenty-two;
  • is_internal_use_only, the record's final bit — false on exactly the ten styles the Visual Styles Manager lists and true on the fourteen it hides.

Band 2 — R2007: the same list plus one 2-bit slot

R2007 keeps the R2004 colour form and its records land 2 bits short on all 72. The leftover bits are 10 followed by is_internal_use_only — 101 on the fourteen hidden styles and 100 on the ten listed ones, on every record of all three files. One more 2-bit read before that final B closes 72 of 72, delta 0.

The slot's position is measured, and Dim is what measures it: it is the one record whose display_brightness is not the 2-bit zero form but the full 34-bit BL holding -50, so it discriminates placements the other 23 cannot.

Placement Records closing on arc_2007.dwg
after display_shadow_type, before the final B 24 / 24
before display_brightness 23 / 24 — fails on exactly Dim
in the head, after internal_style_type 0 / 24
after is_internal_use_only 0 / 24
removed entirely (the R2004 list) 0 / 24, two bits short

Honest declines, with budgets

  • The new slot's token type is not determined. It is two bits reading 0 on all 72 records, so BS / BL / BD all fit. Surfaced as AcadVisualStyle::display_unknown_short rather than given a plausible-sounding name — the same treatment the R2004 13-bit constant run already gets. It is not R2010's BS format_version, which decodes 2.
  • Its side of display_shadow_type is not determined either. Both slots are two bits reading 0 on all 72 records, so the two are interchangeable in the field list. A future R2007 file with a non-default shadow type would settle it.
  • Width-only search does not pick the layout on these bands, and the PR says so. probe_visualstyle_layout --search measures every one-token neighbour (insert / delete / substitute over B BS BL BD RC CMC) against every record at once. It reports 33 closing neighbours on R2007 and 64 on the R14 / R2000 band. Every one is an encoding alias rather than a rival layout: pre-R2004 a colour is a BS, and BS / BL / BD share bit-prefix grammar so they coincide on the small-value forms these records use. The cross-release value agreement above is what selects the reading, and that is the honest framing — the search narrows the field, the values pick the answer.

Coverage — measured before and after, on the merged tree

cargo run --release --example coverage_report, run after git -c merge.ff=false merge origin/main (main at 6cc9b13):

Corpus slice Before After
R14 (AC1014) × 3 426 / 450 / 0 / 48.6 % 498 / 378 / 0 / 56.8 %
R2000 (AC1015) × 3 534 / 99 / 0 / 84.4 % 606 / 27 / 0 / 95.7 %
R2004 (AC1018) × 3 582 / 15 / 0 / 97.5 % 582 / 15 / 0 / 97.5 %
R2007 (AC1021) × 3 462 / 96 / 0 / 82.8 % 534 / 24 / 0 / 95.7 %
R2010 (AC1024) × 3 531 / 12 / 0 / 97.8 % 531 / 12 / 0 / 97.8 %
R2013 (AC1027) × 3 384 / 12 / 0 / 97.0 % 384 / 12 / 0 / 97.0 %
R2018 (AC1032) × 1 776 / 57 / 9 / 92.2 % 776 / 57 / 9 / 92.2 %
Aggregate (19 files) 3695 / 741 / 9 / 83.1 % 3911 / 525 / 9 / 88.0 %

VISUALSTYLE leaves the unhandled histogram entirely. XRECORD (345) is now the largest unmatched class. The error count is unchanged at nine, and the class-census ratchets in tests/class_census.rs and tests/canonical_corpus.rs are untouched — the walk already reached these records; only the decode changed.

Tests

  • Six new BitWriter tests in objects::acad_visual_style, one per band boundary: an R14 record closing on the RL inside its own common object data, an R2000 record closing on bare-index colours, an R2007 record closing on its string stream, plus three negative directions (an R2000 body rejected under the R2004 colour form, an R2007 body without the extra slot rejected, an inline body carrying the extra slot rejected under the R2004 list).
  • tests/samples.rs gains a corpus-gated pin over all 456 records: 24 per file, the ten/fourteen internal-use split, the dense 0…27 enumeration, X-Ray's opacity, the crease angles, the brightness triple and ColorChange's grey in both encodings. The content assertions are scoped to the eighteen saved-down arc_ / circle_ / line_ files, because sample_AC1032.dwg is a different drawing whose author edited some of those values (its Conceptual carries a 40-degree crease angle).
  • examples/probe_visualstyle_layout.rs is new — census, joint-boundary check and uniqueness search — and exits non-zero when a --spec run leaves any record off its boundary, so it can gate.

Follow-ups

  • XRECORD, 345 records, now the largest unmatched class on the corpus.
  • MATERIAL, 65 records — acad_material still reads only strings and a budget.
  • R14 DIMSTYLE — §20.4.68's R13/R14 block order is still unmeasured; six records.
  • The R2004 13-bit constant run and the new R2007 2-bit slot both stay unsplit until a file with a non-default halo gap, isoline count or shadow type appears.

Gate

cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings, cargo test --release (774 lib + all integration suites, run with the corpus present so every corpus-gated test and ratchet actually executed), cargo +1.85.0 test --no-run, cargo deny check all, RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --all-features — all clean.

Source-provenance declaration

This contribution incorporates no executable code from any source whose license is incompatible with Apache-2.0. No Autodesk SDK source, no ODA SDK / Teigha source, no LibreDWG or other GPL-licensed DWG implementation source was consulted. The colour-form rule is the ODA Open Design Specification for .dwg files v5.4.1 §2.11; VISUALSTYLE itself has no §20.4 prescription, and every field list here was derived by measuring the bytes of the local sample corpus against the boundary each record carries. No third-party project's comments or source were read while preparing it.

Closes #73

https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C


Note

Medium Risk
Changes bit-level object decoding and colour handling for a high-volume object type across three release bands; mitigated by strict boundary checks and extensive corpus tests.

Overview
Closes #73 by decoding all 216 previously unhandled VISUALSTYLE records on R14, R2000, and R2007 using the same 30-field flag-less layout as R2004—not a separate “third generation.”

R14 / R2000: Colour slots are read as bare BS indices (§2.11 pre-R2004) instead of full CMC triples, which closes all 144 records at boundary delta 0.

R2007: Keeps R2004 colours and adds one extra 2-bit field before the final is_internal_use_only bit, exposed as display_unknown_short (always 0 in the corpus; token type not pinned).

decode_object no longer returns Unsupported for older releases; pre-R2010 paths all use decode_legacy with version-aware read_color. Docs, coverage tables, and roadmap items are updated (88.0% aggregate decode rate; VISUALSTYLE off the unhandled list).

New examples/probe_visualstyle_layout.rs (census, joint boundary check, --search uniqueness). Six unit tests plus a corpus-gated tests/samples.rs pin over 456 records.

Reviewed by Cursor Bugbot for commit ad5c737. Configure here.

… list, four releases

#72 made the R14 / R2000 / R2007 object walk work and their 216
VISUALSTYLE records reached a decoder for the first time. Neither
shipped list closed on any of them, and #73 opened on the obvious
reading: a third generation of the layout. There is not one.

Measured first, the corpus: every one of the nineteen files holds
exactly 24 VISUALSTYLE records, R14 included, so the 216 split
72 / 72 / 72 rather than 108 / 108 / 0.

R14 and R2000 write the same 30 flag-less fields in the same order as
R2004. The whole difference is §2.11 — before R2004 a colour is the
bare BS index, without the BL true-colour word and RC colour byte.
Read the five colour slots that way and the list lands all 144 records
of the six R14 / R2000 files exactly on their boundary, delta 0. The
two encodings agree through the change: R2004's "none" 0xC8000000 is
index 257, 0xC3000007 is index 7, and ColorChange's grey 0xC2808080
(face + edge) and Shaded's 0xC2787878 silhouette are ACI index 8 — in
exactly those three slots of exactly those two records.

R2007 keeps the R2004 colour form and adds exactly one 2-bit slot
before the record's final B. With the R2004 list its records land two
bits short on all 72, and the leftover bits are 10 then
is_internal_use_only — 101 on the fourteen hidden styles, 100 on the
ten listed ones, on every record of all three files. Dim pins the
position: it is the one record whose display_brightness is the full
34-bit BL rather than the 2-bit zero form, and placing the slot before
the brightness closes 23 of 24 and fails on exactly Dim. The head and
after-the-final-B placements fail on all 24.

Declined honestly: the new slot's token type and its side of
display_shadow_type are not determined — both are two bits reading 0
on all 72 records — so it is surfaced as display_unknown_short rather
than named after a guess. It is not R2010's format_version, which
decodes 2.

examples/probe_visualstyle_layout.rs is new: census, joint-boundary
check and one-token uniqueness search over every VISUALSTYLE record of
every file named. Its --search mode reports 33 closing neighbours on
R2007 and 64 on R14 / R2000, all encoding aliases rather than rival
layouts — pre-R2004 a colour is a BS, and BS / BL / BD coincide on the
small-value forms these records use. Width alone does not pick the
layout; the cross-release value agreement does.

Measured on the 19-file corpus (examples/coverage_report.rs), merged
onto origin/main at 6cc9b13:

  R14    426 / 450 / 0 / 48.6 %  ->  498 / 378 / 0 / 56.8 %
  R2000  534 /  99 / 0 / 84.4 %  ->  606 /  27 / 0 / 95.7 %
  R2007  462 /  96 / 0 / 82.8 %  ->  534 /  24 / 0 / 95.7 %
  TOTAL 3695 / 741 / 9 / 83.1 %  -> 3911 / 525 / 9 / 88.0 %

VISUALSTYLE leaves the unhandled histogram entirely; XRECORD (345) is
now the largest unmatched class, and the error count is unchanged.

Closes #73

Claude-Session: https://claude.ai/code/session_01BaHKf1Rw5aJBGK5y3xmx7C
@cursor

cursor Bot commented Aug 30, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_e8529c75-dfaf-4372-b6ea-fb720d89244f)

@DrunkOnJava
DrunkOnJava merged commit bf6c65d into main Aug 30, 2026
20 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/visualstyle-third-layout branch August 30, 2026 23:30
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.

VISUALSTYLE on R14/R2000/R2007: a third layout (216 records; the R2004 flag-less list misses every boundary)

1 participant