EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_BoundingVolumes.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
11#ifndef EBGEOMETRY_BOUNDINGVOLUMES_HPP
12#define EBGEOMETRY_BOUNDINGVOLUMES_HPP
13
14// Std includes
15#include <cstddef>
16#include <type_traits>
17#include <vector>
18
19// Our includes
20#include "EBGeometry_GPU.hpp"
21#include "EBGeometry_Macros.hpp"
22#include "EBGeometry_Vec.hpp"
23
24namespace EBGeometry {
25
29namespace BoundingVolumes {
30
35template <class T>
36class AABBT
37{
38 static_assert(std::is_floating_point_v<T>, "AABBT<T>: T must be a floating-point type.");
39
40public:
44 using Vec3 = Vec3T<T>;
45
54
62
68
75
85
97
102
108 AABBT&
110
116
122 AABBT&
124
133 inline void
135
146 inline void
148
155 inline bool
157
163 inline Vec3T<T>&
165
171 inline const Vec3T<T>&
173
179 inline Vec3T<T>&
181
187 inline const Vec3T<T>&
189
197
204 inline T
206
213 inline T
215
224 inline T
226
232 inline T
234
240 inline T
242
251 inline AABBT<T>
253
258 Vec3 m_loCorner = Vec3::infinity();
259
263 Vec3 m_hiCorner = -Vec3::infinity();
264};
265
273template <class T>
275bool
277
285template <class T>
287T
289
292} // namespace BoundingVolumes
293
294} // namespace EBGeometry
295
296#include "EBGeometry_BoundingVolumesImplem.hpp"
297
298#endif
GPU portability layer: host/device decoration macros and backend detection.
#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.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Axis-aligned bounding box (AABB) enclosing a set of 3D points.
Definition EBGeometry_BoundingVolumes.hpp:37
Vec3T< T > & getLowCorner() noexcept
Get a modifiable reference to the low corner of the AABB.
Vec3 getCentroid() const noexcept
Compute the centroid of the AABB.
T getDistance(const Vec3 &a_x0) const noexcept
Compute the unsigned distance from a_x0 to this AABB.
Vec3 m_hiCorner
High corner of the bounding box. Initialized to −∞ (inverted sentinel).
Definition EBGeometry_BoundingVolumes.hpp:263
void define(const std::vector< Vec3T< P > > &a_points) noexcept
Fit this AABB to the smallest box enclosing a_points.
AABBT() noexcept=default
Default constructor. Sets lo = +∞, hi = −∞ (inverted sentinel).
bool intersects(const AABBT &a_other) const noexcept
Test whether this AABB intersects a_other.
Vec3T< T > & getHighCorner() noexcept
Get a modifiable reference to the high corner of the AABB.
AABBT< T > merged(const AABBT< T > &a_other) const noexcept
The smallest AABB enclosing this box and a_other.
Vec3 m_loCorner
Low corner of the bounding box. Initialized to +∞ (inverted sentinel).
Definition EBGeometry_BoundingVolumes.hpp:258
T getArea() const noexcept
Compute the AABB surface area.
T getOverlappingVolume(const AABBT< T > &a_other) const noexcept
Compute the overlapping volume between this AABB and a_other.
T getDistance2(const Vec3 &a_x0) const noexcept
Compute the squared unsigned distance from a_x0 to this AABB.
T getVolume() const noexcept
Compute the AABB volume.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26