49 return point(max_.x(), min_.y(), min_.z());
56 return point(max_.x(), max_.y(), min_.z());
63 return point(min_.x(), max_.y(), min_.z());
70 return point(min_.x(), min_.y(), max_.z());
77 return point(max_.x(), min_.y(), max_.z());
88 inline Foam::point Foam::boundBox::hexCorner<7>()
const 91 return point(min_.x(), max_.y(), max_.z());
98 template<Foam::direction CornerNumber>
101 static_assert(CornerNumber < 8,
"Corner index [0..7]");
110 min_(invertedBox.
min()),
111 max_(invertedBox.
max())
149 (max_.x() < min_.x())
150 || (max_.y() < min_.y())
151 || (max_.z() < min_.z())
188 return 0.5 * (min_ + max_);
194 return (max_ - min_);
200 return min_.dist(max_);
206 return min_.distSqr(max_);
238 scalar best = ROOTVGREAT;
240 for (
direction dir = 0; dir < vector::nComponents; ++dir)
242 const scalar dist = (max_[dir] - min_[dir]);
243 if (dist < best && dist > 0)
260 for (
direction dir = 0; dir < vector::nComponents; ++dir)
262 const scalar dist = (max_[dir] - min_[dir]);
278 for (
direction dir = 0; dir < vector::nComponents; ++dir)
280 const scalar dist = (max_[dir] - min_[dir]);
297 min_ = invertedBox.min();
298 max_ = invertedBox.max();
388 minA.x() <= maxB.x() && minB.x() <= maxA.x()
389 && minA.y() <= maxB.y() && minB.y() <= maxA.y()
390 && minA.z() <= maxB.z() && minB.z() <= maxA.z()
397 const point& corner0,
398 const point& corner1,
400 const scalar radiusSqr
407 for (
direction dir = 0; dir < vector::nComponents; ++dir)
409 const scalar d0 = corner0[dir] - centre[dir];
410 const scalar d1 = corner1[dir] - centre[dir];
412 if ((d0 > 0) != (d1 > 0))
421 if (distSqr > radiusSqr)
434 return box_box_overlaps(min_, max_, bb.
min(), bb.
max());
441 const scalar radiusSqr
444 return box_sphere_overlaps(min_, max_, centre, radiusSqr);
452 min_.x() <= pt.x() && pt.x() <= max_.x()
453 && min_.y() <= pt.y() && pt.y() <= max_.y()
454 && min_.z() <= pt.z() && pt.z() <= max_.z()
461 return contains(bb.
min()) && contains(bb.
max());
469 min_.x() < pt.x() && pt.x() < max_.x()
470 && min_.y() < pt.y() && pt.y() < max_.y()
471 && min_.z() < pt.z() && pt.z() < max_.z()
boundBox()
Default construct: an inverted bounding box.
static bool box_box_overlaps(const point &minA, const point &maxA, const point &minB, const point &maxB)
Test for overlap of box and box (inclusive check)
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Cmpt cmptProduct(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
point hexCorner() const
Return corner point [0..7] corresponding to a 'hex' cell.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool contains(const point &pt) const
Contains point? (inside or on edge)
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
bool empty() const
Bounding box is inverted, contains no points.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
T & first()
Access first element of the list, position [0].
int nDim() const
Count the number of positive, non-zero dimensions.
A bounding box defined in terms of min/max extrema points.
const point & min() const noexcept
Minimum describing the bounding box.
scalar avgDim() const
Average length/height/width dimension.
scalar magSqr() const
The magnitude/length squared of bounding box diagonal.
const point & max() const noexcept
Maximum describing the bounding box.
void add(const boundBox &bb)
Extend to include the second box.
direction minDir() const
Direction (X/Y/Z) of the smallest span (for empty box: 0)
Istream & operator>>(Istream &, directionInfo &)
scalar mag() const
The magnitude/length of the bounding box diagonal.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
vector point
Point is a vector.
bool good() const
Bounding box is non-inverted.
vector span() const
The bounding box span (from minimum to maximum)
scalar volume() const
The volume of the bound box.
void reset()
Reset to an inverted box.
direction maxDir() const
Direction (X/Y/Z) of the largest span (for empty box: 0)
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
scalar maxDim() const
Largest length/height/width dimension.
A class for managing temporary objects.
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
point centre() const
The centre (midpoint) of the bounding box.
bool overlaps(const boundBox &bb) const
Overlaps/touches boundingBox?
void grow(const scalar delta)
Expand box by adjusting min/max by specified amount in each dimension.
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
scalar minDim() const
Smallest length/height/width dimension.
bool containsInside(const point &pt) const
Contains point? (inside only)
static bool box_sphere_overlaps(const point &corner0, const point &corner1, const point ¢re, const scalar radiusSqr)
Test for overlap of box and boundingSphere (centre + sqr(radius))
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)