optoctreeparser
Loading...
Searching...
No Matches
optoctreeparser::Parser Class Reference

Parser to parse optoctree. More...

#include <parser/parser.hpp>

Static Public Member Functions

static OptocRoot parse_optoctree_batch (const OptocTreeView &optoctree)
 Parses optoctree from its binary representation.
 
static OptocTreeView pack_optoctree_batch (const OptocRoot &batch)
 Packs OptocRoot into binary representation.
 
static OptocPatchRoot parse_optoctreepatch (const OptocTreeView &optoctree)
 Parses optoctreepatch from its binary representation.
 
static OptocTreeView pack_optoctreepatch (const OptocPatchRoot &patch)
 Packs OptocPatchRoot into binary representation.
 

Detailed Description

Parser to parse optoctree.

Example usage

Let's assume that the optoctree bytes are as follows:

0x04 0x00 0x00 0x00
0x02 0x00 0x25 0x80
0x02 0x00 0x00 0x7E
0x00 0x00 ... (0x0 2*124 times to fill trees)

Explanation:

// ---- Version (int32 Little endian = 4) ----
0x04 0x00 0x00 0x00
// ---- Count of nodes (uint16 Little endian = 2) ----
0x02, 0x00,
// ---- Node 0 ----
0x25, // material type = 37
0x80, // signed distance = 128
0x02, 0x00, // first child_node = 2
// ---- Node 1 ----
0x00, // material type = 0
0x7E, // signed distance = 126
0x00, 0x00 // first child_node = 0

Using this code:

OptocRoot batch = Parser::parse(Your OptocTreeView here);
std::vector< byte > OptocTreeView
Definition base_struct.hpp:16
Root of optoctree file.
Definition base_struct.hpp:72

You will get the following batch structure:

└── version = 4
trees[0]
└── node_count = 2
nodes[0] = { material_type=37, signed_distance=128, first_child_node=2 }
nodes[1] = { material_type=0, signed_distance=126, first_child_node=0 }
Note
OptocTreeView is just std::vector<byte>. This is necessary for representing OptocTree bytes. Use Reader::optoctreeview_from_file to read bytes from file

Member Function Documentation

◆ pack_optoctree_batch()

static OptocTreeView optoctreeparser::Parser::pack_optoctree_batch ( const OptocRoot batch)
static

Packs OptocRoot into binary representation.

Parameters
batchOptocBatch
Returns
OptocTreeView with binary representation

◆ pack_optoctreepatch()

static OptocTreeView optoctreeparser::Parser::pack_optoctreepatch ( const OptocPatchRoot patch)
static

Packs OptocPatchRoot into binary representation.

Parameters
patchOptocPatchRoot
Returns
OptocTreeView with binary representation

◆ parse_optoctree_batch()

static OptocRoot optoctreeparser::Parser::parse_optoctree_batch ( const OptocTreeView optoctree)
static

Parses optoctree from its binary representation.

Parameters
optoctreeByte representation of optoctree
Returns
Parsed OptocRoot
See also
OptocTreeView

◆ parse_optoctreepatch()

static OptocPatchRoot optoctreeparser::Parser::parse_optoctreepatch ( const OptocTreeView optoctree)
static

Parses optoctreepatch from its binary representation.

Parameters
optoctreeByte representation of optoctreepatch
Returns
Parsed OptocPatchRoot
See also
OptocTreeView

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