Skip to content

Commit

Permalink
Merge pull request #129 from azaleostu/kdtree-refactor
Browse files Browse the repository at this point in the history
[SpatialPartitioning] Refactor KdTree into KdTreeDense + KdTreeSparse
  • Loading branch information
nmellado authored Dec 21, 2023
2 parents 8f9df5f + 46bf2d5 commit a75f4aa
Show file tree
Hide file tree
Showing 14 changed files with 355 additions and 182 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Current head (v.1.3 RC)

- API
- [SpatialPartitioning] Change part of the kdtree API (#123)
- [spatialPartitioning] Refactor KdTree into KdTreeDense + KdTreeSparse (#129)

- Docs
- [spatialPartitioning] Update KdTree docs to reflect the kdtree API refactor (#129)

--------------------------------------------------------------------------------
v.1.2
Expand Down
11 changes: 6 additions & 5 deletions Ponca/src/SpatialPartitioning/KdTree/Query/kdTreeQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class KdTreeQuery
m_stack.push({0,0});
}

/// [KdTreeQuery kdtree type]
const KdTreeBase<Traits>* m_kdtree { nullptr };
/// [KdTreeQuery kdtree type]
Stack<IndexSquaredDistance<IndexType, Scalar>, 2 * Traits::MAX_DEPTH> m_stack;

template<typename LeafPreparationFunctor,
Expand All @@ -44,11 +46,10 @@ class KdTreeQuery
ProcessNeighborFunctor processNeighborFunctor
)
{
const auto& nodes = m_kdtree->nodes();
const auto& points = m_kdtree->points();
const auto& indices = m_kdtree->samples();
const auto& nodes = m_kdtree->nodes();
const auto& points = m_kdtree->points();

if (nodes.empty() || points.empty() || indices.empty())
if (nodes.empty() || points.empty() || m_kdtree->sample_count() == 0)
throw std::invalid_argument("Empty KdTree");

while(!m_stack.empty())
Expand All @@ -66,7 +67,7 @@ class KdTreeQuery
prepareLeafTraversal(start, end);
for(IndexType i=start; i<end; ++i)
{
IndexType idx = indices[i];
IndexType idx = m_kdtree->pointFromSample(i);
if(skipFunctor(idx)) continue;

Scalar d = (point - points[idx].pos()).squaredNorm();
Expand Down
Loading

0 comments on commit a75f4aa

Please sign in to comment.