Helios++
Helios software for LiDAR simulations
|
Class for parsing voxel files. More...
#include <VoxelFileParser.h>
Public Member Functions | |
VoxelFileParser () | |
Build a VoxelFileParser. | |
std::vector< std::shared_ptr< DetailedVoxel > > | parseDetailed (std::string const &path, size_t numHeaderLines=2, bool const exactFormat=true, bool const discardNullPad=false, std::string const separator=" ") |
Parse detailed voxels specified at file located at given path. More... | |
std::vector< DetailedVoxel * > | bruteParseDetailed (std::string const &path, size_t numHeaderLines=2, bool const exactFormat=true, bool const discardNullPad=false, std::string const separator=" ") |
Like parseDetailed but returns a vector a normla pointers instead of shared pointers. More... | |
Protected Member Functions | |
void | loadFile (std::vector< std::string > &lines, std::string const &path) |
Loads the file at given path. More... | |
void | cleanLines (std::vector< std::string > &lines, size_t const numHeaderLines, bool &minCornerXFound, double &minCornerX, bool &minCornerYFound, double &minCornerY, bool &minCornerZFound, double &minCornerZ, bool &maxCornerXFound, double &maxCornerX, bool &maxCornerYFound, double &maxCornerY, bool &maxCornerZFound, double &maxCornerZ, bool &splitXFound, size_t &splitX, bool &splitYFound, size_t &splitY, bool &splitZFound, size_t &splitZ, double &voxelSize, double &maxPad) |
Clean unnecessary lines. More... | |
bool | isBlankLine (std::string const &line) |
Check if the line is a blank line. More... | |
bool | handleSpecLine (std::string const &line, bool &minCornerXFound, double &minCornerX, bool &minCornerYFound, double &minCornerY, bool &minCornerZFound, double &minCornerZ, bool &maxCornerXFound, double &maxCornerX, bool &maxCornerYFound, double &maxCornerY, bool &maxCornerZFound, double &maxCornerZ, bool &splitXFound, size_t &splitX, bool &splitYFound, size_t &splitY, bool &splitZFound, size_t &splitZ, double &voxelSize, double &maxPad) |
Handle line if it is an spec line. Do nothing otherwise. More... | |
void | handleSpec (std::string const &line, bool &minCornerXFound, double &minCornerX, bool &minCornerYFound, double &minCornerY, bool &minCornerZFound, double &minCornerZ, bool &maxCornerXFound, double &maxCornerX, bool &maxCornerYFound, double &maxCornerY, bool &maxCornerZFound, double &maxCornerZ, bool &splitXFound, size_t &splitX, bool &splitYFound, size_t &splitY, bool &splitZFound, size_t &splitZ, double &voxelSize, double &maxPad) |
Assuming received line is a spec line, handle it. More... | |
void | cleanLine (std::string &line) |
Remove unnecessary stuff from received line. More... | |
void | removeHeaderLines (std::vector< std::string > &lines, size_t numHeaderLines) |
Remove header lines. More... | |
void | validateDetailed (bool minCornerXFound, bool minCornerYFound, bool minCornerZFound, bool maxCornerXFound, bool maxCornerYFound, bool maxCornerZFound, bool splitXFound, bool splitYFound, bool splitZFound) |
Check if flags are valid. More... | |
DetailedVoxel * | parseDetailedVoxelLine (std::string &line, std::string const separator, bool const exactFormat, bool const discardNullPad, char const *format1, char const *format2, char const *format3, double minCornerX, double minCornerY, double minCornerZ, double maxCornerX, double maxCornerY, double maxCornerZ, double voxelSize, double voxelHalfSize, double maxPad) |
Parse the DetailedVoxel specified in given line. More... | |
Static Protected Attributes | |
static constexpr size_t | N_BLANK_CHARACTERS = 4 |
Nummber of blank characters. | |
static char const | BLANK_CHARACTERS [N_BLANK_CHARACTERS] = {' ', '\t', '\r', '\n'} |
Characters considered "blank". | |
static constexpr char | SPEC_CHARACTER = '#' |
Character which starts spec lines. | |
Class for parsing voxel files.
Current implementation is based on AMAPVox format
std::vector< DetailedVoxel * > VoxelFileParser::bruteParseDetailed | ( | std::string const & | path, |
size_t | numHeaderLines = 2 , |
||
bool const | exactFormat = true , |
||
bool const | discardNullPad = false , |
||
std::string const | separator = " " |
||
) |
Like parseDetailed but returns a vector a normla pointers instead of shared pointers.
|
protected |
Remove unnecessary stuff from received line.
All starting and ending spaces are removed
line | Line to be cleaned |
|
protected |
Clean unnecessary lines.
lines | Lines that shall be cleaned |
numHeaderLines | Number of header lines to be cleaned |
|
protected |
Assuming received line is a spec line, handle it.
Handling a spec line means received arguments will be modified accordingly to what have been handled.
line | Spec line |
minCornerXFound | Specify if the X coordinate of the minimum corner of the bounding box containing the voxels has been found (true) or not (false) |
minCornerX | X coordinate of the minimum corner of the bounding box containing the voxels. |
minCornerYFound | Specify if the Y coordinate of the minimum corner of the bounding box containing the voxels has been found (true) or not (false) |
minCornerY | Y coordinate of the minimum corner of the bounding box containing the voxels. |
minCornerZFound | Specify if the Z coordinate of the minimum corner of the bounding box containing the voxels has been found (true) or not (false) |
minCornerZ | Z coordinate of the minimum corner of the bounding box containing the voxels. |
maxCornerXFound | Specify if the X coordinate of the maximum corner of the bounding box containing the voxels has been found (true) or not (false) |
maxCornerX | X coordinate of the maximum corner of the bounding box containing the voxels. |
maxCornerYFound | Specify if the Y coordinate of the maximum corner of the bounding box containing the voxels has been found (true) or not (false) |
maxCornerY | Y coordinate of the maximum corner of the bounding box containing the voxels. |
maxCornerZFound | Specify if the Z coordinate of the maximum corner of the bounding box containing the voxels has been found (true) or not (false) |
maxCornerZ | Z coordinate of the maximum corner of the bounding box containing the voxels. |
splitXFound | Specify if the number of voxels along the X axis of the bounding box containing the voxels has been found (true) or not (false) |
splitX | Number of voxels along the X axis of the bounding box containing the voxels |
splitYFound | Specify if the number of voxels along the Y axis of the bounding box containing the voxels has been found (true) or not (false) |
splitY | Number of voxels along the Y axis of the bounding box containing the voxels |
splitZFound | Specify if the number of voxels along the Z axis of the bounding box containing the voxels has been found (true) or not (false) |
splitZ | Number of voxels along the Z axis of the bounding box containing the voxels |
voxelSize | The size for each voxel |
|
protected |
Handle line if it is an spec line. Do nothing otherwise.
Spec lines are so because its first non blank character is #
line | Line to be handled |
|
protected |
Check if the line is a blank line.
Blank lines are those lines which only contain spaces, tabulations, carriage return or new line characters.
line | Line to be checked |
|
protected |
Loads the file at given path.
lines | Where lines shall be placed |
path | Path to the file to be loaded |
std::vector< std::shared_ptr< DetailedVoxel > > VoxelFileParser::parseDetailed | ( | std::string const & | path, |
size_t | numHeaderLines = 2 , |
||
bool const | exactFormat = true , |
||
bool const | discardNullPad = false , |
||
std::string const | separator = " " |
||
) |
Parse detailed voxels specified at file located at given path.
path | Where the detailed voxels specification file is located |
numHeaderLines | Specify how many header lines are used at given file. Comments and blank lines must not be considered for this count. |
exactFormat | When true it is assumed that only standard parameters should be considering for each voxel. Using this knowledge parsing process can be accelerated. |
discardNullPad | When true, those voxels with a PadBvTotal of 0 will be discarded (by default they are preserved) |
separator | The separator between different fields |
For instance, if 1st line is a header line, 2nd line is a comment line, 3rd line is a header line and from 4th line all lines are content; number of header lines should be specified as 2
|
protected |
Parse the DetailedVoxel specified in given line.
line | Line where the DetailedVoxel is specified |
separator | The separator between different fields |
format1 | Format string to parse indices at X,Y,Z (i,j,k), so voxel coordinates can be computed |
format2 | Format string to parse expected doubles |
format3 | Format string to parse extra values (doubles) |
|
protected |
Remove header lines.
lines | From where header lines shall be removed |
numHeaderLines | How many header lines shall be removed |
|
protected |
Check if flags are valid.
HeliosException | if there is a not valid flag |