12#ifndef EBGEOMETRY_POINTCLOUDHASHGRID_HPP
13#define EBGEOMETRY_POINTCLOUDHASHGRID_HPP
119 template <
class Source>
122 build(
Pool& a_pool,
const Source& a_source, uint32_t a_numPoints, T a_targetPerCell = T(1), uint32_t a_maxPoints = 0);
135 build(
Pool& a_pool,
const std::vector<
Vec3T<T>>& a_positions, T a_targetPerCell = T(1), uint32_t a_maxPoints = 0);
152 template <
class Source>
155 rebuild(
const Source& a_source, uint32_t a_numPoints, T a_targetPerCell = T(1));
165 return m_positions.m_capacity;
176 template <
class Source>
189 template <
class Source>
241 inline std::vector<Hit>
252 return m_positions.size();
268 return m_positions.at(
base, m_slotOf.
at(
base, a_index));
315 reserveArrays(
Pool& a_pool, uint32_t a_maxPoints, uint32_t a_maxCells);
325 template <class Source>
327 inline BoundingVolumes::AABBT<T>
328 boxOf(const Source& a_source, uint32_t a_numPoints, const
char* a_who);
337 template <class Source>
340 fill(const Source& a_source, uint32_t a_numPoints);
355 setShape(const
Vec3T<T>& a_lo,
356 const
Vec3T<T>& a_hi,
357 std::
size_t a_numPoints,
359 std::
size_t a_cellCap = Math::Limits<std::
size_t>::
max()) noexcept;
367 numCells() const noexcept
369 return std::size_t(m_nx) * std::size_t(m_ny) * std::size_t(m_nz);
381 cellCoord(T a_x, T a_lo,
int a_n)
const noexcept;
392 cellIndex(
int a_ix,
int a_iy,
int a_iz)
const noexcept;
401 cellIndexOf(
const Vec3T<T>& a_p)
const noexcept;
414 query(
const Vec3T<T>& a_query, std::size_t a_k,
Hit* a_out, uint32_t a_exclude)
const noexcept;
449 bool m_parallel =
false;
469 int m_nx = 1, m_ny = 1, m_nz = 1;
476static_assert(std::is_trivially_copyable_v<PointCloudHashGrid<float>>,
477 "PointCloudHashGrid<float> must be trivially copyable");
478static_assert(std::is_trivially_copyable_v<PointCloudHashGrid<double>>,
479 "PointCloudHashGrid<double> must be trivially copyable");
483#include "EBGeometry_PointCloudHashGridBuildImplem.hpp"
484#include "EBGeometry_PointCloudHashGridImplem.hpp"
Declarations of bounding volume types used in bounding volume hierarchies.
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
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
#define EBGEOMETRY_EXPECT(cond)
Runtime precondition assertion for EBGeometry.
Definition EBGeometry_Macros.hpp:269
Scalar helpers and numeric limits that compile for both host and device.
Placement-independent POD array views for the GPU memory foundation.
Query results and helpers shared by the point-cloud search structures.
Growable bump arena for the GPU memory foundation.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
A uniform spatial grid specialized for point clouds, with a fast build and turnkey queries.
Definition EBGeometry_PointCloudHashGrid.hpp:71
std::vector< Hit > allNearestNeighbors(std::size_t a_k=1) const
For every point, its a_k nearest other points (the k-nearest-neighbor graph).
void rebuild(const Source &a_source, uint32_t a_numPoints, T a_targetPerCell=T(1))
Build the grid again, in the arrays build() reserved, from new positions.
PointCloudHashGrid deepCopy(Pool &a_dstPool) const
Duplicate this object's storage into a_dstPool.
const Vec3T< T > & position(uint32_t a_index) const noexcept
Position of the point with the given cloud index.
Definition EBGeometry_PointCloudHashGrid.hpp:262
Hit nearestNeighbor(uint32_t a_point) const noexcept
Nearest other point to a point already in the cloud.
std::size_t numPoints() const noexcept
Number of points in the cloud.
Definition EBGeometry_PointCloudHashGrid.hpp:250
static PointCloudHashGrid build(Pool &a_pool, const Source &a_source, uint32_t a_numPoints, T a_targetPerCell=T(1), uint32_t a_maxPoints=0)
Build a uniform grid over a point cloud, where the pool's memory is.
uint32_t maxPoints() const noexcept
The most points rebuild() can take.
Definition EBGeometry_PointCloudHashGrid.hpp:163
PointCloudHashGrid rebasedView(const Pool &a_pool) const noexcept
Produce a copy of this object that resolves against a_pool.
PointCloud::Hit< T > Hit
One query result: the cloud index of a matched point and its squared distance.
Definition EBGeometry_PointCloudHashGrid.hpp:78
PointCloudHashGrid(Pool &a_pool, const std::vector< Vec3T< T > > &a_positions, T a_targetPerCell=T(1))
Build a uniform grid over a point cloud: build(a_pool, a_positions, a_targetPerCell).
static PointCloudHashGrid build(Pool &a_pool, const std::vector< Vec3T< T > > &a_positions, T a_targetPerCell=T(1), uint32_t a_maxPoints=0)
Build a uniform grid over points on the host, where the pool's memory is; see the build() above.
std::size_t nearestNeighbors(uint32_t a_point, std::size_t a_k, Hit *a_out) const noexcept
The a_k nearest other points to a point already in the cloud, nearest first.
std::size_t closestPoints(const Vec3T< T > &a_query, std::size_t a_k, Hit *a_out) const noexcept
The a_k closest cloud points to an arbitrary query point, nearest first.
void * base() noexcept
The base address this object's arrays are offsets from; see PoolHandle::base().
Definition EBGeometry_Pool.hpp:639
Hit closestPoint(const Vec3T< T > &a_query) const noexcept
Closest cloud point to an arbitrary query point.
Base of every pool-resident handle: the one PoolLocation its arrays resolve against.
Definition EBGeometry_Pool.hpp:563
void * base() noexcept
The base address this handle's offsets resolve against; see PoolLocation::base().
Definition EBGeometry_Pool.hpp:639
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:205
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Vec2T< T > max(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Component-wise maximum of two vectors.
Placement-independent descriptor of a POD array inside a Pool.
Definition EBGeometry_PODVector.hpp:131
T & at(void *a_base, uint32_t a_i) const noexcept
Mutable element access against a_base.
Definition EBGeometry_PODVector.hpp:220
A build through GPU::parallelFor(): each slot's cloud index and position, in cell order,...
Definition EBGeometry_PointCloudHashGrid.hpp:190
A build through GPU::parallelFor(): the sort key of every point, (cell << 32) | cloud index,...
Definition EBGeometry_PointCloudHashGrid.hpp:177
One query result: the cloud index of a matched point and its squared distance.
Definition EBGeometry_PointCloud.hpp:53