Template Class FixedDenseGrid3D

Class Documentation

template<typename T, size_t SIDE_NUM_BITS, typename inner_coord_t>
class FixedDenseGrid3D

A dense 3D grid of NxNxN cells with N = 2^SIDE_NUM_BITS.

All cells are allocated contiguously via calloc (zero-initialized), which is faster than new[] for large arrays because the OS can provide zero-filled pages without actually writing them. For this reason, T must be trivially copyable (enforced by static_assert).

Cell storage order is X-major: cells_[cx + cy*N + cz*N*N]. The bit-shift arithmetic in cellByIndex() exploits the power-of-two side length to replace multiplications with shifts.

This is an internal building block for mola::SparseVoxelPointCloud, where it serves as the dense inner grid inside each sparse outer block.

Template Parameters:
  • T – Cell type. Must be trivially copyable.

  • SIDE_NUM_BITS – log₂ of the number of cells per dimension (e.g. 5 → 32³).

  • inner_coord_t – Integer type for the index coordinates (e.g. uint32_t).

Public Functions

inline FixedDenseGrid3D()
inline ~FixedDenseGrid3D()
FixedDenseGrid3D(const FixedDenseGrid3D&) = default
FixedDenseGrid3D &operator=(const FixedDenseGrid3D&) = default
FixedDenseGrid3D(FixedDenseGrid3D&&) = default
FixedDenseGrid3D &operator=(FixedDenseGrid3D&&) = default
inline T &cellByIndex(const index3d_t<inner_coord_t> &idx)
inline const T &cellByIndex(const index3d_t<inner_coord_t> &idx) const
inline const T *cells() const
inline T *cells()

Public Static Attributes

static constexpr size_t CELLS_PER_DIM = 1 << SIDE_NUM_BITS
static constexpr size_t TOTAL_CELL_COUNT = 1 << (3 * SIDE_NUM_BITS)