48#ifndef Foam_boundBox_H
49#define Foam_boundBox_H
65template<
class T>
class MinMax;
100 const point& corner0,
101 const point& corner1,
103 const scalar radiusSqr
221 inline bool empty()
const;
248 inline scalar
mag() const;
251 inline scalar
magSqr() const;
254 inline scalar
volume() const;
257 inline scalar
minDim() const;
260 inline scalar
maxDim() const;
263 inline scalar
avgDim() const;
278 inline
int nDim() const;
324 inline void add(
const Pair<point>&
points);
327 inline void add(
const UList<point>&
points);
330 inline void add(
const tmp<pointField>& tpoints);
334 void add(
const FixedList<point, N>&
points);
341 const UList<point>&
points,
342 const FixedList<label, N>& indices
349 template<
class IntContainer>
352 const UList<point>&
points,
353 const IntContainer& indices
364 inline void inflate(
const scalar factor);
384 void reduce(
int communicator);
416 const scalar radiusSqr
444 template<
class IntContainer>
448 const IntContainer& indices
467 template<
class IntContainer>
471 const IntContainer& indices
526 return (a.
min() ==
b.min() && a.
max() ==
b.max());
541 || (!(
b.min() < a.
min()) && a.
max() <
b.max())
571 #include "boundBox.txx"
A 1D vector of objects of type <T> with a fixed length <N>.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A min/max value pair with additional methods. In addition to conveniently storing values,...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
An ordered pair of two objects of type <T> with first() and second() elements.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
A bounding box defined in terms of min/max extrema points.
boundBox(const boundBox &bb, bool doReduce)
Copy construct with specified global reduction.
bool containsInside(const point &pt) const
Contains point? (inside only).
int nDim() const
Count the number of positive, non-zero dimensions.
static boundBox returnReduce(const boundBox &bb)
Perform a reduction on a copy and return the result, using UPstream::worldComm.
point faceCentre(const direction facei) const
Face centre of given face index.
static const Foam::faceList & hexFaces()
The boundBox faces as a hexCell, using hexCorner points. Same as hexCell::modelFaces().
const point & max() const noexcept
Maximum describing the bounding box.
friend Ostream & operator<<(Ostream &os, const boundBox &bb)
void grow(const scalar delta)
Expand box by adjusting min/max by specified amount in each dimension.
bool contains(const UList< point > &points, const FixedList< label, N > &indices) const
Contains all of the (subsetted) points? (inside or on edge).
bool valid() const
Bounding box is non-inverted - same as good().
void operator+=(const boundBox &bb)
Extend box to include the second box, as per the add() method.
bool overlaps(const boundBox &bb) const
Overlaps/touches boundingBox?
void reduce()
Inplace parallel reduction of min/max values, using UPstream::worldComm.
directionBit
Bits used for (x/y/z) directional encoding.
@ XDIR
1: x-direction. Same as (1 << vector::X)
@ ZDIR
4: z-direction. Same as (1 << vector::Z)
@ YDIR
2: y-direction. Same as (1 << vector::Y)
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
tmp< pointField > points() const
Corner points in an order corresponding to a 'hex' cell.
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)).
static boundBox returnReduce(const boundBox &bb, int communicator)
Perform a reduction on a copy and return the result, using the specified communicator.
direction minDir() const
Direction (X/Y/Z) of the smallest span (for empty box: 0).
bool containsAny(const UList< point > &points, const FixedList< label, N > &indices) const
Contains any of the (subsetted) points? (inside or on edge).
const point & min() const noexcept
Minimum describing the bounding box.
boundBox & operator=(const boundBox &)=default
Copy assignment.
bool contains(const point &pt) const
Contains point? (inside or on edge).
scalar volume() const
The volume of the bound box.
static const boundBox & null() noexcept
The null boundBox is the same as an inverted box.
void add(const UList< point > &points, const FixedList< label, N > &indices)
Extend to include a (subsetted) point field.
bool empty() const
Bounding box is inverted, contains no points.
void add(const UList< point > &points, const IntContainer &indices)
Extend to include a (subsetted) point field.
boundBox(const UList< point > &points, const labelUList &indices, bool doReduce=true)
Construct bounding box as an indirect subset of the points.
void add(const boundBox &bb)
Extend to include the second box.
tmp< pointField > hexCorners() const
Corner points in an order corresponding to a 'hex' cell.
tmp< pointField > faceCentres() const
Face midpoints.
direction maxDir() const
Direction (X/Y/Z) of the largest span (for empty box: 0).
void add(const FixedList< point, N > &points)
Extend to include the points.
void reduce(int communicator)
Inplace parallel reduction of min/max values, using the specified communicator.
point midpoint() const
Identical to centre().
friend Istream & operator>>(Istream &is, boundBox &bb)
bool containsAny(const UList< point > &points, const IntContainer &indices) const
Contains any of the (subsetted) points? (inside or on edge).
bool contains(const UList< point > &points) const
Contains all points? (inside or on edge).
void inflate(Random &rndGen, const scalar factor)
Expand box slightly by expanding all dimensions with factor*span*(random 0-1) and guarantees factor*m...
void inflate(Random &r, const scalar factor, const scalar delta)
As per two parameter version but with additional grow() by given amount in each dimension.
scalar minDim() const
Smallest length/height/width dimension.
void operator&=(const boundBox &bb)
Restrict min/max to union with other box.
scalar mag() const
The magnitude/length of the bounding box diagonal.
boundBox(const tmp< pointField > &tpoints, bool doReduce=true)
Construct as the bounding box of the given temporary pointField.
static const boundBox greatBox
A large boundBox: min/max == -/+ ROOTVGREAT.
point nearest(const point &p) const
Return the nearest point on the boundBox to the supplied point.
scalar avgDim() const
Average length/height/width dimension.
boundBox()
Default construct: an inverted bounding box.
boundBox(const UList< point > &points, bool doReduce=true)
Construct as the bounding box of the given points.
bool good() const
Bounding box is non-inverted.
void clear()
Same as reset() - reset to an inverted box.
static constexpr label nFaces() noexcept
Number of faces for boundBox and HEX.
boundBox(const boundBox &)=default
Copy construct.
bool contains(const UList< point > &points, const IntContainer &indices) const
Contains all of the (subsetted) points? (inside or on edge).
bool intersects(const plane &pln) const
Does plane intersect this bounding box.
void reset()
Reset to an inverted box.
boundBox(const UList< point > &points, const FixedList< label, N > &indices, bool doReduce=true)
Construct bounding box as an indirect subset of the points.
scalar magSqr() const
The magnitude/length squared of bounding box diagonal.
static constexpr label nEdges() noexcept
Number of edges for boundBox and HEX.
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
bool intersects(const triPointRef &tri) const
Does triangle intersect this bounding box or is contained within this bounding box.
static constexpr label nPoints() noexcept
Number of points for boundBox and HEX.
bool intersect(const boundBox &bb)
Deprecated(2022-10) - use 'operator&=' to avoid confusion with other intersects() methods.
point hexCorner() const
Return corner point [0..7] corresponding to a 'hex' cell.
vector span() const
The bounding box span (from minimum to maximum).
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).
point centre() const
The centre (midpoint) of the bounding box.
bool containsAny(const UList< point > &points) const
Contains any of the points? (inside or on edge).
scalar maxDim() const
Largest length/height/width dimension.
static const FixedList< vector, 6 > faceNormals
The unit normal per face.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
A class for managing temporary objects.
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.
OBJstream os(runTime.globalPath()/outputName)
bool operator!=(const eddy &a, const eddy &b)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
bool operator<=(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A same or older than B.
bool operator>=(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A same or newer than B.
List< face > faceList
List of faces.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Istream & operator>>(Istream &, directionInfo &)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
vector point
Point is a vector.
bool operator<(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A older than B.
triangle< point, const point & > triPointRef
A triangle using referred points.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
bool operator>(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A newer than B.
#define FOAM_DEPRECATED_FOR(since, replacement)
A template class to specify if a data type is composed solely of Foam::scalar elements.
A template class to specify that a data type can be considered as being contiguous in memory.