EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | List of all members
EBGeometry::BVH::ValueStorage< P > Struct Template Reference

Storage policy that stores primitives directly by value, with no pointer indirection at all. More...

#include <EBGeometry_BVH.hpp>

Public Types

using StorageType = P
 Storage representation: the primitive itself, stored by value.
 

Static Public Member Functions

static const Pget (const StorageType &a_stored) noexcept
 Identity access – the stored element already is the primitive.
 
static void appendTreeLeaf (std::vector< StorageType > &a_dst, const PrimitiveList< P > &a_leafPrims)
 Append one TreeBVH leaf's primitives to PackedBVH's flat primitive array.
 
static void appendAliased (std::vector< StorageType > &a_dst, const std::shared_ptr< std::vector< P > > &a_block)
 Materialise a converting packWith() constructor's single contiguous conversion buffer into PackedBVH's flat primitive array.
 

Detailed Description

template<class P>
struct EBGeometry::BVH::ValueStorage< P >

Storage policy that stores primitives directly by value, with no pointer indirection at all.

Removes the per-primitive heap allocation and pointer-chasing that SharedPtrStorage

pays on every leaf visit – worthwhile when P is a self-contained value type (no shared ownership needed) and leaves are visited often, e.g. a nearest-neighbor search over a point cloud.

Template Parameters
PPrimitive type.

Member Function Documentation

◆ appendAliased()

template<class P >
static void EBGeometry::BVH::ValueStorage< P >::appendAliased ( std::vector< StorageType > &  a_dst,
const std::shared_ptr< std::vector< P > > &  a_block 
)
inlinestatic

Materialise a converting packWith() constructor's single contiguous conversion buffer into PackedBVH's flat primitive array.

Like SharedPtrStorage

's equivalent, this appends a_block to a_dst, so the two policies honour the same contract regardless of how many times it is called. When a_dst is still empty (the case for PackedBVH's single-call converting constructor) it takes the fast path of stealing the already-contiguous buffer wholesale – no aliasing shared_ptr machinery, no control-block allocation, and no per-element move; otherwise it move-appends each element.

Parameters
[in,out]a_dstPackedBVH's flat primitive array.
[in]a_blockSingle contiguous buffer holding every converted primitive.

◆ appendTreeLeaf()

template<class P >
static void EBGeometry::BVH::ValueStorage< P >::appendTreeLeaf ( std::vector< StorageType > &  a_dst,
const PrimitiveList< P > &  a_leafPrims 
)
inlinestatic

Append one TreeBVH leaf's primitives to PackedBVH's flat primitive array.

Used by PackedBVH's identity pack() constructor. TreeBVH's own leaf primitives are always shared_ptr<const P> (TreeBVH itself is unaffected by the packed BVH's storage policy), so this policy dereferences and copies each one by value; unavoidable here, since the source is shared_ptr-based regardless of the destination policy.

Parameters
[in,out]a_dstPackedBVH's flat primitive array.
[in]a_leafPrimsOne TreeBVH leaf's primitive list.

◆ get()

template<class P >
static const P & EBGeometry::BVH::ValueStorage< P >::get ( const StorageType a_stored)
inlinestaticnoexcept

Identity access – the stored element already is the primitive.

Parameters
[in]a_storedStored element.
Returns
Reference to the primitive.

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