EBGeometry  1.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DCEL::MeshT< T, Meta > Class Template Reference

Mesh class. More...

#include <EBGeometry_DCEL_Mesh.hpp>

Public Types

enum class  SearchAlgorithm { Direct , Direct2 }
 Possible search algorithms for DCEL::MeshT. More...
 
enum class  VertexNormalWeight { None , Angle }
 How to weight vertex normal.
 
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 Mesh = MeshT< T, Meta >
 Alias for mesh 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

 MeshT () noexcept
 Default constructor. Leaves unobject in an unusable state.
 
 MeshT (const Mesh &a_otherMesh)=delete
 Disallowed copy construction. More...
 
 MeshT (std::vector< FacePtr > &a_faces, std::vector< EdgePtr > &a_edges, std::vector< VertexPtr > &a_vertices) noexcept
 Full constructor. This provides the faces, edges, and vertices to the mesh. More...
 
virtual ~MeshT () noexcept
 Destructor (does nothing)
 
void define (std::vector< FacePtr > &a_faces, std::vector< EdgePtr > &a_edges, std::vector< VertexPtr > &a_vertices) noexcept
 Define function. Puts Mesh in usable state. More...
 
void sanityCheck () const noexcept
 Perform a sanity check. More...
 
void setSearchAlgorithm (const SearchAlgorithm a_algorithm) noexcept
 Search algorithm for direct signed distance computations. More...
 
void setInsideOutsideAlgorithm (typename Polygon2D< T >::InsideOutsideAlgorithm a_algorithm) noexcept
 Set the inside/outside algorithm to use when computing the signed distance to polygon faces. More...
 
void reconcile (const DCEL::VertexNormalWeight a_weight=DCEL::VertexNormalWeight::Angle) noexcept
 Reconcile function which computes the internal parameters in vertices, edges, and faces for use with signed distance functionality. More...
 
void flip () noexcept
 Flip the mesh, making all the normals change direction. More...
 
std::vector< VertexPtr > & getVertices () noexcept
 Get modifiable vertices in this mesh.
 
const std::vector< VertexPtr > & getVertices () const noexcept
 Get immutable vertices in this mesh.
 
std::vector< Vec3T< T > > getAllVertexCoordinates () const noexcept
 Return all vertex coordinates in the mesh.
 
std::vector< EdgePtr > & getEdges () noexcept
 Get modifiable half-edges in this mesh.
 
const std::vector< EdgePtr > & getEdges () const noexcept
 Get immutable half-edges in this mesh.
 
std::vector< FacePtr > & getFaces () noexcept
 Get modifiable faces in this mesh.
 
const std::vector< FacePtr > & getFaces () const noexcept
 Get immutable faces in this mesh.
 
signedDistance (const Vec3 &a_x0) const noexcept
 Compute the signed distance from a point to this mesh. More...
 
signedDistance (const Vec3 &a_x0, SearchAlgorithm a_algorithm) const noexcept
 Compute the signed distance from a point to this mesh. More...
 
unsignedDistance2 (const Vec3 &a_x0) const noexcept
 Compute the unsigned square distance from a point to this mesh. More...
 

Protected Member Functions

void reconcileFaces () noexcept
 Function which computes internal things for the polygon faces. More...
 
void reconcileEdges () noexcept
 Function which computes internal things for the half-edges. More...
 
void reconcileVertices (const DCEL::VertexNormalWeight a_weight) noexcept
 Function which computes internal things for the vertices. More...
 
void flipFaces () noexcept
 Flip all face normals.
 
void flipEdges () noexcept
 Flip all edge normals.
 
void flipVertices () noexcept
 Flip all vertex normal.
 
DirectSignedDistance (const Vec3 &a_point) const noexcept
 Implementation of signed distance function which iterates through all faces. More...
 
DirectSignedDistance2 (const Vec3 &a_point) const noexcept
 Implementation of squared signed distance function which iterates through all faces. More...
 
void incrementWarning (std::map< std::string, size_t > &a_warnings, const std::string &a_warn) const noexcept
 Increment a warning. This is used in sanityCheck() for locating holes or bad inputs in the mesh. More...
 
void printWarnings (const std::map< std::string, size_t > &a_warnings) const noexcept
 Print all warnings to std::cerr.
 

Protected Attributes

SearchAlgorithm m_algorithm
 Search algorithm. Only used in signed distance functions.
 
std::vector< VertexPtrm_vertices
 Mesh vertices.
 
std::vector< EdgePtrm_edges
 Mesh half-edges.
 
std::vector< FacePtrm_faces
 Mesh faces.
 

Detailed Description

template<class T, class Meta>
class DCEL::MeshT< T, Meta >

Mesh class.

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

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 who each have references to other vertices, half-edges, and polygon faces. 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
This class is not for the light of heart – it will almost always be instantiated through a file parser which reads vertices and edges from file and builds the mesh from that. Do not try to build a MeshT object yourself, use file parsers!

Member Enumeration Documentation

