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

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

#include <EBGeometry_DCEL_Edge.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.
 

Public Member Functions

 EdgeT () noexcept=default
 Default constructor. Sets all topology indices to the unset sentinel and vectors to zero vectors.
 
 EdgeT (const Edge &a_otherEdge)=default
 Copy constructor.
 
 EdgeT (Edge &&a_otherEdge)=default
 Move constructor.
 
 EdgeT (const uint32_t a_vertexIndex) noexcept
 Partial constructor. Calls the default constructor but sets the starting vertex.
 
 ~EdgeT ()=default
 Destructor (does nothing)
 
Edge & operator= (const Edge &a_otherEdge)=default
 Copy assignment operator.
 
Edge & operator= (Edge &&a_otherEdge)=default
 Move assignment operator.
 
size_t size () const noexcept
 Get the number of vertices spanned by a half-edge.
 
void define (const uint32_t a_vertexIndex, const uint32_t a_pairEdgeIndex, const uint32_t a_nextEdgeIndex) noexcept
 Define function. Sets the starting vertex, pair/next edge indices.
 
void reconcile (const Mesh &a_mesh) noexcept
 Reconcile internal logic.
 
void flipNormal () noexcept
 Flip surface normal.
 
void setVertex (const uint32_t a_vertexIndex) noexcept
 Set the index of the starting vertex.
 
void setPairEdge (const uint32_t a_pairEdgeIndex) noexcept
 Set the index of the pair edge.
 
void setNextEdge (const uint32_t a_nextEdgeIndex) noexcept
 Set the index of the next edge.
 
void setFace (const uint32_t a_faceIndex) noexcept
 Set the index of this half-edge's face.
 
uint32_t getVertexIndex () const noexcept
 Get the index of the starting vertex.
 
uint32_t getPairEdgeIndex () const noexcept
 Get the index of the pair edge.
 
uint32_t getNextEdgeIndex () const noexcept
 Get the index of the next edge.
 
uint32_t getFaceIndex () const noexcept
 Get the index of this half-edge's face.
 
Vertex & getVertex (Mesh &a_mesh) noexcept
 Get the starting vertex.
 
const Vertex & getVertex (const Mesh &a_mesh) const noexcept
 Get the starting vertex (const overload).
 
Vertex & getOtherVertex (Mesh &a_mesh) noexcept
 Get the end vertex.
 
const Vertex & getOtherVertex (const Mesh &a_mesh) const noexcept
 Get the end vertex (const overload).
 
Edge & getPairEdge (Mesh &a_mesh) noexcept
 Get the pair edge.
 
const Edge & getPairEdge (const Mesh &a_mesh) const noexcept
 Get the pair edge (const overload).
 
Edge & getNextEdge (Mesh &a_mesh) noexcept
 Get the next edge.
 
const Edge & getNextEdge (const Mesh &a_mesh) const noexcept
 Get the next edge (const overload).
 
Vec3T< T > computeNormal (const Mesh &a_mesh) 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.
 
Face & getFace (Mesh &a_mesh) noexcept
 Get this half-edge's face.
 
const Face & getFace (const Mesh &a_mesh) const noexcept
 Get this half-edge's face (const overload).
 
T signedDistance (const Vec3 &a_x0, const Mesh &a_mesh) const noexcept
 Get the signed distance from a_x0 to this half-edge.
 
T unsignedDistance2 (const Vec3 &a_x0, const Mesh &a_mesh) const noexcept
 Get the squared unsigned distance from a_x0 to this half-edge.
 

Protected Member Functions

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

Protected Attributes

Vec3 m_normal = Vec3::zeros()
 Normal vector.
 
uint32_t m_vertex = UINT32_MAX
 Index of the starting vertex.
 
uint32_t m_pairEdge = UINT32_MAX
 Index of the pair edge. See m_vertex for the indexing convention.
 
uint32_t m_nextEdge = UINT32_MAX
 Index of the next edge. See m_vertex for the indexing convention.
 
uint32_t m_face = UINT32_MAX
 Index of the enclosing polygon face, into the owning mesh's face array, or UINT32_MAX if unset.
 

Detailed Description

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

Half-edge class for navigating a DCEL mesh.

Class which represents a half-edge 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 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 stores the indices of the polygon face, vertex, and next half edge in the owning mesh's arrays. It also stores the index of 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.
All topology indices below (m_vertex, m_pairEdge, m_nextEdge, m_face) are indices into the owning DCEL::MeshT's own vertex/edge/face arrays, resolved by passing that mesh to the accessors below. Using indices rather than pointers keeps EdgeT a plain, relocatable value: the owning mesh's arrays are the sole storage, and every cross-reference is a position within them, not an address – so an EdgeT is meaningful under a memcpy or a host-to-device mirror with no pointer patching.
Every member here resolves purely through plain values and an explicitly-supplied Mesh&, so the entire public and protected interface is annotated EBGEOMETRY_HOST_DEVICE.
Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ EdgeT() [1/3]

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

