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

DCEL mesh class - stores a doubly-connected edge mesh. More...

#include <EBGeometry_DCEL_Mesh.hpp>

Inheritance diagram for EBGeometry::DCEL::MeshT< T >:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::DCEL::MeshT< T >:
Collaboration graph
[legend]

Classes

struct  Layout
 The mesh's arrays as offsets into its pool, with no location: what another pool-resident object stores when it holds this mesh (see PoolHandle). More...
 

Public Types

enum class  SearchAlgorithm { Direct , Direct2 }
 Possible search algorithms for DCEL::MeshT. More...
 
using Vec3 = Vec3T< T >
 Alias for vector type.
 
using Vertex = VertexT< T >
 Alias for vertex type.
 
using Edge = EdgeT< T >
 Alias for edge type.
 
using Face = FaceT< T >
 Alias for face type.
 
using Mesh = MeshT< T >
 Alias for mesh type.
 

Public Member Functions

 MeshT () noexcept=default
 Default constructor. Leaves the mesh empty (no vertices, edges, faces) and attached to no Pool, so it cannot yet resolve anything.
 
 MeshT (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.
 
Layout layout () const noexcept
 The mesh's arrays without its location, for storing it inside another pool-resident object.
 
 MeshT (const Mesh &a_otherMesh) noexcept=default
 Copy constructor.
 
 MeshT (Mesh &&a_otherMesh) noexcept=default
 Move constructor.
 
 ~MeshT () noexcept=default
 Destructor (does nothing; MeshT owns no resources).
 
Mesh & operator= (const Mesh &a_otherMesh) noexcept=default
 Copy assignment operator.
 
Mesh & operator= (Mesh &&a_otherMesh) noexcept=default
 Move assignment operator.
 
Mesh deepCopy (Pool &a_dstPool) const
 Create an independent, fully-decoupled copy of this mesh's data in another Pool.
 
void sanityCheck (const std::string a_id) const
 Perform a sanity check.
 
void setSearchAlgorithm (const SearchAlgorithm a_algorithm) noexcept
 Search algorithm for direct signed distance computations.
 
void setInsideOutsideAlgorithm (InsideOutsideAlgorithm a_algorithm) noexcept
 Set the inside/outside algorithm to use when computing the signed distance to polygon faces.
 
void reconcile ()
 Reconcile function which computes the internal parameters in vertices, edges, and faces for use with signed distance functionality.
 
void flip () noexcept
 Flip the mesh, making all the normals change direction.
 
void reserveVertices (Pool &a_pool, uint32_t a_capacity)
 Reserve storage for a_capacity vertices.
 
void reserveEdges (Pool &a_pool, uint32_t a_capacity)
 Reserve storage for a_capacity half-edges.
 
void reserveFaces (Pool &a_pool, uint32_t a_capacity)
 Reserve storage for a_capacity faces.
 
uint32_t addVertex (Pool &a_pool, const Vertex &a_vertex)
 Append a vertex into the pre-reserved capacity (see reserveVertices()).
 
uint32_t addEdge (Pool &a_pool, const Edge &a_edge)
 Append a half-edge into the pre-reserved capacity (see reserveEdges()).
 
uint32_t addFace (Pool &a_pool, const Face &a_face)
 Append a face into the pre-reserved capacity (see reserveFaces()).
 
Vertex & getVertex (uint32_t a_index) noexcept
 Get modifiable vertex by index.
 
const Vertex & getVertex (uint32_t a_index) const noexcept
 Get immutable vertex by index.
 
Edge & getEdge (uint32_t a_index) noexcept
 Get modifiable half-edge by index.
 
const Edge & getEdge (uint32_t a_index) const noexcept
 Get immutable half-edge by index.
 
Face & getFace (uint32_t a_index) noexcept
 Get modifiable face by index.
 
const Face & getFace (uint32_t a_index) const noexcept
 Get immutable face by index.
 
uint32_t numVertices () const noexcept
 Number of vertices in this mesh.
 
uint32_t numEdges () const noexcept
 Number of half-edges in this mesh.
 
uint32_t numFaces () const noexcept
 Number of faces in this mesh.
 
std::vector< Vec3T< T > > getAllVertexCoordinates () const
 Return all vertex coordinates in the mesh.
 
T signedDistance (const Vec3 &a_x0) const noexcept
 Compute the signed distance from a point to this mesh.
 
T signedDistance (const Vec3 &a_x0, SearchAlgorithm a_algorithm) const noexcept
 Compute the signed distance from a point to this mesh, using an explicit search algorithm.
 
T unsignedDistance2 (const Vec3 &a_x0) const noexcept
 Compute the unsigned square distance from a point to this mesh.
 
Mesh rebasedView (const Pool &a_pool) const noexcept
 Produce a copy of this mesh's descriptor that resolves against a mirror of this mesh's Pool, rather than against the Pool the mesh was built in.
 
- Public Member Functions inherited from EBGeometry::PoolHandle
PoolLocation location () const noexcept
 Where this handle's arrays live.
 
bool isAttachedTo (const Pool &a_pool) const noexcept
 Check whether this handle's arrays were reserved from a_pool.
 

Protected Member Functions

void attachTo (const Pool &a_pool) noexcept
 Attach this mesh to a_pool, or check that it is already attached to it.
 
void reconcileFaces () noexcept
 Function which computes internal things for the polygon faces.
 
void reconcileEdges () noexcept
 Function which computes internal things for the half-edges.
 
void reconcileVertices ()
 Compute each vertex's angle-weighted pseudonormal.
 
void flipFaceNormals () noexcept
 Flip all face normals.
 
void flipEdgeNormals () noexcept
 Flip all edge normals.
 
void flipVertexNormals () noexcept
 Flip all vertex normals.
 
T DirectSignedDistance (const Vec3 &a_point) const noexcept
 Implementation of signed distance function which iterates through all faces.
 
T DirectSignedDistance2 (const Vec3 &a_point) const noexcept
 Implementation of signed distance function which iterates through all faces, comparing squared unsigned distances.
 
void incrementWarning (std::map< std::string, size_t > &a_warnings, const std::string &a_warn) const
 Increment a warning. This is used in sanityCheck() for locating holes or bad inputs in the mesh.
 
void printWarnings (const std::map< std::string, size_t > &a_warnings, const std::string &a_id) const
 Print all warnings to std::cerr.
 
bool faceLoopCloses (uint32_t a_faceIndex, uint32_t &a_lastEdge, uint32_t &a_steps) const noexcept
 Walk a face's half-edge loop, bounded by the number of half-edges.
 
- Protected Member Functions inherited from EBGeometry::PoolHandle
 PoolHandle () noexcept=default
 An unset location; the first reservation attaches it.
 
 PoolHandle (const PoolLocation &a_location) noexcept
 Adopt a location, as a handle rebuilt from a stored layout does.
 
 PoolHandle (const PoolHandle &) noexcept=default
 Copy a handle, as a derived handle's copy does.
 
 PoolHandle (PoolHandle &&) noexcept=default
 Move a handle; the same as a copy.
 
PoolHandle & operator= (const PoolHandle &) noexcept=default
 Copy-assign a handle, as a derived handle's assignment does.
 
PoolHandle & operator= (PoolHandle &&) noexcept=default
 Move-assign a handle; the same as a copy.
 
 ~PoolHandle () noexcept=default
 Destructor; protected, since a PoolHandle exists only as the base of a handle.
 
void * base () noexcept
 The base address this handle's offsets resolve against; see PoolLocation::base().
 
const void * base () const noexcept
 The base address this handle's offsets resolve against, for read-only access.
 
void attach (const Pool &a_pool, const char *a_who) noexcept
 Follow a_pool, as the first reservation does; see PoolLocation::attach().
 
PoolLocation rebasedLocation (const Pool &a_pool, uint64_t a_endByte, const char *a_who) const noexcept
 The location of this handle's arrays in another pool of its mirror chain; see PoolLocation::rebasedOnto().
 
void setLocation (const PoolLocation &a_location) noexcept
 Replace the location, for a view or a copy made by a derived handle.
 

Protected Attributes

SearchAlgorithm m_algorithm = SearchAlgorithm::Direct2
 Search algorithm. Only used in signed distance functions.
 
PODVector< Vertex > m_vertices
 Mesh vertices.
 
PODVector< Edge > m_edges
 Mesh half-edges.
 
PODVector< Face > m_faces
 Mesh faces.
 

Detailed Description

template<class T>
class EBGeometry::DCEL::MeshT< T >

DCEL mesh class - stores a doubly-connected edge mesh.

Mesh class which stores a full DCEL mesh (with signed distance functions)

Template Parameters
TFloating-point precision type.

This encapsulates a full DCEL mesh, and also includes DIRECT signed distance functions. The mesh consists of a set of vertices, half-edges, and polygon faces, stored as PODVectors; every cross-reference between them (vertex-to-outgoing-edge, edge-to-vertex/pair edge/next edge/face, face-to-half-edge) is an index into these arrays rather than a pointer – see the class-level notes on VertexT/EdgeT/FaceT. The signed distance functions DIRECT, which means that they go through ALL of the polygon faces and compute the signed distance to them. This is extremely inefficient, which is why this class is almost always embedded into a bounding volume hierarchy.

Note
MeshT owns no resources: every member (three PODVectors, the search-algorithm enum, and the PoolLocation held by its PoolHandle base) is a plain value, so MeshT is trivially copyable – a bytewise copy is meaningful in any address space, since it never needs to dereference anything beyond its own bytes. This is what makes a mesh built and reconciled on the host mirror-safe: its Pool can be mirrored to a device and the mesh rebased onto the mirror (see rebasedView()), with zero pointer patching inside the mesh itself.

A mesh resolves its PODVector offsets through its PoolLocation (see PoolHandle and PoolLocation::base()), which takes one of two forms:

Member Enumeration Documentation

◆ SearchAlgorithm

template<class T >
enum class EBGeometry::DCEL::MeshT::SearchAlgorithm
strong

Possible search algorithms for DCEL::MeshT.

Enumerator
Direct 

Computes the signed distance to every face and returns the one with the smallest magnitude. See DirectSignedDistance().

Direct2 

Computes the squared unsigned distance to every face to find the closest one, then returns the signed distance to only that face. Equivalent to Direct but usually faster since it avoids a square root per face. See DirectSignedDistance2().

Constructor & Destructor Documentation

◆ MeshT() [1/4]

template<class T >
EBGeometry::DCEL::MeshT< T >::MeshT ( )
defaultnoexcept

Default constructor. Leaves the mesh empty (no vertices, edges, faces) and attached to no Pool, so it cannot yet resolve anything.

No Pool is needed at construction – every build-phase method (reserveX/addX) takes its Pool explicitly. Use reserveVertices()/reserveEdges()/reserveFaces() followed by addVertex()/addEdge()/addFace() to populate the mesh (a file parser normally does this); the first reserve attaches the mesh to that Pool, after which it is queryable immediately – there is no separate binding or freezing step.

◆ MeshT() [2/4]

template<class T >
EBGeometry::DCEL::MeshT< T >::MeshT ( const Layout &  a_layout,
const PoolLocation &  a_location 
)
inlinenoexcept

Rebuild a handle from a stored layout and the location of the pool that holds it.

How an outer pool-resident object evaluates a mesh it stores as a layout: it pairs the layout with its own location. a_location must belong to the pool the layout was reserved from, or to a mirror of it; nothing is checked, since a device has no pool to check against.

Parameters
[in]a_layoutThe mesh's arrays.
[in]a_locationWhere they live.

◆ MeshT() [3/4]

template<class T >
EBGeometry::DCEL::MeshT< T >::MeshT ( const Mesh &  a_otherMesh)
defaultnoexcept

Copy constructor.

Defaulted memberwise copy. Every member is a plain value (three PODVectors, the search-algorithm enum, and the PoolLocation held by the PoolHandle base), so this is a cheap, always-safe descriptor copy – it does NOT duplicate the underlying vertex/edge/face data, which stays shared between the original and the copy (both still resolve against the same Pool/base). Use deepCopy() when independent, separately-owned storage is required (e.g. in a different Pool).

Parameters
[in]a_otherMeshOther mesh.

◆ MeshT() [4/4]

template<class T >
EBGeometry::DCEL::MeshT< T >::MeshT ( Mesh &&  a_otherMesh)
defaultnoexcept

Move constructor.

Defaulted memberwise move. Since every member is a plain value, this is identical to the copy constructor – the moved-from mesh is left referencing the exact same data (not emptied), since MeshT never owned that data in the first place.

Parameters
[in,out]a_otherMeshOther mesh.

Member Function Documentation

◆ addEdge()

template<class T >
uint32_t EBGeometry::DCEL::MeshT< T >::addEdge ( Pool &  a_pool,
const Edge &  a_edge 
)
inline

Append a half-edge into the pre-reserved capacity (see reserveEdges()).

Parameters
[in,out]a_poolPool this mesh's half-edges were reserved from.
[in]a_edgeHalf-edge to append.
Returns
Index of the newly-appended half-edge in this mesh's edge array.

◆ addFace()

template<class T >
uint32_t EBGeometry::DCEL::MeshT< T >::addFace ( Pool &  a_pool,
const Face &  a_face 
)
inline

Append a face into the pre-reserved capacity (see reserveFaces()).

Parameters
[in,out]a_poolPool this mesh's faces were reserved from.
[in]a_faceFace to append.
Returns
Index of the newly-appended face in this mesh's face array.

◆ addVertex()

template<class T >
uint32_t EBGeometry::DCEL::MeshT< T >::addVertex ( Pool &  a_pool,
const Vertex &  a_vertex 
)
inline

Append a vertex into the pre-reserved capacity (see reserveVertices()).

Parameters
[in,out]a_poolPool this mesh's vertices were reserved from.
[in]a_vertexVertex to append.
Returns
Index of the newly-appended vertex in this mesh's vertex array.

◆ attachTo()

template<class T >
void EBGeometry::DCEL::MeshT< T >::attachTo ( const Pool &  a_pool)
inlineprotectednoexcept

Attach this mesh to a_pool, or check that it is already attached to it.

Called by every reserveX(); a mesh's storage must come from exactly one Pool, and reserving from a second one aborts, in every build.

Parameters
[in]a_poolPool being reserved from.

◆ deepCopy()

template<class T >
Mesh EBGeometry::DCEL::MeshT< T >::deepCopy ( Pool &  a_dstPool) const
inline

Create an independent, fully-decoupled copy of this mesh's data in another Pool.

Reserves fresh storage in a_dstPool and copies every vertex/edge/face by value; since every cross-reference is an index rather than a pointer, the copy is already fully independent and correctly linked – no relinking pass is needed. Every field is preserved exactly (position, normal vector, centroid, area, search algorithm) rather than recomputed, so a mesh that has had flipNormal()/flip() called on it and not yet been re-reconciled is copied faithfully rather than silently "un-flipped". Unlike the copy/move constructors, this creates genuinely separate storage rather than sharing the source's, and the returned mesh is attached to a_dstPool.

Note
a_dstPool may be the same Pool this mesh's data already lives in. That is safe even though the reserves below can grow (and move) the block, because both meshes re-resolve through the Pool's control block on every access rather than caching an address.
Parameters
[in,out]a_dstPoolPool to reserve the copy's storage from.
Returns
A new mesh, independent of this one, by value.

◆ DirectSignedDistance()

template<class T >
T EBGeometry::DCEL::MeshT< T >::DirectSignedDistance ( const Vec3 &  a_point) const
inlineprotectednoexcept

Implementation of signed distance function which iterates through all faces.

Parameters
[in]a_point3D point
Returns
Signed distance to the nearest face, or +infinity if the mesh has no faces.

◆ DirectSignedDistance2()

template<class T >
T EBGeometry::DCEL::MeshT< T >::DirectSignedDistance2 ( const Vec3 &  a_point) const
inlineprotectednoexcept

Implementation of signed distance function which iterates through all faces, comparing squared unsigned distances.

This first finds the face with the smallest unsigned squared distance, and then returns the signed distance to that face (more efficient than the other version).

Parameters
[in]a_point3D point
Returns
Signed distance to the nearest face, or +infinity if the mesh has no faces.

◆ faceLoopCloses()

template<class T >
bool EBGeometry::DCEL::MeshT< T >::faceLoopCloses ( uint32_t  a_faceIndex,
uint32_t &  a_lastEdge,
uint32_t &  a_steps 
) const
inlineprotectednoexcept

Walk a face's half-edge loop, bounded by the number of half-edges.

EdgeIteratorT does not count its steps, so it would never finish on a loop that cycles without returning to its first edge, and it reads out of bounds at an edge index past the end of the edge array. This walk stops on both. reconcile() aborts on such a loop and sanityCheck() reports it.

Parameters
[in]a_faceIndexFace whose loop to walk.
[out]a_lastEdgeThe edge index the walk stopped at (the face's first edge if the loop closes).
[out]a_stepsThe number of steps taken.
Returns
True if the loop returns to the face's first edge.

◆ flip()

template<class T >
void EBGeometry::DCEL::MeshT< T >::flip ( )
inlinenoexcept

Flip the mesh, making all the normals change direction.

Note
Should be called AFTER all normals have been computed.

◆ getAllVertexCoordinates()

template<class T >
std::vector< Vec3T< T > > EBGeometry::DCEL::MeshT< T >::getAllVertexCoordinates ( ) const
inline

Return all vertex coordinates in the mesh.

Returns
Vector of 3D coordinates of all vertices.

◆ getEdge() [1/2]

template<class T >
const Edge & EBGeometry::DCEL::MeshT< T >::getEdge ( uint32_t  a_index) const
inlinenoexcept

Get immutable half-edge by index.

Warning
The returned reference is invalidated by any Pool::reserve on this mesh's Pool; see the class-level warning.
Parameters
[in]a_indexHalf-edge index (must be < numEdges()).
Returns
Const reference to the half-edge.

◆ getEdge() [2/2]

template<class T >
Edge & EBGeometry::DCEL::MeshT< T >::getEdge ( uint32_t  a_index)
inlinenoexcept

Get modifiable half-edge by index.

Warning
The returned reference is invalidated by any Pool::reserve on this mesh's Pool; see the class-level warning.
Parameters
[in]a_indexHalf-edge index (must be < numEdges()).
Returns
Reference to the half-edge.

◆ getFace() [1/2]

template<class T >
const Face & EBGeometry::DCEL::MeshT< T >::getFace ( uint32_t  a_index) const
inlinenoexcept

Get immutable face by index.

Warning
The returned reference is invalidated by any Pool::reserve on this mesh's Pool; see the class-level warning.
Parameters
[in]a_indexFace index (must be < numFaces()).
Returns
Const reference to the face.

◆ getFace() [2/2]

template<class T >
Face & EBGeometry::DCEL::MeshT< T >::getFace ( uint32_t  a_index)
inlinenoexcept

Get modifiable face by index.

Warning
The returned reference is invalidated by any Pool::reserve on this mesh's Pool; see the class-level warning.
Parameters
[in]a_indexFace index (must be < numFaces()).
Returns
Reference to the face.

◆ getVertex() [1/2]

template<class T >
const Vertex & EBGeometry::DCEL::MeshT< T >::getVertex ( uint32_t  a_index) const
inlinenoexcept

Get immutable vertex by index.

Warning
The returned reference is invalidated by any Pool::reserve on this mesh's Pool; see the class-level warning.
Parameters
[in]a_indexVertex index (must be < numVertices()).
Returns
Const reference to the vertex.

◆ getVertex() [2/2]

template<class T >
Vertex & EBGeometry::DCEL::MeshT< T >::getVertex ( uint32_t  a_index)
inlinenoexcept

Get modifiable vertex by index.

Warning
The returned reference is invalidated by any Pool::reserve on this mesh's Pool; see the class-level warning.
Parameters
[in]a_indexVertex index (must be < numVertices()).
Returns
Reference to the vertex.

◆ incrementWarning()

template<class T >
void EBGeometry::DCEL::MeshT< T >::incrementWarning ( std::map< std::string, size_t > &  a_warnings,
const std::string &  a_warn 
) const
inlineprotected

Increment a warning. This is used in sanityCheck() for locating holes or bad inputs in the mesh.

Parameters
[in]a_warningsMap of all registered warnings
[in]a_warnCurrent warning to increment by

◆ layout()

template<class T >
Layout EBGeometry::DCEL::MeshT< T >::layout ( ) const
inlinenoexcept

The mesh's arrays without its location, for storing it inside another pool-resident object.

Returns
The layout.

◆ numEdges()

template<class T >
uint32_t EBGeometry::DCEL::MeshT< T >::numEdges ( ) const
inlinenoexcept

Number of half-edges in this mesh.

Returns
Half-edge count.

◆ numFaces()

template<class T >
uint32_t EBGeometry::DCEL::MeshT< T >::numFaces ( ) const
inlinenoexcept

Number of faces in this mesh.

Returns
Face count.

◆ numVertices()

template<class T >
uint32_t EBGeometry::DCEL::MeshT< T >::numVertices ( ) const
inlinenoexcept

Number of vertices in this mesh.

Returns
Vertex count.

◆ operator=() [1/2]

template<class T >
Mesh & EBGeometry::DCEL::MeshT< T >::operator= ( const Mesh &  a_otherMesh)
defaultnoexcept

Copy assignment operator.

Has the same semantics as the copy constructor; see its documentation.

Parameters
[in]a_otherMeshOther mesh.
Returns
Reference to (*this).

◆ operator=() [2/2]

template<class T >
Mesh & EBGeometry::DCEL::MeshT< T >::operator= ( Mesh &&  a_otherMesh)
defaultnoexcept

Move assignment operator.

Has the same semantics as the move constructor; see its documentation.

Parameters
[in,out]a_otherMeshOther mesh.
Returns
Reference to (*this).

◆ printWarnings()

template<class T >
void EBGeometry::DCEL::MeshT< T >::printWarnings ( const std::map< std::string, size_t > &  a_warnings,
const std::string &  a_id 
) const
inlineprotected

Print all warnings to std::cerr.

Parameters
[in]a_warningsList of warnings (generated by sanityCheck)
[in]a_idIdentifier used when printing warnings (can be empty string)

◆ rebasedView()

template<class T >
Mesh EBGeometry::DCEL::MeshT< T >::rebasedView ( const Pool &  a_pool) const
inlinenoexcept

Produce a copy of this mesh's descriptor that resolves against a mirror of this mesh's Pool, rather than against the Pool the mesh was built in.

This is the one sanctioned way to move a mesh between address spaces. Only the descriptor is copied – the vertex/edge/face data is whatever a_pool already contains, which Pool::mirror put there. Since every cross-reference is a byte offset rather than a pointer, no patching is needed on either side:

hostPool.freeze();
Pool devicePool = Pool::mirror(hostPool, deviceMemoryResource());
const Mesh deviceMesh = mesh.rebasedView(devicePool); // rebase on the host ...
myKernel<<<blocks, threads>>>(deviceMesh, ...); // ... then copy by value
DCEL mesh class - stores a doubly-connected edge mesh.
Definition EBGeometry_DCEL_Mesh.hpp:100
Mesh rebasedView(const Pool &a_pool) const noexcept
Produce a copy of this mesh's descriptor that resolves against a mirror of this mesh's Pool,...
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:183
static Pool mirror(const Pool &a_src, MemoryResource &a_dstResource)
Mirror a frozen pool's whole block into another resource.
DeviceMemoryResource & deviceMemoryResource() noexcept
Process-wide default device memory resource.

How the returned view resolves depends on a_pool, not on a separate choice by the caller (see PoolLocation::rebasedOnto()):

  • a device-accessible target (Device, Managed, Mapped), which must be frozen, yields a view holding a plain base address, since a kernel cannot follow a host control block. The host can use the view too if the memory is host-accessible (Managed, Mapped), but not for a Device pool.
  • a host-only target (Host, Pinned) yields a view holding that Pool's control block, so it is growth-immune exactly like the original mesh.
    Note
    a_pool must be the Pool this mesh was built in or belong to its mirror chain – a mirror of it, or a mirror of a mirror (so host -> pinned staging -> device works, including rebasing a view of the staging pool onto the device pool). It must also be large enough to contain this mesh's arrays, which catches a Pool mirrored before the mesh's last reserve. Each is checked in every build; a violation aborts with a message.
    Parameters
    [in]a_poolPool to rebase onto: this mesh's own Pool or one in its mirror chain.
    Returns
    A mesh descriptor resolving against a_pool.

◆ reconcile()

template<class T >
void EBGeometry::DCEL::MeshT< T >::reconcile ( )
inline

Reconcile function which computes the internal parameters in vertices, edges, and faces for use with signed distance functionality.

This will reconcile faces, edges, and vertices, e.g. computing the area and normal vector for faces, and the angle-weighted pseudonormal of each vertex (Baerentzen and Aanes, DOI: 10.1109/TVCG.2005.49). A malformed topology that would otherwise read out of bounds or never finish (a face whose half-edge loop does not return to its first edge, a face with fewer than 3 vertices, a vertex index past the end of the vertex array, or a face visiting a vertex more than once) aborts with a message in every build. A mesh assembled by hand must be reconciled before it is queried.

◆ reconcileEdges()

template<class T >
void EBGeometry::DCEL::MeshT< T >::reconcileEdges ( )
inlineprotectednoexcept

Function which computes internal things for the half-edges.

Note
This calls DCEL::EdgeT<T>::reconcile()

◆ reconcileFaces()

template<class T >
void EBGeometry::DCEL::MeshT< T >::reconcileFaces ( )
inlineprotectednoexcept

Function which computes internal things for the polygon faces.

Note
This calls DCEL::FaceT<T>::reconcile()

◆ reconcileVertices()

template<class T >
void EBGeometry::DCEL::MeshT< T >::reconcileVertices ( )
inlineprotected

Compute each vertex's angle-weighted pseudonormal.

Note
This calls DCEL::VertexT<T>::computeVertexNormalAngleWeighted().

◆ reserveEdges()

template<class T >
void EBGeometry::DCEL::MeshT< T >::reserveEdges ( Pool &  a_pool,
uint32_t  a_capacity 
)
inline

Reserve storage for a_capacity half-edges.

Must be called before any addEdge() call, and only once – PODVector never reallocates once reserved (see EBGeometry_PODVector.hpp).

Parameters
[in,out]a_poolPool to reserve from (must not be frozen).
[in]a_capacityNumber of half-edge slots to reserve.

◆ reserveFaces()

template<class T >
void EBGeometry::DCEL::MeshT< T >::reserveFaces ( Pool &  a_pool,
uint32_t  a_capacity 
)
inline

Reserve storage for a_capacity faces.

Must be called before any addFace() call, and only once – PODVector never reallocates once reserved (see EBGeometry_PODVector.hpp).

Parameters
[in,out]a_poolPool to reserve from (must not be frozen).
[in]a_capacityNumber of face slots to reserve.

◆ reserveVertices()

template<class T >
void EBGeometry::DCEL::MeshT< T >::reserveVertices ( Pool &  a_pool,
uint32_t  a_capacity 
)
inline

Reserve storage for a_capacity vertices.

Must be called before any addVertex() call, and only once – PODVector never reallocates once reserved (see EBGeometry_PODVector.hpp).

Parameters
[in,out]a_poolPool to reserve from (must not be frozen).
[in]a_capacityNumber of vertex slots to reserve.

◆ sanityCheck()

template<class T >
void EBGeometry::DCEL::MeshT< T >::sanityCheck ( const std::string  a_id) const
inline

Perform a sanity check.

This will provide error messages if vertices are badly linked, faces have no half-edge, and so on. These messages are logged by calling incrementWarning() which identifies types of errors that can occur, and how many of those errors have occurred. A face whose half-edge loop does not close is reported and skipped, so the check finishes on any mesh, reconciled or not.

Parameters
[in]a_idIdentifier when printing error messages (can be empty string).

◆ setInsideOutsideAlgorithm()

template<class T >
void EBGeometry::DCEL::MeshT< T >::setInsideOutsideAlgorithm ( InsideOutsideAlgorithm  a_algorithm)
inlinenoexcept

Set the inside/outside algorithm to use when computing the signed distance to polygon faces.

Computing the signed distance to faces requires testing if a point projected to a polygon face plane falls inside or outside the polygon face. There are multiple algorithms to use here.

Parameters
[in]a_algorithmAlgorithm to use

◆ setSearchAlgorithm()

template<class T >
void EBGeometry::DCEL::MeshT< T >::setSearchAlgorithm ( const SearchAlgorithm  a_algorithm)
inlinenoexcept

Search algorithm for direct signed distance computations.

Parameters
[in]a_algorithmAlgorithm to use

◆ signedDistance() [1/2]

template<class T >
T EBGeometry::DCEL::MeshT< T >::signedDistance ( const Vec3 &  a_x0) const
inlinenoexcept

Compute the signed distance from a point to this mesh.

Parameters
[in]a_x03D point in space.

This function will iterate through ALL faces in the mesh and return the value with the smallest magnitude. This is horrendously slow, which is why this function is almost never called. Rather, MeshT<T> can be embedded in a bounding volume hierarchy for faster access.

Note
This will call the other version with the object's search algorithm.
Returns
Signed distance to the mesh; negative inside, positive outside. Returns +infinity if the mesh has no faces.

◆ signedDistance() [2/2]

template<class T >
T EBGeometry::DCEL::MeshT< T >::signedDistance ( const Vec3 &  a_x0,
SearchAlgorithm  a_algorithm 
) const
inlinenoexcept

Compute the signed distance from a point to this mesh, using an explicit search algorithm.

Parameters
[in]a_x03D point in space.
[in]a_algorithmSearch algorithm

This function will iterate through ALL faces in the mesh and return the value with the smallest magnitude. This is horrendously slow, which is why this function is almost never called. Rather, MeshT<T> can be embedded in a bounding volume hierarchy for faster access.

Returns
Signed distance to the mesh; negative inside, positive outside. Returns +infinity if the mesh has no faces.

◆ unsignedDistance2()

template<class T >
T EBGeometry::DCEL::MeshT< T >::unsignedDistance2 ( const Vec3 &  a_x0) const
inlinenoexcept

Compute the unsigned square distance from a point to this mesh.

Parameters
[in]a_x03D point in space.

This function will iterate through ALL faces in the mesh and return the value with the smallest magnitude. This is horrendously slow, which is why this function is almost never called. Rather, MeshT<T> can be embedded in a bounding volume hierarchy for faster access.

Returns
Squared unsigned distance to the nearest face, or +infinity if the mesh has no faces.

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