feat(render): draw a proxy entity's cached preview instead of nothing
An entity from an application we have no reader for — e.g. an Autodesk Raster
Design embedded raster image — now arrives as `Unknown` (acadrust 769741d) and
rendered as nothing at all, so the drawing silently lost it with no hint that
anything was there.
Such entities almost always ship proxy graphics: the vector preview their author
cached for precisely this case, and what AutoCAD itself falls back to when the
object enabler is absent. Decode it and draw it, so the entity holds its real
place and size.
The record grammar has no reference implementation to copy — LibreDWG keeps the
blob raw ("see par 29") and ACadSharp stores the bytes without parsing them — so
rather than infer a general decoder from one sample, `proxy_graphics` accepts a
single polyline record and only when the blob matches it byte-for-byte: sizes
must agree, the points must consume every remaining byte, and coordinates must
be finite. Anything else returns None and draws nothing, exactly as before, so
a file this does not model cannot regress or sprout invented geometry.
Verified on a Raster Design drawing: its 140-byte preview decodes with 0 bytes
left over to the image frame (1192.149 x 877.824, closed), matching what ODA
reports for the same entity. Unit-tested against that real blob.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3bd5453c3b
commit
f720e40ba1
4 changed files with 134 additions and 1 deletions
|
|
@ -228,6 +228,27 @@ pub(crate) fn tessellate_entity(
|
|||
let pattern_length = pattern_length * pslt_factor;
|
||||
let pattern = pattern.map(|v| v * pslt_factor);
|
||||
|
||||
// ── Proxy entity: draw its cached preview ───────────────────────────────
|
||||
//
|
||||
// An entity from an application we have no reader for (e.g. an Autodesk
|
||||
// Raster Design embedded raster image) arrives as `Unknown`. Its own data is
|
||||
// a private format we cannot decode — but it usually ships a proxy-graphics
|
||||
// blob, the vector preview its author cached for exactly this case. AutoCAD
|
||||
// draws that when the object enabler is missing; draw it too, so the entity
|
||||
// occupies its real place instead of silently disappearing.
|
||||
if let EntityType::Unknown(_) = e {
|
||||
if let Some(blob) = e.common().graphic_data.as_ref() {
|
||||
if let Some(p) = convert::proxy_graphics::decode_polyline(blob) {
|
||||
let (pts, pts_low) = convert::tessellate::points_to_ds(p.points);
|
||||
let mut w = WireModel::solid(h.value().to_string(), pts, entity_color, sel);
|
||||
w.points_low = pts_low;
|
||||
w.line_weight_px = line_weight_px;
|
||||
w.aci = aci;
|
||||
return vec![w];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Dimension baked-block fast path ─────────────────────────────────────
|
||||
//
|
||||
// AutoCAD bakes each dimension's final geometry (extension lines, dim
|
||||
|
|
|
|||
Loading…
Reference in a new issue