to_from_json.cpp
Go to the documentation of this file.
1 #include "to_from_json.h"
2 
3 #include <SimoxUtility/json.h>
4 
5 
6 namespace visionx::voxelgrid
7 {
8 
9 
10  void 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 from_json(const nlohmann::json& json, VoxelGridStructure& structure)
19  {
20  structure.setGridSize(json.at("gridSize").get<Eigen::Vector3i>());
21  structure.setVoxelSize(json.at("voxelSize").get<Eigen::Vector3f>());
22  structure.setOrigin(json.at("origin").get<Eigen::Vector3f>());
23  structure.setOrientation(json.at("orientation").get<Eigen::Quaternionf>());
24  }
25 
26 
27 }
visionx::voxelgrid::to_json
void to_json(nlohmann::json &json, const VoxelGridStructure &structure)
Definition: to_from_json.cpp:10
visionx::voxelgrid::VoxelGridStructure::getVoxelSize
Eigen::Vector3f getVoxelSize() const
Get the voxel size.
Definition: VoxelGridStructure.cpp:82
visionx::voxelgrid::VoxelGridStructure::setGridSize
void setGridSize(int gridSize)
Set the grid size for a cubic grid.
Definition: VoxelGridStructure.cpp:72
visionx::voxelgrid::VoxelGridStructure::getOrientation
Eigen::Quaternionf getOrientation() const
Get the grid orienation in the world frame.
Definition: VoxelGridStructure.cpp:212
visionx::voxelgrid
Definition: exceptions.cpp:8
visionx::voxelgrid::VoxelGridStructure
Geometric structure of a 3D voxel grid.
Definition: VoxelGridStructure.h:96
visionx::voxelgrid::from_json
void from_json(const nlohmann::json &json, VoxelGridStructure &structure)
Definition: to_from_json.cpp:18
visionx::voxelgrid::VoxelGridStructure::getGridSize
Eigen::Vector3i getGridSize() const
Get the grid size.
Definition: VoxelGridStructure.cpp:67
visionx::voxelgrid::VoxelGridStructure::setOrigin
void setOrigin(const Eigen::Vector3f &value)
Set the grid origin the world frame (center of voxel [0 0 0]).
Definition: VoxelGridStructure.cpp:207
visionx::voxelgrid::VoxelGridStructure::setOrientation
void setOrientation(const Eigen::Quaternionf &value)
Set the grid orienation in the world frame.
Definition: VoxelGridStructure.cpp:217
armarx::Quaternion< float, 0 >
visionx::voxelgrid::VoxelGridStructure::setVoxelSize
void setVoxelSize(float voxelSize)
Set the voxel size for cubic voxels.
Definition: VoxelGridStructure.cpp:87
to_from_json.h
visionx::voxelgrid::VoxelGridStructure::getOrigin
Eigen::Vector3f getOrigin() const
Get the grid origin in the world frame (center of voxel [0 0 0]).
Definition: VoxelGridStructure.cpp:202