34 template<
class tetPo
intsOp>
35 void Foam::tetOverlapVolume::tetTetOverlap
37 const tetPoints& tetA,
38 const tetPoints& tetB,
47 tetPointRef::storeOp inside(insideTets, nInside);
48 tetPointRef::storeOp cutInside(cutInsideTets, nCutInside);
49 tetPointRef::dummyOp outside;
53 static FixedList<vector, 4> tetAFaceAreas;
54 static FixedList<scalar, 4> tetAMag2FaceAreas;
56 for (label facei = 0; facei < 4; ++facei)
58 tetAFaceAreas[facei] = -tetATet.tri(facei).areaNormal();
59 tetAMag2FaceAreas[facei] =
magSqr(tetAFaceAreas[facei]);
60 if (tetAMag2FaceAreas[facei] < ROOTVSMALL)
66 static FixedList<vector, 4> tetBFaceAreas;
67 static FixedList<scalar, 4> tetBMag2FaceAreas;
69 for (label facei = 0; facei < 4; ++facei)
71 tetBFaceAreas[facei] = -tetBTet.tri(facei).areaNormal();
72 tetBMag2FaceAreas[facei] =
magSqr(tetBFaceAreas[facei]);
73 if (tetBMag2FaceAreas[facei] < ROOTVSMALL)
83 plane pl0(tetBTet.tri(0).a(),
n,
false);
85 tetA.tet().sliceWithPlane(pl0, cutInside, outside);
95 plane pl1(tetBTet.tri(1).a(),
n,
false);
98 for (label i = 0; i < nCutInside; i++)
101 t.sliceWithPlane(pl1, inside, outside);
112 plane pl2(tetBTet.tri(2).a(),
n,
false);
115 for (label i = 0; i < nInside; i++)
118 t.sliceWithPlane(pl2, cutInside, outside);
129 plane pl3(tetBTet.tri(3).a(),
n,
false);
130 for (label i = 0; i < nCutInside; i++)
133 t.sliceWithPlane(pl3, insideOp, outside);
139 template<
class tetsOp>
140 void Foam::tetOverlapVolume::cellCellOverlapMinDecomp
142 const primitiveMesh& meshA,
145 const primitiveMesh& meshB,
147 const treeBoundBox& cellBbB,
148 tetsOp& combineTetsOp
151 const cell& cFacesA = meshA.cells()[cellAI];
152 const point& ccA = meshA.cellCentres()[cellAI];
154 const cell& cFacesB = meshB.cells()[cellBI];
155 const point& ccB = meshB.cellCentres()[cellBI];
159 label faceAI = cFacesA[cFA];
161 const face& fA = meshA.faces()[faceAI];
162 const treeBoundBox pyrA = pyrBb(meshA.points(), fA, ccA);
163 if (!pyrA.overlaps(cellBbB))
168 bool ownA = (meshA.faceOwner()[faceAI] == cellAI);
170 label tetBasePtAI = 0;
172 const point& tetBasePtA = meshA.points()[fA[tetBasePtAI]];
174 for (label tetPtI = 1; tetPtI < fA.size() - 1; tetPtI++)
176 label facePtAI = (tetPtI + tetBasePtAI) % fA.size();
177 label otherFacePtAI = fA.fcIndex(facePtAI);
185 pt1I = fA[otherFacePtAI];
189 pt0I = fA[otherFacePtAI];
197 meshA.points()[pt0I],
201 const treeBoundBox tetAbb(tetA.bounds());
206 label faceBI = cFacesB[cFB];
208 const face& fB = meshB.faces()[faceBI];
209 const treeBoundBox pyrB = pyrBb(meshB.points(), fB, ccB);
210 if (!pyrB.overlaps(pyrA))
215 bool ownB = (meshB.faceOwner()[faceBI] == cellBI);
217 label tetBasePtBI = 0;
219 const point& tetBasePtB = meshB.points()[fB[tetBasePtBI]];
221 for (label tetPtI = 1; tetPtI < fB.size() - 1; tetPtI++)
223 label facePtBI = (tetPtI + tetBasePtBI) % fB.size();
224 label otherFacePtBI = fB.fcIndex(facePtBI);
232 pt1I = fB[otherFacePtBI];
236 pt0I = fB[otherFacePtBI];
244 meshB.points()[pt0I],
248 const treeBoundBox tetBbb(tetB.bounds());
250 if (!tetBbb.overlaps(tetAbb))
255 if (combineTetsOp(tetA, tetB))
tetrahedron< point, const point & > tetPointRef
A tetrahedron using referred points.
dimensionedScalar sqrt(const dimensionedScalar &ds)
FixedList< tetPoints, 200 > tetIntersectionList
Storage type for tets originating from intersecting tets.
#define forAll(list, i)
Loop across all elements in list.
vector point
Point is a vector.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)