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())
156 (max_.x() < min_.x())
157 || (max_.y() < min_.y())
158 || (max_.z() < min_.z())
195 return 0.5 * (min_ + max_);
201 return (max_ - min_);
207 return min_.dist(max_);
213 return min_.distSqr(max_);
245 scalar best = ROOTVGREAT;
247 for (
direction dir = 0; dir < vector::nComponents; ++dir)
249 const scalar dist = (max_[dir] - min_[dir]);
250 if (dist < best && dist > 0)
267 for (
direction dir = 0; dir < vector::nComponents; ++dir)
269 const scalar dist = (max_[dir] - min_[dir]);
285 for (
direction dir = 0; dir < vector::nComponents; ++dir)
287 const scalar dist = (max_[dir] - min_[dir]);
304 min_ = invertedBox.min();
305 max_ = invertedBox.max();
402 minA.x() <= maxB.x() && minB.x() <= maxA.x()
403 && minA.y() <= maxB.y() && minB.y() <= maxA.y()
404 && minA.z() <= maxB.z() && minB.z() <= maxA.z()
411 const point& corner0,
412 const point& corner1,
414 const scalar radiusSqr
421 for (
direction dir = 0; dir < vector::nComponents; ++dir)
423 const scalar d0 = corner0[dir] - centre[dir];
424 const scalar d1 = corner1[dir] - centre[dir];
426 if ((d0 > 0) != (d1 > 0))
435 if (distSqr > radiusSqr)
448 return box_box_overlaps(min_, max_, bb.
min(), bb.
max());
455 const scalar radiusSqr
458 return box_sphere_overlaps(min_, max_, centre, radiusSqr);
466 min_.x() <= pt.x() && pt.x() <= max_.x()
467 && min_.y() <= pt.y() && pt.y() <= max_.y()
468 && min_.z() <= pt.z() && pt.z() <= max_.z()
475 return contains(bb.
min()) && contains(bb.
max());
483 min_.x() < pt.x() && pt.x() < max_.x()
484 && min_.y() < pt.y() && pt.y() < max_.y()
485 && 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.
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &f1)
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...
Represents 0/1 range or concept. Used for tagged dispatch or clamping.
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.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
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.
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)
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...