1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "PstreamReduceOps.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 const Foam::scalar Foam::boundBox::great(VGREAT);
34 const Foam::boundBox Foam::boundBox::greatBox
36 point(-VGREAT, -VGREAT, -VGREAT),
37 point(VGREAT, VGREAT, VGREAT)
41 const Foam::boundBox Foam::boundBox::invertedBox
43 point(VGREAT, VGREAT, VGREAT),
44 point(-VGREAT, -VGREAT, -VGREAT)
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 void Foam::boundBox::calculate(const pointField& points, const bool doReduce)
57 if (doReduce && Pstream::parRun())
59 // Use values that get overwritten by reduce minOp, maxOp below
60 min_ = point(VGREAT, VGREAT, VGREAT);
61 max_ = point(-VGREAT, -VGREAT, -VGREAT);
71 min_ = ::Foam::min(min_, points[i]);
72 max_ = ::Foam::max(max_, points[i]);
76 // Reduce parallel information
79 reduce(min_, minOp<point>());
80 reduce(max_, maxOp<point>());
85 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
87 Foam::boundBox::boundBox(const pointField& points, const bool doReduce)
92 calculate(points, doReduce);
96 Foam::boundBox::boundBox(const tmp<pointField>& points, const bool doReduce)
101 calculate(points(), doReduce);
106 Foam::boundBox::boundBox(Istream& is)
108 operator>>(is, *this);
112 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
114 Foam::Ostream& Foam::operator<<(Ostream& os, const boundBox& bb)
116 if (os.format() == IOstream::ASCII)
118 os << bb.min_ << token::SPACE << bb.max_;
124 reinterpret_cast<const char*>(&bb.min_),
129 // Check state of Ostream
130 os.check("Ostream& operator<<(Ostream&, const boundBox&)");
135 Foam::Istream& Foam::operator>>(Istream& is, boundBox& bb)
137 if (is.format() == IOstream::ASCII)
139 return is >> bb.min_ >> bb.max_;
145 reinterpret_cast<char*>(&bb.min_),
150 // Check state of Istream
151 is.check("Istream& operator>>(Istream&, boundBox&)");
155 // ************************************************************************* //