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, Meta > Class Template Reference

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

#include <EBGeometry_DCEL_Vertex.hpp>

Collaboration diagram for EBGeometry::DCEL::VertexT< T, Meta >:
Collaboration graph
[legend]

Public Types

using Vec3 = Vec3T< T >
 Alias for vector type.
 
using Vertex = VertexT< T, Meta >
 Alias for vertex type.
 
using Edge = EdgeT< T, Meta >
 Alias for edge type.
 
using Face = FaceT< T, Meta >
 Alias for face type.
 
using VertexPtr = std::shared_ptr< Vertex >
 Alias for vertex pointer type.
 
using EdgePtr = std::shared_ptr< Edge >
 Alias for edge pointer type.
 
using FacePtr = std::shared_ptr< Face >
 Alias for face pointer type.
 
using EdgeIterator = EdgeIteratorT< T, Meta >
 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)
 Copy constructor.
 
 VertexT (Vertex &&a_otherVertex)=default
 Move constructor.
 
 ~VertexT ()=default
 Destructor (does nothing)
 
Vertexoperator= (const Vertex &a_otherVertex)
 Copy assignment operator.
 
Vertexoperator= (Vertex &&a_otherVertex)=default
 Move assignment operator.
 
void define (const Vec3 &a_position, const EdgePtr &a_edge, 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 EdgePtr &a_edge) noexcept
 Set the reference to the outgoing edge.
 
void setMetaData (const Meta &a_metaData) noexcept
 Set the meta-data.
 
void addFace (const FacePtr &a_face)
 Add a face to the polygon face list.
 
void normalizeNormalVector () noexcept
 Normalize the normal vector, ensuring its length is 1.
 
void computeVertexNormalAverage () noexcept
 Compute the vertex normal, using an average the normal vector in this vertex's face list (m_faces)
 
void computeVertexNormalAverage (const std::vector< FacePtr > &a_faces) noexcept
 Compute the vertex normal, using an average of the normal vectors in the input face list.
 
void computeVertexNormalAngleWeighted ()
 Compute the vertex normal, using the pseudonormal algorithm which weights the normal with the subtended angle to each connected face.
 
void computeVertexNormalAngleWeighted (const std::vector< FacePtr > &a_faces)
 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.
 
EdgePtr getOutgoingEdge () noexcept
 Get the outgoing edge.
 
EdgePtr getOutgoingEdge () const noexcept
 Get the outgoing edge (const overload).
 
std::vector< FacePtr > & getFaces () noexcept
 Get modifiable polygon face list for this vertex.
 
const std::vector< FacePtr > & getFaces () const noexcept
 Get immutable polygon face list for this vertex.
 
signedDistance (const Vec3 &a_x0) const noexcept
 Get the signed distance to this vertex.
 
unsignedDistance2 (const Vec3 &a_x0) const noexcept
 Get the squared unsigned distance to this vertex.
 
MetagetMetaData () noexcept
 Get meta-data.
 
const MetagetMetaData () const noexcept
 Get meta-data.
 

Protected Attributes

std::weak_ptr< Edgem_outgoingEdge
 Pointer to an outgoing edge from this vertex.
 
Vec3 m_position
 Vertex position.
 
Vec3 m_normal
 Vertex normal vector.
 
std::vector< FacePtrm_faces
 List of faces connected to this vertex.
 
Meta m_metaData {}
 Meta-data for this vertex.
 

Detailed Description

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

Vertex class for navigating a DCEL mesh.

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

Template Parameters
TFloating-point precision type.
MetaUser-defined metadata 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 a pointer to one of the outgoing edges from the vertex. For performance reasons we also include pointers to all the polygon faces that share this 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.
Template Parameters
TFloating-point precision.
MetaMeta-data type stored per vertex.

Constructor & Destructor Documentation

◆ VertexT() [1/5]

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

Default constructor.

Defaulted: the position and normal vectors zero-initialize via Vec3T's own default constructor, the outgoing edge pointer defaults to null, the face list defaults to empty, and the meta-data value-initializes (see m_metaData). Not marked noexcept since Meta is an unconstrained template parameter whose default constructor is not guaranteed to be noexcept.

