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::DCEL::VertexT< T > Class Template Reference

Vertex class for navigating a DCEL mesh. More...

#include <EBGeometry_DCEL_Vertex.hpp>

Public Types

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.
 
using EdgeIterator = EdgeIteratorT< T >
 Alias for edge iterator.
 

Public Member Functions

 VertexT ()=default
 Default constructor.
 
 VertexT (const Vec3 &a_position)
 Partial constructor.
 
 VertexT (const Vec3 &a_position, const Vec3 &a_normal)
 Constructor.
 
 VertexT (const Vertex &a_otherVertex)=default
 Copy constructor.
 
 VertexT (Vertex &&a_otherVertex)=default
 Move constructor.
 
 ~VertexT ()=default
 Destructor (does nothing)
 
Vertex & operator= (const Vertex &a_otherVertex)=default
 Copy assignment operator.
 
Vertex & operator= (Vertex &&a_otherVertex)=default
 Move assignment operator.
 
void define (const Vec3 &a_position, const uint32_t a_edgeIndex, const Vec3 &a_normal) noexcept
 Define function.
 
void setPosition (const Vec3 &a_position) noexcept
 Set the vertex position.
 
void setNormal (const Vec3 &a_normal) noexcept
 Set the vertex normal vector.
 
void setEdge (const uint32_t a_edgeIndex) noexcept
 Set the index of the outgoing edge.
 
void normalizeNormalVector () noexcept
 Normalize the normal vector, ensuring its length is 1.
 
void computeVertexNormalAngleWeighted (const uint32_t a_thisVertexIndex, const std::vector< uint32_t > &a_faceIndices, const Mesh &a_mesh)
 Compute the vertex normal, using the pseudonormal algorithm which weights the normal with the subtended angle to each connected face.
 
void flipNormal () noexcept
 Flip the normal vector.
 
Vec3T< T > & getPosition () noexcept
 Return modifiable vertex position.
 
const Vec3T< T > & getPosition () const noexcept
 Return immutable vertex position.
 
Vec3T< T > & getNormal () noexcept
 Return modifiable vertex normal vector.
 
const Vec3T< T > & getNormal () const noexcept
 Return immutable vertex normal vector.
 
uint32_t getOutgoingEdgeIndex () const noexcept
 Get the index of the outgoing edge.
 
Edge & getOutgoingEdge (Mesh &a_mesh) noexcept
 Get the outgoing edge.
 
const Edge & getOutgoingEdge (const Mesh &a_mesh) const noexcept
 Get the outgoing edge (const overload).
 
T signedDistance (const Vec3 &a_x0) const noexcept
 Get the signed distance to this vertex.
 
T unsignedDistance2 (const Vec3 &a_x0) const noexcept
 Get the squared unsigned distance to this vertex.
 

Protected Attributes

uint32_t m_outgoingEdge = UINT32_MAX
 Index of an outgoing edge from this vertex.
 
Vec3 m_position = Vec3::zeros()
 Vertex position.
 
Vec3 m_normal = Vec3::zeros()
 Vertex normal vector.
 

Detailed Description

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

Vertex class for navigating a DCEL mesh.

Class which represents a vertex node in a doubly-connected edge list (DCEL).

Template Parameters
TFloating-point precision type.

This class is used in DCEL functionality which stores polygonal surfaces in a mesh. The VertexT class has a position, a normal vector, and the index of one of the outgoing edges from the vertex.

Note
The normal vector is outgoing, i.e. a point x is "outside" the vertex if the dot product between n and (x - x0) is positive.
m_outgoingEdge is an index into the owning DCEL::MeshT's own edge array, resolved by passing that mesh to the accessors below (see EdgeT for why indices rather than pointers are used). It is the sole topology this class stores: which faces touch this vertex is not cached here. Every member is a plain value (Vec3, uint32_t), so VertexT itself is trivially copyable. A vertex's id is its index in the mesh's vertex array. computeVertexNormalAngleWeighted() takes the touching-faces list as an explicit parameter instead: MeshT::reconcileVertices() builds it transiently by walking every face's own boundary loop (no pair edges needed, so this works even on a non-watertight/"dirty" mesh), and discards it once normals are computed. m_outgoingEdge itself is unrelated to this – it is not read by the normal computation – and remains purely a convenience for callers who want O(1) access to some edge leaving this vertex.
Every method that resolves purely through plain-value members and an explicitly-supplied Mesh& (getPosition/getNormal/getOutgoingEdgeIndex/ getOutgoingEdge, define, setPosition/setNormal/setEdge, normalizeNormalVector, flipNormal, signedDistance, unsignedDistance2) is annotated EBGEOMETRY_HOST_DEVICE. computeVertexNormalAngleWeighted() takes a std::vector<uint32_t>& and aborts with a message on a malformed face, so it remains EBGEOMETRY_HOST.
Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ VertexT() [1/5]

