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

Half-edge class for navigating a DCEL mesh. More...

#include <EBGeometry_DCEL_Edge.hpp>

Collaboration diagram for EBGeometry::DCEL::EdgeT< 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.
 

Public Member Functions

 EdgeT () noexcept=default
 Default constructor. Sets all pointers to zero and vectors to zero vectors.
 
 EdgeT (const Edge &a_otherEdge) noexcept
 Copy constructor.
 
 EdgeT (Edge &&a_otherEdge)=default
 Move constructor.
 
 EdgeT (const VertexPtr &a_vertex) noexcept
 Partial constructor. Calls the default constructor but sets the starting vertex.
 
 ~EdgeT ()=default
 Destructor (does nothing)
 
Edgeoperator= (const Edge &a_otherEdge) noexcept
 Copy assignment operator.
 
Edgeoperator= (Edge &&a_otherEdge)=default
 Move assignment operator.
 
size_t size () const noexcept
 Get size (in bytes) of this object.
 
void define (const VertexPtr &a_vertex, const EdgePtr &a_pairEdge, const EdgePtr &a_nextEdge) noexcept
 Define function. Sets the starting vertex, edges, and normal vectors.
 
void reconcile () noexcept
 Reconcile internal logic.
 
void flipNormal () noexcept
 Flip surface normal.
 
void setVertex (const VertexPtr &a_vertex) noexcept
 Set the starting vertex.
 
void setPairEdge (const EdgePtr &a_pairEdge) noexcept
 Set the pair edge.
 
void setNextEdge (const EdgePtr &a_nextEdge) noexcept
 Set the next edge.
 
void setFace (const FacePtr &a_face) noexcept
 Set the pointer to this half-edge's face.
 
void setMetaData (const Meta &a_metaData) noexcept
 Set the meta-data.
 
VertexPtr getVertex () noexcept
 Get the starting vertex.
 
VertexPtr getVertex () const noexcept
 Get the starting vertex (const overload).
 
VertexPtr getOtherVertex () noexcept
 Get the end vertex.
 
VertexPtr getOtherVertex () const noexcept
 Get the end vertex (const overload).
 
EdgePtr getPairEdge () noexcept
 Get the pair edge.
 
EdgePtr getPairEdge () const noexcept
 Get the pair edge (const overload).
 
EdgePtr getNextEdge () noexcept
 Get the next edge.
 
EdgePtr getNextEdge () const noexcept
 Get the next edge (const overload).
 
Vec3T< T > computeNormal () const noexcept
 Compute the normal vector as the average of the face normals on both sides of this edge.
 
Vec3T< T > & getNormal () noexcept
 Get modifiable normal vector.
 
const Vec3T< T > & getNormal () const noexcept
 Get the stored normal vector.
 
FacePtr getFace () noexcept
 Get this half-edge's face.
 
FacePtr getFace () const noexcept
 Get this half-edge's face (const overload).
 
MetagetMetaData () noexcept
 Get meta-data.
 
const MetagetMetaData () const noexcept
 Get meta-data.
 
signedDistance (const Vec3 &a_x0) const noexcept
 Get the signed distance from a_x0 to this half-edge.
 
unsignedDistance2 (const Vec3 &a_x0) const noexcept
 Get the squared unsigned distance from a_x0 to this half-edge.
 

Protected Member Functions

projectPointToEdge (const Vec3 &a_x0) const noexcept
 Returns the parametric projection of a_x0 onto this edge.
 
Vec3T< T > getX2X1 () const noexcept
 Get the vector pointing along this edge (from start to end vertex).
 

Protected Attributes

Vec3 m_normal = Vec3::zeros()
 Normal vector.
 
std::weak_ptr< Vertexm_vertex
 Starting vertex.
 
std::weak_ptr< Edgem_pairEdge
 Pair edge. See m_vertex for why this is a weak_ptr.
 
