9#include "abstractNeighborGraph.h"
10#include "Query/neighborGraphOneConnectedQuery.h"
11#include "Query/neighborGraphRangeQuery.h"
13#include "../KdTree/kdTree.h"
24 template <
typename _Traits>
27 WRITE_NEIGHBOR_GRAPH_ALIASES
35 const size_t _points_size,
const size_t _indices_size,
36 typename Traits::IndexContainerRef _ranges)
37 :
Base(_points, _indices, _points_size, _indices_size), ranges(_ranges)
52 template <
typename _Traits>
55 NeighborGraphOneConnectedQuery<StaticNeighborGraphBase<_Traits>>,
56 NeighborGraphRangeQuery<StaticNeighborGraphBase<_Traits>>>
59 WRITE_NEIGHBOR_GRAPH_ALIASES
69 using Buffers =
typename Base::Buffers;
75 PONCA_MULTIARCH [[nodiscard]]
inline int k(
int vId = 0)
const {
return endId(vId) *
beginId(vId); }
79 PONCA_MULTIARCH [[nodiscard]]
inline int endId(
int vId)
const {
return Base::buffers().ranges[vId + 1]; }
83 template <
typename _Traits>
87 WRITE_NEIGHBOR_GRAPH_ALIASES
91 using Buffers =
typename Base::Buffers;
105 template <
typename KdTreeTraits>
110#define CHECK_TRAITS_TYPENAME_COMPAT(A, B) \
111 static_assert(std::is_same_v<A, B> || std::is_convertible_v<A, B> || std::is_convertible_v<B, A>, \
112 "KdTreeTraits::DataPoint is not equal to Traits::DataPoint");
114 static_assert(std::is_same_v<typename Traits::DataPoint, typename KdTreeTraits::DataPoint>,
115 "KdTreeTraits::DataPoint is not equal to Traits::DataPoint");
117 CHECK_TRAITS_TYPENAME_COMPAT(
typename Traits::PointContainer,
typename KdTreeTraits::PointContainer)
118 CHECK_TRAITS_TYPENAME_COMPAT(
typename Traits::IndexContainer,
typename KdTreeTraits::IndexContainer)
120#undef CHECK_TRAITS_TYPENAME_COMPAT
128 PONCA_ASSERT(cloudSize == samplesSize);
134 for (
int i = 0; i < cloudSize; ++i)
136 for (
auto n : _kdtree.
rangeNeighbors(
typename KdTreeTraits::IndexType(i), range))
154 template <
typename DataPo
int>
Base class for neighbor graphs.
PointContainer points() const
Get the internal point container.
Buffers m_bufs
Buffers used to store the KnnGraph.
const Buffers & buffers() const
Get access to the internal buffer, for instance to prepare GPU binding.
NeighborGraphBase(const KdTreeBase< KdTreeTraits > &_kdtree, const Scalar range)
Build a neighbor graph by connecting all points using Euclidean range queries: two points.
typename Traits::IndexType IndexType
Type used to index points into the PointContainer.
typename DataPoint::Scalar Scalar
Scalar given by user via DataPoint
Extension of the Query class that allows to read the neighbors that are directly connected to the que...
Extension of the Query class that allows to read the result of a range neighbor search on the KnnGrap...
IndexType pointCount() const
Get the number of points.
IndexType sampleCount() const
Get the number of indices.
KdTreeRangePointQuery< Traits > rangeNeighbors(const VectorType &point, Scalar r) const
Computes a Query object to iterate over the neighbors that are inside a given radius....
Static generic neighbor graph (does not include build functions)
typename Traits::PointContainer PointContainer
Container for DataPoint used inside the KdTree
int endId(int vId) const
Index of the end of the neighborhood range (see storing convention in NeighborGraphBuffer)
_Traits Traits
Alias to the Traits type
int beginId(int vId) const
Index of the beginning of the neighborhood range (see storing convention in NeighborGraphBuffer)
int k(int vId=0) const
[Neighbor Graph Accessors]
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Internal structure storing the buffers used by a neighbor graph.
size_t points_size
Number of points in the graph.
size_t indices_size
Number of connections in the graph.
IndexContainer indices
Buffer storing the indices associating the input points to the nodes.
Buffer class for StaticNeighborGraphBase.
typename Traits::IndexContainer IndexContainer
Container for indices used inside the KdTree
typename Traits::PointContainerConstRef PointContainerConstRef
Container for DataPoint used inside the KdTree