30 template<
class Po
int,
class AboveOp,
class BelowOp>
33 const FixedList<Point, 3>& tri,
34 const FixedList<scalar, 3>& level,
35 const AboveOp& aboveOp,
36 const BelowOp& belowOp
40 if (level[0] == 0 && level[1] == 0 && level[2] == 0)
42 return aboveOp() + 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 Swap(indices[0], indices[i]);
68 <<
"The number of tri vertices above the level set should always " 75 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] = (tri[i] - p.refPoint()) & p.normal();
118 return triCut(tri, level, aboveOp, belowOp);
122 template<
class Po
int,
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]);
139 if (levelMin == 0 && levelMax == 0)
141 return aboveOp() + belowOp();
145 return aboveOp(tet) + belowOp();
149 return aboveOp() + belowOp(tet);
156 FixedList<label, 4> indices({0, 1, 2, 3});
157 bool signChange =
false;
161 while (i < j && level[indices[i]] > 0)
165 while (j > i && level[indices[j]] <= 0)
173 Swap(indices[i], indices[j]);
174 signChange = !signChange;
185 for (
label i = 0; i < 2; ++ i)
187 Swap(indices[i], indices[3-i]);
194 Swap(indices[2], indices[3]);
198 const FixedList<Point, 4> p =
tetReorder(tet, indices);
199 const FixedList<scalar, 4> l =
tetReorder(level, indices);
207 FixedList<scalar, 3>
f;
208 for (
label i = 0; i < 3; ++ i)
210 f[i] = l[0]/(l[0] - l[i+1]);
224 FixedList<scalar, 4>
f;
225 for (
label i = 0; i < 2; ++ i)
227 for (
label j = 0; j < 2; ++ j)
229 f[2*i+j] = l[i]/(l[i] - l[j+2]);
243 <<
"The number of tet vertices above the level set should always be " 246 return aboveOp() + belowOp();
250 template<
class AboveOp,
class BelowOp>
253 const FixedList<point, 4>& tet,
255 const AboveOp& aboveOp,
256 const BelowOp& belowOp
260 FixedList<scalar, 4> level;
261 for (
label i = 0; i < 4; ++ i)
263 level[i] = (tet[i] - p.refPoint()) & p.normal();
267 return tetCut(tet, level, aboveOp, belowOp);
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > 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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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)
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)
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.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
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)
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.