Repository navigation
fix(tables): VPORT's aspect ratio and view mode in AutoCAD's terms (§20.4.64) - #238
Merged
Merged
Conversation
…20.4.64) §20.4.64 says VPORT's second BD is the aspect ratio times the view height, to be divided by the height, and that the view mode is four bits mapping to group 71 bits 1, 2, 4 and the opposite of 16, with UCSFOLLOW giving bit 8. VportEntry surfaced both as stored: an aspect_ratio of 603.86 where AutoCAD exports 2.0332, and a view_mode of 1 where it exports 0. The DXF value oracle found both disagreeing on all 42 VPORTs of the nextgis and ACadSharp exports. The stored BD is now view_width, with aspect_ratio() dividing by the height, and view_mode is the group-71 value assembled as §20.4.64 prescribes, UCSFOLLOW included. Both now equal the export on all 42. Refs #99
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 26, 2026
DrunkOnJava
enabled auto-merge (squash)
October 26, 2026 10:31
5 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
The pre-R2007 VIEW decoder read the view centre as two BDs, the view
mode as a BS and stopped after the associated-UCS bit. §20.4.60 gives a
2RD centre ("not bit-pair coded"), a 4-bit view mode (the encoding
VPORT uses), an RC render mode from R2000, the paper-space bit, and
from R2000 the associated-UCS bit followed, when set, by the UCS origin,
axes, elevation and orthographic type. The three ACadSharp VIEW records
of the R14, R2000 and R2004 saves errored on a reserved BD code; with
the spec's list all three close on their boundary (ACadSharp errors
308 -> 305, decoded 6438 -> 6441; nextgis unchanged, it has no VIEW).
The view mode stays the stored four bits, as on R2007+; surfacing it as
group 71 for VIEW and VPORT alike follows #238. The pre-R2007 synthetic
test writes the spec's layout.
Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
The pre-R2007 VIEW decoder read the view centre as two BDs, the view
mode as a BS and stopped after the associated-UCS bit. §20.4.60 gives a
2RD centre ("not bit-pair coded"), a 4-bit view mode (the encoding
VPORT uses), an RC render mode from R2000, the paper-space bit, and
from R2000 the associated-UCS bit followed, when set, by the UCS origin,
axes, elevation and orthographic type. The three ACadSharp VIEW records
of the R14, R2000 and R2004 saves errored on a reserved BD code; with
the spec's list all three close on their boundary (ACadSharp errors
308 -> 305, decoded 6438 -> 6441; nextgis unchanged, it has no VIEW).
The view mode stays the stored four bits, as on R2007+; surfacing it as
group 71 for VIEW and VPORT alike follows #238. The pre-R2007 synthetic
test writes the spec's layout.
Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
The pre-R2007 VIEW decoder read the view centre as two BDs, the view
mode as a BS and stopped after the associated-UCS bit. §20.4.60 gives a
2RD centre ("not bit-pair coded"), a 4-bit view mode (the encoding
VPORT uses), an RC render mode from R2000, the paper-space bit, and
from R2000 the associated-UCS bit followed, when set, by the UCS origin,
axes, elevation and orthographic type. The three ACadSharp VIEW records
of the R14, R2000 and R2004 saves errored on a reserved BD code; with
the spec's list all three close on their boundary (ACadSharp errors
308 -> 305, decoded 6438 -> 6441; nextgis unchanged, it has no VIEW).
The view mode stays the stored four bits, as on R2007+; surfacing it as
group 71 for VIEW and VPORT alike follows #238. The pre-R2007 synthetic
test writes the spec's layout.
Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
The pre-R2007 VIEW decoder read the view centre as two BDs, the view
mode as a BS and stopped after the associated-UCS bit. §20.4.60 gives a
2RD centre ("not bit-pair coded"), a 4-bit view mode (the encoding
VPORT uses), an RC render mode from R2000, the paper-space bit, and
from R2000 the associated-UCS bit followed, when set, by the UCS origin,
axes, elevation and orthographic type. The three ACadSharp VIEW records
of the R14, R2000 and R2004 saves errored on a reserved BD code; with
the spec's list all three close on their boundary (ACadSharp errors
308 -> 305, decoded 6438 -> 6441; nextgis unchanged, it has no VIEW).
The view mode stays the stored four bits, as on R2007+; surfacing it as
group 71 for VIEW and VPORT alike follows #238. The pre-R2007 synthetic
test writes the spec's layout.
Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
* fix(tables): read the pre-R2007 VIEW record as §20.4.60 gives it
The pre-R2007 VIEW decoder read the view centre as two BDs, the view
mode as a BS and stopped after the associated-UCS bit. §20.4.60 gives a
2RD centre ("not bit-pair coded"), a 4-bit view mode (the encoding
VPORT uses), an RC render mode from R2000, the paper-space bit, and
from R2000 the associated-UCS bit followed, when set, by the UCS origin,
axes, elevation and orthographic type. The three ACadSharp VIEW records
of the R14, R2000 and R2004 saves errored on a reserved BD code; with
the spec's list all three close on their boundary (ACadSharp errors
308 -> 305, decoded 6438 -> 6441; nextgis unchanged, it has no VIEW).
The view mode stays the stored four bits, as on R2007+; surfacing it as
group 71 for VIEW and VPORT alike follows #238. The pre-R2007 synthetic
test writes the spec's layout.
Refs #256
* test(corpus): record the three VIEW records #256's fix decodes
sample_AC1014, sample_AC1015 and sample_AC1018 each decode one more
record (their VIEW) and error one fewer; measure.py check passes.
4 tasks done
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Refs #256
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Closes #256 (with #263, #279 and #293, every decoded VIEW value now equals the export).
DrunkOnJava
added a commit
that referenced
this pull request
Oct 26, 2026
§20.4.60 stores VIEW's view mode as four bits, "0: 71's bit 0 (1), 1: 71's bit 1 (2), 2: 71's bit 2 (4), 3: OPPOSITE of 71's bit 4 (16)", and notes that bit 3 (8) of group 71 "can not be specified". Both VIEW paths surfaced the raw bits; they now surface the group-71 value through the conversion VPORT uses (§20.4.64, #238), with no UCSFOLLOW bit. The DXF value oracle compares ViewEntry::view_mode with group 71 directly now, instead of converting the stored bits in its scorer: equal on all 6 VIEW records, R2000 to R2018. Its baseline row is renamed from "view_mode (stored bits, as group 71)" to "view_mode". The two VIEW round-trip tests write the bits 0001, whose group-71 value is 0. Closes #256 (with #263, #279 and #293, every decoded VIEW value now equals the export).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VPORT's aspect ratio and view mode in AutoCAD's terms, as §20.4.64 prescribes: the stored second
BDis the view width (view_width, withaspect_ratio()dividing by the height), andview_modeis the group-71 value assembled from the four stored bits andUCSFOLLOW.Spec reference
§20.4.64 VPORT:
VportEntry::aspect_ratioheld the stored product (the module docs already noted it "observes as the view width").view_modeheld the four raw bits packed first-read-high.aspect_ratio(the field) is renamedview_widthand gains the method;view_modekeeps its name and now holds the DXF 71 value. The one existing assertion on the field is renamed; no test added.examples/dump_decoded_entitiesprints the ratio.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurescargo test --release --all-featureswith the 19-file../../samplescorpus present: all passexamples/dxf_oracle, the pairing/scorer example that follows feat(dxf): an ASCII DXF reader keyed by handle, for the value oracle #223) over nextgisff05d5a8and ACadSharpsamples/c30a97ce(the pinned set of ci(corpus): measure the reader on public drawings fetched by pinned hash #225):Before (
main), the VPORT table:After (this branch):
603.8576017130621 / 297.0is the2.033190578158458the R2013 export writes; the stored bits0001(front clip at the eye) give71 = 0. Every other VPORT field the decoder surfaces agrees on all 42 records exceptgeoloc.dwg's view height and centre, which differ as a view does between two saves and are listed on #99 as open.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:
CLEANROOM.md).Based on ODA spec v5.4.1 §20.4.64 and AutoCAD's own DXF exports in
nextgis/dwg_samplesand the ACadSharpsamples/directory, read as data. No permissively-licensed project's 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.
Refs #99