33 template<
class AboveOp,
class BelowOp>
36 const FixedList<point, 3>& tri,
37 const FixedList<scalar, 3>& level,
38 const AboveOp& aboveOp,
39 const BelowOp& belowOp
44 if (level[0] >= 0 && level[1] >= 0 && level[2] >= 0)
46 return aboveOp(tri) + belowOp();
48 if (level[0] <= 0 && level[1] <= 0 && level[2] <= 0)
50 return aboveOp() + belowOp(tri);
55 FixedList<label, 3> indices({0, 1, 2});
57 for (i = 0; i < 3; ++i)
59 if (level[(i + 1)%3]*level[(i + 2)%3] >= 0)
61 std::swap(indices[0], indices[i]);
68 <<
"The number of tri vertices above the level set should always " 75 std::swap(indices[1], indices[2]);
79 const FixedList<point, 3>
p =
triReorder(tri, indices);
80 const FixedList<scalar, 3> l =
triReorder(level, indices);
86 for (label i = 0; i < 2; ++i)
88 f[i] = l[0]/(l[0] - l[i+1]);
101 template<
class AboveOp,
class BelowOp>
104 const FixedList<point, 3>& tri,
106 const AboveOp& aboveOp,
107 const BelowOp& belowOp
111 FixedList<scalar, 3> level;
112 for (label i = 0; i < 3; ++i)
114 level[i] = pln.signedDistance(tri[i]);
118 return triCut(tri, level, aboveOp, belowOp);
122 template<
class AboveOp,
class BelowOp>
125 const FixedList<point, 4>& tet,
126 const FixedList<scalar, 4>& level,
127 const AboveOp& aboveOp,
128 const BelowOp& belowOp
133 scalar levelMin = VGREAT, levelMax = - VGREAT;
134 for (label i = 0; i < 4; ++i)
136 levelMin =
min(levelMin, level[i]);
137 levelMax =
max(levelMax, level[i]);
141 return aboveOp(tet) + belowOp();
145 return aboveOp() + belowOp(tet);
152 FixedList<label, 4> indices({0, 1, 2, 3});
153 bool signChange =
false;
157 while (i < j && level[indices[i]] > 0)
161 while (j > i && level[indices[j]] <= 0)
169 std::swap(indices[i], indices[j]);
170 signChange = !signChange;
181 for (label i = 0; i < 2; ++i)
183 std::swap(indices[i], indices[3-i]);
190 std::swap(indices[2], indices[3]);
194 const FixedList<point, 4>
p =
tetReorder(tet, indices);
195 const FixedList<scalar, 4> l =
tetReorder(level, indices);
203 FixedList<scalar, 3>
f;
204 for (label i = 0; i < 3; ++i)
206 f[i] = l[0]/(l[0] - l[i+1]);
220 FixedList<scalar, 4>
f;
221 for (label i = 0; i < 2; ++i)
223 for (label j = 0; j < 2; ++j)
225 f[2*i+j] = l[i]/(l[i] - l[j+2]);
239 <<
"The number of tet vertices above the level set should always be " 242 return aboveOp() + belowOp();
246 template<
class AboveOp,
class BelowOp>
249 const FixedList<point, 4>& tet,
251 const AboveOp& aboveOp,
252 const BelowOp& belowOp
256 FixedList<scalar, 4> level;
257 for (label i = 0; i < 4; ++i)
259 level[i] = pln.signedDistance(tet[i]);
263 return tetCut(tet, level, aboveOp, belowOp);
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Trait to determine the result of the addition of two operations.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
cut::opAddResult< AboveOp, BelowOp >::type tetCut(const FixedList< point, 4 > &tet, const FixedList< scalar, 4 > &level, const AboveOp &aboveOp, const BelowOp &belowOp)
As triCut, but for a tetrahedron.
const cut::uniformOp< Type > & tetCutPrism0(const cut::uniformOp< Type > &x, const FixedList< scalar, 3 > &)
Modify a uniform operation for cutting prism0 from a tet (does nothing)
const cut::uniformOp< Type > & triCutTri(const cut::uniformOp< Type > &x, const Pair< scalar > &)
Modify a uniform operation for cutting a tri from a tri (does nothing)
cut::opAddResult< AboveOp, BelowOp >::type triCut(const FixedList< point, 3 > &tri, const FixedList< scalar, 3 > &level, const AboveOp &aboveOp, const BelowOp &belowOp)
Cut a triangle along the zero plane defined by the given levels.
const cut::uniformOp< Type > & tetCutPrism23(const cut::uniformOp< Type > &x, const FixedList< scalar, 4 > &)
Modify a uniform operation for cutting prism23 from a tet (does nothing)
const cut::uniformOp< Type > & triCutQuad(const cut::uniformOp< Type > &x, const Pair< scalar > &)
Modify a uniform operation for cutting a quad from a tri (does nothing)
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Functions for cutting triangles and tetrahedra. Generic operations are applied to each half of a cut...
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const cut::uniformOp< Type > & tetCutPrism01(const cut::uniformOp< Type > &x, const FixedList< scalar, 4 > &)
Modify a uniform operation for cutting prism01 from a tet (does nothing)
const cut::uniformOp< Type > & tetReorder(const cut::uniformOp< Type > &x, const FixedList< label, 4 > &)
Modify a uniform operation for reordering a tet (does nothing)
const cut::uniformOp< Type > & triReorder(const cut::uniformOp< Type > &x, const FixedList< label, 3 > &)
Modify a uniform operation for reordering a tri (does nothing)
const cut::uniformOp< Type > & tetCutTet(const cut::uniformOp< Type > &x, const FixedList< scalar, 3 > &)
Modify a uniform operation for cutting a tet from a tet (does nothing)