class mp2p_icp_filters::PointCloudToVoxelGrid

Overview

Auxiliary data structure: an index of points in a point cloud, organized by their 3D position according to a predefined regular-sized voxel grid.

#include <PointCloudToVoxelGrid.h>

class PointCloudToVoxelGrid
{
public:
    // structs

    struct Impl;
    struct IndicesHash;
    struct Parameters;
    struct indices_t;
    struct voxel_t;

    // fields

    Parameters params;

    // methods

    void setConfiguration(const float voxel_size, bool use_tsl_robin_map);

    void processPointCloud(
        const mrpt::maps::CPointsMap& p,
        const std::size_t first_pt_idx = 0,
        const std::size_t points_to_process = 0
        );

    void mergeFrom(const PointCloudToVoxelGrid& other);
    void mergeFrom(const std::vector<const PointCloudToVoxelGrid*>& others);
    void sortVoxelPointIndices();
    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)

Sets the voxel grid configuration, clearing past contents

void mergeFrom(const PointCloudToVoxelGrid& other)

Appends the contents of another grid into this one, joining the point indices of voxels sharing the same key.

Intended to reassemble the partial grids built by each thread when the input cloud is binned in parallel: without it, one spatial voxel remains split into one fragment per thread.

Both grids must have the same resolution and map type. Point indices are left in arbitrary order; call sortVoxelPointIndices() afterwards to restore the ascending order that sequential binning would have produced.

void mergeFrom(const std::vector<const PointCloudToVoxelGrid*>& others)

Like mergeFrom(), for several grids at once.

Preferred over calling mergeFrom() in a loop: the point indices of all voxels live in one contiguous array, which is laid out just once here instead of once per merged grid.

void sortVoxelPointIndices()

Sorts the point indices of every voxel in ascending order, so that the contents no longer depend on the order in which points were binned.

void clear()

Remove all points and internal data.

size_t size() const

Returns the number of occupied voxels.