EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
EBGeometry::PointCloudBVH< T, K, W > Class Template Reference

A BVH over a point cloud, with a fast build and turnkey queries. More...

#include <EBGeometry_PointCloudBVH.hpp>

Inheritance diagram for EBGeometry::PointCloudBVH< T, K, W >:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::PointCloudBVH< T, K, W >:
Collaboration graph
[legend]

Public Types

using PointGroup = PointAoSoA< T, W >
 The SoA leaf primitive: a group of up to W points carrying their cloud indices.
 
using Packed = BVH::PackedBVH< T, PointGroup, K >
 The packed BVH this class holds over its point groups.
 
using Node = typename Packed::Node
 Flat node type of the held BVH.
 
using AABB = BoundingVolumes::AABBT< T >
 Axis-aligned bounding box type.
 
using Hit = PointCloud::Hit< T >
 One query result: the cloud index of a matched point and its squared distance.
 
- Public Types inherited from EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >
using Item = typename Prim::Item
 What a source of the primitives returns.
 
using Group = typename Prim::Group
 The SoA leaf primitive: a group of up to W primitives carrying their cloud indices.
 
using Packed = BVH::PackedBVH< T, Group, K >
 The packed BVH over the groups.
 
using Node = typename Packed::Node
 Flat node type of the held BVH.
 
using AABB = BoundingVolumes::AABBT< T >
 Axis-aligned bounding box type.
 

Public Member Functions

 PointCloudBVH (Pool &a_pool, const std::vector< Vec3T< T > > &a_positions, std::size_t a_targetLeafSize=16 *W)
 Build a BVH over a point cloud on the host: shorthand for build(a_pool, a_positions, a_targetLeafSize).
 
template<class Source >
void rebuild (const Source &a_source, uint32_t a_numPoints)
 Build the BVH again, in the arrays build() reserved, from new positions.
 
uint32_t maxPoints () const noexcept
 The most points rebuild() can take.
 
Hit closestPoint (const Vec3T< T > &a_query) const noexcept
 Closest cloud point to an arbitrary query point.
 
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.
 
Hit nearestNeighbor (uint32_t a_point) const noexcept
 Nearest other point to a point already in the cloud (seed-from-own-leaf search).
 
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::vector< Hit > allNearestNeighbors (std::size_t a_k=1) const
 For every point, its a_k nearest other points (the k-nearest-neighbor graph).
 
std::size_t numPoints () const noexcept
 Number of points in the cloud.
 
const Vec3T< T > & position (uint32_t a_index) const noexcept
 Position of the point with the given cloud index.
 
Packed getBVH () const noexcept
 The held packed BVH over the point groups.
 
PointCloudBVH rebasedView (const Pool &a_pool) const noexcept
 Produce a copy of this object that resolves against a_pool.
 
PointCloudBVH deepCopy (Pool &a_dstPool) const
 Duplicate this object's storage into a_dstPool.
 
void * base () noexcept
 The base address this object's arrays are offsets from; see PoolHandle::base().
 
const void * base () const noexcept
 The base address this object's arrays are offsets from; see PoolHandle::base().
 
- Public Member Functions inherited from EBGeometry::PoolHandle
PoolLocation location () const noexcept
 Where this handle's arrays live.
 
bool isAttachedTo (const Pool &a_pool) const noexcept
 Check whether this handle's arrays were reserved from a_pool.
 

Static Public Member Functions

template<class Source >
static PointCloudBVH build (Pool &a_pool, const Source &a_source, uint32_t a_numPoints, std::size_t a_targetLeafSize=16 *W, uint32_t a_maxPoints=0)
 Build a BVH over a point cloud, where the pool's memory is.
 
static PointCloudBVH build (Pool &a_pool, const std::vector< Vec3T< T > > &a_positions, std::size_t a_targetLeafSize=16 *W, uint32_t a_maxPoints=0)
 Build a BVH over points on the host, where the pool's memory is; see the build() above.
 

Additional Inherited Members

- Protected Member Functions inherited from EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >
 CloudBVH () noexcept=default
 An empty BVH, to be reserved and filled.
 
template<class Source >
void initialize (Pool &a_pool, const Source &a_source, uint32_t a_numItems, std::size_t a_targetLeafSize, uint32_t a_maxItems, const char *a_who)
 Build over the primitives of a source, where the pool's memory is: the body of PointCloudBVH::build().
 
