40#ifndef Foam_triangle_H
41#define Foam_triangle_H
65template<
class Po
int,
class Po
intRef>
68template<
class Po
int,
class Po
intRef>
89 void front() =
delete;
162 inline scalar
mag()
const;
165 inline scalar
magSqr()
const;
185template<
class Po
int,
class Po
intRef>
216 void operator()(
const triPoints&)
const noexcept
261 inline static point planeIntersection
270 template<
class AboveOp,
class BelowOp>
271 inline static void triSliceWithPlane
354 inline static Pair<Point>
box
382 inline scalar
mag()
const;
385 inline scalar
magSqr()
const;
420 PointRef refPt =
Zero,
482 const scalar tol = 0.0
525 inline int sign(
const point&
p,
const scalar tol = SMALL)
const;
528 template<
class AboveOp,
class BelowOp>
539 template<
class Ins
ideOp,
class Outs
ideOp>
A 1D vector of objects of type <T> with a fixed length <N>.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
An ordered pair of two objects of type <T> with first() and second() elements.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Triangle point storage. Default constructable (triangle is not).
void flip()
Flip triangle orientation by swapping second and third vertices.
point & b() noexcept
The second vertex.
triPointRef tri() const
Return as triangle reference.
void back()=delete
The back() accessor (from FixedList) has no purpose.
void front()=delete
The front() accessor (from FixedList) has no purpose.
const point & c() const noexcept
The third vertex.
point & a() noexcept
The first vertex.
vector vecA() const
Edge vector opposite point a(): from b() to c().
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
const point & b() const noexcept
The second vertex.
Pair< point > box() const
The enclosing (bounding) box for the triangle.
vector unitNormal() const
Return unit normal.
scalar mag() const
The magnitude of the triangle area.
vector vecC() const
Edge vector opposite point c(): from a() to b().
triPoints()=default
Default construct.
point & c() noexcept
The third vertex.
const point & a() const noexcept
The first vertex.
scalar magSqr() const
The magnitude squared of the triangle area.
point centre() const
Return centre (centroid).
vector vecB() const
Edge vector opposite point b(): from c() to a().
A triangle primitive used to calculate face normals and swept volumes. Uses referred points.
Point circumCentre() const
Return circum-centre.
barycentric2D pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
void sliceWithPlane(const plane &pln, AboveOp &aboveOp, BelowOp &belowOp) const
Decompose triangle into triangles above and below plane.
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 ...
triangle(const UList< Point > &points, const label p0, const label p1, const label p2)
Construct from three points out of the list of points.
FOAM_DEPRECATED_FOR(2018-12, "areaNormal() or unitNormal()") vector normal() const
Legacy name for areaNormal().
scalar circumRadius() const
Return circum-radius.
Point barycentricToPoint(const barycentric2D &bary) const
Calculate the point from the given barycentric coordinates.
scalar sweptVol(const triangle &t) const
Return swept-volume.
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
Point centre() const
Return centre (centroid).
triangle(const FixedList< Point, 3 > &pts)
Construct from three points.
Point vecB() const
Edge vector opposite point b(): from c() to a().
FixedList< triPoints, 27 > triIntersectionList
Storage type for triangles originating from intersecting triangle with another triangle.
void triangleOverlap(const vector &n, const triangle< Point, PointRef > &tri, InsideOp &insideOp, OutsideOp &outsideOp) const
Decompose triangle into triangles inside and outside.
pointHit nearestPointClassify(const point &p, label &nearType, label &nearLabel) const
Find the nearest point to p on the triangle and classify it:
bool intersects(const point &origin, const vector::components axis) const
Fast intersection detection with an axis plane.
proxType
Proximity classifications.
triangle(const Point &p0, const Point &p1, const Point &p2)
Construct from three points.
static Pair< Point > box(const Point &p0, const Point &p1, const Point &p2)
The enclosing (bounding) box for three points.
static Point centre(const Point &p0, const Point &p1, const Point &p2)
The centre (centroid) of three points.
const Point & b() const noexcept
The second vertex.
scalar pointToBarycentric(const point &pt, barycentric2D &bary) const
Calculate the barycentric coordinates from the given point.
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.
vector unitNormal() const
Return unit normal.
triangle(Istream &is)
Construct from Istream.
pointHit nearestPoint(const linePointRef &edge, pointHit &edgePoint) const
Return nearest point to line on triangle. Returns hit if.
tensor inertia(PointRef refPt=Zero, scalar density=1.0) const
Return the inertia tensor, with optional reference.
scalar mag() const
The magnitude of the triangle area.
bool intersects(const point &origin, const vector &normal) const
Fast intersection detection with a plane.
friend Ostream & operator(Ostream &, const triangle &)
Point point_type
The point type.
pointHit nearestPoint(const point &p) const
Return nearest point to p on triangle.
Point randomPoint(Random &rndGen) const
Return a random point on the triangle from a uniform distribution.
Pair< Point > box() const
The enclosing (bounding) box for the triangle.
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
bool classify(const point &p, label &nearType, label &nearLabel) const
Classify nearest point to p in triangle plane.
scalar magSqr() const
The magnitude squared of the triangle area.
int sign(const point &p, const scalar tol=SMALL) const
The sign for which side of the face plane the point is on.
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).
scalar quality() const
Return quality: Ratio of triangle and circum-circle.
const Point & c() const noexcept
The third vertex.
Point vecA() const
Edge vector opposite point a(): from b() to c().
const Point & a() const noexcept
The first vertex.
triangle(const UList< Point > &points, const FixedList< label, 3 > &indices)
Construct from three points out of the list of points.
Point vecC() const
Edge vector opposite point c(): from a() to b().
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const volScalarField & p0
PointHit< point > pointHit
A PointHit with a 3D point.
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
line< point, const point & > linePointRef
A line using referred points.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
triangle< point, const point & > triPointRef
A triangle using referred points.
#define FOAM_DEPRECATED_FOR(since, replacement)
void operator()(const triPoints &) const noexcept
storeOp(triIntersectionList &, label &)
triIntersectionList & tris_
void operator()(const triPoints &)
void operator()(const triPoints &)
constexpr sumAreaOp() noexcept
scalar total() const noexcept