38 namespace triIntersect
60 return bStar == 0 ? 0 :
max(a*
sign(b), 0)/bStar;
66 Ostream& operator<<(Ostream& os, const FixedList<FixedList<Type, 3>, 3>& l)
92 if (groups[i] ==
group)
106 if (groups[i] ==
group)
108 y[i] =
min(
max(x[i], 0), 1);
117 if (groups[i] ==
group)
126 if (groups[i] ==
group)
130 phi =
max(phi, n*x[i]/(n*x[i] - 1));
136 phi =
max(phi, n*xn/(n*xn - 1));
141 if (groups[i] ==
group)
143 y[i] =
min(
max((1 - phi)*x[i] + phi/n, 0), 1);
167 const vector CCtt = C + Ct*t;
168 const vector CuCtut = Cu + Ctu*t;
169 const vector CvCtvt = Cv + Ctv*t;
173 CuCtut & CuCtut, CuCtut & CvCtvt,
174 CvCtvt & CuCtut, CvCtvt & CvCtvt
182 const scalar detA =
det(A);
214 ((C ^ Ctu) & Ctv) + ((Ct ^ Cu) & Ctv) + ((Ct ^ Ctu) & Cv),
215 ((C ^ Cu) & Ctv) + ((C ^ Ctu) & Cv) + ((Ct ^ Cu) & Cv),
241 tuvs[nTuvs ++] = tuv;
246 for (
label i = 0; i < nTuvs; ++ i)
248 const vector tuvOld = tuvs[i];
254 for (
label i = 0; i < nTuvs - 1; ++ i)
256 for (
label j = 0; j < nTuvs - 1; ++ j)
258 if (tuvClippage[j] > tuvClippage[j + 1])
260 Swap(tuvs[j], tuvs[j + 1]);
261 Swap(tuvClippage[j], tuvClippage[j + 1]);
268 for (
label i = 0; i < nTuvs; ++ i)
270 const scalar t = tuvs[i].x(), u = tuvs[i].y(), v = tuvs[i].z();
272 const scalar magSqrF =
273 magSqr(C + Ct*t + Cu*u + Cv*v + Ctu*t*u + Ctv*t*v);
274 const scalar magSqrErrF =
285 if (magSqrF < magSqrErrF)
309 const triPointRef tgtTri(tgtPs[0], tgtPs[1], tgtPs[2]);
316 srcFwd[srcPi] = (srcNs[srcPi] & tgtN) < maxDot;
327 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
333 {tgtPs[tgtPi0], tgtPs[tgtPi1]},
336 srcInTgtEdge[srcPi][tgtEi] = o > 0 ? +1 : -1;
347 srcInTgtEdge[srcPi] = {-1, -1, -1};
379 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
381 if (srcFwd[srcPi0] != srcFwd[srcPi1])
388 maxDot - (srcNs[srcPi0] & tgtN),
389 (srcNs[srcPi1] - srcNs[srcPi0]) & tgtN
391 const point srcP = (1 - srcT)*srcPs[srcPi0] + srcT*srcPs[srcPi1];
392 const vector srcN = (1 - srcT)*srcNs[srcPi0] + srcT*srcNs[srcPi1];
396 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
402 {tgtPs[tgtPi0], tgtPs[tgtPi1]},
405 srcInTgtEdge[srcFwd[srcPi0] ? srcPi1 : srcPi0][tgtEi] =
414 srcInTgtTri[srcPi] =
count(srcInTgtEdge[srcPi], 1) == 3 ? +1 : -1;
432 const triPointRef tgtTri(tgtPs[0], tgtPs[1], tgtPs[2]);
441 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
445 {srcPs[srcPi0], srcPs[srcPi1]},
446 {srcNs[srcPi0], srcNs[srcPi1]},
450 tgtInSrcEdge[tgtPi][srcEi] = o > 0 ? +1 : -1;
457 tgtInSrcTri[tgtPi] =
count(tgtInSrcEdge[tgtPi], 1) == 3 ? +1 : -1;
463 if (tgtInSrcTri[tgtPi] == 1)
468 const bool tgtFwd = (srcN & tgtN) < maxDot;
469 tgtInSrcTri[tgtPi] = tgtFwd ? +1 : -1;
484 forAll(thisOtherPis, thisPi)
486 const label otherPi = thisOtherPis[thisPi];
490 const label otherEi0 = (otherPi + 2) % 3, otherEi1 = otherPi;
492 thisInOtherTri[thisPi] = 0;
494 thisInOtherEdge[thisPi][otherEi0] = 0;
495 thisInOtherEdge[thisPi][otherEi1] = 0;
513 order[nVisited ++] = i0;
569 auto branch = [&](
const bool isSrcEdge)
590 && (branch(
true) || branch(
false))
602 order[-- nVisited] = -1;
621 srcPointNormals.
resize(pointLocations.
size());
624 forAll(pointLocations, pointi)
626 const location& l = pointLocations[pointi];
634 srcPoints[pointi] = srcP;
635 srcPointNormals[pointi] = srcN;
636 tgtPoints[pointi] = tgtP;
645 srcPoints[pointi] = srcP;
646 srcPointNormals[pointi] = srcN;
657 tgtPoints[pointi] = tgtP;
661 const label srcPi0 = l.
srcEdgei(), srcPi1 = (srcPi0 + 1) % 3;
662 const label tgtPi0 = l.
tgtEdgei(), tgtPi1 = (tgtPi0 + 1) % 3;
667 {srcPs[srcPi0], srcPs[srcPi1]},
668 {srcNs[srcPi0], srcNs[srcPi1]},
669 {tgtPs[tgtPi0], tgtPs[tgtPi1]}
671 const scalar srcT = ts.
first(), tgtT = ts.
second();
674 (1 - srcT)*srcPs[srcPi0] + srcT*srcPs[srcPi1];
675 srcPointNormals[pointi] =
676 (1 - srcT)*srcNs[srcPi0] + srcT*srcNs[srcPi1];
678 (1 - tgtT)*tgtPs[tgtPi0] + tgtT*tgtPs[tgtPi1];
699 scalar lengthScale = 0;
700 for (
label i = 0; i < 3; ++ i)
702 lengthScale =
max(lengthScale,
mag(srcPs[i] - srcPs[(i + 1) % 3]));
705 const label nu = nEdge, nv = nNormal;
706 const scalar
u0 = 0, u1 = 1;
707 const scalar v0 = -lNormal/2*lengthScale, v1 = lNormal/2*lengthScale;
710 for (
label i = 0; i < 3; ++ i)
712 const point& p0 = srcPs[i], p1 = srcPs[(i + 1) % 3];
713 const vector& n0 = srcNs[i], n1 = srcNs[(i + 1) % 3];
715 for (
label iu = 0; iu <= nu; ++ iu)
717 const scalar u = u0 + (u1 -
u0)*scalar(iu)/nu;
718 for (
label iv = 0; iv <= nv; ++ iv)
720 const scalar v = v0 + (v1 - v0)*scalar(iv)/nv;
721 const vector x = p0 + (p1 - p0)*u + (n0 + (n1 - n0)*u)*v;
722 ps[i*(nu + 1)*(nv + 1) + iu*(nv + 1) + iv] = x;
728 for (
label i = 0; i < 3; ++ i)
730 for (
label iu = 0; iu < nu; ++ iu)
732 for (
label iv = 0; iv < nv; ++ iv)
734 fs[i*nu*nv + iu*nv + iv] =
737 i*(nu + 1)*(nv + 1) + (nv + 1)*iu + iv,
738 i*(nu + 1)*(nv + 1) + (nv + 1)*iu + iv + 1,
739 i*(nu + 1)*(nv + 1) + (nv + 1)*(iu + 1) + iv + 1,
740 i*(nu + 1)*(nv + 1) + (nv + 1)*(iu + 1) + iv
767 const tensor A(srcPs[1] - srcPs[0], srcNs[0], srcNs[1]);
768 const scalar detA =
det(A);
772 const vector detAY =
T & (tgtP - srcPs[0]);
775 const scalar offset = Yx*detAY.y() - (1 - Yx)*detAY.z();
777 return offset == 0 ? - vSmall : offset;
786 const bool srcDirection
807 const tensor A(srcN, tgtPs[1] - tgtPs[0], srcN^(tgtPs[1] - tgtPs[0]));
808 const scalar detA =
det(A);
812 const vector detAY =
T & (tgtPs[0] - srcP);
816 return offset == 0 ? - vSmall : offset;
825 const bool tgtDirection
860 if (solution.
first())
863 srcT = solution.
second().x();
864 tgtT = solution.
second().y();
919 scalar tgtT0 = 0, tgtT1 = 1;
924 const scalar
s = o0 > o1 ? +1 : -1;
928 const scalar tgtT = (tgtT0 + tgtT1)/2;
929 const vector tgtP = (1 - tgtT)*tgtPs[0] + tgtT*tgtPs[1];
943 tgtT = (tgtT0 + tgtT1)/2;
946 const vector srcDP = srcPs[1] - srcPs[0];
947 const vector tgtP = (1 - tgtT)*tgtPs[0] + tgtT*tgtPs[1];
949 const tensor A(srcDP, srcNs[0], srcNs[1]);
950 const scalar detA =
det(A);
954 const scalar magDetAYx =
sign(detA)*(Tx & (tgtP - srcPs[0]));
958 const vector srcN = (1 - srcTStar)*srcNs[0] + srcTStar*srcNs[1];
960 const vector srcDPPerpN = srcDP - (srcDP & srcN)*srcN;
965 (tgtP - srcPs[0]) & srcDPPerpN,
1000 const scalar srcT0 = 1 - srcTs.x() - srcTs.y();
1001 return srcT0*srcPNs[0] + srcTs.x()*srcPNs[1] + srcTs.y()*srcPNs[2];
1004 auto srcEdgePNs = [srcPN]
1011 return Pair<vector>(srcPN(srcPNs, srcTs0), srcPN(srcPNs, srcTs1));
1018 srcEdgePNs(srcPs, srcTs0, srcTs1),
1019 srcEdgePNs(srcNs, srcTs0, srcTs1),
1030 if (offsets[
findMin(offsets)] >= 0 || offsets[
findMax(offsets)] <= 0)
1040 srcPs[1] - srcPs[0],
1041 srcPs[2] - srcPs[0],
1042 srcNs[1] - srcNs[0],
1043 srcNs[2] - srcNs[0],
1046 if (solution.
first())
1049 srcT = solution.
second().y();
1050 srcU = solution.
second().z();
1056 const scalar
sign = offsets[
findMin(offsets)] > 0 ? +1 : -1;
1058 vector2D srcTsA(0, 0), srcTsB(1, 0), srcTsC(0, 1);
1062 const vector2D srcTsAB = (srcTsA + srcTsB)/2;
1063 const vector2D srcTsBC = (srcTsB + srcTsC)/2;
1064 const vector2D srcTsCA = (srcTsC + srcTsA)/2;
1066 const scalar oA = sign*offset(srcTsCA, srcTsAB);
1067 const scalar oB = sign*offset(srcTsAB, srcTsBC);
1068 const scalar oC = sign*offset(srcTsBC, srcTsCA);
1072 if (offsets[offsetMini] > 0)
1078 else if (offsetMini == 0)
1083 else if (offsetMini == 1)
1088 else if (offsetMini == 2)
1095 srcT = (srcTsA[0] + srcTsB[0] + srcTsC[0])/3;
1096 srcU = (srcTsA[1] + srcTsB[1] + srcTsC[1])/3;
1105 const label srcEi0 = (srcEi + 2) % 3, srcEi1 = (srcEi + 1) % 3;
1110 && offsets[srcEi0] >= 0
1111 && offsets[srcEi1] >= 0
1114 const label srcPi0 = srcEi, srcPi1 = (srcEi + 1) % 3;
1115 const label srcPiOpp = (srcEi + 2) % 3;
1123 srcPs[srcPi0] - tgtP,
1124 srcPs[srcPi1] - srcPs[srcPi0],
1125 srcPs[srcPi0] - srcPs[srcPiOpp],
1127 srcPs[srcPi1] - srcPs[srcPi0],
1128 srcNs[srcPi1] - srcNs[srcPi0],
1131 if (solution.
first())
1134 srcT = solution.
second().x();
1135 srcU = solution.
second().y();
1141 const vector2D srcTsOpp(srcPiOpp == 1, srcPiOpp == 2);
1142 const vector2D srcTs0(srcPi0 == 1, srcPi0 == 2);
1143 const vector2D srcTs1(srcPi1 == 1, srcPi1 == 2);
1145 scalar srcT0 = 0, srcT1 = 1;
1149 const scalar srcT = (srcT0 + srcT1)/2;
1150 const vector2D srcTs01(srcTs0*(1 - srcT) + srcTs1*srcT);
1152 const scalar o = offset(srcTsOpp, srcTs01);
1164 srcT = (srcT0 + srcT1)/2;
1168 srcPs[srcPi0] - tgtP,
1169 srcPs[srcPi1] - srcPs[srcPi0],
1170 srcPs[srcPi0] - srcPs[srcPiOpp],
1172 srcPs[srcPi1] - srcPs[srcPi0],
1173 srcNs[srcPi1] - srcNs[srcPi0],
1181 y[srcPiOpp] = - srcU;
1182 y[srcPi0] = (1 + srcU)*(1 - srcT);
1183 y[srcPi1] = (1 + srcU)*srcT;
1191 const label srcEiOpp = (srcPi + 1) % 3;
1192 const label srcEi0 = (srcPi + 2) % 3, srcEi1 = srcPi;
1196 offsets[srcEiOpp] >= 0
1197 && offsets[srcEi0] <= 0
1198 && offsets[srcEi1] <= 0
1202 const label srcPi0 = (srcPi + 2) % 3, srcPi1 = (srcPi + 1) % 3;
1206 srcPs[srcPi] - srcPs[srcPi0],
1207 srcPs[srcPi] - srcPs[srcPi1],
1211 const scalar detA = A.
x() &
T0;
1222 y[srcPi] = 1 + srcT + srcU;
1229 <<
"Point " << tgtP <<
" could not be classified within triangle " 1230 << srcPs <<
" with projection normals " << srcNs <<
exit(
FatalError);
1242 const tensor A(tgtPs[1] - tgtPs[0], tgtPs[2] - tgtPs[0], - srcN);
1243 const scalar detA =
det(A);
1248 const vector detAY = (T & (srcP - tgtPs[0])) +
vector(detA, 0, 0);
1253 maxMagDetAY/vGreat <
mag(detA)
1255 : detAY/maxMagDetAY*vGreat;
1275 const word& writePrefix
1296 srcInTgt(srcPs, srcNs, srcOwns, tgtPs, tgtOwns, srcInTgtEdge, srcInTgtTri);
1297 thisIsOther(srcTgtPis, srcInTgtEdge, srcInTgtTri);
1298 tgtInSrc(srcPs, srcNs, srcOwns, tgtPs, tgtOwns, tgtInSrcEdge, tgtInSrcTri);
1299 thisIsOther(tgtSrcPis, tgtInSrcEdge, tgtInSrcTri);
1303 if (
count(srcTgtPis, -1) != 3)
1308 <<
indent <<
"srcInTgtEdge=" << srcInTgtEdge <<
endl;
1309 if (
count(tgtSrcPis, -1) != 3)
1313 Info<<
indent <<
"tgtInSrcTri=" << tgtInSrcTri << endl
1314 <<
indent <<
"tgtInSrcEdge=" << tgtInSrcEdge <<
endl;
1318 bool noIntersection =
false;
1324 bool outside =
true;
1327 if (tgtInSrcEdge[tgtPi][srcEi] == 1)
1335 noIntersection =
true;
1343 if (
count(srcInTgtEdge, {-1, -1, -1}) == 3)
1345 noIntersection =
true;
1350 if (!noIntersection)
1355 auto addPointLocations = [&pointLocations]
1359 const bool add = true
1362 if (!pointLocations.
empty())
1368 const label srcEi0 =
1372 const label tgtEi0 =
1377 const label srcEi1 =
1381 const label tgtEi1 =
1394 label srcEj = srcEi0;
1396 srcEj = (srcEj + 2) % 3
1407 pointLocations.
append(l1);
1411 pointLocations.
append(l2);
1416 auto inTriToOut = [&addPointLocations,&srcInTgtEdge]
1419 const label tgtOutSrcEi1,
1420 const label tgtOutSrcPi1,
1427 : srcInTgtEdge[tgtOutSrcPi1][tgtEi] == 1
1428 ? (tgtOutSrcPi1 + 2*
reverse) % 3
1429 : (tgtOutSrcPi1 + 2*!
reverse) % 3;
1438 auto isPointToOutEdge = [&addPointLocations,&srcInTgtEdge]
1441 const label tgtIsSrcPi0,
1442 const label tgtOutSrcEi1,
1446 const label srcEi0Next = (tgtIsSrcPi0 + 2*
reverse) % 3;
1447 const label srcEi0Opp = (tgtIsSrcPi0 + 1) % 3;
1451 srcInTgtEdge[(tgtIsSrcPi0 + 1) % 3][tgtEi] == -1
1452 && srcInTgtEdge[(tgtIsSrcPi0 + 2) % 3][tgtEi] == -1
1458 if (tgtOutSrcEi1 == srcEi0Next)
1463 if (tgtOutSrcEi1 == srcEi0Opp)
1473 auto isPointToOutCorner = []
1476 const label tgtIsSrcPi0,
1477 const label tgtOutSrcPi1,
1481 return tgtOutSrcPi1 != (tgtIsSrcPi0 + 1 +
reverse) % 3;
1485 auto outEdgeToOutEdge = [&addPointLocations,&srcInTgtEdge]
1488 const label tgtOutSrcEi0,
1489 const label tgtOutSrcEi1
1492 const label srcPi = (5 - tgtOutSrcEi0 - tgtOutSrcEi1) % 3;
1496 (tgtOutSrcEi0 != (tgtOutSrcEi1 + 1) % 3)
1497 && (srcInTgtEdge[srcPi][tgtEi] != 1)
1505 (tgtOutSrcEi0 == (tgtOutSrcEi1 + 1) % 3)
1506 != (srcInTgtEdge[srcPi][tgtEi] == 1)
1521 auto outEdgeToOutCorner = [&addPointLocations,&srcInTgtEdge]
1524 const label tgtOutSrcEi0,
1525 const label tgtOutSrcPi1,
1529 if (tgtOutSrcEi0 != (tgtOutSrcPi1 + 1) % 3)
1534 const label srcPi1Prev = (tgtOutSrcPi1 + 1 + !
reverse) % 3;
1536 if (srcInTgtEdge[srcPi1Prev][tgtEi] == -1)
1541 const label srcPi1Next = (tgtOutSrcPi1 + 1 +
reverse) % 3;
1543 if (srcInTgtEdge[srcPi1Next][tgtEi] == 1)
1551 srcInTgtEdge[tgtOutSrcPi1][tgtEi] == 1
1552 ? (tgtOutSrcPi1 + 2*
reverse) % 3
1553 : (tgtOutSrcPi1 + 2*!
reverse) % 3;
1562 addPointLocations(l1, l2);
1568 auto outCornerToOutCorner = []
1571 const label tgtOutSrcPi0,
1572 const label tgtOutSrcPi1
1575 return tgtOutSrcPi0 != (tgtOutSrcPi1 + 2) % 3;
1581 const label tgtPi0 = tgtEi, tgtPi1 = (tgtEi + 1) % 3;
1583 const bool tgtInSrcTri0 = tgtInSrcTri[tgtPi0] == 1;
1584 const bool tgtInSrcTri1 = tgtInSrcTri[tgtPi1] == 1;
1586 const label tgtIsSrcPi0 =
1587 tgtInSrcTri[tgtPi0] == 0 ? tgtSrcPis[tgtPi0] : -1;
1588 const label tgtIsSrcPi1 =
1589 tgtInSrcTri[tgtPi1] == 0 ? tgtSrcPis[tgtPi1] : -1;
1591 const label tgtOutSrcEi0 =
1592 count(tgtInSrcEdge[tgtPi0], -1) == 1
1595 const label tgtOutSrcEi1 =
1596 count(tgtInSrcEdge[tgtPi1], -1) == 1
1600 const label tgtOutSrcPi0 =
1601 count(tgtInSrcEdge[tgtPi0], -1) == 2
1602 ? (
findIndex(tgtInSrcEdge[tgtPi0], 1) + 2) % 3
1604 const label tgtOutSrcPi1 =
1605 count(tgtInSrcEdge[tgtPi1], -1) == 2
1606 ? (
findIndex(tgtInSrcEdge[tgtPi1], 1) + 2) % 3
1614 if (tgtIsSrcPi0 != -1)
1622 (tgtInSrcTri0 && tgtInSrcTri1)
1623 || (tgtOutSrcEi0 != -1 && tgtOutSrcEi0 == tgtOutSrcEi1)
1624 || (tgtOutSrcPi0 != -1 && tgtOutSrcPi0 == tgtOutSrcPi1)
1632 (tgtInSrcTri0 && tgtIsSrcPi1 != -1)
1633 || (tgtIsSrcPi0 != -1 && tgtInSrcTri1)
1639 else if (tgtInSrcTri0 && (tgtOutSrcEi1 != -1 || tgtOutSrcPi1 != -1))
1643 if (!inTriToOut(tgtEi, tgtOutSrcEi1, tgtOutSrcPi1, 0))
1645 pointLocations.
clear();
1649 else if ((tgtOutSrcEi0 != -1 || tgtOutSrcPi0 != -1) && tgtInSrcTri1)
1652 if (!inTriToOut(tgtEi, tgtOutSrcEi0, tgtOutSrcPi0, 1))
1654 pointLocations.
clear();
1658 else if (tgtIsSrcPi0 != -1 && tgtIsSrcPi1 != -1)
1662 if (tgtIsSrcPi0 != (tgtIsSrcPi1 + 1) % 3)
1664 pointLocations.
clear();
1668 else if (tgtIsSrcPi0 != -1 && tgtOutSrcEi1 != -1)
1672 if (!isPointToOutEdge(tgtEi, tgtIsSrcPi0, tgtOutSrcEi1, 0))
1674 pointLocations.
clear();
1678 else if (tgtOutSrcEi0 != -1 && tgtIsSrcPi1 != -1)
1681 if (!isPointToOutEdge(tgtEi, tgtIsSrcPi1, tgtOutSrcEi0, 1))
1683 pointLocations.
clear();
1687 else if (tgtIsSrcPi0 != -1 && tgtOutSrcPi1 != -1)
1691 if (!isPointToOutCorner(tgtEi, tgtIsSrcPi0, tgtOutSrcPi1, 0))
1693 pointLocations.
clear();
1697 else if (tgtOutSrcPi0 != -1 && tgtIsSrcPi1 != -1)
1700 if (!isPointToOutCorner(tgtEi, tgtIsSrcPi1, tgtOutSrcPi0, 1))
1702 pointLocations.
clear();
1706 else if (tgtOutSrcEi0 != -1 && tgtOutSrcEi1 != -1)
1709 if (!outEdgeToOutEdge(tgtEi, tgtOutSrcEi0, tgtOutSrcEi1))
1711 pointLocations.
clear();
1715 else if (tgtOutSrcEi0 != -1 && tgtOutSrcPi1 != -1)
1719 if (!outEdgeToOutCorner(tgtEi, tgtOutSrcEi0, tgtOutSrcPi1, 0))
1721 pointLocations.
clear();
1725 else if (tgtOutSrcPi0 != -1 && tgtOutSrcEi1 != -1)
1728 if (!outEdgeToOutCorner(tgtEi, tgtOutSrcEi1, tgtOutSrcPi0, 1))
1730 pointLocations.
clear();
1734 else if (tgtOutSrcPi0 != -1 && tgtOutSrcPi1 != -1)
1737 if (!outCornerToOutCorner(tgtEi, tgtOutSrcPi0, tgtOutSrcPi1))
1739 pointLocations.
clear();
1747 pointLocations.
clear();
1753 if (!pointLocations.
empty())
1759 addPointLocations(l,
location(),
false);
1773 if (pointLocations.
empty() &&
count(srcInTgtTri, 1) == 3)
void generateGeometryForLocations(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< point, 3 > &tgtPs, DynamicList< point > &srcPoints, DynamicList< vector > &srcPointNormals, DynamicList< point > &tgtPoints, const DynamicList< location > &pointLocations)
const char *const group
Group name for atomic constants.
dimensionedScalar sign(const dimensionedScalar &ds)
List< labelList > labelListList
A List of labelList.
barycentric2D srcTriTgtPointIntersection(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const point &tgtP)
Calculate the intersection of a target point with a source triangle's.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Pair< scalar > srcEdgeTgtEdgeIntersection(const Pair< point > &srcPs, const Pair< vector > &srcNs, const Pair< point > &tgtPs)
Calculate the intersection of a target edge with a source edge's.
bool isTgtNotSrcPoint() const
Return whether the location is a target point and not a source.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
A triangle primitive used to calculate face areas and swept volumes.
void srcInTgt(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns, FixedList< FixedList< label, 3 >, 3 > &srcInTgtEdge, FixedList< label, 3 > &srcInTgtTri)
Calculate whether the points of the given source triangle project inside or.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Ostream & indent(Ostream &os)
Indent stream.
bool isIntersection() const
Return whether the location is an intersection.
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
void resize(const label)
Alter the addressed list size.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label log2(label i)
Return the log base 2 by successive bit-shifting of the given label.
A 2-tuple for storing two objects of different types.
const Type1 & first() const
Return first.
void size(const label)
Override size to be inconsistent with allocated storage.
Vector2D< scalar > vector2D
vector2D obtained from generic Vector2D
bool isSrcPoint() const
Return whether the location is a source point.
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Ostream & endl(Ostream &os)
Add newline and flush stream.
label count(const ListType &l, typename ListType::const_reference x)
Count the number of occurrences of a value in a list.
scalar srcEdgeTgtPointOffset(const Pair< point > &srcPs, const Pair< vector > &srcNs, const point &tgtP)
Calculate the signed offset of a target point in relation to a projected.
static location tgtPoint(const label tgtPi)
Construct a target point location.
label findMin(const ListType &, const label start=0)
Find index of min element (and less than given element).
Templated storage for the roots of polynomial equations, plus flags to indicate the nature of the roo...
Vector< scalar > vector
A scalar version of the templated Vector.
static location srcPoint(const label srcPi)
Construct a source point location.
bool isSrcNotTgtPoint() const
Return whether the location is a source point and not a target.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
static location srcTgtPoint(const label srcPi, const label tgtPi)
Construct a source and target point location.
bool isTgtPoint() const
Return whether the location is a target point.
T & first()
Return the first element of the list.
vector clipped01(const vector x, const FixedList< label, 3 > groups)
Clip the given vector between values of 0 and 1, and also clip one minus.
Tuple2< bool, vector > solveProjection(const vector &C, const vector &Ct, const vector &Cu, const vector &Cv, const vector &Ctu, const vector &Ctv, const FixedList< label, 3 > groups)
Solve a projection equation.
Templated 2D tensor derived from VectorSpace adding construction from 4 components, element access using xx(), xy(), yx() and yy() member functions and the iner-product (dot-product) and outer-product of two Vector2Ds (tensor-product) operators.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
void intersectTris(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< label, 3 > &srcTgtPis, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns, const FixedList< label, 3 > &tgtSrcPis, DynamicList< point > &srcPoints, DynamicList< vector > &srcPointNormals, DynamicList< point > &tgtPoints, DynamicList< location > &pointLocations, const bool debug, const word &writePrefix=word::null)
Construct the intersection of a source triangle's projected volume and a.
label tgtPointi() const
Return the target point index.
Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of which is redundant...
void inplaceReverseList(ListType &list)
Inplace reversal of a list using Swap.
label srcPointi() const
Return the source point index.
Cubic equation of the form a*x^3 + b*x^2 + c*x + d = 0.
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))
dimensionedScalar cos(const dimensionedScalar &ds)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void thisIsOther(const FixedList< label, 3 > &thisOtherPis, FixedList< FixedList< label, 3 >, 3 > &thisInOtherEdge, FixedList< label, 3 > &thisInOtherTri)
Override results of the srcInTgt/tgtInSrc calculations with explicit.
void tgtInSrc(const FixedList< point, 3 > &srcPs, const FixedList< vector, 3 > &srcNs, const FixedList< bool, 3 > &srcOwns, const FixedList< point, 3 > &tgtPs, const FixedList< bool, 3 > &tgtOwns, FixedList< FixedList< label, 3 >, 3 > &tgtInSrcEdge, FixedList< label, 3 > &tgtInSrcTri)
Calculate whether the points of the given target triangle project inside or.
A class for handling words, derived from string.
void writeTriProjection(const word &name, const FixedList< point, 3 > &srcTriPs, const FixedList< vector, 3 > &srcTriNs, const label nEdge=20, const label nNormal=20, const scalar lNormal=0.5)
Write a VTK file of a triangle projection.
scalar srcPointTgtEdgeOffset(const point &srcP, const vector &srcN, const Pair< point > &tgtPs)
Calculate the signed offset of a projected source point in relation to a.
dimensionSet cmptMag(const dimensionSet &)
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
static const word null
An empty word.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
List< label > labelList
A List of labels.
vector solveProjectionGivenT(const vector &C, const vector &Ct, const vector &Cu, const vector &Cv, const vector &Ctu, const vector &Ctv, const FixedList< label, 3 > groups, const scalar t)
Solve a projection equation given a value of the t variable.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
vector normal() const
Return unit normal.
scalar protectedDivideAndClip01(const scalar a, const scalar b)
Divide two numbers, protect the result from overflowing, and clip the.
Type tgtTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcPointTgtTriIntersection to interpolate.
label findMax(const ListType &, const label start=0)
Find index of max element (and larger than given element).
Templated 3D Vector derived from VectorSpace adding construction from 3 components, element access using x(), y() and z() member functions and the inner-product (dot-product) and cross product operators.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
void reverse(UList< T > &, const label n)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
void write(const fileName &file, const word &title, const bool binary, const PointField &points, const VertexList &vertices, const LineList &lines, const FaceList &faces, const wordList &fieldNames, const boolList &fieldIsPointValues, const UPtrList< const Field< label >> &fieldLabelValues #define FieldTypeValuesConstArg(Type, nullArg))
Write VTK polygonal data to a file. Takes a PtrList of fields of labels and.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const Type & second() const
Return second.
Roots< 3 > roots() const
Get the roots.
bool isSrcAndTgtPoint() const
Return whether the location is a source point and a target point.
scalar protectedDivide(const scalar a, const scalar b)
Divide two numbers and protect the result from overflowing.
Type srcTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcTriTgtPointIntersection to interpolate.
barycentric2D srcPointTgtTriIntersection(const point &srcP, const vector &srcN, const FixedList< point, 3 > &tgtPs)
Calculate the intersection of a projected source point with a target.
bool orderLocations(const UList< location > &locations, bool isSrcEdge, const label i0, label &nVisited, boolList &visited, labelList &order)
Order intersection locations into a polygon.
static location intersection(const label srcEi, const label tgtEi)
Construct an intersection location between a source and a.
void writePolygon(const word &name, const PointField &ps)
Write a VTK file of a polygon.
static Vector< scalar > uniform(const scalar &s)
Return a VectorSpace with all elements = s.
const Type2 & second() const
Return second.
dimensioned< scalar > mag(const dimensioned< Type > &)
Selector class for relaxation factors, solver type and solution.
Functions with which to perform an intersection of a pair of triangles; the source and target...
T & last()
Return the last element of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
const Type & first() const
Return first.
dimensionedSymmTensor cof(const dimensionedSymmTensor &dt)
label tgtEdgei() const
Return the target edge index.
label srcEdgei() const
Return the source edge index.
void type(const direction i, const rootType t)
Set the type of the i-th root.