NearestNeighborHashGrid
Nearest-neighbor search over a point cloud using the turnkey PointCloudHashGrid class – the
uniform-grid counterpart to NearestNeighborBVH, with the same interface, so
switching between the tree and the grid is a one-line type change (see Point clouds).
allNearestNeighbors(k) computes the k nearest neighbors of every point in one batched pass; a
self query excludes the point itself, so the neighbors returned are the nearest other points. The
grid suits near-uniform clouds; for clustered or multi-scale clouds the density-adaptive
PointCloudBVH is the better choice.
The source for this example is at Examples/NearestNeighborHashGrid/main.cpp. See
Building for how to compile it with CMake, GNU Make, or a direct compiler invocation.
cd Examples/NearestNeighborHashGrid
./NearestNeighborHashGrid.ex