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: BSD-3-Clause
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
73 void
74 packUnchecked(const Vec3T<T>* a_positions, const uint32_t* a_pointIds, uint32_t a_count) noexcept;
75
83 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
85 getDistances2(const Vec3T<T>& a_point) const noexcept;
86
93 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
95 getDistances(const Vec3T<T>& a_point) const noexcept;
96
105 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
106 T
107 getMinimumDistance2(const Vec3T<T>& a_point) const noexcept;
108
115 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
116 T
117 getMinimumDistance(const Vec3T<T>& a_point) const noexcept;
118
125 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
126 T
127 getMaximumDistance2(const Vec3T<T>& a_point) const noexcept;
128
135 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
136 T
137 getMaximumDistance(const Vec3T<T>& a_point) const noexcept;
138
146 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
147 uint32_t
148 getPointId(size_t a_lane) const noexcept;
149
155 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
157 getPosition(size_t a_lane) const noexcept
158 {
159 return m_positions.getPosition(a_lane);
160 }
161
166 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
167 uint32_t
168 numValid() const noexcept
169 {
170 return m_positions.numValid();
171 }
172
180 template <class BV>
181 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
182 BV
183 computeBoundingVolume() const noexcept;
184
185protected:
192 void
193 packIds(const uint32_t* a_pointIds, uint32_t a_count) noexcept;
194
200
205 Array<uint32_t, W> m_pointIds;
206};
207
208static_assert(std::is_trivially_copyable_v<PointAoSoA<float>>, "PointAoSoA<float> must be trivially copyable");
209static_assert(std::is_trivially_copyable_v<PointAoSoA<double>>, "PointAoSoA<double> must be trivially copyable");
210
211} // namespace EBGeometry
212
213#include "EBGeometry_PointAoSoAImplem.hpp"
214
215#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:168
void packIds(const uint32_t *a_pointIds, uint32_t a_count) noexcept
Store the point ids, padding lanes a_count..W-1 with the last one.
BV computeBoundingVolume() const noexcept
Compute the bounding volume enclosing all valid points in this group.
void packUnchecked(const Vec3T< T > *a_positions, const uint32_t *a_pointIds, uint32_t a_count) noexcept
pack() without its always-on checks, for a build that runs on a device.
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:199
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.
Vec3T< T > getPosition(size_t a_lane) const noexcept
Get the position of the point in one lane of this group.
Definition EBGeometry_PointAoSoA.hpp:157
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:205
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
Vec3T< T > getPosition(size_t a_lane) const noexcept
The position in one lane.
Definition EBGeometry_PointSoA.hpp:256
uint32_t numValid() const noexcept
Number of real (non-padded) positions in this group.
Definition EBGeometry_PointSoA.hpp:244