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

The state and build of a linear BVH over a cloud of primitives (points or spheres), built where its pool is; the base of PointCloudBVH and SphereCloudBVH. More...

#include <EBGeometry_CloudBVH.hpp>

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

Classes

struct  Scratch
 The scratch arrays of a build: in the BVH's pool for a BVH with room for a rebuild, and in a pool of their own, released after the build, otherwise. More...
 
struct  Sizes
 The largest array sizes any cloud of a given size can need; see PointCloudBVH's build steps. More...
 

Public Types

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.
 

Protected Member Functions

 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

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

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).
 

Additional Inherited Members

- 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.
 

Detailed Description

template<class T, size_t K, size_t W, class Prim>
class EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >

The state and build of a linear BVH over a cloud of primitives (points or spheres), built where its pool is; the base of PointCloudBVH and SphereCloudBVH.

Internal; not part of the public API. The build is the one PointCloudBVH describes, step by step: the Morton keys and the cuts come from each primitive's center (Prim::center()), the boxes hold the primitives (Prim::grow()), and the leaves are packed into Prim::Group groups of W.

Template Parameters
TFloating-point precision.
KBVH branching factor.
WPrimitives per leaf group.
PrimThe primitive type; see PointPrimitive.

Member Function Documentation

◆ copyInto()

template<class T , size_t K, size_t W, class Prim >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::copyInto ( CloudBVH< T, K, W, Prim > &  a_copy,
Pool &  a_dstPool 
) const
inlineprotected

Duplicate this object's storage into a_dstPool, for a_copy, a copy of this object: the body of PointCloudBVH::deepCopy().

Parameters
[out]a_copyThe copy, whose arrays are reserved and written.
[in,out]a_dstPoolPool to reserve the copy's arrays from.

◆ initialize() [1/2]

template<class T , size_t K, size_t W, class Prim >
template<class Source >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::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 
)
inlineprotected

Build over the primitives of a source, where the pool's memory is: the body of PointCloudBVH::build().

Template Parameters
SourceThe primitives' source.
Parameters
[in,out]a_poolPool the arrays are reserved from.
[in]a_sourceThe primitives.
[in]a_numItemsNumber of primitives.
[in]a_targetLeafSizeTarget primitives per leaf.
[in]a_maxItemsMost primitives a rebuild may have; 0 for none.
[in]a_whoThe calling function, for the messages.

◆ initialize() [2/2]

template<class T , size_t K, size_t W, class Prim >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::initialize ( Pool &  a_pool,
const std::vector< Item > &  a_items,
std::size_t  a_targetLeafSize,
uint32_t  a_maxItems,
const char *  a_who 
)
inlineprotected

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.

Parameters
[in,out]a_poolPool the arrays are reserved from.
[in]a_itemsThe primitives.
[in]a_targetLeafSizeTarget primitives per leaf.
[in]a_maxItemsMost primitives a rebuild may have; 0 for none.
[in]a_whoThe calling function, for the messages.

◆ rebase()

template<class T , size_t K, size_t W, class Prim >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::rebase ( const Pool &  a_pool)
inlineprotectednoexcept

Resolve this object against a_pool: the body of PointCloudBVH::rebasedView(), on a copy.

Parameters
[in]a_poolThe pool to resolve against.

◆ reinitialize()

template<class T , size_t K, size_t W, class Prim >
template<class Source >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::reinitialize ( const Source &  a_source,
uint32_t  a_numItems,
const char *  a_who 
)
inlineprotected

Build again in the arrays initialize() reserved: the body of PointCloudBVH::rebuild().

Template Parameters
SourceThe primitives' source.
Parameters
[in]a_sourceThe primitives.
[in]a_numItemsNumber of primitives, at most m_maxItems.
[in]a_whoThe calling function, for the messages.

◆ reserveArrays()

template<class T , size_t K, size_t W, class Prim >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::reserveArrays ( Pool &  a_pool,
const Sizes &  a_sizes,
uint32_t  a_numItems 
)
inlineprotected

