mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge commit 'bundle/home' into olesenm
This commit is contained in:
@ -27,18 +27,34 @@ License
|
||||
#include "boundBox.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::boundBox Foam::boundBox::greatBox
|
||||
(
|
||||
point(-VGREAT, -VGREAT, -VGREAT),
|
||||
point(VGREAT, VGREAT, VGREAT)
|
||||
);
|
||||
|
||||
|
||||
const Foam::boundBox Foam::boundBox::invertedBox
|
||||
(
|
||||
point(VGREAT, VGREAT, VGREAT),
|
||||
point(-VGREAT, -VGREAT, -VGREAT)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
|
||||
:
|
||||
min_(vector::zero),
|
||||
max_(vector::zero)
|
||||
min_(point::zero),
|
||||
max_(point::zero)
|
||||
{
|
||||
if (points.size() == 0)
|
||||
{
|
||||
if (Pstream::parRun() && doReduce)
|
||||
{
|
||||
// Use values which get overwritten by reduce minOp,maxOp below
|
||||
// Use values that get overwritten by reduce minOp, maxOp below
|
||||
min_ = point(VGREAT, VGREAT, VGREAT);
|
||||
max_ = point(-VGREAT, -VGREAT, -VGREAT);
|
||||
}
|
||||
@ -89,7 +105,6 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const boundBox&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -111,7 +126,6 @@ Foam::Istream& Foam::operator>>(Istream& is, boundBox& bb)
|
||||
|
||||
// Check state of Istream
|
||||
is.check("Istream& operator>>(Istream&, boundBox&)");
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ Ostream& operator<<(Ostream& os, const boundBox& b);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class boundBox Declaration
|
||||
Class boundBox Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class boundBox
|
||||
@ -61,13 +61,22 @@ class boundBox
|
||||
|
||||
public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- A very large boundBox: min/max == -/+ VGREAT
|
||||
static const boundBox greatBox;
|
||||
|
||||
//- A very large inverted boundBox: min/max == +/- VGREAT
|
||||
static const boundBox invertedBox;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null setting points to zero
|
||||
//- Construct null, setting points to zero
|
||||
boundBox()
|
||||
:
|
||||
min_(vector::zero),
|
||||
max_(vector::zero)
|
||||
min_(point::zero),
|
||||
max_(point::zero)
|
||||
{}
|
||||
|
||||
//- Construct from components
|
||||
@ -77,8 +86,8 @@ public:
|
||||
max_(max)
|
||||
{}
|
||||
|
||||
//- Construct as the bounding box of the given pointField. Does
|
||||
// parallel communication (doReduce = true)
|
||||
//- Construct as the bounding box of the given pointField.
|
||||
// Does parallel communication (doReduce = true)
|
||||
boundBox(const pointField& points, const bool doReduce = true);
|
||||
|
||||
//- Construct from Istream
|
||||
@ -117,39 +126,26 @@ public:
|
||||
|
||||
// Query
|
||||
|
||||
//- Intersects other boundingbox?
|
||||
//- Intersects other boundingBox?
|
||||
bool overlaps(const boundBox& bb) const
|
||||
{
|
||||
if
|
||||
return
|
||||
(
|
||||
(min_.x() <= bb.max().x()) &&
|
||||
(min_.y() <= bb.max().y()) &&
|
||||
(min_.z() <= bb.max().z()) &&
|
||||
|
||||
(max_.x() >= bb.min().x()) &&
|
||||
(max_.y() >= bb.min().y()) &&
|
||||
(max_.z() >= bb.min().z())
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
min_.x() <= bb.max().x() && max_.x() >= bb.min().x()
|
||||
&& min_.y() <= bb.max().y() && max_.y() >= bb.min().y()
|
||||
&& min_.z() <= bb.max().z() && max_.z() >= bb.min().z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//- Contains a point?
|
||||
bool contains(const point& pt) const
|
||||
{
|
||||
return
|
||||
pt.x() >= min().x()
|
||||
&& pt.y() >= min().y()
|
||||
&& pt.z() >= min().z()
|
||||
&& pt.x() <= max().x()
|
||||
&& pt.y() <= max().y()
|
||||
&& pt.z() <= max().z();
|
||||
(
|
||||
pt.x() >= min().x() && pt.x() <= max().x()
|
||||
&& pt.y() >= min().y() && pt.y() <= max().y()
|
||||
&& pt.z() >= min().z() && pt.z() <= max().z()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -173,7 +169,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- Specify data associated with boundBox type is contiguous
|
||||
//- Specify data associated with boundBox type are contiguous
|
||||
template<>
|
||||
inline bool contiguous<boundBox>() {return contiguous<point>();}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user