Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
lvr2::ChunkHashGrid Class Reference

#include <ChunkHashGrid.hpp>

Inheritance diagram for lvr2::ChunkHashGrid:
Inheritance graph
[legend]

Public Types

using io = Hdf5Build< hdf5features::ChunkIO >
 
using val_type = boost::variant< MeshBufferPtr, PointBufferPtr >
 

Public Member Functions

 ChunkHashGrid (std::string hdf5Path, size_t cacheSize, float chunkSize=10.0f)
 class to load chunks from an HDF5 file More...
 
 ChunkHashGrid (std::string hdf5Path, size_t cacheSize, BoundingBox< BaseVector< float >> boundingBox, float chunkSize)
 class to load chunks from an HDF5 file More...
 
const BoundingBox< BaseVector< float > > & getBoundingBox () const
 
template<typename T >
boost::optional< T > getChunk (std::string layer, int x, int y, int z)
 delivers the content of a chunk More...
 
const BaseVector< std::size_t > & getChunkAmount () const
 
BaseVector< int > getChunkMaxChunkIndex () const
 returns the maximum chunk ids More...
 
BaseVector< int > getChunkMinChunkIndex () const
 returns the minimum chunk ids More...
 
float getChunkSize () const
 
std::size_t hashValue (int i, int j, int k) const
 Calculates the hash value for the given index triple. More...
 
bool isChunkLoaded (std::string layer, size_t hashValue)
 indicates if wether or not a chunk is currently loaded in the local cache More...
 
bool isChunkLoaded (std::string layer, int x, int y, int z)
 indicates if wether or not a chunk is currently loaded in the local cache More...
 
void setBoundingBox (const BoundingBox< BaseVector< float >> boundingBox)
 sets the bounding box in this container and in persistend storage More...
 
template<typename T >
void setChunk (std::string layer, int x, int y, int z, T data)
 sets a chunk of a given layer in hashgrid More...
 
template<typename T >
void setGeometryChunk (std::string layer, int x, int y, int z, T data)
 sets a chunk of a given layer in hashgrid More...
 

Protected Member Functions

void expandBoundingBox (const val_type &data)
 
template<typename T >
bool loadChunk (std::string layer, int x, int y, int z)
 loads a chunk from persistent storage into cache More...
 
void loadChunk (std::string layer, int x, int y, int z, const val_type &data)
 loads given chunk data into cache More...
 
void rehashCache (const BaseVector< std::size_t > &oldChunkAmount, const BaseVector< std::size_t > &oldChunkIndexOffset)
 regenerates cache hash grid More...
 
void setChunkSize (float chunkSize)
 sets chunk size in this container and in persistent storage More...
 

Protected Attributes

BoundingBox< BaseVector< float > > m_boundingBox
 

Private Member Functions

void setChunkAmountAndOffset (const BaseVector< std::size_t > &chunkAmount, const BaseVector< std::size_t > &chunkIndexOffset)
 sets the amount of chunks in x y and z direction in this container and in persistent storage More...
 

Private Attributes

size_t m_cacheSize
 
BaseVector< std::size_t > m_chunkAmount
 
BaseVector< std::size_t > m_chunkIndexOffset
 
float m_chunkSize
 
std::unordered_map< std::string, std::unordered_map< size_t, val_type > > m_hashGrid
 
io m_io
 
std::list< std::pair< std::string, size_t > > m_items
 

Detailed Description

Definition at line 67 of file ChunkHashGrid.hpp.

Member Typedef Documentation

◆ io

Definition at line 72 of file ChunkHashGrid.hpp.

◆ val_type

Definition at line 70 of file ChunkHashGrid.hpp.

Constructor & Destructor Documentation

◆ ChunkHashGrid() [1/2]

lvr2::ChunkHashGrid::ChunkHashGrid ( std::string  hdf5Path,
size_t  cacheSize,
float  chunkSize = 10.0f 
)
explicit

class to load chunks from an HDF5 file

Parameters
hdf5Pathpath to the HDF5 file

Definition at line 39 of file ChunkHashGrid.cpp.

◆ ChunkHashGrid() [2/2]

lvr2::ChunkHashGrid::ChunkHashGrid ( std::string  hdf5Path,
size_t  cacheSize,
BoundingBox< BaseVector< float >>  boundingBox,
float  chunkSize 
)