Reserve the BVH's and the cloud's arrays from a_pool.

Parameters
[in,out]a_poolPool to reserve from; this object is attached to it.
[in]a_sizesArray sizes.
[in]a_numItemsNumber of primitives.

◆ reserveScratch()

template<class T , size_t K, size_t W, class Prim >
static Scratch EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::reserveScratch ( Pool &  a_pool,
uint32_t  a_numItems,
uint32_t  a_leafSize,
const char *  a_who 
)
inlinestaticprotected

Reserve a build's scratch from a_pool, for up to a_numItems primitives.

Parameters
[in,out]a_poolPool to reserve from.
[in]a_numItemsMost primitives.
[in]a_leafSizeThe largest leaf.
[in]a_whoThe calling function, for the messages.
Returns
The scratch arrays.

◆ run()

template<class T , size_t K, size_t W, class Prim >
template<class F >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::run ( std::size_t  a_count,
const F &  a_f 
) const
inlineprotected

Run a build step: through GPU::parallelFor() for a build there, and in a host loop otherwise.

Template Parameters
FThe step's functor.
Parameters
[in]a_countNumber of indices.
[in]a_fThe functor.

◆ scan()

template<class T , size_t K, size_t W, class Prim >
std::uint32_t EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::scan ( std::uint32_t *  a_values,
std::uint32_t  a_count,
std::uint32_t *  a_scratch 
) const
inlineprotected

An exclusive scan, where the build runs; see GPU::exclusiveScan().

Parameters
[in,out]a_valuesThe values.
[in]a_countNumber of values.
[out]a_scratchGPU::exclusiveScanScratchSize(a_count) elements, for a build through GPU::parallelFor().
Returns
The values' sum.

◆ shape()

template<class T , size_t K, size_t W, class Prim >
template<class Source >
Sizes EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::shape ( const Scratch &  a_scratch,
void *  a_base,
const Source &  a_source,
uint32_t  a_numItems,
const char *  a_who 
)
inlineprotected

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 Parameters
SourceThe primitives' source.
Parameters
[in]a_scratchThe scratch arrays.
[in]a_baseBase address of the scratch arrays' pool.
[in]a_sourceThe primitives.
[in]a_numItemsNumber of primitives.
[in]a_whoThe calling function, for the messages.
Returns
The tree's array sizes.

◆ sizesFor()

template<class T , size_t K, size_t W, class Prim >
static Sizes EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::sizesFor ( uint32_t  a_numItems,
uint32_t  a_leafSize,
const char *  a_who 
)
inlinestaticprotectednoexcept

Bounds on the array sizes of a build over a_numItems primitives.

Parameters
[in]a_numItemsNumber of primitives.
[in]a_leafSizeThe largest leaf, max(a_targetLeafSize, K).
[in]a_whoThe calling function, for the messages.
Returns
The bounds.

◆ toHost()

template<class T , size_t K, size_t W, class Prim >
template<class U >
static std::vector< U > EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::toHost ( const PODVector< U > &  a_array,
const void *  a_base 
)
inlinestaticprotected

Copy one pool-resident array back into a host std::vector.

Template Parameters
UElement type.
Parameters
[in]a_arrayArray to read.
[in]a_baseBase address of the pool holding a_array.
Returns
A host copy of the array's elements.

◆ write()

template<class T , size_t K, size_t W, class Prim >
template<class Source >
void EBGeometry::PointCloudDetail::CloudBVH< T, K, W, Prim >::write ( const Scratch &  a_scratch,
void *  a_base,
const Sizes &  a_sizes,
const Source &  a_source,
uint32_t  a_numItems 
)
inlineprotected

Build step 6 (see PointCloudBVH): write the arrays reserved for the tree shape() gave.

Template Parameters
SourceThe primitives' source.
Parameters
[in]a_scratchThe scratch arrays, as shape() left them.
[in]a_baseBase address of the scratch arrays' pool.
[in]a_sizesThe tree's array sizes.
[in]a_sourceThe primitives.
[in]a_numItemsNumber of primitives.

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