#ifndef SPATINDEX_HPP #define SPATINDEX_HPP #include #include #include #include namespace Slic3r { namespace sla { typedef Eigen::Matrix Vec3d; using SpatElement = std::pair; class SpatIndex { class Impl; // We use Pimpl because it takes a long time to compile boost headers which // is the engine of this class. We include it only in the cpp file. std::unique_ptr m_impl; public: SpatIndex(); ~SpatIndex(); SpatIndex(const SpatIndex&); SpatIndex(SpatIndex&&); SpatIndex& operator=(const SpatIndex&); SpatIndex& operator=(SpatIndex&&); void insert(const SpatElement&); bool remove(const SpatElement&); inline void insert(const Vec3d& v, unsigned idx) { insert(std::make_pair(v, unsigned(idx))); } std::vector query(std::function); std::vector nearest(const Vec3d&, unsigned k); // For testing size_t size() const; bool empty() const { return size() == 0; } void foreach(std::function fn); }; } } #endif // SPATINDEX_HPP