feat(dwg): parse MESH (AcDbSubDMesh) and document the fix

The road-surface drawing (대산당진 2공구_노면) rendered nothing for its
노면/부체도로면 geometry. The cause was not the renderer: the parseResult
contained zero MESH entities.

Two faults, both in the wasm parser, fixed upstream in hmwebviewer 35f5b1c:

1. dwg-wasm never serialized MESH. acadrust reads the entity in full; only the
   JSON arm was missing.

2. acadrust's read_mesh clamped its array counts with the blanket 100_000-item
   corrupt-data guard. This drawing's road mesh has 105_497 vertices, so the
   count was truncated, the remaining vertex bits were never consumed, and the
   face/edge/crease lists after them decoded from the wrong bit offset —
   producing a plausible-looking vertex count next to a nonsense 14-face list.
   Counts are now bounded by the bits actually left in the object stream.

       before  verts=100000 faces=14      face sizes [64, 0, 64, 23, 0, 0, 0, 15]
       after   verts=105497 faces=185444  face sizes [3, 3, 3, ...]

This commit carries the vendored side of that work:

- the rebuilt wasm, which now emits MESH as flat arrays (vertices [x,y,z,...],
  faceList in DXF group-93 layout, deduplicated edges). The sample drawing goes
  from 116 MB to 130 MB of parseResult with parse time unchanged at ~3.2 s.
- a MESH case in the property inspector (vertex/face/edge counts, subdivision
  level, bbox and elevation range)
- docs/subdmesh-rendering.md, plus README pointers
- the acadrust licence notice, which can no longer say "consumed unmodified" —
  read_mesh now carries a local patch. MPL-2.0 is file-level copyleft, so the
  patched file stays under MPL and its source ships in hmwebviewer.

Verified: 9 MESH entities parsed from the drawing; entity histograms over six
other sample drawings are byte-identical to the previous wasm, so nothing else
moved.

Two deliberate omissions, both because a lineweight/fat-line refactor is in
flight in this working tree:

- Viewer2D.js is not included. Its _meshSegs helper and three MESH dispatch
  sites share hunks with that refactor and cannot be separated; the same
  renderer code is committed upstream in hmwebviewer 35f5b1c and will land here
  with the refactor. docs/subdmesh-rendering.md records this.
- dist2/ is not rebuilt here. The current build embeds the half-wired
  lineweight button and progress-bar markup; deploy per
  docs/deploy-dist2-static-build.md once that work lands.

The wasm binary also carries the new lineweight parser fields (lwdisplay,
celweight, layer and entity lineWeight), since it was built from a tree that
already had them. They are additive JSON keys with no consumer in this commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
minsung
2026-08-04 17:05:39 +09:00
co-authored by Claude Opus 5
parent 6f200ef692
commit eec33820a6
5 changed files with 198 additions and 4 deletions
+31
View File
@@ -155,6 +155,37 @@ export function formatEntityProperties(entity: any): FormattedProperties {
break;
}
// MESH (AcDbSubDMesh). dwg-wasm emits flat arrays: vertices [x,y,z,…],
// faceList [n, i0 … i(n-1)] repeated, edges [a,b,…].
case 'MESH': {
const verts: number[] = d.vertices ?? [];
const vCount = d.vertexCount ?? Math.floor(verts.length / 3);
const fCount = d.faceCount ?? 0;
const eCount = Math.floor((d.edges?.length ?? 0) / 2);
const sub = d.subdivisionLevel ?? 0;
geometry.push(['정점 개수 (Vertices)', String(vCount)]);
geometry.push(['면 개수 (Faces)', String(fCount)]);
geometry.push(['모서리 개수 (Edges)', String(eCount)]);
geometry.push(['세분 레벨 (Subdivision)', String(sub)]);
geometry.push(['크리스 혼합 (Blend Crease)', d.blendCrease ? '예 (Yes)' : '아니오 (No)']);
if (vCount > 0) {
let minX = Infinity, minY = Infinity, minZ = Infinity;
let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
for (let i = 0; i + 2 < verts.length; i += 3) {
const x = verts[i], y = verts[i + 1], z = verts[i + 2];
if (x < minX) minX = x; if (x > maxX) maxX = x;
if (y < minY) minY = y; if (y > maxY) maxY = y;
if (z < minZ) minZ = z; if (z > maxZ) maxZ = z;
}
geometry.push(['최소점 (Min)', pt({ x: minX, y: minY, z: minZ })]);
geometry.push(['최대점 (Max)', pt({ x: maxX, y: maxY, z: maxZ })]);
geometry.push(['표고 범위 (Z Range)', `${f3(minZ)} ~ ${f3(maxZ)}`]);
}
break;
}
case 'TEXT':
case 'MTEXT':
case 'ATTRIB': {
Binary file not shown.
+3 -3
View File
@@ -1,8 +1,8 @@
/**
* DWG parser — rust/dwg-wasm wrapper around the acadrust crate (MPL-2.0,
* consumed unmodified; see rust/dwg-wasm). Emits the parseResult shape
* Viewer2D.load() consumes. Lazy-imported so the wasm is only fetched when a
* DWG is actually opened.
* vendored with a local read_mesh patch; see hmwebviewer rust/dwg-wasm). Emits
* the parseResult shape Viewer2D.load() consumes. Lazy-imported so the wasm is
* only fetched when a DWG is actually opened.
*
* History: until 2026-07-10 this module selected between acadrust and
* @horu2day/pure-cad-parser (?dwgparser= toggle). The old parser was removed