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
32 PONCA_MULTIARCH
inline NeighborGraphBuffer() =
default;
35 typename Traits::IndexContainerRef _indices,
36 const size_t _points_size,
const size_t _indices_size,
37 typename Traits::IndexContainerRef _ranges)
38 : Base(_points, _indices, _points_size, _indices_size), ranges(_ranges)
53 template <
typename _Traits>
54 class StaticNeighborGraphBase
56 NeighborGraphOneConnectedQuery<StaticNeighborGraphBase<_Traits>>,
57 NeighborGraphRangeQuery<StaticNeighborGraphBase<_Traits>>>
60 WRITE_NEIGHBOR_GRAPH_ALIASES
70 using Buffers =
typename Base::Buffers;
72 PONCA_MULTIARCH
inline StaticNeighborGraphBase(
const Buffers& _bufs) : Base(_bufs) {}
76 PONCA_MULTIARCH [[nodiscard]]
inline int k(
int vId = 0)
const {
return endId(vId) *
beginId(vId); }
80 PONCA_MULTIARCH [[nodiscard]]
inline int endId(
int vId)
const {
return Base::buffers().ranges[vId + 1]; }
84 template <
typename _Traits>
88 WRITE_NEIGHBOR_GRAPH_ALIASES
91 using Base = StaticNeighborGraphBase<Traits>;
92 using Buffers =
typename Base::Buffers;
106 template <
typename KdTreeTraits>
111#define CHECK_TRAITS_TYPENAME_COMPAT(A, B) \
112 static_assert(std::is_same_v<A, B> || std::is_convertible_v<A, B> || std::is_convertible_v<B, A>, \
113 "KdTreeTraits::DataPoint is not equal to Traits::DataPoint");
115 static_assert(std::is_same_v<typename Traits::DataPoint, typename KdTreeTraits::DataPoint>,
116 "KdTreeTraits::DataPoint is not equal to Traits::DataPoint");
121#undef CHECK_TRAITS_TYPENAME_COMPAT
129 PONCA_ASSERT(cloudSize == samplesSize);
135 for (
int i = 0; i < cloudSize; ++i)
137 for (
auto n : _kdtree.
rangeNeighbors(
typename KdTreeTraits::IndexType(i), range))
155 template <
typename DataPo
int>
AbstractNeighborGraph(const Buffers &_bufs)
PointContainerConstRef points() const
const Buffers & buffers() const
Constructor that allows the use of prebuilt KdTree containers.
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
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....
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]
typename Traits::PointContainerConstRef PointContainerConstRef
This Source Code Form is subject to the terms of the Mozilla Public License, v.
NeighborGraphBase< NeighborGraphDefaultTraits< DataPoint > > NeighborGraph
Public interface for the NeighborGraph datastructure.
NeighborGraphBufferBase()=default
Default constructor, might be deleted depending on the PointContainer type (e.g. const reference).
Buffer class for StaticNeighborGraphBase.
typename Traits::PointContainerConstRef PointContainerConstRef
Container for DataPoint used inside the KdTree.
typename Traits::IndexContainer IndexContainer
Container for indices used inside the KdTree.
std::vector< IndexType > IndexContainer
Type used to store the index container in the AbstractNeighborGraph::Buffers.
const PointContainer & PointContainerConstRef
Convenience alias used to convey the constness and the absence of copy of the container.