/****************************************************************************** * Copyright (c) 2019, Connor Manning (connor@hobu.co) * * Entwine -- Point cloud indexing * * Entwine is available under the terms of the LGPL2 license. See COPYING * for specific license text and more information. * ******************************************************************************/ #pragma once #include #include #include namespace entwine { class Chunk; class ChunkCache; struct CachedChunk { CachedChunk() : xyz( std::numeric_limits::max(), std::numeric_limits::max(), std::numeric_limits::max()) { } CachedChunk(const Xyz& xyz) : xyz(xyz) { } Xyz xyz; Chunk* chunk = nullptr; }; inline bool operator<(const CachedChunk& a, const CachedChunk& b) { return a.xyz < b.xyz; } class Clipper { public: Clipper(ChunkCache& cache) : m_cache(cache) { m_fast.fill(CachedChunk()); } ~Clipper(); Chunk* get(const ChunkKey& ck); void set(const ChunkKey& ck, Chunk* chunk); void clip(); private: ChunkCache& m_cache; using UsedMap = std::map; using AgedSet = std::set; std::array m_fast; std::array, maxDepth> m_slow; std::array, maxDepth> m_aged; }; } // namespace entwine