Medusa  1.1
Coordinate Free Mehless Method implementation
PointCloud.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_SPATIAL_SEARCH_POINTCLOUD_HPP_
2 #define MEDUSA_BITS_SPATIAL_SEARCH_POINTCLOUD_HPP_
3 
9 #include <vector>
10 
11 namespace mm {
12 
14 namespace kdtree_internal {
15 
17 template <typename vec_t>
18 struct PointCloud {
19  std::vector<vec_t> pts;
20 
22  PointCloud() = default;
23 
25  PointCloud(const std::vector<vec_t>& pts) : pts(pts) {}
26 
28  void setPts(const std::vector<vec_t>& pts) {
30  }
31 
33  inline int kdtree_get_point_count() const { return pts.size(); }
34 
36  inline typename vec_t::scalar_t kdtree_get_pt(const size_t idx, int dim) const {
37  return pts[idx][dim];
38  }
39 
41  inline vec_t get(const size_t idx) const { return pts[idx]; }
42 
44  inline void add(const vec_t& p) { pts.push_back(p); }
45 
47  template <class BBOX>
48  bool kdtree_get_bbox(BBOX& /* bb */) const { return false; }
49 };
50 
51 } // namespace kdtree_internal
52 } // namespace mm
53 
54 #endif // MEDUSA_BITS_SPATIAL_SEARCH_POINTCLOUD_HPP_
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
scalar_t
Scalar scalar_t
Type of the elements, alias of Scalar.
Definition: MatrixBaseAddons.hpp:16
mm::kdtree_internal::PointCloud::get
vec_t get(const size_t idx) const
Access the points.
Definition: PointCloud.hpp:41
mm::kdtree_internal::PointCloud
Helper class for KDTree with appropriate accessors containing a set of points.
Definition: PointCloud.hpp:18
mm::kdtree_internal::PointCloud::PointCloud
PointCloud(const std::vector< vec_t > &pts)
Construct from an array of points.
Definition: PointCloud.hpp:25
dim
@ dim
Number of elements of this matrix.
Definition: MatrixBaseAddons.hpp:14
mm::kdtree_internal::PointCloud::setPts
void setPts(const std::vector< vec_t > &pts)
Reset contained points.
Definition: PointCloud.hpp:28
mm::kdtree_internal::PointCloud::pts
std::vector< vec_t > pts
Points, contained in the tree.
Definition: PointCloud.hpp:19
mm::kdtree_internal::PointCloud::add
void add(const vec_t &p)
Add a point to the cloud.
Definition: PointCloud.hpp:44
mm::kdtree_internal::PointCloud::kdtree_get_pt
vec_t::scalar_t kdtree_get_pt(const size_t idx, int dim) const
Interface requirement: returns dim-th coordinate of idx-th point.
Definition: PointCloud.hpp:36
mm::kdtree_internal::PointCloud::kdtree_get_bbox
bool kdtree_get_bbox(BBOX &) const
Comply with the interface.
Definition: PointCloud.hpp:48
mm::kdtree_internal::PointCloud::PointCloud
PointCloud()=default
Construct an empty point set.
mm::kdtree_internal::PointCloud::kdtree_get_point_count
int kdtree_get_point_count() const
Interface requirement: returns number of data points.
Definition: PointCloud.hpp:33