◆ VertexT() [2/5]

template<class T , class Meta >
EBGeometry::DCEL::VertexT< T, Meta >::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. The polygon face list is empty.

◆ VertexT() [3/5]

template<class T , class Meta >
EBGeometry::DCEL::VertexT< T, Meta >::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. The polygon face list is empty.

◆ VertexT() [4/5]

template<class T , class Meta >
EBGeometry::DCEL::VertexT< T, Meta >::VertexT ( const Vertex a_otherVertex)

Copy constructor.

Parameters
[in]a_otherVertexOther vertex.

Copies only the position, normal vector, and outgoing edge pointer from the other vertex. The polygon face list (m_faces) and meta-data (m_metaData) are deliberately NOT copied – they default-construct empty/default instead; use addFace()/setMetaData() afterwards if they need to be populated. Rationale: m_faces and m_outgoingEdge are back-references into a specific mesh's topology (the faces/edges they point to still reference the original vertex, not this copy), so copying them wholesale would not be topologically meaningful; only the geometric value (position, normal) survives a copy. operator=(const Vertex&) has identical semantics.

◆ VertexT() [5/5]

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

Move constructor.

Unlike the copy constructor, this transfers the entire state (including m_faces and m_metaData) from a_otherVertex, since moving relocates a single object's identity rather than grafting a copy into a different mesh's topology. Defaulted (memberwise move) rather than hand-written: explicitly defaulting is required here since the presence of a user-declared copy constructor would otherwise suppress the implicitly-generated move constructor. Not marked noexcept since Meta is an unconstrained template parameter whose move constructor is not guaranteed to be noexcept.

Parameters
[in,out]a_otherVertexOther vertex.

Member Function Documentation

◆ addFace()

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::addFace ( const FacePtr a_face)
inline

Add a face to the polygon face list.

Parameters
[in]a_facePointer to face.

◆ computeVertexNormalAngleWeighted() [1/2]

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::computeVertexNormalAngleWeighted ( )
inline

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

This calls the other version with a_faces = m_faces

Note
This computes the normal vector using the pseudnormal algorithm from Baerentzen and Aanes in "Signed distance computation using the angle weighted pseudonormal" (DOI: 10.1109/TVCG.2005.49)

◆ computeVertexNormalAngleWeighted() [2/2]

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::computeVertexNormalAngleWeighted ( const std::vector< FacePtr > &  a_faces)
inline

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

Parameters
[in]a_facesFaces to use for computation.
Note
This computes the normal vector using the pseudnormal algorithm from Baerentzen and Aanes in "Signed distance computation using the angle weighted pseudonormal" (DOI: 10.1109/TVCG.2005.49)

◆ computeVertexNormalAverage()

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::computeVertexNormalAverage ( const std::vector< FacePtr > &  a_faces)
inlinenoexcept

Compute the vertex normal, using an average of the normal vectors in the input face list.

Parameters
[in]a_facesFaces
Note
This computes the vertex normal as n = sum(normal(face))/num(faces)

◆ define()

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::define ( const Vec3 a_position,
const EdgePtr a_edge,
const Vec3 a_normal 
)
inlinenoexcept

Define function.

Parameters
[in]a_positionVertex position
[in]a_edgePointer to outgoing edge
[in]a_normalVertex normal vector

This sets the position, normal vector, and edge pointer.

◆ getFaces() [1/2]

template<class T , class Meta >
const std::vector< FacePtr > & EBGeometry::DCEL::VertexT< T, Meta >::getFaces ( ) const
inlinenoexcept

Get immutable polygon face list for this vertex.

Returns
Const reference to m_faces.

◆ getFaces() [2/2]

template<class T , class Meta >
std::vector< FacePtr > & EBGeometry::DCEL::VertexT< T, Meta >::getFaces ( )
inlinenoexcept

Get modifiable polygon face list for this vertex.

Returns
Reference to m_faces.

◆ getMetaData() [1/2]

template<class T , class Meta >
const Meta & EBGeometry::DCEL::VertexT< T, Meta >::getMetaData ( ) const
inlinenoexcept

Get meta-data.

Returns
m_metaData

