Skip to content

fix(entities): a HATCH spline edge without fit points stores no tangents (#228) - #294

Merged
DrunkOnJava merged 4 commits into
mainfrom
fix/228-hatch
Oct 26, 2026
Merged

DrunkOnJava merged 4 commits into
mainfrom
fix/228-hatch

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

Read a HATCH spline edge's start and end tangents only when the edge has fit points. §20.4.75 prints them unconditionally after the R2010+ fit-point list. The one spline edge in the corpus has no fit points and stores no tangents, and that record, HATCH 0xAA8 of ACadSharp's export_sample.dwg, now closes. With this, HATCH records error on no release. Part of #228; DIMSTYLE is #293, and VIEW belongs to the oracle lane.

Spec reference

§20.4.75 HATCH, spline edge (pathtypestatus == 4), R24: block: BL numfitpoints, 2RD fit points, 2RD start tangent, 2RD end tangent.

decode_spline_edge now reads the two tangents only when numfitpoints > 0. That keeps the spec's order for the case with fit points, which no corpus record has.

The record it was measured on

0xAA8 (R2018) has one boundary path (flags 5: external, derived) with one spline edge: degree 3, 13 knots, 9 control points, 0 fit points. Read with the tangents, its num_boundary_handles decodes to 298,029,779 and the record errors. Read without them, every field after the edge is plausible:

Field Value
numfitpoints 0 (then no tangents)
numboundaryobjhandles 1
style, pattern type 1, 1
pattern angle, scale, double 0, 1, false
definition line 45°, through (0, 0), offset (−0.0884, 0.0884): ANSI31's 0.125 spacing
pixel size 0.0177 (the path is derived)
seed point (5.13, 2.59)
end bit 2827, the string-stream start, with "LINEAR" and "ANSI31" both consumed

The edge's control polygon is closed and starts and ends at (4.43, 2.59). That is the first and last of the 7 fit points of SPLINE 0xA7F in the same drawing, and the seed point lies inside that curve. export_sample.dwg has no DXF twin, so this is the evidence available.

D=~/Library/Caches/dwg-corpus/acadsharp/export_sample.dwg
cargo run --release --example probe_decode_errors -- $D HATCH        # 0 erroring record(s)
cargo run --release --example probe_entity_field_list -- $D 0xAA8 BL,BS,BS,BD,BD,B,BS,BD,2BD,2BD,BS,BD,BL,2RD --at=2374   # delta 0
cargo run --release --example probe_entity_field_list -- $D 0xAA8 2RD,2RD,BL --at=2374                                 # BL = 298029779

No other HATCH record in the 52-file corpus or ../../samples has a spline edge, so no other record's reading changes.

Coverage, ../../samples

Unchanged, TOTAL 4256 / 180 / 9 (no spline-edged HATCH among the 19 files).

Public corpus: tools/corpus/baseline.tsv (regenerated, committed)

export_sample.dwg   453 11 14  →  454 11 13

52-file total: 14938 / 831 / 305 → 14939 / 831 / 304, measured against main at dcc29d7. measure.py check passes. spec_examples are unchanged: §20.4.75.1 is a class-numbered record whose walk and CRC are all that run.

Class census and reference closure

Unchanged on all 19 files of ../../samples and in the baseline's census and closure columns.

Docs

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • RUSTFLAGS="-D warnings" cargo test --release --all-features (real-file tests ran against ../../samples)
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • tools/corpus/measure.py check passes against the committed baseline
  • No unit tests added or changed (no existing test builds a spline edge).

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.

My contribution is based on §20.4.75 of the ODA's freely-redistributable Open Design Specification for .dwg files (v5.4.1) and on the corpus bytes (ACadSharp samples/ at c30a97ce, MIT, pinned by #225). No third-party 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.

…nts (#228)

§20.4.75 prints the R2010+ spline-edge tangents unconditionally after
the fit points. The corpus's one spline edge, HATCH 0xAA8 of
export_sample.dwg, has no fit points and closes on its string stream
only without them; read with them its boundary-handle count decodes to
298,029,779. Read the tangents only when there are fit points, and bring
the module's field list in line with §20.4.75 as the decoder reads it.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-26T17:33:52.876473Z ebb803f 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

Copy link
Copy Markdown
Owner Author

Merge-train note for ebb803f: main had changed these docs/data/spec-coverage.tsv notes since this PR's base, and this PR rewrote them too. The PR's free text was kept and main's was dropped. Tool-written sentences (DXF oracle, spec examples) were kept and regenerated. Check that nothing below still needs saying:

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