diff --git a/src/OpenFOAM/meshes/boundBox/boundBox.C b/src/OpenFOAM/meshes/boundBox/boundBox.C index c368e1a662..c87e552c85 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBox.C +++ b/src/OpenFOAM/meshes/boundBox/boundBox.C @@ -87,9 +87,47 @@ boundBox::boundBox(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -Ostream& operator<<(Ostream& os, const boundBox& b) +Ostream& operator<<(Ostream& os, const boundBox& bb) { - return os << b.min() << token::SPACE << b.max(); + if (os.format() == IOstream::ASCII) + { + os << bb.min_ << token::SPACE << bb.max_; + } + else + { + os.write + ( + reinterpret_cast(&bb.min_), + sizeof(boundBox) + ); + } + + // Check state of Ostream + os.check("Ostream& operator<<(Ostream&, const boundBox&)"); + + return os; +} + + +Istream& operator>>(Istream& is, boundBox& bb) +{ + if (is.format() == IOstream::ASCII) + { + return is >> bb.min_ >> bb.max_; + } + else + { + is.read + ( + reinterpret_cast(&bb.min_), + sizeof(boundBox) + ); + } + + // Check state of Istream + is.check("Istream& operator>>(Istream&, boundBox&)"); + + return is; } diff --git a/src/OpenFOAM/meshes/boundBox/boundBox.H b/src/OpenFOAM/meshes/boundBox/boundBox.H index 40287e53eb..1493c0fe2f 100644 --- a/src/OpenFOAM/meshes/boundBox/boundBox.H +++ b/src/OpenFOAM/meshes/boundBox/boundBox.H @@ -153,12 +153,31 @@ public: } - // Ostream operator + // Friend Operators - friend Ostream& operator<<(Ostream& os, const boundBox& b); + friend bool operator==(const boundBox& a, const boundBox& b) + { + return (a.min_ == b.min_) && (a.max_ == b.max_); + } + + friend bool operator!=(const boundBox& a, const boundBox& b) + { + return !(a == b); + } + + + // IOstream operator + + friend Istream& operator>>(Istream& is, boundBox&); + friend Ostream& operator<<(Ostream& os, const boundBox&); }; +//- Specify data associated with boundBox type is contiguous +template<> +inline bool contiguous() {return contiguous();} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam