Skip to content

feat(dxf): score the DIMENSION family in the value oracle (§20.4.22 to §20.4.29) - #387

Merged
DrunkOnJava merged 3 commits into
mainfrom
feat/dxf-oracle-dimension
Oct 28, 2026
Merged

DrunkOnJava merged 3 commits into
mainfrom
feat/dxf-oracle-dimension

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

The value oracle scores the seven DIMENSION types (§20.4.23 to §20.4.29, with the common dimension data of §20.4.22) against AutoCAD's DXF export: 66 records, R2000 to R2018.

Every group code but 10 is written once per record, so the record is scored as a whole. The common fields: the extrusion (210), the text midpoint (11, 21) with the elevation as its z (31), the text (1), the text rotation and horizontal direction (53, 51), the insertion scale z and rotation (43, 54), the attachment (71), the line spacing (72, 41), the measurement (42), the flip arrows from R2007 (74, 75), the version byte from R2010 (280) and the clone point (12, 22). Each subtype adds its points (10, 13, 14, 15, 16) and scalars (40, 50, 52).

The DWG's flags byte is not group 70. §20.4.22 and §20.4.23 make the group from the subtype's type, 32 for the flags bit 1, 128 for the absence of its bit 0, and 64 for an ordinate dimension's second flag byte. That derived value is the one compared, and it equals the export on all 66 records. A group the export omits stands for the DXF Reference's default (line spacing style 1 and factor 1, rotations 0, empty text, insertion scale z 1) and counts as default, never equal.

Spec reference

Spec §20.4.22 Common dimension data, §20.4.23 ORDINATE, §20.4.24 LINEAR, §20.4.25 ALIGNED, §20.4.26 ANGULAR 3-PT, §20.4.27 ANGULAR 2-LINE, §20.4.28 RADIUS and §20.4.29 DIAMETER. Before and after, on the 49 drawing pairs:

Type Records Equal Default Different DWG only Not decoded
ORDINATE (§20.4.23) 12 202 120 0 48 56
LINEAR (§20.4.24) 18 309 210 0 72 106
ALIGNED (§20.4.25) 12 202 132 0 48 211
ANGULAR 3-PT (§20.4.26) 6 119 60 0 24 28
ANGULAR 2-LINE (§20.4.27) 6 137 60 0 24 28
RADIUS (§20.4.28) 6 89 60 0 24 82
DIAMETER (§20.4.29) 6 89 60 0 24 82
after, total 66 1147 702 0 264 593
before (main) 66 paired, each listed under "Paired records no scorer covers: no scorer yet" - - - - -

No field comes out different. The 264 DWG-only values are two groups of decoded fields the export has no group to compare: the clone point (12, 22), which the export omits on all 66 records, and the insertion scale x and y (§20.4.22 says they go to the anonymous block and cannot be read back; their codes 41 and 42 are the line spacing factor and the measurement). The not-decoded groups are the handles (the dimension style in 3, the anonymous block in 2, the owner in 330), the spec's unknown (73), the layer (8), the entity's colours and the extended data of a dimension with an overridden style.

tools/oracle/baseline.tsv gains the 1343 new rows; no existing row changes (the ratchet against main's baseline passes). The seven rows of docs/spec-coverage.md say what the oracle measured; their states stay closes.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, cargo test --release --all-features, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features, python3 tools/ci/spec_coverage.py --check
  • Real files, no new unit tests. The oracle over the pinned corpus reproduces the committed TSV and passes its ratchet against main's baseline:
cargo run --release --features dxf-reader --example dxf_oracle -- <corpus-dir> \
    --baseline tools/oracle/baseline.tsv --tsv oracle.tsv --details
cmp oracle.tsv tools/oracle/baseline.tsv

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. This matters because dwg-rs is Apache-2.0 and must remain compatible.

My contribution is based on:

  • The ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1);
  • Public reverse-engineering notes, research papers, or blog posts cited inline;
  • Reading algorithm-description comments (not executable code) in permissively-licensed projects (MIT / Apache / BSD) to resolve spec ambiguities — disclose any such reading in this PR body so it can be recorded in CLEANROOM.md.

No such reading was needed: the mapping is the spec's DXF column and the DXF Reference's AcDbDimension groups, read from AutoCAD's own exports as data.

See CLEANROOM.md for the full allowed/forbidden source list and the honest scope of what "clean-room" means for this project.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the
Developer Certificate of Origin 1.1.
Specifically, I affirm that the contribution is my own work (or rightfully
licensed to me) and that it can be distributed under the project's Apache-2.0
license.

I will sign off commits with git commit -s when asked, which adds a
Signed-off-by trailer to the commit message asserting the DCO.

Refs #99, #102, #144.

…o §20.4.29)

The seven DIMENSION decoders (§20.4.23 to §20.4.29, with the common
dimension data of §20.4.22) are now compared with AutoCAD's export field
by field. The record is scored as a whole, since every group code but 10
is written once: the common fields (the extrusion in 210, the text
midpoint in 11 with the elevation as its z in 31, the text, rotations,
insertion scale z and rotation, attachment, line spacing, measurement,
flip arrows from R2007, version byte from R2010, the clone point in 12)
and each subtype's points (10, 13, 14, 15, 16) and scalars (40, 50, 52).
The DWG's flags byte is not group 70: the subtype's type, 32 for its
bit 1, 128 for the absence of its bit 0 and 64 for an ordinate
dimension's second flag byte make the group (§20.4.22, §20.4.23), and
that derived value is the one compared. A group the export omits stands
for the DXF Reference's default (line spacing style 1 and factor 1,
rotations 0, empty text, insertion scale z 1).

On the 49 drawing pairs: 66 records, R2000 to R2018 (11 per release:
3 linear, 2 aligned, 2 ordinate, 1 each of the two angular, radius and
diameter), 1147 values equal the export, 702 by its default, none
differ. 264 decoded values have no DXF group (the clone point, which the
export omits, and the insertion scale x and y, which share codes 41 and 42
with the line spacing factor and the measurement). tools/oracle/baseline.tsv
gains the 1343 new rows, and the seven rows of docs/spec-coverage.md say
what the oracle measured. The oracle's section map files the seven types
under §20.4.23 to §20.4.29.

Refs #99, #102, #144
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-28T06:32:56.978818Z 0d7b1f0 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 28, 2026 06:46
@DrunkOnJava
DrunkOnJava merged commit 852e608 into main Oct 28, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the feat/dxf-oracle-dimension branch October 28, 2026 06:51
DrunkOnJava added a commit that referenced this pull request Oct 28, 2026
…till skipped (#424)

CHANGELOG gains the table objects (#313, #316, #317, #319), the nineteen classes derived from
AutoCAD's output (#326 to #341), the DIMENSION scorer (#387), the BLOCK fixtures (#407), the
maintainer tools (#406, #383) and the merge train's stack handling (#421 to #423). README said every
skipped type had a decoder in review; only SHAPE (#310) and the VIEWPORT entity header (#311) do,
and the rest are twelve custom classes in the BookViewerApp3 drawings with no DXF export yet, now
named. STATUS's pending section says its counts are the 2026-08-30 snapshot.
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.

1 participant