Skip to content

Civil: write and read an empty TIN surface's shell (W2-2) - #656

Merged
HakanSeven12 merged 2 commits into
hakanaktt:mainfrom
schoeller:surfparcel
Nov 24, 2026
Merged

HakanSeven12 merged 2 commits into
hakanaktt:mainfrom
schoeller:surfparcel

Conversation

@schoeller

Copy link
Copy Markdown
Contributor

Closes the D016 gap W2-2 (and the folded W1-2 investigation) from the corpus packets.

Finding

A surface the application has not built keeps no triangulation — only a shell: the four bounding corners at the drawing extremes, each with RL flags 0x40, RL -1 and positions at the ±DBL_MAX extremes, then BL 0 triangles. Both records are in the tutorials corpus:

  • Surface-2.dwg "EG" (the file's only surface): the app itself reads vertices=0 triangles=0 (bridge probe), yet the codec reported tin_surface() = None and the rebuilt file had 0 surfaces vs the oracle's 1.
  • Pipe Networks-3B.dwg third surface (W1-2): the same empty block stored twice with BL 0, BL 1, MMS01 between — a snapshot-only empty surface (definitions decode as [Kind40(0)]). Same phenomenon, not a decode hole; the reader now surfaces it empty-not-None.

Change

  • Reader (read_at): accept corner-only blocks — count >= 4 (was 7) and triangle_count == 0 allowed when count == 4. A shell decodes as a TinSurface with four vertices and no triangles (empty, not None); a snapshot of one the same way. The probe fallback is protected by the exact-shape gate.
  • Writer: Triangulation::empty() stores the app's own form; the triangulation closure writes -1 as a vertex's incident triangle when it has none (was 0 — latent) and the bare corner flag 0x40 on a shell (the app's form; built surfaces keep 0x8440). add_empty_tin_surface adds a shell; add_tin_surface_with stores a shell for definitions that bring no geometry (reproducing the snapshot-only record), with an empty snapshot for a no-geometry prefix.

Verification (corpus roundtrip, oracle = Civil Tutorials Drawings)

  • Surface-2 analyze→build→verify: manifest tin_surface count=1 names=["EG"] vs built 1 == 1, name identical; lwpolyline 85/85 BIT-EXACT; compare_verify tin_surface: 1 items BIT-EXACT; census {AcDbPolyline: 85, AeccDbSurfaceTin: 1} == oracle.
  • Bridge (Civil 3D, port 7900): built file opens with no dialog, audit clean (86 entities, 0 null/erased refs), app census AcDbPolyline=85 AeccDbSurfaceTin=1 == oracle, and the app reads the built surface tin name=EG vertices=0 triangles=0 — identical to its read of the oracle.
  • Pipe Networks-3B: the snapshot-only surface decodes tin_surface() = Some(4, 0) and tin_snapshot() = Some(4, 0).
  • New tests: shell bit-gram decode (plus the 5-vertices/0-triangles negative) and a shell + snapshot-only file round trip.
  • Full suite green on this tip (3302 passed / 0 failed).

Related open PRs: #655 (W1-5 COGO points, disjoint files). The W1-6 parcel re-measurement on this same tip is recorded in the campaign runlog: refusals unchanged (129/163, all "crosses or touches a member it may not meet"), no code change proposed.

A surface the application has not built keeps no triangulation — only
its shell: the four bounding corners at the drawing extremes, with no
incident triangle and no triangles (the tutorials' Surface-2.dwg "EG",
and the snapshot-only surface of Pipe Networks-3B.dwg). The reader
refused the block (fewer than 7 vertices, zero triangles) and reported
None, so a census of the drawing lost the surface; the writer had no
way to add one.

The reader now decodes the shell as a corner-only TinSurface (four
vertices, no triangles) — empty, not None — and a snapshot of it the
same way. The writer emits the app's own form for a surface with no
data: add_empty_tin_surface, and add_tin_surface_with accepts
definitions that bring no geometry (a snapshot-only surface) by storing
the shell. Corners of a shell carry the bare corner flag (0x40) and -1
as their incident triangle, as the app stores them.

Closes the D016 gap W2-2: the built Surface-2 now opens in Civil 3D
with census 1 == 1 surfaces, audit clean, and the application reads the
shell back as name EG, 0 vertices, 0 triangles — identical to the
oracle.
Missed in b74c489: the civil::civil re-export references the new
constructor, but the create-module export was left unstaged, breaking
the crate build.
@HakanSeven12
HakanSeven12 merged commit 52244c5 into hakanaktt:main Nov 24, 2026
6 checks passed
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.

2 participants