EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
EBGeometry::PointSoAT< T, W > Struct Template Reference

True SoA (Structure of Arrays) layout for W point positions, enabling SIMD distance evaluation against the whole group at once. More...

#include <EBGeometry_PointSoA.hpp>

Inheritance diagram for EBGeometry::PointSoAT< T, W >:
Inheritance graph
[legend]

Public Member Functions

void pack (const Vec3T< T > *a_positions, uint32_t a_count) noexcept
 Pack a_count positions from a_positions[0..a_count-1] into this SoA group.
 
std::array< T, WgetDistances2 (const Vec3T< T > &a_point) const noexcept
 Squared unsigned distances from a_point to every one of the W lane positions.
 
std::array< T, WgetDistances (const Vec3T< T > &a_point) const noexcept
 Unsigned distances from a_point to every one of the W lane positions.
 
getMinimumDistance2 (const Vec3T< T > &a_point) const noexcept
 Shortest squared unsigned distance from a_point to the closest position in this group.
 
getMinimumDistance (const Vec3T< T > &a_point) const noexcept
 Shortest unsigned distance from a_point to the closest position in this group.
 
getMaximumDistance2 (const Vec3T< T > &a_point) const noexcept
 Largest squared unsigned distance from a_point to the farthest position in this group.
 
getMaximumDistance (const Vec3T< T > &a_point) const noexcept
 Largest unsigned distance from a_point to the farthest position in this group.
 
template<class BV >
BV computeBoundingVolume () const noexcept
 Compute the bounding volume enclosing all valid positions in this group.
 

Protected Attributes

m_x [W]
 x-coordinates of point positions. m_x[j] = x-coord of point j.
 
m_y [W]
 y-coordinates of point positions.
 
m_z [W]
 z-coordinates of point positions.
 
uint32_t m_validCount = 0
 Number of valid (non-padded) positions in this group (1..W).
 

Detailed Description

template<class T, size_t W = PointSoA::DefaultWidth<T>()>
struct EBGeometry::PointSoAT< T, W >

True SoA (Structure of Arrays) layout for W point positions, enabling SIMD distance evaluation against the whole group at once.

Deliberately carries positions only – no metadata, no orientation. A point has no inside/outside notion, so there is no signedDistance() here, only unsigned distance queries. The one SIMD kernel computes the squared distance from the query point to all W lane positions simultaneously; everything the class exposes is a thin wrapper over it – getDistances2()/ getDistances() return the whole W-lane array, and getMinimumDistance2()/getMaximumDistance2() (and their sqrt counterparts) horizontally reduce it. Metadata, when needed, is carried by the separate PointAoSoA<T, Meta, W> wrapper (see EBGeometry_PointAoSoA.hpp) rather than as a member here, so that a pure position-only distance traversal never has metadata bytes anywhere near its hot data – not merely unused, but physically absent from this type.

Warning
This type is over-aligned (up to 64 bytes, for AVX-512F) via alignas. The library's own usage (PackedBVH storing groups inside a std::vector<PointSoAT>) is safe: C++17 mandates that std::allocator respect over-alignment. If you allocate a PointSoAT yourself outside of that path – a raw new, a container with a custom/pre-C++17-style allocator, placement-new into externally-owned storage, or a malloc'd buffer – you are responsible for ensuring the memory is aligned to alignof(PointSoAT<T, W>); nothing in this class enforces or checks that.
Template Parameters
TFloating-point precision.
WSIMD width: 4 for SSE (128-bit), 8 for AVX (256-bit float) or AVX-512F (512-bit double), 16 for AVX-512F (512-bit float). Defaults to PointSoA::DefaultWidth<T>(), the width that fills one SIMD register exactly for T on the current target ISA – note this default is itself different for float and double (see the table above), so PointSoAT<float> and PointSoAT<double> do not, in general, share a width even both left at their defaults.

Member Function Documentation

◆ computeBoundingVolume()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
template<class BV >
BV EBGeometry::PointSoAT< T, W >::computeBoundingVolume ( ) const
noexcept

Compute the bounding volume enclosing all valid positions in this group.

Requires the group to have already been packed via pack() (1 <= m_validCount <= W).

Template Parameters
BVBounding volume type (e.g. AABBT<T>); must be constructible from a std::vector<Vec3T<T>> of positions.
Returns
Bounding volume enclosing all m_validCount valid positions.

