A triangle primitive used to calculate face normals and swept volumes. More...
Public Types | |
enum | proxType { NONE, POINT, EDGE } |
Return types for classify. More... | |
Public Member Functions | |
triangle (const Point &a, const Point &b, const Point &c) | |
Construct from three points. More... | |
triangle (const UList< Point > &, const FixedList< label, 3 > &indices) | |
Construct from three points in the list of points. More... | |
triangle (Istream &) | |
Construct from Istream. More... | |
const Point & | a () const |
Return first vertex. More... | |
const Point & | b () const |
Return second vertex. More... | |
const Point & | c () const |
Return third vertex. More... | |
Point | centre () const |
Return centre (centroid) More... | |
scalar | mag () const |
Return scalar magnitude. More... | |
vector | normal () const |
Return vector normal. More... | |
Point | circumCentre () const |
Return circum-centre. More... | |
scalar | circumRadius () const |
Return circum-radius. More... | |
scalar | quality () const |
Return quality: Ratio of triangle and circum-circle. More... | |
scalar | sweptVol (const triangle &t) const |
Return swept-volume. More... | |
tensor | inertia (PointRef refPt=vector::zero, scalar density=1.0) const |
Return the inertia tensor, with optional reference. More... | |
Point | randomPoint (Random &rndGen) const |
Return a random point on the triangle from a uniform. More... | |
Point | randomPoint (cachedRandom &rndGen) const |
Return a random point on the triangle from a uniform. More... | |
scalar | barycentric (const point &pt, List< scalar > &bary) const |
Calculate the barycentric coordinates of the given. More... | |
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. More... | |
pointHit | intersection (const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const |
Fast intersection with a ray. More... | |
pointHit | nearestPointClassify (const point &p, label &nearType, label &nearLabel) const |
Find the nearest point to p on the triangle and classify it: More... | |
pointHit | nearestPoint (const point &p) const |
Return nearest point to p on triangle. More... | |
bool | classify (const point &p, label &nearType, label &nearLabel) const |
Classify nearest point to p in triangle plane. More... | |
pointHit | nearestPoint (const linePointRef &edge, pointHit &edgePoint) const |
Return nearest point to line on triangle. Returns hit if. More... | |
Friends | |
Istream & | operator>> (Istream &, triangle &) |
Ostream & | operator (Ostream &, const triangle &) |
A triangle primitive used to calculate face normals and swept volumes.
Definition at line 57 of file triangle.H.
enum proxType |
|
inline |
Construct from three points.
Definition at line 34 of file triangleI.H.
Construct from three points in the list of points.
The indices could be from triFace etc.
Definition at line 48 of file triangleI.H.
Construct from Istream.
Definition at line 61 of file triangleI.H.
|
inline |
Return first vertex.
Definition at line 70 of file triangleI.H.
Referenced by triSurfaceTools::calcInterpolationWeights(), particle< Type >::hitWallFaces(), and OBJstream::write().
|
inline |
Return second vertex.
Definition at line 76 of file triangleI.H.
Referenced by triSurfaceTools::calcInterpolationWeights(), particle< Type >::hitWallFaces(), and OBJstream::write().
|
inline |
Return third vertex.
Definition at line 82 of file triangleI.H.
Referenced by triSurfaceTools::calcInterpolationWeights(), particle< Type >::hitWallFaces(), and OBJstream::write().
|
inline |
Return centre (centroid)
Definition at line 89 of file triangleI.H.
Referenced by momentOfInertia::massPropertiesShell(), and polyMesh::pointInCell().
|
inline |
Return scalar magnitude.
Definition at line 96 of file triangleI.H.
References Foam::mag().
Referenced by FreeStream< CloudType >::inflow(), and momentOfInertia::massPropertiesShell().
|
inline |
Return vector normal.
Definition at line 103 of file triangleI.H.
Referenced by particle< Type >::hitWallFaces(), solidParticle::hitWallPatch(), particle< Type >::normal(), particle< Type >::oldNormal(), KinematicCloud< CloudType >::patchData(), polyMesh::pointInCell(), wallBoundedParticle::trackToEdge(), and particle< Type >::trackToFace().
|
inline |
Return circum-centre.
Definition at line 110 of file triangleI.H.
References Foam::constant::physicoChemical::c1, Foam::constant::physicoChemical::c2, and Foam::mag().
|
inline |
Return circum-radius.
Definition at line 137 of file triangleI.H.
References Foam::mag(), Foam::max(), Foam::min(), and Foam::sqrt().
|
inline |
Return quality: Ratio of triangle and circum-circle.
area, scaled so that an equilateral triangle has a quality of 1
Definition at line 161 of file triangleI.H.
References Foam::mag(), Foam::sqr(), Foam::sqrt(), and triangle< Point, PointRef >::sweptVol().
|
inline |
Return swept-volume.
Definition at line 177 of file triangleI.H.
References triangle< Point, PointRef >::inertia().
Referenced by triangle< Point, PointRef >::quality().
|
inline |
Return the inertia tensor, with optional reference.
point and density specification
Definition at line 196 of file triangleI.H.
References Foam::I, and Foam::mag().
Referenced by triFace::inertia(), and triangle< Point, PointRef >::sweptVol().
|
inline |
Return a random point on the triangle from a uniform.
distribution
Definition at line 232 of file triangleI.H.
References s(), Random::scalar01(), and Foam::sqrt().
Referenced by FreeStream< CloudType >::inflow(), and patchInjectionBase::setPositionAndCell().
|
inline |
Return a random point on the triangle from a uniform.
distribution
Definition at line 249 of file triangleI.H.
References triangle< Point, PointRef >::barycentric(), s(), cachedRandom::sample01(), and Foam::sqrt().
Calculate the barycentric coordinates of the given.
point, in the same order as a, b, c. Returns the determinant of the solution.
Definition at line 268 of file triangleI.H.
References Foam::mag(), triangle< Point, PointRef >::ray(), and List< T >::setSize().
Referenced by cellPointWeight::findTriangle(), and triangle< Point, PointRef >::randomPoint().
|
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 309 of file triangleI.H.
References PointHit< Point >::hit(), triangle< Point, PointRef >::intersection(), Foam::mag(), Foam::min(), n, p, PointHit< Point >::rawPoint(), PointHit< Point >::setDistance(), PointHit< Point >::setHit(), PointHit< Point >::setMiss(), and PointHit< Point >::setPoint().
Referenced by triangle< Point, PointRef >::barycentric(), and triFace::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 425 of file triangleI.H.
References Foam::det(), triangle< Point, PointRef >::nearestPointClassify(), PointHit< Point >::setDistance(), PointHit< Point >::setHit(), PointHit< Point >::setPoint(), and Foam::Zero.
Referenced by mappedPatchBase::facePoint(), particle< Type >::hitWallFaces(), triFace::intersection(), and triangle< Point, PointRef >::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 508 of file triangleI.H.
References cp, Foam::mag(), and triangle< Point, PointRef >::nearestPoint().
Referenced by triSurfaceTools::calcInterpolationWeights(), triangle< Point, PointRef >::intersection(), triFace::nearestPointClassify(), and face::nearestPointClassify().
|
inline |
Return nearest point to p on triangle.
Definition at line 657 of file triangleI.H.
References triangle< Point, PointRef >::classify().
Referenced by triangle< Point, PointRef >::classify(), cellPointWeight::findTriangle(), triFace::nearestPoint(), and triangle< Point, PointRef >::nearestPointClassify().
Classify nearest point to p in triangle plane.
w.r.t. triangle edges and points. Returns inside (true)/outside (false).
Definition at line 671 of file triangleI.H.
References triangle< Point, PointRef >::nearestPoint().
Referenced by triangle< Point, PointRef >::nearestPoint().
|
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 683 of file triangleI.H.
References PointHit< Point >::distance(), line< Point, PointRef >::end(), PointHit< Point >::hit(), PointHit< Point >::hitPoint(), Foam::mag(), PointHit< Point >::missPoint(), line< Point, PointRef >::nearestDist(), Foam::nl, Istream::readBegin(), PointHit< Point >::setDistance(), PointHit< Point >::setHit(), PointHit< Point >::setMiss(), PointHit< Point >::setPoint(), line< Point, PointRef >::start(), and line< Point, PointRef >::vec().