template class Bonxai::VoxelGrid
#include <mrpt/maps/bonxai/bonxai.hpp> template <typename DataT> class VoxelGrid { public: // typedefs typedef Grid<DataT> LeafGrid; typedef Grid<std::shared_ptr<LeafGrid>> InnerGrid; typedef std::unordered_map<CoordT, InnerGrid> RootMap; // classes class Accessor; // fields const uint32_t INNER_BITS; const uint32_t LEAF_BITS; const uint32_t Log2N; const double resolution; const double inv_resolution; const uint32_t INNER_MASK; const uint32_t LEAF_MASK; RootMap root_map; // construction VoxelGrid(double voxel_size, uint8_t inner_bits = 2, uint8_t leaf_bits = 3); // methods size_t memUsage() const; size_t activeCellsCount() const; CoordT posToCoord(double x, double y, double z); CoordT posToCoord(const Point3D& pos); Point3D coordToPos(const CoordT& coord); template <class VisitorFunction> void forEachCell(VisitorFunction func); Accessor createAccessor(); CoordT getRootKey(const CoordT& coord); CoordT getInnerKey(const CoordT& coord); uint32_t getInnerIndex(const CoordT& coord); uint32_t getLeafIndex(const CoordT& coord); };
Construction
VoxelGrid(double voxel_size, uint8_t inner_bits = 2, uint8_t leaf_bits = 3)
VoxelGrid constructor.
Parameters:
voxel_size |
dimension of the voxel. Used to convert between Point3D and CoordT |
Methods
size_t memUsage() const
getMemoryUsage returns the amount of bytes used by this data structure
size_t activeCellsCount() const
Return the total number of active cells.
CoordT posToCoord(double x, double y, double z)
posToCoord is used to convert real coordinates to CoordT indexes.
CoordT posToCoord(const Point3D& pos)
posToCoord is used to convert real coordinates to CoordT indexes.
Point3D coordToPos(const CoordT& coord)
coordToPos converts CoordT indexes to Point3D.
template <class VisitorFunction> void forEachCell(VisitorFunction func)
forEachCell apply a function of type:
void(DataT*, const CoordT&)
to each active element of the grid.