11#ifndef EBGEOMETRY_POINTCLOUD_HPP
12#define EBGEOMETRY_POINTCLOUD_HPP
89 : m_out(a_out), m_k(a_k), m_exclude(a_exclude)
104 insert(
const T a_distanceSquared,
const uint32_t a_index)
noexcept
106 if (a_distanceSquared >= m_bound || a_index == m_exclude) {
110 std::size_t slot = (m_found < m_k) ? m_found++ : (m_k - 1);
112 for (; slot > 0 && m_out[slot - 1].distanceSquared > a_distanceSquared; slot--) {
113 m_out[slot] = m_out[slot - 1];
116 m_out[slot] =
Hit<T>{a_index, a_distanceSquared};
118 if (m_found == m_k) {
119 m_bound = m_out[m_k - 1].distanceSquared;
151 std::size_t m_found = 0;
174 const uint32_t a_numPoints,
176 const std::size_t a_k,
182 KBest<T> best(a_out, a_k, a_exclude);
184 for (uint32_t i = 0; i < a_numPoints; i++) {
185 best.
insert((a_positions[i] - a_query).length2(), i);
206 const uint32_t a_numPoints,
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Utility macros for EBGeometry.
#define EBGEOMETRY_EXPECT(cond)
Runtime precondition assertion for EBGeometry.
Definition EBGeometry_Macros.hpp:155
Scalar helpers and numeric limits that compile for both host and device.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
The k nearest points seen so far, kept sorted in a caller-supplied buffer.
Definition EBGeometry_PointCloud.hpp:79
std::size_t found() const noexcept
Number of candidates held, at most k.
Definition EBGeometry_PointCloud.hpp:142
void insert(const T a_distanceSquared, const uint32_t a_index) noexcept
Offer one candidate.
Definition EBGeometry_PointCloud.hpp:104
KBest(Hit< T > *a_out, const std::size_t a_k, const uint32_t a_exclude=InvalidIndex) noexcept
Start an empty set.
Definition EBGeometry_PointCloud.hpp:88
T bound() const noexcept
The squared distance a candidate must beat to be inserted.
Definition EBGeometry_PointCloud.hpp:131
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
std::size_t closestPointsBruteForce(const Vec3T< T > *a_positions, const uint32_t a_numPoints, const Vec3T< T > &a_query, const std::size_t a_k, Hit< T > *a_out, const uint32_t a_exclude=InvalidIndex) noexcept
The a_k points of a cloud nearest to a query point, by a full scan.
Definition EBGeometry_PointCloud.hpp:173
Hit< T > closestPointBruteForce(const Vec3T< T > *a_positions, const uint32_t a_numPoints, const Vec3T< T > &a_query, const uint32_t a_exclude=InvalidIndex) noexcept
The point of a cloud nearest to a query point, by a full scan.
Definition EBGeometry_PointCloud.hpp:205
constexpr uint32_t InvalidIndex
The cloud index of "no point": a miss, or a result slot a query could not fill.
Definition EBGeometry_PointCloud.hpp:41
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Numeric limits, with the meanings of the std::numeric_limits members of the same names.
Definition EBGeometry_Math.hpp:91
One query result: the cloud index of a matched point and its squared distance.
Definition EBGeometry_PointCloud.hpp:53
T distanceSquared
Squared distance from the query to it.
Definition EBGeometry_PointCloud.hpp:55
bool valid() const noexcept
Whether this is a match rather than a miss.
Definition EBGeometry_PointCloud.hpp:63
uint32_t index
Cloud index of the matched point.
Definition EBGeometry_PointCloud.hpp:54