75template<
class Po
int,
class Po
intRef>
91template<
class Po
int,
class Po
intRef>
97 a_(
pts.template get<0>()),
98 b_(
pts.template get<1>()),
99 c_(
pts.template get<2>()),
100 d_(
pts.template get<3>())
104template<
class Po
int,
class Po
intRef>
111 a_(
points[indices.template get<0>()]),
113 c_(
points[indices.template get<2>()]),
114 d_(
points[indices.template get<3>()])
118template<
class Po
int,
class Po
intRef>
144template<
class Po
int,
class Po
intRef>
161template<
class Po
int,
class Po
intRef>
174template<
class Po
int,
class Po
intRef>
190template<
class Po
int,
class Po
intRef>
217 <<
"Face index (" << facei <<
") out of range 0..3\n"
223template<
class Po
int,
class Po
intRef>
230template<
class Po
int,
class Po
intRef>
237template<
class Po
int,
class Po
intRef>
244template<
class Po
int,
class Po
intRef>
251template<
class Po
int,
class Po
intRef>
254 return 0.25*(a_ + b_ + c_ + d_);
258template<
class Po
int,
class Po
intRef>
261 return (1.0/6.0)*(((b_ - a_) ^ (c_ - a_)) & (d_ - a_));
265template<
class Po
int,
class Po
intRef>
279 scalar denom = (
c & ba);
288 return a_ + 0.5*(a + num/denom);
292template<
class Po
int,
class Po
intRef>
306 scalar denom = (c & ba);
318template<
class Po
int,
class Po
intRef>
331template<
class Po
int,
class Po
intRef>
341template<
class Po
int,
class Po
intRef>
347 return Point(bary.a()*a_ + bary.b()*b_ + bary.c()*c_ + bary.d()*d_);
351template<
class Po
int,
class Po
intRef>
363template<
class Po
int,
class Po
intRef>
379 e0.x(), e1.x(), e2.x(),
380 e0.y(), e1.y(), e2.y(),
381 e0.z(), e1.z(), e2.z()
384 scalar detT =
det(t);
400 bary[3] = 1 - bary[0] - bary[1] - bary[2];
406template<
class Po
int,
class Po
intRef>
420 scalar minOutsideDistance = VGREAT;
435 if (info.
distance() < minOutsideDistance)
437 closestPt = info.
point();
439 minOutsideDistance = info.
distance();
446 const triangle<Point, PointRef> tria(a_, d_, c_);
448 if (((
p - a_) & tria.areaNormal()) >= 0)
455 if (info.distance() < minOutsideDistance)
457 closestPt = info.point();
459 minOutsideDistance = info.distance();
468 if (((
p - a_) & tria.areaNormal()) >= 0)
475 if (info.distance() < minOutsideDistance)
477 closestPt = info.point();
479 minOutsideDistance = info.distance();
488 if (((
p - a_) & tria.areaNormal()) >= 0)
495 if (info.distance() < minOutsideDistance)
497 closestPt = info.point();
499 minOutsideDistance = info.distance();
508 minOutsideDistance = 0;
521template<
class Po
int,
class Po
intRef>
543 if (((
p - b_) & tria.unitNormal()) > SMALL)
553 if (((
p - a_) & tria.unitNormal()) > SMALL)
563 if (((
p - a_) & tria.unitNormal()) > SMALL)
573 if (((
p - a_) & tria.unitNormal()) > SMALL)
583template<
class Po
int,
class Po
intRef>
589 vol_ += tet.tet().mag();
593template<
class Po
int,
class Po
intRef>
605template<
class Po
int,
class Po
intRef>
611 tets_[nTets_++] = tet;
615template<
class Po
int,
class Po
intRef>
616inline Foam::point Foam::tetrahedron<Point, PointRef>::planeIntersection
625 (d[posI]*t[negI] - d[negI]*t[posI])
626 / (-d[negI]+d[posI]);
630template<
class Po
int,
class Po
intRef>
632inline void Foam::tetrahedron<Point, PointRef>::decomposePrism
634 const FixedList<point, 6>&
points,
644template<
class Po
int,
class Po
intRef>
645template<
class AboveTetOp,
class BelowTetOp>
646inline void Foam::tetrahedron<Point, PointRef>::tetSliceWithPlane
659 d[i] = pln.signedDistance(tet[i]);
687 label i2 = d.fcIndex(i1);
688 label i3 = d.fcIndex(i2);
690 point p01(planeIntersection(d, tet, i0, i1));
691 point p02(planeIntersection(d, tet, i0, i2));
692 point p03(planeIntersection(d, tet, i0, i3));
701 if (i0 == 0 || i0 == 2)
722 decomposePrism(
p, aboveOp);
744 decomposePrism(
p, aboveOp);
773 if (posEdge ==
edge(0, 1))
775 point p02(planeIntersection(d, tet, 0, 2));
776 point p03(planeIntersection(d, tet, 0, 3));
777 point p12(planeIntersection(d, tet, 1, 2));
778 point p13(planeIntersection(d, tet, 1, 3));
794 decomposePrism(
p, aboveOp);
810 decomposePrism(
p, belowOp);
813 else if (posEdge ==
edge(1, 2))
815 point p01(planeIntersection(d, tet, 0, 1));
816 point p13(planeIntersection(d, tet, 1, 3));
817 point p02(planeIntersection(d, tet, 0, 2));
818 point p23(planeIntersection(d, tet, 2, 3));
834 decomposePrism(
p, aboveOp);
850 decomposePrism(
p, belowOp);
853 else if (posEdge ==
edge(2, 0))
855 point p01(planeIntersection(d, tet, 0, 1));
856 point p03(planeIntersection(d, tet, 0, 3));
857 point p12(planeIntersection(d, tet, 1, 2));
858 point p23(planeIntersection(d, tet, 2, 3));
874 decomposePrism(
p, aboveOp);
890 decomposePrism(
p, belowOp);
893 else if (posEdge ==
edge(0, 3))
895 point p01(planeIntersection(d, tet, 0, 1));
896 point p02(planeIntersection(d, tet, 0, 2));
897 point p13(planeIntersection(d, tet, 1, 3));
898 point p23(planeIntersection(d, tet, 2, 3));
914 decomposePrism(
p, aboveOp);
930 decomposePrism(
p, belowOp);
933 else if (posEdge ==
edge(1, 3))
935 point p01(planeIntersection(d, tet, 0, 1));
936 point p12(planeIntersection(d, tet, 1, 2));
937 point p03(planeIntersection(d, tet, 0, 3));
938 point p23(planeIntersection(d, tet, 2, 3));
954 decomposePrism(
p, aboveOp);
970 decomposePrism(
p, belowOp);
973 else if (posEdge ==
edge(2, 3))
975 point p02(planeIntersection(d, tet, 0, 2));
976 point p12(planeIntersection(d, tet, 1, 2));
977 point p03(planeIntersection(d, tet, 0, 3));
978 point p13(planeIntersection(d, tet, 1, 3));
994 decomposePrism(
p, aboveOp);
1010 decomposePrism(
p, belowOp);
1016 <<
"Missed edge:" << posEdge
1033 label i1 = d.fcIndex(i0);
1034 label i2 = d.fcIndex(i1);
1035 label i3 = d.fcIndex(i2);
1037 point p01(planeIntersection(d, tet, i0, i1));
1038 point p02(planeIntersection(d, tet, i0, i2));
1039 point p03(planeIntersection(d, tet, i0, i3));
1043 if (i0 == 0 || i0 == 2)
1064 decomposePrism(
p, belowOp);
1087 decomposePrism(
p, belowOp);
1097template<
class Po
int,
class Po
intRef>
1098template<
class AboveTetOp,
class BelowTetOp>
1102 AboveTetOp& aboveOp,
1106 tetSliceWithPlane(pl, tetPoints(a_, b_, c_, d_), aboveOp, belowOp);
1112template<
class Po
int,
class Po
intRef>
1113inline Foam::Istream& Foam::operator>>
1119 is.readBegin(
"tetrahedron");
1120 is >> t.a_ >> t.b_ >> t.c_ >> t.d_;
1121 is.readEnd(
"tetrahedron");
1129template<
class Po
int,
class Po
intRef>
1130inline Foam::Ostream& Foam::operator<<
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
const Cmpt & b() const noexcept
const Cmpt & d() const noexcept
const Cmpt & a() const noexcept
const Cmpt & c() const noexcept
A 1D vector of objects of type <T> with a fixed length <N>.
label fcIndex(const label i) const noexcept
Return the forward circular index, i.e. next index which returns to the first at the end of the list.
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.
scalar distance() const noexcept
Return distance to hit.
const point_type & point() const noexcept
Return the point, no checks.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const Cmpt & x() const noexcept
Access to the vector x component.
const Cmpt & z() const noexcept
Access to the vector z component.
const Cmpt & y() const noexcept
Access to the vector y component.
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 ...
Tet point storage. Default constructable (tetrahedron is not).
void flip()
Invert tetrahedron by swapping third and fourth vertices.
const point & c() const noexcept
The third vertex.
const point & d() const noexcept
The fourth vertex.
const point & b() const noexcept
The second vertex.
Pair< point > box() const
The enclosing (bounding) box for the tetrahedron.
tetPointRef tet() const
Return as tetrahedron reference.
const point & a() const noexcept
The first vertex.
tetPoints()=default
Default construct.
treeBoundBox bounds() const
The bounding box for the tetrahedron.
Point circumCentre() const
Return circum-centre.
barycentric pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
vector Sd() const
Face area normal for side d.
triPointRef tri(const label facei) const
Return i-th face.
scalar circumRadius() const
Return circum-radius.
Point centre() const
Return centre (centroid).
vector Sc() const
Face area normal for side c.
bool inside(const point &pt) const
Return true if point is inside tetrahedron.
vector Sb() const
Face area normal for side b.
tetrahedron(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Construct from four points.
const point & b() const noexcept
scalar mag() const
Return volume.
pointHit nearestPoint(const point &p) const
Return nearest point to p on tetrahedron. Is p itself.
Point randomPoint(Random &rndGen) const
Return a random point in the tetrahedron from a uniform distribution.
Pair< Point > box() const
The enclosing (bounding) box for the tetrahedron.
FixedList< tetPoints, 200 > tetIntersectionList
Storage type for tets originating from intersecting tets.
void sliceWithPlane(const plane &pl, AboveTetOp &aboveOp, BelowTetOp &belowOp) const
Decompose tet into tets above and below plane.
Point barycentricToPoint(const barycentric &bary) const
Calculate the point from the given barycentric coordinates.
treeBoundBox bounds() const
The bounding box for the tetrahedron.
scalar quality() const
Return quality: Ratio of tetrahedron and circum-sphere volume, scaled so that a regular tetrahedron h...
const point & c() const noexcept
const point & a() const noexcept
vector Sa() const
Face area normal for side a.
const Point & d() const noexcept
Return vertex d.
static Pair< Point > box(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
The enclosing (bounding) box for four points.
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
Standard boundBox with extra functionality for use in octree.
A triangle primitive used to calculate face normals and swept volumes. Uses referred 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 ...
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
pointHit nearestPoint(const point &p) const
Return nearest point to p on 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).
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
const volScalarField & p0
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
dimensionedScalar det(const dimensionedSphericalTensor &dt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
barycentric barycentric01(Random &rndGen)
Generate a random barycentric coordinate within the unit tetrahedron.
dimensionedScalar pos0(const dimensionedScalar &ds)
PointHit< point > pointHit
A PointHit with a 3D point.
dimensionedScalar pow3(const dimensionedScalar &ds)
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
vector point
Point is a vector.
triangle< point, const point & > triPointRef
A triangle using referred points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
#define forAll(list, i)
Loop across all elements in list.
tetIntersectionList & tets_
storeOp(tetIntersectionList &, label &)