template struct mola::index3d_t

Overview

Discrete 3D voxel index: a plain (cx, cy, cz) triple of integer coordinates.

Suitable for both std::map (using index3d_hash as comparator) and std::unordered_map / tsl::robin_map (using index3d_hash as hash).

The default coordinate type is int32_t, which covers roughly ±2×10⁹ voxels per axis. Use uint32_t for inner (non-negative) indices in dense grids.

See also:

index3d_hash for the associated hash / comparator functor.

#include <index3d_t.h>

template <typename cell_coord_t = int32_t>
struct index3d_t
{
    // fields

    cell_coord_t cx = 0;
    cell_coord_t cy = 0;
    cell_coord_t cz = 0;

    // construction

    index3d_t();

    index3d_t(
        cell_coord_t Cx,
        cell_coord_t Cy,
        cell_coord_t Cz
        );

    // methods

    bool operator == (const index3d_t<cell_coord_t>& o) const;
    bool operator != (const index3d_t<cell_coord_t>& o) const;
    index3d_t operator + (const index3d_t& o) const;
    index3d_t operator - (const index3d_t& o) const;
};