Repository navigation
feat(objects): decode VIEWPORT ENTITY HEADER from §20.4.70 (#146) #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4f74e9c
feat(objects): decode VIEWPORT ENTITY HEADER from §20.4.70 (#146)
DrunkOnJava 2ee1ad0
refactor(objects): name the module control_vp_ent_hdr so its entry in…
DrunkOnJava 78863ed
fix(examples): carry the one harness file every probe of this lane sh…
DrunkOnJava 9338d80
Merge origin/main into obj/vp-ent-hdr
DrunkOnJava 51ae0f5
chore(corpus): record the baseline the Corpus job measured for VIEWPO…
DrunkOnJava a2b06c8
docs(architecture): renumber the new section (7au->7bu) after the sec…
DrunkOnJava 219af1f
Merge remote-tracking branch 'origin/main' into HEAD
DrunkOnJava 3ab4a09
chore(corpus): commit the baselines CI run 40739158933 measured
DrunkOnJava File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| //! Does the §20.4.70 VIEWPORT ENTITY HEADER field list close on every corpus | ||
| //! record? | ||
| //! | ||
| //! # What this proves | ||
| //! | ||
| //! For every VP_ENT_HDR (type 0x47) of every drawing under the corpus | ||
| //! directory this reports whether the crate's decoder closed exactly on the | ||
| //! record's data-stream boundary (ARCHITECTURE.md §7i), and prints the entry | ||
| //! name and flags it read. Only R14 and R2000 drawings hold one, and | ||
| //! AutoCAD's DXF exports of the corpus (R12 for R14, R2000's own) hold no | ||
| //! record for it, so there is nothing to compare values with: the evidence is | ||
| //! the boundary. | ||
| //! | ||
| //! ```sh | ||
| //! python3 -I tools/corpus/fetch.py --dest ../dwg-corpus | ||
| //! cargo run --release --example probe_vp_ent_hdr -- ../dwg-corpus | ||
| //! ``` | ||
| //! | ||
| //! Exit status is non-zero when a record errors or is not decoded. | ||
|
|
||
| #[path = "support/twin.rs"] | ||
| mod twin; | ||
|
|
||
| use dwg::ObjectType; | ||
| use dwg::entities::DecodedEntity; | ||
| use std::process::ExitCode; | ||
| use twin::{Probe, Record, Tally}; | ||
|
|
||
| fn compare(decoded: &DecodedEntity, _rec: Option<&Record>, _t: &mut Tally) -> bool { | ||
| let DecodedEntity::VpEntHdr(ours) = decoded else { | ||
| return false; | ||
| }; | ||
| println!( | ||
| " name {:?}, 64-flag {}, xref index + 1 {}, xdep {}, 1 flag {}", | ||
| ours.name, ours.flag_64, ours.xref_index_plus_1, ours.is_xref_dependent, ours.flag_1 | ||
| ); | ||
| true | ||
| } | ||
|
|
||
| fn main() -> ExitCode { | ||
| twin::run( | ||
| &Probe { | ||
| tag: "VP_ENT_HDR", | ||
| class: None, | ||
| kind: Some(ObjectType::VpEntHdr), | ||
| dxf_kind: "", | ||
| decodes_on: |_| true, | ||
| note: "; the DXF exports hold no VIEWPORT ENTITY HEADER, so only the boundary is checked", | ||
| }, | ||
| compare, | ||
| ) | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| //! VIEWPORT ENTITY HEADER (§20.4.70, type 0x47) — the header the older | ||
| //! releases keep for each viewport entity of a paper space layout. | ||
| //! | ||
| //! Only R14 and R2000 drawings hold one; later releases do not. It is a | ||
| //! non-entity object whose data stream is the name and flags a symbol-table | ||
| //! entry opens with (§20.4.54), then one more flag: | ||
| //! | ||
| //! ```text | ||
| //! TV entry name DXF 2 | ||
| //! B 64-flag DXF 70, the 64 bit | ||
| //! BS xrefindex + 1 DXF 70; subtract one, -1 means not from an xref | ||
| //! B xdep DXF 70, the 16 bit; dependent on an xref | ||
| //! B 1 flag DXF 70, the 1 bit | ||
| //! ``` | ||
| //! | ||
| //! Its handle references (the viewport entity control, the extension | ||
| //! dictionary, the external reference block, the viewport entity it | ||
| //! describes and the previous header of the chain) are in the handle stream | ||
| //! and are not read here. The corpus's AutoCAD DXF exports hold no VIEWPORT | ||
| //! ENTITY HEADER, so its records are checked against their data-stream | ||
| //! boundary alone. | ||
|
|
||
| use crate::error::Result; | ||
| use crate::objects::modern; | ||
| use crate::version::Version; | ||
|
|
||
| /// A decoded VIEWPORT ENTITY HEADER. | ||
| #[derive(Debug, Clone, PartialEq, Eq, Default)] | ||
| pub struct VpEntHdr { | ||
| /// `TV` entry name, DXF 2. | ||
| pub name: String, | ||
| /// `B` the 64 bit of DXF group 70. | ||
| pub flag_64: bool, | ||
| /// `BS` xrefindex + 1. | ||
| pub xref_index_plus_1: i16, | ||
| /// `B` xdep: dependent on an external reference. | ||
| pub is_xref_dependent: bool, | ||
| /// `B` the 1 bit of DXF group 70. | ||
| pub flag_1: bool, | ||
| } | ||
|
|
||
| /// Decode a VIEWPORT ENTITY HEADER (§20.4.70) from its raw object payload, | ||
| /// checking the data fields end exactly on the data-stream boundary. | ||
| pub(crate) fn decode_object( | ||
| payload: &[u8], | ||
| body_start: usize, | ||
| inline_data_end: Option<usize>, | ||
| version: Version, | ||
| ) -> Result<VpEntHdr> { | ||
| let mut split = modern::open(payload, body_start, inline_data_end, version)?; | ||
| let out = VpEntHdr { | ||
| name: modern::read_tv(&mut split.data, &mut split.strings, version)?, | ||
| flag_64: split.data.read_b()?, | ||
| xref_index_plus_1: split.data.read_bs()?, | ||
| is_xref_dependent: split.data.read_b()?, | ||
| flag_1: split.data.read_b()?, | ||
| }; | ||
| split.finish("VP_ENT_HDR")?; | ||
| Ok(out) | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.