#pragma once /** * @file * Implementation of KDTree storage class. */ #include #include namespace meshless { /// Helper class for KDTree with appropriate accessors containing a set of points. @ingroup utils struct PointCloud { std::vector pts; ///< Points, contained in the tree. /// Construct an empty point set. PointCloud() = default; /// Construct from an array of points. PointCloud(const std::vector& pts) : pts(pts) {} /// Reset contained points. void setPts(const std::vector& pts) { PointCloud::pts = pts; } /// Interface requirement: returns number of data points. inline int kdtree_get_point_count() const { return pts.size(); } /// Interface requirement: returns `dim`-th coordinate of `idx`-th point. inline typename double kdtree_get_pt(const size_t idx, int dim) const { return pts[idx][dim]; } /// Access the points. inline Eigen::Vector3d get(const size_t idx) const { return pts[idx]; } /// Add a point to the cloud. inline void add(const Eigen::Vector3d& p) { pts.push_back(p); } /// Comply with the interface. template bool kdtree_get_bbox(BBOX& /* bb */) const { return false; } }; } // namespace mm