EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
EBGeometry::MeshSDF< T, Meta, K > Class Template Reference

Signed distance function for a DCEL mesh. Stores the mesh in a PackedBVH for SIMD-accelerated traversal. Accepts any polygon, not just triangles. More...

#include <EBGeometry_MeshDistanceFunctions.hpp>

Inheritance diagram for EBGeometry::MeshSDF< T, Meta, K >:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::MeshSDF< T, Meta, K >:
Collaboration graph
[legend]

Public Types

using Face = typename EBGeometry::DCEL::FaceT< T, Meta >
 Alias for DCEL face type.
 
using Mesh = typename EBGeometry::DCEL::MeshT< T, Meta >
 Alias for DCEL mesh type.
 
using Root = EBGeometry::BVH::PackedBVH< T, Face, K >
 Alias for the linearized BVH root.
 
using Node = typename Root::Node
 Alias for a single linearized node.
 

Public Member Functions

 MeshSDF ()=delete
 Default disallowed constructor.
 
 MeshSDF (const std::shared_ptr< Mesh > &a_mesh, const BVH::Build a_build)
 Full constructor. Takes the input mesh and creates the BVH.
 
 ~MeshSDF () override=default
 Destructor.
 
 MeshSDF (const MeshSDF &a_other)=default
 Copy constructor.
 
MeshSDFoperator= (const MeshSDF &a_other)=default
 Copy assignment operator.
 
 MeshSDF (MeshSDF &&a_other) noexcept=default
 Move constructor.
 
MeshSDFoperator= (MeshSDF &&a_other) noexcept=default
 Move assignment operator.
 
signedDistance (const Vec3T< T > &a_point) const noexcept override
 Compute the signed distance from a_point to the mesh.
 
virtual std::vector< std::pair< std::shared_ptr< const Face >, T > > getClosestFaces (const Vec3T< T > &a_point, const bool a_sorted) const
 Return faces within BVH-pruned candidate distance of a_point.
 
virtual std::shared_ptr< Root > & getRoot () noexcept
 Get the PackedBVH enclosing the mesh.
 
virtual const std::shared_ptr< Root > & getRoot () const noexcept
 Get the PackedBVH enclosing the mesh (const overload).
 
EBGeometry::BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 Compute the AABB enclosing the entire mesh.
 
- Public Member Functions inherited from EBGeometry::SignedDistanceFunction< T >
 SignedDistanceFunction ()=default
 Default constructor.
 
 ~SignedDistanceFunction () override=default
 Destructor.
 
value (const Vec3T< T > &a_point) const noexcept final
 Implementation of ImplicitFunction::value; delegates to signedDistance().
 
virtual Vec3T< T > normal (const Vec3T< T > &a_point, const T &a_delta) const noexcept
 Compute the outward normal using central finite differences.
 
- Public Member Functions inherited from EBGeometry::ImplicitFunction< T >
 ImplicitFunction ()=default
 Default constructor.
 
virtual ~ImplicitFunction ()=default
 Default destructor.
 
operator() (const Vec3T< T > &a_point) const noexcept
 Call operator — alternative signature for the value function.
 
template<class BV >
BV approximateBoundingVolumeOctree (const Vec3T< T > &a_initialLowCorner, const Vec3T< T > &a_initialHighCorner, const unsigned int a_maxTreeDepth, const T &a_safety=0.0) const
 Compute an approximation to the bounding volume for the implicit surface using octree subdivision.
 

Protected Attributes

std::shared_ptr< Rootm_bvh
 Linearized BVH.
 
std::shared_ptr< Meshm_mesh
 Source DCEL mesh.
 

Detailed Description

template<class T, class Meta, size_t K>
class EBGeometry::MeshSDF< T, Meta, K >

Signed distance function for a DCEL mesh. Stores the mesh in a PackedBVH for SIMD-accelerated traversal. Accepts any polygon, not just triangles.

