You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
#pragma once
|
|
|
|
/**
|
|
* @file
|
|
* Implementation of KDTree storage class.
|
|
*/
|
|
|
|
#include <vector>
|
|
#include <Eigen/Core>
|
|
|
|
namespace meshless {
|
|
|
|
/// Helper class for KDTree with appropriate accessors containing a set of points. @ingroup utils
|
|
struct PointCloud {
|
|
std::vector<Eigen::Vector3d> pts; ///< Points, contained in the tree.
|
|
|
|
/// Construct an empty point set.
|
|
PointCloud() = default;
|
|
|
|
/// Construct from an array of points.
|
|
PointCloud(const std::vector<Eigen::Vector3d>& pts) : pts(pts) {}
|
|
|
|
/// Reset contained points.
|
|
void setPts(const std::vector<Eigen::Vector3d>& 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 <class BBOX>
|
|
bool kdtree_get_bbox(BBOX& /* bb */) const {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
} // namespace mm
|
|
|
|
|