◆ getDistances()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
std::array< T, W > EBGeometry::PointSoAT< T, W >::getDistances ( const Vec3T< T > &  a_point) const
noexcept

Unsigned distances from a_point to every one of the W lane positions.

The sqrt of each getDistances2() lane; see it for the padding convention. Prefer getDistances2() when only comparisons are needed.

Parameters
[in]a_pointQuery point. Must be finite.
Returns
Per-lane distances, one per W lanes.

◆ getDistances2()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
std::array< T, W > EBGeometry::PointSoAT< T, W >::getDistances2 ( const Vec3T< T > &  a_point) const
noexcept

Squared unsigned distances from a_point to every one of the W lane positions.

This is the group's one SIMD kernel; every other distance query is a wrapper over it. Squared, so sqrt-free – prefer it (and getMinimumDistance2()/getMaximumDistance2()) whenever the caller only needs distances for comparison, not their actual magnitude. All W lanes are returned: padded lanes (indices m_validCount..W-1) repeat the last real position's squared distance, matching pack()'s padding, so a caller iterating lanes should stop at the real count (or, if it lacks that count, de-duplicate – e.g. PointAoSoA pairs each lane with getMetaData()). Requires the group to have already been packed via pack() (1 <= m_validCount <= W).

Parameters
[in]a_pointQuery point. Must be finite.
Returns
Per-lane squared distances, one per W lanes.

◆ getMaximumDistance()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
T EBGeometry::PointSoAT< T, W >::getMaximumDistance ( const Vec3T< T > &  a_point) const
noexcept

Largest unsigned distance from a_point to the farthest position in this group.

The sqrt of getMaximumDistance2(); prefer that when only comparisons are needed.

Parameters
[in]a_pointQuery point. Must be finite.
Returns
Distance from a_point to the farthest valid position in this group.

◆ getMaximumDistance2()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
T EBGeometry::PointSoAT< T, W >::getMaximumDistance2 ( const Vec3T< T > &  a_point) const
noexcept

Largest squared unsigned distance from a_point to the farthest position in this group.

Horizontal maximum over the real lanes of getDistances2(). Requires the group to have already been packed via pack() (1 <= m_validCount <= W).

Parameters
[in]a_pointQuery point. Must be finite.
Returns
Squared distance from a_point to the farthest valid position in this group.

◆ getMinimumDistance()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
T EBGeometry::PointSoAT< T, W >::getMinimumDistance ( const Vec3T< T > &  a_point) const
noexcept

Shortest unsigned distance from a_point to the closest position in this group.

The sqrt of getMinimumDistance2(); prefer that when only comparisons are needed.

Parameters
[in]a_pointQuery point. Must be finite.
Returns
Distance from a_point to the closest valid position in this group.

◆ getMinimumDistance2()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
T EBGeometry::PointSoAT< T, W >::getMinimumDistance2 ( const Vec3T< T > &  a_point) const
noexcept

Shortest squared unsigned distance from a_point to the closest position in this group.

Horizontal minimum over the real lanes of getDistances2(). Requires the group to have already been packed via pack() (1 <= m_validCount <= W).

Parameters
[in]a_pointQuery point. Must be finite.
Returns
Squared distance from a_point to the closest valid position in this group.

◆ pack()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
void EBGeometry::PointSoAT< T, W >::pack ( const Vec3T< T > *  a_positions,
uint32_t  a_count 
)
noexcept

Pack a_count positions from a_positions[0..a_count-1] into this SoA group.

Pads lanes a_count..W-1 by repeating the last real position so that all W lanes hold valid data and SIMD loads never read uninitialised memory.

Parameters
[in]a_positionsSource position array with at least a_count elements. Must not be null.
[in]a_countNumber of valid positions to pack. Must satisfy 1 <= a_count <= W.

Member Data Documentation

◆ m_validCount

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
uint32_t EBGeometry::PointSoAT< T, W >::m_validCount = 0
protected

Number of valid (non-padded) positions in this group (1..W).

Zero-initialized so that a default-constructed (not-yet-packed) group reliably fails the EBGEOMETRY_EXPECT(m_validCount >= 1) precondition in getDistance()/getDistance2()/ computeBoundingVolume(), rather than reading whatever indeterminate value happened to be there.


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