EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_PointSoA.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
11#ifndef EBGEOMETRY_POINTSOA_HPP
12#define EBGEOMETRY_POINTSOA_HPP
13
14// Std includes
15#include <array>
16#include <cstddef>
17#include <cstdint>
18#include <type_traits>
19
20#if defined(__SSE4_1__) || defined(__AVX__) || defined(__AVX512F__)
21#include <immintrin.h>
22#endif
23
24// Our includes
25#include "EBGeometry_Vec.hpp"
26
27namespace EBGeometry {
28
32namespace PointSoA {
33
51template <typename T>
52[[nodiscard]] constexpr size_t
54{
55 static_assert(std::is_floating_point_v<T>, "EBGeometry::PointSoA::DefaultWidth requires a floating-point T");
56#if defined(__AVX512F__)
57 if constexpr (std::is_same_v<T, double>) {
58 return 8;
59 }
60 else {
61 return 16;
62 }
63#elif defined(__AVX__)
64 if constexpr (std::is_same_v<T, double>) {
65 return 4;
66 }
67 else {
68 return 8;
69 }
70#else
71 return 4;
72#endif
73}
74
75} // namespace PointSoA
76
102template <class T, size_t W = PointSoA::DefaultWidth<T>()>
104{
105 static_assert(W > 0, "W must be positive");
106 static_assert(std::is_floating_point_v<T>, "PointSoAT requires a floating-point type T");
107
108public:
116 void
118
131 [[nodiscard]] std::array<T, W>
132 getDistances2(const Vec3T<T>& a_point) const noexcept;
133
141 [[nodiscard]] std::array<T, W>
142 getDistances(const Vec3T<T>& a_point) const noexcept;
143
151 [[nodiscard]] T
152 getMinimumDistance2(const Vec3T<T>& a_point) const noexcept;
153
160 [[nodiscard]] T
161 getMinimumDistance(const Vec3T<T>& a_point) const noexcept;
162
170 [[nodiscard]] T
171 getMaximumDistance2(const Vec3T<T>& a_point) const noexcept;
172
179 [[nodiscard]] T
180 getMaximumDistance(const Vec3T<T>& a_point) const noexcept;
181
189 template <class BV>
190 [[nodiscard]] BV
192
197 alignas(W * sizeof(T)) T m_x[W];
198
202 T m_y[W];
203
207 T m_z[W];
208
216};
217
218} // namespace EBGeometry
219
220#include "EBGeometry_PointSoAImplem.hpp"
221
222#endif
Declaration of 2D and 3D point/vector classes with templated precision. Used with DCEL tools.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:225
constexpr size_t DefaultWidth() noexcept
Returns the SIMD-optimal SoA width (points per PointSoAT group) for type T on the current target ISA.
Definition EBGeometry_PointSoA.hpp:53
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:31
True SoA (Structure of Arrays) layout for W point positions, enabling SIMD distance evaluation agains...
Definition EBGeometry_PointSoA.hpp:104
BV computeBoundingVolume() const noexcept
Compute the bounding volume enclosing all valid positions in this group.
T m_z[W]
z-coordinates of point positions.
Definition EBGeometry_PointSoA.hpp:207
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, W > getDistances(const Vec3T< T > &a_point) const noexcept
Unsigned distances from a_point to every one of the W lane positions.
T getMaximumDistance2(const Vec3T< T > &a_point) const noexcept
Largest squared unsigned distance from a_point to the farthest position in this group.
T getMinimumDistance2(const Vec3T< T > &a_point) const noexcept
Shortest squared unsigned distance from a_point to the closest 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.
std::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.
T m_y[W]
y-coordinates of point positions.
Definition EBGeometry_PointSoA.hpp:202
uint32_t m_validCount
Number of valid (non-padded) positions in this group (1..W).
Definition EBGeometry_PointSoA.hpp:215
T m_x[W]
x-coordinates of point positions. m_x[j] = x-coord of point j.
Definition EBGeometry_PointSoA.hpp:197
T getMinimumDistance(const Vec3T< T > &a_point) const noexcept
Shortest unsigned distance from a_point to the closest position in this group.