cad-editor/examples
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Hakan Seven 416b0d4dc3 fix(quadtree): split() on internal node was orphaning the entire subtree
Symptom: open a non-UTM drawing, most lines/polylines/hatches/etc.
vanish — only ~5% of indexed entities reachable from a huge query
(walking the nodes flat showed all 2975 items present, but recursing
through `node.children` from root reached only 161).

Root cause: when straddler items piled up at an INTERNAL node and the
count exceeded LEAF_CAPACITY, `insert()` re-invoked `split()` on that
node. `split()` allocates four fresh children and assigns them to
`node.children = Some([...])` — overwriting the existing children
pointer and orphaning the entire previous subtree (the descendant
nodes still hold their items; nothing reaches them).

Splitting an internal node is futile anyway: straddlers don't fit
smaller children either. Fix: gate the split on
`children.is_none()` so only leaves split. Internal nodes accumulate
straddlers as a linear-scan list — slower per-query for big strad-
dler counts, but correct.

Adds a regression test (`many_straddlers_dont_orphan_subtree`) that
floods an internal node with straddlers and verifies a huge query
still returns every inserted handle.

Bonus: `examples/dump_index_stats.rs` — standalone tool that loads a
DWG/DXF and dumps per-type counts (indexed / unbounded / top-level /
block-internal) plus a sample of bboxes. Useful for future bug
triage; built and ran cleanly against the file that exposed this.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-17 19:28:57 +03:00
..
dump_index_stats.rs fix(quadtree): split() on internal node was orphaning the entire subtree 2026-05-17 19:28:57 +03:00
find_raster.rs chore: expose lib target + open-path profiling examples 2026-05-13 23:02:54 +03:00
inspect_insert.rs chore: expose lib target + open-path profiling examples 2026-05-13 23:02:54 +03:00
inspect_polyline.rs feat(io): drop parser-garbage entities at load time 2026-05-13 10:00:16 +03:00
inspect_viewports.rs fix(scene): viewport auto-fit fallback + f64-precision projection 2026-05-16 19:32:36 +03:00
time_open.rs chore: expose lib target + open-path profiling examples 2026-05-13 23:02:54 +03:00
xref_states.rs perf(scene): frustum-cull wires using camera view AABB 2026-05-14 13:52:04 +03:00