A triangle primitive used to calculate face normals and swept volumes. Uses referred points. More...
#include <triangle.H>

Classes | |
| struct | dummyOp |
| Dummy. More... | |
| struct | sumAreaOp |
| Sum resulting areas. More... | |
| struct | storeOp |
| Store resulting tris. More... | |
Public Types | |
| enum | proxType { NONE = 0 , POINT , EDGE } |
| Proximity classifications. More... | |
| typedef Point | point_type |
| The point type. | |
| typedef FixedList< triPoints, 27 > | triIntersectionList |
| Storage type for triangles originating from intersecting triangle with another triangle. | |
Public Member Functions | |
| triangle (const Point &p0, const Point &p1, const Point &p2) | |
| Construct from three points. | |
| triangle (const FixedList< Point, 3 > &pts) | |
| Construct from three points. | |
| triangle (const UList< Point > &points, const FixedList< label, 3 > &indices) | |
| Construct from three points out of the list of points. | |
| triangle (const UList< Point > &points, const label p0, const label p1, const label p2) | |
| Construct from three points out of the list of points. | |
| triangle (Istream &is) | |
| Construct from Istream. | |
| const Point & | a () const noexcept |
| The first vertex. | |
| const Point & | b () const noexcept |
| The second vertex. | |
| const Point & | c () const noexcept |
| The third vertex. | |
| Point | centre () const |
| Return centre (centroid). | |
| vector | areaNormal () const |
| The area normal - with magnitude equal to area of triangle. | |
| vector | unitNormal () const |
| Return unit normal. | |
| FOAM_DEPRECATED_FOR (2018-12, "areaNormal() or unitNormal()") vector normal() const | |
| Legacy name for areaNormal(). | |
| scalar | mag () const |
| The magnitude of the triangle area. | |
| scalar | magSqr () const |
| The magnitude squared of the triangle area. | |
| Pair< Point > | box () const |
| The enclosing (bounding) box for the triangle. | |
| Point | vecA () const |
| Edge vector opposite point a(): from b() to c(). | |
| Point | vecB () const |
| Edge vector opposite point b(): from c() to a(). | |
| Point | vecC () const |
| Edge vector opposite point c(): from a() to b(). | |
| Point | circumCentre () const |
| Return circum-centre. | |
| scalar | circumRadius () const |
| Return circum-radius. | |
| scalar | quality () const |
| Return quality: Ratio of triangle and circum-circle. | |
| scalar | sweptVol (const triangle &t) const |
| Return swept-volume. | |
| tensor | inertia (PointRef refPt=Zero, scalar density=1.0) const |
| Return the inertia tensor, with optional reference. | |
| Point | randomPoint (Random &rndGen) const |
| Return a random point on the triangle from a uniform distribution. | |
| Point | barycentricToPoint (const barycentric2D &bary) const |
| Calculate the point from the given barycentric coordinates. | |
| barycentric2D | pointToBarycentric (const point &pt) const |
| Calculate the barycentric coordinates from the given point. | |
| scalar | pointToBarycentric (const point &pt, barycentric2D &bary) const |
| Calculate the barycentric coordinates from the given point. | |
| bool | intersects (const point &origin, const vector &normal) const |
| Fast intersection detection with a plane. | |
| bool | intersects (const point &origin, const vector::components axis) const |
| Fast intersection detection with an axis plane. | |
| pointHit | ray (const point &p, const vector &q, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction dir=intersection::VECTOR) const |
| Return point intersection with a ray. | |
| pointHit | intersection (const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const |
| Fast intersection with a ray. | |
| pointHit | nearestPointClassify (const point &p, label &nearType, label &nearLabel) const |
| Find the nearest point to p on the triangle and classify it: | |
| pointHit | nearestPoint (const point &p) const |
| Return nearest point to p on triangle. | |
| bool | classify (const point &p, label &nearType, label &nearLabel) const |
| Classify nearest point to p in triangle plane. | |
| pointHit | nearestPoint (const linePointRef &edge, pointHit &edgePoint) const |
| Return nearest point to line on triangle. Returns hit if. | |
| int | sign (const point &p, const scalar tol=SMALL) const |
| The sign for which side of the face plane the point is on. | |
| template<class AboveOp, class BelowOp> | |
| void | sliceWithPlane (const plane &pln, AboveOp &aboveOp, BelowOp &belowOp) const |
| Decompose triangle into triangles above and below plane. | |
| template<class InsideOp, class OutsideOp> | |
| void | triangleOverlap (const vector &n, const triangle< Point, PointRef > &tri, InsideOp &insideOp, OutsideOp &outsideOp) const |
| Decompose triangle into triangles inside and outside. | |
Static Public Member Functions | |
| static Point | centre (const Point &p0, const Point &p1, const Point &p2) |
| The centre (centroid) of three points. | |
| static vector | areaNormal (const Point &p0, const Point &p1, const Point &p2) |
| The area normal for a triangle defined by three points (right-hand rule). Magnitude equal to area of the triangle. | |
| static vector | unitNormal (const Point &p0, const Point &p1, const Point &p2) |
| The unit normal for a triangle defined by three points (right-hand rule). | |
| static Pair< Point > | box (const Point &p0, const Point &p1, const Point &p2) |
| The enclosing (bounding) box for three points. | |
Friends | |
| Istream & | operator>> (Istream &, triangle &) |
| Ostream & | operator (Ostream &, const triangle &) |
A triangle primitive used to calculate face normals and swept volumes. Uses referred points.
Definition at line 233 of file triangle.H.
| typedef Point point_type |
The point type.
Definition at line 242 of file triangle.H.
| typedef FixedList<triPoints, 27> triIntersectionList |
Storage type for triangles originating from intersecting triangle with another triangle.
Definition at line 248 of file triangle.H.
Proximity classifications.
| Enumerator | |
|---|---|
| NONE | Unknown proximity. |
| POINT | Close to point. |
| EDGE | Close to edge. |
Definition at line 253 of file triangle.H.
|
inline |
Construct from three points.
Definition at line 80 of file triangleI.H.
References p0.
Referenced by triangle< Point, PointRef >::sumAreaOp::operator()(), sweptVol(), and triangleOverlap().

|
inline |
Construct from three points out of the list of points.
The indices could be from triFace etc.
Definition at line 106 of file triangleI.H.
References points.
|
inline |
Construct from three points out of the list of points.
Definition at line 119 of file triangleI.H.
Construct from Istream.
Definition at line 134 of file triangleI.H.
The first vertex.
Definition at line 398 of file triangle.H.
Referenced by triSurfaceTools::calcInterpolationWeights(), circumRadius(), inertia(), triangleFuncs::intersectBb(), offsetSurface::operator()(), and triangleOverlap().

The second vertex.
Definition at line 403 of file triangle.H.
Referenced by triSurfaceTools::calcInterpolationWeights(), triangleFuncs::intersectBb(), offsetSurface::operator()(), and triangleOverlap().

The third vertex.
Definition at line 408 of file triangle.H.
Referenced by triSurfaceTools::calcInterpolationWeights(), circumCentre(), triangleFuncs::intersectBb(), offsetSurface::operator()(), quality(), and triangleOverlap().

|
inlinestatic |
The centre (centroid) of three points.
Definition at line 143 of file triangleI.H.
References p0.
Referenced by circumCentre(), primitiveMeshTools::makeFaceCentresAndAreas(), stabilisedFvGeometryScheme::makeFaceCentresAndAreas(), momentOfInertia::massPropertiesShell(), nearestPointClassify(), polyMesh::pointInCell(), wallBoundedStreamLine::pushIn(), and primitiveMeshTools::updateFaceCentresAndAreas().

|
inlinestatic |
The area normal for a triangle defined by three points (right-hand rule). Magnitude equal to area of the triangle.
Definition at line 168 of file triangleI.H.
References p0.
Referenced by mag(), magSqr(), primitiveMeshTools::makeFaceCentresAndAreas(), stabilisedFvGeometryScheme::makeFaceCentresAndAreas(), tetrahedron< Point, PointRef >::nearestPoint(), polyMesh::pointInCell(), ray(), advancingFrontAMI::triangulatePatch(), unitNormal(), and primitiveMeshTools::updateFaceCentresAndAreas().

|
inlinestatic |
The unit normal for a triangle defined by three points (right-hand rule).
Definition at line 193 of file triangleI.H.
References areaNormal(), n, and p0.
Referenced by tetrahedron< Point, PointRef >::inside(), and sign().


|
inlinestatic |
The enclosing (bounding) box for three points.
Definition at line 220 of file triangleI.H.
References Foam::max(), Foam::min(), and p0.

Return centre (centroid).
Definition at line 155 of file triangleI.H.
|
inline |
The area normal - with magnitude equal to area of triangle.
Definition at line 180 of file triangleI.H.
Referenced by triangle< point, const point & >::FOAM_DEPRECATED_FOR(), tetrahedron< Point, PointRef >::Sa(), tetrahedron< Point, PointRef >::Sb(), tetrahedron< Point, PointRef >::Sc(), and tetrahedron< Point, PointRef >::Sd().

|
inline |
Return unit normal.
Definition at line 207 of file triangleI.H.
References unitNormal().
Referenced by unitNormal().


|
inline |
Legacy name for areaNormal().
Definition at line 478 of file triangle.H.
|
inline |
The magnitude of the triangle area.
Definition at line 309 of file triangleI.H.
References areaNormal().
Referenced by polyMeshGeometry::checkFaceFlatness(), FreeStream< CloudType >::inflow(), momentOfInertia::massPropertiesShell(), and advancingFrontAMI::triangulatePatch().


|
inline |
The magnitude squared of the triangle area.
Definition at line 322 of file triangleI.H.
References areaNormal().

|
inline |
The enclosing (bounding) box for the triangle.
Definition at line 236 of file triangleI.H.
References box().
Referenced by box().


Edge vector opposite point a(): from b() to c().
Definition at line 249 of file triangleI.H.
Edge vector opposite point b(): from c() to a().
Definition at line 255 of file triangleI.H.
Edge vector opposite point c(): from a() to b().
Definition at line 261 of file triangleI.H.
Return circum-centre.
Definition at line 329 of file triangleI.H.
References c(), centre(), and Foam::mag().
Referenced by Foam::edgeMeshTools::featureProximity().


|
inline |
Return circum-radius.
Definition at line 356 of file triangleI.H.
References a(), Foam::clamp(), Foam::mag(), and Foam::sqrt().
Referenced by Foam::edgeMeshTools::featureProximity(), and quality().


|
inline |
Return quality: Ratio of triangle and circum-circle.
area, scaled so that an equilateral triangle has a quality of 1
Definition at line 377 of file triangleI.H.
References c(), circumRadius(), Foam::mag(), Foam::sqr(), and Foam::sqrt().
Referenced by searchableSurfaces::checkQuality().


|
inline |
Return swept-volume.
Definition at line 392 of file triangleI.H.
References triangle().
Referenced by face::sweptVol().


|
inline |
Return the inertia tensor, with optional reference.
point and density specification
Definition at line 411 of file triangleI.H.
References a(), Foam::I, Foam::mag(), and VectorSpace< Form, Cmpt, Mrows *Ncols >::one.
Referenced by face::inertia(), and momentOfInertia::massPropertiesShell().


Return a random point on the triangle from a uniform distribution.
Definition at line 448 of file triangleI.H.
References Foam::barycentric2D01(), barycentricToPoint(), and rndGen.
Referenced by FreeStream< CloudType >::inflow().


|
inline |
Calculate the point from the given barycentric coordinates.
Definition at line 455 of file triangleI.H.
Referenced by randomPoint().

|
inline |
Calculate the barycentric coordinates from the given point.
Definition at line 465 of file triangleI.H.
References pointToBarycentric().
Referenced by cellPointWeight::findTriangle(), distributedTriSurfaceMesh::getNormal(), offsetSurface::operator()(), and pointToBarycentric().


|
inline |
Calculate the barycentric coordinates from the given point.
Returns the determinant.
Definition at line 477 of file triangleI.H.
References Foam::mag().

|
inline |
Fast intersection detection with a plane.
Definition at line 516 of file triangleI.H.
|
inline |
Fast intersection detection with an axis plane.
Definition at line 536 of file triangleI.H.
|
inline |
Return point intersection with a ray.
For a hit, the distance is signed. Positive number represents the point in front of triangle. In case of miss pointHit is set to nearest point on triangle and its distance to the distance between the original point and the plane intersection point
Definition at line 556 of file triangleI.H.
References areaNormal(), intersection::CONTACT_SPHERE, intersection::FULL_RAY, intersection::HALF_RAY, PointHit< PointType >::hit(), PointHit< PointType >::hitPoint(), intersection(), Foam::mag(), Foam::min(), n, nearestPoint(), p, intersection::planarTol(), PointHit< PointType >::point(), ray(), PointHit< PointType >::setDistance(), PointHit< PointType >::setMiss(), PointHit< PointType >::setPoint(), intersection::VECTOR, and intersection::VISIBLE.
Referenced by face::ray(), and ray().


|
inline |
Fast intersection with a ray.
For a hit, the pointHit.distance() is the line parameter t : intersection=p+t*q. Only defined for VISIBLE, FULL_RAY or HALF_RAY. tol increases the virtual size of the triangle by a relative factor.
Definition at line 671 of file triangleI.H.
References Foam::det(), intersection::FULL_RAY, intersection::HALF_RAY, intersection(), intersection::VISIBLE, and Foam::Zero.
Referenced by mappedPatchBase::facePoint(), treeDataPrimitivePatch< PatchType >::findIntersection(), triangleFuncs::intersectBb(), face::intersection(), intersection(), nearestPoint(), and ray().


| Foam::pointHit nearestPointClassify | ( | const point & | p, |
| label & | nearType, | ||
| label & | nearLabel ) const |
Find the nearest point to p on the triangle and classify it:
+ near point (nearType=POINT, nearLabel=0, 1, 2) + near edge (nearType=EDGE, nearLabel=0, 1, 2) Note: edges are counted from starting vertex so e.g. edge 2 is from f[2] to f[0]
Definition at line 753 of file triangleI.H.
References centre(), Foam::cp(), EDGE, Foam::mag(), NONE, p, and POINT.
Referenced by triSurfaceTools::calcInterpolationWeights(), classify(), nearestPoint(), and face::nearestPointClassify().


|
inline |
Return nearest point to p on triangle.
Definition at line 902 of file triangleI.H.
References nearestPointClassify(), and p.
Referenced by wallBoundedStreamLine::findNearestTet(), cellPointWeight::findTriangle(), tetrahedron< Point, PointRef >::nearestPoint(), and ray().


|
inline |
Classify nearest point to p in triangle plane.
w.r.t. triangle edges and points. Returns inside (true)/outside (false).
Definition at line 916 of file triangleI.H.
References nearestPointClassify(), and p.
Referenced by triSurfaceTools::classify().


|
inline |
Return nearest point to line on triangle. Returns hit if.
point is inside triangle. Sets edgePoint to point on edge (hit if nearest is inside line)
Definition at line 928 of file triangleI.H.
References Vector< Cmpt >::dist(), PointHit< PointType >::distance(), intersection::FULL_RAY, PointHit< PointType >::hit(), PointHit< PointType >::hitPoint(), intersection(), Foam::ln(), Foam::mag(), PointHit< PointType >::point(), PointHit< PointType >::setDistance(), PointHit< PointType >::setMiss(), and PointHit< PointType >::setPoint().

|
inline |
The sign for which side of the face plane the point is on.
Uses the supplied tolerance for rounding around zero.
Definition at line 1052 of file triangleI.H.
References p, and unitNormal().
Referenced by face::sign().


|
inline |
Decompose triangle into triangles above and below plane.
Definition at line 106 of file triangle.C.
|
inline |
Decompose triangle into triangles inside and outside.
(with respect to user provided normal) other triangle.
Definition at line 119 of file triangle.C.
References a(), b(), c(), Foam::mag(), n, triangle< Point, PointRef >::storeOp::nTris_, s(), triangle(), and triangle< Point, PointRef >::storeOp::tris_.

|
friend |
|
friend |