template<class T >
EBGeometry::DCEL::VertexT< T >::VertexT ( )
default

Default constructor.

Defaulted: the position and normal vectors are zero and the outgoing edge index is the unset sentinel, from their member initializers (see m_outgoingEdge).

◆ VertexT() [2/5]

template<class T >
EBGeometry::DCEL::VertexT< T >::VertexT ( const Vec3 &  a_position)

Partial constructor.

Parameters
[in]a_positionVertex position

This initializes the position to a_position and the normal vector to the zero vector.

◆ VertexT() [3/5]

template<class T >
EBGeometry::DCEL::VertexT< T >::VertexT ( const Vec3 &  a_position,
const Vec3 &  a_normal 
)

Constructor.

Parameters
[in]a_positionVertex position
[in]a_normalVertex normal vector

This initializes the position to a_position and the normal vector to a_normal.

◆ VertexT() [4/5]

template<class T >
EBGeometry::DCEL::VertexT< T >::VertexT ( const Vertex &  a_otherVertex)
default

Copy constructor.

Parameters
[in]a_otherVertexOther vertex.

Defaulted memberwise copy of every member – position, normal vector and outgoing edge index. This is what lets VertexT be trivially copyable: std::is_trivially_copyable requires the copy constructor to be the implicit/defaulted one, so a user-provided body – even one that does nothing but a plain memberwise copy – would disqualify it. operator=(const Vertex&) has identical semantics.

◆ VertexT() [5/5]

template<class T >
EBGeometry::DCEL::VertexT< T >::VertexT ( Vertex &&  a_otherVertex)
default

Move constructor.

Defaulted memberwise move; equivalent to the copy constructor since every member is a plain value.

Parameters
[in,out]a_otherVertexOther vertex.

Member Function Documentation

◆ computeVertexNormalAngleWeighted()

template<class T >
void EBGeometry::DCEL::VertexT< T >::computeVertexNormalAngleWeighted ( const uint32_t  a_thisVertexIndex,
const std::vector< uint32_t > &  a_faceIndices,
const Mesh &  a_mesh 
)
inline

Compute the vertex normal, using the pseudonormal algorithm which weights the normal with the subtended angle to each connected face.

Parameters
[in]a_thisVertexIndexThis vertex's own index in the owning mesh's vertex array, used to identify which of a face's vertices is "this" one while walking that face's boundary.
[in]a_faceIndicesIndices, into the owning mesh's face array, of every face touching this vertex. Not cached anywhere – callers (see MeshT::reconcileVertices()) discover this by walking each candidate face's own boundary loop, which needs no pair edges and so works regardless of whether the mesh is watertight.
[in]a_meshOwning mesh, used to resolve a_faceIndices and a_thisVertexIndex.
Note
This computes the normal vector using the pseudonormal algorithm from Baerentzen and Aanes in "Signed distance computation using the angle weighted pseudonormal" (DOI: 10.1109/TVCG.2005.49).
Every face in a_faceIndices with a non-zero normal must visit this vertex exactly once, and the vertex and its two neighbors on that face must have distinct positions. A violation aborts with a message in every build, rather than reading out of bounds or dividing by zero.

◆ define()

template<class T >
void EBGeometry::DCEL::VertexT< T >::define ( const Vec3 &  a_position,
const uint32_t  a_edgeIndex,
const Vec3 &  a_normal 
)
inlinenoexcept

Define function.

Parameters
[in]a_positionVertex position
[in]a_edgeIndexIndex of the outgoing edge in the owning mesh's edge array, or UINT32_MAX if not yet wired into a mesh.
[in]a_normalVertex normal vector

This sets the position, normal vector, and outgoing edge index.

◆ getNormal() [1/2]

template<class T >
const Vec3T< T > & EBGeometry::DCEL::VertexT< T >::getNormal ( ) const
inlinenoexcept

Return immutable vertex normal vector.

Returns
Const reference to m_normal.

◆ getNormal() [2/2]

template<class T >
Vec3T< T > & EBGeometry::DCEL::VertexT< T >::getNormal ( )
inlinenoexcept

Return modifiable vertex normal vector.

Returns
Reference to m_normal.

◆ getOutgoingEdge() [1/2]

