40#ifndef PCL_RECOGNITION_VOXEL_STRUCTURE_HPP_
41#define PCL_RECOGNITION_VOXEL_STRUCTURE_HPP_
50template<
class T,
typename REAL>
inline void
70 voxels_ =
new T[total_num_of_voxels_];
78 min_center_[0] = bounds_[0] +
static_cast<REAL> (0.5)*spacing_[0];
79 min_center_[1] = bounds_[2] +
static_cast<REAL> (0.5)*spacing_[1];
80 min_center_[2] = bounds_[4] +
static_cast<REAL> (0.5)*spacing_[2];
84template<
class T,
typename REAL>
inline T*
87 if ( p[0] < bounds_[0] || p[0] >= bounds_[1] || p[1] < bounds_[2] || p[1] >= bounds_[3] || p[2] < bounds_[4] || p[2] >= bounds_[5] )
90 int x =
static_cast<int> ((p[0] - bounds_[0])/spacing_[0]);
91 int y =
static_cast<int> ((p[1] - bounds_[2])/spacing_[1]);
92 int z =
static_cast<int> ((p[2] - bounds_[4])/spacing_[2]);
94 return &voxels_[z*num_of_voxels_xy_plane_ + y*num_of_voxels_[0] + x];
98template<
class T,
typename REAL>
inline T*
105 return &voxels_[z*num_of_voxels_xy_plane_ + y*num_of_voxels_[0] + x];
109template<
class T,
typename REAL>
inline int
112 if ( p[0] < bounds_[0] || p[0] >= bounds_[1] || p[1] < bounds_[2] || p[1] >= bounds_[3] || p[2] < bounds_[4] || p[2] >= bounds_[5] )
115 const int x =
static_cast<int> ((p[0] - bounds_[0])/spacing_[0]);
116 const int y =
static_cast<int> ((p[1] - bounds_[2])/spacing_[1]);
117 const int z =
static_cast<int> ((p[2] - bounds_[4])/spacing_[2]);
Iterator class for point clouds with or without given indices.
void build(const REAL bounds[6], int num_of_voxels[3])
Call this method before using an instance of this class.
T * getVoxel(const REAL p[3])
Returns a pointer to the voxel which contains p or NULL if p is not inside the structure.
int getNeighbors(const REAL *p, T **neighs) const
Saves pointers to the voxels which are neighbors of the voxels which contains 'p'.