The mesh faces are packed into a flat-array PackedBVH. SIMD traversal is used when T and K match an available ISA path. Unlike TriMeshSDF, MeshSDF does not expose a PackedBVH StoragePolicy choice: its PackedBVH always uses BVH::SharedPtrStorage<Face>, sharing each packed face with the DCEL mesh's own face list rather than copying it. This is not just a default – DCEL::FaceT's copy constructor deliberately does not copy its cached 2D polygon embedding (m_poly2, used by signedDistance()'s point-in-face test), so a naive by-value copy (as BVH::ValueStorage would produce) is left with a null embedding and crashes on first query; see FaceT's copy-constructor documentation. See the user documentation for the full rationale, including why TriMeshSDF's SoA groups do not have this restriction.

Template Parameters
TFloating-point precision type (float or double).
MetaTriangle metadata type stored on each DCEL face.
KBVH branching factor (number of children per internal node).

Constructor & Destructor Documentation

◆ MeshSDF() [1/3]

template<class T , class Meta , size_t K>
EBGeometry::MeshSDF< T, Meta, K >::MeshSDF ( const std::shared_ptr< Mesh > &  a_mesh,
const BVH::Build  a_build 
)

Full constructor. Takes the input mesh and creates the BVH.

No default arguments: this is a low-level constructor, and callers working at this level must consciously choose a build strategy. Use Parser::readIntoPackedBVH for sensible defaults.

Parameters
[in]a_meshInput mesh.
[in]a_buildBVH build strategy. SAH (binned Surface Area Heuristic) is recommended.

◆ MeshSDF() [2/3]

template<class T , class Meta , size_t K>
EBGeometry::MeshSDF< T, Meta, K >::MeshSDF ( const MeshSDF< T, Meta, K > &  a_other)
default

Copy constructor.

Explicitly defaulted for documentation purposes: MeshSDF's members (m_bvh, m_mesh) are both shared_ptr, so the implicitly-generated copy is a cheap, correct handle-copy.

Parameters
[in]a_otherOther instance to copy.

◆ MeshSDF() [3/3]

template<class T , class Meta , size_t K>
EBGeometry::MeshSDF< T, Meta, K >::MeshSDF ( MeshSDF< T, Meta, K > &&  a_other)
defaultnoexcept

Move constructor.

Explicitly defaulted: the user-declared destructor above would otherwise suppress the implicitly-generated move constructor.

Parameters
[in,out]a_otherOther instance to move from.

Member Function Documentation

◆ computeBoundingVolume()

template<class T , class Meta , size_t K>
EBGeometry::BoundingVolumes::AABBT< T > EBGeometry::MeshSDF< T, Meta, K >::computeBoundingVolume ( ) const
noexcept

Compute the AABB enclosing the entire mesh.

Returns
Axis-aligned bounding box of the mesh.

◆ getClosestFaces()

template<class T , class Meta , size_t K>
virtual std::vector< std::pair< std::shared_ptr< const Face >, T > > EBGeometry::MeshSDF< T, Meta, K >::getClosestFaces ( const Vec3T< T > &  a_point,
const bool  a_sorted 
) const
virtual

Return faces within BVH-pruned candidate distance of a_point.

Traverses the PackedBVH and collects candidate faces. The result pairs each face with its unsigned distance to a_point.

Parameters
[in]a_pointQuery point.
[in]a_sortedIf true, the returned vector is sorted by ascending unsigned distance (closest face first).
Returns
Vector of (face, unsigned_distance) pairs, optionally sorted.

◆ getRoot() [1/2]

template<class T , class Meta , size_t K>
virtual const std::shared_ptr< Root > & EBGeometry::MeshSDF< T, Meta, K >::getRoot ( ) const
virtualnoexcept

Get the PackedBVH enclosing the mesh (const overload).

Returns
Const reference to the shared-pointer owning the packed BVH root.

◆ getRoot() [2/2]

template<class T , class Meta , size_t K>
virtual std::shared_ptr< Root > & EBGeometry::MeshSDF< T, Meta, K >::getRoot ( )
virtualnoexcept

Get the PackedBVH enclosing the mesh.

Returns
Mutable reference to the shared-pointer owning the packed BVH root.

◆ operator=() [1/2]

template<class T , class Meta , size_t K>
MeshSDF & EBGeometry::MeshSDF< T, Meta, K >::operator= ( const MeshSDF< T, Meta, K > &  a_other)
default

Copy assignment operator.

Parameters
[in]a_otherOther instance to copy.
Returns
Reference to *this.

◆ operator=() [2/2]

template<class T , class Meta , size_t K>
MeshSDF & EBGeometry::MeshSDF< T, Meta, K >::operator= ( MeshSDF< T, Meta, K > &&  a_other)
defaultnoexcept

Move assignment operator.

Parameters
[in,out]a_otherOther instance to move from.
Returns
Reference to *this.

◆ signedDistance()

template<class T , class Meta , size_t K>
T EBGeometry::MeshSDF< T, Meta, K >::signedDistance ( const Vec3T< T > &  a_point) const
overridevirtualnoexcept

Compute the signed distance from a_point to the mesh.

Parameters
[in]a_pointQuery point.
Returns
Signed distance to the nearest face; negative inside the mesh.

Implements EBGeometry::SignedDistanceFunction< T >.

Member Data Documentation

◆ m_mesh

template<class T , class Meta , size_t K>
std::shared_ptr<Mesh> EBGeometry::MeshSDF< T, Meta, K >::m_mesh
protected

Source DCEL mesh.

Retained so that the faces held by m_bvh – whose half-edges (and the edges/vertices reachable from them) are only weakly referenced, not owned, see DCEL::FaceT::m_halfEdge – stay valid. The mesh's own vertex/edge/face vectors are the sole owners of that topology.


The documentation for this class was generated from the following file: