class mp2p_icp_filters::PointCloudToVoxelGridAverage
Overview
Like PointCloudToVoxelGrid, but for the decimation methods that only need a summary of each voxel: its point count, the average of its points, and optionally the point closest to that average.
PointCloudToVoxelGrid has to keep the index list of every voxel, which costs a second hashed pass over the cloud, a relayout of the whole index array, and a random-access gather of x/y/z when those lists are walked. None of that is needed here: one hashed pass accumulates the sums, and a second linear pass (hash-free, since the first pass records the voxel of each point) finds the closest point to the resulting average. Both passes read the coordinate buffers sequentially.
Results are identical to summarizing PointCloudToVoxelGrid ‘s index lists, including floating-point rounding: the per-voxel sum is accumulated in the same ascending point order.
#include <PointCloudToVoxelGridAverage.h> class PointCloudToVoxelGridAverage { public: // structs struct Impl; struct IndicesHash; struct indices_t; struct voxel_t; // methods void setConfiguration(const float voxel_size, bool use_tsl_robin_map = true); void processPointCloud(const mrpt::maps::CPointsMap& p, bool findClosestToAverage); void clear(); int32_t coord2idx(float xyz) const; void visit_voxels(const std::function<void(const indices_t idx, const voxel_t&vxl)>& userCode) const; size_t size() const; };
Methods
void setConfiguration(const float voxel_size, bool use_tsl_robin_map = true)
Changes the voxel settings, clearing past contents
void processPointCloud( const mrpt::maps::CPointsMap& p, bool findClosestToAverage )
Bins one cloud and summarizes each voxel.
Parameters:
findClosestToAverage |
If false, voxel_t::closestToAverageIdx is left undefined and the second pass is skipped altogether. |
void clear()
Remove all points and internal data.
size_t size() const
Returns the number of occupied voxels.