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). More...
 
template<class VoxelT >
static void fromJson (const nlohmann::json &j, VoxelGrid< VoxelT > &grid, const VoxelAttributeSetterMap< VoxelT > &attributeMap)
 Deserialize a voxel grid from JSON. More...
 
template<class VoxelT >
static VoxelGrid< VoxelT > read (const std::string &filename, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from file. More...
 
template<class VoxelT >
static void read (const std::string &filename, VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from file. More...
 
template<class VoxelT >
static VoxelGrid< VoxelT > read (std::istream &is, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from is. More...
 
template<class VoxelT >
static void read (std::istream &is, VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Read a voxel grid from is. More...
 
static nlohmann::json readJson (const std::string &filename)
 Read JSON from file. More...
 
static nlohmann::json readJson (std::istream &is)
 Read JSON json is. More...
 
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). More...
 
template<class VoxelT >
static nlohmann::json toJson (const VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Serialize a voxel grid to JSON. More...
 
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). More...
 
template<class VoxelT >
static void toJson (nlohmann::json &j, const VoxelGrid< VoxelT > &grid, const VoxelAttributeGetterMap< VoxelT > &attributeMap)
 Serialize a voxel grid to JSON. More...
 
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. More...
 
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. More...
 
static void writeJson (const std::string &filename, const nlohmann::json &j, int indent=-1, char indentChar=' ')
 Write JSON json to file. More...
 
static void writeJson (std::ostream &os, const nlohmann::json &j, int indent=-1, char indentChar=' ')
 Write JSON json to os. More...
 

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 100 of file JsonIO.h.

Member Function Documentation

◆ fromJson() [1/2]

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 330 of file JsonIO.h.

+ Here is the call graph for this function:

◆ fromJson() [2/2]

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

Deserialize a voxel grid from JSON.

Definition at line 306 of file JsonIO.h.

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

◆ read() [1/4]

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

Read a voxel grid from file.

Definition at line 229 of file JsonIO.h.

+ Here is the call graph for this function:

◆ read() [2/4]

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

Read a voxel grid from file.

Definition at line 133 of file JsonIO.h.

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

◆ read() [3/4]

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

Read a voxel grid from is.

Definition at line 239 of file JsonIO.h.

+ Here is the call graph for this function:

◆ read() [4/4]

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

Read a voxel grid from is.

Definition at line 149 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 23 of file JsonIO.cpp.

+ 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 29 of file JsonIO.cpp.

◆ toJson() [1/4]

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 297 of file JsonIO.h.

+ Here is the call graph for this function:

◆ toJson() [2/4]

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

Serialize a voxel grid to JSON.

Definition at line 249 of file JsonIO.h.

+ Here is the call graph for this function:

◆ toJson() [3/4]

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 287 of file JsonIO.h.

+ Here is the call graph for this function:

◆ toJson() [4/4]

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

Serialize a voxel grid to JSON.

Definition at line 259 of file JsonIO.h.

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

◆ write() [1/2]

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 108 of file JsonIO.h.

+ Here is the call graph for this function:

◆ write() [2/2]

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 119 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 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 16 of file JsonIO.cpp.


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