|
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 > |
| 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. | |
| using | EdgeIterator = EdgeIteratorT< T > |
| Alias for edge iterator. | |
Public Member Functions | |
| FaceT ()=default | |
| Default constructor. Sets the half-edge index to the unset sentinel and the inside/outside algorithm to crossing number algorithm. | |
| FaceT (const uint32_t a_edgeIndex) | |
| Partial constructor. Calls default constructor but associates a half-edge. | |
| FaceT (const Face &a_otherFace)=default | |
| Copy constructor. | |
| FaceT (Face &&a_otherFace)=default | |
| Move constructor. | |
| ~FaceT ()=default | |
| Destructor (does nothing) | |
| Face & | operator= (const Face &a_otherFace)=default |
| Copy assignment operator. | |
| Face & | operator= (Face &&a_otherFace)=default |
| Move assignment operator. | |
| void | define (const Vec3 &a_normal, const uint32_t a_edgeIndex) noexcept |
| Define function which sets the normal vector and half-edge index. | |
| void | reconcile (const Mesh &a_mesh) |
| Reconcile face. This will compute the normal vector, area, centroid, and the 2D embedding of the polygon. | |
| uint32_t | numVertices (const Mesh &a_mesh) const noexcept |
| Number of vertices on this face's half-edge loop. | |
| void | computeProjectionDirections () noexcept |
| 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 uint32_t a_halfEdgeIndex) noexcept |
| Set the half edge index. | |
| void | setInsideOutsideAlgorithm (InsideOutsideAlgorithm a_algorithm) noexcept |
| Set the inside/outside algorithm when determining if a point projects to the inside or outside of the polygon. | |
| uint32_t | getHalfEdgeIndex () const noexcept |
| Get the index of the starting half-edge. | |
| 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()). | |
| T | signedDistance (const Vec3 &a_x0, const Mesh &a_mesh) const noexcept |
| Compute the signed distance to a point. | |
| T | closestPoint (const Vec3 &a_x0, const Mesh &a_mesh, Vec3 &a_closestPoint, Vec3 &a_normal) const noexcept |
| The closest point on this face to a_x0, the pseudonormal there, and the signed distance. | |
| T | rayCrossing (const Vec3 &a_origin, const Vec3 &a_direction, T a_tMin, T a_tMax, const Mesh &a_mesh) const noexcept |
| Where a ray crosses the face, from either side. | |
| T | unsignedDistance2 (const Vec3 &a_x0, const Mesh &a_mesh) const noexcept |
| Compute the unsigned squared distance to a point. | |
| std::vector< Vec3T< T > > | getAllVertexCoordinates (const Mesh &a_mesh) const |
| Return the coordinates of all the vertices on this polygon. | |
| std::vector< uint32_t > | gatherVertexIndices (const Mesh &a_mesh) const |
| Return the indices of all the vertices on this polygon. | |
| std::vector< uint32_t > | gatherEdgeIndices (const Mesh &a_mesh) const |
| Return the indices of all the half-edges on this polygon. | |
| Vec3T< T > | getSmallestCoordinate (const Mesh &a_mesh) const noexcept |
| Get the lower-left-most coordinate of this polygon face. | |
| Vec3T< T > | getHighestCoordinate (const Mesh &a_mesh) const noexcept |
| Get the upper-right-most coordinate of this polygon face. | |
Protected Member Functions | |
| void | computeCentroid (const Mesh &a_mesh) |
| Compute the centroid position of this polygon. | |
| void | computeNormal (const Mesh &a_mesh) |
| Compute the unit normal vector of this polygon (Newell's method). | |
| void | computeArea (const Mesh &a_mesh) |
| 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 Mesh &a_mesh) const noexcept |
| Check if a point projects to inside or outside the polygon face. | |
| Vec2T< T > | projectPoint (const Vec3 &a_point) const noexcept |
| Project a 3D point to this face's 2D embedding by dropping one coordinate. | |
| int | computeWindingNumber (const Vec2T< T > &a_point, const Mesh &a_mesh) const noexcept |
| Compute the winding number of this polygon's boundary around a projected 2D point. | |
| size_t | computeCrossingNumber (const Vec2T< T > &a_point, const Mesh &a_mesh) const noexcept |
| Compute the crossing number of a +x ray from a projected 2D point with this polygon. | |
| T | computeSubtendedAngle (const Vec2T< T > &a_point, const Mesh &a_mesh) const noexcept |
| Compute the total subtended angle of this polygon's edges around a projected 2D point. | |
Protected Attributes | |
| uint32_t | m_halfEdge = UINT32_MAX |
| This polygon's half-edge index. 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. | |
| T | m_area {T(0)} |
| Cached polygon face area (stored by reconcile()). | |
| uint32_t | m_xDir = UINT32_MAX |
| Cartesian axis used as the 2D x-direction of this polygon's 2D embedding (stored by reconcile()). The inside/outside test projects points to 2D by keeping (m_xDir, m_yDir) and dropping the coordinate of the largest normal component. | |
| uint32_t | m_yDir = UINT32_MAX |
| Cartesian axis used as the 2D y-direction of this polygon's 2D embedding (stored by reconcile()). | |
| InsideOutsideAlgorithm | m_insideOutsideAlgorithm = InsideOutsideAlgorithm::CrossingNumber |
| Algorithm for inside/outside tests. | |
Face class for navigating a DCEL mesh.
Class which represents a polygon face in a doubly-connected edge list (DCEL).
| T | Floating-point precision type. |
This class is a polygon face in a DCEL mesh. It stores the index of 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.
| T | Floating-point precision type. |
| EBGeometry::DCEL::FaceT< T >::FaceT | ( | const uint32_t | a_edgeIndex | ) |
Partial constructor. Calls default constructor but associates a half-edge.
| [in] | a_edgeIndex | Index of the half-edge in the owning mesh's edge array. |
|
default |
Copy constructor.
Defaulted memberwise copy: every member is a plain value (see the class-level note), so the copy is immediately usable for a point-in-face test against the same mesh the source face belonged to.
| [in] | a_otherFace | Other face to copy from. |
|
default |
Move constructor.
Defaulted memberwise move; equivalent to the copy constructor since every member is a plain value.
| [in,out] | a_otherFace | Other face. |
|
inlinenoexcept |
The closest point on this face to a_x0, the pseudonormal there, and the signed distance.
The same cases as signedDistance(): the projection into the face's plane, with the face normal, where a_x0 projects inside the face; otherwise the closest point of the nearest edge (the first one found on a tie), with that edge's or end vertex's pseudonormal (EdgeT::closestPoint()). A point projecting onto the face's boundary, where an edge or vertex is as near as the plane, is reported on that feature, with its pseudonormal.
| [in] | a_x0 | Query point. |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
| [out] | a_closestPoint | The closest point. |
| [out] | a_normal | The pseudonormal of the face, edge or vertex it lies on. |
|
inlineprotected |
Compute the area of this polygon and cache it in m_area.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlineprotected |
Compute the centroid position of this polygon.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlineprotectednoexcept |
Compute the crossing number of a +x ray from a projected 2D point with this polygon.
Walks the face's half-edge loop, projecting each vertex on the fly.
| [in] | a_point | Projected 2D query point. |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlineprotected |
Compute the unit normal vector of this polygon (Newell's method).
A zero-area face (collinear or coincident vertices) gets a zero normal rather than a NaN. A face with fewer than 3 vertices aborts with a message in every build.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlinenoexcept |
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.
|
inlineprotectednoexcept |
Compute the total subtended angle of this polygon's edges around a projected 2D point.
Walks the face's half-edge loop, projecting each vertex on the fly.
| [in] | a_point | Projected 2D query point. |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlineprotectednoexcept |
Compute the winding number of this polygon's boundary around a projected 2D point.
Walks the face's half-edge loop, projecting each vertex on the fly.
| [in] | a_point | Projected 2D query point. |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlinenoexcept |
Define function which sets the normal vector and half-edge index.
| [in] | a_normal | Normal vector |
| [in] | a_edgeIndex | Index of the half-edge in the owning mesh's edge array. |
|
inline |
Return the indices of all the half-edges on this polygon.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
This builds a list of all the edge indices and returns it.
|
inline |
Return the indices of all the vertices on this polygon.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
This builds a list of all the vertex indices and returns it.
|
inline |
Return the coordinates of all the vertices on this polygon.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
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 index of the starting half-edge.
|
inlinenoexcept |
Get the upper-right-most coordinate of this polygon face.
Streams the half-edge loop and reduces componentwise, rather than going through getAllVertexCoordinates(), so that no std::vector is materialized and the function stays callable from device code.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlinenoexcept |
Get immutable normal vector.
|
inlinenoexcept |
Get modifiable normal vector.
|
inlinenoexcept |
Get the lower-left-most coordinate of this polygon face.
Streams the half-edge loop and reduces componentwise, rather than going through getAllVertexCoordinates(), so that no std::vector is materialized and the function stays callable from device code.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlineprotectednoexcept |
Check if a point projects to inside or outside the polygon face.
| [in] | a_p | Point in space |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlineprotectednoexcept |
Normalize the normal vector, ensuring it has a length of 1.
A zero normal (a zero-area face) is left zero.
|
inlinenoexcept |
Number of vertices on this face's half-edge loop.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
default |
Copy assignment operator.
Defaulted memberwise copy; see the copy constructor's documentation.
| [in] | a_otherFace | Other face. |
|
default |
Move assignment operator.
Defaulted memberwise move; equivalent to copy assignment since every member is a plain value.
| [in,out] | a_otherFace | Other face. |
|
inlineprotectednoexcept |
Project a 3D point to this face's 2D embedding by dropping one coordinate.
| [in] | a_point | 3D point. |
|
inlineprotectednoexcept |
Compute the projection of a point onto the polygon face plane.
| [in] | a_p | Point in space |
|
inlinenoexcept |
Where a ray crosses the face, from either side.
The ray is a_origin + t * a_direction. The face is taken to be planar and convex, as the mesh SDFs require: the ray meets the face's plane at one t, and that point is inside the face if it is on the inner side of every edge (which side that is, the loop's orientation about the normal says). The edge tests are widened by the rounding error of that point, a distance of a few ulps of the coordinates and of t, so that a ray through an edge or vertex shared by two faces crosses at least one of them however far it comes from; a point counted that way must also be that close to the edge's extent, so that a sliver is not crossed far beyond its corners. A ray in the face's plane, or a face of zero area, crosses nothing. The plane is the one through the face's centroid with its normal: for a face that is not quite planar, a ray nearly in it can cross at a t that differs from the vertices' by the face's deviation from planarity.
| [in] | a_origin | Ray origin. |
| [in] | a_direction | Ray direction. |
| [in] | a_tMin | Start of the interval. |
| [in] | a_tMax | End of the interval. |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inline |
Reconcile face. This will compute the normal vector, area, centroid, and the 2D embedding of the polygon.
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
|
inlinenoexcept |
Set the half edge index.
| [in] | a_halfEdgeIndex | Index of the half-edge in the owning mesh's edge array, or UINT32_MAX to mark it unset. |
|
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 |
Compute the signed distance to a point.
| [in] | a_x0 | Point in space |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
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 |
| [in] | a_mesh | Owning mesh, used to resolve the half-edge loop. |
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 index. A valid face will always have this set.
Index into the owning DCEL::MeshT's edge array, or UINT32_MAX if unset.
|
protected |
Cartesian axis used as the 2D x-direction of this polygon's 2D embedding (stored by reconcile()). The inside/outside test projects points to 2D by keeping (m_xDir, m_yDir) and dropping the coordinate of the largest normal component.
Defaults to the out-of-range sentinel UINT32_MAX rather than a valid axis (0-2) so that a face used before reconcile()/computeProjectionDirections() has run trips the m_xDir < 3 assertions in projectPoint() and isPointInsideFace() instead of silently projecting onto axis 0.
|
protected |
Cartesian axis used as the 2D y-direction of this polygon's 2D embedding (stored by reconcile()).
Defaults to the out-of-range sentinel UINT32_MAX for the same reason as m_xDir.