9#include "./knnGraphTraits.h"
11#include "Query/knnGraphKNearestQuery.h"
12#include "Query/knnGraphRangeQuery.h"
14#include "../KdTree/kdTree.h"
21 template <
typename Traits>
32 template <
typename DataPo
int>
46 template <
typename Traits>
51 using Scalar =
typename DataPoint::Scalar;
54 using IndexType =
typename Traits::IndexType;
73 template <
typename KdTreeTraits>
75 : m_k(std::
min(
k,
kdtree.sampleCount() - 1)), m_kdTreePoints(
kdtree.points())
77 static_assert(std::is_same<typename Traits::DataPoint, typename KdTreeTraits::DataPoint>::value,
78 "KdTreeTraits::DataPoint is not equal to Traits::DataPoint");
79 static_assert(std::is_same<typename Traits::PointContainer, typename KdTreeTraits::PointContainer>::value,
80 "KdTreeTraits::PointContainer is not equal to Traits::PointContainer");
81 static_assert(std::is_same<typename Traits::IndexContainer, typename KdTreeTraits::IndexContainer>::value,
82 "KdTreeTraits::IndexContainer is not equal to Traits::IndexContainer");
95#pragma omp parallel for shared(kdtree, cloudSize) default(none)
99 for (
auto n :
kdtree.kNearestNeighbors(
typename KdTreeTraits::IndexType(
i),
100 typename KdTreeTraits::IndexType(m_k)))
102 m_indices[
i * m_k +
j] = n;
161 [[
nodiscard]]
inline size_t size()
const {
return m_indices.size() /
static_cast<size_t>(m_k); }
170 inline const IndexContainer& index_data()
const {
return m_indices; };
Aggregator class used to declare specialized structures using CRTP.
Customizable base class for KnnGraph datastructure.
typename Traits::PointContainer PointContainer
Container for DataPoint used inside the KdTree.
KNearestIndexQuery kNearestNeighborsIndexQuery() const
Convenience function that provides a k-nearest neighbors Query object.
RangeIndexQuery rangeNeighbors(int index, Scalar r) const
Computes a Query object to iterate over the neighbors that are inside a given radius.
typename Traits::DataPoint DataPoint
DataPoint given by user via Traits.
KnnGraphBase(const KdTreeBase< KdTreeTraits > &kdtree, int k=6)
Build a KnnGraph from a KdTreeDense.
RangeIndexQuery rangeNeighborsIndexQuery() const
Convenience function that provides an empty range neighbors Query object.
typename DataPoint::Scalar Scalar
Scalar given by user via DataPoint.
int k() const
Number of neighbor per vertex.
size_t size() const
Number of vertices in the neighborhood graph.
typename Traits::IndexContainer IndexContainer
Container for indices used inside the KdTree.
typename DataPoint::VectorType VectorType
VectorType given by user via DataPoint.
KNearestIndexQuery kNearestNeighbors(int index) const
Computes a Query object to iterate over the k-nearest neighbors of a point.
Extension of the Query class that allows to read the result of a k-nearest neighbors search on the Kn...
Extension of the Query class that allows to read the result of a range neighbor search on the KnnGrap...
This Source Code Form is subject to the terms of the Mozilla Public License, v.