template class mola::FixedDenseGrid3D
Overview
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.
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. |
#include <FixedDenseGrid3D.h> template <typename T, size_t SIDE_NUM_BITS, typename inner_coord_t> class FixedDenseGrid3D { public: // fields static constexpr static size_t CELLS_PER_DIM = 1<<SIDE_NUM_BITS; static constexpr static size_t TOTAL_CELL_COUNT = 1<<(3* SIDE_NUM_BITS); // construction FixedDenseGrid3D(); FixedDenseGrid3D(const FixedDenseGrid3D&); FixedDenseGrid3D(FixedDenseGrid3D&&); // methods FixedDenseGrid3D& operator = (const FixedDenseGrid3D&); FixedDenseGrid3D& operator = (FixedDenseGrid3D&&); T& cellByIndex(const index3d_t<inner_coord_t>& idx); const T& cellByIndex(const index3d_t<inner_coord_t>& idx) const; const T* cells() const; T* cells(); };