|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
Face class for navigating a DCEL mesh. More...
#include <EBGeometry_DCEL_Face.hpp>

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 | |
| FaceT ()=default | |
| Default constructor. Sets the half-edge to zero and the inside/outside algorithm to crossing number algorithm. | |
| FaceT (const EdgePtr &a_edge) | |
| Partial constructor. Calls default constructor but associates a half-edge. | |
| FaceT (const Face &a_otherFace) | |
| Copy constructor. | |
| FaceT (Face &&a_otherFace)=default | |
| Move constructor. | |
| ~FaceT ()=default | |
| Destructor (does nothing) | |
| Face & | operator= (const Face &a_otherFace) noexcept |
| Copy assignment operator. | |
| Face & | operator= (Face &&a_otherFace)=default |
| Move assignment operator. | |
| void | define (const Vec3 &a_normal, const EdgePtr &a_edge) noexcept |
| Define function which sets the normal vector and half-edge. | |
| void | reconcile () |
| Reconcile face. This will compute the normal vector, area, centroid, and the 2D embedding of the polygon. | |
| void | computePolygon2D () |
| Compute the 2D embedding of this polygon from the current normal vector and topology, without touching the normal vector, centroid, or area. | |
| void | flipNormal () noexcept |
| Flip the normal vector. | |
| void | setHalfEdge (const EdgePtr &a_halfEdge) noexcept |
| Set the half edge. | |
| void | setMetaData (const Meta &a_metaData) noexcept |
| Set the meta-data. | |
| void | setInsideOutsideAlgorithm (typename Polygon2D< T >::InsideOutsideAlgorithm &a_algorithm) noexcept |
| Set the inside/outside algorithm when determining if a point projects to the inside or outside of the polygon. | |
| EdgePtr | getHalfEdge () noexcept |
| Get the starting half-edge. | |
| EdgePtr | getHalfEdge () const noexcept |
| Get the starting half-edge (const overload). | |
| Vec3T< T > & | getCentroid () noexcept |
| Get modifiable centroid. | |
| const Vec3T< T > & | getCentroid () const noexcept |
| Get immutable centroid. | |
| T & | getCentroid (const size_t a_dir) noexcept |
| Get modifiable centroid position in specified coordinate direction. | |
| const T & | getCentroid (const size_t a_dir) const noexcept |
| Get immutable centroid position in specified coordinate direction. | |
| Vec3T< T > & | getNormal () noexcept |
| Get modifiable normal vector. | |
| const Vec3T< T > & | getNormal () const noexcept |
| Get immutable normal vector. | |
| T & | getArea () noexcept |
| Get modifiable polygon area (computed during reconcile()). | |
| const T & | getArea () const noexcept |
| Get immutable polygon area (computed during reconcile()). | |
| Meta & | getMetaData () noexcept |
| Get meta-data. | |
| const Meta & | getMetaData () const noexcept |
| Get meta-data (const overload) | |
| T | signedDistance (const Vec3 &a_x0) const noexcept |
| Compute the signed distance to a point. | |
| T | unsignedDistance2 (const Vec3 &a_x0) const noexcept |
| Compute the unsigned squared distance to a point. | |
| std::vector< Vec3T< T > > | getAllVertexCoordinates () const |
| Return the coordinates of all the vertices on this polygon. | |
| std::vector< VertexPtr > | gatherVertices () const |
| Return all the vertices on this polygon. | |
| std::vector< EdgePtr > | gatherEdges () const |
| Return all the half-edges on this polygon. | |
| Vec3T< T > | getSmallestCoordinate () const |
| Get the lower-left-most coordinate of this polygon face. | |
| Vec3T< T > | getHighestCoordinate () const |
| Get the upper-right-most coordinate of this polygon face. | |
Protected Member Functions | |
| void | computeCentroid () |
| Compute the centroid position of this polygon. | |
| void | computeNormal () |
| Compute the normal position of this polygon. | |
| void | computeArea () |
| Compute the area of this polygon and cache it in m_area. | |
| void | normalizeNormalVector () noexcept |
| Normalize the normal vector, ensuring it has a length of 1. | |
| Vec3T< T > | projectPointIntoFacePlane (const Vec3 &a_p) const noexcept |
| Compute the projection of a point onto the polygon face plane. | |
| bool | isPointInsideFace (const Vec3 &a_p) const noexcept |
| Check if a point projects to inside or outside the polygon face. | |
Protected Attributes | |
| std::weak_ptr< Edge > | m_halfEdge |
| This polygon's half-edge. A valid face will always have this set. | |
| Vec3 | m_normal = Vec3::zeros() |
| Polygon face normal vector. | |
| Vec3 | m_centroid = Vec3::zeros() |
| Polygon face centroid position. | |
| Meta | m_metaData {} |
| Meta-data attached to this face. | |
| T | m_area {T(0)} |
| Cached polygon face area (stored by reconcile()). | |
| std::shared_ptr< Polygon2D< T > > | m_poly2 = nullptr |
| 2D embedding of this polygon. This is the 2D view of the current object projected along its normal vector cardinal. | |
| Polygon2D< T >::InsideOutsideAlgorithm | m_poly2Algorithm = Polygon2D<T>::InsideOutsideAlgorithm::CrossingNumber |
| Algorithm for inside/outside tests. | |
Face class for navigating a DCEL mesh.
Class which represents a polygon face in a double-edge connected list (DCEL).
| T | Floating-point precision type. |
| Meta | User-defined metadata type. |
This class is a polygon face in a DCEL mesh. It contains pointer storage to one of the half-edges that circulate the inside of the polygon face, as well as having a normal vector, a centroid, and an area. This class supports signed distance computations. These computations require algorithms that compute e.g. the winding number of the polygon, or the number of times a ray cast passes through it. Thus, one of its central features is that it can be embedded in 2D by projecting it along the cardinal direction of its normal vector. To be fully consistent with a DCEL structure the class stores a reference to one of its half edges, but for performance reasons it also stores references to the other half edges.
| T | Floating-point precision type. |
| Meta | User-defined metadata type. |
Partial constructor. Calls default constructor but associates a half-edge.
| [in] | a_edge | Half-edge |
| EBGeometry::DCEL::FaceT< T, Meta >::FaceT | ( | const Face & | a_otherFace | ) |
Copy constructor.
Copies the normal vector, half-edge pointer, centroid, and area from the other face. Meta-data (m_metaData), the 2D embedding (m_poly2), and the inside/outside algorithm (m_poly2Algorithm) are deliberately NOT copied – they default-construct instead; use setMetaData() and reconcile() afterwards if they need to be (re)populated. Rationale: m_halfEdge is a back-reference into a specific mesh's topology (same as VertexT/EdgeT's copy constructors), so copying it wholesale is not topologically meaningful in general, but is occasionally useful. m_normal, m_centroid, and m_area are plain geometric/cached values with no such concern, so they are copied like any other value. operator=(const Face&) has identical semantics.
| [in] | a_otherFace | Other face to copy from. |
|
default |
Move constructor.
Unlike the copy constructor, this transfers the entire state (including m_metaData, m_poly2, and m_poly2Algorithm) from a_otherFace, 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.
| [in,out] | a_otherFace | Other face. |
|
inline |
Compute the 2D embedding of this polygon from the current normal vector and topology, without touching the normal vector, centroid, or area.
Unlike reconcile(), this does not recompute the normal vector, so it is safe to call after manually restoring a normal vector (e.g. when deep-copying a face and preserving whatever normal it had, including one set via flipNormal()) without having that normal silently overwritten by a geometrically-derived one.
|
inlinenoexcept |
Define function which sets the normal vector and half-edge.
| [in] | a_normal | Normal vector |
| [in] | a_edge | Half edge |
|
inline |
Return all the half-edges on this polygon.
This builds a list of all the edges and returns it.
|
inline |
Return all the vertices on this polygon.
This builds a list of all the vertices and returns it.
|
inline |
Return the coordinates of all the vertices on this polygon.
This builds a list of all the vertex coordinates and returns it.
|
inlinenoexcept |
Get immutable polygon area (computed during reconcile()).
|
inlinenoexcept |
Get modifiable polygon area (computed during reconcile()).
|
inlinenoexcept |
Get immutable centroid.
|
inlinenoexcept |
Get modifiable centroid.
|
inlinenoexcept |
Get immutable centroid position in specified coordinate direction.
| [in] | a_dir | Coordinate direction |
|
inlinenoexcept |
Get modifiable centroid position in specified coordinate direction.
| [in] | a_dir | Coordinate direction |
|
inlinenoexcept |
Get the starting half-edge (const overload).
|
inlinenoexcept |
Get the starting half-edge.
Returns a shared_ptr obtained by locking the internal weak_ptr (see the class-level note on ownership near m_halfEdge). Returns nullptr if the edge has been destroyed, which should not happen while the owning mesh is alive.
|
inline |
Get the upper-right-most coordinate of this polygon face.
|
inlinenoexcept |
Get meta-data (const overload)
|
inlinenoexcept |
Get meta-data.
|
inlinenoexcept |
Get immutable normal vector.
|
inlinenoexcept |
Get modifiable normal vector.
|
inline |
Get the lower-left-most coordinate of this polygon face.
|
inlineprotectednoexcept |
Check if a point projects to inside or outside the polygon face.
| [in] | a_p | Point in space |
|
noexcept |
Copy assignment operator.
Has the same semantics as the copy constructor; see its documentation.
| [in] | a_otherFace | Other face. |
|
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).
| [in,out] | a_otherFace | Other face. |
|
inlineprotectednoexcept |
Compute the projection of a point onto the polygon face plane.
| [in] | a_p | Point in space |
Reconcile face. This will compute the normal vector, area, centroid, and the 2D embedding of the polygon.
|
inlinenoexcept |
Set the half edge.
| [in] | a_halfEdge | Half edge |
|
inlinenoexcept |
Set the inside/outside algorithm when determining if a point projects to the inside or outside of the polygon.
| [in] | a_algorithm | Desired algorithm |
|
inlinenoexcept |
Set the meta-data.
| [in] | a_metaData | Meta-data. |
|
inlinenoexcept |
Compute the signed distance to a point.
| [in] | a_x0 | Point in space |
This algorithm operates by checking if the input point projects to the inside of the polygon. If it does then the distance is just the projected distance onto the polygon plane and the sign is well-defined. Otherwise, we check the distance to the edges of the polygon.
|
inlinenoexcept |
Compute the unsigned squared distance to a point.
| [in] | a_x0 | Point in space |
This algorithm operates by checking if the input point projects to the inside of the polygon. If it does then the distance is just the projected distance onto the polygon plane. Otherwise, we check the distance to the edges of the polygon.
|
protected |
This polygon's half-edge. A valid face will always have this set.
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_face (and, transitively, with EdgeT::m_nextEdge/m_pairEdge and VertexT::m_outgoingEdge) that shared_ptr's reference counting can never collect.
Meta-data attached to this face.
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.