COGS
Computer Graphics Structures library
AabbHierarchy.h
1 #ifndef COGS_AABB_HIERARCHY_H
2 #define COGS_AABB_HIERARCHY_H
3 #include <memory>
4 
5 #include <Utils/GeometryStructures.h>
6 #include <COGS/API.h>
7 
8 namespace cogs
9 {
10  //template<typename T>
12  class COGS_API AabbHierarchy
13  {
14  public:
15  //typedef int(*DistributionFunc)(const T &elem1, const T &elem2); // 0 == left subtree, 1 == right_subtree, -1 == both
16  //AabbHierarchy(const std::vector<T> &elements, const DistributionFunc function);
17  AabbHierarchy(std::vector<geom::Triangle3> &triangles, const geom::Aabb3 &aabb);
18 
20  void GetIntersections(const geom::Line3 &ray, std::vector<glm::vec3> *intersections) const;
21 
22  private:
23  struct TreeNode
24  {
25  TreeNode(std::vector<geom::Triangle3> &triangles, const geom::Aabb3 &aabb, const uint8_t depth = 0, const uint8_t cycle_counter = 0);
26 
27  void GetIntersections(const geom::Line3 &ray, std::vector<glm::vec3> *intersections) const;
28 
29  private:
30  const geom::Aabb3 aabb_;
31  std::unique_ptr<TreeNode> l_node_ = nullptr, r_node_ = nullptr;
32  std::vector<geom::Triangle3> triangles_;
33 
34  const uint8_t kMinLeafElements = 10;
35  };
36 
37  std::unique_ptr<TreeNode> tree;
38  };
39 }
40 #endif /* !COGS_AABB_HIERARCHY_H */
Namespace of "Computer Graphic Structures" library, which implement many core classes and structures...
Definition: AabbHierarchy.h:8
Space-partitioning data structure for point clouds.
Definition: AabbHierarchy.h:12