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 const label i1 = (i0 + 1) % 3;
101 const label i2 = (i1 + 1) % 3;
103 const scalar u1 = V10[i1];
104 const scalar v1 = V10[i2];
106 const scalar u2 = V20[i1];
107 const scalar v2 = V20[i2];
109 const scalar localScale =
mag(u1) +
mag(v1) +
mag(u2) +
mag(v2);
111 const scalar
det = v2*u1 - u2*v1;
117 if (localScale < vSmall ||
Foam::mag(
det)/localScale < small)
125 const point& P = origin[originI];
127 const scalar
u0 = P[i1] - V0[i1];
128 const scalar v0 = P[i2] - V0[i2];
134 if (
mag(u1) < rootVSmall)
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))
149 inter = ((
alpha >= 0) && ((
alpha + beta) <= 1));
155 pInter = V0 +
alpha*V10 + beta*V20;
156 const scalar
s = pInter[i0] - P[i0];
158 if ((
s >= 0) && (
s <= maxLength))
180 const vector p10 = p1 - p0;
181 const vector p20 = p2 - p0;
208 scalar maxSx =
max.x() -
min.x();
210 if (intersectAxesBundle(p0, p10, p20, 0, origin, maxSx, pInter))
221 scalar maxSy =
max.y() -
min.y();
223 if (intersectAxesBundle(p0, p10, p20, 1, origin, maxSy, pInter))
234 scalar maxSz =
max.z() -
min.z();
236 if (intersectAxesBundle(p0, p10, p20, 2, origin, maxSz, pInter))
541 scalar magArea =
mag(na);
544 if (
mag(na & normal) > (1 - small))
550 const point va1 = va0 + va10;
551 const point va2 = va0 + va20;
554 scalar sign0 = (va0 - base) & normal;
555 scalar sign1 = (va1 - base) & normal;
556 scalar sign2 = (va2 - base) & normal;
558 label oppositeVertex = -1;
621 if (oppositeVertex == 0)
624 setIntersection(va0, sign0, va1, sign1, tol, pInter0);
625 setIntersection(va0, sign0, va2, sign2, tol, pInter1);
627 else if (oppositeVertex == 1)
630 setIntersection(va1, sign1, va0, sign0, tol, pInter0);
631 setIntersection(va1, sign1, va2, sign2, tol, pInter1);
636 setIntersection(va2, sign2, va0, sign0, tol, pInter0);
637 setIntersection(va2, sign2, va1, sign1, tol, pInter1);
668 if (!intersect(va0, va10, va20, vb0, nb, planeB0, planeB1))
676 if (!intersect(vb0, vb10, vb20, va0, na, planeA0, planeA1))
699 sortCoords[0] = coordB0;
703 sortCoords[1] = coordB1;
707 sortCoords[2] = coordA0;
711 sortCoords[3] = coordA1;
717 if (isFromB[indices[0]] == isFromB[indices[1]])
726 pInter0 = *pts[indices[1]];
727 pInter1 = *pts[indices[2]];
#define forAll(list, i)
Loop across all elements in list.
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.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void sort()
(stable) sort the list (if changed after construction time)
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
Standard boundBox + extra functionality for use in octree.
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,.
static bool intersectBb(const point &p0, const point &p1, const point &p2, const treeBoundBox &cubeBb)
Does triangle intersect bounding box.
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.
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.
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
dimensionedScalar det(const dimensionedSphericalTensor &dt)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
vector point
Point is a vector.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)