◆ SearchAlgorithm

template<class T , class Meta >
enum DCEL::MeshT::SearchAlgorithm
strong

Possible search algorithms for DCEL::MeshT.

Direct means compute the signed distance for all primitives, Direct2 means compute the squared signed distance for all primitives.

Constructor & Destructor Documentation

◆ MeshT() [1/2]

template<class T , class Meta >
DCEL::MeshT< T, Meta >::MeshT ( const Mesh a_otherMesh)
delete

Disallowed copy construction.

Parameters
[in]a_otherMeshOther mesh

◆ MeshT() [2/2]

template<class T , class Meta >
DCEL::MeshT< T, Meta >::MeshT ( std::vector< FacePtr > &  a_faces,
std::vector< EdgePtr > &  a_edges,
std::vector< VertexPtr > &  a_vertices 
)
noexcept

Full constructor. This provides the faces, edges, and vertices to the mesh.

Calls define(a_faces, a_edges, a_vertices)

Parameters
[in]a_facesPolygon faces
[in]a_edgesHalf-edges
[in]a_verticesVertices
Note
The constructor arguments should provide a complete DCEL mesh description. This is usually done through a file parser which reads a mesh file format and creates the DCEL mesh structure

Member Function Documentation

◆ define()

template<class T , class Meta >
void DCEL::MeshT< T, Meta >::define ( std::vector< FacePtr > &  a_faces,
std::vector< EdgePtr > &  a_edges,
std::vector< VertexPtr > &  a_vertices 
)
inlinenoexcept

Define function. Puts Mesh in usable state.

Parameters
[in]a_facesPolygon faces
[in]a_edgesHalf-edges
[in]a_verticesVertices
Note
The function arguments should provide a complete DCEL mesh description. This is usually done through a file parser which reads a mesh file format and creates the DCEL mesh structure. Note that this only involves associating pointer structures through the mesh. Internal parameters like face area and normal is computed in MeshT<T, Meta>::reconcile.

◆ DirectSignedDistance()

template<class T , class Meta >
T DCEL::MeshT< T, Meta >::DirectSignedDistance ( const Vec3 a_point) const
inlineprotectednoexcept

Implementation of signed distance function which iterates through all faces.

Parameters
[in]a_point3D point

◆ DirectSignedDistance2()

template<class T , class Meta >
T DCEL::MeshT< T, Meta >::DirectSignedDistance2 ( const Vec3 a_point) const
inlineprotectednoexcept

Implementation of squared signed distance function which iterates through all faces.

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

Parameters
[in]a_point3D point

◆ flip()

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

Flip the mesh, making all the normals change direction.

Note
Should be called AFTER all normals have been computed.

◆ incrementWarning()

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

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

◆ reconcile()

template<class T , class Meta >
void DCEL::MeshT< T, Meta >::reconcile ( const DCEL::VertexNormalWeight  a_weight = DCEL::VertexNormalWeight::Angle)
inlinenoexcept

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

Parameters
[in]a_weightVertex angle weighting function. Either VertexNormalWeight::None for unweighted vertex normals or VertexNormalWeight::Angle for the pseudonormal

This will reconcile faces, edges, and vertices, e.g. computing the area and normal vector for faces

◆ reconcileEdges()

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

Function which computes internal things for the half-edges.

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

◆ reconcileFaces()

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

Function which computes internal things for the polygon faces.

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

◆ reconcileVertices()

template<class T , class Meta >
void DCEL::MeshT< T, Meta >::reconcileVertices ( const DCEL::VertexNormalWeight  a_weight)
inlineprotectednoexcept

Function which computes internal things for the vertices.

Parameters
[in]a_weightVertex angle weighting
Note
This calls DCEL::VertexT<T, Meta>::computeVertexNormalAverage() or DCEL::VertexT<T, Meta>::computeVertexNormalAngleWeighted()

◆ sanityCheck()

template<class T , class Meta >
void DCEL::MeshT< T, Meta >::sanityCheck ( ) const
inlinenoexcept

Perform a sanity check.

This will provide error messages if vertices are badly linked, faces are nullptr, 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.

◆ setInsideOutsideAlgorithm()

template<class T , class Meta >
void DCEL::MeshT< T, Meta >::setInsideOutsideAlgorithm ( typename Polygon2D< T >::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 polygo 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 , class Meta >
void DCEL::MeshT< T, Meta >::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 , class Meta >
T DCEL::MeshT< T, Meta >::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, Meta> can be embedded in a bounding volume hierarchy for faster access.

Note
This will call the other version with the object's search algorithm.

◆ signedDistance() [2/2]

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

Compute the signed distance from a point to this mesh.

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, Meta> can be embedded in a bounding volume hierarchy for faster access.

◆ unsignedDistance2()

template<class T , class Meta >
T DCEL::MeshT< T, Meta >::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, Meta> can be embedded in a bounding volume hierarchy for faster access.

Note
This will call the other version with the object's search algorithm.

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