std::weak_ptr< Edgem_nextEdge
 Next edge. See m_vertex for why this is a weak_ptr.
 
std::weak_ptr< Facem_face
 Enclosing polygon face. See m_vertex for why this is a weak_ptr.
 
Meta m_metaData {}
 Meta-data attached to this edge.
 

Detailed Description

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

Half-edge class for navigating a DCEL mesh.

Class which represents a half-edge 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 information contain in an EdgeT object contains the necessary object for logically circulating the inside of a polygon face. This means that a polygon face has a double-connected list of half-edges which circulate the interior of the face. The EdgeT object is such a half-edge; it represents the outgoing half-edge from a vertex, located such that it can be logically represented as a half edge on the "inside" of a polygon face. It contains pointers to the polygon face, vertex, and next half edge It also contains a pointer to the "pair" half edge, i.e. the corresponding half-edge on the other face that shares this edge. Since this class is used with DCEL functionality and signed distance fields, this class also has a signed distance function and thus a "normal vector".

Note
The normal vector is outgoing, i.e. a point x is "outside" if the dot product between n and (x - x0) is positive.
Template Parameters
TFloating-point precision.
MetaMeta-data type stored per edge.

Constructor & Destructor Documentation

◆ EdgeT() [1/3]

template<class T , class Meta >
EBGeometry::DCEL::EdgeT< T, Meta >::EdgeT ( const Edge a_otherEdge)
noexcept

Copy constructor.

