Go to the documentation of this file.
66 if (json.get<
int>() < 0)
90 for (
const Voxel& voxel : *
this)
113 "Provided density grid has different structure, but adoptStructure is false.");
117 for (std::size_t i = 0; i <
numVoxels(); ++i)
static void fromJson(const nlohmann::json &j, VoxelGrid< VoxelT > &grid, const VoxelAttributeSetterMap< VoxelT > &attributeMap)
Deserialize a voxel grid from JSON.
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).
static void toJson(nlohmann::json &j, const VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
Serialize a voxel grid to JSON.
Label getMaxLabel() const
Get the label with most points.
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.
void resetStructure(const VoxelGridStructure &structure)
Set the voxel grid structure and reset voxel data.
Voxel grid storing the number of points per label in each voxel.
Voxel grid storing the number of points per label in each voxel.
static void writeJson(const std::string &filename, const nlohmann::json &j, int indent=-1, char indentChar=' ')
Write JSON json to file.
VoxelGridStructure getStructure() const
Get the voxel grid structure.
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
VoxelT & getVoxel(std::size_t index)
Get the voxel with the given index.
bool isFree() const
Indicate whether this voxel is free, i.e. it contains no points.
uint32_t Label
Type of an object label.
std::size_t numVoxels() const
Get the number of voxels in the grid.
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 nlohmann::json readJson(const std::string &filename)
Read JSON from file.
static const std::string JSON_VOXEL_ARRAY_NAME
Name of the single voxel array in JSON.
Map of labels (object IDs) to number of points.
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.
A voxel storing whether it is occupied or free and the object label it is occupied by.
Indicates that a voxel grid structure should have matched another one, but did not.
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.