#ifndef SLA_SPATINDEX_HPP #define SLA_SPATINDEX_HPP #include #include #include #include #include namespace Slic3r { namespace sla { typedef Eigen::Matrix Vec3d; using PointIndexEl = std::pair; class PointIndex { 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: PointIndex(); ~PointIndex(); PointIndex(const PointIndex&); PointIndex(PointIndex&&); PointIndex& operator=(const PointIndex&); PointIndex& operator=(PointIndex&&); void insert(const PointIndexEl&); bool remove(const PointIndexEl&); inline void insert(const Vec3d& v, unsigned idx) { insert(std::make_pair(v, unsigned(idx))); } std::vector query(std::function) const; std::vector nearest(const Vec3d&, unsigned k) const; std::vector query(const Vec3d &v, unsigned k) const // wrapper { return nearest(v, k); } // For testing size_t size() const; bool empty() const { return size() == 0; } void foreach(std::function fn); void foreach(std::function fn) const; }; using BoxIndexEl = std::pair; class BoxIndex { 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: BoxIndex(); ~BoxIndex(); BoxIndex(const BoxIndex&); BoxIndex(BoxIndex&&); BoxIndex& operator=(const BoxIndex&); BoxIndex& operator=(BoxIndex&&); void insert(const BoxIndexEl&); void insert(const BoundingBox& bb, unsigned idx) { insert(std::make_pair(bb, unsigned(idx))); } bool remove(const BoxIndexEl&); enum QueryType { qtIntersects, qtWithin }; std::vector query(const BoundingBox&, QueryType qt); // For testing size_t size() const; bool empty() const { return size() == 0; } void foreach(std::function fn); }; } } #endif // SPATINDEX_HPP