|
NuriKit v0.1.0b2
|
A uniform voxel-grid (cell list) index for 3D point clouds with a fixed neighbor cutoff. More...
#include <nuri/core/geometry.h>
Public Types | |
| using | Points = ConstRef<Matrix3Xd> |
Public Member Functions | |
| VoxelGrid ()=default | |
| VoxelGrid (Points pts, double cutoff) | |
| void | rebuild (Points pts, double cutoff=-1.0) |
| void | find_neighbors_d (const Vector3d &pt, std::vector< int > &idxs, std::vector< double > &distsq) const |
| Find indices of all points within the build-time cutoff of a query point. | |
| void | find_neighbors_grid (const VoxelGrid &grid, std::vector< int > &self, std::vector< int > &other) const |
Find all pairs (i, j) where i is in *this and j is in grid and the distance between the points is within the build-time cutoff of *this. | |
| std::vector< std::vector< int > > | find_neighbors_grid (const VoxelGrid &grid) const |
| Convenience overload returning a per-self adjacency list. | |
| void | find_neighbors_self (std::vector< int > &left, std::vector< int > &right) const |
| Find all non-redundant pairs of neighbors within the build-time cutoff. | |
| const Matrix3Xd & | pts () const |
| The grid-owned, cell-reordered copy of the input coordinates. | |
| double | cutoff () const |
| const Vector3d & | origin () const |
| const Array3i & | dims () const |
| int | num_cells () const |
| const ArrayXi & | cell_offset () const |
| const ArrayXi & | cell_pts () const |
A uniform voxel-grid (cell list) index for 3D point clouds with a fixed neighbor cutoff.
Unlike OCTree, the cutoff distance is baked in at build time and equals the voxel edge length. Neighbor queries therefore only need to scan the 3x3x3 = 27 voxels around each query point. The grid stores its contents in a CSR-style layout:
The grid owns its own copy of the input coordinates, reordered so that points belonging to the same voxel are contiguous in memory. pts() returns this reordered copy, not the original input; the p-th column of pts() corresponds to the original input point cell_pts()[p]. The original point set is not referenced after rebuild() returns, so the caller is free to mutate or destroy it.
| using nuri::VoxelGrid::Points = ConstRef<Matrix3Xd> |
|
default |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
| void nuri::VoxelGrid::find_neighbors_d | ( | const Vector3d & | pt, |
| std::vector< int > & | idxs, | ||
| std::vector< double > & | distsq ) const |
Find indices of all points within the build-time cutoff of a query point.
| pt | The query point. |
| idxs | Output indices into pts() of the matched points. |
| distsq | Output squared distances corresponding to each matched index. |
| std::vector< std::vector< int > > nuri::VoxelGrid::find_neighbors_grid | ( | const VoxelGrid & | grid | ) | const |
Convenience overload returning a per-self adjacency list.
| grid | The other voxel grid; only its point set is used. |
grid whose points are within the cutoff of point i in *this. | void nuri::VoxelGrid::find_neighbors_grid | ( | const VoxelGrid & | grid, |
| std::vector< int > & | self, | ||
| std::vector< int > & | other ) const |
Find all pairs (i, j) where i is in *this and j is in grid and the distance between the points is within the build-time cutoff of *this.
| grid | The other voxel grid; only its point set is used. |
| self | Output indices into *this. |
| other | Output indices into grid. |
| void nuri::VoxelGrid::find_neighbors_self | ( | std::vector< int > & | left, |
| std::vector< int > & | right ) const |
Find all non-redundant pairs of neighbors within the build-time cutoff.
| left | Output indices of the first member of each pair. |
| right | Output indices of the second member of each pair. |
Each pair is reported exactly once with i != j; if (i, j) is emitted then (j, i) will not be. The ordering between left[k] and right[k] is unspecified.
|
inline |
|
inline |
|
inline |
The grid-owned, cell-reordered copy of the input coordinates.
The p-th column corresponds to the original input point at index cell_pts()[p]. Use cell_pts() to translate between the internal layout and the caller's indexing.
|
inline |