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: BSD-3-Clause
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
86 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
88 getSeparations(const Vec3T<T>& a_center, T a_radius) const noexcept;
89
103 void
104 rayIntervals(const Vec3T<T>& a_origin,
105 const Vec3T<T>& a_direction,
106 Array<T, W>& a_entry,
107 Array<T, W>& a_exit) const noexcept;
108
115 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
116 uint32_t
117 getSphereId(size_t a_lane) const noexcept;
118
123 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
124 uint32_t
125 numValid() const noexcept
126 {
127 return m_centers.numValid();
128 }
129
135 template <class BV>
136 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
137 BV
138 computeBoundingVolume() const noexcept;
139
140protected:
145
150};
151
152static_assert(std::is_trivially_copyable_v<SphereAoSoA<float>>, "SphereAoSoA<float> must be trivially copyable");
153static_assert(std::is_trivially_copyable_v<SphereAoSoA<double>>, "SphereAoSoA<double> must be trivially copyable");
154
155} // namespace EBGeometry
156
157#include "EBGeometry_SphereAoSoAImplem.hpp"
158
159#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.
void rayIntervals(const Vec3T< T > &a_origin, const Vec3T< T > &a_direction, Array< T, W > &a_entry, Array< T, W > &a_exit) const noexcept
Where a ray runs through each of the W lane spheres: the distances along it at which it enters and le...
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 > getSeparations(const Vec3T< T > &a_center, T a_radius) const noexcept
Separations between a sphere and every one of the W lane spheres, |c - c_j| - (r + r_j).
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:144
uint32_t numValid() const noexcept
Number of real (non-padded) spheres in this group.
Definition EBGeometry_SphereAoSoA.hpp:125
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:149
A sphere of a sphere cloud: a center and a radius.
Definition EBGeometry_SphereCloud.hpp:48