Skip to content

fix(entities): read MESH's trailing BL and decode MESH on every release (#71) - #252

Merged
DrunkOnJava merged 6 commits into
mainfrom
fix/71-mesh
Oct 26, 2026
Merged

DrunkOnJava merged 6 commits into
mainfrom
fix/71-mesh

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Read MESH's trailing field as a BL (AutoCAD's DXF export names it: a group 90 equal to 0 after the creases) and stop refusing MESH before R2010. All 14 MESH records of the public corpus now close, R14 to R2018. On the 12 that have a DXF twin, every value equals the DXF, group by group. With #247 (VIEWPORT) and #249 (LEADER) this finishes #71.

Closes #71 (once #247 and #249 are merged; this PR is queued after them).

Spec reference

ODA spec v5.4.1 has no section for MESH (the MESH custom class, DXF subclass AcDbSubDMesh); the field list was already measured (§7i of ARCHITECTURE.md). Two changes:

  1. The trailing two bits are a BL 0. §7i left them unread: 10 is the zero code of BS, BL and BD alike, and both records encode zero, so both errored at delta -2. The DXF twin settles it. Each AcDbSubDMesh group ends 95 (crease count), 140 × crease count, then one more 90 = 0. Every other BL of the record is a group 90 (face-list entries, edge endpoints), written in the record's own order. The decoder now reads the BL and returns Unsupported for a non-zero value, whose contents nothing in the corpus shows, rather than closing on a guess.
  2. MESH is not R2010-only. AutoCAD 2025 writes the same record into its R14, R2000, R2004 and R2007 saves. It is the same class with the same bit budget (93,941 bits for 0x343 on R2000, R2004 and R2010), not a proxy. The decoder returned Unsupported for every pre-R2010 MESH, so 8 of the 14 corpus errors were that gate.

Still undetermined: whether version, subdivision level and vertex count are BS or BL. Every value is below 256, where the two spend the same bits.

Records it was measured on

examples/probe_mesh.rs (new) walks the twin's AcDbSubDMesh group in order and compares every value. That is version, blend crease, subdivision level, every vertex coordinate, every face-list entry, every edge endpoint, every crease and the trailing count.

$ C=~/Library/Caches/dwg-corpus/acadsharp
$ cargo run --release --example probe_mesh -- $C/sample_AC1014.dwg            # R14: no twin, close only
sample_AC1014.dwg (AC1014 (R14)) 0x343 closes  version 2 blend false level 0 vertices 62 faces 72 edges 132 creases 132
sample_AC1014.dwg (AC1014 (R14)) 0x380 closes  version 2 blend false level 0 vertices 64 faces 64 edges 128 creases 128
$ for v in 1015 1018 1021 1024 1027 1032; do cargo run --release --example probe_mesh -- $C/sample_AC$v.dwg $C/sample_AC${v}_ascii.dxf; done
sample_AC1015.dwg (AC1015 (2000)) 0x343 closes ...   DXF: 926 values compared, 0 differ
sample_AC1015.dwg (AC1015 (2000)) 0x380 closes ...   DXF: 904 values compared, 0 differ
... identical for AC1018, AC1021, AC1024, AC1027, AC1032

No other file of either corpus holds a MESH. These are two meshes saved seven times. The record is pinned across releases, but the trailing count has only ever been 0.

Coverage, ../../samples

cargo run --release --example coverage_report -- ../../samples, base 240f376:

                       before                        after
sample_AC1032.dwg   776  57  9  92.2 %          778  57  7  92.4 %
TOTAL              3911 525  9  88.0 %         3913 525  7  88.0 %

The error histogram loses MESH (custom class) → 2.

Coverage, public corpus (acadsharp/; nextgis/ unchanged at 7343 / 1100 / 0)

file before deco / skip / err after
sample_AC1014.dwg 676 / 461 / 105 678 / 461 / 103
sample_AC1015.dwg 914 / 82 / 51 916 / 82 / 49
sample_AC1018.dwg 850 / 74 / 90 852 / 74 / 88
sample_AC1021.dwg 834 / 76 / 15 836 / 76 / 13
sample_AC1024.dwg 851 / 57 / 15 853 / 57 / 13
sample_AC1027.dwg 799 / 57 / 9 801 / 57 / 7
sample_AC1032.dwg 776 / 57 / 9 778 / 57 / 7
TOTAL (10 files) 6438 / 885 / 308 6452 / 885 / 294

These are the decoded/skipped/errored columns of tools/corpus/baseline.tsv. The file will be regenerated in the serial rebase after #249.

Class census and reference closure

probe_class_census and probe_reference_closure on all 19 files of ../../samples give output identical to the run before the change.

Docs

  • ARCHITECTURE.md: new §7m (table above). The §7i MESH row and the "undetermined readings" MESH row point at it.
  • src/entities/mesh.rs: the module doc drops the "§19.4.66" citation (the spec has no MESH section) and the "pre-R2010 files never emit this entity" claim, and records the measurement.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test --release --all-features (real-file tests ran against ../../samples)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • Shown on real files: the records above. Removes 1 existing unit test that asserted the R2007 refusal the corpus disproves; adds none. Two changes to the existing suite follow from the fix:
    • The test helper write_mesh now writes the trailing BL 0, so the two roundtrip tests still build a whole record.
    • rejects_pre_r2010 is removed. It asserted that an R2007 MESH is refused, and the corpus shows AutoCAD writing, and this decoder closing, MESH on R14 to R2007 (8 records, 6 of them matching their DXF twin value for value). Flagging it here because it removes an existing test.

Source-provenance declaration

By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:

  • No Autodesk DWG SDK source (RealDWG, ObjectARX, ObjectDBX) or NDA-protected Autodesk documentation was consulted or imported.
  • No Open Design Alliance Teigha / Drawings SDK source was consulted or imported. The ODA's public Open Design Specification for .dwg files PDF is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

My contribution is based on the corpus bytes and on AutoCAD's DXF exports of the same drawings, read as data files (ACadSharp samples/ at c30a97ce, MIT, pinned by #225). The trailing field is identified from the position and group code the DXF writes there; it is left unnamed, and no outside vocabulary was used. No third-party code or comments were read.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.

…se (#71)

MESH's last two bits, 10, were left unread because they are the zero
code of BS, BL and BD alike. AutoCAD's DXF export of the same drawing
ends each AcDbSubDMesh group with one more group 90 equal to 0 after
the creases, the group it writes for every other BL in the record, so
they are a BL 0. A non-zero value is refused rather than guessed.

AutoCAD writes the same MESH record into R14, R2000, R2004 and R2007
saves, not a proxy, and the decoder refused all of them. Without that
gate the field list closes on all 14 MESH records of the public corpus,
R14 to R2018, and on the 12 with a DXF twin every value equals the DXF
(926 and 904 per record). The test that pinned the pre-R2010 refusal
is removed; the roundtrip helper writes the trailing BL.

examples/probe_mesh.rs reproduces it; ARCHITECTURE.md §7m records it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T17:13:34.719163Z 6fa1d1b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 17:14
@DrunkOnJava
DrunkOnJava merged commit aba881b into main Oct 26, 2026
26 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/71-mesh branch October 26, 2026 17:20
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.

VIEWPORT / LEADER / MESH field lists: three honest #63 errors, each needing one more differently-shaped sample

1 participant