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

25 lines
710 B
C++
Raw Normal View History

#pragma once
#include "vde/spatial/spatial_index.h"
namespace vde::spatial {
using core::AABB3D;
using core::Point3D;
using core::Ray3Dd;
template <typename T>
class KDTree : public SpatialIndex<T> {
public:
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 items_.size(); }
private:
std::vector<T> items_;
};
} // namespace vde::spatial