#include <KDGrid_fwd.hpp>
Search structure over given d-dimensional box with given cell size.
At most one point per cell can be stored. This is often a faster and more memory hungry substitute for KDTree.
Usage example:
Definition at line 29 of file KDGrid_fwd.hpp.
Public Member Functions | |
KDGrid (const vec_t &bot, const vec_t &top, scalar_t cell_size) | |
Construct a search grid from bot to top with given cell_size . More... | |
const vec_t & | bottom () const |
Get bottom bound. More... | |
const vec_t & | top () const |
Get top bound. More... | |
scalar_t | cellSize () const |
Get cell size. More... | |
const Grid< int, dim > & | grid () const |
Get access to underlying grid of point indices. More... | |
const std::vector< vec_t > & | points () const |
Get access to array of stored points. More... | |
const vec_t & | point (int idx) const |
Get point by its sequential index. More... | |
int | size () const |
Get number of points stored in the structure. More... | |
int | insert (const vec_t &p) |
Insert a new point in the structure. More... | |
void | insert (const std::vector< vec_t > &pts) |
Vectorised version of insert. More... | |
bool | existsPointInSphere (const vec_t &p, scalar_t r) |
Check if any point exists in sphere centered at p with radius r . More... | |
Public Types | |
enum | { dim = vec_t::dim } |
Store dimension of the space. More... | |
typedef vec_t | vector_t |
Vector type used. More... | |
typedef vector_t::scalar_t | scalar_t |
Scalar type used. More... | |
Friends | |
template<typename V > | |
std::ostream & | operator<< (std::ostream &os, const KDGrid< V > &search) |
Output some information about the search grid. More... | |
Private Types | |
typedef Grid< int, dim >::IndexArray | IndexArray |
Multi-index type. More... | |
Private Member Functions | |
IndexArray | compute_index (const vec_t &p) |
Compute point multi-index. More... | |
bool | existsPointInSphere (const vec_t &p, scalar_t r, const IndexArray &index) |
Implementation of existsPointInSphere. More... | |
int | insert (const vec_t &p, const IndexArray &index) |
Implementation of insert. More... | |
bool | increment (IndexArray &cur, int span, const IndexArray &ref) |
Increment a dim-ary counter. More... | |
Static Private Member Functions | |
static IndexArray | compute_size (const vec_t &bot, const vec_t &top, scalar_t cell_size) |
Compute the sizes of the rid along each dimension. More... | |
Private Attributes | |
vec_t | bot_ |
Lower bound of the box. More... | |
vec_t | top_ |
Upper bound of the box. More... | |
scalar_t | cell_size_ |
Size of a single cell. More... | |
Grid< int, dim > | grid_ |
Background grid of cells pointing to sequential point indices. More... | |
std::vector< vec_t > | points_ |
List of inserted points. More... | |
anonymous enum |
Store dimension of the space.
Enumerator | |
---|---|
dim | Dimensionality of the space. |
Definition at line 34 of file KDGrid_fwd.hpp.
|
inline |
Construct a search grid from bot
to top
with given cell_size
.
Definition at line 46 of file KDGrid_fwd.hpp.
|
inline |
Get bottom bound.
Definition at line 52 of file KDGrid_fwd.hpp.
|
inline |
Get cell size.
Definition at line 56 of file KDGrid_fwd.hpp.
|
private |
Compute point multi-index.
Definition at line 70 of file KDGrid.hpp.
|
staticprivate |
Compute the sizes of the rid along each dimension.
Definition at line 19 of file KDGrid.hpp.
|
inline |
Check if any point exists in sphere centered at p
with radius r
.
Definition at line 81 of file KDGrid_fwd.hpp.
|
private |
Implementation of existsPointInSphere.
Definition at line 53 of file KDGrid.hpp.
|
inline |
Get access to underlying grid of point indices.
Definition at line 58 of file KDGrid_fwd.hpp.
|
private |
Increment a dim-ary counter.
Definition at line 29 of file KDGrid.hpp.
|
inline |
Vectorised version of insert.
Definition at line 76 of file KDGrid_fwd.hpp.
|
inline |
Insert a new point in the structure.
p | The point to insert. |
Assertion | fails if there is also point in this cell or if the point is out of range. |
Definition at line 73 of file KDGrid_fwd.hpp.
|
private |
Implementation of insert.
Definition at line 42 of file KDGrid.hpp.
|
inline |
Get point by its sequential index.
Definition at line 62 of file KDGrid_fwd.hpp.
|
inline |
Get access to array of stored points.
Definition at line 60 of file KDGrid_fwd.hpp.
|
inline |
Get number of points stored in the structure.
Definition at line 65 of file KDGrid_fwd.hpp.
|
inline |
Get top bound.
Definition at line 54 of file KDGrid_fwd.hpp.
|
friend |
Output some information about the search grid.
|
private |
Lower bound of the box.
Definition at line 37 of file KDGrid_fwd.hpp.
|
private |
Size of a single cell.
Definition at line 39 of file KDGrid_fwd.hpp.
|
private |
Background grid of cells pointing to sequential point indices.
Definition at line 40 of file KDGrid_fwd.hpp.
|
private |
List of inserted points.
Definition at line 41 of file KDGrid_fwd.hpp.
|
private |
Upper bound of the box.
Definition at line 38 of file KDGrid_fwd.hpp.