void initialize (Pool &a_pool, const std::vector< Item > &a_items, std::size_t a_targetLeafSize, uint32_t a_maxItems, const char *a_who)
 Build over the primitives of a host array, where the pool's memory is: for a pool in device memory, the primitives are checked on the host and copied to scratch there first.
 
template<class Source >
void reinitialize (const Source &a_source, uint32_t a_numItems, const char *a_who)
 Build again in the arrays initialize() reserved: the body of PointCloudBVH::rebuild().
 
void rebase (const Pool &a_pool) noexcept
 Resolve this object against a_pool: the body of PointCloudBVH::rebasedView(), on a copy.
 
void copyInto (CloudBVH &a_copy, Pool &a_dstPool) const
 Duplicate this object's storage into a_dstPool, for a_copy, a copy of this object: the body of PointCloudBVH::deepCopy().
 
void reserveArrays (Pool &a_pool, const Sizes &a_sizes, uint32_t a_numItems)
 Reserve the BVH's and the cloud's arrays from a_pool.
 
template<class Source >
Sizes shape (const Scratch &a_scratch, void *a_base, const Source &a_source, uint32_t a_numItems, const char *a_who)
 Build steps 1 to 5 (see PointCloudBVH): the box, the sorted keys, the tree's levels, the subtree sizes, boxes and depth-first indices, and the scans that place the rows and the groups.
 
template<class Source >
void write (const Scratch &a_scratch, void *a_base, const Sizes &a_sizes, const Source &a_source, uint32_t a_numItems)
 Build step 6 (see PointCloudBVH): write the arrays reserved for the tree shape() gave.
 
template<class F >
void run (std::size_t a_count, const F &a_f) const
 Run a build step: through GPU::parallelFor() for a build there, and in a host loop otherwise.
 
std::uint32_t scan (std::uint32_t *a_values, std::uint32_t a_count, std::uint32_t *a_scratch) const
 An exclusive scan, where the build runs; see GPU::exclusiveScan().
 
- Protected Member Functions inherited from EBGeometry::PoolHandle
 PoolHandle () noexcept=default
 An unset location; the first reservation attaches it.
 
 PoolHandle (const PoolLocation &a_location) noexcept
 Adopt a location, as a handle rebuilt from a stored layout does.
 
 PoolHandle (const PoolHandle &) noexcept=default
 Copy a handle, as a derived handle's copy does.
 
 PoolHandle (PoolHandle &&) noexcept=default
 Move a handle; the same as a copy.
 
PoolHandle & operator= (const PoolHandle &) noexcept=default
 Copy-assign a handle, as a derived handle's assignment does.
 
PoolHandle & operator= (PoolHandle &&) noexcept=default
 Move-assign a handle; the same as a copy.
 
 ~PoolHandle () noexcept=default
 Destructor; protected, since a PoolHandle exists only as the base of a handle.
 
void * base () noexcept
 The base address this handle's offsets resolve against; see PoolLocation::base().
 
const void * base () const noexcept
 The base address this handle's offsets resolve against, for read-only access.
 
void attach (const Pool &a_pool, const char *a_who, const bool a_deviceWritten=false) noexcept
 Follow a_pool, as the first reservation does; see PoolLocation::attach().
 
PoolLocation rebasedLocation (const Pool &a_pool, uint64_t a_endByte, const char *a_who) const noexcept
 The location of this handle's arrays in another pool of its mirror chain; see PoolLocation::rebasedOnto().
 
void setLocation (const PoolLocation &a_location) noexcept
 Replace the location, for a view or a copy made by a derived handle.
 
- Static Protected Member Functions inherited from EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >
static Sizes sizesFor (uint32_t a_numItems, uint32_t a_leafSize, const char *a_who) noexcept
 Bounds on the array sizes of a build over a_numItems primitives.
 
static Scratch reserveScratch (Pool &a_pool, uint32_t a_numItems, uint32_t a_leafSize, const char *a_who)
 Reserve a build's scratch from a_pool, for up to a_numItems primitives.
 
template<class U >
static std::vector< U > toHost (const PODVector< U > &a_array, const void *a_base)
 Copy one pool-resident array back into a host std::vector.
 
- Protected Attributes inherited from EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >
Packed::Layout m_bvhLayout
 The packed BVH over the groups, as a layout: it shares this object's location.
 
