Skip to content

perf(core): opt-in fast coincident-point merge for vtkCleanPolyData#84

Closed
akaszynski wants to merge 0 commit into
mainfrom
feat/fast-cleanpoly-port
Closed

perf(core): opt-in fast coincident-point merge for vtkCleanPolyData#84
akaszynski wants to merge 0 commit into
mainfrom
feat/fast-cleanpoly-port

Conversation

@akaszynski

Copy link
Copy Markdown
Member

Summary

Adds an opt-in fast path to vtkCleanPolyData — the filter behind pyvista's .clean() — for the common polys-only exact-merge case, reusing the already-vendored pvaClean.h (MIT) kernel via a new adapter fvtkFastCleanPoly.{h,cxx}.

Stacked on #83 (fast static-clean UG). Base is feat/fast-clean-port; review/merge #81#82#83 first. Net-new here is the vtkCleanPolyData path + cleanpoly_fast op (the kernel + OpenMP CMake come from #83).

Scope (tight, by design)

vtkCleanPolyData has rich semantics (4 cell arrays, degenerate→line→vertex conversion, strip→poly conversion). Rather than reimplement all of it, the fast path engages only for the dominant triangulated-surface case and falls back otherwise. It activates only when fvtk::FastModeEnabled() AND:

  • PointMerging on, effective tolerance 0 (exact merge),
  • input has polys and no verts/lines/strips,
  • no point global-ids (different merge predicate) and no ghost points,
  • float/double points, <2³¹ points,
  • and no cell degeneratesvtkCleanPolyData would convert a collapsed poly to a line/vertex, which the kernel doesn't reproduce, so the adapter detects a repeated id in any output cell and bails to the standard path.

Everything else → standard byte-exact path (default, fast-off).

Faithful-to-stock details

  • Polys kept 1:1 in input order → cell data passes through unchanged.
  • Merged-point data copied from the kernel's canonical source; tolerance-0 merge → coincident points share exact coords, so output coordinates are bit-identical to stock.
  • Output is polys-only (matching stock for polys-only non-degenerate input), so the captured array set matches.

Validation

  • cp312-abi3 manylinux wheel; vtkFiltersCore.abi3.so links libgomp.
  • Engagement proven: under EnableFast() the output point order is reordered vs the standard path (same point set, same counts) → not a silent fallback.
  • Bit-exact gate: 296 passed — the 4 cleanpoly_fast cases match stock points-relaxed; the original byte-exact clean cases still pass.

🤖 Generated with Claude Code

@akaszynski akaszynski changed the base branch from feat/fast-clean-port to main June 20, 2026 10:05
@akaszynski akaszynski closed this Jun 20, 2026
@akaszynski akaszynski reopened this Jun 20, 2026
@akaszynski akaszynski force-pushed the feat/fast-cleanpoly-port branch from 149a8ab to ba6b693 Compare June 20, 2026 10:23
@akaszynski akaszynski closed this Jun 20, 2026
@akaszynski akaszynski reopened this Jun 20, 2026
@akaszynski akaszynski closed this Jun 20, 2026
@akaszynski akaszynski force-pushed the feat/fast-cleanpoly-port branch from ba6b693 to 89ebe2a Compare June 20, 2026 11:27
@akaszynski

Copy link
Copy Markdown
Member Author

Merged to main via fast-forward (89ebe2a). Live on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant