35 return sphere.
second() >= 0;
39 template<
class Po
intField>
44 const FixedList<label, 4>& pis,
51 return Tuple2<point, scalar>(point::uniform(NaN), -vGreat);
54 return Tuple2<point, scalar>(ps[pis[0]], 0);
58 return Tuple2<point, scalar>
60 (ps[pis[0]] + ps[pis[1]])/2,
61 mag(ps[pis[0]] - ps[pis[1]])/2
91 <<
"Cannot compute the intersect bounding sphere of more than "
93 return Tuple2<point, scalar>(point::uniform(NaN), NaN);
98 template<
class Po
intField>
103 const FixedList<label, 4>& pis,
107 static const scalar tol = 1 + 2*
sqrt(small*rootSmall);
121 for (
label i = 0; i < 3; ++ i)
123 const point& p0 = ps[pis[i]];
124 const point& p1 = ps[pis[(i + 1) % 3]];
125 const point& pOpp = ps[pis[(i + 2) % 3]];
127 const point c = (p0 + p1)/2;
128 const scalar rSqr =
magSqr(p0 - p1)/4;
130 if (
magSqr(pOpp -
c) <= tol*rSqr)
142 static const FixedList<labelPair, 6> p01s =
143 {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};
144 static const FixedList<labelPair, 6> pOpp01s =
145 {{2, 3}, {1, 3}, {1, 2}, {0, 3}, {0, 2}, {0, 1}};
146 for (
label i = 0; i < 6; ++ i)
148 const point& p0 = ps[pis[p01s[i].first()]];
149 const point& p1 = ps[pis[p01s[i].second()]];
150 const point& pOpp0 = ps[pis[pOpp01s[i].first()]];
151 const point& pOpp1 = ps[pis[pOpp01s[i].second()]];
153 const point c = (p0 + p1)/2;
154 const scalar rSqr =
magSqr(p0 - p1)/4;
159 &&
magSqr(pOpp1 -
c) <= tol*rSqr
167 point minC = point::uniform(NaN);
168 scalar minR = vGreat;
169 for (
label i = 0; i < 4; ++ i)
174 ps[pis[(i + 1) % 4]],
177 const point& pOpp = ps[pis[(i + 3) % 4]];
179 const Tuple2<point, scalar> circ = tri.circumCircle();
180 const point&
c = circ.first();
181 const scalar r = circ.second();
183 if (
magSqr(pOpp -
c) <= tol*
sqr(r) && r < minR)
191 return Tuple2<point, scalar>(minC, minR);
199 <<
"Cannot compute the trivial bounding sphere of more than "
201 return Tuple2<point, scalar>(point::uniform(NaN), NaN);
209 template<
class Po
intField>
215 FixedList<label, 4>& boundaryPis,
216 const label nBoundaryPs
219 static const scalar tol = 1 + 2*
sqrt(small*rootSmall);
221 Tuple2<point, scalar> sphere;
223 if (nBoundaryPs != 0)
228 if (nBoundaryPs == 4)
233 for (
label i = 0; i < nPs; ++ i)
237 (nBoundaryPs == 0 && i == 0)
238 || (
magSqr(ps[pis[i]] - sphere.first()) > tol*
sqr(sphere.second()))
241 boundaryPis[nBoundaryPs] = pis[i];
247 Swap(pis[0], pis[i]);
255 template<
class Po
intField>
261 static const FixedList<label, 4> pis({0, 1, 2, 3});
268 FixedList<label, 4> boundaryPis({-1, -1, -1, -1});
274 template<
class Po
intField>
280 static const FixedList<label, 4> pis({0, 1, 2, 3});
286 randomGenerator(0).permute(pis);
287 FixedList<label, 4> boundaryPis({-1, -1, -1, -1});
Functions for constructing bounding spheres of lists of points.
A 2-tuple for storing two objects of different types.
const Type2 & second() const
Return second.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar c
Speed of light in a vacuum.
bool isValidBoundSphere(const Tuple2< point, scalar > &sphere)
Return whether or not the given sphere is valid.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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)
vector point
Point is a vector.
Tuple2< point, scalar > intersectBoundSphere(const PointField &ps, const FixedList< label, 4 > &pis, const label nPs)
Compute a sphere of four points or less where every point intersects the.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
Tuple2< point, scalar > trivialBoundSphere(const PointField &ps, const FixedList< label, 4 > &pis, const label nPs)
Compute a bounding sphere of four points or less.
GeometricField< Type, pointPatchField, pointMesh > PointField
triangle< point, const point & > triPointRef
Tuple2< point, scalar > weizlBoundSphere(const PointField &ps, List< label > &pis, const label nPs, FixedList< label, 4 > &boundaryPis, const label nBoundaryPs)
Compute a bounding sphere for an arbitrary number of points recursively.
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
dimensioned< scalar > magSqr(const dimensioned< Type > &)
Tuple2< point, scalar > boundSphere(const PointField &ps, randomGenerator &rndGen)
Compute a bounding sphere for an arbitrary number of points, and given an.
tetrahedron< point, const point & > tetPointRef
randomGenerator rndGen(653213)