75 template<
class Po
int,
class Po
intRef>
91 template<
class Po
int,
class Po
intRef>
104 template<
class Po
int,
class Po
intRef>
118 template<
class Po
int,
class Po
intRef>
144 template<
class Po
int,
class Po
intRef>
161 template<
class Po
int,
class Po
intRef>
174 template<
class Po
int,
class Po
intRef>
190 template<
class Po
int,
class Po
intRef>
217 <<
"Face index (" << facei <<
") out of range 0..3\n" 223 template<
class Po
int,
class Po
intRef>
230 template<
class Po
int,
class Po
intRef>
237 template<
class Po
int,
class Po
intRef>
244 template<
class Po
int,
class Po
intRef>
251 template<
class Po
int,
class Po
intRef>
254 return 0.25*(a_ + b_ + c_ + d_);
258 template<
class Po
int,
class Po
intRef>
261 return (1.0/6.0)*(((b_ - a_) ^ (c_ - a_)) & (d_ - a_));
265 template<
class Po
int,
class Po
intRef>
279 scalar denom = (
c & ba);
288 return a_ + 0.5*(a + num/denom);
292 template<
class Po
int,
class Po
intRef>
306 scalar denom = (
c & ba);
318 template<
class Po
int,
class Po
intRef>
331 template<
class Po
int,
class Po
intRef>
341 template<
class Po
int,
class Po
intRef>
347 return Point(bary.
a()*a_ + bary.
b()*b_ + bary.
c()*c_ + bary.
d()*d_);
351 template<
class Po
int,
class Po
intRef>
358 pointToBarycentric(pt, bary);
363 template<
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];
406 template<
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();
466 const triangle<Point, PointRef> tria(a_, b_, d_);
468 if (((
p - a_) & tria.areaNormal()) >= 0)
475 if (info.distance() < minOutsideDistance)
477 closestPt = info.point();
479 minOutsideDistance = info.distance();
486 const triangle<Point, PointRef> tria(a_, c_, b_);
488 if (((
p - a_) & tria.areaNormal()) >= 0)
495 if (info.distance() < minOutsideDistance)
497 closestPt = info.point();
499 minOutsideDistance = info.distance();
508 minOutsideDistance = 0;
521 template<
class Po
int,
class Po
intRef>
543 if (((
p - b_) & tria.unitNormal()) > SMALL)
551 const triangle<Point, PointRef> tria(a_, d_, c_);
553 if (((
p - a_) & tria.unitNormal()) > SMALL)
561 const triangle<Point, PointRef> tria(a_, b_, d_);
563 if (((
p - a_) & tria.unitNormal()) > SMALL)
571 const triangle<Point, PointRef> tria(a_, c_, b_);
573 if (((
p - a_) & tria.unitNormal()) > SMALL)
583 template<
class Po
int,
class Po
intRef>
591 template<
class Po
int,
class Po
intRef>
598 template<
class Po
int,
class Po
intRef>
604 vol_ += tet.tet().
mag();
608 template<
class Po
int,
class Po
intRef>
620 template<
class Po
int,
class Po
intRef>
626 tets_[nTets_++] = tet;
630 template<
class Po
int,
class Po
intRef>
640 (d[posI]*t[negI] - d[negI]*t[posI])
641 / (-d[negI]+d[posI]);
645 template<
class Po
int,
class Po
intRef>
646 template<
class TetOp>
649 const FixedList<point, 6>&
points,
659 template<
class Po
int,
class Po
intRef>
660 template<
class AboveTetOp,
class BelowTetOp>
664 const tetPoints& tet,
670 FixedList<scalar, 4> d;
674 d[i] = pln.signedDistance(tet[i]);
701 label i1 = d.fcIndex(i0);
702 label i2 = d.fcIndex(i1);
703 label i3 = d.fcIndex(i2);
705 point p01(planeIntersection(d, tet, i0, i1));
706 point p02(planeIntersection(d, tet, i0, i2));
707 point p03(planeIntersection(d, tet, i0, i3));
716 if (i0 == 0 || i0 == 2)
718 tetPoints t(tet[i0], p01, p02, p03);
724 FixedList<point, 6>
p 737 decomposePrism(
p, aboveOp);
741 tetPoints t(p01, p02, p03, tet[i0]);
747 FixedList<point, 6>
p 759 decomposePrism(
p, aboveOp);
786 const edge posEdge(
pos0, pos1);
788 if (posEdge == edge(0, 1))
790 point p02(planeIntersection(d, tet, 0, 2));
791 point p03(planeIntersection(d, tet, 0, 3));
792 point p12(planeIntersection(d, tet, 1, 2));
793 point p13(planeIntersection(d, tet, 1, 3));
796 FixedList<point, 6>
p 809 decomposePrism(
p, aboveOp);
812 FixedList<point, 6>
p 825 decomposePrism(
p, belowOp);
828 else if (posEdge == edge(1, 2))
830 point p01(planeIntersection(d, tet, 0, 1));
831 point p13(planeIntersection(d, tet, 1, 3));
832 point p02(planeIntersection(d, tet, 0, 2));
833 point p23(planeIntersection(d, tet, 2, 3));
836 FixedList<point, 6>
p 849 decomposePrism(
p, aboveOp);
852 FixedList<point, 6>
p 865 decomposePrism(
p, belowOp);
868 else if (posEdge == edge(2, 0))
870 point p01(planeIntersection(d, tet, 0, 1));
871 point p03(planeIntersection(d, tet, 0, 3));
872 point p12(planeIntersection(d, tet, 1, 2));
873 point p23(planeIntersection(d, tet, 2, 3));
876 FixedList<point, 6>
p 889 decomposePrism(
p, aboveOp);
892 FixedList<point, 6>
p 905 decomposePrism(
p, belowOp);
908 else if (posEdge == edge(0, 3))
910 point p01(planeIntersection(d, tet, 0, 1));
911 point p02(planeIntersection(d, tet, 0, 2));
912 point p13(planeIntersection(d, tet, 1, 3));
913 point p23(planeIntersection(d, tet, 2, 3));
916 FixedList<point, 6>
p 929 decomposePrism(
p, aboveOp);
932 FixedList<point, 6>
p 945 decomposePrism(
p, belowOp);
948 else if (posEdge == edge(1, 3))
950 point p01(planeIntersection(d, tet, 0, 1));
951 point p12(planeIntersection(d, tet, 1, 2));
952 point p03(planeIntersection(d, tet, 0, 3));
953 point p23(planeIntersection(d, tet, 2, 3));
956 FixedList<point, 6>
p 969 decomposePrism(
p, aboveOp);
972 FixedList<point, 6>
p 985 decomposePrism(
p, belowOp);
988 else if (posEdge == edge(2, 3))
990 point p02(planeIntersection(d, tet, 0, 2));
991 point p12(planeIntersection(d, tet, 1, 2));
992 point p03(planeIntersection(d, tet, 0, 3));
993 point p13(planeIntersection(d, tet, 1, 3));
996 FixedList<point, 6>
p 1009 decomposePrism(
p, aboveOp);
1012 FixedList<point, 6>
p 1025 decomposePrism(
p, belowOp);
1031 <<
"Missed edge:" << posEdge
1048 label i1 = d.fcIndex(i0);
1049 label i2 = d.fcIndex(i1);
1050 label i3 = d.fcIndex(i2);
1052 point p01(planeIntersection(d, tet, i0, i1));
1053 point p02(planeIntersection(d, tet, i0, i2));
1054 point p03(planeIntersection(d, tet, i0, i3));
1058 if (i0 == 0 || i0 == 2)
1060 tetPoints t(tet[i0], p01, p02, p03);
1066 FixedList<point, 6>
p 1079 decomposePrism(
p, belowOp);
1083 tetPoints t(p01, p02, p03, tet[i0]);
1089 FixedList<point, 6>
p 1102 decomposePrism(
p, belowOp);
1112 template<
class Po
int,
class Po
intRef>
1113 template<
class AboveTetOp,
class BelowTetOp>
1117 AboveTetOp& aboveOp,
1121 tetSliceWithPlane(pl, tetPoints(a_, b_, c_, d_), aboveOp, belowOp);
1127 template<
class Po
int,
class Po
intRef>
1131 tetrahedron<Point, PointRef>& t
1135 is >> t.a_ >> t.b_ >> t.c_ >> t.d_;
1136 is.readEnd(
"tetrahedron");
1144 template<
class Po
int,
class Po
intRef>
1148 const tetrahedron<Point, PointRef>& t
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
treeBoundBox bounds() const
The bounding box for the tetrahedron.
A triangle primitive used to calculate face normals and swept volumes. Uses referred points...
Pair< Point > box() const
The enclosing (bounding) box for the tetrahedron.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
barycentric barycentric01(Random &rndGen)
Generate a random barycentric coordinate within the unit tetrahedron.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
scalar circumRadius() const
Return circum-radius.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Point circumCentre() const
Return circum-centre.
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
tetrahedron(const Point &p0, const Point &p1, const Point &p2, const Point &p3)
Construct from four points.
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
tetPointRef tet() const
Return as tetrahedron reference.
vector Sd() const
Face area normal for side d.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
const point & a() const noexcept
The first vertex.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
constexpr char nl
The newline '\n' character (0x0a)
dimensionedScalar sqrt(const dimensionedScalar &ds)
storeOp(tetIntersectionList &, label &)
tetPoints()=default
Default construct.
Begin list [isseparator].
const point & c() const noexcept
The third vertex.
Barycentric< scalar > barycentric
A scalar version of the templated Barycentric.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
const Cmpt & b() const noexcept
Point barycentricToPoint(const barycentric &bary) const
Calculate the point from the given barycentric coordinates.
#define forAll(list, i)
Loop across all elements in list.
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
pointHit nearestPoint(const point &p) const
Return nearest point to p on triangle.
An ordered pair of two objects of type <T> with first() and second() elements.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
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 ...
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)
const Cmpt & c() const noexcept
scalar quality() const
Return quality: Ratio of tetrahedron and circum-sphere volume, scaled so that a regular tetrahedron h...
vector Sb() const
Face area normal for side b.
scalar mag() const
Return volume.
vector Sa() const
Face area normal for side a.
Describes the interaction of a object and a (templated) point. It carries the info of a successful hi...
Point centre() const
Return centre (centroid)
bool inside(const point &pt) const
Return true if point is inside tetrahedron.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Pair< point > box() const
The enclosing (bounding) box for the tetrahedron.
const Cmpt & d() const noexcept
An Ostream is an abstract base class for all output systems (streams, files, token lists...
dimensionedScalar pos0(const dimensionedScalar &ds)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
void sliceWithPlane(const plane &pl, AboveTetOp &aboveOp, BelowTetOp &belowOp) const
Decompose tet into tets above and below plane.
const point & b() const noexcept
The second vertex.
const dimensionedScalar mu
Atomic mass unit.
triPointRef tri(const label facei) const
Return i-th face.
dimensionedScalar pow3(const dimensionedScalar &ds)
barycentric pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
vector point
Point is a vector.
Tet point storage. Default constructable (tetrahedron is not)
const dimensionedScalar c
Speed of light in a vacuum.
scalar distance() const noexcept
Return distance to hit.
pointHit nearestPoint(const point &p) const
Return nearest point to p on tetrahedron. Is p itself.
triangle< point, const point & > triPointRef
A triangle using referred points.
treeBoundBox bounds() const
The bounding box for the tetrahedron.
const point_type & point() const noexcept
Return the point, no checks.
Standard boundBox with extra functionality for use in octree.
Point randomPoint(Random &rndGen) const
Return a random point in the tetrahedron from a uniform distribution.
const Cmpt & a() const noexcept
vector Sc() const
Face area normal for side c.
Tensor of scalars, i.e. Tensor<scalar>.
const point & d() const noexcept
The fourth vertex.
void flip()
Invert tetrahedron by swapping third and fourth vertices.
const volScalarField & p0
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
PointHit< point > pointHit
A PointHit with a 3D point.
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.