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

BVH-accelerated smooth union of many primitives of one type. More...

#include <EBGeometry_BVHUnion.hpp>

Inheritance diagram for EBGeometry::BVHSmoothUnion< T, P, K, Blend >:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::BVHSmoothUnion< T, P, K, Blend >:
Collaboration graph
[legend]

Classes

struct  Layout
 The smooth union's arrays and parameters, with no location: what an outer union stores when this one is its primitive (see PoolHandle). More...
 

Public Types

using Root = BVH::PackedBVH< T, CSGDetail::Stored< P >, K >
 Alias for the packed BVH type. Its primitives are P, or P's layout for a pool-resident P.
 
using BV = BoundingVolumes::AABBT< T >
 Alias for the bounding volume type.
 

Public Member Functions

 BVHSmoothUnion ()=delete
 Disallowed, use the full constructor.
 
 BVHSmoothUnion (Pool &a_pool, const std::vector< P > &a_primitives, const std::vector< BV > &a_boundingVolumes, T a_smoothLen, Blend a_blend=Blend{}, BVH::Construction a_construction=BVH::Construction::SAH)
 Build the smooth union.
 
 BVHSmoothUnion (Pool &a_pool, const std::vector< P > &a_primitives, const std::vector< BV > &a_boundingVolumes, T a_smoothLen, Blend a_blend, BVH::Construction a_construction, const BVH::ConstructionOptions &a_options)
 Build the smooth union with leaf-size settings.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Evaluate the smooth union at a point.
 
BV computeBoundingVolume () const noexcept
 The axis-aligned bounding box enclosing all primitives.
 
Root getBVH () const noexcept
 Get the packed BVH over the primitives whose bounding box is bounded.
 
PODSpan< const CSGDetail::Stored< P > > getUnboundedPrimitives () const noexcept
 Get the primitives whose bounding box is unbounded, which every query evaluates.
 
BVHSmoothUnion rebasedView (const Pool &a_pool) const noexcept
 Produce a copy of this smooth union that resolves against a_pool; see BVHUnion::rebasedView().
 
BVHSmoothUnion deepCopy (Pool &a_dstPool) const
 Duplicate this smooth union's storage into a_dstPool; see BVHUnion::deepCopy().
 
 BVHSmoothUnion (const Layout &a_layout, const PoolLocation &a_location) noexcept
 Rebuild a handle from a stored layout and the location of the pool that holds it; see BVHUnion.
 
Layout layout () const noexcept
 The union's arrays and parameters without its location, for storing it inside an outer union.
 
- 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

static BVH::ConstructionOptions defaultConstructionOptions () noexcept
 The leaf-size settings the constructor without options uses; the same as BVHUnion's.
 

Static Public Attributes

static constexpr DistanceQuality distanceQuality
 How far signedDistance() can be trusted as a distance: a bound, or only a sign if the primitives' values are not distances. SmoothMinOp and ExpMinOp weight the two primitives' gradients by weights that sum to one, so they do not make the blend steeper than its inputs.
 

Additional Inherited Members

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

Detailed Description

template<class T, class P, size_t K, class Blend = SmoothMinOp<T>>
class EBGeometry::BVHSmoothUnion< T, P, K, Blend >

BVH-accelerated smooth union of many primitives of one type.

Uses the BVH to find the two primitives with the smallest values and blends those values with a smooth-minimum operator, yielding C1 (or better) blending across nearby surfaces with sub-linear query cost. Otherwise identical to BVHUnion: a plain, trivially copyable value type whose signedDistance() is callable on the host and on a device.

Template Parameters
TFloating-point precision.
PPrimitive type; see BVHUnion.
KBVH branching factor.
BlendSmooth-minimum operator: a trivially copyable function object with an EBGEOMETRY_HOST_DEVICE T operator()(const T& a, const T& b, const T& s) const, such as SmoothMinOp (the default) or ExpMinOp.

Constructor & Destructor Documentation

◆ BVHSmoothUnion() [1/3]

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
EBGeometry::BVHSmoothUnion< T, P, K, Blend >::BVHSmoothUnion ( Pool &  a_pool,
const std::vector< P > &  a_primitives,
const std::vector< BV > &  a_boundingVolumes,
T  a_smoothLen,
Blend  a_blend = Blend{},
BVH::Construction  a_construction = BVH::Construction::SAH 
)

Build the smooth union.

Parameters
[in,out]a_poolPool the BVH is reserved from; see BVHUnion.
[in]a_primitivesPrimitives (must be non-empty).
[in]a_boundingVolumesBounding box of each primitive (same length as a_primitives).
[in]a_smoothLenSmoothing length (must be > 0).
[in]a_blendSmooth-minimum operator.
[in]a_constructionPreset construction method; every BVH::Construction value is supported. The leaf sizes are defaultConstructionOptions().

