Repository navigation
fix(entities): keep the entity colour's true colour and transparency words, RGB first (§2.11) (#126) - #359
Merged
Conversation
…words, RGB first (§2.11) (#126)
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fe0fac281
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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
read_common_entity_dataread an R2004+ entity colour's two optionalBLwords in the wrong order and dropped both. This keeps them (CommonEntityData::color_raw,color_rgb,color_alpha) with the RGB word first, as §2.11 lists them, and addsprobe_entity_colour, which compares them with AutoCAD's own export of the corpus drawings. Split out of #358 (the ENTITIES writer, #126) at the integrator's request so the finding lands on its own before the writer.What this changes and what it does not, measured on
main(b9beccb): the twoBLs are 32 bits each, so reading them in either order leaves the cursor in the same place, and the old code discarded both. No decoded count, no decoded entity value and no consumer moves: the entity structs carry no colour, SVG, glTF and DXF export read none of it, and nothing inexamples/dxf_oraclereadsCommonEntityData. The order became observable only once the words were kept; the first cut of #358 kept them in the ordermainread them and disagreed with the export on every entity that carries both. What is new is the public data: three fields onCommonEntityData, which #358 writes as DXF groups 62, 420 and 440.Spec reference
ODA v5.4.1 §2.11 CMC: the
BScolour index, whose high byte flags a true colourBL(0x80), a colour book handle (0x40, the RGB and name are then in the AcDbColor object) and a transparencyBL(0x20), read in that order after theBS, followed by the names when flagged. §20.4.1 puts the CMC in the common entity data.src/common_entity.rs: the three fields, and the read order.examples/probe_entity_colour.rs: the probe, wired into the Corpus job (.github/workflows/ci.yml,Cargo.toml).ARCHITECTURE.md7al: the finding with its evidence table.Test plan
cargo fmt --all -- --check,cargo clippy --all-targets --all-features -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-featurescargo run --release --features dxf-reader --example probe_entity_colour -- <dwg-corpus>pairs every entity of the 42 corpus drawings that have an AutoCAD export (R2000 to R2018, 2,579 entities) with the export's record of the same handle. Exit 0, 0 disagree:The
bothcolumn is the entities that carry both words, the only ones the order can touch. Read RGB first (agree), all 14 per release match the export's 420 and 440. With the two words exchanged, which is what the old order would have produced had it kept them (exchanged), none does. Before and after on one real entity, the LINE9D4ofsample_AC1032.dwg: the export reads62 183,420 8404418,440 16777216; the stream holds0xC2802142then0x01000000. After:color_rgb = 0xC2802142(low 24 bits 8404418),color_alpha = 0x01000000(16777216). Before, in the old order: transparency0xC2802142, colour0x01000000.CommonEntityData, so its baseline cannot move; the Corpus job checks that. The new probe is the measurement against the same AutoCAD exports.NOT MEASURED. The real corpus run above reads all 2,579 with 0 unread. Negative run,PROBE_ENTITY_COLOUR_TRUNCATE=4(cuts every record to 4 bytes): 2,609 entities named unreadable,NOT MEASURED, exit 1.CIRCLE 99Fofsample_AC1018.dwgand its re-saves) is counted and not compared: its 420 is in the AcDbColor object, not in the entity.cargo test --release --all-features --lib common_entity: 4 passed (the preamble round-trips), on this head.cargo test --release --all-featuresruns in CI; I did not run it locally on this head.Existing tests and code changed
CommonEntityDatagains three public fields (nothing outsideread_entity_mode_onwardsbuilds one). No existing test changed.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:
The only other inputs are the public corpus and AutoCAD's own DXF exports of its drawings. No algorithm-description comments in other projects were read.
Developer Certificate of Origin
I affirm the contribution is my own work and may be distributed under the project's Apache-2.0 license.