JsonIO Class Reference

Class to store voxel grids in a vectorized JSON format. More...

#include <VisionX/libraries/VoxelGridCore/io/JsonIO.h>

Static Public Member Functions

template<class VoxelT>
static void fromJson (const nlohmann::json &j, VoxelGrid< VoxelT > &grid, const std::string &voxelArrayName="voxels")
 Deserialize a voxel grid from JSON with plain voxel array (with name voxelArrayName).
 
template<class VoxelT>
static void fromJson (const nlohmann::json &j, VoxelGrid< VoxelT > &grid, const VoxelAttributeSetterMap< VoxelT > &attributeMap)
 Deserialize a voxel grid from JSON.
 
template<class VoxelT>
static VoxelGrid< VoxelT > read (const std::string &filename, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from file.
 
template<class VoxelT>
static void read (const std::string &filename, VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from file.
 
template<class VoxelT>
static VoxelGrid< VoxelT > read (std::istream &is, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from is.
 
template<class VoxelT>
static void read (std::istream &is, VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from is.
 
static nlohmann::json readJson (const std::string &filename)
 Read JSON from file.
 
static nlohmann::json readJson (std::istream &is)
 Read JSON json is.
 
template<class VoxelT>
static nlohmann::json toJson (const VoxelGrid< VoxelT > &grid, const std::string &voxelArrayName="voxels")
 Serialize a voxel grid to JSON with plain voxel array (with name voxelArrayName).
 
template<class VoxelT>
static nlohmann::json toJson (const VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Serialize a voxel grid to JSON.
 
template<class VoxelT>
static void toJson (nlohmann::json &j, const VoxelGrid< VoxelT > &grid, const std::string &voxelArrayName="voxels")
 Serialize a voxel grid to JSON with plain voxel array (with name voxelArrayName).
 
template<class VoxelT>
static void toJson (nlohmann::json &j, const VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Serialize a voxel grid to JSON.
 
template<class VoxelT>
static void write (const std::string &filename, const VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap, int indent=-1, char indentChar=' ')
 Write a voxel grid to file.
 
template<class VoxelT>
static void write (std::ostream &os, const VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap, int indent=-1, char indentChar=' ')
 Write a voxel grid to os.
 
static void writeJson (const std::string &filename, const nlohmann::json &j, int indent=-1, char indentChar=' ')
 Write JSON json to file.
 
static void writeJson (std::ostream &os, const nlohmann::json &j, int indent=-1, char indentChar=' ')
 Write JSON json to os.
 

Detailed Description

Class to store voxel grids in a vectorized JSON format.

The methods in class can be used to store voxel grids in JSON format. A voxel grid essentially consists of its structure (grid and voxel size, pose) and its voxel data.

In the format produced by this class, there is one top-level JSON element for each voxel attribute to store. Each of this elements is an array storing the attribute value of each voxel.

For example, if a voxel has two attributes, int foo and float bar, the produces JSON object would look like this:

{
"structure: { ... },
"foo": [0 1 1 2 ... -1 0],
"bar": [0.0, 1.0, 1.1, ... , 0.0, -1.0]
}

This is done to reduce the redundancy of JSON for a large number of voxels.

Definition at line 92 of file JsonIO.h.

Member Function Documentation

◆ fromJson() [1/2]

template<class VoxelT>
void fromJson ( const nlohmann::json & j,
VoxelGrid< VoxelT > & grid,
const std::string & voxelArrayName = "voxels" )
static

Deserialize a voxel grid from JSON with plain voxel array (with name voxelArrayName).

VoxelT must provide an implementation of from_json().

Definition at line 317 of file JsonIO.h.

+ Here is the call graph for this function:

◆ fromJson() [2/2]

template<class VoxelT>
void fromJson ( const nlohmann::json & j,
VoxelGrid< VoxelT > & grid,
const VoxelAttributeSetterMap< VoxelT > & attributeMap )
static

Deserialize a voxel grid from JSON.

Definition at line 294 of file JsonIO.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read() [1/4]

template<class VoxelT>
VoxelGrid< VoxelT > read ( const std::string & filename,
const VoxelAttributeGetterMap< VoxelT > & attributeMap )
static

Read a voxel grid from file.

Definition at line 217 of file JsonIO.h.

+ Here is the call graph for this function:

◆ read() [2/4]

template<class VoxelT>
static void read ( const std::string & filename,
VoxelGrid< VoxelT > & grid,
const VoxelAttributeGetterMap< VoxelT > & attributeMap )
inlinestatic

Read a voxel grid from file.

Definition at line 126 of file JsonIO.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read() [3/4]

template<class VoxelT>
VoxelGrid< VoxelT > read ( std::istream & is,
const VoxelAttributeGetterMap< VoxelT > & attributeMap )
static

Read a voxel grid from is.

Definition at line 226 of file JsonIO.h.

+ Here is the call graph for this function:

◆ read() [4/4]

template<class VoxelT>
static void read ( std::istream & is,
VoxelGrid< VoxelT > & grid,
const VoxelAttributeGetterMap< VoxelT > & attributeMap )
inlinestatic

Read a voxel grid from is.

Definition at line 141 of file JsonIO.h.

+ Here is the call graph for this function:

◆ readJson() [1/2]

nlohmann::json readJson ( const std::string & filename)
static

Read JSON from file.

Definition at line 24 of file JsonIO.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readJson() [2/2]

nlohmann::json readJson ( std::istream & is)
static

Read JSON json is.

Definition at line 31 of file JsonIO.cpp.

◆ toJson() [1/4]

template<class VoxelT>
nlohmann::json toJson ( const VoxelGrid< VoxelT > & grid,
const std::string & voxelArrayName = "voxels" )
static

Serialize a voxel grid to JSON with plain voxel array (with name voxelArrayName).

VoxelT must provide an implementation of to_json().

Definition at line 285 of file JsonIO.h.

+ Here is the call graph for this function:

◆ toJson() [2/4]

template<class VoxelT>
nlohmann::json toJson ( const VoxelGrid< VoxelT > & grid,
const VoxelAttributeGetterMap< VoxelT > & attributeMap )
static

Serialize a voxel grid to JSON.

Definition at line 235 of file JsonIO.h.

+ Here is the call graph for this function:

◆ toJson() [3/4]

template<class VoxelT>
void toJson ( nlohmann::json & j,
const VoxelGrid< VoxelT > & grid,
const std::string & voxelArrayName = "voxels" )
static

Serialize a voxel grid to JSON with plain voxel array (with name voxelArrayName).

VoxelT must provide an implementation of to_json().

Definition at line 273 of file JsonIO.h.

+ Here is the call graph for this function:

◆ toJson() [4/4]

template<class VoxelT>
void toJson ( nlohmann::json & j,
const VoxelGrid< VoxelT > & grid,
const VoxelAttributeGetterMap< VoxelT > & attributeMap )
static

Serialize a voxel grid to JSON.

Definition at line 245 of file JsonIO.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write() [1/2]

template<class VoxelT>
static void write ( const std::string & filename,
const VoxelGrid< VoxelT > & grid,
const VoxelAttributeGetterMap< VoxelT > & attributeMap,
int indent = -1,
char indentChar = ' ' )
inlinestatic

Write a voxel grid to file.

Definition at line 100 of file JsonIO.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ write() [2/2]

template<class VoxelT>
static void write ( std::ostream & os,
const VoxelGrid< VoxelT > & grid,
const VoxelAttributeGetterMap< VoxelT > & attributeMap,
int indent = -1,
char indentChar = ' ' )
inlinestatic

Write a voxel grid to os.

Definition at line 112 of file JsonIO.h.

+ Here is the call graph for this function:

◆ writeJson() [1/2]

void writeJson ( const std::string & filename,
const nlohmann::json & j,
int indent = -1,
char indentChar = ' ' )
static

Write JSON json to file.

Definition at line 8 of file JsonIO.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeJson() [2/2]

void writeJson ( std::ostream & os,
const nlohmann::json & j,
int indent = -1,
char indentChar = ' ' )
static

Write JSON json to os.

Definition at line 18 of file JsonIO.cpp.


The documentation for this class was generated from the following files: