Repository navigation
feat(entities): decode SHAPE from §20.4.37 (#140) #310
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
7 commits
Select commit
Hold shift + click to select a range
508b7c7
feat(entities): decode SHAPE from §20.4.37 (#140)
DrunkOnJava f7c0ad0
fix(examples): carry the one harness file every probe of this lane sh…
DrunkOnJava 6ddcdac
fix(examples): compare SHAPE's rotation and oblique angle in the DXF'…
DrunkOnJava 9c64935
Merge origin/main into obj/shape
DrunkOnJava f506b3a
docs(architecture): renumber the new section (7au->7bt) after the sec…
DrunkOnJava 13eaf3c
Merge remote-tracking branch 'origin/main' into HEAD
DrunkOnJava 369a726
chore(corpus): commit the baselines CI run 40736084515 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,72 @@ | ||
| //! Does the §20.4.37 SHAPE field list close on every corpus record, and do | ||
| //! its values equal AutoCAD's DXF export? | ||
| //! | ||
| //! # What this proves | ||
| //! | ||
| //! For every SHAPE (type 0x21) 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, where the corpus holds | ||
| //! AutoCAD's DXF export of the drawing, compares each decoded value with the | ||
| //! `AcDbShape` entity whose handle (group 5) matches: the insertion point | ||
| //! (10, 20, 30), scale (40), rotation (50), width factor (41), oblique angle | ||
| //! (51), thickness (39) and extrusion (210, 220, 230). A group the DXF leaves | ||
| //! out (AutoCAD omits a default) is counted as omitted, not compared against | ||
| //! an assumed default. The shape number has no DXF group, the DXF writing the | ||
| //! shape's name (group 2) instead, so it is not compared. R14 has no twin in | ||
| //! the corpus, so its record is checked against its boundary alone. | ||
| //! | ||
| //! ```sh | ||
| //! python3 -I tools/corpus/fetch.py --dest ../dwg-corpus | ||
| //! cargo run --release --example probe_shape -- ../dwg-corpus | ||
| //! ``` | ||
| //! | ||
| //! Exit status is non-zero when a record errors, a value differs, a twin | ||
| //! lacks the record, or no value was compared at all. | ||
|
|
||
| #[path = "support/twin.rs"] | ||
| mod twin; | ||
|
|
||
| use dwg::ObjectType; | ||
| use dwg::entities::DecodedEntity; | ||
| use std::process::ExitCode; | ||
| use twin::{Group, Probe, Record, Tally}; | ||
|
|
||
| fn compare(decoded: &DecodedEntity, rec: Option<&Record>, t: &mut Tally) -> bool { | ||
| let DecodedEntity::Shape(ours) = decoded else { | ||
| return false; | ||
| }; | ||
| let Some(rec) = rec else { | ||
| return true; | ||
| }; | ||
| let real = |code: u16| rec.first(code).and_then(Group::real); | ||
| for (what, v, code) in [ | ||
| ("insertion x", ours.insertion_point.x, 10), | ||
| ("insertion y", ours.insertion_point.y, 20), | ||
| ("insertion z", ours.insertion_point.z, 30), | ||
| ("scale", ours.scale, 40), | ||
| ("rotation", ours.rotation.to_degrees(), 50), | ||
| ("width factor", ours.width_factor, 41), | ||
| ("oblique", ours.oblique.to_degrees(), 51), | ||
| ("thickness", ours.thickness, 39), | ||
| ("extrusion x", ours.extrusion.x, 210), | ||
| ("extrusion y", ours.extrusion.y, 220), | ||
| ("extrusion z", ours.extrusion.z, 230), | ||
| ] { | ||
| t.real(what, v, real(code)); | ||
| } | ||
| true | ||
| } | ||
|
|
||
| fn main() -> ExitCode { | ||
| twin::run( | ||
| &Probe { | ||
| tag: "SHAPE", | ||
| class: None, | ||
| kind: Some(ObjectType::Shape), | ||
| dxf_kind: "SHAPE", | ||
| decodes_on: |_| true, | ||
| note: "; the shape number has no DXF group (the DXF holds the name)", | ||
| }, | ||
| 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
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.