|
chombo-discharge
|
Class that represents a single triangle together with associated metadata on the vertices (one float per vertex) More...
#include <CD_Triangle.H>


Public Types | |
| using | Vec3 = EBGeometry::Vec3T< Real > |
| Alias for always-3D vector type. | |
Public Member Functions | |
| Triangle () noexcept | |
| Default constructor. | |
| Triangle (const std::array< Vec3, 3 > &a_vertexPositions) noexcept | |
| Full constructor. | |
| virtual | ~Triangle () noexcept |
| Destructor. | |
| void | computeArea () noexcept |
| Compute and store the triangle area in m_area. | |
| void | setVertexPositions (const std::array< Vec3, 3 > &a_vertexPositions) noexcept |
| Set vertex positions and recompute the triangle area. | |
| void | setVertexData (const std::array< Real, 3 > &a_vertexData) noexcept |
| Set meta-data on the vertices. | |
| Vec3 | projectToTrianglePlane (const Vec3 &a_point) const noexcept |
| Project the input point to the triangle plane. | |
| bool | isInside (const Vec3 &a_point) const noexcept |
| Check if a point lies inside the triangle. | |
| Real | interpolate (const Vec3 &a_point) const noexcept |
| Interpolate vertex data at a point using barycentric coordinates or IDW fallback. | |
Protected Member Functions | |
| Real | computeTriangleArea (const Vec3 a_x1, const Vec3 a_x2, const Vec3 a_x3) const noexcept |
| Compute the area of a triangle defined by three vertices. | |
Protected Attributes | |
| Real | m_area = Real(0) |
| Triangle area. | |
Class that represents a single triangle together with associated metadata on the vertices (one float per vertex)
|
noexcept |
Default constructor.
Leaves vertex positions at their EBGeometry defaults and initializes vertex metadata to zero. The triangle area is zero-initialized. Vertex positions must be set before calling computeArea(), isInside(), or interpolate().
|
noexcept |
Full constructor.
Sets vertex positions, computes the triangle normal and area, and zero-initializes vertex metadata.
| [in] | a_vertexPositions | Vertex positions, in CCW order when viewed from the normal direction. |
|
noexcept |
Compute and store the triangle area in m_area.
Uses the cross-product formula: area = 0.5 * ||(v1-v0) x (v2-v0)||. This is called automatically by setVertexPositions(), so manual invocation is only needed if vertex positions were changed through the base class API directly.
Interpolate vertex data at a point using barycentric coordinates or IDW fallback.
For points inside the triangle, barycentric weights are computed from area ratios and the weighted sum of the three vertex data values is returned. For points outside the triangle, inverse-distance weighting (IDW, Shepard power = 1) over the two nearest vertices is used instead: weights are w_i = d_j/(d_i+d_j) and w_j = d_i/(d_i+d_j), ensuring the interpolated value stays within the data range and is bounded. If both nearest distances are zero, equal weights of 0.5 are used. Returns zero for degenerate triangles (m_area == 0).
| [in] | a_point | Query point in 3D space. |
Check if a point lies inside the triangle.
Tests whether the projection of a_point onto the triangle plane falls within the triangle boundary. The test is based on the sign of the triple products of each edge direction with the triangle normal, so it is valid for arbitrary 3D points (not just coplanar ones). Points exactly on an edge are considered inside.
| [in] | a_point | Query point in 3D space. |
Project the input point to the triangle plane.
| [in] | a_point | Input point. |
|
noexcept |
Set meta-data on the vertices.
| [in] | a_vertexData | Data on the vertices. Must be in the same order as the vertex positions. |
|
noexcept |
Set vertex positions and recompute the triangle area.
This shadows EBGeometry::Triangle::setVertexPositions to ensure that m_area is kept in sync whenever vertex positions change.
| [in] | a_vertexPositions | Vertex positions. |