EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_PointAoSoA.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_POINTAOSOA_HPP
12#define EBGEOMETRY_POINTAOSOA_HPP
13
14// Std includes
15#include <cstddef>
16#include <cstdint>
17#include <type_traits>
18
19// Our includes
20#include "EBGeometry_Array.hpp"
22#include "EBGeometry_Vec.hpp"
23
24namespace EBGeometry {
25
42template <class T, size_t W = PointSoA::DefaultWidth<T>()>
44{
45 static_assert(W > 0, "W must be positive");
46 static_assert(std::is_floating_point_v<T>, "PointAoSoA requires a floating-point type T");
47
48public:
61 void
62 pack(const Vec3T<T>* a_positions, const uint32_t* a_pointIds, uint32_t a_count) noexcept;
63
71 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
73 getDistances2(const Vec3T<T>& a_point) const noexcept;
74
81 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
83 getDistances(const Vec3T<T>& a_point) const noexcept;
84
93 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
94 T
95 getMinimumDistance2(const Vec3T<T>& a_point) const noexcept;
96
103 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
104 T
105 getMinimumDistance(const Vec3T<T>& a_point) const noexcept;
106
113 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
114 T
115 getMaximumDistance2(const Vec3T<T>& a_point) const noexcept;
116
123 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
124 T
125 getMaximumDistance(const Vec3T<T>& a_point) const noexcept;
126
134 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
135 uint32_t
136 getPointId(size_t a_lane) const noexcept;
137
142 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
143 uint32_t
144 numValid() const noexcept
145 {
146 return m_positions.numValid();
147 }
148
156 template <class BV>
157 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
158 BV
159 computeBoundingVolume() const noexcept;
160
161protected:
167
172 Array<uint32_t, W> m_pointIds;
173};
174
175static_assert(std::is_trivially_copyable_v<PointAoSoA<float>>, "PointAoSoA<float> must be trivially copyable");
176static_assert(std::is_trivially_copyable_v<PointAoSoA<double>>, "PointAoSoA<double> must be trivially copyable");
177
178} // namespace EBGeometry
179
180#include "EBGeometry_PointAoSoAImplem.hpp"
181
182#endif
A fixed-size array that compiles for both host and device.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
Declaration of a true SoA point-position group for SIMD nearest-neighbor evaluation.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Fixed-size array with host- and device-callable members.
Definition EBGeometry_Array.hpp:33
A PointSoAT<T, W> group that also carries each point's cloud index.
Definition EBGeometry_PointAoSoA.hpp:44
uint32_t numValid() const noexcept
Number of real (non-padded) points in this group.
Definition EBGeometry_PointAoSoA.hpp:144
BV computeBoundingVolume() const noexcept
Compute the bounding volume enclosing all valid points in this group.
T getMinimumDistance2(const Vec3T< T > &a_point) const noexcept
Shortest squared unsigned distance from a_point to the closest point in this group.
T getMinimumDistance(const Vec3T< T > &a_point) const noexcept
Shortest unsigned distance from a_point to the closest point in this group.
PointSoAT< T, W > m_positions
The wrapped, position-only SoA block. SIMD-hot: this is all the distance queries ever touch....
Definition EBGeometry_PointAoSoA.hpp:166
uint32_t getPointId(size_t a_lane) const noexcept
Get the id of the point in one lane of this group.
void pack(const Vec3T< T > *a_positions, const uint32_t *a_pointIds, uint32_t a_count) noexcept
Pack a_count (position, point id) pairs into this 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 points.
Array< T, W > getDistances(const Vec3T< T > &a_point) const noexcept
Unsigned distances from a_point to every one of the W lane points.
Array< uint32_t, W > m_pointIds
Per-lane point ids, physically separate from m_positions. m_pointIds[j] = id of point j....
Definition EBGeometry_PointAoSoA.hpp:172
T getMaximumDistance(const Vec3T< T > &a_point) const noexcept
Largest unsigned distance from a_point to the farthest point in this group.
T getMaximumDistance2(const Vec3T< T > &a_point) const noexcept
Largest squared unsigned distance from a_point to the farthest point in this group.
True SoA (Structure of Arrays) layout for W point positions, enabling SIMD distance evaluation agains...
Definition EBGeometry_PointSoA.hpp:128