COGS
Computer Graphics Structures library
Octree.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef COGS_OCTREE_H
7 #define COGS_OCTREE_H
8 #include <COGS/PointCloud.h>
9 
10 namespace cogs
11 {
13  class OctreeNode;
14 
16  class COGS_API Octree
17  {
18  public:
20  static const uint8_t POINTS_THRESHOLD = 64;
22  ~Octree();
24  Octree() = default;
31  Octree(const cogs::PointCloud &cloud);
38  Octree(const std::vector<glm::vec3> &positions);
45  void Include(const cogs::PointCloud &cloud);
52  void Include(const std::vector<const cogs::PointCloud *> &clouds);
59  std::string ToString() const;
66  size_t GetNodeCount() const;
73  std::vector<geom::Aabb3> GetNodeCubes() const;
84  bool HasPointIn(const glm::vec3 &location, float_t radius) const;
93  bool HasPointIn(const geom::Aabb3 &search_range) const;
104  std::vector<uint32_t> Find(const glm::vec3 &location, float_t radius) const;
113  std::vector<uint32_t> Find(const geom::Aabb3 &search_range) const;
124  int32_t GetIntersectedPoint(const geom::Ray3 &ray, std::optional<float> tolerance = std::nullopt) const;
125 
126  private:
128  OctreeNode *root_ = nullptr;
130  void InitializeRoot(const std::vector<glm::vec3> &positions);
132  float_t GetMaximumExtent(const std::vector<glm::vec3> &positions) const;
134  float_t GetMinimumExtent(const std::vector<glm::vec3> &positions) const;
141  bool RayIntersectsPoint(const geom::Ray3 &ray, const glm::vec3 &point, std::optional<float> tolerance = std::nullopt) const;
142  };
143 }
144 #endif /* !COGS_OCTREE_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: Octree.h:16