Skip to content

Add support for legacy AutoCAD R14 ASCII DWF - #1

Merged
wybaby168 merged 13 commits into
mainfrom
fix/legacy-ascii-dwf-v0034
Aug 24, 2026
Merged

wybaby168 merged 13 commits into
mainfrom
fix/legacy-ascii-dwf-v0034

Conversation

@brownie-cake

Copy link
Copy Markdown
Contributor

Root cause

The customer drawing is a pre-DWF-6 readable WHIP!/W2D stream (DWF V00.34) produced by AutoCAD R14, not a ZIP-based DWF 6+ package. The loader correctly recognized it as text, but the existing textual fallback was line-oriented and only understood fixture-style commands. It therefore could not parse real compact WHIP opcodes or counted point sets that continue across physical lines.

Fix

  • Add a bounded, linear-time stream scanner for legacy readable DWF.
  • Parse the core C, L, P, T, M, F/f, and V/v opcodes.
  • Parse palette colors, source background, line weight, marker size, and extended ASCII operands.
  • Triangulate T polytriangle strips with alternating winding and degenerate-strip handling.
  • Distinguish filled P polygons from unfilled polylines.
  • Preserve the declared DWF background across Canvas, WASM, and WebGL by emitting a page-sized backdrop primitive.
  • Classify successfully parsed readable streams as classic dwf documents rather than unknown text.

Regression coverage

The proprietary Mercedes-Benz drawing remains local and is not committed. A synthetic DWF V00.34 fixture covers multiline point sets, palette/background handling, triangle strips, fill state, markers, visibility, and hidden URL geometry.

Production validation asserts:

  • exactly 8 fixture primitives;
  • polyline: 3, polygon: 3, rect: 2;
  • black source backdrop;
  • zero non-info diagnostics.

Customer-file verification

  • document kind: dwf;
  • page kind: w2d-text;
  • 19,572 renderable primitives including the source backdrop;
  • 0 warning/error diagnostics;
  • complete Mercedes electrical diagram visually restored in the raster preview;
  • parse time approximately 40 ms on the local Node validation run.

Local checks

  • isolated strict TypeScript parser compile: passed;
  • loader/parser integration compile: passed;
  • customer-file parse and visual render inspection: passed;
  • synthetic fixture assertions: passed.

Copy link
Copy Markdown
Contributor Author

Final verification complete.

  • CI run 13: passed (build, validate:production, check:examples, build:demo, pack:dry).
  • Cloudflare Pages demo run 13: demo build and artifact upload passed; deployment was intentionally skipped for the pull-request context.
  • Customer Mercedes-Benz DWF: opened as dwf / w2d-text, produced 19,572 renderable primitives including the black source backdrop, and reported zero warning/error diagnostics.
  • The customer drawing was not committed; only the synthetic legacy DWF V00.34 regression fixture is public.
  • PR is conflict-free and mergeable.

@wybaby168
wybaby168 merged commit c6f7027 into main Aug 24, 2026
2 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