40 : m_cacheSize(cacheSize)
71 auto chunkIt = layerIt->second.find(hashValue);
72 if (chunkIt != layerIt->second.end())
88 std::unordered_map<std::string, std::unordered_map<std::size_t, val_type>> tmpCache;
89 for (std::pair<std::string, std::size_t>& elem :
m_items)
92 int k = elem.second % oldChunkAmount.
z - oldChunkIndexOffset.
z;
93 int j = (elem.second / oldChunkAmount.
z) % oldChunkAmount.
y - oldChunkIndexOffset.
y;
94 int i = elem.second / (oldChunkAmount.
y * oldChunkAmount.
z) - oldChunkIndexOffset.
x;
98 auto layerIt = tmpCache.find(elem.first);
99 if (layerIt != tmpCache.end())
101 auto chunkIt = tmpCache[elem.first].find(elem.second);
102 if (chunkIt != tmpCache[elem.first].end())
104 chunk = tmpCache[elem.first][elem.second];
116 std::size_t newHash =
hashValue(i, j, k);
118 auto chunkIt =
m_hashGrid[elem.first].find(newHash);
121 tmpCache[elem.first][newHash] =
m_hashGrid[elem.first][newHash];
126 elem.second = newHash;
136 for (
unsigned int i = 0; i < geometryChannel.get().numElements(); i++)
147 std::size_t chunkHash =
hashValue(x, y, z);
153 m_items.remove({layer, chunkHash});
157 m_items.push_front({layer, chunkHash});
const BoundingBox< BaseVector< float > > & getBoundingBox() const
float getChunkSize() const
void rehashCache(const BaseVector< std::size_t > &oldChunkAmount, const BaseVector< std::size_t > &oldChunkIndexOffset)
regenerates cache hash grid
void expand(T v)
Expands the bounding box if the given Vector v} is outside the current volume.
BaseVecT getMin() const
Returns the lower left coordinates.
bool isChunkLoaded(std::string layer, size_t hashValue)
indicates if wether or not a chunk is currently loaded in the local cache
std::size_t hashValue(int i, int j, int k) const
Calculates the hash value for the given index triple.
visitor that returns the channel that holds geometic information (like vertices-channel for meshes) ...
ChunkHashGrid(std::string hdf5Path, size_t cacheSize, float chunkSize=10.0f)
class to load chunks from an HDF5 file
BaseVector< std::size_t > m_chunkIndexOffset
A dynamic bounding box class.
void setBoundingBox(const BoundingBox< BaseVector< float >> boundingBox)
sets the bounding box in this container and in persistend storage
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 ...
bool loadChunk(std::string layer, int x, int y, int z)
loads a chunk from persistent storage into cache
boost::variant< MeshBufferPtr, PointBufferPtr > val_type
FloatChannel::Optional FloatChannelOptional
void setChunkSize(float chunkSize)
sets chunk size in this container and in persistent storage
BaseVecT getMax() const
Returns the upper right coordinates.
BoundingBox< BaseVector< float > > m_boundingBox
std::list< std::pair< std::string, size_t > > m_items
std::unordered_map< std::string, std::unordered_map< size_t, val_type > > m_hashGrid
BaseVector< std::size_t > m_chunkAmount
void expandBoundingBox(const val_type &data)