NanoVDB: CUDA connected-components labeling for ValueOnIndex grids - #2261
Draft
sifakis wants to merge 2 commits into
Draft
NanoVDB: CUDA connected-components labeling for ValueOnIndex grids#2261sifakis wants to merge 2 commits into
sifakis wants to merge 2 commits into
Conversation
Add nanovdb::tools::cuda::ConnectedComponents, which labels the active voxels
of a NanoVDB ValueOnIndex grid by 6-connectivity: two active voxels share a
label iff they are connected through a path of adjacent active voxels. The
public getVoxelLabelsAndCount() returns a per-active-voxel dense component id
in [0,N) plus the component count N.
The implementation is hierarchical:
- per-leaf Shiloach-Vishkin union-find in shared memory (one block per leaf),
yielding each leaf-local component's voxel Mask<3> and six face bitmasks;
- cross-leaf edge detection by intersecting touching face masks over +X/+Y/+Z
neighbours;
- a global lock-free union-find over the resulting component graph.
Also add the ex_connected_components_cuda example (rasterize an .obj to a
narrow band via MeshToGrid, drop the sqrt(3)/2-voxel surface shell via
PruneGrid, then label; a CPU union-find oracle verifies the result) and a
ConnectedComponentsMultiSphere unit test.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Efty Sifakis <esifakis@nvidia.com>
…-voxels Accept one or more .obj files (concatenated into a single mesh) and add a --discard-surface-voxels switch: by default label the full narrow band (one component per closed surface), or prune the sqrt(3)/2-voxel barrier shell first when the switch is given. --voxel-size / --band-width replace the old positional args. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: JaeHyun Lee <jaehlee@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
nanovdb::tools::cuda::ConnectedComponents— a CUDA connected-components labeling of theactive voxels of a NanoVDB
ValueOnIndexgrid (6-connectivity). Two active voxels share a labeliff they are connected through a path of adjacent active voxels. The public
getVoxelLabelsAndCount()returns a per-active-voxel dense component id in[0, N)plus thecomponent count
N.Algorithm
Hierarchical, exploiting the 8³ leaf structure:
leaf-local component's voxel
Mask<3>and six face bitmasks.neighbours (each undirected boundary visited once).
class's minimum slot, so the result is order-independent.
Also included
ex_connected_components_cuda— rasterizes an.objto a narrow band (MeshToGrid), drops the√3/2-voxel surface shell (
PruneGrid), then labels; a CPU union-find oracle independentlyverifies the GPU component count and per-voxel partition.
ConnectedComponentsMultiSphereunit test (analytic ground truth: N separated spheres → 2Nshells; overlapping pair → 2).
pendingchanges/entry.Notes
MeshToGrid,PruneGrid,voxelsToGrid) + CUB;no new third-party dependencies, no OpenVDB requirement for the example.
master.Opening as a draft to run CI and for review.
🤖 Generated with Claude Code