EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_BVHRefit.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
17#ifndef EBGEOMETRY_BVHREFIT_HPP
18#define EBGEOMETRY_BVHREFIT_HPP
19
20// Std includes
21#include <cstddef>
22#include <cstdint>
23#include <type_traits>
24#include <vector>
25
26// Our includes
28#include "EBGeometry_Macros.hpp"
31#include "EBGeometry_Pool.hpp"
32
33namespace EBGeometry {
34
35namespace BVH {
36
53{
54public:
65 template <class T, class P, size_t K>
67 RefitSchedule(Pool& a_pool, const PackedBVH<T, P, K>& a_bvh);
68
73 [[nodiscard]] EBGEOMETRY_HOST
74 inline size_t
75 numLevels() const noexcept
76 {
77 return m_levelBegin.empty() ? 0 : m_levelBegin.size() - 1;
78 }
79
80private:
84 template <class T, class P, size_t K, class BVConstructor>
85 friend void
86 refit(Pool& a_pool,
87 const PackedBVH<T, P, K>& a_bvh,
88 const RefitSchedule& a_schedule,
89 const BVConstructor& a_bvConstructor);
90
94 PODVector<uint32_t> m_nodes;
95
99 std::vector<uint32_t> m_levelBegin;
100
105 uint64_t m_rootId = 0;
106
112 uint64_t m_nodesOffset = 0;
113};
114
149template <class T, class P, size_t K, class BVConstructor>
151inline void
152refit(Pool& a_pool,
153 const PackedBVH<T, P, K>& a_bvh,
154 const RefitSchedule& a_schedule,
155 const BVConstructor& a_bvConstructor);
156
157namespace RefitDetail {
158
164template <class Bvh, class BVConstructor>
165struct Level
166{
172 mutable Bvh m_bvh;
173
177 PODVector<uint32_t> m_nodes;
178
182 uint32_t m_begin;
183
187 BVConstructor m_bvConstructor;
188
194 inline void
195 operator()(const std::size_t a_i) const
196 {
197 void* base = m_bvh.base();
198
199 m_bvh.refitNode(base, m_nodes.at(base, m_begin + static_cast<uint32_t>(a_i)), m_bvConstructor);
200 }
201};
202
203} // namespace RefitDetail
204
205} // namespace BVH
206
207} // namespace EBGeometry
208
209#include "EBGeometry_BVHRefitImplem.hpp"
210
211#endif
GPU::parallelFor() and GPU::transform(), which run a functor over many indices or inputs: in a kernel...
#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
Utility macros for EBGeometry.
Placement-independent POD array views for the GPU memory foundation.
The flattened, device-callable bounding volume hierarchy: PackedBVH, its node layout,...
Growable bump arena for the GPU memory foundation.
Forward declaration of the linearised BVH, defined below.
Definition EBGeometry_PackedBVH.hpp:365
A PackedBVH's nodes grouped by tree depth, deepest level first: the order in which BVH::refit() refit...
Definition EBGeometry_BVHRefit.hpp:53
RefitSchedule(Pool &a_pool, const PackedBVH< T, P, K > &a_bvh)
Group the nodes of a_bvh by depth.
friend void refit(Pool &a_pool, const PackedBVH< T, P, K > &a_bvh, const RefitSchedule &a_schedule, const BVConstructor &a_bvConstructor)
BVH::refit() reads the node list and the levels.
size_t numLevels() const noexcept
Number of tree levels; 0 for an empty BVH.
Definition EBGeometry_BVHRefit.hpp:75
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:188
void refit(Pool &a_pool, const PackedBVH< T, P, K > &a_bvh, const RefitSchedule &a_schedule, const BVConstructor &a_bvConstructor)
Refit the copy of a_bvh that lives in a_pool, after its primitives have moved: every box becomes the ...
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Placement-independent descriptor of a POD array inside a Pool.
Definition EBGeometry_PODVector.hpp:119
T & at(void *a_base, uint32_t a_i) const noexcept
Mutable element access against a_base.
Definition EBGeometry_PODVector.hpp:198