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