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.
 
Array< T, W > getDistances2 (const Vec3T< T > &a_point) const noexcept
 Squared unsigned distances from a_point to every one of the W lane positions.
 
Array< T, W > getDistances (const Vec3T< T > &a_point) const noexcept
 Unsigned distances from a_point to every one of the W lane positions.
 
T getMinimumDistance2 (const Vec3T< T > &a_point) const noexcept
 Shortest squared unsigned distance from a_point to the closest position in this group.
 
T getMinimumDistance (const Vec3T< T > &a_point) const noexcept
 Shortest unsigned distance from a_point to the closest position in this group.
 
T getMaximumDistance2 (const Vec3T< T > &a_point) const noexcept
 Largest squared unsigned distance from a_point to the farthest position in this group.
 
T 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.
 
uint32_t numValid () const noexcept
 Number of real (non-padded) positions in this group.
 

Protected Attributes

T m_x [W]
 x-coordinates of point positions. m_x[j] = x-coord of point j.
 
T m_y [W]
 y-coordinates of point positions.
 
T 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 ids, 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. Point ids, when needed, are carried by the separate PointAoSoA<T, W> wrapper (see EBGeometry_PointAoSoA.hpp) rather than as a member here, so that a pure position-only distance traversal never has id 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 in a Pool-backed PODVector, reserved at the group's alignof inside a PoolBaseAlign-aligned block) is safe. 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.
WLanes per group. A host build vectorizes (float, 4) with SSE4.1, (float, 8), (double, 4) and (double, 8, as two halves) with AVX, and (float, 16) and (double, 8) with AVX-512F; any other width, and every width on a device, runs the scalar loop. Defaults to PointSoA::DefaultWidth<T>(), which is 4 for both float and double in every translation unit; PointSoA::HostWidth<T>() gives the width that fills one SIMD register for T under the compiler's SIMD flags, for host-only code.

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 point array (a Vec3T<T> pointer and a count).
Returns
Bounding volume enclosing all m_validCount valid positions.

◆ getDistances()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
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>()>
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, use numValid()). 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.

◆ numValid()

template<class T , size_t W = PointSoA::DefaultWidth<T>()>
uint32_t EBGeometry::PointSoAT< T, W >::numValid ( ) const
inlinenoexcept

Number of real (non-padded) positions in this group.

Lanes 0..numValid()-1 hold the packed positions; the rest repeat the last one. A scan that must see each point once stops here.

Returns
The count passed to pack(), 1..W (0 before pack()).

◆ 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 uninitialized 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 getDistances2() (which every distance query goes through) and computeBoundingVolume(), rather than reading whatever indeterminate value happened to be there.


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