Copy constructor.

Defaulted memberwise copy of every member – the normal vector, and all four topology indices (vertex, pair edge, next edge, face). This is what lets EdgeT 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 Edge&) has identical semantics.

Parameters
[in]a_otherEdgeOther edge.

◆ EdgeT() [2/3]

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

Move constructor.

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

Parameters
[in,out]a_otherEdgeOther edge.

◆ EdgeT() [3/3]

template<class T >
EBGeometry::DCEL::EdgeT< T >::EdgeT ( const uint32_t  a_vertexIndex)
noexcept

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

Parameters
[in]a_vertexIndexIndex of the starting vertex in the owning mesh's vertex array.

Member Function Documentation

◆ computeNormal()

template<class T >
Vec3T< T > EBGeometry::DCEL::EdgeT< T >::computeNormal ( const Mesh &  a_mesh) const
inlinenoexcept

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

An edge with no pair edge (a hole) uses its own face's normal alone.

Parameters
[in]a_meshOwning mesh, used to resolve the face/pair-edge indices.
Returns
Unit normal vector for this edge, or the zero vector if the two faces fold back onto each other (their normals cancel).

◆ define()

template<class T >
void EBGeometry::DCEL::EdgeT< T >::define ( const uint32_t  a_vertexIndex,
const uint32_t  a_pairEdgeIndex,
const uint32_t  a_nextEdgeIndex 
)
inlinenoexcept

Define function. Sets the starting vertex, pair/next edge indices.

Parameters
[in]a_vertexIndexIndex of the starting vertex in the owning mesh's vertex array.
[in]a_pairEdgeIndexIndex of the pair half-edge in the owning mesh's edge array, or UINT32_MAX if unset.
[in]a_nextEdgeIndexIndex of the next half-edge in the owning mesh's edge array, or UINT32_MAX if unset.

◆ getFace() [1/2]

template<class T >
const Face & EBGeometry::DCEL::EdgeT< T >::getFace ( const Mesh &  a_mesh) const
inlinenoexcept

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

Parameters
[in]a_meshOwning mesh, used to resolve the face index.
Returns
Const reference to the owning face. m_face must be set (see getFaceIndex()).

◆ getFace() [2/2]

template<class T >
Face & EBGeometry::DCEL::EdgeT< T >::getFace ( Mesh &  a_mesh)
inlinenoexcept

Get this half-edge's face.

Parameters
[in]a_meshOwning mesh, used to resolve the face index.
Returns
Reference to the owning face. m_face must be set (see getFaceIndex()).

◆ getFaceIndex()

template<class T >
uint32_t EBGeometry::DCEL::EdgeT< T >::getFaceIndex ( ) const
inlinenoexcept

Get the index of this half-edge's face.

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

◆ getNextEdge() [1/2]

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

Get the next edge (const overload).

Parameters
[in]a_meshOwning mesh, used to resolve the next-edge index.
Returns
Const reference to the next edge. m_nextEdge must be set (see getNextEdgeIndex()).

◆ getNextEdge() [2/2]

template<class T >
Edge & EBGeometry::DCEL::EdgeT< T >::getNextEdge ( Mesh &  a_mesh)
inlinenoexcept

Get the next edge.

Parameters
[in]a_meshOwning mesh, used to resolve the next-edge index.
Returns
Reference to the next edge. m_nextEdge must be set (see getNextEdgeIndex()).

◆ getNextEdgeIndex()

template<class T >
uint32_t EBGeometry::DCEL::EdgeT< T >::getNextEdgeIndex ( ) const
inlinenoexcept

Get the index of the next edge.

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

◆ getNormal() [1/2]

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

Get the stored normal vector.

Returns
Const reference to m_normal.

◆ getNormal() [2/2]

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

Get modifiable normal vector.

Returns
Reference to m_normal.

◆ getOtherVertex() [1/2]

template<class T >
const Vertex & EBGeometry::DCEL::EdgeT< T >::getOtherVertex ( const Mesh &  a_mesh) const
inlinenoexcept

Get the end vertex (const overload).

Parameters
[in]a_meshOwning mesh, used to resolve the next-edge and vertex indices.
Returns
Const reference to the next half-edge's starting vertex. m_nextEdge must be set.

◆ getOtherVertex() [2/2]

template<class T >
Vertex & EBGeometry::DCEL::EdgeT< T >::getOtherVertex ( Mesh &  a_mesh)
inlinenoexcept

Get the end vertex.

Parameters
[in]a_meshOwning mesh, used to resolve the next-edge and vertex indices.
Returns
Reference to the next half-edge's starting vertex. m_nextEdge must be set.

◆ getPairEdge() [1/2]

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

Get the pair edge (const overload).

Parameters
[in]a_meshOwning mesh, used to resolve the pair-edge index.
Returns
Const reference to the pair edge. m_pairEdge must be set (see getPairEdgeIndex()).

◆ getPairEdge() [2/2]

