Files
ViewDesignEngine/include/vde/spatial/octree.h
T

25 lines
787 B
C++
Raw Normal View History

#pragma once
#include "vde/spatial/spatial_index.h"
namespace vde::spatial {
template <typename T>
class Octree : public SpatialIndex<T> {
public:
explicit Octree(int max_depth = 8, int max_items = 16)
: max_depth_(max_depth), max_items_(max_items) {}
void build(const std::vector<T>& items) override;
void insert(const T& item) override;
bool remove(const T& item) override;
std::vector<T> query_range(const AABB3D& range) const override;
std::vector<T> query_knn(const Point3D& point, size_t k) const override;
std::vector<T> query_ray(const Ray3Dd& ray) const override;
void clear() override;
size_t size() const override { return count_; }
private:
int max_depth_, max_items_;
size_t count_ = 0;
};
} // namespace vde::spatial