OGS
OctTree.h
Go to the documentation of this file.
1
15#pragma once
16
17#include <Eigen/Core>
18#include <cstdint>
19#include <limits>
20#include <vector>
21
22namespace GeoLib
23{
26template <typename POINT, std::size_t MAX_POINTS>
28{
29public:
47 Eigen::Vector3d ll, Eigen::Vector3d ur,
48 double eps = std::numeric_limits<double>::epsilon());
49
52 virtual ~OctTree();
53
68 bool addPoint(POINT* pnt, POINT*& ret_pnt);
69
72 template <typename T>
73 void getPointsInRange(T const& min, T const& max,
74 std::vector<POINT*>& pnts) const;
75
76#ifndef NDEBUG
77 Eigen::Vector3d const& getLowerLeftCornerPoint() const { return _ll; }
78 Eigen::Vector3d const& getUpperRightCornerPoint() const { return _ur; }
79 OctTree<POINT, MAX_POINTS> const* getChild(std::size_t i) const
80 {
81 return _children[i];
82 }
83 std::vector<POINT*> const& getPointVector() const { return _pnts; }
84#endif
85
86private:
91 OctTree(Eigen::Vector3d const& ll, Eigen::Vector3d const& ur, double eps);
92
93 enum class Quadrant : std::int8_t
94 {
95 NEL = 0,
96 NWL,
97 SWL,
98 SEL,
99 NEU,
100 NWU,
101 SWU,
102 SEU
103 };
104
110 bool addPoint_(POINT* pnt, POINT*& ret_pnt);
111
118 bool addPointToChild(POINT* pnt);
119
123 void splitNode(POINT* pnt);
124
128 bool isOutside(POINT* pnt) const;
129
139 std::array<OctTree<POINT, MAX_POINTS>*, 8> _children;
141 Eigen::Vector3d const _ll;
143 Eigen::Vector3d const _ur;
145 std::vector<POINT*> _pnts;
149 double const _eps;
150};
151
152} // end namespace GeoLib
153
154#include "OctTree-impl.h"
Implementation of the OctTree class.
Eigen::Vector3d const _ur
upper right back face point of the cube
Definition OctTree.h:143
Eigen::Vector3d const & getLowerLeftCornerPoint() const
Definition OctTree.h:77
bool addPoint(POINT *pnt, POINT *&ret_pnt)
bool addPointToChild(POINT *pnt)
bool addPoint_(POINT *pnt, POINT *&ret_pnt)
void splitNode(POINT *pnt)
void getPointsInRange(T const &min, T const &max, std::vector< POINT * > &pnts) const
bool _is_leaf
flag if this OctTree is a leaf
Definition OctTree.h:147
OctTree(Eigen::Vector3d const &ll, Eigen::Vector3d const &ur, double eps)
Eigen::Vector3d const & getUpperRightCornerPoint() const
Definition OctTree.h:78
@ NEU
south west upper
@ NEL
north east lower
@ SWU
south west upper
@ SEU
south east upper
@ NWL
north west lower
@ SWL
south west lower
@ NWU
south west upper
@ SEL
south east lower
std::array< OctTree< POINT, MAX_POINTS > *, 8 > _children
Definition OctTree.h:139
std::vector< POINT * > const & getPointVector() const
Definition OctTree.h:83
std::vector< POINT * > _pnts
vector of pointers to POINT objects
Definition OctTree.h:145
bool isOutside(POINT *pnt) const
double const _eps
threshold for point uniqueness
Definition OctTree.h:149
static OctTree< POINT, MAX_POINTS > * createOctTree(Eigen::Vector3d ll, Eigen::Vector3d ur, double eps=std::numeric_limits< double >::epsilon())
virtual ~OctTree()
OctTree< POINT, MAX_POINTS > const * getChild(std::size_t i) const
Definition OctTree.h:79
Eigen::Vector3d const _ll
lower left front face point of the cube
Definition OctTree.h:141