11#ifndef EBGEOMETRY_MESHDISTANCEFUNCTIONS_HPP
12#define EBGEOMETRY_MESHDISTANCEFUNCTIONS_HPP
80 static_assert(std::is_floating_point_v<T>,
"FlatMeshSDF requires a floating-point T");
120 :
PoolHandle(a_location), m_meshLayout(a_layout.m_mesh)
131 return Layout{m_meshLayout};
223static_assert(std::is_trivially_copyable_v<
FlatMeshSDF<
float>>, "
FlatMeshSDF<
float> must be trivially copyable");
224static_assert(std::is_trivially_copyable_v<
FlatMeshSDF<
double>>, "
FlatMeshSDF<
double> must be trivially copyable");
247template <class T,
size_t K>
250 static_assert(std::is_floating_point_v<T>,
"MeshSDF requires a floating-point T");
251 static_assert(K >= 2,
"MeshSDF requires branching factor K >= 2");
278 using Node =
typename Root::Node;
314 :
PoolHandle(a_location), m_meshLayout(a_layout.m_mesh), m_bvhLayout(a_layout.m_bvh)
325 return Layout{m_meshLayout, m_bvhLayout};
354 inline
MeshSDF(const
Mesh& a_mesh,
Pool& a_pool, const BVH::Construction a_construction);
368 const BVH::Construction a_construction,
369 const BVH::ConstructionOptions& a_options);
409 getRoot() const noexcept
433 return this->getRoot().getBoundingVolume();
470 buildBVH(
const Mesh& a_mesh,
479 typename Mesh::Layout m_meshLayout;
484 typename Root::Layout m_bvhLayout;
513template <
class T,
size_t K,
size_t W>
516 static_assert(std::is_floating_point_v<T>,
"TriMeshSDF<T,K,W> requires a floating-point T");
517 static_assert(K >= 2,
"TriMeshSDF requires branching factor K >= 2");
518 static_assert(W > 0,
"TriMeshSDF requires SoA width W > 0");
573 :
PoolHandle(a_location), m_bvhLayout(a_layout.m_bvh)
584 return Layout{m_bvhLayout};
628 const size_t a_maxLeafGroups);
643 const size_t a_maxLeafGroups);
707 return Root(m_bvhLayout, this->location());
718 return this->getRoot().getBoundingVolume();
749 static inline std::vector<Tri>
750 extractTriangles(
const Mesh& a_mesh);
762 buildBVH(
const std::vector<Tri>& a_triangles,
778 buildClusterSAH(
const std::vector<Tri>& a_triangles,
Pool& a_pool,
const BVH::ClusterSpec& a_spec);
787 template <
class GetTriangle>
789 static inline std::vector<TriAoSoA>
790 groupTriangles(
const GetTriangle& a_getTriangle, uint32_t a_count);
802 static std::vector<TriAoSoA>
803 groupTrianglesIntoSoA(
const std::vector<std::shared_ptr<const Tri>>& a_triangles,
819 typename Root::Layout m_bvhLayout;
826static_assert(std::is_trivially_copyable_v<MeshSDF<float, 4>>,
"MeshSDF<float, 4> must be trivially copyable");
827static_assert(std::is_trivially_copyable_v<MeshSDF<double, 4>>,
"MeshSDF<double, 4> must be trivially copyable");
828static_assert(std::is_trivially_copyable_v<TriMeshSDF<float, 4, 4>>,
829 "TriMeshSDF<float, 4, 4> must be trivially copyable");
830static_assert(std::is_trivially_copyable_v<TriMeshSDF<double, 4, 4>>,
831 "TriMeshSDF<double, 4, 4> must be trivially copyable");
835#include "EBGeometry_MeshDistanceFunctionsImplem.hpp"
Bounding volume hierarchies: everything in EBGeometry_PackedBVH.hpp, EBGeometry_TreeBVH....
Declarations of bounding volume types used in bounding volume hierarchies.
Declaration of a mesh class which stores a DCEL mesh (with signed distance functions)
How far a function's value can be trusted as a distance: DistanceQuality, and the distanceQualityOf t...
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
Scalar helpers and numeric limits that compile for both host and device.
Growable bump arena for the GPU memory foundation.
Declaration of a face-id-carrying wrapper around TriangleSoAT.
Declaration of SoA triangle group for SIMD signed-distance evaluation.
Declaration of a triangle class with signed distance functionality.
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
Face class for navigating a DCEL mesh.
Definition EBGeometry_DCEL_Face.hpp:68
DCEL mesh class - stores a doubly-connected edge mesh.
Definition EBGeometry_DCEL_Mesh.hpp:102
Signed distance function for a DCEL mesh. Does not use BVHs.
Definition EBGeometry_MeshDistanceFunctions.hpp:79
FlatMeshSDF(const Layout &a_layout, const PoolLocation &a_location) noexcept
Rebuild a handle from a stored layout and the location of the pool that holds it.
Definition EBGeometry_MeshDistanceFunctions.hpp:119
T signedDistance(const Vec3T< T > &a_point) const noexcept
Compute the signed distance from a_point to the mesh.
Mesh getMesh() const noexcept
Get the underlying DCEL mesh descriptor.
Definition EBGeometry_MeshDistanceFunctions.hpp:175
ClosestFace< T > getClosestFace(const Vec3T< T > &a_point) const noexcept
Find the face closest to a_point, and the signed distance to it.
Layout layout() const noexcept
The object's arrays without its location, for storing it inside another pool-resident object.
Definition EBGeometry_MeshDistanceFunctions.hpp:129
FlatMeshSDF(const Mesh &a_mesh, Pool &a_pool) noexcept
Full constructor.
EBGeometry::DCEL::MeshT< T > Mesh
Alias for DCEL mesh type.
Definition EBGeometry_MeshDistanceFunctions.hpp:92
FlatMeshSDF rebasedView(const Pool &a_pool) const noexcept
Produce a copy of this object that resolves against a_pool.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to a watertight mesh.
Definition EBGeometry_MeshDistanceFunctions.hpp:87
FlatMeshSDF deepCopy(Pool &a_dstPool) const
Duplicate the mesh's storage into a_dstPool.
FlatMeshSDF()=delete
Disallowed constructor.
EBGeometry::BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
Compute the AABB enclosing the entire mesh.
A FlatMeshSDF must be trivially copyable: that is what lets a rebasedView() be byte-copied into a dev...
Definition EBGeometry_MeshDistanceFunctions.hpp:249
Mesh getMesh() const noexcept
Get the DCEL mesh descriptor the BVH's faces resolve against.
Definition EBGeometry_MeshDistanceFunctions.hpp:420
Layout layout() const noexcept
The object's arrays without its location, for storing it inside another pool-resident object.
Definition EBGeometry_MeshDistanceFunctions.hpp:323
typename Root::Node Node
Alias for a single linearized node.
Definition EBGeometry_MeshDistanceFunctions.hpp:278
MeshSDF(const Layout &a_layout, const PoolLocation &a_location) noexcept
Rebuild a handle from a stored layout and the location of the pool that holds it.
Definition EBGeometry_MeshDistanceFunctions.hpp:313
static BVH::ConstructionOptions defaultConstructionOptions() noexcept
The leaf-size settings the constructor without options uses.
EBGeometry::BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
Compute the AABB enclosing the entire mesh.
Definition EBGeometry_MeshDistanceFunctions.hpp:431
MeshSDF rebasedView(const Pool &a_pool) const noexcept
Produce a copy of this object that resolves against a_pool.
typename EBGeometry::DCEL::MeshT< T > Mesh
Alias for DCEL mesh type.
Definition EBGeometry_MeshDistanceFunctions.hpp:268
MeshSDF deepCopy(Pool &a_dstPool) const
Duplicate the mesh's and the BVH's storage into a_dstPool.
MeshSDF()=delete
Default disallowed constructor.
typename EBGeometry::DCEL::FaceT< T > Face
Alias for DCEL face type.
Definition EBGeometry_MeshDistanceFunctions.hpp:263
Base of every pool-resident handle: the one PoolLocation its arrays resolve against.
Definition EBGeometry_Pool.hpp:506
PoolLocation location() const noexcept
Where this handle's arrays live.
Definition EBGeometry_Pool.hpp:514
PoolHandle() noexcept=default
An unset location; the first reservation attaches it.
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:188
Signed distance function for a pure triangle mesh using SoA-grouped primitives in a compact (lineariz...
Definition EBGeometry_MeshDistanceFunctions.hpp:515
typename EBGeometry::BVH::PackedBVH< T, TriAoSoA, K > Root
Alias for which BVH root node.
Definition EBGeometry_MeshDistanceFunctions.hpp:545
TriMeshSDF(const std::vector< Tri > &a_triangles, Pool &a_pool, const BVH::Construction a_construction, const size_t a_maxLeafGroups)
Full constructor. Takes the input triangles and creates the BVH.
TriMeshSDF(const std::vector< Tri > &a_triangles, Pool &a_pool, const BVH::Construction a_construction, const BVH::ConstructionOptions &a_options)
Full constructor from a triangle soup, with leaf-size settings.
TriMeshSDF()=delete
Default disallowed constructor.
TriMeshSDF(const Mesh &a_mesh, Pool &a_pool, const BVH::Construction a_construction, const size_t a_maxLeafGroups)
Full constructor. Extracts flat triangles from a DCEL mesh, then builds the BVH.
typename EBGeometry::Triangle< T > Tri
Alias for the flat triangle type the BVH is built from.
Definition EBGeometry_MeshDistanceFunctions.hpp:535
EBGeometry::BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
Compute the AABB enclosing the entire triangle mesh.
Definition EBGeometry_MeshDistanceFunctions.hpp:716
Layout layout() const noexcept
The object's arrays without its location, for storing it inside another pool-resident object.
Definition EBGeometry_MeshDistanceFunctions.hpp:582
T signedDistance(const Vec3T< T > &a_point) const noexcept
Compute the signed distance from a_point to the triangle mesh.
TriMeshSDF rebasedView(const Pool &a_pool) const noexcept
Produce a copy of this object that resolves against a_pool.
static BVH::ConstructionOptions defaultConstructionOptions(const size_t a_maxLeafGroups) noexcept
The leaf-size settings the constructors taking a_maxLeafGroups use.
TriMeshSDF(const Layout &a_layout, const PoolLocation &a_location) noexcept
Rebuild a handle from a stored layout and the location of the pool that holds it.
Definition EBGeometry_MeshDistanceFunctions.hpp:572
TriMeshSDF(const Mesh &a_mesh, Pool &a_pool, const BVH::Construction a_construction, const BVH::ConstructionOptions &a_options)
Full constructor from a DCEL mesh, with leaf-size settings.
Root getRoot() const noexcept
Get the PackedBVH storing SoA triangle groups.
Definition EBGeometry_MeshDistanceFunctions.hpp:705
ClosestFace< T > getClosestFace(const Vec3T< T > &a_point) const noexcept
Find the face closest to a_point, and the signed distance to it.
TriMeshSDF deepCopy(Pool &a_dstPool) const
Duplicate the BVH's storage into a_dstPool.
Triangle class with signed distance functionality.
Definition EBGeometry_Triangle.hpp:52
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
Construction
The preset BVH construction methods that the library's own BVH users accept.
Definition EBGeometry_PackedBVH.hpp:65
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
DistanceQuality
How far the value of a signed distance function can be trusted, from strongest to weakest.
Definition EBGeometry_DistanceQuality.hpp:25
@ Exact
The value's magnitude is the Euclidean distance to the surface.
Configuration for the ClusterSAH direct PackedBVH construction path.
Definition EBGeometry_PackedBVH.hpp:94
Leaf-size settings for the preset construction methods, one per family of methods.
Definition EBGeometry_PackedBVH.hpp:115
The face of a mesh closest to a query point, as the mesh SDFs' getClosestFace() returns it.
Definition EBGeometry_MeshDistanceFunctions.hpp:46
uint32_t faceId
Id of the closest face; UINT32_MAX for an empty mesh.
Definition EBGeometry_MeshDistanceFunctions.hpp:48
T signedDistance
Signed distance to the closest face; negative inside.
Definition EBGeometry_MeshDistanceFunctions.hpp:47
The mesh's arrays as offsets into its pool, with no location: what another pool-resident object store...
Definition EBGeometry_DCEL_Mesh.hpp:159
The object's arrays as offsets into its pool, with no location (see PoolHandle).
Definition EBGeometry_MeshDistanceFunctions.hpp:103
Mesh::Layout m_mesh
The mesh.
Definition EBGeometry_MeshDistanceFunctions.hpp:107
Numeric limits, with the meanings of the std::numeric_limits members of the same names.
Definition EBGeometry_Math.hpp:91
The object's arrays as offsets into its pool, with no location (see PoolHandle).
Definition EBGeometry_MeshDistanceFunctions.hpp:292
Mesh::Layout m_mesh
The mesh.
Definition EBGeometry_MeshDistanceFunctions.hpp:296
Root::Layout m_bvh
The BVH over the mesh's face ids.
Definition EBGeometry_MeshDistanceFunctions.hpp:301
Where a pool-resident descriptor resolves its offsets, and the rules for moving it.
Definition EBGeometry_Pool.hpp:99
The object's arrays as offsets into its pool, with no location (see PoolHandle).
Definition EBGeometry_MeshDistanceFunctions.hpp:556
Root::Layout m_bvh
The BVH over SoA triangle groups.
Definition EBGeometry_MeshDistanceFunctions.hpp:560
Face-id-carrying wrapper around a single TriangleSoAT<T, W>.
Definition EBGeometry_TriangleAoSoA.hpp:50