6#include <SimoxUtility/json/json.hpp>
46 bool _isOccupied =
true;
104 void writeJson(
const std::filesystem::path& file)
const;
108 void readJson(
const std::filesystem::path& file);
Voxel grid storing the number of points per label in each voxel.
Voxel grid storing the number of points per label in each voxel.
std::set< Label > getUniqueLabels() const
Get the set of unique labels in the grid.
static VoxelGrid fromLabelDensity(const LabelDensity::VoxelGrid &density)
Make a label occupancy grid from the given density grid.
void setByLabelDensity(const LabelDensity::VoxelGrid &density, bool adoptStructure=false)
Set the voxels by selecting the label with most points for each voxel.
void writeJson(std::ostream &os) const
Write this voxel grid to JSON.
static const std::string JSON_VOXEL_ARRAY_NAME
Name of the single voxel array in JSON.
VoxelGrid()
Construct a voxel grid with 0 voxels of size 1.0.
void readJson(std::istream &is)
Read this voxel grid from JSON.
A voxel storing whether it is occupied or free and the object label it is occupied by.
void setFree()
Set the voxel to free, i.e. unoccupied.
Voxel()
Construct an unoccupied voxel.
bool isOccupied() const
Indicate whether this voxel is occupied.
Label getLabel() const
Get the label. Voxel must be occupied.
bool isFree() const
Indicate whether this voxel is free (i.e. it is not occupied).
void setOccupied(Label label)
Set the voxel to occupied and set its label.
A 3D grid of voxels of type _VoxelT.
void to_json(nlohmann::json &json, const Voxel &voxel)
Set json to the voxel's label if occupied, and to -1 if free.
void from_json(const nlohmann::json &json, Voxel &voxel)
Set this voxel free, if json is < 0.
uint32_t Label
Type of an object label.
voxelgrid::VoxelGrid< VoxelT > VoxelGrid