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::TriangleAoSoA< T, Meta, W > Struct Template Reference

Metadata-carrying wrapper around a single TriangleSoAT<T, W>. More...

#include <EBGeometry_TriangleAoSoA.hpp>

Collaboration diagram for EBGeometry::TriangleAoSoA< T, Meta, W >:
Collaboration graph
[legend]

Public Member Functions

void pack (const Triangle< T, Meta > *a_triangles, uint32_t a_count) noexcept
 Pack a_count triangles from a_triangles[0..a_count-1] into this group.
 
signedDistance (const Vec3T< T > &a_point) const noexcept
 Evaluate signed distance from a_point to the closest triangle in this group.
 
signedDistance (const Vec3T< T > &a_point, Meta &a_closestMeta) const noexcept
 Evaluate signed distance from a_point to the closest triangle and report that triangle's metadata.
 
const MetagetMetaData (size_t a_lane) const noexcept
 Get the metadata for one lane of this group.
 
template<class BV >
BV computeBoundingVolume () const noexcept
 Compute the bounding volume enclosing all valid triangles in this group.
 

Protected Attributes

TriangleSoAT< T, Wm_triangles
 The wrapped, coordinate-only SoA block. SIMD-hot: this is all signedDistance() touches.
 
std::array< Meta, Wm_metaData
 Per-lane metadata, physically separate from m_triangles. m_metaData[j] = metadata of triangle j. Never read by signedDistance(const Vec3T<T>&).
 
uint32_t m_validCount = 0
 Number of valid (non-padded) triangles in this group (1..W).
 

Detailed Description

template<class T, class Meta, size_t W = TriangleSoA::DefaultWidth<T>()>
struct EBGeometry::TriangleAoSoA< T, Meta, W >

Metadata-carrying wrapper around a single TriangleSoAT<T, W>.

Structurally this is an AoSoA (Array of Structures of Arrays): TriangleSoAT<T, W> itself is true SoA (one flat array per coordinate, no per-triangle structure at all), and TriangleAoSoA adds exactly one more member – a std::array<Meta, W> – alongside it. The two are never merged or interleaved: the hot signedDistance(const Vec3T<T>&) query is delegated straight through to the embedded TriangleSoAT and never reads m_metaData at all, so a pure signed-distance traversal over TriangleAoSoA-packed leaves touches exactly the same bytes it would touch over bare TriangleSoAT-packed leaves. The metadata is read only afterward, once a query already knows which lane (and therefore which triangle) it cares about, via getMetaData() or the metadata-reporting signedDistance(point, Meta&) overload – so a caller can recover which triangle (and its metadata) is closest at no cost to the throughput signedDistance() path.

Warning
Inherits the embedded TriangleSoAT's over-alignment (up to 64 bytes, for AVX-512F). The library's own usage (PackedBVH storing groups inside a std::vector<TriangleAoSoA>) is safe: C++17 mandates that std::allocator respect over-alignment. If you allocate a TriangleAoSoA 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(TriangleAoSoA<T, Meta, W>).
Template Parameters
TFloating-point precision.
MetaPer-triangle user metadata type stored with each triangle.
WSIMD width; see TriangleSoAT. Defaults to TriangleSoA::DefaultWidth<T>(), matching TriangleSoAT's own default.

Member Function Documentation

◆ computeBoundingVolume()

template<class T , class Meta , size_t W = TriangleSoA::DefaultWidth<T>()>
template<class BV >
BV EBGeometry::TriangleAoSoA< T, Meta, W >::computeBoundingVolume ( ) const
noexcept

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

Delegates entirely to the embedded TriangleSoAT<T, W>.

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

◆ getMetaData()

template<class T , class Meta , size_t W = TriangleSoA::DefaultWidth<T>()>
const Meta & EBGeometry::TriangleAoSoA< T, Meta, W >::getMetaData ( size_t  a_lane) const
noexcept

Get the metadata for one lane of this group.

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

Parameters
[in]a_laneLane index. Must satisfy 0 <= a_lane < W (padded lanes return the last real triangle's metadata – see pack()).
Returns
Metadata for the triangle at a_lane.

◆ pack()

template<class T , class Meta , size_t W = TriangleSoA::DefaultWidth<T>()>
void EBGeometry::TriangleAoSoA< T, Meta, W >::pack ( const Triangle< T, Meta > *  a_triangles,
uint32_t  a_count 
)
noexcept

Pack a_count triangles from a_triangles[0..a_count-1] into this group.

Pads lanes a_count..W-1 by repeating the last real triangle (its coordinates and its metadata), matching TriangleSoAT::pack()'s own padding convention, so all W lanes hold valid data. The coordinates go into the embedded TriangleSoAT; each triangle's metadata (via Triangle::getMetaData()) goes into the parallel m_metaData array.

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

◆ signedDistance() [1/2]

template<class T , class Meta , size_t W = TriangleSoA::DefaultWidth<T>()>
T EBGeometry::TriangleAoSoA< T, Meta, W >::signedDistance ( const Vec3T< T > &  a_point) const
noexcept

Evaluate signed distance from a_point to the closest triangle in this group.

Delegates entirely to the embedded TriangleSoAT<T, W>; never touches m_metaData, so the metadata array adds no cost to this hot (SIMD) path. See TriangleSoAT::signedDistance().

Parameters
[in]a_pointQuery point. Must be finite.
Returns
Signed distance from a_point to the closest valid triangle.

◆ signedDistance() [2/2]

template<class T , class Meta , size_t W = TriangleSoA::DefaultWidth<T>()>
T EBGeometry::TriangleAoSoA< T, Meta, W >::signedDistance ( const Vec3T< T > &  a_point,
Meta a_closestMeta 
) const
noexcept

Evaluate signed distance from a_point to the closest triangle and report that triangle's metadata.

The metadata-retrieving analogue of signedDistance(const Vec3T<T>&): it returns the same minimum-absolute-value signed distance, but also writes the winning triangle's metadata to a_closestMeta. Unlike the plain overload it takes the scalar per-lane path (TriangleSoAT::signedDistances()) to recover which lane won, then reads that lane's metadata – the extra work the throughput path deliberately avoids (see issue #105).

Parameters
[in]a_pointQuery point. Must be finite.
[out]a_closestMetaSet to the metadata of the winning (minimum-|distance|) triangle.
Returns
Signed distance from a_point to the closest valid triangle.

Member Data Documentation

◆ m_validCount

template<class T , class Meta , size_t W = TriangleSoA::DefaultWidth<T>()>
uint32_t EBGeometry::TriangleAoSoA< T, Meta, W >::m_validCount = 0
protected

Number of valid (non-padded) triangles 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 getMetaData()/signedDistance(point, Meta&), rather than reading whatever indeterminate value happened to be there. (The plain signedDistance() gets the same protection for free from the embedded TriangleSoAT's own m_validCount.)


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