to_from_json.cpp
Go to the documentation of this file.
1#include "to_from_json.h"
2
3#include <SimoxUtility/json.h>
4
5namespace visionx::voxelgrid
6{
7
8
9 void
10 to_json(nlohmann::json& json, const VoxelGridStructure& structure)
11 {
12 json["gridSize"] = structure.getGridSize();
13 json["voxelSize"] = structure.getVoxelSize();
14 json["origin"] = structure.getOrigin();
15 json["orientation"] = structure.getOrientation();
16 }
17
18 void
19 from_json(const nlohmann::json& json, VoxelGridStructure& structure)
20 {
21 structure.setGridSize(json.at("gridSize").get<Eigen::Vector3i>());
22 structure.setVoxelSize(json.at("voxelSize").get<Eigen::Vector3f>());
23 structure.setOrigin(json.at("origin").get<Eigen::Vector3f>());
24 structure.setOrientation(json.at("orientation").get<Eigen::Quaternionf>());
25 }
26
27
28} // namespace visionx::voxelgrid
Geometric structure of a 3D voxel grid.
Eigen::Vector3f getOrigin() const
Get the grid origin in the world frame (center of voxel [0 0 0]).
void setVoxelSize(float voxelSize)
Set the voxel size for cubic voxels.
void setOrientation(const Eigen::Quaternionf &value)
Set the grid orienation in the world frame.
void setOrigin(const Eigen::Vector3f &value)
Set the grid origin the world frame (center of voxel [0 0 0]).
Eigen::Vector3i getGridSize() const
Get the grid size.
Eigen::Vector3f getVoxelSize() const
Get the voxel size.
void setGridSize(int gridSize)
Set the grid size for a cubic grid.
Eigen::Quaternionf getOrientation() const
Get the grid orienation in the world frame.
Quaternion< float, 0 > Quaternionf
void from_json(const nlohmann::json &json, VoxelGridStructure &structure)
void to_json(nlohmann::json &json, const VoxelGridStructure &structure)