Copies the normal vector and all four topology pointers (vertex, pair edge, next edge, face) from the other half-edge. Meta-data (m_metaData) is deliberately NOT copied – it default-constructs instead; use setMetaData() afterwards if it needs to be populated. Rationale: same as VertexT's copy constructor – these pointers are back-references into a specific mesh's topology (the objects they point to still reference the original edge, not this copy), so copying them wholesale is not topologically meaningful in general, but is occasionally useful (e.g. duplicating an edge's geometric/adjacency snapshot). operator=(const Edge&) has identical semantics.

Parameters
[in]a_otherEdgeOther edge.

◆ EdgeT() [2/3]

template<class T , class Meta >
EBGeometry::DCEL::EdgeT< T, Meta >::EdgeT ( Edge &&  a_otherEdge)
default

Move constructor.

Unlike the copy constructor, this transfers the entire state (including m_metaData) from a_otherEdge, since moving relocates a single object's identity. 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_otherEdgeOther edge.

◆ EdgeT() [3/3]

template<class T , class Meta >
EBGeometry::DCEL::EdgeT< T, Meta >::EdgeT ( const VertexPtr a_vertex)
noexcept

Partial constructor. Calls the default constructor but sets the starting vertex.

Parameters
[in]a_vertexStarting vertex.

Member Function Documentation

◆ computeNormal()

template<class T , class Meta >
Vec3T< T > EBGeometry::DCEL::EdgeT< T, Meta >::computeNormal ( ) const
inlinenoexcept

Compute the normal vector as the average of the face normals on both sides of this edge.

Returns
Unit normal vector for this edge.

◆ define()

template<class T , class Meta >
void EBGeometry::DCEL::EdgeT< T, Meta >::define ( const VertexPtr a_vertex,
const EdgePtr a_pairEdge,
const EdgePtr a_nextEdge 
)
inlinenoexcept

Define function. Sets the starting vertex, edges, and normal vectors.

Parameters
[in]a_vertexStarting vertex
[in]a_pairEdgePair half-edge
[in]a_nextEdgeNext half-edge

◆ getFace() [1/2]

template<class T , class Meta >
FacePtr EBGeometry::DCEL::EdgeT< T, Meta >::getFace ( ) const
inlinenoexcept

Get this half-edge's face (const overload).

Returns
Owning face, or nullptr.

◆ getFace() [2/2]

template<class T , class Meta >
FacePtr EBGeometry::DCEL::EdgeT< T, Meta >::getFace ( )
inlinenoexcept

Get this half-edge's face.

Returns
Owning face, or nullptr.

◆ getMetaData() [1/2]

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

Get meta-data.

Returns
m_metaData

◆ getMetaData() [2/2]

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

Get meta-data.

Returns
m_metaData

◆ getNextEdge() [1/2]

template<class T , class Meta >
EdgePtr EBGeometry::DCEL::EdgeT< T, Meta >::getNextEdge ( ) const
inlinenoexcept

Get the next edge (const overload).

Returns
Next edge, or nullptr.

◆ getNextEdge() [2/2]

template<class T , class Meta >
EdgePtr EBGeometry::DCEL::EdgeT< T, Meta >::getNextEdge ( )
inlinenoexcept

Get the next edge.

Returns
Next edge, or nullptr.

◆ getNormal() [1/2]

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

Get the stored normal vector.

Returns
Const reference to m_normal.

◆ getNormal() [2/2]

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

Get modifiable normal vector.

Returns
Reference to m_normal.

◆ getOtherVertex() [1/2]

template<class T , class Meta >
VertexPtr EBGeometry::DCEL::EdgeT< T, Meta >::getOtherVertex ( ) const
inlinenoexcept

Get the end vertex (const overload).

Returns
The next half-edge's starting vertex, or nullptr.

◆ getOtherVertex() [2/2]

template<class T , class Meta >
VertexPtr EBGeometry::DCEL::EdgeT< T, Meta >::getOtherVertex ( )
inlinenoexcept

Get the end vertex.

Returns
The next half-edge's starting vertex, or nullptr.

◆ getPairEdge() [1/2]

template<class T , class Meta >
EdgePtr EBGeometry::DCEL::EdgeT< T, Meta >::getPairEdge ( ) const
inlinenoexcept

Get the pair edge (const overload).

Returns
Pair edge, or nullptr.

◆ getPairEdge() [2/2]

template<class T , class Meta >
EdgePtr EBGeometry::DCEL::EdgeT< T, Meta >::getPairEdge ( )
inlinenoexcept

Get the pair edge.

Returns
Pair edge, or nullptr.

◆ getVertex() [1/2]

template<class T , class Meta >
VertexPtr EBGeometry::DCEL::EdgeT< T, Meta >::getVertex ( ) const
inlinenoexcept

Get the starting vertex (const overload).

Returns
Starting vertex, or nullptr.

◆ getVertex() [2/2]

template<class T , class Meta >
VertexPtr EBGeometry::DCEL::EdgeT< T, Meta >::getVertex ( )
inlinenoexcept

Get the starting vertex.

Returns a shared_ptr obtained by locking the internal weak_ptr (see the class-level

note on ownership). Returns nullptr if the vertex has been destroyed, which should not happen while the owning mesh is alive.

Returns
Starting vertex, or nullptr.

◆ getX2X1()

template<class T , class Meta >
Vec3T< T > EBGeometry::DCEL::EdgeT< T, Meta >::getX2X1 ( ) const
inlineprotectednoexcept

Get the vector pointing along this edge (from start to end vertex).

Returns
x2 - x1, where x1 = getVertex()->getPosition() and x2 = getOtherVertex()->getPosition().

◆ operator=() [1/2]

template<class T , class Meta >
Edge & EBGeometry::DCEL::EdgeT< T, Meta >::operator= ( const Edge a_otherEdge)
noexcept

Copy assignment operator.

Has the same semantics as the copy constructor (including that m_metaData is not copied; use setMetaData() afterwards if it needs to be populated). See the copy constructor's documentation for details.

Parameters
[in]a_otherEdgeOther edge.
Returns
Reference to (*this).

◆ operator=() [2/2]

template<class T , class Meta >
Edge & EBGeometry::DCEL::EdgeT< T, Meta >::operator= ( Edge &&  a_otherEdge)
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_otherEdgeOther edge.
Returns
Reference to (*this).

◆ projectPointToEdge()

template<class T , class Meta >
T EBGeometry::DCEL::EdgeT< T, Meta >::projectPointToEdge ( const Vec3 a_x0) const
inlineprotectednoexcept

Returns the parametric projection of a_x0 onto this edge.

Parametrizes the edge as x(t) = x1 + (x2-x1)*t and computes t such that x(t) is the closest point to a_x0. Returns t in (-inf, +inf); the point is on the segment when t in [0,1].

Parameters
[in]a_x0Query point.
Returns
Projection parameter t.

◆ reconcile()

template<class T , class Meta >
void EBGeometry::DCEL::EdgeT< T, Meta >::reconcile ( )
inlinenoexcept

Reconcile internal logic.

Computes normal.

◆ setFace()

template<class T , class Meta >
void EBGeometry::DCEL::EdgeT< T, Meta >::setFace ( const FacePtr a_face)
inlinenoexcept

Set the pointer to this half-edge's face.

Parameters
[in]a_faceFace to associate with this half-edge.

◆ setMetaData()

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

Set the meta-data.

Parameters
[in]a_metaDataMeta-data.

◆ setNextEdge()

template<class T , class Meta >
void EBGeometry::DCEL::EdgeT< T, Meta >::setNextEdge ( const EdgePtr a_nextEdge)
inlinenoexcept

Set the next edge.

Parameters
[in]a_nextEdgeNext edge

◆ setPairEdge()

template<class T , class Meta >
void EBGeometry::DCEL::EdgeT< T, Meta >::setPairEdge ( const EdgePtr a_pairEdge)
inlinenoexcept

Set the pair edge.

Parameters
[in]a_pairEdgePair edge

◆ setVertex()

template<class T , class Meta >
void EBGeometry::DCEL::EdgeT< T, Meta >::setVertex ( const VertexPtr a_vertex)
inlinenoexcept

Set the starting vertex.

Parameters
[in]a_vertexStarting vertex

◆ signedDistance()

template<class T , class Meta >
T EBGeometry::DCEL::EdgeT< T, Meta >::signedDistance ( const Vec3 a_x0) const
inlinenoexcept

Get the signed distance from a_x0 to this half-edge.

Checks whether a_x0 projects onto the edge segment or past one of the end vertices. If it projects to a vertex, the signed distance to that vertex is returned. Otherwise the sign is determined from the edge normal.

Parameters
[in]a_x0Query point.
Returns
Signed distance; positive on the normal side of the edge.

◆ size()

template<class T , class Meta >
size_t EBGeometry::DCEL::EdgeT< T, Meta >::size ( ) const
inlinenoexcept

Get size (in bytes) of this object.

Returns
Size in bytes of this edge object.

◆ unsignedDistance2()

template<class T , class Meta >
T EBGeometry::DCEL::EdgeT< T, Meta >::unsignedDistance2 ( const Vec3 a_x0) const
inlinenoexcept

Get the squared unsigned distance from a_x0 to this half-edge.

Clamps the projection parameter to [0,1] so the closest point is always on the segment, then returns the squared distance. Faster than signedDistance().

Parameters
[in]a_x0Query point.
Returns
Squared Euclidean distance to the closest point on the edge.

Member Data Documentation

◆ m_metaData

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

Meta-data attached to this edge.

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_vertex

template<class T , class Meta >
std::weak_ptr<Vertex> EBGeometry::DCEL::EdgeT< T, Meta >::m_vertex
protected

Starting vertex.

Stored as a weak_ptr: the vertex is owned by the mesh's own vertex list, and a plain shared_ptr here (mirrored by the sibling m_pairEdge/m_nextEdge/m_face links, and by FaceT::m_halfEdge and VertexT::m_outgoingEdge) would form a reference cycle across the half-edge/face/vertex graph that shared_ptr's reference counting can never collect.


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