template<class T >
Edge & EBGeometry::DCEL::EdgeT< T >::getPairEdge ( Mesh &  a_mesh)
inlinenoexcept

Get the pair edge.

Parameters
[in]a_meshOwning mesh, used to resolve the pair-edge index.
Returns
Reference to the pair edge. m_pairEdge must be set (see getPairEdgeIndex()).

◆ getPairEdgeIndex()

template<class T >
uint32_t EBGeometry::DCEL::EdgeT< T >::getPairEdgeIndex ( ) const
inlinenoexcept

Get the index of the pair edge.

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

◆ getVertex() [1/2]

template<class T >
const Vertex & EBGeometry::DCEL::EdgeT< T >::getVertex ( const Mesh &  a_mesh) const
inlinenoexcept

Get the starting vertex (const overload).

Parameters
[in]a_meshOwning mesh, used to resolve the vertex index.
Returns
Const reference to the starting vertex. m_vertex must be set (see getVertexIndex()).

◆ getVertex() [2/2]

template<class T >
Vertex & EBGeometry::DCEL::EdgeT< T >::getVertex ( Mesh &  a_mesh)
inlinenoexcept

Get the starting vertex.

Parameters
[in]a_meshOwning mesh, used to resolve the vertex index.
Returns
Reference to the starting vertex. m_vertex must be set (see getVertexIndex()).

◆ getVertexIndex()

template<class T >
uint32_t EBGeometry::DCEL::EdgeT< T >::getVertexIndex ( ) const
inlinenoexcept

Get the index of the starting vertex.

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

◆ getX2X1()

template<class T >
Vec3T< T > EBGeometry::DCEL::EdgeT< T >::getX2X1 ( const Mesh &  a_mesh) const
inlineprotectednoexcept

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

Parameters
[in]a_meshOwning mesh, used to resolve the vertex indices.
Returns
x2 - x1, where x1 = getVertex(a_mesh).getPosition() and x2 = getOtherVertex(a_mesh).getPosition().

◆ operator=() [1/2]

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

Copy assignment operator.

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

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

◆ operator=() [2/2]

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

◆ projectPointToEdge()

template<class T >
T EBGeometry::DCEL::EdgeT< T >::projectPointToEdge ( const Vec3 &  a_x0,
const Mesh &  a_mesh 
) 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.
[in]a_meshOwning mesh, used to resolve the vertex indices.
Returns
Projection parameter t.

◆ reconcile()

template<class T >
void EBGeometry::DCEL::EdgeT< T >::reconcile ( const Mesh &  a_mesh)
inlinenoexcept

Reconcile internal logic.

Computes the normal vector.

Parameters
[in]a_meshOwning mesh, used to resolve the face/pair-edge indices.

◆ setFace()

template<class T >
void EBGeometry::DCEL::EdgeT< T >::setFace ( const uint32_t  a_faceIndex)
inlinenoexcept

Set the index of this half-edge's face.

Parameters
[in]a_faceIndexIndex of the face in the owning mesh's face array, or UINT32_MAX to mark it unset.

◆ setNextEdge()

template<class T >
void EBGeometry::DCEL::EdgeT< T >::setNextEdge ( const uint32_t  a_nextEdgeIndex)
inlinenoexcept

Set the index of the next edge.

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

◆ setPairEdge()

template<class T >
void EBGeometry::DCEL::EdgeT< T >::setPairEdge ( const uint32_t  a_pairEdgeIndex)
inlinenoexcept

Set the index of the pair edge.

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

◆ setVertex()

template<class T >
void EBGeometry::DCEL::EdgeT< T >::setVertex ( const uint32_t  a_vertexIndex)
inlinenoexcept

Set the index of the starting vertex.

Parameters
[in]a_vertexIndexIndex of the starting vertex in the owning mesh's vertex array.

◆ signedDistance()

template<class T >
T EBGeometry::DCEL::EdgeT< T >::signedDistance ( const Vec3 &  a_x0,
const Mesh &  a_mesh 
) 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.
[in]a_meshOwning mesh, used to resolve the vertex indices.
Returns
Signed distance; positive on the normal side of the edge (or of the closest end vertex).

◆ size()

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

Get the number of vertices spanned by a half-edge.

Returns
Always 2 (the starting and ending vertex); not the object's size in bytes.

◆ unsignedDistance2()

template<class T >
T EBGeometry::DCEL::EdgeT< T >::unsignedDistance2 ( const Vec3 &  a_x0,
const Mesh &  a_mesh 
) 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.
[in]a_meshOwning mesh, used to resolve the vertex indices.
Returns
Squared Euclidean distance to the closest point on the edge.

Member Data Documentation

◆ m_vertex

template<class T >
uint32_t EBGeometry::DCEL::EdgeT< T >::m_vertex = UINT32_MAX
protected

Index of the starting vertex.

Index into the owning DCEL::MeshT's vertex array, or UINT32_MAX if unset.


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