◆ getMetaData() [2/2]

template<class T , class Meta >
Meta & EBGeometry::DCEL::VertexT< T, Meta >::getMetaData ( )
inlinenoexcept

Get meta-data.

Returns
m_metaData

◆ getNormal() [1/2]

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

Return immutable vertex normal vector.

Returns
Const reference to m_normal.

◆ getNormal() [2/2]

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

Return modifiable vertex normal vector.

Returns
Reference to m_normal.

◆ getOutgoingEdge() [1/2]

template<class T , class Meta >
EdgePtr EBGeometry::DCEL::VertexT< T, Meta >::getOutgoingEdge ( ) const
inlinenoexcept

Get the outgoing edge (const overload).

Returns
Outgoing edge, or nullptr.

◆ getOutgoingEdge() [2/2]

template<class T , class Meta >
EdgePtr EBGeometry::DCEL::VertexT< T, Meta >::getOutgoingEdge ( )
inlinenoexcept

Get the outgoing edge.

Returns a shared_ptr obtained by locking the internal weak_ptr (see the class-level note on ownership near m_outgoingEdge). Returns nullptr if the edge has been destroyed, which should not happen while the owning mesh is alive.

Returns
Outgoing edge, or nullptr.

◆ getPosition() [1/2]

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

Return immutable vertex position.

Returns
Const reference to m_position.

◆ getPosition() [2/2]

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

Return modifiable vertex position.

Returns
Reference to m_position.

◆ normalizeNormalVector()

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::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 , class Meta >
Vertex & EBGeometry::DCEL::VertexT< T, Meta >::operator= ( const Vertex a_otherVertex)

Copy assignment operator.

Has the same narrow-copy semantics as the copy constructor (including that m_faces and m_metaData are not copied; use addFace()/setMetaData() afterwards if they need to be populated). See the copy constructor's documentation for details.

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

◆ operator=() [2/2]

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

Move assignment operator.

Has the same full-state-transfer semantics as the move constructor (defaulted memberwise move; see its documentation for why this must be defaulted explicitly).

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

◆ setEdge()

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::setEdge ( const EdgePtr a_edge)
inlinenoexcept

Set the reference to the outgoing edge.

Parameters
[in]a_edgePointer to an outgoing edge

◆ setMetaData()

template<class T , class Meta >
void EBGeometry::DCEL::VertexT< T, Meta >::setMetaData ( const Meta a_metaData)
inlinenoexcept

Set the meta-data.

Parameters
[in]a_metaDataMeta-data.

◆ setNormal()

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

Set the vertex normal vector.

Parameters
[in]a_normalVertex normal vector

◆ setPosition()

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

Set the vertex position.

Parameters
[in]a_positionVertex position

◆ signedDistance()

template<class T , class Meta >
T EBGeometry::DCEL::VertexT< T, Meta >::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 * |a_x0 - m_position|.

◆ unsignedDistance2()

template<class T , class Meta >
T EBGeometry::DCEL::VertexT< T, Meta >::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_faces

template<class T , class Meta >
std::vector<FacePtr> EBGeometry::DCEL::VertexT< T, Meta >::m_faces
protected

List of faces connected to this vertex.

These must be added by addFace(), and is used when computing the vertex normal vector.

◆ m_metaData

template<class T , class Meta >
Meta EBGeometry::DCEL::VertexT< T, Meta >::m_metaData {}
protected

Meta-data for this vertex.

Value-initialized so that every constructor leaves it in a defined state: for a fundamental Meta type (e.g. short, int), a member with no initializer and no explicit mention in a constructor's member-initializer list is left indeterminate, not zero.

◆ m_outgoingEdge

template<class T , class Meta >
std::weak_ptr<Edge> EBGeometry::DCEL::VertexT< T, Meta >::m_outgoingEdge
protected

Pointer to an outgoing edge from this vertex.

Stored as a weak_ptr: the edge is owned by the mesh's own edge list, and a plain shared_ptr here would form a reference cycle with EdgeT::m_vertex (and, transitively, with EdgeT::m_nextEdge/m_pairEdge/m_face and FaceT::m_halfEdge) that shared_ptr's reference counting can never collect.


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