template<class T >
const Edge & EBGeometry::DCEL::VertexT< T >::getOutgoingEdge ( const Mesh &  a_mesh) const
inlinenoexcept

Get the outgoing edge (const overload).

Parameters
[in]a_meshOwning mesh, used to resolve the outgoing edge index.
Returns
Const reference to the outgoing edge. m_outgoingEdge must be set (see getOutgoingEdgeIndex()).

◆ getOutgoingEdge() [2/2]

template<class T >
Edge & EBGeometry::DCEL::VertexT< T >::getOutgoingEdge ( Mesh &  a_mesh)
inlinenoexcept

Get the outgoing edge.

Parameters
[in]a_meshOwning mesh, used to resolve the outgoing edge index.
Returns
Reference to the outgoing edge. m_outgoingEdge must be set (see getOutgoingEdgeIndex()).

◆ getOutgoingEdgeIndex()

template<class T >
uint32_t EBGeometry::DCEL::VertexT< T >::getOutgoingEdgeIndex ( ) const
inlinenoexcept

Get the index of the outgoing edge.

Returns
Index of the outgoing edge in the owning mesh's edge array, or UINT32_MAX if unset.

◆ getPosition() [1/2]

template<class T >
const Vec3T< T > & EBGeometry::DCEL::VertexT< T >::getPosition ( ) const
inlinenoexcept

Return immutable vertex position.

Returns
Const reference to m_position.

◆ getPosition() [2/2]

template<class T >
Vec3T< T > & EBGeometry::DCEL::VertexT< T >::getPosition ( )
inlinenoexcept

Return modifiable vertex position.

Returns
Reference to m_position.

◆ normalizeNormalVector()

template<class T >
void EBGeometry::DCEL::VertexT< T >::normalizeNormalVector ( )
inlinenoexcept

Normalize the normal vector, ensuring its length is 1.

The current normal must not be (near-)zero-length; a zero-length normal cannot be normalized and is left unchanged (a no-op) rather than dividing by zero.

◆ operator=() [1/2]

template<class T >
Vertex & EBGeometry::DCEL::VertexT< T >::operator= ( const Vertex &  a_otherVertex)
default

Copy assignment operator.

Defaulted memberwise copy; see the copy constructor's documentation.

Parameters
[in]a_otherVertexOther vertex.
Returns
Reference to (*this).

◆ operator=() [2/2]

template<class T >
Vertex & EBGeometry::DCEL::VertexT< T >::operator= ( Vertex &&  a_otherVertex)
default

Move assignment operator.

Defaulted memberwise move; equivalent to copy assignment since every member is a plain value (see the copy constructor for why it must stay defaulted).

Parameters
[in,out]a_otherVertexOther vertex.
Returns
Reference to (*this).

◆ setEdge()

template<class T >
void EBGeometry::DCEL::VertexT< T >::setEdge ( const uint32_t  a_edgeIndex)
inlinenoexcept

Set the index of the outgoing edge.

Parameters
[in]a_edgeIndexIndex of an outgoing edge in the owning mesh's edge array, or UINT32_MAX to mark it unset.

◆ setNormal()

template<class T >
void EBGeometry::DCEL::VertexT< T >::setNormal ( const Vec3 &  a_normal)
inlinenoexcept

Set the vertex normal vector.

Parameters
[in]a_normalVertex normal vector

◆ setPosition()

template<class T >
void EBGeometry::DCEL::VertexT< T >::setPosition ( const Vec3 &  a_position)
inlinenoexcept

Set the vertex position.

Parameters
[in]a_positionVertex position

◆ signedDistance()

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

Get the signed distance to this vertex.

Parameters
[in]a_x0Position in space.
Returns
The returned distance is |a_x0 - m_position| and the sign is given by the sign of m_normal.dot(a_x0 - m_position); a dot product of zero gives a negative sign.

◆ unsignedDistance2()

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

Get the squared unsigned distance to this vertex.

This is faster to compute than signedDistance, and might be preferred for some algorithms.

Parameters
[in]a_x0Query position.
Returns
Squared Euclidean distance |a_x0 - m_position|^2.

Member Data Documentation

◆ m_outgoingEdge

template<class T >
uint32_t EBGeometry::DCEL::VertexT< T >::m_outgoingEdge = UINT32_MAX
protected

Index of an outgoing edge from this vertex.

Index into the owning DCEL::MeshT's edge array, or UINT32_MAX if unset. Not read by computeVertexNormalAngleWeighted(), which takes the touching faces as an explicit list; see the class notes.


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