30 template<
class AboveOp,
class BelowOp>
33 const FixedList<point, 3>& tri,
34 const FixedList<scalar, 3>& level,
35 const AboveOp& aboveOp,
36 const BelowOp& belowOp
41 if (level[0] >= 0 && level[1] >= 0 && level[2] >= 0)
43 return aboveOp(tri) + belowOp();
45 if (level[0] <= 0 && level[1] <= 0 && level[2] <= 0)
47 return aboveOp() + belowOp(tri);
52 FixedList<label, 3> indices({0, 1, 2});
54 for (i = 0; i < 3; ++ i)
56 if (level[(i + 1)%3]*level[(i + 2)%3] >= 0)
58 Swap(indices[0], indices[i]);
65 <<
"The number of tri vertices above the level set should always " 72 Swap(indices[1], indices[2]);
76 const FixedList<point, 3> p =
triReorder(tri, indices);
77 const FixedList<scalar, 3> l =
triReorder(level, indices);
83 for (
label i = 0; i < 2; ++ i)
85 f[i] = l[0]/(l[0] - l[i+1]);
98 template<
class AboveOp,
class BelowOp>
101 const FixedList<point, 3>& tri,
103 const AboveOp& aboveOp,
104 const BelowOp& belowOp
108 FixedList<scalar, 3> level;
109 for (
label i = 0; i < 3; ++ i)
111 level[i] = (tri[i] - p.refPoint()) & p.normal();
115 return triCut(tri, level, aboveOp, belowOp);
119 template<
class AboveOp,
class BelowOp>
122 const FixedList<point, 4>& tet,
123 const FixedList<scalar, 4>& level,
124 const AboveOp& aboveOp,
125 const BelowOp& belowOp
130 scalar levelMin = VGREAT, levelMax = - VGREAT;
131 for (
label i = 0; i < 4; ++ i)
133 levelMin =
min(levelMin, level[i]);
134 levelMax =
max(levelMax, level[i]);
138 return aboveOp(tet) + belowOp();
142 return aboveOp() + belowOp(tet);
149 FixedList<label, 4> indices({0, 1, 2, 3});
150 bool signChange =
false;
154 while (i < j && level[indices[i]] > 0)
158 while (j > i && level[indices[j]] <= 0)
166 Swap(indices[i], indices[j]);
167 signChange = !signChange;
178 for (
label i = 0; i < 2; ++ i)
180 Swap(indices[i], indices[3-i]);
187 Swap(indices[2], indices[3]);
191 const FixedList<point, 4> p =
tetReorder(tet, indices);
192 const FixedList<scalar, 4> l =
tetReorder(level, indices);
200 FixedList<scalar, 3>
f;
201 for (
label i = 0; i < 3; ++ i)
203 f[i] = l[0]/(l[0] - l[i+1]);
217 FixedList<scalar, 4>
f;
218 for (
label i = 0; i < 2; ++ i)
220 for (
label j = 0; j < 2; ++ j)
222 f[2*i+j] = l[i]/(l[i] - l[j+2]);
236 <<
"The number of tet vertices above the level set should always be " 239 return aboveOp() + belowOp();
243 template<
class AboveOp,
class BelowOp>
246 const FixedList<point, 4>& tet,
248 const AboveOp& aboveOp,
249 const BelowOp& belowOp
253 FixedList<scalar, 4> level;
254 for (
label i = 0; i < 4; ++ i)
256 level[i] = (tet[i] - p.refPoint()) & p.normal();
260 return tetCut(tet, level, aboveOp, belowOp);
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Trait to determine the result of the addition of two operations.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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. Templated.
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 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)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
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)