Class ChunkHashGrid

Inheritance Relationships

Derived Type

Class Documentation

class ChunkHashGrid

Subclassed by lvr2::ChunkManager

Public Types

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

Public Functions

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

class to load chunks from an HDF5 file

Parameters:

hdf5Path – path to the HDF5 file

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

class to load chunks from an HDF5 file

Parameters:

hdf5Path – path to the HDF5 file

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

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:

T – type of chunk

Parameters:
  • layer – layer of chunk

  • x – x coordinate of chunk in chunk coordinates

  • y – y coordinate of chunk in chunk coordinates

  • z – z coordinate of chunk in chunk coordinates

  • data – content of chunk to be added

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

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:

T – type of chunk

Parameters:
  • layer – layer of chunk

  • x – x coordinate of chunk in chunk coordinates

  • y – y coordinate of chunk in chunk coordinates

  • z – z coordinate of chunk in chunk coordinates

  • data – content of chunk to be added

template<typename T>
boost::optional<T> 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:

T – type of requested chunk

Parameters:
  • layer – layer of requested chunk

  • x – x coordinate of chunk in chunk coordinates

  • y – y coordinate of chunk in chunk coordinates

  • z – z coordinate of chunk in chunk coordinates

Returns:

content of the chunk

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

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

Parameters:
  • layer – layer of chunk

  • hashValue – hashValue hash of the chunk coordinate

Returns:

true if chunk is loaded; else false

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

Parameters:
  • layer – layer of chunk

  • x – x coordinate of chunk in chunk coordinates

  • y – y coordinate of chunk in chunk coordinates

  • z – z coordinate of chunk in chunk coordinates

Returns:

true if chunk is loaded; else false

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

Calculates the hash value for the given index triple.

Parameters:
  • i – index of x-axis

  • j – index of y-axis

  • k – index of z-axis

Returns:

hash value

inline const BoundingBox<BaseVector<float>> &getBoundingBox() const
inline float getChunkSize() const
inline const BaseVector<std::size_t> &getChunkAmount() const
inline BaseVector<int> getChunkMinChunkIndex() const

returns the minimum chunk ids

inline BaseVector<int> getChunkMaxChunkIndex() const

returns the maximum chunk ids

void setBoundingBox(const BoundingBox<BaseVector<float>> boundingBox)

sets the bounding box in this container and in persistend storage

Parameters:

boundingBox – new bounding box

Protected Functions

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

regenerates cache hash grid

Parameters:
  • oldChunkAmount – previous amount of chunks

  • oldChunkIndexOffset – previous offset for chunk indices

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

Template Parameters:

T – Type of chunk data

Parameters:
  • layer – layer of chunk

  • x – x coordinate of chunk in chunk coordinates

  • y – y coordinate of chunk in chunk coordinates

  • z – z coordinate of chunk in chunk coordinates

Returns:

true if chunk has been loaded; false if chunk does not exist in persistend storage

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

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:
  • layer – layer of chunk

  • x – x coordinate of chunk in chunk coordinates

  • y – y coordinate of chunk in chunk coordinates

  • z – z coordinate of chunk in chunk coordinates

  • data – content of chunk to load

inline void setChunkSize(float chunkSize)

sets chunk size in this container and in persistent storage

Parameters:

chunkSize – new size of chunks

Protected Attributes

BoundingBox<BaseVector<float>> m_boundingBox