EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_SphereAoSoA.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_SPHEREAOSOA_HPP
12#define EBGEOMETRY_SPHEREAOSOA_HPP
13
14// Std includes
15#include <cstddef>
16#include <cstdint>
17#include <type_traits>
18
19// Our includes
20#include "EBGeometry_Array.hpp"
23#include "EBGeometry_Vec.hpp"
24
25namespace EBGeometry {
26
35template <class T, size_t W = PointSoA::DefaultWidth<T>()>
37{
38 static_assert(W > 0, "W must be positive");
39 static_assert(std::is_floating_point_v<T>, "SphereAoSoA requires a floating-point type T");
40
41public:
53 void
54 pack(const SphereCloud::Sphere<T>* a_spheres, const uint32_t* a_sphereIds, uint32_t a_count) noexcept;
55
64 void
65 packUnchecked(const SphereCloud::Sphere<T>* a_spheres, const uint32_t* a_sphereIds, uint32_t a_count) noexcept;
66
73 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
75 getSignedDistances(const Vec3T<T>& a_point) const noexcept;
76
83 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
84 uint32_t
85 getSphereId(size_t a_lane) const noexcept;
86
91 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
92 uint32_t
93 numValid() const noexcept
94 {
95 return m_centers.numValid();
96 }
97
103 template <class BV>
104 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
105 BV
106 computeBoundingVolume() const noexcept;
107
108protected:
113
118};
119
120static_assert(std::is_trivially_copyable_v<SphereAoSoA<float>>, "SphereAoSoA<float> must be trivially copyable");
121static_assert(std::is_trivially_copyable_v<SphereAoSoA<double>>, "SphereAoSoA<double> must be trivially copyable");
122
123} // namespace EBGeometry
124
125#include "EBGeometry_SphereAoSoAImplem.hpp"
126
127#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 PointSoAT group that carries point ids.
The sphere, query result and sphere sources of SphereCloudBVH.
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
A group of up to W spheres carrying their cloud indices: a PointAoSoA<T, W> of the centers,...
Definition EBGeometry_SphereAoSoA.hpp:37
uint32_t getSphereId(size_t a_lane) const noexcept
Get the id of the sphere in one lane of this group.
BV computeBoundingVolume() const noexcept
Compute the bounding volume enclosing all valid spheres in this group, each grown by its radius.
void pack(const SphereCloud::Sphere< T > *a_spheres, const uint32_t *a_sphereIds, uint32_t a_count) noexcept
Pack a_count (sphere, id) pairs into this group.
Array< T, W > getSignedDistances(const Vec3T< T > &a_point) const noexcept
Signed distances from a_point to the surface of every one of the W lane spheres, |p - c| - r.
PointAoSoA< T, W > m_centers
The centers and ids. It also holds the valid-sphere count.
Definition EBGeometry_SphereAoSoA.hpp:112
uint32_t numValid() const noexcept
Number of real (non-padded) spheres in this group.
Definition EBGeometry_SphereAoSoA.hpp:93
void packUnchecked(const SphereCloud::Sphere< T > *a_spheres, const uint32_t *a_sphereIds, uint32_t a_count) noexcept
pack() without its always-on checks, for a build that runs on a device.
Array< T, W > m_radii
Per-lane radii. m_radii[j] = radius of sphere j.
Definition EBGeometry_SphereAoSoA.hpp:117
A sphere of a sphere cloud: a center and a radius.
Definition EBGeometry_SphereCloud.hpp:48