mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
added static data boundBox::greatBox and boundBox::invertedBox
- boundBox::invertedBox is useful for initializing our own calculations - NOTE treeBoundBox::greatBox is still in place, since it uses GREAT instead of VGREAT. If this is only historical, we can drop it.
This commit is contained in:
@ -109,7 +109,7 @@ Foam::label Foam::checkTopology
|
||||
{
|
||||
Info<< " Number of regions: " << rs.nRegions() << " (OK)."
|
||||
<< endl;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -214,7 +214,7 @@ Foam::label Foam::checkTopology
|
||||
const pointField& pts = pp.points();
|
||||
const labelList& mp = pp.meshPoints();
|
||||
|
||||
boundBox bb(vector::zero, vector::zero);
|
||||
boundBox bb; // zero-sized
|
||||
if (returnReduce(mp.size(), sumOp<label>()) > 0)
|
||||
{
|
||||
bb.min() = pts[mp[0]];
|
||||
|
||||
@ -273,7 +273,7 @@ autoPtr<mapPolyMesh> mergeSharedPoints
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
@ -418,11 +418,7 @@ int main(int argc, char *argv[])
|
||||
// Read point on individual processors to determine merge tolerance
|
||||
// (otherwise single cell domains might give problems)
|
||||
|
||||
boundBox bb
|
||||
(
|
||||
point(GREAT, GREAT, GREAT),
|
||||
point(-GREAT, -GREAT, -GREAT)
|
||||
);
|
||||
boundBox bb = boundBox::invertedBox;
|
||||
|
||||
for (label procI = 0; procI < nProcs; procI++)
|
||||
{
|
||||
|
||||
@ -27,24 +27,40 @@ 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("boundBox::boundBox(const pointField& points)")
|
||||
WarningIn("boundBox::boundBox(const pointField&)")
|
||||
<< "Cannot find bounding box for zero sized pointField, "
|
||||
"returning zero"
|
||||
<< endl;
|
||||
@ -98,7 +114,6 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
|
||||
|
||||
// Check state of Ostream
|
||||
os.check("Ostream& operator<<(Ostream&, const boundBox&)");
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -120,7 +135,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>();}
|
||||
|
||||
|
||||
@ -96,11 +96,7 @@ Foam::scalar Foam::autoHexMeshDriver::getMergeDistance(const scalar mergeTol)
|
||||
//)
|
||||
//{
|
||||
// // Determine outside point.
|
||||
// boundBox overallBb
|
||||
// (
|
||||
// point(GREAT, GREAT, GREAT),
|
||||
// point(-GREAT, -GREAT, -GREAT)
|
||||
// );
|
||||
// boundBox overallBb = boundBox::invertedBox;
|
||||
//
|
||||
// bool hasSurface = false;
|
||||
//
|
||||
|
||||
@ -158,11 +158,7 @@ void Foam::shellSurfaces::setAndCheckLevels
|
||||
void Foam::shellSurfaces::orient()
|
||||
{
|
||||
// Determine outside point.
|
||||
boundBox overallBb
|
||||
(
|
||||
point(GREAT, GREAT, GREAT),
|
||||
point(-GREAT, -GREAT, -GREAT)
|
||||
);
|
||||
boundBox overallBb = boundBox::invertedBox;
|
||||
|
||||
bool hasSurface = false;
|
||||
|
||||
|
||||
@ -110,8 +110,10 @@ Foam::treeBoundBox::treeBoundBox(const UList<point>& points)
|
||||
{
|
||||
if (points.size() == 0)
|
||||
{
|
||||
WarningIn("treeBoundBox::treeBoundBox(const UList<point>&)")
|
||||
<< "cannot find bounding box for zero sized pointField"
|
||||
WarningIn
|
||||
(
|
||||
"treeBoundBox::treeBoundBox(const UList<point>&)"
|
||||
) << "cannot find bounding box for zero-sized pointField"
|
||||
<< "returning zero" << endl;
|
||||
|
||||
return;
|
||||
@ -132,17 +134,18 @@ Foam::treeBoundBox::treeBoundBox(const UList<point>& points)
|
||||
Foam::treeBoundBox::treeBoundBox
|
||||
(
|
||||
const UList<point>& points,
|
||||
const labelList& meshPoints
|
||||
const UList<label>& meshPoints
|
||||
)
|
||||
:
|
||||
boundBox()
|
||||
{
|
||||
if (meshPoints.size() == 0)
|
||||
if (points.size() == 0 || meshPoints.size() == 0)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"treeBoundBox::treeBoundBox(const UList<point>&, const labelList)"
|
||||
) << "cannot find bounding box for zero sized pointField"
|
||||
"treeBoundBox::treeBoundBox"
|
||||
"(const UList<point>&, const UList<label>&)"
|
||||
) << "cannot find bounding box for zero-sized pointField"
|
||||
<< "returning zero" << endl;
|
||||
|
||||
return;
|
||||
|
||||
@ -87,6 +87,7 @@ public:
|
||||
|
||||
// Static data members
|
||||
|
||||
//- As per boundBox::greatBox, but with GREAT instead of VGREAT
|
||||
static const treeBoundBox greatBox;
|
||||
|
||||
//- Bits used for octant/point coding. Every octant/corner point
|
||||
@ -171,7 +172,7 @@ public:
|
||||
treeBoundBox(const UList<point>& points);
|
||||
|
||||
//- Construct as subset of points
|
||||
treeBoundBox(const UList<point>&, const labelList& meshPoints);
|
||||
treeBoundBox(const UList<point>&, const UList<label>& meshPoints);
|
||||
|
||||
//- Construct from Istream
|
||||
treeBoundBox(Istream&);
|
||||
|
||||
@ -27,29 +27,21 @@ License
|
||||
#include "treeBoundBox.H"
|
||||
#include "Random.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct null setting points to zero
|
||||
inline treeBoundBox::treeBoundBox()
|
||||
inline Foam::treeBoundBox::treeBoundBox()
|
||||
:
|
||||
boundBox()
|
||||
{}
|
||||
|
||||
|
||||
// Construct from components
|
||||
inline treeBoundBox::treeBoundBox(const point& min, const point& max)
|
||||
inline Foam::treeBoundBox::treeBoundBox(const point& min, const point& max)
|
||||
:
|
||||
boundBox(min, max)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from components
|
||||
inline treeBoundBox::treeBoundBox(const boundBox& bb)
|
||||
inline Foam::treeBoundBox::treeBoundBox(const boundBox& bb)
|
||||
:
|
||||
boundBox(bb)
|
||||
{}
|
||||
@ -57,7 +49,7 @@ inline treeBoundBox::treeBoundBox(const boundBox& bb)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline scalar treeBoundBox::minDim() const
|
||||
inline Foam::scalar Foam::treeBoundBox::minDim() const
|
||||
{
|
||||
return ::Foam::min
|
||||
(
|
||||
@ -71,7 +63,7 @@ inline scalar treeBoundBox::minDim() const
|
||||
}
|
||||
|
||||
|
||||
inline scalar treeBoundBox::maxDim() const
|
||||
inline Foam::scalar Foam::treeBoundBox::maxDim() const
|
||||
{
|
||||
return ::Foam::max
|
||||
(
|
||||
@ -85,7 +77,7 @@ inline scalar treeBoundBox::maxDim() const
|
||||
}
|
||||
|
||||
|
||||
inline scalar treeBoundBox::avgDim() const
|
||||
inline Foam::scalar Foam::treeBoundBox::avgDim() const
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -96,19 +88,19 @@ inline scalar treeBoundBox::avgDim() const
|
||||
}
|
||||
|
||||
|
||||
inline scalar treeBoundBox::typDim() const
|
||||
inline Foam::scalar Foam::treeBoundBox::typDim() const
|
||||
{
|
||||
return avgDim();
|
||||
}
|
||||
|
||||
|
||||
inline point treeBoundBox::mid() const
|
||||
inline Foam::point Foam::treeBoundBox::mid() const
|
||||
{
|
||||
return 0.5*(min() + max());
|
||||
}
|
||||
|
||||
|
||||
inline point treeBoundBox::corner(const direction octant) const
|
||||
inline Foam::point Foam::treeBoundBox::corner(const direction octant) const
|
||||
{
|
||||
return point
|
||||
(
|
||||
@ -119,7 +111,7 @@ inline point treeBoundBox::corner(const direction octant) const
|
||||
}
|
||||
|
||||
// Returns octant in which sample resides. Reverse of subBbox.
|
||||
inline direction treeBoundBox::subOctant(const point& sample) const
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant(const point& sample) const
|
||||
{
|
||||
point mid = 0.5*(max() + min());
|
||||
|
||||
@ -146,7 +138,7 @@ inline direction treeBoundBox::subOctant(const point& sample) const
|
||||
|
||||
// Returns octant in which sample resides. Reverse of subBbox. Precalculated
|
||||
// midpoint
|
||||
inline direction treeBoundBox::subOctant
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const point& sample
|
||||
@ -175,8 +167,11 @@ inline direction treeBoundBox::subOctant
|
||||
|
||||
// Returns octant in which sample resides. Reverse of subBbox. Flags sample
|
||||
// exactly on edge.
|
||||
inline direction treeBoundBox::subOctant(const point& sample, bool& onEdge)
|
||||
const
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
(
|
||||
const point& sample,
|
||||
bool& onEdge
|
||||
) const
|
||||
{
|
||||
point mid = 0.5*(max() + min());
|
||||
|
||||
@ -216,7 +211,7 @@ inline direction treeBoundBox::subOctant(const point& sample, bool& onEdge)
|
||||
|
||||
// Returns octant in which sample resides. Reverse of subBbox. Precalculated
|
||||
// midpoint
|
||||
inline direction treeBoundBox::subOctant
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const point& sample,
|
||||
@ -261,7 +256,7 @@ inline direction treeBoundBox::subOctant
|
||||
// Precalculated midpoint. If the sample is on the dividing line between
|
||||
// the octants the direction vector determines which octant to use
|
||||
// (i.e. in which octant the sample would be if it were moved along dir)
|
||||
inline direction treeBoundBox::subOctant
|
||||
inline Foam::direction Foam::treeBoundBox::subOctant
|
||||
(
|
||||
const point& mid,
|
||||
const vector& dir,
|
||||
@ -319,9 +314,9 @@ inline direction treeBoundBox::subOctant
|
||||
}
|
||||
|
||||
|
||||
// Returns reference to octantOrder which defines the
|
||||
// Returns reference to octantOrder which defines the
|
||||
// order to do the search.
|
||||
inline void treeBoundBox::searchOrder
|
||||
inline void Foam::treeBoundBox::searchOrder
|
||||
(
|
||||
const point& sample,
|
||||
FixedList<direction,8>& octantOrder
|
||||
@ -380,7 +375,7 @@ inline void treeBoundBox::searchOrder
|
||||
{
|
||||
min = treeBoundBox::FRONTHALF;
|
||||
mid = treeBoundBox::TOPHALF;
|
||||
max = treeBoundBox::RIGHTHALF;
|
||||
max = treeBoundBox::RIGHTHALF;
|
||||
}
|
||||
else if( dist.x() < dist.z())
|
||||
{
|
||||
@ -412,13 +407,13 @@ inline void treeBoundBox::searchOrder
|
||||
|
||||
// true if bb's intersect or overlap.
|
||||
// Note: <= to make sure we catch all.
|
||||
inline bool treeBoundBox::overlaps(const treeBoundBox& bb) const
|
||||
inline bool Foam::treeBoundBox::overlaps(const treeBoundBox& bb) const
|
||||
{
|
||||
return boundBox::overlaps(bb);
|
||||
}
|
||||
|
||||
|
||||
inline bool treeBoundBox::contains(const point& sample) const
|
||||
inline bool Foam::treeBoundBox::contains(const point& sample) const
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -433,7 +428,11 @@ inline bool treeBoundBox::contains(const point& sample) const
|
||||
|
||||
|
||||
//- Return slightly wider bounding box
|
||||
inline treeBoundBox treeBoundBox::extend(Random& rndGen, const scalar s) const
|
||||
inline Foam::treeBoundBox Foam::treeBoundBox::extend
|
||||
(
|
||||
Random& rndGen,
|
||||
const scalar s
|
||||
) const
|
||||
{
|
||||
treeBoundBox bb(*this);
|
||||
|
||||
@ -456,6 +455,4 @@ inline treeBoundBox treeBoundBox::extend(Random& rndGen, const scalar s) const
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -776,8 +776,7 @@ void Foam::distributedTriSurfaceMesh::calcBounds
|
||||
pointIsUsed = 0U;
|
||||
|
||||
nPoints = 0;
|
||||
bb.min() = point(VGREAT, VGREAT, VGREAT);
|
||||
bb.max() = point(-VGREAT, -VGREAT, -VGREAT);
|
||||
bb = boundBox::invertedBox;
|
||||
|
||||
const triSurface& s = static_cast<const triSurface&>(*this);
|
||||
|
||||
@ -2123,7 +2122,7 @@ void Foam::distributedTriSurfaceMesh::distribute
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
faceMap.reset
|
||||
(
|
||||
|
||||
@ -1213,11 +1213,7 @@ void Foam::triSurface::writeStats(Ostream& os) const
|
||||
pointIsUsed = 0U;
|
||||
|
||||
label nPoints = 0;
|
||||
boundBox bb
|
||||
(
|
||||
point(VGREAT, VGREAT, VGREAT),
|
||||
point(-VGREAT, -VGREAT, -VGREAT)
|
||||
);
|
||||
boundBox bb = boundBox::invertedBox;
|
||||
|
||||
forAll(*this, triI)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user