boundBox, octree cleanup

- added boundBox(const tmp<pointField>&) constructor for use with
    coordinate systems
  - moved some methods from treeBoundBox to boundBox and use VectorSpace ops
This commit is contained in:
Mark Olesen
2009-01-01 17:03:19 +01:00
parent 28b200bcd9
commit 973b9ea0ce
38 changed files with 813 additions and 976 deletions

View File

@ -26,9 +26,12 @@ License
#include "boundBox.H"
#include "PstreamReduceOps.H"
#include "tmp.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::scalar Foam::boundBox::great(VGREAT);
const Foam::boundBox Foam::boundBox::greatBox
(
point(-VGREAT, -VGREAT, -VGREAT),
@ -43,16 +46,16 @@ const Foam::boundBox Foam::boundBox::invertedBox
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
:
min_(point::zero),
max_(point::zero)
void Foam::boundBox::calculate(const pointField& points, const bool doReduce)
{
if (points.size() == 0)
{
if (Pstream::parRun() && doReduce)
min_ = point::zero;
max_ = point::zero;
if (doReduce && Pstream::parRun())
{
// Use values that get overwritten by reduce minOp, maxOp below
min_ = point(VGREAT, VGREAT, VGREAT);
@ -64,22 +67,43 @@ Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
min_ = points[0];
max_ = points[0];
forAll(points, i)
for (label i = 1; i < points.size(); i++)
{
min_ = ::Foam::min(min_, points[i]);
max_ = ::Foam::max(max_, points[i]);
}
}
// Reduce parallel information
if (doReduce)
{
// Reduce parallel information
reduce(min_, minOp<point>());
reduce(max_, maxOp<point>());
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
:
min_(point::zero),
max_(point::zero)
{
calculate(points, doReduce);
}
Foam::boundBox::boundBox(const tmp<pointField>& points, const bool doReduce)
:
min_(point::zero),
max_(point::zero)
{
calculate(points(), doReduce);
points.clear();
}
Foam::boundBox::boundBox(Istream& is)
{
operator>>(is, *this);