◆ BVHSmoothUnion() [2/3]

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
EBGeometry::BVHSmoothUnion< T, P, K, Blend >::BVHSmoothUnion ( Pool &  a_pool,
const std::vector< P > &  a_primitives,
const std::vector< BV > &  a_boundingVolumes,
T  a_smoothLen,
Blend  a_blend,
BVH::Construction  a_construction,
const BVH::ConstructionOptions &  a_options 
)

Build the smooth union with leaf-size settings.

As the constructor without options, which uses defaultConstructionOptions(). The chosen method reads only its own field of a_options; see BVH::ConstructionOptions.

Parameters
[in,out]a_poolPool the BVH is reserved from; see BVHUnion.
[in]a_primitivesPrimitives (must be non-empty).
[in]a_boundingVolumesBounding box of each primitive (same length as a_primitives).
[in]a_smoothLenSmoothing length (must be > 0).
[in]a_blendSmooth-minimum operator.
[in]a_constructionPreset construction method; every BVH::Construction value is supported.
[in]a_optionsLeaf-size settings, in primitives.

◆ BVHSmoothUnion() [3/3]

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
EBGeometry::BVHSmoothUnion< T, P, K, Blend >::BVHSmoothUnion ( const Layout &  a_layout,
const PoolLocation &  a_location 
)
inlinenoexcept

Rebuild a handle from a stored layout and the location of the pool that holds it; see BVHUnion.

Parameters
[in]a_layoutThe union's arrays and parameters.
[in]a_locationWhere they live.

Member Function Documentation

◆ computeBoundingVolume()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
BV EBGeometry::BVHSmoothUnion< T, P, K, Blend >::computeBoundingVolume ( ) const
inlinenoexcept

The axis-aligned bounding box enclosing all primitives.

Returns
The BVH's root box merged with the boxes of the unbounded primitives.

◆ deepCopy()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
BVHSmoothUnion EBGeometry::BVHSmoothUnion< T, P, K, Blend >::deepCopy ( Pool &  a_dstPool) const
inline

Duplicate this smooth union's storage into a_dstPool; see BVHUnion::deepCopy().

Parameters
[in,out]a_dstPoolPool to reserve the copy from.
Returns
A BVHSmoothUnion with the same structure, backed by a_dstPool.

◆ defaultConstructionOptions()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
static BVH::ConstructionOptions EBGeometry::BVHSmoothUnion< T, P, K, Blend >::defaultConstructionOptions ( )
inlinestaticnoexcept

The leaf-size settings the constructor without options uses; the same as BVHUnion's.

Returns
The default settings.

◆ getBVH()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
Root EBGeometry::BVHSmoothUnion< T, P, K, Blend >::getBVH ( ) const
inlinenoexcept

Get the packed BVH over the primitives whose bounding box is bounded.

The primitives with unbounded boxes are not in it; see getUnboundedPrimitives().

Returns
The BVH.

◆ getUnboundedPrimitives()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
PODSpan< const CSGDetail::Stored< P > > EBGeometry::BVHSmoothUnion< T, P, K, Blend >::getUnboundedPrimitives ( ) const
inlinenoexcept

Get the primitives whose bounding box is unbounded, which every query evaluates.

The span is a resolved address into pool memory; the lifetime caveat of BVH::PackedBVH::getPrimitives() applies.

Returns
Span over those primitives; empty if there are none.

◆ layout()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
Layout EBGeometry::BVHSmoothUnion< T, P, K, Blend >::layout ( ) const
inlinenoexcept

The union's arrays and parameters without its location, for storing it inside an outer union.

Returns
The layout.

◆ rebasedView()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
BVHSmoothUnion EBGeometry::BVHSmoothUnion< T, P, K, Blend >::rebasedView ( const Pool &  a_pool) const
inlinenoexcept

Produce a copy of this smooth union that resolves against a_pool; see BVHUnion::rebasedView().

Parameters
[in]a_poolPool to rebase onto: the union's own pool or one in its mirror chain.
Returns
A BVHSmoothUnion resolving against a_pool.

◆ signedDistance()

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
T EBGeometry::BVHSmoothUnion< T, P, K, Blend >::signedDistance ( const Vec3T< T > &  a_point) const
inlinenoexcept

Evaluate the smooth union at a point.

Finds the two smallest primitive values via the BVH and blends them. Negative when inside the smooth union.

Parameters
[in]a_point3D query point.
Returns
Smooth minimum of the two smallest primitive values.

Member Data Documentation

◆ distanceQuality

template<class T , class P , size_t K, class Blend = SmoothMinOp<T>>
constexpr DistanceQuality EBGeometry::BVHSmoothUnion< T, P, K, Blend >::distanceQuality
staticconstexpr
Initial value:
=
@ Bound
The value's magnitude never exceeds the distance to the surface: it may underestimate,...
@ NotADistance
Only the sign is meaningful, so the function describes a surface (its zero level set) but says nothin...

How far signedDistance() can be trusted as a distance: a bound, or only a sign if the primitives' values are not distances. SmoothMinOp and ExpMinOp weight the two primitives' gradients by weights that sum to one, so they do not make the blend steeper than its inputs.


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