PODVector< Item > m_items
 The primitives, indexed by cloud index.
 
PODVector< std::uint32_t > m_leafOff
 Per-primitive own-leaf group offset (for seeding).
 
PODVector< std::uint32_t > m_leafCnt
 Per-primitive own-leaf group count (for seeding).
 
PODVector< std::uint32_t > m_order
 Cloud indices in leaf (build) order; the spatially coherent batch-query order.
 
Scratch m_scratch
 The scratch arrays a rebuild uses; empty for a BVH without room for one.
 
std::uint32_t m_maxItems = 0
 The most primitives a rebuild can take, 0 for none.
 
std::uint32_t m_leafSize = 0
 The largest leaf, max(a_targetLeafSize, K): a node of more primitives is cut.
 
std::uint32_t m_depth = 0
 The tree's depth in node levels (the root is level 1), 0 for an empty cloud.
 
bool m_parallel = false
 Whether the build runs through GPU::parallelFor() (the pool's memory is device-accessible).
 

Detailed Description

template<class T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
class EBGeometry::PointCloudBVH< T, K, W >

A BVH over a point cloud, with a fast build and turnkey queries.

Holds a PackedBVH over SoA point groups (rather than deriving from one) together with the cloud data the queries need. Unlike the general PackedBVH builds (which take a list of pre-made primitives and partition it via SAH/Midpoint/SFC), PointCloudBVH is built directly from a raw point cloud, as a linear BVH: the points sorted along a Morton curve, and every node's range of them cut where their codes first differ. build() runs it where the pool's memory is, on a device included, and every side gives the same tree, array for array.

The build, step by step (EBGeometry_CloudBVHImplem.hpp, shared with SphereCloudBVH):

  1. The cloud's box, every coordinate checked finite.
  2. Each point's key: its 63-bit Morton code over the box, its longest side scaled to the code's span, and its cloud index, which breaks ties. The keys are sorted (std::sort on the host, a bitonic sort through GPU::parallelFor()); the keys are distinct, so both give one order.
  3. The tree is grown one level at a time, breadth first. A node holds a range of the sorted points; one of at most max(a_targetLeafSize, K) points is a leaf, and any other is cut into K ranges, its children. The K ranges come from K - 1 binary cuts, made as a midpoint build makes them (the first cut gives K/2 of the parts to the left): a range is cut at the first point whose code has the highest bit where the range's first and last codes differ set, its points so far left of the Morton curve's split plane, or at its middle when every code is equal. Each cut keeps at least floor(n / (4K)) points (and one) per part on either side, n the node's size: a cut further out is moved in to that quota. The quota bounds the node count (every leaf below an interior node holds at least floor((max(a_targetLeafSize, K) + 1) / (4K)) points), which is what lets build() reserve room for a rebuild of any cloud of a given size. It also bounds a child at about (3K + 1) / (4K) of its parent, which does not keep every cloud within BVH::DeviceTraversalDepth levels: a cloud whose codes are made to leave each cut its smallest part does not. So the levels from DeviceTraversalDepth + 1 - H on, H being the levels a tree of all the points cut into K equal parts needs, are cut into K parts of equal count instead, which keeps every tree within that depth, on the host and on a device. A real cloud reaches its leaves long before (level 25 for a million points in leaves of 64 at K = 4), so its tree is the Morton cuts' alone. Each level is one launch: a node's children go at the next level's offset plus K times its rank among the level's interior nodes (an exclusive scan).
  4. Each node's subtree size, the levels from the deepest up, with each node's box; then each node's depth-first index, from the root down. The node array is in depth-first order, and its leaves are in the sorted points' order.
  5. The child-box rows (one per interior node, in depth-first order), and each leaf's groups of W points (in depth-first order), placed by two exclusive scans over the nodes in depth-first order.
  6. Every node written by its own thread: its children's depth-first indices, its row, its children's boxes into that row, its box slot; a leaf also packs its groups and writes, for each of its points, the position (by cloud index), the leaf tables and the point's place in the leaf order.

A cut that needs no median or sort of its range is what makes the tree the same on every side, and cheap to build on a device. The alternatives: a top-down longest-axis midpoint build, the reference below, partitions each range around a coordinate and has no cheap device form; spreading the Morton-sorted points evenly over a perfect K-ary tree queried 1.2-8.6x slower than it (500,000 points, host and an RTX 3080); a prototype of these radix cuts with a quarter-share quota per binary cut queried within about 10% of it (faster on a uniform cube, slower on a sphere's surface). A half-share quota cost about 10% more on the sphere.

Every leaf lane carries its point's cloud index (its position in the input positions array), and queries return that index in a PointCloud::Hit. Per-point user data lives in the caller's own array, indexed by it. PointCloudHashGrid answers the same queries with the same Hit type. The class hides all of traverse()/the SoA leaf kernel/the seed-from-own-leaf optimization behind a few high-level query methods.

Note
Queries come in two flavours. External queries (closestPoint / closestPoints) take an arbitrary point and traverse top-down. Self queries (nearestNeighbor / nearestNeighbors), and the batch allNearestNeighbors(), take a point already in the cloud and additionally seed the search bound from the leaf that point lives in (skipping that leaf during traversal) – a strictly cheaper search that an external point cannot use.
Device portability. The held PackedBVH and every cloud array (positions, the seeding tables, the leaf order) are reserved from the same Pool, and the class stores only offsets into it, so a PointCloudBVH is trivially copyable. Mirror the pool, call rebasedView(), and pass the returned value into a kernel; every query that answers through a caller-supplied buffer (closestPoint(s), nearestNeighbor(s)) is device-callable. allNearestNeighbors() returns a std::vector and stays host-only.
Template Parameters
TFloating-point precision.
KBVH branching factor. Defaults to BVH::DefaultBranchingRatio<T>().
WPoints per SoA leaf lane group. Defaults to PointSoA::DefaultWidth<T>().

Member Typedef Documentation

◆ Hit

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
using EBGeometry::PointCloudBVH< T, K, W >::Hit = PointCloud::Hit<T>

One query result: the cloud index of a matched point and its squared distance.

Shared with PointCloudHashGrid. A miss, and every result slot a multi-result query could not fill, has Hit::valid() false; those queries also return the count found.

Constructor & Destructor Documentation

◆ PointCloudBVH()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
EBGeometry::PointCloudBVH< T, K, W >::PointCloudBVH ( Pool &  a_pool,
const std::vector< Vec3T< T > > &  a_positions,
std::size_t  a_targetLeafSize = 16 *W 
)
inline

Build a BVH over a point cloud on the host: shorthand for build(a_pool, a_positions, a_targetLeafSize).

A point's cloud index, which the queries report, is its position in a_positions.

Parameters
[in,out]a_poolPool the packed BVH and the cloud arrays are reserved from; must outlive this object.
[in]a_positionsPoint positions. At most 2^31, all finite.
[in]a_targetLeafSizeTarget points per leaf (a node of at most max(a_targetLeafSize, K) points is a leaf). Must be at least 1.

Member Function Documentation

◆ allNearestNeighbors()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
std::vector< Hit > EBGeometry::PointCloudBVH< T, K, W >::allNearestNeighbors ( std::size_t  a_k = 1) const
inline

For every point, its a_k nearest other points (the k-nearest-neighbor graph).

Processes points in leaf (build) order – already spatially coherent, so consecutive queries touch nearby leaves and stay hot in cache, with no per-call sort – and seeds each from its own leaf, so the whole batch is cheaper than the sum of independent queries. Result is flattened row-major: entry [i*a_k + j] is the j-th nearest neighbor of point i (ascending by distance).

Parameters
[in]a_kNumber of neighbors per point.
Returns
A vector of size numPoints()*a_k of Hits.

◆ base() [1/2]

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
const void * EBGeometry::PoolHandle::base ( ) const
inlinenoexcept

The base address this object's arrays are offsets from; see PoolHandle::base().

Returns
The base address: const void* for a const object, void* otherwise.

◆ base() [2/2]

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
void * EBGeometry::PoolHandle::base ( )
inlinenoexcept

The base address this object's arrays are offsets from; see PoolHandle::base().

Returns
The base address: const void* for a const object, void* otherwise.

◆ build() [1/2]

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
template<class Source >
static PointCloudBVH EBGeometry::PointCloudBVH< T, K, W >::build ( Pool &  a_pool,
const Source &  a_source,
uint32_t  a_numPoints,
std::size_t  a_targetLeafSize = 16 *W,
uint32_t  a_maxPoints = 0 
)
inlinestatic

Build a BVH over a point cloud, where the pool's memory is.

A point's cloud index, which the queries report, is the index the source is called with. The build (see the class) runs where the pool's memory is. In device-accessible memory (device or managed memory in a CUDA or HIP build; emulated device memory in a host build) it runs through GPU::parallelFor(): kernels in a CUDA or HIP translation unit, which read a_source on the device, and host loops otherwise. In host memory it runs on the host, which reads a_source there. Both give the same tree, array for array. The build reads each point from the source four times (for the box, its key, its leaf's box and its group), so an expensive source pays that. A point with a non-finite coordinate is rejected: on the host by its index, through GPU::parallelFor() only as "a point". The tree is at most BVH::DeviceTraversalDepth levels deep whatever the points (see the class), so no arrangement of them makes the build fail, and every tree can be queried on a device. Freeze the pool and take rebasedView() to query a BVH in device memory in a kernel.

The scratch arrays (the keys, the box, the build's nodes and two scans' values) are reserved from a second pool on the same memory resource and released on return, and the BVH's arrays at the sizes this cloud needs, unless a_maxPoints is given: then the arrays are reserved at the largest sizes any cloud of that many points can need (more than a uniform cloud uses), and the scratch in the BVH's pool too, so that rebuild() reserves nothing and works on a frozen pool.

Template Parameters
SourceA source of positions: a trivially copyable type whose const call operator takes a cloud index (uint32_t) and returns that point's Vec3T<T>; see PointCloud::FromArray.
Parameters
[in,out]a_poolPool the BVH's arrays are reserved from; must outlive the BVH.
[in]a_sourceThe positions.
[in]a_numPointsNumber of points. At most 2^31, all finite.
[in]a_targetLeafSizeTarget points per leaf (a node of at most max(a_targetLeafSize, K) points is a leaf). Must be at least 1.
[in]a_maxPointsMost points a rebuild() may have; 0 for no rebuild(), and the arrays this cloud needs only. At least a_numPoints otherwise.
Returns
The BVH.

◆ build() [2/2]

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
static PointCloudBVH EBGeometry::PointCloudBVH< T, K, W >::build ( Pool &  a_pool,
const std::vector< Vec3T< T > > &  a_positions,
std::size_t  a_targetLeafSize = 16 *W,
uint32_t  a_maxPoints = 0 
)
inlinestatic

Build a BVH over points on the host, where the pool's memory is; see the build() above.

For a pool in device memory, the positions are first copied to scratch there.

Parameters
[in,out]a_poolPool the BVH's arrays are reserved from; must outlive the BVH.
[in]a_positionsPoint positions. At most 2^31, all finite.
[in]a_targetLeafSizeTarget points per leaf. Must be at least 1.
[in]a_maxPointsMost points a rebuild() may have (see the build() above).
Returns
The BVH.

◆ closestPoint()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
Hit EBGeometry::PointCloudBVH< T, K, W >::closestPoint ( const Vec3T< T > &  a_query) const
inlinenoexcept

Closest cloud point to an arbitrary query point.

Parameters
[in]a_queryQuery point (need not be in the cloud).
Returns
The nearest point and its squared distance.

◆ closestPoints()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
std::size_t EBGeometry::PointCloudBVH< T, K, W >::closestPoints ( const Vec3T< T > &  a_query,
std::size_t  a_k,
Hit *  a_out 
) const
inlinenoexcept

The a_k closest cloud points to an arbitrary query point, nearest first.

Parameters
[in]a_queryQuery point (need not be in the cloud).
[in]a_kNumber of neighbors requested.
[out]a_outBuffer of at least a_k Hits; filled [0, returned count), ascending by distance.
Returns
The number of neighbors found (min(a_k, cloud size)).

◆ deepCopy()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
PointCloudBVH EBGeometry::PointCloudBVH< T, K, W >::deepCopy ( Pool &  a_dstPool) const
inline

Duplicate this object's storage into a_dstPool.

The copy constructor copies descriptors only, leaving both objects resolving against the same pool memory. This is the operation that gives genuinely independent storage. It reads this object's arrays on the host, so their pool must be host-accessible (mirror a pool in device memory to the host first), and a_dstPool must be a host pool. The copy holds the arrays at the sizes the tree uses, with no room for a rebuild().

Parameters
[in,out]a_dstPoolPool to reserve the copy's arrays from.
Returns
A PointCloudBVH with the same tree and cloud, backed by a_dstPool.

◆ getBVH()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
Packed EBGeometry::PointCloudBVH< T, K, W >::getBVH ( ) const
inlinenoexcept

The held packed BVH over the point groups.

For callers that want the general PackedBVH interface (bounding volume, a custom traverse(), ...) on top of the turnkey queries above.

Returns
The packed BVH.

◆ maxPoints()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
uint32_t EBGeometry::PointCloudBVH< T, K, W >::maxPoints ( ) const
inlinenoexcept

The most points rebuild() can take.

Returns
build()'s a_maxPoints; 0 for a BVH built without room for a rebuild.

◆ nearestNeighbor()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
Hit EBGeometry::PointCloudBVH< T, K, W >::nearestNeighbor ( uint32_t  a_point) const
inlinenoexcept

Nearest other point to a point already in the cloud (seed-from-own-leaf search).

Parameters
[in]a_pointCloud index of the query point; excluded from its own result.
Returns
The nearest other point and its squared distance.

◆ nearestNeighbors()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
std::size_t EBGeometry::PointCloudBVH< T, K, W >::nearestNeighbors ( uint32_t  a_point,
std::size_t  a_k,
Hit *  a_out 
) const
inlinenoexcept

The a_k nearest other points to a point already in the cloud, nearest first.

Parameters
[in]a_pointCloud index of the query point; excluded from its own result.
[in]a_kNumber of neighbors requested.
[out]a_outBuffer of at least a_k Hits; filled [0, returned count), ascending.
Returns
The number of neighbors found (min(a_k, cloud size - 1)).

◆ numPoints()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
std::size_t EBGeometry::PointCloudBVH< T, K, W >::numPoints ( ) const
inlinenoexcept

Number of points in the cloud.

Returns
The point count.

◆ position()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
const Vec3T< T > & EBGeometry::PointCloudBVH< T, K, W >::position ( uint32_t  a_index) const
inlinenoexcept

Position of the point with the given cloud index.

Parameters
[in]a_indexCloud index.
Returns
The point's position.

◆ rebasedView()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
PointCloudBVH EBGeometry::PointCloudBVH< T, K, W >::rebasedView ( const Pool &  a_pool) const
inlinenoexcept

Produce a copy of this object that resolves against a_pool.

Same contract as PackedBVH::rebasedView(): mirror the pool first, then rebase, then copy the returned value into a kernel. The BVH and the cloud arrays are offsets into one pool, so rebasing the one location rebases everything. Every tree a build makes is shallow enough for a device traversal (see build()).

Pool devicePool = Pool::mirror(hostPool, deviceMemoryResource());
const auto deviceCloud = cloud.rebasedView(devicePool);
myKernel<<<blocks, threads>>>(deviceCloud, ...);
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:205
static Pool mirror(const Pool &a_src, MemoryResource &a_dstResource)
Mirror a frozen pool's whole block into another resource.
DeviceMemoryResource & deviceMemoryResource() noexcept
Process-wide default device memory resource.
Parameters
[in]a_poolPool to rebase onto: the object's own pool or one in its mirror chain.
Returns
A copy of this object resolving against a_pool.

◆ rebuild()

template<class T , size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = PointSoA::DefaultWidth<T>()>
template<class Source >
void EBGeometry::PointCloudBVH< T, K, W >::rebuild ( const Source &  a_source,
uint32_t  a_numPoints 
)
inline

Build the BVH again, in the arrays build() reserved, from new positions.

The same tree as a new build() from these positions with the same target leaf size, reserving nothing in the pool: it runs where the build did, and works on a frozen pool (the host keeps one small vector of level offsets). Needs room reserved by build()'s a_maxPoints; more points than maxPoints() is rejected, and a non-finite point aborts, as in build(). A view taken with rebasedView() before the rebuild still describes the old tree (its array sizes): take a new one, which copies nothing. Call it on the BVH build() returned, not on a view or a deepCopy().

Template Parameters
SourceA source of positions, as for build().
Parameters
[in]a_sourceThe positions.
[in]a_numPointsNumber of points, at most maxPoints(). All finite.

The documentation for this class was generated from the following file: