34 void Foam::triangleFuncs::setIntersection
36 const point& oppositeSidePt,
37 const scalar oppositeSign,
39 const point& thisSidePt,
40 const scalar thisSign,
47 scalar denom = oppositeSign - thisSign;
56 pt = oppositeSidePt + oppositeSign/denom*(thisSidePt - oppositeSidePt);
61 void Foam::triangleFuncs::selectPt
91 const scalar maxLength,
100 label i1 = (i0 + 1) % 3;
101 label i2 = (i1 + 1) % 3;
111 scalar
det = v2*u1 - u2*v1;
117 if (localScale < vSmall ||
Foam::mag(det)/localScale < small)
125 const point& P = origin[originI];
127 scalar
u0 = P[i1] - V0[i1];
128 scalar v0 = P[i2] - V0[i2];
137 if ((beta >= 0) && (beta <= 1))
139 alpha = (v0 - beta*v2)/v1;
140 inter = ((alpha >= 0) && ((alpha + beta) <= 1));
145 beta = (v0*u1 - u0*v1)/det;
146 if ((beta >= 0) && (beta <= 1))
148 alpha = (u0 - beta*u2)/u1;
149 inter = ((alpha >= 0) && ((alpha + beta) <= 1));
155 pInter = V0 + alpha*V10 + beta*V20;
156 scalar
s = (pInter - origin[originI])[i0];
158 if ((s >= 0) && (s <= maxLength))
179 const vector p10 = p1 - p0;
180 const vector p20 = p2 - p0;
187 const point cube1(min.
x(), min.
y(), max.
z());
188 const point cube2(max.
x(), min.
y(), max.
z());
189 const point cube3(max.
x(), min.
y(), min.
z());
191 const point cube4(min.
x(), max.
y(), min.
z());
192 const point cube5(min.
x(), max.
y(), max.
z());
193 const point cube7(max.
x(), max.
y(), min.
z());
207 scalar maxSx = max.
x() - min.
x();
220 scalar maxSy = max.
y() - min.
y();
233 scalar maxSz = max.
z() - min.
z();
540 scalar magArea =
mag(na);
543 if (
mag(na & normal) > (1 - small))
549 const point va1 = va0 + va10;
550 const point va2 = va0 + va20;
553 scalar sign0 = (va0 - base) & normal;
554 scalar sign1 = (va1 - base) & normal;
555 scalar sign2 = (va2 - base) & normal;
557 label oppositeVertex = -1;
620 if (oppositeVertex == 0)
623 setIntersection(va0, sign0, va1, sign1, tol, pInter0);
624 setIntersection(va0, sign0, va2, sign2, tol, pInter1);
626 else if (oppositeVertex == 1)
629 setIntersection(va1, sign1, va0, sign0, tol, pInter0);
630 setIntersection(va1, sign1, va2, sign2, tol, pInter1);
635 setIntersection(va2, sign2, va0, sign0, tol, pInter0);
636 setIntersection(va2, sign2, va1, sign1, tol, pInter1);
667 if (!
intersect(va0, va10, va20, vb0, nb, planeB0, planeB1))
675 if (!
intersect(vb0, vb10, vb20, va0, na, planeA0, planeA1))
685 scalar coordB0 = planeB0 & intersection;
686 scalar coordB1 = planeB1 & intersection;
688 scalar coordA0 = planeA0 & intersection;
689 scalar coordA1 = planeA1 & intersection;
698 sortCoords[0] = coordB0;
702 sortCoords[1] = coordB1;
706 sortCoords[2] = coordA0;
710 sortCoords[3] = coordA1;
716 if (isFromB[indices[0]] == isFromB[indices[1]])
725 pInter0 = *pts[indices[1]];
726 pInter1 = *pts[indices[2]];
#define forAll(list, i)
Loop across all elements in list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void sort()
(stable) sort the list (if changed after construction time)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A list that is sorted upon construction or when explicitly requested with the sort() method...
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
static bool intersectBb(const point &p0, const point &p1, const point &p2, const treeBoundBox &cubeBb)
Does triangle intersect bounding box.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar det(const dimensionedSphericalTensor &dt)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
bool intersects(const point &overallStart, const vector &overallVec, const point &start, const point &end, point &pt, direction &ptBits) const
Intersects segment; set point to intersection position and face,.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
static bool intersect(const point &va0, const point &va10, const point &va20, const point &basePoint, const vector &normal, point &pInter0, point &pInter1)
Does triangle intersect plane. Return bool and set intersection segment.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
const point & max() const
Maximum point defining the bounding box.
vector point
Point is a vector.
Standard boundBox + extra functionality for use in octree.
dimensioned< scalar > mag(const dimensioned< Type > &)
const point & min() const
Minimum point defining the bounding box.
static bool intersectAxesBundle(const point &V0, const point &V10, const point &V20, const label i0, const pointField &origin, const scalar maxLength, point &pInter)
Intersect triangle with parallel edges aligned with axis i0.