COGS
Computer Graphics Structures library
KdTree.h
1 #ifndef COGS_KD_TREE_H
2 #define COGS_KD_TREE_H
3 #include <memory>
4 #include <Utils/GeometryStructures.h>
5 
6 #include <COGS/PointCloud.h>
7 
8 namespace cogs
9 {
11  class COGS_API KdTree
12  {
13  public:
14  KdTree() = default;
15  KdTree(const cogs::PointCloud &cloud);
16  KdTree(const std::vector<const cogs::PointCloud *> clouds);
18  void Initialize(const cogs::PointCloud &cloud);
20  void Initialize(const std::vector<const cogs::PointCloud *> clouds);
22  bool IsPointInRange(const geom::Aabb3 &search_range) const;
24  void GetPointsInRange(const geom::Aabb3 &search_range, std::vector<uint32_t> *output) const;
25 
26  private:
27  struct TreeNode
28  {
29  TreeNode() = default;
30  void Include(std::vector<std::pair<uint32_t, glm::vec3>> &points, uint8_t dimension = 0);
31  bool QueryRange(const geom::Aabb3 &search_range, std::vector<uint32_t> *output = nullptr) const;
32  private:
33  glm::vec3 value_;
34  uint32_t index_;
35  uint8_t depth_mod_;
36  std::unique_ptr<TreeNode> l_node_ = nullptr, r_node_ = nullptr;
37  };
38 
39  std::unique_ptr<TreeNode> tree_;
40  uint32_t point_count_;
41  };
42 }
43 #endif /* !COGS_KD_TREE_H */
Namespace of "Computer Graphic Structures" library, which implement many core classes and structures...
Definition: AabbHierarchy.h:8
Management class for a set of data points in a 3D space.
Definition: PointCloud.h:32
Space-partitioning data structure for point clouds.
Definition: KdTree.h:11