class to load chunks from an HDF5 file

Parameters
hdf5Pathpath to the HDF5 file

Definition at line 55 of file ChunkHashGrid.cpp.

Member Function Documentation

◆ expandBoundingBox()

void lvr2::ChunkHashGrid::expandBoundingBox ( const val_type data)
protected

Definition at line 130 of file ChunkHashGrid.cpp.

◆ getBoundingBox()

const BoundingBox<BaseVector<float> >& lvr2::ChunkHashGrid::getBoundingBox ( ) const
inline

Definition at line 180 of file ChunkHashGrid.hpp.

◆ getChunk()

template<typename T >
boost::optional<T> lvr2::ChunkHashGrid::getChunk ( std::string  layer,
int  x,
int  y,
int  z 
)

delivers the content of a chunk

Returns a the content of a chunk from the local cache. If the requested chunk is not cached, the chunk will be loaded from the persistent storage and returned after being added to the cache.

Template Parameters
Ttype of requested chunk
Parameters
layerlayer of requested chunk
xx coordinate of chunk in chunk coordinates
yy coordinate of chunk in chunk coordinates
zz coordinate of chunk in chunk coordinates
Returns
content of the chunk

◆ getChunkAmount()

const BaseVector<std::size_t>& lvr2::ChunkHashGrid::getChunkAmount ( ) const
inline

Definition at line 190 of file ChunkHashGrid.hpp.

◆ getChunkMaxChunkIndex()

BaseVector<int> lvr2::ChunkHashGrid::getChunkMaxChunkIndex ( ) const
inline

returns the maximum chunk ids

Definition at line 207 of file ChunkHashGrid.hpp.

◆ getChunkMinChunkIndex()

BaseVector<int> lvr2::ChunkHashGrid::getChunkMinChunkIndex ( ) const
inline

returns the minimum chunk ids

Definition at line 198 of file ChunkHashGrid.hpp.

◆ getChunkSize()

float lvr2::ChunkHashGrid::getChunkSize ( ) const
inline

Definition at line 185 of file ChunkHashGrid.hpp.

◆ hashValue()

std::size_t lvr2::ChunkHashGrid::hashValue ( int  i,
int  j,
int  k 
) const
inline

Calculates the hash value for the given index triple.

Parameters
iindex of x-axis
jindex of y-axis
kindex of z-axis
Returns
hash value

Definition at line 174 of file ChunkHashGrid.hpp.

◆ isChunkLoaded() [1/2]

bool lvr2::ChunkHashGrid::isChunkLoaded ( std::string  layer,
size_t  hashValue 
)

indicates if wether or not a chunk is currently loaded in the local cache

Parameters
layerlayer of chunk
hashValuehashValue hash of the chunk coordinate
Returns
true if chunk is loaded; else false

◆ isChunkLoaded() [2/2]

bool lvr2::ChunkHashGrid::isChunkLoaded ( std::string  layer,
int  x,
int  y,
int  z 
)

indicates if wether or not a chunk is currently loaded in the local cache

Parameters
layerlayer of chunk
xx coordinate of chunk in chunk coordinates
yy coordinate of chunk in chunk coordinates
zz coordinate of chunk in chunk coordinates
Returns
true if chunk is loaded; else false

Definition at line 80 of file ChunkHashGrid.cpp.

◆ loadChunk() [1/2]

template<typename T >
bool lvr2::ChunkHashGrid::loadChunk ( std::string  layer,
int  x,
int  y,
int  z 
)
protected

loads a chunk from persistent storage into cache

Template Parameters
TType of chunk data
Parameters
layerlayer of chunk
xx coordinate of chunk in chunk coordinates
yy coordinate of chunk in chunk coordinates
zz coordinate of chunk in chunk coordinates
Returns
true if chunk has been loaded; false if chunk does not exist in persistend storage

◆ loadChunk() [2/2]

void lvr2::ChunkHashGrid::loadChunk ( std::string  layer,
int  x,
int  y,
int  z,
const val_type data 
)
protected

loads given chunk data into cache

Loads given chunk data into cache and handles cache overflows. If the cache is full after adding the chunk, the least recent used chunk will be removed from cache.

Parameters
layerlayer of chunk
xx coordinate of chunk in chunk coordinates
yy coordinate of chunk in chunk coordinates
zz coordinate of chunk in chunk coordinates
datacontent of chunk to load

