Skip to content

Commit 5161a54

Browse files
Nemanja Bartolovicmeta-codesync[bot]
authored andcommitted
Add Kd-Tree for closest cluster lookup
Summary: This Diff accelerates closest visibility cluster lookup via a KdTree implementation found in `axel`, an internal spatial acceleration data structure library. The lookup changes the current (linear) search from O(N) average time to O(logN) average time. Given that we want to experiment with a higher number of clusters, performing the lookup quickly will become valuable. As the tree class does not have a default constructor (or move construction), we manage it via a `unique_ptr`. I also fixed a few minor issues in the surrounding IO code. Differential Revision: D88371683 fbshipit-source-id: 5da6198378d5ca282db6264ef25162938fa40f3d
1 parent 0e2d094 commit 5161a54

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

axel/axel/KdTree.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
#include <Eigen/Core>
1414
#include <Eigen/Eigen>
1515

16+
#ifdef True
17+
#undef True
18+
#endif // True
19+
20+
#ifdef False
21+
#undef False
22+
#endif // False
23+
1624
namespace axel {
1725

1826
namespace detail {
@@ -71,7 +79,8 @@ class KdTree {
7179
typename = std::enable_if_t<
7280
detail::IsEigenTypeWithStorage<T> && // This check might be obsolete due to transitivity.
7381
std::is_same_v<std::decay_t<T>, std::decay_t<EigenMatrixType>>>>
74-
explicit KdTree(T&& points) : points_(std::forward<T>(points)), tree_(points_.cols(), points_) {
82+
explicit KdTree(T&& points)
83+
: points_(std::forward<T>(points)), tree_(static_cast<int32_t>(points_.cols()), points_) {
7584
tree_.index->buildIndex();
7685
}
7786

0 commit comments

Comments
 (0)