38 template<
class SrcPatchType,
class TgtPatchType>
41 const label patchFacei,
48 isSrc ? srcFaceTris_[patchFacei] : tgtFaceTris_[patchFacei];
50 forAll(patchFaceTris, patchFaceTrii)
52 const label trii = patchFaceTris[patchFaceTrii];
54 if (triPoints_[trii] != FixedList<label, 3>({-1, -1, -1}))
56 forAll(triEdges_[trii], triEdgei)
58 const label edgei = triEdges_[trii][triEdgei];
61 const edge
e = triEdgePoints(trii, triEdgei);
65 <<
"Tri #" << trii <<
"'s tri-edge #" << triEdgei
66 <<
" (edge #" << triEdges_[trii][triEdgei] <<
") has "
75 <<
"Tri #" << trii <<
" references edge #" << edgei
80 const label otherTrii = edgeTris_[edgei][!edgeTrii];
84 const label otherTriEdgei =
86 if (otherTriEdgei == -1)
89 <<
"Edge #" << edgei <<
" references tri #"
90 << otherTrii <<
" but the reverse is not true"
96 const edge otherE = triEdgePoints(otherTrii, otherTriEdgei);
97 if (edge::compare(
e, otherE) != -1)
100 <<
"Edge #" << edgei <<
' ' << edgePoints(edgei)
101 <<
" is not the same in adjacent tri #" << trii
102 <<
' ' << triPoints(trii) <<
" and tri #"
103 << otherTrii <<
' ' << triPoints(otherTrii)
111 if (edgeFrontEdges_[edgei] != -1)
114 const label frontEdgei = edgeFrontEdges_[edgei];
117 frontEdgeEdges_.size() <= frontEdgei
118 || frontEdgeEdges_[frontEdgei] != edgei
122 <<
"Edge #" << edgei <<
" is marked as part of the "
123 <<
"front but is not in the front edge list"
128 const label trii0 = edgeTris_[edgei][0];
129 const label trii1 = edgeTris_[edgei][1];
134 || (triSrcFace_[trii0] == -1) == (triSrcFace_[trii1] == -1)
138 <<
"Front edge #" << edgei
139 <<
" does not connect a source-tri to a target-tri"
157 template<
class SrcPatchType,
class TgtPatchType>
160 const label patchEdgei,
167 isSrc ? this->srcPatch_.edgeFaces() : this->tgtPatch_.edgeFaces();
169 const labelList patchFaceis = patchEdgePatchFaces[patchEdgei];
173 checkPatchFace(patchFaceis[i], isSrc);
180 template<
class SrcPatchType,
class TgtPatchType>
188 const List<DynamicList<label>>& patchFaceTris =
189 isSrc ? srcFaceTris_ : tgtFaceTris_;
191 forAll(patchFaceTris, patchFacei)
193 checkPatchFace(patchFacei, isSrc);
200 template<
class SrcPatchType,
class TgtPatchType>
210 && intersectEdgeFaces_[edgei] !=
labelPair(-1, -1)
214 <<
"Attempted to remove edge #" << edgei <<
" which is still "
215 <<
"connected to triangles " << edgeTris_[edgei] <<
" and faces "
216 << intersectEdgeFaces_[edgei]
221 removedEdges_.append(edgei);
223 if (edgeFrontEdges_[edgei] != -1)
225 frontEdgeEdges_[edgeFrontEdges_[edgei]] = -1;
226 edgeFrontEdges_[edgei] = -1;
231 template<
class SrcPatchType,
class TgtPatchType>
237 triPoints_[trii] =
triFace(-1, -1, -1);
240 const bool isSrc = triSrcFace_[trii] != -1;
242 const label patchFacei = isSrc ? triSrcFace_[trii] : triTgtFace_[trii];
244 DynamicList<label>& patchFaceTris =
245 isSrc ? srcFaceTris_[patchFacei] : tgtFaceTris_[patchFacei];
247 label patchFaceTrii = patchFaceTris.size() - 1;
249 for (; patchFaceTris[patchFaceTrii] != trii; -- patchFaceTrii);
251 for (; patchFaceTrii < patchFaceTris.size() - 1; ++ patchFaceTrii)
253 patchFaceTris[patchFaceTrii] = patchFaceTris[patchFaceTrii + 1];
256 patchFaceTris.resize(patchFaceTris.size() - 1);
259 triSrcFace_[trii] = -1;
260 triTgtFace_[trii] = -1;
262 if (triCandidateTris_[trii] != -1)
264 candidateTriTris_[triCandidateTris_[trii]] = -1;
265 triCandidateTris_[trii] = -1;
268 if (triMarkedTris_[trii] != -1)
270 markedTriTris_[triMarkedTris_[trii]] = -1;
271 triMarkedTris_[trii] = -1;
274 forAll(triEdges_[trii], i)
276 const label edgei = triEdges_[trii][i];
278 edgeTris_[edgei][edgeTris_[edgei][1] == trii] = -1;
283 && intersectEdgeFaces_[edgei] ==
labelPair(-1, -1)
290 triEdges_[trii] = FixedList<label, 3>({-1, -1, -1});
292 removedTris_.append(trii);
296 template<
class SrcPatchType,
class TgtPatchType>
299 if (removedTris_.size())
301 return removedTris_.remove();
305 triPoints_.append(
triFace(-1, -1, -1));
306 triEdges_.append(FixedList<label, 3>({-1, -1, -1}));
307 triSrcFace_.append(-1);
308 triTgtFace_.append(-1);
309 triCandidateTris_.append(-1);
310 triMarkedTris_.append(-1);
311 return triPoints_.size() - 1;
316 template<
class SrcPatchType,
class TgtPatchType>
319 if (removedEdges_.size())
321 return removedEdges_.remove();
325 edgeTris_.append({-1, -1});
326 intersectEdgeFaces_.append({-1, -1});
327 edgeFrontEdges_.append(-1);
328 return edgeTris_.size() - 1;
333 template<
class SrcPatchType,
class TgtPatchType>
336 const label pointi = srcPoints_.size();
338 srcPoints_.append(point::uniform(NaN));
339 srcPointNormals_.append(vector::uniform(NaN));
340 tgtPoints_.append(point::uniform(NaN));
341 pointPoints_.append(pointi);
342 this->pointSrcFaces_.append(-1);
343 this->pointTgtFaces_.append(-1);
344 this->pointSrcEdges_.append(-1);
345 this->pointTgtEdges_.append(-1);
346 this->pointSrcPoints_.append(-1);
347 this->pointTgtPoints_.append(-1);
352 template<
class SrcPatchType,
class TgtPatchType>
356 const label triPointi
359 return pointPoints_[triPoints_[trii][triPointi]];
363 template<
class SrcPatchType,
class TgtPatchType>
370 forAll(triPoints_[trii], triPointi)
372 result[triPointi] = triPoint(trii, triPointi);
378 template<
class SrcPatchType,
class TgtPatchType>
390 result[triPointi] = values[triPoint(trii, triPointi)];
396 template<
class SrcPatchType,
class TgtPatchType>
404 forAll(triEdges_[trii], triEdgei)
406 result[triEdgei] = edgeTris_[triEdges_[trii][triEdgei]][0] == trii;
412 template<
class SrcPatchType,
class TgtPatchType>
417 const label otherTrii
420 FixedList<label, 3> result({-1, -1, -1});
421 forAll(triPoints_[trii], triPointi)
423 forAll(triPoints_[otherTrii], otherTriPointi)
427 triPoint(trii, triPointi)
428 == triPoint(otherTrii, otherTriPointi)
431 result[triPointi] = otherTriPointi;
439 template<
class SrcPatchType,
class TgtPatchType>
444 const label otherTrii
447 FixedList<label, 3> result({-1, -1, -1});
448 forAll(triEdges_[trii], triEdgei)
450 forAll(triEdges_[otherTrii], otherTriEdgei)
454 triEdges_[trii][triEdgei]
455 == triEdges_[otherTrii][otherTriEdgei]
458 result[triEdgei] = otherTriEdgei;
466 template<
class SrcPatchType,
class TgtPatchType>
475 triPoint(trii, triEdgei),
476 triPoint(trii, (triEdgei + 1) % 3)
481 template<
class SrcPatchType,
class TgtPatchType>
487 const label edgeSidei = edgeTris_[edgei][0] == -1;
489 const label trii = edgeTris_[edgei][edgeSidei];
492 const edge
e = triEdgePoints(trii, triEdgei);
494 return edgeSidei == 0 ?
e :
e.reverseEdge();
498 template<
class SrcPatchType,
class TgtPatchType>
502 const label patchFacei,
503 const label patchFacePointi,
509 ? this->srcPointPoints_
511 this->srcPatch_.localFaces()[patchFacei][patchFacePointi]
513 : this->tgtPointPoints_
515 this->tgtPatch_.localFaces()[patchFacei][patchFacePointi]
520 template<
class SrcPatchType,
class TgtPatchType>
524 const label patchFacei,
529 forAll(result, patchFacePointi)
531 result[patchFacePointi] =
532 patchFacePoint(patchFacei, patchFacePointi, isSrc);
538 template<
class SrcPatchType,
class TgtPatchType>
543 const label patchFacei,
549 forAll(result, patchFacePointi)
551 result[patchFacePointi] =
552 values[patchFacePoint(patchFacei, patchFacePointi, isSrc)];
558 template<
class SrcPatchType,
class TgtPatchType>
562 const label patchFacei,
567 isSrc ? this->srcPatch_.localFaces() : this->tgtPatch_.localFaces();
569 isSrc ? this->srcPatch_.faceEdges() : this->tgtPatch_.faceEdges();
571 isSrc ? this->srcPatch_.edges() : this->tgtPatch_.edges();
575 const edge&
e = localEdges[faceEdges[patchFacei][i]];
576 const edge fe = localFaces[patchFacei].faceEdge(i);
577 result[i] = edge::compare(
e, fe) > 0;
583 template<
class SrcPatchType,
class TgtPatchType>
588 const label patchFacei,
589 const label otherPatchFacei,
593 const triFace pointis = patchFacePoints(patchFacei, isSrc);
594 const triFace otherPointis = patchFacePoints(otherPatchFacei, !isSrc);
595 FixedList<label, 3> result({-1, -1, -1});
598 forAll(otherPointis, otheri)
600 if (pointis[i] == otherPointis[otheri])
610 template<
class SrcPatchType,
class TgtPatchType>
614 const label patchFacei,
615 const label patchFacePointi,
621 ? this->srcPatch_.localFaces()[patchFacei][patchFacePointi]
622 : this->tgtPatch_.localFaces()[patchFacei][patchFacePointi];
626 template<
class SrcPatchType,
class TgtPatchType>
630 const label patchFacei,
637 result[i] = patchFacePatchPoint(patchFacei, i, isSrc);
643 template<
class SrcPatchType,
class TgtPatchType>
647 const label patchFacei,
648 const label patchFaceEdgei,
654 ? this->srcPatch_.
faceEdges()[patchFacei][patchFaceEdgei]
655 : this->tgtPatch_.faceEdges()[patchFacei][patchFaceEdgei];
659 template<
class SrcPatchType,
class TgtPatchType>
663 const label patchFacei,
670 result[i] = patchFacePatchEdge(patchFacei, i, isSrc);
676 template<
class SrcPatchType,
class TgtPatchType>
685 isSrc ? this->srcPatch_.pointEdges() : this->tgtPatch_.pointEdges();
688 isSrc ? this->pointSrcPoints_ : this->pointTgtPoints_;
690 isSrc ? this->pointSrcEdges_ : this->pointTgtEdges_;
692 auto nPointPatchEdges = [&](
const label pointi)
694 const label patchPointi = pointPatchPoints[pointi];
696 if (patchPointi == -1)
698 return pointPatchEdges[pointi] == -1 ?
label(0) :
label(1);
702 return patchPointPatchEdges[patchPointi].size();
706 auto pointPatchEdge = [&]
712 const label patchPointi = pointPatchPoints[pointi];
714 if (patchPointi == -1)
716 return pointPatchEdges[pointi];
720 return patchPointPatchEdges[patchPointi][i];
724 const edge&
e = edgePoints(edgei);
725 const label pointi0 =
e.first(), pointi1 =
e.last();
727 label patchEdgei = -1;
729 for (
label i0 = 0; i0 < nPointPatchEdges(pointi0); ++ i0)
731 for (
label i1 = 0; i1 < nPointPatchEdges(pointi1); ++ i1)
733 const label patchEdgei0 = pointPatchEdge(pointi0, i0);
734 const label patchEdgei1 = pointPatchEdge(pointi1, i1);
736 if (patchEdgei0 == patchEdgei1)
738 if (patchEdgei != -1 && patchEdgei != patchEdgei0)
741 <<
"Edge #" << edgei <<
" (points " <<
e
742 <<
") is associated with two or more different "
743 << (isSrc ?
"source" :
"target")
744 <<
" patch edges. This should not be possible."
748 patchEdgei = patchEdgei0;
757 template<
class SrcPatchType,
class TgtPatchType>
764 return labelPair(edgePatchEdge(edgei,
true), edgePatchEdge(edgei,
false));
768 template<
class SrcPatchType,
class TgtPatchType>
772 const FixedList<label, 3>& edgeis,
773 const label patchFacei,
781 const label edgei = edgeis[triEdgei];
783 if (edgei == -1)
continue;
785 const label otherTrii = edgeTris_[edgei][edgeTris_[edgei][0] == -1];
787 if (otherTrii == -1)
continue;
789 const label otherTriEdgei =
findIndex(triEdges_[otherTrii], edgei);
791 const edge eThis = pointis.faceEdge(triEdgei);
792 const edge eOther = triEdgePoints(otherTrii, otherTriEdgei);
794 if (edge::compare(eThis, eOther) != -1)
797 <<
"Edge #" << edgei <<
' ' << edgePoints(edgei)
798 <<
" is not the same in the new tri " << pointis <<
' '
799 << edgeis <<
" and the existing adjacent tri "
800 << triPoints(otherTrii) <<
' ' << triEdges_[otherTrii]
807 const label trii = newTrii();
810 triPoints_[trii] = pointis;
814 triEdges_[trii] = edgeis;
815 forAll(triEdges_[trii], triEdgei)
817 label& edgei = triEdges_[trii][triEdgei];
824 edgeTris_[edgei][edgeTris_[edgei][0] != -1] = trii;
830 triSrcFace_[trii] = patchFacei;
831 srcFaceTris_[patchFacei].append(trii);
835 triTgtFace_[trii] = patchFacei;
836 tgtFaceTris_[patchFacei].append(trii);
843 template<
class SrcPatchType,
class TgtPatchType>
850 forAll(edgeTris_[edgei], edgeTrii)
852 const label trii = edgeTris_[edgei][edgeTrii];
854 if (trii == -1)
return;
859 if (edgePatchEdges(edgei) !=
labelPair(-1, -1))
862 <<
"Flipping an original edge"
871 labelPair edgei0s(-1, -1), trii0s(-1, -1);
872 labelPair edgei1s(-1, -1), trii1s(-1, -1);
873 forAll(edgeTris_[edgei], edgeTrii)
875 const label trii = edgeTris_[edgei][edgeTrii];
878 pointi0 = triPoint(trii, (triEdgei + edgeTrii) % 3);
879 pointi1 = triPoint(trii, (triEdgei + !edgeTrii) % 3);
880 pointiOpps[edgeTrii] = triPoint(trii, (triEdgei + 2) % 3);
882 edgei0s[edgeTrii] = triEdges_[trii][(triEdgei + !edgeTrii + 1) % 3];
886 [edgeTris_[edgei0s[edgeTrii]][0] == trii];
887 edgei1s[edgeTrii] = triEdges_[trii][(triEdgei + edgeTrii + 1) % 3];
891 [edgeTris_[edgei1s[edgeTrii]][0] == trii];
896 const label trii0 = edgeTris_[edgei][0], trii1 = edgeTris_[edgei][1];
898 triPoints_[trii0] = {pointi0, pointiOpps[1], pointiOpps[0]};
899 triEdges_[trii0] = {edgei0s[1], edgei, edgei0s[0]};
900 edgeTris_[edgei0s[1]][edgeTris_[edgei0s[1]][1] == trii1] = trii0;
902 triPoints_[trii1] = {pointi1, pointiOpps[0], pointiOpps[1]};
903 triEdges_[trii1] = {edgei1s[0], edgei, edgei1s[1]};
904 edgeTris_[edgei1s[0]][edgeTris_[edgei1s[0]][1] == trii0] = trii1;
909 template<
class SrcPatchType,
class TgtPatchType>
922 triSrcFace_[trii] != -1 ? srcPoints_ : tgtPoints_;
926 const Tuple2<point, scalar> circle = t.circumCircle();
932 template<
class SrcPatchType,
class TgtPatchType>
935 const label insertionTriOrEdgei,
937 const UList<label>& pointis,
938 UList<label>& insertionEdgeis,
939 const UList<label>& fixedEdgeis
943 insertionEdgeis = -1;
949 candidateTriTris_.append(insertionTriOrEdgei);
950 triCandidateTris_[insertionTriOrEdgei] = 0;
956 insertionEdgeis[0] = insertionTriOrEdgei;
963 const label trii0 = edgeTris_[insertionTriOrEdgei][0];
964 const label trii1 = edgeTris_[insertionTriOrEdgei][1];
970 && (triSrcFace_[trii0] == -1) != (triSrcFace_[trii1] == -1)
974 <<
"Attempted insertion into front edge #"
981 const label adjacentTri =
983 ? insertionTriOrEdgei
984 : edgeTris_[insertionTriOrEdgei][edgeTris_[insertionTriOrEdgei][0] == -1];
985 const bool isSrc = triSrcFace_[adjacentTri] != -1;
986 const label patchEdgei =
989 : edgePatchEdge(insertionTriOrEdgei, isSrc);
990 const label patchFacei =
993 : (isSrc ? triSrcFace_[adjacentTri] : triTgtFace_[adjacentTri]);
996 List<DynamicList<label>>& patchEdgePoints =
997 isSrc ? this->srcEdgePoints_ : this->tgtEdgePoints_;
998 DynamicList<label>& pointPatchEdges =
999 isSrc ? this->pointSrcEdges_ : this->pointTgtEdges_;
1000 DynamicList<label>& pointPatchFaces =
1001 isSrc ? this->pointSrcFaces_ : this->pointTgtFaces_;
1004 const bool isClosedStar =
1005 isTri ||
findIndex(edgeTris_[insertionEdgeis[0]], -1) == -1;
1010 const label pointi = pointis[pointii];
1015 label initialTriOrEdgei = -1;
1018 label insertionCandidateTrii = -1;
1019 scalar minDistSqr = vGreat;
1020 forAll(candidateTriTris_, candidateTrii)
1022 const label trii = candidateTriTris_[candidateTrii];
1023 if (trii == -1)
continue;
1024 const scalar distSqr = circumDistSqr(trii, pointi);
1025 if (distSqr < minDistSqr)
1027 insertionCandidateTrii = candidateTrii;
1028 minDistSqr = distSqr;
1035 initialTriOrEdgei = candidateTriTris_[insertionCandidateTrii];
1039 initialTriOrEdgei = insertionEdgeis[pointii];
1043 star::context starContext = star_.populate
1054 edgePatchEdges(edgei) !=
labelPair(-1, -1)
1055 || (isSrc && triTgtFace_[trii] != -1)
1056 || (!isSrc && triSrcFace_[trii] != -1)
1068 const label edgej0 = triEdges_[trii][(triEdgei + 1) % 3];
1069 const label edgej1 = triEdges_[trii][(triEdgei + 2) % 3];
1071 edgeTris_[edgej0][edgeTris_[edgej0][0] == trii];
1073 edgeTris_[edgej1][edgeTris_[edgej1][0] == trii];
1076 (trij0 != -1 && star_.faceStarFaces()[trij0] != -1)
1077 || (trij1 != -1 && star_.faceStarFaces()[trij1] != -1)
1078 || (!isTri &&
findIndex(insertionEdgeis, edgej0) != -1)
1079 || (!isTri &&
findIndex(insertionEdgeis, edgej1) != -1)
1087 return circumDistSqr(trii, pointi) < 0;
1094 const edge insertionEdge =
1095 isTri ? edge(-1, -1) : edgePoints(insertionEdgeis[pointii]);
1099 label newTrii0 = -1, newTrii00 = -1;
1102 const bool isFirst = i == 0;
1103 const bool isLast = i == star_.starEdgeEdges().size() - 1;
1105 const bool edgeSidei =
1106 edgeTris_[edgei][0] == -1
1107 || star_.faceStarFaces()[edgeTris_[edgei][0]] == -1;
1109 const label trii = edgeTris_[edgei][edgeSidei];
1113 const label tempEdgei = newEdgei();
1114 triEdges_[trii][triEdgei] = tempEdgei;
1115 edgeTris_[tempEdgei][0] = trii;
1116 edgeTris_[edgei][edgeSidei] = -1;
1119 const label newTrii =
1124 triPoint(trii, triEdgei),
1125 triPoint(trii, (triEdgei + 1) % 3),
1128 !isFirst ? triEdges_[newTrii0][2] : -1,
1130 isClosedStar && isLast ? triEdges_[newTrii00][0] : -1
1132 isSrc ? triSrcFace_[trii] : triTgtFace_[trii],
1136 newTrii00 = isFirst ? newTrii0 : newTrii00;
1141 candidateTriTris_.append(newTrii);
1142 triCandidateTris_[newTrii] = candidateTriTris_.size() - 1;
1146 if (triPoint(newTrii, 2) == insertionEdge[0])
1148 insertionEdgeis[pointii] = triEdges_[newTrii][2];
1152 if (!isTri && triPoint(newTrii, 1) == insertionEdge[1])
1154 insertionEdgeis[pointii + 1] = triEdges_[newTrii][0];
1159 if (patchEdgei != -1)
1161 patchEdgePoints[patchEdgei].append(-1);
1162 label patchEdgePointi = patchEdgePoints[patchEdgei].size() - 1;
1163 for (; patchEdgePointi >= 0; -- patchEdgePointi)
1165 label& pointi = patchEdgePoints[patchEdgei][patchEdgePointi];
1166 pointi = patchEdgePoints[patchEdgei][patchEdgePointi - 1];
1169 pointPoints_[pointi] == insertionEdge[0]
1170 || pointPoints_[pointi] == insertionEdge[1]
1177 patchEdgePoints[patchEdgei][patchEdgePointi] = pointi;
1179 pointPatchEdges[pointi] = patchEdgei;
1183 pointPatchFaces[pointi] = patchFacei;
1187 if (patchEdgei != -1)
1189 checkPatchEdge(patchEdgei, isSrc);
1193 checkPatchFace(patchFacei, isSrc);
1200 if (edgePoints(insertionEdgeis[pointii + 1])[1] != insertionEdge[1])
1204 edgeTris_[insertionEdgeis[pointii + 1]][0],
1205 edgeTris_[insertionEdgeis[pointii + 1]][1]
1217 if (patchEdgei != -1)
1219 checkPatchEdge(patchEdgei, isSrc);
1223 checkPatchFace(patchFacei, isSrc);
1230 forAll(candidateTriTris_, candidateTrii)
1232 const label trii = candidateTriTris_[candidateTrii];
1235 triCandidateTris_[trii] = -1;
1238 candidateTriTris_.clear();
1243 template<
class SrcPatchType,
class TgtPatchType>
1251 this->pointSrcPoints_[pointi] != -1
1252 && this->pointTgtPoints_[pointi] == -1
1253 && this->pointTgtEdges_[pointi] == -1
1254 && this->pointTgtFaces_[pointi] == -1
1257 this->pointTgtPoints_[pointi] != -1
1258 && this->pointSrcPoints_[pointi] == -1
1259 && this->pointSrcEdges_[pointi] == -1
1260 && this->pointSrcFaces_[pointi] == -1
1265 template<
class SrcPatchType,
class TgtPatchType>
1273 edgePatchEdge(edgei,
true) != -1
1274 && edgePatchEdge(edgei,
false) == -1
1276 edgeTris_[edgei][0] == -1
1277 || triTgtFace_[edgeTris_[edgei][0]] == -1
1280 edgeTris_[edgei][1] == -1
1281 || triTgtFace_[edgeTris_[edgei][1]] == -1
1285 edgePatchEdge(edgei,
false) != -1
1286 && edgePatchEdge(edgei,
true) == -1
1288 edgeTris_[edgei][0] == -1
1289 || triSrcFace_[edgeTris_[edgei][0]] == -1
1292 edgeTris_[edgei][1] == -1
1293 || triSrcFace_[edgeTris_[edgei][1]] == -1
1299 template<
class SrcPatchType,
class TgtPatchType>
1303 const label srcFacei,
1304 const label tgtFacei,
1305 const scalar snapTol
1308 static const FixedList<label, 3> triNoSnap({-1, -1, -1});
1311 triPointRef(tgtPoints_, patchFacePoints(tgtFacei,
false)).normal();
1314 FixedList<barycentric2D, 3> srcFaceTgtTs(barycentric2D::uniform(-vGreat));
1315 FixedList<label, 3> srcFaceSnapTgtFacePoint(triNoSnap);
1316 FixedList<label, 3> srcFaceSnapTgtFaceEdge(triNoSnap);
1317 forAll(srcFaceSnapTgtFacePoint, srcFacePointi)
1319 const label srcPointi = patchFacePoint(srcFacei, srcFacePointi,
true);
1321 if (!pointCanIntersect(srcPointi))
continue;
1323 if ((srcPointNormals_[srcPointi] & tgtNormal) < 0)
1325 srcFaceTgtTs[srcFacePointi] =
1328 srcPoints_[srcPointi],
1329 srcPointNormals_[srcPointi],
1330 patchFacePointValues(tgtFacei,
false, tgtPoints_)
1333 for (
label tgtFacePointi = 0; tgtFacePointi < 3; ++ tgtFacePointi)
1335 const label tgtPointi =
1336 patchFacePoint(tgtFacei, tgtFacePointi,
false);
1338 const label tgtFacePointi0 = (tgtFacePointi + 2) % 3;
1339 const label tgtFacePointi1 = (tgtFacePointi + 1) % 3;
1343 pointCanIntersect(tgtPointi)
1344 &&
mag(srcFaceTgtTs[srcFacePointi][tgtFacePointi0]) < snapTol
1345 &&
mag(srcFaceTgtTs[srcFacePointi][tgtFacePointi1]) < snapTol
1348 srcFaceSnapTgtFacePoint[srcFacePointi] =
1349 srcFaceSnapTgtFacePoint[srcFacePointi] == -1
1353 srcFaceTgtTs[srcFacePointi][tgtFacePointi] = 1;
1354 srcFaceTgtTs[srcFacePointi][tgtFacePointi0] = 0;
1355 srcFaceTgtTs[srcFacePointi][tgtFacePointi1] = 0;
1359 srcFaceSnapTgtFacePoint[srcFacePointi] =
1360 max(srcFaceSnapTgtFacePoint[srcFacePointi], -1);
1362 if (srcFaceSnapTgtFacePoint[srcFacePointi] != -1)
continue;
1364 for (
label tgtFaceEdgei = 0; tgtFaceEdgei < 3; ++ tgtFaceEdgei)
1366 const label tgtFacePointi0 = tgtFaceEdgei;
1367 const label tgtFacePointi1 = (tgtFaceEdgei + 1) % 3;
1368 const label tgtFacePointiOpp = (tgtFaceEdgei + 2) % 3;
1372 srcFaceTgtTs[srcFacePointi][tgtFacePointi0] >= snapTol
1373 && srcFaceTgtTs[srcFacePointi][tgtFacePointi1] >= snapTol
1374 &&
mag(srcFaceTgtTs[srcFacePointi][tgtFacePointiOpp]) < snapTol
1377 srcFaceSnapTgtFaceEdge[srcFacePointi] =
1378 srcFaceSnapTgtFaceEdge[srcFacePointi] == -1
1383 srcFaceTgtTs[srcFacePointi][tgtFacePointiOpp];
1384 srcFaceTgtTs[srcFacePointi][tgtFacePointiOpp] = 0;
1385 srcFaceTgtTs[srcFacePointi][tgtFacePointi0] /= 1 - eps;
1386 srcFaceTgtTs[srcFacePointi][tgtFacePointi1] /= 1 - eps;
1390 srcFaceSnapTgtFaceEdge[srcFacePointi] =
1391 max(srcFaceSnapTgtFaceEdge[srcFacePointi], -1);
1396 FixedList<barycentric2D, 3> tgtFaceSrcTs(barycentric2D::uniform(-vGreat));
1397 FixedList<label, 3> tgtFaceSnapSrcFacePoint(triNoSnap);
1398 FixedList<label, 3> tgtFaceSnapSrcFaceEdge(triNoSnap);
1399 forAll(tgtFaceSnapSrcFacePoint, tgtFacePointi)
1401 const label tgtPointi = patchFacePoint(tgtFacei, tgtFacePointi,
false);
1403 if (!pointCanIntersect(tgtPointi))
continue;
1405 tgtFaceSrcTs[tgtFacePointi] =
1408 patchFacePointValues(srcFacei,
true, srcPoints_),
1409 patchFacePointValues(srcFacei,
true, srcPointNormals_),
1410 tgtPoints_[tgtPointi]
1416 tgtFaceSrcTs[tgtFacePointi],
1417 patchFacePointValues(srcFacei,
true, srcPointNormals_)
1420 if ((srcNormal & tgtNormal) < 0)
1422 for (
label srcFacePointi = 0; srcFacePointi < 3; ++ srcFacePointi)
1424 const label srcPointi =
1425 patchFacePoint(srcFacei, srcFacePointi,
true);
1427 const label srcFacePointi0 = (srcFacePointi + 2) % 3;
1428 const label srcFacePointi1 = (srcFacePointi + 1) % 3;
1432 pointCanIntersect(srcPointi)
1433 &&
mag(tgtFaceSrcTs[tgtFacePointi][srcFacePointi0]) < snapTol
1434 &&
mag(tgtFaceSrcTs[tgtFacePointi][srcFacePointi1]) < snapTol
1437 tgtFaceSnapSrcFacePoint[tgtFacePointi] =
1438 tgtFaceSnapSrcFacePoint[tgtFacePointi] == -1
1442 tgtFaceSrcTs[tgtFacePointi][srcFacePointi] = 1;
1443 tgtFaceSrcTs[tgtFacePointi][srcFacePointi0] = 0;
1444 tgtFaceSrcTs[tgtFacePointi][srcFacePointi1] = 0;
1448 tgtFaceSnapSrcFacePoint[tgtFacePointi] =
1449 max(tgtFaceSnapSrcFacePoint[tgtFacePointi], -1);
1451 if (tgtFaceSnapSrcFacePoint[tgtFacePointi] != -1)
continue;
1453 for (
label srcFaceEdgei = 0; srcFaceEdgei < 3; ++ srcFaceEdgei)
1455 const label srcFacePointi0 = srcFaceEdgei;
1456 const label srcFacePointi1 = (srcFaceEdgei + 1) % 3;
1457 const label srcFacePointiOpp = (srcFaceEdgei + 2) % 3;
1461 tgtFaceSrcTs[tgtFacePointi][srcFacePointi0] >= snapTol
1462 && tgtFaceSrcTs[tgtFacePointi][srcFacePointi1] >= snapTol
1463 &&
mag(tgtFaceSrcTs[tgtFacePointi][srcFacePointiOpp]) < snapTol
1466 tgtFaceSnapSrcFaceEdge[tgtFacePointi] =
1467 tgtFaceSnapSrcFaceEdge[tgtFacePointi] == -1
1472 tgtFaceSrcTs[tgtFacePointi][srcFacePointiOpp];
1473 tgtFaceSrcTs[tgtFacePointi][srcFacePointiOpp] = 0;
1474 tgtFaceSrcTs[tgtFacePointi][srcFacePointi0] /= 1 - eps;
1475 tgtFaceSrcTs[tgtFacePointi][srcFacePointi1] /= 1 - eps;
1479 tgtFaceSnapSrcFaceEdge[tgtFacePointi] =
1480 max(tgtFaceSnapSrcFaceEdge[tgtFacePointi], -1);
1487 srcFaceSnapTgtFacePoint == triNoSnap
1488 && srcFaceSnapTgtFaceEdge == triNoSnap
1489 && tgtFaceSnapSrcFacePoint == triNoSnap
1490 && tgtFaceSnapSrcFaceEdge == triNoSnap
1497 forAll(srcFaceSnapTgtFacePoint, srcFacePointi)
1499 const label tgtFacePointi = srcFaceSnapTgtFacePoint[srcFacePointi];
1501 if (tgtFacePointi != -1)
1503 tgtFaceSnapSrcFacePoint[tgtFacePointi] = srcFacePointi;
1506 forAll(tgtFaceSnapSrcFacePoint, tgtFacePointi)
1508 const label srcFacePointi = tgtFaceSnapSrcFacePoint[tgtFacePointi];
1510 if (srcFacePointi != -1)
1512 srcFaceSnapTgtFacePoint[srcFacePointi] = tgtFacePointi;
1517 forAll(srcFaceSnapTgtFacePoint, srcFacePointi)
1519 const label tgtFacePointi = srcFaceSnapTgtFacePoint[srcFacePointi];
1521 if (tgtFacePointi == -1)
continue;
1523 const label srcPointi = patchFacePoint(srcFacei, srcFacePointi,
true);
1524 const label tgtPointi = patchFacePoint(tgtFacei, tgtFacePointi,
false);
1526 if (!pointCanIntersect(srcPointi))
continue;
1527 if (!pointCanIntersect(tgtPointi))
continue;
1529 srcPoints_[tgtPointi] = srcPoints_[srcPointi];
1530 srcPointNormals_[tgtPointi] = srcPointNormals_[srcPointi];
1531 tgtPoints_[srcPointi] = tgtPoints_[tgtPointi];
1533 const point& srcP = srcPoints_[srcPointi];
1534 const vector& srcN = srcPointNormals_[srcPointi];
1535 const point& tgtP = tgtPoints_[tgtPointi];
1537 srcPoints_[srcPointi] += d/2;
1538 tgtPoints_[tgtPointi] -= d/2;
1542 forAll(srcFaceSnapTgtFaceEdge, srcFacePointi)
1544 const label tgtFaceEdgei = srcFaceSnapTgtFaceEdge[srcFacePointi];
1546 if (tgtFaceEdgei == -1)
continue;
1548 const label srcPointi = patchFacePoint(srcFacei, srcFacePointi,
true);
1550 if (!pointCanIntersect(srcPointi))
continue;
1552 tgtPoints_[srcPointi] =
1555 srcFaceTgtTs[srcFacePointi],
1556 patchFacePointValues(tgtFacei,
false, tgtPoints_)
1559 const point& srcP = srcPoints_[srcPointi];
1560 const vector& srcN = srcPointNormals_[srcPointi];
1561 const point& tgtP = tgtPoints_[srcPointi];
1563 srcPoints_[srcPointi] += d;
1567 forAll(tgtFaceSnapSrcFaceEdge, tgtFacePointi)
1569 const label srcFaceEdgei = tgtFaceSnapSrcFaceEdge[tgtFacePointi];
1571 if (srcFaceEdgei == -1)
continue;
1573 const label tgtPointi = patchFacePoint(tgtFacei, tgtFacePointi,
false);
1575 if (!pointCanIntersect(tgtPointi))
continue;
1577 srcPoints_[tgtPointi] =
1580 tgtFaceSrcTs[tgtFacePointi],
1581 patchFacePointValues(srcFacei,
true, srcPoints_)
1583 srcPointNormals_[tgtPointi] =
1586 tgtFaceSrcTs[tgtFacePointi],
1587 patchFacePointValues(srcFacei,
true, srcPointNormals_)
1590 const point& srcP = srcPoints_[tgtPointi];
1591 const vector& srcN = srcPointNormals_[tgtPointi];
1592 const point& tgtP = tgtPoints_[tgtPointi];
1594 tgtPoints_[tgtPointi] -= d;
1598 forAll(srcFaceSnapTgtFacePoint, srcFacePointi)
1600 const label tgtFacePointi = srcFaceSnapTgtFacePoint[srcFacePointi];
1602 if (tgtFacePointi == -1)
continue;
1604 const label srcPointi = patchFacePoint(srcFacei, srcFacePointi,
true);
1605 const label tgtPointi = patchFacePoint(tgtFacei, tgtFacePointi,
false);
1607 if (!pointCanIntersect(srcPointi))
continue;
1608 if (!pointCanIntersect(tgtPointi))
continue;
1610 srcPoints_[tgtPointi] = srcPoints_[srcPointi];
1611 srcPointNormals_[tgtPointi] = srcPointNormals_[srcPointi];
1612 tgtPoints_[srcPointi] = tgtPoints_[tgtPointi];
1614 pointPoints_[tgtPointi] = srcPointi;
1616 this->pointTgtEdges_[srcPointi] = this->pointTgtEdges_[tgtPointi];
1617 this->pointSrcEdges_[tgtPointi] = -1;
1618 this->pointTgtEdges_[tgtPointi] = -1;
1620 this->pointTgtPoints_[srcPointi] = this->pointTgtPoints_[tgtPointi];
1621 this->tgtPointPoints_[this->pointTgtPoints_[tgtPointi]] = srcPointi;
1622 this->pointSrcPoints_[tgtPointi] = -1;
1623 this->pointTgtPoints_[tgtPointi] = -1;
1627 checkPatchFace(srcFacei,
true);
1628 checkPatchFace(tgtFacei,
false);
1631 labelList insertPointis(1), insertEdgeis(2,
label(-1)), fixedEdgeis(0);
1634 forAll(srcFaceSnapTgtFaceEdge, srcFacePointi)
1636 const label tgtFaceEdgei = srcFaceSnapTgtFaceEdge[srcFacePointi];
1638 if (tgtFaceEdgei == -1)
continue;
1640 const label srcPointi = patchFacePoint(srcFacei, srcFacePointi,
true);
1642 if (!pointCanIntersect(srcPointi))
continue;
1644 const label tgtPatchEdgei =
1645 patchFacePatchEdge(tgtFacei, tgtFaceEdgei,
false);
1649 label insertTgtEdgei = -1;
1650 scalar insertDistSqr = vGreat;
1651 forAll(tgtFaceTris_[tgtFacei], tgtFaceTrii)
1653 const label tgtTrii = tgtFaceTris_[tgtFacei][tgtFaceTrii];
1655 forAll(triEdges_[tgtTrii], tgtTriEdgei)
1657 const label tgtEdgei = triEdges_[tgtTrii][tgtTriEdgei];
1661 edgeCanIntersect(tgtEdgei)
1662 && tgtPatchEdgei == edgePatchEdge(tgtEdgei,
false)
1665 const scalar distSqr = circumDistSqr(tgtTrii, srcPointi);
1667 if (distSqr < insertDistSqr)
1669 insertDistSqr = distSqr;
1670 insertTgtEdgei = tgtEdgei;
1676 if (insertTgtEdgei != -1)
1678 insertPointis[0] = srcPointi;
1691 forAll(tgtFaceSnapSrcFaceEdge, tgtFacePointi)
1693 const label srcFaceEdgei = tgtFaceSnapSrcFaceEdge[tgtFacePointi];
1695 if (srcFaceEdgei == -1)
continue;
1697 const label tgtPointi = patchFacePoint(tgtFacei, tgtFacePointi,
false);
1699 if (!pointCanIntersect(tgtPointi))
continue;
1701 const label srcPatchEdgei =
1702 patchFacePatchEdge(srcFacei, srcFaceEdgei,
true);
1704 srcPoints_[tgtPointi] =
1707 tgtFaceSrcTs[tgtFacePointi],
1708 patchFacePointValues(srcFacei,
true, srcPoints_)
1710 srcPointNormals_[tgtPointi] =
1713 tgtFaceSrcTs[tgtFacePointi],
1714 patchFacePointValues(srcFacei,
true, srcPointNormals_)
1719 label insertSrcEdgei = -1;
1720 scalar insertDistSqr = vGreat;
1721 forAll(srcFaceTris_[srcFacei], srcFaceTrii)
1723 const label srcTrii = srcFaceTris_[srcFacei][srcFaceTrii];
1725 forAll(triEdges_[srcTrii], srcTriEdgei)
1727 const label srcEdgei = triEdges_[srcTrii][srcTriEdgei];
1731 edgeCanIntersect(srcEdgei)
1732 && srcPatchEdgei == edgePatchEdge(srcEdgei,
true)
1735 const scalar distSqr = circumDistSqr(srcTrii, tgtPointi);
1737 if (distSqr < insertDistSqr)
1739 insertDistSqr = distSqr;
1740 insertSrcEdgei = srcEdgei;
1746 if (insertSrcEdgei != -1)
1748 insertPointis[0] = tgtPointi;
1761 checkPatchFace(srcFacei,
true);
1762 checkPatchFace(tgtFacei,
false);
1766 template<
class SrcPatchType,
class TgtPatchType>
1769 const label srcTrii,
1774 const label srcFacei = triSrcFace_[srcTrii];
1775 const label tgtFacei = triTgtFace_[tgtTrii];
1776 if (srcFacei == -1 || tgtFacei == -1)
1779 <<
"Tri-intersections must be between a tri associated with the "
1780 <<
"source patch and one associated with the target patch"
1785 DynamicList<point> ictSrcPoints;
1786 DynamicList<vector> ictSrcPointNormals;
1787 DynamicList<point> ictTgtPoints;
1788 DynamicList<triIntersect::location> ictPointLocations;
1791 triPointValues(srcTrii, srcPoints_),
1792 triPointValues(srcTrii, srcPointNormals_),
1794 triOtherTriPoints(srcTrii, tgtTrii),
1795 triPointValues(tgtTrii, tgtPoints_),
1797 triOtherTriPoints(tgtTrii, srcTrii),
1804 ?
"srcTrii##tgtTrii=" +
name(srcTrii) +
name(tgtTrii)
1809 if (!ictPointLocations.size())
1817 forAll(ictPointLocations, ictPointi)
1819 const triIntersect::location& l = ictPointLocations[ictPointi];
1821 if (l.isSrcPoint() && !l.isTgtPoint())
1823 const label pointi = triPoint(srcTrii, l.srcPointi());
1827 this->pointTgtPoints_[pointi] != -1
1828 || this->pointTgtEdges_[pointi] != -1
1829 || this->pointTgtFaces_[pointi] != -1
1835 if (!l.isSrcPoint() && l.isTgtPoint())
1837 const label pointi = triPoint(tgtTrii, l.tgtPointi());
1841 this->pointSrcPoints_[pointi] != -1
1842 || this->pointSrcEdges_[pointi] != -1
1843 || this->pointSrcFaces_[pointi] != -1
1849 if (l.isIntersection())
1851 const label srcEdgei = triEdges_[srcTrii][l.srcEdgei()];
1852 const label tgtEdgei = triEdges_[tgtTrii][l.tgtEdgei()];
1854 const labelPair srcPatchEdges = edgePatchEdges(srcEdgei);
1855 const labelPair tgtPatchEdges = edgePatchEdges(tgtEdgei);
1859 (srcPatchEdges[0] != -1 && tgtPatchEdges[1] != -1)
1860 && (srcPatchEdges[1] != -1 || tgtPatchEdges[0] != -1)
1866 const label srcTrij =
1867 edgeTris_[srcEdgei][edgeTris_[srcEdgei][0] == srcTrii];
1868 const label tgtTrij =
1869 edgeTris_[tgtEdgei][edgeTris_[tgtEdgei][0] == tgtTrii];
1873 (srcTrij != -1 && triTgtFace_[srcTrij] != -1)
1874 || (tgtTrij != -1 && triSrcFace_[tgtTrij] != -1)
1883 bool insertPointsIntoTri =
false;
1884 bool insertPointsIntoEdges =
false;
1890 labelList ictPointiToPointi(ictPointLocations.size(), -1);
1891 forAll(ictPointLocations, ictPointi)
1893 const triIntersect::location& l = ictPointLocations[ictPointi];
1895 if (l.isSrcPoint() && !l.isTgtPoint())
1897 const label pointi = triPoint(srcTrii, l.srcPointi());
1899 ictPointiToPointi[ictPointi] = pointi;
1902 tgtPoints_[pointi] = ictTgtPoints[ictPointi];
1904 insertPointsIntoTri =
true;
1906 if (!l.isSrcPoint() && l.isTgtPoint())
1908 const label pointi = triPoint(tgtTrii, l.tgtPointi());
1910 ictPointiToPointi[ictPointi] = pointi;
1913 srcPoints_[pointi] = ictSrcPoints[ictPointi];
1914 srcPointNormals_[pointi] = ictSrcPointNormals[ictPointi];
1916 insertPointsIntoTri =
true;
1918 if (l.isIntersection())
1920 const label srcPatchEdgei =
1921 edgePatchEdge(triEdges_[srcTrii][l.srcEdgei()],
true);
1922 const label tgtPatchEdgei =
1923 edgePatchEdge(triEdges_[tgtTrii][l.tgtEdgei()],
false);
1925 if (srcPatchEdgei != -1 && tgtPatchEdgei != -1)
1927 ictPointiToPointi[ictPointi] = srcPoints_.size();
1931 srcPoints_[pointi] = ictSrcPoints[ictPointi];
1932 srcPointNormals_[pointi] = ictSrcPointNormals[ictPointi];
1933 tgtPoints_[pointi] = ictTgtPoints[ictPointi];
1935 insertPointsIntoEdges =
true;
1941 const FixedList<label, 3> srcTriEdges = triEdges_[srcTrii];
1942 const FixedList<bool, 3> srcTriOwns = triOwns(srcTrii);
1943 const FixedList<label, 3> tgtTriEdges = triEdges_[tgtTrii];
1944 const FixedList<bool, 3> tgtTriOwns = triOwns(tgtTrii);
1953 DynamicList<label> fixedSrcEdgeis, fixedTgtEdgeis;
1954 #ifdef OVERCONSTRAIN
1955 forAll(srcTriEdges, srcTriEdgei)
1957 fixedSrcEdgeis.append(srcTriEdges[srcTriEdgei]);
1959 forAll(tgtTriEdges, tgtTriEdgei)
1961 fixedTgtEdgeis.append(tgtTriEdges[tgtTriEdgei]);
1966 if (insertPointsIntoTri)
1968 DynamicList<label> insertSrcPointis(3), insertTgtPointis(3);
1969 DynamicList<label> insertEdgeis;
1970 forAll(ictPointLocations, ictPointi)
1972 const label pointi = ictPointiToPointi[ictPointi];
1974 if (pointi == -1)
continue;
1976 const triIntersect::location& l = ictPointLocations[ictPointi];
1978 if (l.isSrcPoint() && !l.isTgtPoint())
1980 insertSrcPointis.append(pointi);
1982 if (!l.isSrcPoint() && l.isTgtPoint())
1984 insertTgtPointis.append(pointi);
1988 if (insertSrcPointis.size())
2000 if (insertTgtPointis.size())
2013 checkPatchFace(srcFacei,
true);
2014 checkPatchFace(tgtFacei,
false);
2018 if (insertPointsIntoEdges)
2020 DynamicList<label> insertPointis(2), insertEdgeis(3);
2021 forAll(ictPointLocations, ictPointi0)
2023 const label ictPointi1 = ictPointLocations.fcIndex(ictPointi0);
2025 const label pointi0 = ictPointiToPointi[ictPointi0];
2026 const label pointi1 = ictPointiToPointi[ictPointi1];
2028 const triIntersect::location& l0 = ictPointLocations[ictPointi0];
2029 const triIntersect::location& l1 = ictPointLocations[ictPointi1];
2031 insertPointis.clear();
2032 insertEdgeis.clear();
2033 insertEdgeis.append(-1);
2040 && l0.srcEdgei() != (l1.srcPointi() + 1) % 3
2044 && l1.isIntersection()
2045 && (l0.srcPointi() + 1) % 3 != l1.srcEdgei()
2049 && l1.isIntersection()
2050 && l0.srcEdgei() == l1.srcEdgei()
2054 const label srcTriEdgei =
2055 l0.isIntersection() ? l0.srcEdgei() : l1.srcEdgei();
2057 if (!l0.isSrcPoint() && pointi0 != -1)
2059 insertPointis.append(pointi0);
2060 insertEdgeis.append(-1);
2062 if (!l1.isSrcPoint() && pointi1 != -1)
2064 insertPointis.append(pointi1);
2065 insertEdgeis.append(-1);
2067 if (!srcTriOwns[srcTriEdgei])
2072 if (insertPointis.size())
2076 srcTriEdges[srcTriEdgei],
2084 #ifdef OVERCONSTRAIN
2085 fixedSrcEdgeis[srcTriEdgei] = insertEdgeis.remove();
2086 fixedSrcEdgeis.append(insertEdgeis);
2095 && l0.tgtEdgei() != (l1.tgtPointi() + 1) % 3
2099 && l1.isIntersection()
2100 && (l0.tgtPointi() + 1) % 3 != l1.tgtEdgei()
2105 && l1.isIntersection()
2106 && l0.tgtEdgei() == l1.tgtEdgei()
2110 const label tgtTriEdgei =
2111 l0.isIntersection() ? l0.tgtEdgei() : l1.tgtEdgei();
2113 if (!l0.isTgtPoint() && pointi0 != -1)
2115 insertPointis.append(pointi0);
2116 insertEdgeis.append(-1);
2118 if (!l1.isTgtPoint() && pointi1 != -1)
2120 insertPointis.append(pointi1);
2121 insertEdgeis.append(-1);
2123 if (tgtTriOwns[tgtTriEdgei])
2128 if (insertPointis.size())
2132 tgtTriEdges[tgtTriEdgei],
2140 #ifdef OVERCONSTRAIN
2141 fixedTgtEdgeis[tgtTriEdgei] = insertEdgeis.remove();
2142 fixedTgtEdgeis.append(insertEdgeis);
2148 checkPatchFace(srcFacei,
true);
2149 checkPatchFace(tgtFacei,
false);
2156 template<
class SrcPatchType,
class TgtPatchType>
2160 const label srcFacei,
2161 const label tgtFacei
2165 const DynamicList<label>& srcFaceTris = srcFaceTris_[srcFacei];
2166 forAll(srcFaceTris, srcFaceTrii)
2168 const label srcTrii = srcFaceTris[srcFaceTrii];
2170 if (triMarkedTris_[srcTrii] != -1)
2172 markedTriTris_[triMarkedTris_[srcTrii]] = -1;
2173 triMarkedTris_[srcTrii] = -1;
2178 label srcFaceTrii = 0;
2179 while (srcFaceTrii < srcFaceTris.size())
2182 const label srcTrii = srcFaceTris[srcFaceTrii];
2183 markedTriTris_.append(srcTrii);
2184 triMarkedTris_[srcTrii] = markedTriTris_.size() - 1;
2187 const DynamicList<label>& tgtFaceTris = tgtFaceTris_[tgtFacei];
2188 forAll(tgtFaceTris, tgtFaceTrii)
2190 const label tgtTrii = tgtFaceTris[tgtFaceTrii];
2192 if (triMarkedTris_[tgtTrii] != -1)
2194 markedTriTris_[triMarkedTris_[tgtTrii]] = -1;
2195 triMarkedTris_[tgtTrii] = -1;
2200 label tgtFaceTrii = 0;
2201 while (tgtFaceTrii < tgtFaceTris.size())
2204 const label tgtTrii = tgtFaceTris[tgtFaceTrii];
2205 markedTriTris_.append(tgtTrii);
2206 triMarkedTris_[tgtTrii] = markedTriTris_.size() - 1;
2220 if (triMarkedTris_[tgtFaceTris[tgtFaceTrii]] != -1)
2226 if (triMarkedTris_[srcFaceTris[srcFaceTrii]] == -1)
break;
2232 && triMarkedTris_[tgtFaceTris[tgtFaceTrii]] == -1
2246 && triMarkedTris_[srcFaceTris[srcFaceTrii]] == -1
2257 forAll(markedTriTris_, markedTrii)
2259 const label trii = markedTriTris_[markedTrii];
2262 triMarkedTris_[trii] = -1;
2265 markedTriTris_.clear();
2269 template<
class SrcPatchType,
class TgtPatchType>
2273 const label patchFacei,
2274 const label otherPatchFacei,
2279 isSrc ? srcFaceTris_[patchFacei] : tgtFaceTris_[patchFacei];
2281 isSrc ? tgtFaceTris_[otherPatchFacei] : srcFaceTris_[otherPatchFacei];
2284 isSrc ? triTgtFace_ : triSrcFace_;
2288 const vector& patchFaceN =
2290 ? this->srcPatch_.faceNormals()[patchFacei]
2291 : this->tgtPatch_.faceNormals()[patchFacei];
2293 auto pointIntersectsPatchFace = [&]
2296 const label patchFacei,
2301 isSrc ? this->pointSrcPoints_ : this->pointTgtPoints_;
2303 isSrc ? this->pointSrcEdges_ : this->pointTgtEdges_;
2305 isSrc ? this->pointSrcFaces_ : this->pointTgtFaces_;
2307 const triFace patchFacePatchPoints
2309 this->patchFacePatchPoints(patchFacei, isSrc)
2311 const triFace patchFacePatchEdges
2313 this->patchFacePatchEdges(patchFacei, isSrc)
2319 patchFacePatchPoints,
2320 pointPatchPoints[pointi]
2324 patchFacePatchEdges,
2325 pointPatchEdges[pointi]
2327 || pointPatchFaces[pointi] == patchFacei;
2330 auto edgeIntersectsPatchFace = [&]
2333 const label patchFacei,
2337 const edge
e = edgePoints(edgei);
2339 pointIntersectsPatchFace(
e[0], patchFacei, isSrc)
2340 && pointIntersectsPatchFace(
e[1], patchFacei, isSrc);
2344 DynamicList<label> conformEdgeis;
2345 forAll(otherPatchFaceTris, otherPatchFaceTrii)
2347 const label trii = otherPatchFaceTris[otherPatchFaceTrii];
2349 forAll(triEdges_[trii], triEdgei)
2351 const label edgei = triEdges_[trii][triEdgei];
2354 edgeTris_[edgei][edgeTris_[edgei][0] == trii];
2356 const label otherPatchFacej =
2357 trij == -1 ? -1 : triOtherPatchFaces[trij];
2361 otherPatchFacei != otherPatchFacej
2362 && edgeIntersectsPatchFace(edgei, patchFacei, isSrc)
2365 conformEdgeis.append(edgei);
2371 auto isConformed = [&](
const label edgei)
2373 const edge
e = edgePoints(edgei);
2375 forAll(patchFaceTris, patchFaceTrii)
2377 const label trii = patchFaceTris[patchFaceTrii];
2379 forAll(triEdges_[trii], triEdgei)
2381 const label edgei = triEdges_[trii][triEdgei];
2383 if (edge::compare(
e, edgePoints(edgei)) != 0)
2394 forAll(conformEdgeis, conformj)
2396 if (!isConformed(conformEdgeis[conformj]))
2398 conformEdgeis[conformi] = conformEdgeis[conformj];
2402 conformEdgeis.resize(conformi);
2406 if (conformEdgeis.empty())
return true;
2409 auto nextConnectedPatchFaceTri = [&]
2412 const label patchFaceTrii0 = 0
2417 label patchFaceTrii = patchFaceTrii0;
2418 patchFaceTrii < patchFaceTris.size();
2422 const label trii = patchFaceTris[patchFaceTrii];
2424 if (
findIndex(triPoints(trii), pointi) != -1)
2426 return patchFaceTrii;
2435 auto trackToEdge = [&]
2450 const vector ab = t.b() - t.a();
2451 const vector ac = t.c() - t.a();
2452 const vector bc = t.c() - t.b();
2453 const scalar detA = (ab ^ ac) & patchFaceN;
2464 scalar lambdaByDetAH =
2465 !std::isnormal(detA) || detA < 0 ? vGreat : 1/detA;
2469 if (TDp[i] < - detA*small)
2471 const scalar lambdaByDetA = -
y[i]/TDp[i];
2473 if (0 <= lambdaByDetA && lambdaByDetA < lambdaByDetAH)
2476 lambdaByDetAH = lambdaByDetA;
2481 y += lambdaByDetAH*TDp;
2484 y.replace(i, i == iH ? 0 :
max(0,
y[i]));
2491 triEdgei = iH == -1 ? -1 : (iH + 1) % 3;
2499 if (triEdgei == -1)
return false;
2501 const label edgei = triEdges_[trii][triEdgei];
2503 if (edgePatchEdges(edgei) !=
labelPair(-1, -1))
return false;
2505 const label trij = edgeTris_[edgei][edgeTris_[edgei][0] == trii];
2507 if (trij == -1)
return false;
2509 if (triSrcFace_[trii] != triSrcFace_[trij])
return false;
2510 if (triTgtFace_[trii] != triTgtFace_[trij])
return false;
2520 scalar temp =
y.a();
2528 scalar temp =
y.c();
2535 inplaceRotate(
y, triEdgei - 1 + 3);
2537 inplaceRotate(
y, 1 - triEdgej + 3);
2540 triEdgei = triEdgej;
2549 forAll(conformEdgeis, conformi)
2551 const label edgei = conformEdgeis[conformi];
2555 if (isConformed(edgei))
continue;
2558 const edge
e = edgePoints(edgei);
2559 const label pointi0 =
e[0], pointi1 =
e[1];
2562 const label patchFaceTrii0 = nextConnectedPatchFaceTri(pointi0);
2563 const label patchFaceTrii1 = nextConnectedPatchFaceTri(pointi1);
2567 if (patchFaceTrii0 == -1 || patchFaceTrii1 == -1)
continue;
2571 DynamicList<label> routeTriis;
2572 DynamicList<label> routeEdgeis;
2573 label routePatchFaceTrii0 = -1;
2577 routeEdgeis.clear();
2579 routePatchFaceTrii0 =
2580 nextConnectedPatchFaceTri(pointi0, routePatchFaceTrii0 + 1);
2582 if (routePatchFaceTrii0 == -1)
break;
2584 label trii = patchFaceTris[routePatchFaceTrii0];
2585 label triEdgei = -1;
2589 forAll(patchFaceTris, iter)
2591 if (
findIndex(triPoints(trii), pointi0) != -1)
2594 routeEdgeis.clear();
2597 routeTriis.append(trii);
2599 if (
findIndex(triPoints(trii), pointi1) != -1)
break;
2601 trackToEdge(trii, triEdgei,
y, pointi1);
2603 if (triEdgei == -1)
break;
2605 routeEdgeis.append(triEdges_[trii][triEdgei]);
2607 if (!crossEdge(trii, triEdgei,
y))
break;
2610 if (
findIndex(triPoints(trii), pointi1) != -1)
break;
2614 if (routeEdgeis.size() == 0)
2618 if (this->debug > 1)
2621 <<
indent <<
"Failed to route edge " <<
e
2622 <<
" through the triangulation of "
2623 << (isSrc ?
"source" :
"target") <<
" face #"
2624 << patchFacei <<
endl;
2625 writePatchFace(patchFacei, isSrc);
2629 else if (routeEdgeis.size() == 1)
2632 flipEdge(routeEdgeis.first());
2645 DynamicList<label> leftPolyPointis, rightPolyPointis;
2646 DynamicList<label> leftPolyEdgeis, rightPolyEdgeis;
2647 DynamicList<label> leftPolyTriis, rightPolyTriis;
2650 leftPolyPointis.append(pointi0);
2651 rightPolyPointis.append(pointi0);
2655 const label trii = routeTriis.first();
2656 const label edgei1 = routeEdgeis.first();
2658 const label triEdgeiLeft = (triEdgei1 + 2) % 3;
2659 const label triEdgeiRight = (triEdgei1 + 1) % 3;
2660 leftPolyEdgeis.append(triEdges_[trii][triEdgeiLeft]);
2661 rightPolyEdgeis.append(triEdges_[trii][triEdgeiRight]);
2662 leftPolyTriis.append(trii);
2663 rightPolyTriis.append(trii);
2664 leftPolyPointis.append(triPoint(trii, triEdgei1));
2665 rightPolyPointis.append(triPoint(trii, triEdgeiRight));
2671 label routeTrii = 1;
2672 routeTrii < routeTriis.size() - 1;
2676 const label trii = routeTriis[routeTrii];
2677 const label edgei0 = routeEdgeis[routeTrii - 1];
2678 const label edgei1 = routeEdgeis[routeTrii];
2681 if ((triEdgei0 + 2) % 3 == triEdgei1)
2683 const label triEdgeiLeft = (triEdgei1 + 2) % 3;
2684 leftPolyEdgeis.append(triEdges_[trii][triEdgeiLeft]);
2685 leftPolyTriis.append(trii);
2686 leftPolyPointis.append(triPoint(trii, triEdgei1));
2690 const label triEdgeiRight = (triEdgei1 + 1) % 3;
2691 rightPolyEdgeis.append(triEdges_[trii][triEdgeiRight]);
2692 rightPolyTriis.append(trii);
2693 rightPolyPointis.append(triPoint(trii, triEdgeiRight));
2699 const label trii = routeTriis.last();
2700 const label edgei0 = routeEdgeis.last();
2702 const label triEdgeiLeft = (triEdgei0 + 1) % 3;
2703 const label triEdgeiRight = (triEdgei0 + 2) % 3;
2704 leftPolyEdgeis.append(triEdges_[trii][triEdgeiLeft]);
2705 rightPolyEdgeis.append(triEdges_[trii][triEdgeiRight]);
2706 leftPolyTriis.append(trii);
2707 rightPolyTriis.append(trii);
2708 leftPolyPointis.append(pointi1);
2709 rightPolyPointis.append(pointi1);
2714 auto disconnect = [&]
2722 const label edgei = edgeis[i];
2723 const label trii = triis[i];
2725 const label edgeTrii = edgeTris_[edgei][0] != trii;
2728 const label tempEdgei = newEdgei();
2729 triEdges_[trii][triEdgei] = tempEdgei;
2730 edgeTris_[tempEdgei][0] = trii;
2731 edgeTris_[edgei][edgeTrii] = -1;
2734 disconnect(leftPolyEdgeis, leftPolyTriis);
2735 disconnect(rightPolyEdgeis, rightPolyTriis);
2736 forAll(routeTriis, routeTrii)
2738 removeTri(routeTriis[routeTrii]);
2742 const label middleEdgei = newEdgei();
2743 leftPolyEdgeis.append(middleEdgei);
2744 rightPolyEdgeis.append(middleEdgei);
2747 SubList<label> subRightPolyPointis
2750 rightPolyPointis.size() - 1,
2760 DynamicList<label>& polyPointis,
2761 DynamicList<label>& polyEdgeis
2765 polyEdgeis.resize(2*polyPointis.size() - 3, -1);
2766 for (
label i = polyPointis.size(); i < polyEdgeis.size(); ++ i)
2768 polyEdgeis[i] = newEdgei();
2772 polygonTriangulate_.triangulate
2774 UIndirectList<point>(
points, polyPointis)
2778 forAll(polygonTriangulate_.triPoints(), trii)
2782 polygonTriangulate_.triPoints(trii, polyPointis),
2783 polygonTriangulate_.triEdges(trii, polyEdgeis),
2789 insert(leftPolyPointis, leftPolyEdgeis);
2790 insert(rightPolyPointis, rightPolyEdgeis);
2795 checkPatchFace(patchFacei, isSrc);
2801 template<
class SrcPatchType,
class TgtPatchType>
2805 const label srcFacei,
2806 const label tgtFacei
2810 conformPatchFaceTris(srcFacei, tgtFacei,
true)
2811 && conformPatchFaceTris(tgtFacei, srcFacei,
false);
2815 template<
class SrcPatchType,
class TgtPatchType>
2819 const label srcFacei,
2820 const label tgtFacei
2825 auto triIsIntersected = [&]
2828 const label otherPatchFacei,
2829 const triFace& otherPatchFacePatchPoints,
2830 const triFace& otherPatchFacePatchEdges,
2834 const labelList& pointOtherPatchPoints =
2835 isSrc ? this->pointTgtPoints_ : this->pointSrcPoints_;
2837 isSrc ? this->pointTgtEdges_ : this->pointSrcEdges_;
2839 isSrc ? this->pointTgtFaces_ : this->pointSrcFaces_;
2841 forAll(triPoints_[trii], triPointi)
2843 const label pointi = triPoint(trii, triPointi);
2850 otherPatchFacePatchPoints,
2851 pointOtherPatchPoints[pointi]
2856 otherPatchFacePatchEdges,
2857 pointOtherPatchEdges[pointi]
2860 && pointOtherPatchFaces[pointi] != otherPatchFacei
2873 auto getIntersectionPolygon = [&]
2875 const label patchFacei,
2876 const label otherPatchFacei,
2878 DynamicList<label>& triis,
2879 DynamicList<label>& edgeis
2883 isSrc ? srcFaceTris_[patchFacei] : tgtFaceTris_[patchFacei];
2885 isSrc ? triSrcFace_ : triTgtFace_;
2887 const triFace otherPatchFacePatchPoints
2889 patchFacePatchPoints(otherPatchFacei, !isSrc)
2891 const triFace otherPatchFacePatchEdges
2893 patchFacePatchEdges(otherPatchFacei, !isSrc)
2898 forAll(patchFaceTris, patchFaceTrii)
2900 const label trii = patchFaceTris[patchFaceTrii];
2907 otherPatchFacePatchPoints,
2908 otherPatchFacePatchEdges,
2917 if (trii0 == -1)
return;
2920 star::context starContext = star_.populate
2927 triPatchFaces[trii] == patchFacei
2932 otherPatchFacePatchPoints,
2933 otherPatchFacePatchEdges,
2950 edgeis.append(edgei);
2953 DynamicList<label> srcPolyTris, srcPolyEdges;
2954 DynamicList<label> tgtPolyTris, tgtPolyEdges;
2955 getIntersectionPolygon
2963 getIntersectionPolygon
2973 if (srcPolyEdges.size() == 0 && tgtPolyEdges.size() == 0)
2979 if (srcPolyEdges.size() && tgtPolyEdges.size())
2983 label tgtPolyEdgei0 = 0;
2984 forAll(tgtPolyEdges, tgtPolyEdgei)
2986 const edge srcE = edgePoints(srcPolyEdges[0]);
2987 const edge tgtE = edgePoints(tgtPolyEdges[tgtPolyEdgei]);
2989 if (edge::compare(srcE, tgtE) != 0)
2991 tgtPolyEdgei0 = tgtPolyEdgei;
3003 if (srcPolyEdges.size() == tgtPolyEdges.size())
3006 forAll(srcPolyEdges, polyEdgei)
3008 const edge srcE = edgePoints(srcPolyEdges[polyEdgei]);
3009 const edge tgtE = edgePoints(tgtPolyEdges[polyEdgei]);
3011 if (edge::compare(srcE, tgtE) == 0)
3024 if (this->debug > 1)
3027 <<
indent <<
"Failed to combine intersected parts of source "
3028 <<
"face #" << srcFacei <<
" and target face #" << tgtFacei
3030 writePatchFace(srcFacei,
true);
3031 writePatchFace(tgtFacei,
false);
3037 forAll(srcPolyTris, srcPolyTrii)
3039 const label srcTrii = srcPolyTris[srcPolyTrii];
3040 markedTriTris_.append(srcTrii);
3041 triMarkedTris_[srcTrii] = markedTriTris_.size() - 1;
3043 forAll(tgtPolyTris, tgtPolyTrii)
3045 const label tgtTrii = tgtPolyTris[tgtPolyTrii];
3046 markedTriTris_.append(tgtTrii);
3047 triMarkedTris_[tgtTrii] = markedTriTris_.size() - 1;
3058 forAll(srcPolyEdges, polyEdgei)
3060 const label srcEdgei = srcPolyEdges[polyEdgei];
3061 const label tgtEdgei = tgtPolyEdges[polyEdgei];
3063 if (srcEdgei == tgtEdgei)
continue;
3065 const label srcEdgeTrii =
3066 edgeTris_[srcEdgei][0] == -1
3067 || triMarkedTris_[edgeTris_[srcEdgei][0]] == -1
3068 || triSrcFace_[edgeTris_[srcEdgei][0]] == -1;
3069 const label tgtEdgeTrii =
3070 edgeTris_[tgtEdgei][0] == -1
3071 || triMarkedTris_[edgeTris_[tgtEdgei][0]] == -1
3072 || triTgtFace_[edgeTris_[tgtEdgei][0]] == -1;
3074 const label tgtTrii = edgeTris_[tgtEdgei][tgtEdgeTrii];
3075 const label srcTrij = edgeTris_[srcEdgei][!srcEdgeTrii];
3076 const label tgtTrij = edgeTris_[tgtEdgei][!tgtEdgeTrii];
3078 edgeTris_[srcEdgei][!srcEdgeTrii] = tgtTrii;
3079 edgeTris_[tgtEdgei][tgtEdgeTrii] = srcTrij;
3081 const label tgtTriEdgei =
findIndex(triEdges_[tgtTrii], tgtEdgei);
3082 triEdges_[tgtTrii][tgtTriEdgei] = srcEdgei;
3086 const label srcTriEdgej =
findIndex(triEdges_[srcTrij], srcEdgei);
3087 triEdges_[srcTrij][srcTriEdgej] = tgtEdgei;
3090 if (srcTrij != -1 && tgtTrij != -1)
3092 edgeFrontEdges_[tgtEdgei] = frontEdgeEdges_.size();
3093 frontEdgeEdges_.append(tgtEdgei);
3098 const label facei = this->faces().size();
3099 this->faces_.append(face(srcPolyEdges.size()));
3100 faceEdges_.append(
labelList(srcPolyEdges.size()));
3101 this->srcFaceFaces_[srcFacei].append(facei);
3102 this->tgtFaceFaces_[tgtFacei].append(facei);
3103 this->faceSrcFaces_.append(srcFacei);
3104 this->faceTgtFaces_.append(tgtFacei);
3105 forAll(srcPolyEdges, polyEdgei)
3107 const label srcEdgei = srcPolyEdges[polyEdgei];
3108 const label srcEdgeTrii =
3109 edgeTris_[srcEdgei][0] == -1
3110 || triMarkedTris_[edgeTris_[srcEdgei][0]] == -1
3111 || triSrcFace_[edgeTris_[srcEdgei][0]] == -1;
3113 const label srcTrii = edgeTris_[srcEdgei][srcEdgeTrii];
3114 const label srcTriEdgei =
findIndex(triEdges_[srcTrii], srcEdgei);
3116 this->faces_.last()[polyEdgei] =
3117 triEdgePoints(srcTrii, srcTriEdgei).start();
3119 const label tgtEdgei = tgtPolyEdges[polyEdgei];
3121 faceEdges_.last()[polyEdgei] = tgtEdgei;
3122 intersectEdgeFaces_[tgtEdgei][intersectEdgeFaces_[tgtEdgei][0] != -1] =
3127 forAll(markedTriTris_, candidateTrii)
3129 const label trii = markedTriTris_[candidateTrii];
3132 triMarkedTris_[trii] = -1;
3135 markedTriTris_.clear();
3138 checkPatchFace(srcFacei,
true);
3139 checkPatchFace(tgtFacei,
false);
3142 forAll(srcPolyTris, srcPolyTrii)
3144 removeTri(srcPolyTris[srcPolyTrii]);
3146 forAll(tgtPolyTris, tgtPolyTrii)
3148 removeTri(tgtPolyTris[tgtPolyTrii]);
3152 checkPatchFace(srcFacei,
true);
3153 checkPatchFace(tgtFacei,
false);
3156 forAll(tgtPolyEdges, polyEdgei)
3158 const label edgei = tgtPolyEdges[polyEdgei];
3160 const label trii0 = edgeTris_[edgei][0];
3161 const label trii1 = edgeTris_[edgei][1];
3163 const bool isFront =
3166 && (triSrcFace_[trii0] == -1) != (triSrcFace_[trii1] == -1);
3168 if (isFront && edgeFrontEdges_[edgei] == -1)
3170 edgeFrontEdges_[edgei] = frontEdgeEdges_.size();
3171 frontEdgeEdges_.append(edgei);
3174 if (!isFront && edgeFrontEdges_[edgei] != -1)
3176 frontEdgeEdges_[edgeFrontEdges_[edgei]] = -1;
3177 edgeFrontEdges_[edgei] = -1;
3182 checkPatchFace(srcFacei,
true);
3183 checkPatchFace(tgtFacei,
false);
3189 template<
class SrcPatchType,
class TgtPatchType>
3197 this->points_.clear();
3199 this->srcPointPoints_ = -1;
3200 this->tgtPointPoints_ = -1;
3201 this->pointSrcPoints_.clear();
3202 this->pointTgtPoints_.clear();
3204 forAll(this->srcEdgePoints_, srcEdgei)
3206 this->srcEdgePoints_[srcEdgei].clear();
3208 forAll(this->tgtEdgePoints_, tgtEdgei)
3210 this->tgtEdgePoints_[tgtEdgei].clear();
3212 this->pointSrcEdges_.clear();
3213 this->pointTgtEdges_.clear();
3215 this->pointSrcFaces_.clear();
3216 this->pointTgtFaces_.clear();
3218 this->faces_.clear();
3220 forAll(this->srcFaceFaces_, srcFacei)
3222 this->srcFaceFaces_[srcFacei].clear();
3224 forAll(this->tgtFaceFaces_, tgtFacei)
3226 this->tgtFaceFaces_[tgtFacei].clear();
3228 this->faceSrcFaces_.clear();
3229 this->faceTgtFaces_.clear();
3235 this->srcPatch_.nPoints() + this->tgtPatch_.nPoints();
3236 srcPoints_.resize(
nPoints, point::uniform(NaN));
3237 srcPointNormals_.resize(
nPoints, vector::uniform(NaN));
3238 tgtPoints_.resize(
nPoints, point::uniform(NaN));
3239 pointPoints_.resize(
nPoints, -1);
3240 this->pointSrcPoints_.resize(
nPoints, -1);
3241 this->pointTgtPoints_.resize(
nPoints, -1);
3242 this->pointSrcEdges_.resize(
nPoints, -1);
3243 this->pointTgtEdges_.resize(
nPoints, -1);
3244 this->pointSrcFaces_.resize(
nPoints, -1);
3245 this->pointTgtFaces_.resize(
nPoints, -1);
3246 forAll(this->srcPatch_.localPoints(), srcPointi)
3248 const label pointi = srcPointi;
3250 srcPoints_[pointi] = this->srcPatch_.localPoints()[srcPointi];
3251 tgtPoints_[pointi] = this->srcPatch_.localPoints()[srcPointi];
3252 srcPointNormals_[pointi] = srcPointNormals[srcPointi];
3253 pointPoints_[pointi] = pointi;
3254 this->srcPointPoints_[srcPointi] = pointi;
3255 this->pointSrcPoints_[pointi] = srcPointi;
3257 forAll(this->tgtPatch_.localPoints(), tgtPointi)
3259 const label pointi = this->srcPatch_.nPoints() + tgtPointi;
3261 srcPoints_[pointi] = this->tgtPatch_.localPoints()[tgtPointi];
3262 tgtPoints_[pointi] = this->tgtPatch_.localPoints()[tgtPointi];
3263 pointPoints_[pointi] = pointi;
3264 this->tgtPointPoints_[tgtPointi] = pointi;
3265 this->pointTgtPoints_[pointi] = tgtPointi;
3269 const label nEdges = this->srcPatch_.nEdges() + this->tgtPatch_.nEdges();
3270 edgeTris_.resize(nEdges,
labelPair(-1, -1));
3271 intersectEdgeFaces_.resize(nEdges,
labelPair(-1, -1));
3272 forAll(this->srcPatch_.faceEdges(), srcFacei)
3274 const label trii = srcFacei;
3276 forAll(this->srcPatch_.faceEdges()[srcFacei], srcFaceEdgei)
3278 const label srcEdgei =
3279 this->srcPatch_.faceEdges()[srcFacei][srcFaceEdgei];
3280 const label edgei = srcEdgei;
3282 const edge&
e = this->srcPatch_.edges()[srcEdgei];
3284 this->srcPatch_.localFaces()[srcFacei].faceEdge(srcFaceEdgei);
3286 edgeTris_[edgei][edge::compare(
e, fe) < 0] = trii;
3289 forAll(this->srcPatch_.edges(), srcEdgei)
3291 const edge&
e = this->srcPatch_.edges()[srcEdgei];
3293 this->srcEdgePoints_[srcEdgei].append(this->srcPointPoints_[
e[0]]);
3294 this->srcEdgePoints_[srcEdgei].append(this->srcPointPoints_[
e[1]]);
3296 forAll(this->tgtPatch_.faceEdges(), tgtFacei)
3298 const label trii = this->srcPatch_.size() + tgtFacei;
3300 forAll(this->tgtPatch_.faceEdges()[tgtFacei], tgtFaceEdgei)
3302 const label tgtEdgei =
3303 this->tgtPatch_.faceEdges()[tgtFacei][tgtFaceEdgei];
3304 const label edgei = this->srcPatch_.nEdges() + tgtEdgei;
3306 const edge&
e = this->tgtPatch_.edges()[tgtEdgei];
3308 this->tgtPatch_.localFaces()[tgtFacei].faceEdge(tgtFaceEdgei);
3310 edgeTris_[edgei][edge::compare(
e, fe) < 0] = trii;
3313 forAll(this->tgtPatch_.edges(), tgtEdgei)
3315 const edge&
e = this->tgtPatch_.edges()[tgtEdgei];
3317 this->tgtEdgePoints_[tgtEdgei].append(this->tgtPointPoints_[
e[0]]);
3318 this->tgtEdgePoints_[tgtEdgei].append(this->tgtPointPoints_[
e[1]]);
3322 const label nTris = this->srcPatch_.size() + this->tgtPatch_.size();
3323 triPoints_.resize(nTris);
3324 triEdges_.resize(nTris);
3325 triSrcFace_.resize(nTris, -1);
3326 triTgtFace_.resize(nTris, -1);
3327 forAll(this->srcPatch_.localFaces(), srcFacei)
3329 const label trii = srcFacei;
3331 forAll(this->srcPatch_.localFaces()[srcFacei], i)
3333 triPoints_[trii][i] = this->srcPatch_.localFaces()[srcFacei][i];
3334 triEdges_[trii][i] = this->srcPatch_.faceEdges()[srcFacei][i];
3336 triSrcFace_[trii] = srcFacei;
3337 srcFaceTris_[srcFacei].resize(1, trii);
3339 forAll(this->tgtPatch_.localFaces(), tgtFacei)
3341 const label trii = this->srcPatch_.size() + tgtFacei;
3343 forAll(this->tgtPatch_.localFaces()[tgtFacei], i)
3345 triPoints_[trii][i] =
3346 this->srcPatch_.nPoints()
3347 + this->tgtPatch_.localFaces()[tgtFacei][i];
3348 triEdges_[trii][i] =
3349 this->srcPatch_.nEdges()
3350 + this->tgtPatch_.faceEdges()[tgtFacei][i];
3352 triTgtFace_[trii] = tgtFacei;
3353 tgtFaceTris_[tgtFacei].resize(1, trii);
3357 removedEdges_.clear();
3358 removedTris_.clear();
3361 frontEdgeEdges_.clear();
3362 edgeFrontEdges_ = DynamicList<label>(edgeTris_.size(), -1);
3365 candidateTriTris_.clear();
3366 triCandidateTris_ = DynamicList<label>(triPoints_.size(), -1);
3369 markedTriTris_.clear();
3370 triMarkedTris_ = DynamicList<label>(triPoints_.size(), -1);
3372 checkPatchFaces(
true);
3373 checkPatchFaces(
false);
3377 template<
class SrcPatchType,
class TgtPatchType>
3388 labelList oldPointNewPoints(pointPoints_.size(), -1);
3390 forAll(pointPoints_, pointj)
3392 if (pointPoints_[pointj] == pointj)
3394 oldPointNewPoints[pointj] = pointi;
3395 srcPoints_[pointi] = srcPoints_[pointj];
3396 srcPointNormals_[pointi] = srcPointNormals_[pointj];
3397 tgtPoints_[pointi] = tgtPoints_[pointj];
3398 pointPoints_[pointi] = pointi;
3399 this->pointSrcPoints_[pointi] = this->pointSrcPoints_[pointj];
3400 this->pointTgtPoints_[pointi] = this->pointTgtPoints_[pointj];
3401 this->pointSrcEdges_[pointi] = this->pointSrcEdges_[pointj];
3402 this->pointTgtEdges_[pointi] = this->pointTgtEdges_[pointj];
3403 this->pointSrcFaces_[pointi] = this->pointSrcFaces_[pointj];
3404 this->pointTgtFaces_[pointi] = this->pointTgtFaces_[pointj];
3408 srcPoints_.resize(pointi);
3409 srcPointNormals_.resize(pointi);
3410 tgtPoints_.resize(pointi);
3411 pointPoints_.resize(pointi);
3412 this->pointSrcPoints_.resize(pointi);
3413 this->pointTgtPoints_.resize(pointi);
3414 this->pointSrcEdges_.resize(pointi);
3415 this->pointTgtEdges_.resize(pointi);
3416 this->pointSrcFaces_.resize(pointi);
3417 this->pointTgtFaces_.resize(pointi);
3420 labelList oldEdgeNewEdges(edgeTris_.size(), -1);
3427 || intersectEdgeFaces_[edgej] !=
labelPair(-1, -1)
3430 oldEdgeNewEdges[edgej] = edgei;
3431 edgeTris_[edgei] = edgeTris_[edgej];
3432 intersectEdgeFaces_[edgei] = intersectEdgeFaces_[edgej];
3433 edgeFrontEdges_[edgei] = edgeFrontEdges_[edgej];
3437 edgeTris_.resize(edgei);
3438 intersectEdgeFaces_.resize(edgei);
3439 edgeFrontEdges_.resize(edgei);
3442 labelList oldTriNewTris(triPoints_.size(), -1);
3446 if (triPoints_[trij] != FixedList<label, 3>({-1, -1, -1}))
3448 oldTriNewTris[trij] = trii;
3449 triPoints_[trii] = triPoints_[trij];
3450 triEdges_[trii] = triEdges_[trij];
3451 triSrcFace_[trii] = triSrcFace_[trij];
3452 triTgtFace_[trii] = triTgtFace_[trij];
3456 triPoints_.resize(trii);
3457 triEdges_.resize(trii);
3458 triSrcFace_.resize(trii);
3459 triTgtFace_.resize(trii);
3476 removedEdges_.clear();
3477 removedTris_.clear();
3480 candidateTriTris_.clear();
3481 triCandidateTris_ = DynamicList<label>(triPoints_.size(), -1);
3484 markedTriTris_.clear();
3485 triMarkedTris_ = DynamicList<label>(triPoints_.size(), -1);
3487 checkPatchFaces(
true);
3488 checkPatchFaces(
false);
3492 template<
class SrcPatchType,
class TgtPatchType>
3499 const label nFaces = this->faces_.size();
3501 this->faces_.resize(nFaces + triPoints_.size());
3502 faceEdges_.resize(nFaces + triPoints_.size());
3503 this->faceSrcFaces_.resize(nFaces + triPoints_.size());
3504 this->faceTgtFaces_.resize(nFaces + triPoints_.size());
3508 const label facei = nFaces + trii;
3510 if (triSrcFace_[trii] != -1)
3512 this->faces_[facei] = triPoints(trii);
3513 faceEdges_[facei] =
labelList(triEdges_[trii]);
3514 this->srcFaceFaces_[triSrcFace_[trii]].append(facei);
3515 this->faceSrcFaces_[facei] = triSrcFace_[trii];
3516 this->faceTgtFaces_[facei] = -1;
3520 this->faces_[facei] = triPoints(trii).reverseFace();
3522 this->tgtFaceFaces_[triTgtFace_[trii]].append(facei);
3523 this->faceSrcFaces_[facei] = -1;
3524 this->faceTgtFaces_[facei] = triTgtFace_[trii];
3528 nonIntersectEdgeFaces_.resize(edgeTris_.size());
3531 forAll(edgeTris_[edgei], edgeTrii)
3533 nonIntersectEdgeFaces_[edgei][edgeTrii] =
3534 edgeTris_[edgei][edgeTrii] + nFaces;
3538 checkPatchFaces(
true);
3539 checkPatchFaces(
false);
3543 template<
class SrcPatchType,
class TgtPatchType>
3553 nFaces < this->faces_.size()
3554 && this->faceSrcFaces_[nFaces] != -1
3555 && this->faceTgtFaces_[nFaces] != -1
3561 this->faces_.resize(nFaces);
3562 faceEdges_.resize(nFaces);
3563 this->faceSrcFaces_.resize(nFaces);
3564 this->faceTgtFaces_.resize(nFaces);
3568 DynamicList<label>& faceis =
3569 triSrcFace_[trii] != -1
3570 ? this->srcFaceFaces_[triSrcFace_[trii]]
3571 : this->tgtFaceFaces_[triTgtFace_[trii]];
3574 while (
n < faceis.size() && faceis[
n] < nFaces)
3582 nonIntersectEdgeFaces_.clear();
3584 checkPatchFaces(
true);
3585 checkPatchFaces(
false);
3589 template<
class SrcPatchType,
class TgtPatchType>
3592 if (this->debug > 2)
3597 this->report(
name(writei_));
3602 const fileName frontFileName =
3603 type() +
"_front_" +
name(writei_) +
".vtk";
3606 DynamicList<point> writePoints(frontEdgeEdges_.size()*2);
3607 DynamicList<labelPair> writeLines(frontEdgeEdges_.size()*2);
3608 forAll(frontEdgeEdges_, frontEdgei)
3610 const label edgei = frontEdgeEdges_[frontEdgei];
3612 if (edgei == -1)
continue;
3614 const edge
e = edgePoints(edgei);
3615 writePoints.append(tgtPoints_[
e.start()]);
3616 writePoints.append(tgtPoints_[
e.end()]);
3618 const label i = writePoints.size() - 2;
3638 template<
class SrcPatchType,
class TgtPatchType>
3641 const label patchFacei,
3647 word(isSrc ?
"src" :
"tgt") +
"Face_" +
name(patchFacei) +
".obj"
3652 word(isSrc ?
"src" :
"tgt") +
"FaceTris_" +
name(patchFacei) +
".obj"
3656 <<
" and patch face triangulation to " << tos.
name()
3659 forAll(patchFacePatchPoints(patchFacei, isSrc), patchFacePatchPointi)
3661 const label patchPointi =
3662 patchFacePatchPoints(patchFacei, isSrc)[patchFacePatchPointi];
3665 ? this->srcPatch_.localPoints()[patchPointi]
3666 : this->tgtPatch_.localPoints()[patchPointi];
3667 os <<
"v " <<
p.x() <<
' ' <<
p.y() <<
' ' <<
p.z() <<
nl;
3669 os <<
"f 1 2 3" <<
nl;
3672 isSrc ? srcFaceTris_[patchFacei] : tgtFaceTris_[patchFacei];
3674 forAll(patchFaceTris, patchFaceTrii)
3676 const label trii = patchFaceTris[patchFaceTrii];
3678 Info<<
indent <<
"tri #" << trii <<
" points=" << triPoints(trii)
3679 <<
" edges=" << triEdges_[trii] <<
endl;
3681 forAll(triPoints_[trii], triPointi)
3683 const label pointi = triPoint(trii, triPointi);
3684 const point&
p = isSrc ? srcPoints_[pointi] : tgtPoints_[pointi];
3685 tos <<
"v " <<
p.x() <<
' ' <<
p.y() <<
' ' <<
p.z() <<
nl;
3688 forAll(triPoints_[trii], triPointi)
3690 tos <<
" " << 1 + 3*patchFaceTrii + triPointi;
3701 template<
class SrcPatchType,
class TgtPatchType>
3704 const SrcPatchType& srcPatch,
3705 const TgtPatchType& tgtPatch,
3706 const scalar snapTol
3713 template<
class SrcPatchType,
class TgtPatchType>
3716 const SrcPatchType& srcPatch,
3718 const TgtPatchType& tgtPatch,
3719 const scalar snapTol
3726 tgtPoints_(this->points_),
3730 intersectEdgeFaces_(),
3731 nonIntersectEdgeFaces_(),
3737 srcFaceTris_(srcPatch.size()),
3738 tgtFaceTris_(tgtPatch.size()),
3748 candidateTriTris_(),
3749 triCandidateTris_(),
3754 polygonTriangulate_(),
3763 << this->
srcPatch_.size() <<
" source tri faces and "
3805 srcFaceSpheres[srcFacei] =
3809 {srcFace[0], srcFace[1], srcFace[2], -1},
3812 srcFaceSpheres[srcFacei].second() *= 1 + snapTol;
3817 tgtFaceSpheres[tgtFacei] =
3821 {tgtFace[0], tgtFace[1], tgtFace[2], -1},
3824 tgtFaceSpheres[tgtFacei].second() *= 1 + snapTol;
3830 12*(this->
srcPatch_.size() + this->tgtPatch_.size())
3834 label nIntersections = 0, nIntersectionFailures = 0;
3837 auto intersect = [&](
const label srcFacei,
const label tgtFacei)
3849 forAll(srcLocalFaces[srcFacei], srcFacePointi)
3851 const label srcPointi =
3852 srcLocalFaces[srcFacei][srcFacePointi];
3854 forAll(srcPointFaces[srcPointi], srcPointFacei)
3856 const label srcFacej =
3857 srcPointFaces[srcPointi][srcPointFacei];
3859 forAll(tgtLocalFaces[tgtFacei], tgtFacePointi)
3861 const label tgtPointi =
3862 tgtLocalFaces[tgtFacei][tgtFacePointi];
3864 forAll(tgtPointFaces[tgtPointi], tgtPointFacei)
3866 const label tgtFacej =
3867 tgtPointFaces[tgtPointi][tgtPointFacei];
3869 const point& srcC = srcFaceSpheres[srcFacej].
first();
3870 const scalar srcR = srcFaceSpheres[srcFacej].second();
3871 const point& tgtC = tgtFaceSpheres[tgtFacej].
first();
3872 const scalar tgtR = tgtFaceSpheres[tgtFacej].second();
3877 && !srcFaceTgtFaceSnaps.
found({srcFacej, tgtFacej})
3880 srcFaceTgtFaceSnaps.
insert({srcFacej, tgtFacej});
3881 snapPatchFaceTris(srcFacej, tgtFacej, snapTol);
3888 intersectPatchFaceTris(srcFacei, tgtFacei);
3892 const bool conformFailure = !conformPatchFaceTris(srcFacei, tgtFacei);
3894 const bool combineFailure = !combinePatchFaceTris(srcFacei, tgtFacei);
3897 nIntersectionFailures += conformFailure || combineFailure;
3923 class findIntersectExcludingOp
3934 findIntersectExcludingOp
3941 excludingIndices_(hitIndices)
3951 point& intersectionPoint
3954 if (excludingIndices_.
found(index))
3977 initialise(srcPointNormals);
3996 const point& srcP = srcPoints_[pointi];
3997 const vector& srcN = srcPointNormals_[pointi];
4001 const label srcEdgei =
4002 this->
srcPatch_.pointEdges()[srcPointi][srcPointEdgei];
4009 srcL /= this->
srcPatch_.pointEdges()[srcPointi].size();
4020 findIntersectExcludingOp(tgtTree, tgtFaceis)
4023 if (!hit.
hit())
break;
4029 if (tgtFaceis.
empty())
continue;
4035 const label srcFacei =
4036 this->
srcPatch_.pointFaces()[srcPointi][srcPointFacei];
4040 intersect(srcFacei, tgtFaceiIter.key());
4042 if (frontEdgeEdges_.
size())
break;
4045 if (frontEdgeEdges_.
size())
break;
4049 while (frontEdgeEdges_.
size())
4053 if (edgei == -1)
continue;
4055 edgeFrontEdges_[edgei] = -1;
4057 label srcTrii = edgeTris_[edgei][0];
4058 label tgtTrii = edgeTris_[edgei][1];
4060 if (triSrcFace_[srcTrii] == -1)
4062 Swap(srcTrii, tgtTrii);
4065 intersect(triSrcFace_[srcTrii], triTgtFace_[tgtTrii]);
4076 if (nIntersectionFailures)
4078 Info<<
indent <<
"*** Topology could not be generated in "
4079 << nIntersectionFailures <<
"/" << nIntersections <<
" cases"
4080 <<
endl <<
indent <<
" The intersection may be incomplete"
4093 template<
class SrcPatchType,
class TgtPatchType>
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Functions for constructing bounding spheres of lists of points.
T remove()
Remove and return the top element.
A HashTable with keys but without contents.
bool insert(const Key &key)
Insert a new entry.
bool empty() const
Return true if the hash table is empty.
bool found(const Key &) const
Return true if hashedEntry is found in table.
virtual const fileName & name() const
Return the name of the stream.
void size(const label)
Override size to be inconsistent with allocated storage.
Base class for patch intersections. Provides storage and access to the intersection points and faces ...
const SrcPatchType & srcPatch_
Reference to the source patch.
const TgtPatchType & tgtPatch_
Reference to the target patch.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
label index() const
Return index.
bool hit() const
Is there a hit.
Patch intersection based on triangular faces. Intersects and combines two triangulated patches increm...
virtual ~TriPatchIntersection()
Destructor.
TriPatchIntersection(const SrcPatchType &srcPatch, const TgtPatchType &tgtPatch, const scalar snapTol)
Construct from a source and a target patch.
const DynamicList< labelList > & faceEdges() const
...
virtual word type() const
T & first()
Return the first element of the list.
Starts timing CPU usage and return elapsed time from start.
double cpuTimeIncrement() const
Return CPU time (in seconds) since last call to cpuTimeIncrement()
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A class for handling file names.
word name() const
Return file name (part beyond last /)
Non-pointer based hierarchical recursive searching.
DynamicList< label > pointTgtFaces_
The intersection points' target faces, or -1 if the point.
DynamicField< point > points_
The intersection points.
DynamicList< label > pointTgtPoints_
The intersection points' corresponding target points, or -1.
void report(const word &writeSuffix=word::null)
Report properties of the intersection process.
DynamicList< label > pointSrcPoints_
The intersection points' corresponding source points, or -1.
DynamicList< face > faces_
The intersection faces.
DynamicList< label > pointTgtEdges_
The intersection points' target edges, or -1 if the point.
Standard boundBox + extra functionality for use in octree.
treeBoundBox extend(const scalar s) const
Return asymmetrically extended bounding box, with guaranteed.
Encapsulation of data needed to search on PrimitivePatches.
A triangular face using a FixedList of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volVectorField vectorField(fieldObject, mesh)
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar e
Elementary charge.
barycentric2D srcPointTgtTriIntersection(const point &srcP, const vector &srcN, const FixedList< point, 3 > &tgtPs)
Calculate the intersection of a projected source point with a target.
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.
Type tgtTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcPointTgtTriIntersection to interpolate.
Type srcTriInterpolate(const barycentric2D &y, const FixedList< Type, 3 > &tgtPsis)
Use the coordinates obtained from srcTriTgtPointIntersection to interpolate.
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.
void insert(const scalar, DynamicList< floatScalar > &)
Append scalar to given DynamicList.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Pair< label > labelPair
Label pair.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
ListType reverseList(const ListType &list)
Reverse a list. First element becomes last element etc.
void inplaceReverseList(ListType &list)
Inplace reversal of a list using Swap.
void inplaceRotateList(ListType< DataType > &list, label n)
Inplace reversal of a list using the Reversal Block Swapping algorithm.
vectorField pointField
pointField is a vectorField.
static const Identity< scalar > I
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
vector point
Point is a vector.
Vector< scalar > vector
A scalar version of the templated Vector.
BarycentricTensor2D< scalar > barycentricTensor2D
A scalar version of the templated BarycentricTensor2D.
List< labelList > labelListList
A List of labelList.
dimensioned< scalar > mag(const dimensioned< Type > &)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Tuple2< point, scalar > trivialBoundSphere(const PointField &ps, const FixedList< label, 4 > &pis, const label nPs)
Compute a bounding sphere of four points or less.
triangle< point, const point & > triPointRef
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
Cmpt cmptSum(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
UList< label > labelUList
Ostream & indent(Ostream &os)
Indent stream.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
#define forAllStarFaces(star, starFacei, facei)
#define forAllStarEdges(star, i, starEdgei, edgei)
Functions with which to perform an intersection of a pair of triangles; the source and target....