Definition at line 145 of file ChunkHashGrid.cpp.

◆ rehashCache()

void lvr2::ChunkHashGrid::rehashCache ( const BaseVector< std::size_t > &  oldChunkAmount,
const BaseVector< std::size_t > &  oldChunkIndexOffset 
)
protected

regenerates cache hash grid

Parameters
oldChunkAmountprevious amount of chunks
oldChunkIndexOffsetprevious offset for chunk indices

Definition at line 85 of file ChunkHashGrid.cpp.

◆ setBoundingBox()

void lvr2::ChunkHashGrid::setBoundingBox ( const BoundingBox< BaseVector< float >>  boundingBox)

sets the bounding box in this container and in persistend storage

Parameters
boundingBoxnew bounding box

Definition at line 172 of file ChunkHashGrid.cpp.

◆ setChunk()

template<typename T >
void lvr2::ChunkHashGrid::setChunk ( std::string  layer,
int  x,
int  y,
int  z,
data 
)

sets a chunk of a given layer in hashgrid

Adds a chunk for a given layer and coordinate in chunk coordinates to local cache and stores it permanently using io module. if the given chunk coordinate does not exist, the boudnig box will be expanded to fit the new chunk

Template Parameters
Ttype of chunk
Parameters
layerlayer of chunk
xx coordinate of chunk in chunk coordinates
yy coordinate of chunk in chunk coordinates
zz coordinate of chunk in chunk coordinates
datacontent of chunk to be added

◆ setChunkAmountAndOffset()

void lvr2::ChunkHashGrid::setChunkAmountAndOffset ( const BaseVector< std::size_t > &  chunkAmount,
const BaseVector< std::size_t > &  chunkIndexOffset 
)
private

sets the amount of chunks in x y and z direction in this container and in persistent storage

Parameters
chunkAmountnew amounts of chunks

Definition at line 202 of file ChunkHashGrid.cpp.

◆ setChunkSize()

void lvr2::ChunkHashGrid::setChunkSize ( float  chunkSize)
inlineprotected

sets chunk size in this container and in persistent storage

Parameters
chunkSizenew size of chunks

Definition at line 268 of file ChunkHashGrid.hpp.

◆ setGeometryChunk()

template<typename T >
void lvr2::ChunkHashGrid::setGeometryChunk ( std::string  layer,
int  x,
int  y,
int  z,
data 
)

sets a chunk of a given layer in hashgrid

Adds a chunk for a given layer and coordinate in chunk coordinates to local cache and stores it permanently using io module. Uses the geometrical data of the chunk data (if exists) to expand boundingbox

Template Parameters
Ttype of chunk
Parameters
layerlayer of chunk
xx coordinate of chunk in chunk coordinates
yy coordinate of chunk in chunk coordinates
zz coordinate of chunk in chunk coordinates
datacontent of chunk to be added

Member Data Documentation

◆ m_boundingBox

BoundingBox<BaseVector<float> > lvr2::ChunkHashGrid::m_boundingBox
protected

Definition at line 276 of file ChunkHashGrid.hpp.

◆ m_cacheSize

size_t lvr2::ChunkHashGrid::m_cacheSize
private

Definition at line 293 of file ChunkHashGrid.hpp.

◆ m_chunkAmount

BaseVector<std::size_t> lvr2::ChunkHashGrid::m_chunkAmount
private

Definition at line 305 of file ChunkHashGrid.hpp.

◆ m_chunkIndexOffset

BaseVector<std::size_t> lvr2::ChunkHashGrid::m_chunkIndexOffset
private

Definition at line 308 of file ChunkHashGrid.hpp.

◆ m_chunkSize

float lvr2::ChunkHashGrid::m_chunkSize
private

Definition at line 302 of file ChunkHashGrid.hpp.

◆ m_hashGrid

std::unordered_map<std::string, std::unordered_map<size_t, val_type> > lvr2::ChunkHashGrid::m_hashGrid
private

Definition at line 299 of file ChunkHashGrid.hpp.

◆ m_io

io lvr2::ChunkHashGrid::m_io
private

Definition at line 290 of file ChunkHashGrid.hpp.

◆ m_items

std::list<std::pair<std::string, size_t> > lvr2::ChunkHashGrid::m_items
private

Definition at line 296 of file ChunkHashGrid.hpp.


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


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:11