Add vtkSurfaceNetsAtlas

vtkSurfaceNetsAtlas is a new filter which consumes the polygonal output of any SurfaceNets filter (vtkSurfaceNets2D, vtkSurfaceNets3D, or vtkGeneralizedSurfaceNets3D) and exposes it as a queryable label atlas.

The atlas is built once per input mesh change (gated on the input vtkPolyData MTime) and then reused for subsequent queries without re-running surface extraction. This makes iterative workflows (e.g. interactively toggling label visibility in a viewer) inexpensive.

Key capabilities:

  • Produces a vtkPartitionedDataSetCollection organized by a vtkDataAssembly into:
    • Regions: one partitioned dataset per label.
    • Patches (optional): one partitioned dataset per adjacent label pair.
  • Each output partition carries identifying arrays so downstream consumers can work without the assembly. The scalar type of "BoundaryLabels" matches the upstream filter's "BoundaryLabels" input array type.
    • Region cell data: "BoundaryLabels" (2-component) — one tuple per cell; Label0 is always the region's own label so normals point outward. "BoundaryLabels" is the active scalar. Also "Label" (vtkIdType, constant) and "LID" (int, constant) — same value for every cell, backed by vtkConstantArray (O(1) storage).
    • Region field data: "AdjacentLabels" (vtkIdType[]), "PatchIDs" (int[]) — all neighbouring labels and their patch IDs.
    • Patch cell data: "BoundaryLabels" (2-component) — Label0 < Label1 by label value (background is always Label1 when present). "BoundaryLabels" is the active scalar. Also "PatchID" (int, constant) — same value for every cell, backed by vtkConstantArray (O(1) storage).
    • Patch field data: none.
    • PDC field data: "LIDToLabel" (vtkIdType[]) — the full Label↔️LID mapping; "PatchLIDs" (2-component int) — maps each patch ID to its [LID0, LID1] pair; "PatchLabels" (2-component vtkIdType) — maps each patch ID to its [Label0, Label1] pair. All three are always present regardless of GeneratePatches.
  • Supports query-driven extraction via:
    • ExtractionMode (EXTRACT_ALL / EXTRACT_LABEL_SET): extract all labels or a user-provided label set.
    • OutputStyle + GeneratePatches: the defaults (Boundary + on) produce an exact partition of the upstream SurfaceNets output — Regions carry background-facing cells, Patches carry interior label-to-label cells, and the total cell count equals the upstream output with no duplication. Setting OutputStyle to All emits every cell for each Region regardless, causing interior-interface cells to appear in both adjacent Region partitions.
  • Optional local post-processing to resolve non-manifold points (ResolveNonManifoldPoints). When the input carries a NonManifoldTableIndices point-data array (produced by vtkSurfaceNets3D), only points marked in that array are candidates; otherwise all points are scanned. The array is never present in output partitions.
  • Provides post-Update() inspection APIs for label↔️index mapping and topology queries (presence, adjacency, patch indexing, patch cell counts).

The following changes were made to support vtkSurfaceNetsAtlas:

  • vtkSurfaceNets3D deprecations: OUTPUT_STYLE_BOUNDARY and OUTPUT_STYLE_SELECTED, along with the associated SelectedLabels API, are deprecated in VTK 9.7 in favor of using vtkSurfaceNetsAtlas downstream. For backward compatibility, these code paths now delegate their filtering behavior to a vtkSurfaceNetsAtlas instance internally and merge the per-label partitions back into a single vtkPolyData using vtkAppendPolyData.

  • vtkGeneralizedSurfaceNets3D dispatch: now dispatches over the concrete scalar type of the region-ids input array (via vtkArrayDispatch) instead of requiring vtkIntArray or silently converting to one. Any integer array type (vtkShortArray, vtkIntArray, vtkLongArray, etc.) is handled natively without a copy.

  • Consistent "BoundaryLabels" convention: vtkSurfaceNets2D and vtkGeneralizedSurfaceNets3D were updated to name the boundary-label cell-data array "BoundaryLabels" and to use a consistent 2-tuple ordering (background label last; smaller label first when both are non-background), matching the convention of vtkSurfaceNets3D. vtkGeneralizedSurfaceNets3D also reverses polygon winding together with the label swap to preserve outward-facing normals. These changes are required for vtkSurfaceNetsAtlas to work correctly with their output.

Edited by Spiros Tsalikis

Merge request reports

Loading