From a2974de9788a8e3caebb5724cbaa55d666094679 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 8 Apr 2005 09:01:23 +0000 Subject: [PATCH] Moved the istream and ostream support from Vec* and Matrix* into a seperate io_utils file. --- VisualStudio/osg/osg.dsp | 4 + include/osg/Matrixd | 19 ---- include/osg/Matrixf | 20 ---- include/osg/Vec2d | 17 ---- include/osg/Vec2f | 19 ---- include/osg/Vec3d | 18 ---- include/osg/Vec3f | 15 --- include/osg/Vec4d | 17 ---- include/osg/Vec4f | 17 ---- include/osg/io_utils | 163 +++++++++++++++++++++++++++++++ src/osg/AnimationPath.cpp | 1 + src/osg/ImpostorSprite.cpp | 5 - src/osgGA/TerrainManipulator.cpp | 1 + src/osgProducer/Viewer.cpp | 1 + src/osgUtil/IntersectVisitor.cpp | 1 + src/osgUtil/TriStripVisitor.cpp | 1 + 16 files changed, 172 insertions(+), 147 deletions(-) create mode 100644 include/osg/io_utils diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index 96e8b8ec0..682eb94fd 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -876,6 +876,10 @@ SOURCE=..\..\include\osg\ref_ptr # End Source File # Begin Source File +SOURCE=..\..\include\osg\io_utils +# End Source File +# Begin Source File + SOURCE=..\..\Include\Osg\Referenced # End Source File # Begin Source File diff --git a/include/osg/Matrixd b/include/osg/Matrixd index c0354392b..bdd88cbb5 100644 --- a/include/osg/Matrixd +++ b/include/osg/Matrixd @@ -15,17 +15,10 @@ #define OSG_MATRIXD 1 #include -#include #include -#include #include #include -#include - -#include -#include - namespace osg { class Matrixf; @@ -646,18 +639,6 @@ inline Vec4d Matrixd::operator* (const Vec4d& v) const return postMult(v); } -inline std::ostream& operator<< (std::ostream& os, const Matrixd& m ) -{ - os << "{"< -#include #include -#include #include #include -#include - -#include -#include - namespace osg { class Matrixf; @@ -633,19 +626,6 @@ inline Vec4d Matrixf::operator* (const Vec4d& v) const return postMult(v); } -inline std::ostream& operator<< (std::ostream& os, const Matrixf& m ) -{ - os << "{"<> (std::istream& input, Vec2d& vec) -{ - input >> vec._v[0] >> vec._v[1]; - return input; -} - - } // end of namespace osg #endif diff --git a/include/osg/Vec2f b/include/osg/Vec2f index 170fd69b3..049104d4f 100644 --- a/include/osg/Vec2f +++ b/include/osg/Vec2f @@ -14,9 +14,6 @@ #ifndef OSG_VEC2F #define OSG_VEC2F 1 -#include -#include - #include namespace osg { @@ -166,22 +163,6 @@ class Vec2f }; // end of class Vec2f - -// streaming operators - -inline std::ostream& operator << (std::ostream& output, const Vec2f& vec) -{ - output << vec._v[0] << " " << vec._v[1]; - return output; // to enable cascading -} - -inline std::istream& operator >> (std::istream& input, Vec2f& vec) -{ - input >> vec._v[0] >> vec._v[1]; - return input; -} - - } // end of namespace osg #endif diff --git a/include/osg/Vec3d b/include/osg/Vec3d index 9d7e8135c..85fc580e6 100644 --- a/include/osg/Vec3d +++ b/include/osg/Vec3d @@ -199,24 +199,6 @@ class Vec3d }; // end of class Vec3d - -// streaming operators - -inline std::ostream& operator << (std::ostream& output, const Vec3d& vec) -{ - output << vec._v[0] << " " - << vec._v[1] << " " - << vec._v[2]; - return output; // to enable cascading -} - -inline std::istream& operator >> (std::istream& input, Vec3d& vec) -{ - input >> vec._v[0] >> vec._v[1] >> vec._v[2]; - return input; -} - - } // end of namespace osg #endif diff --git a/include/osg/Vec3f b/include/osg/Vec3f index 101d8dffb..620899503 100644 --- a/include/osg/Vec3f +++ b/include/osg/Vec3f @@ -197,21 +197,6 @@ class Vec3f }; // end of class Vec3f -// streaming operators - -inline std::ostream& operator << (std::ostream& output, const Vec3f& vec) -{ - output << vec._v[0] << " " - << vec._v[1] << " " - << vec._v[2]; - return output; // to enable cascading -} - -inline std::istream& operator >> (std::istream& input, Vec3f& vec) -{ - input >> vec._v[0] >> vec._v[1] >> vec._v[2]; - return input; -} const Vec3f X_AXIS(1.0,0.0,0.0); const Vec3f Y_AXIS(0.0,1.0,0.0); diff --git a/include/osg/Vec4d b/include/osg/Vec4d index 12f8011a4..2e629008b 100644 --- a/include/osg/Vec4d +++ b/include/osg/Vec4d @@ -239,23 +239,6 @@ class Vec4d }; // end of class Vec4d -// streaming operators - -inline std::ostream& operator << (std::ostream& output, const Vec4d& vec) -{ - output << vec._v[0] << " " - << vec._v[1] << " " - << vec._v[2] << " " - << vec._v[3]; - return output; // to enable cascading -} - -inline std::istream& operator >> (std::istream& input, Vec4d& vec) -{ - input >> vec._v[0] >> vec._v[1] >> vec._v[2] >> vec._v[3]; - return input; -} - /** Compute the dot product of a (Vec3,1.0) and a Vec4d. */ inline Vec4d::value_type operator * (const Vec3d& lhs,const Vec4d& rhs) diff --git a/include/osg/Vec4f b/include/osg/Vec4f index 66485e294..81a55da32 100644 --- a/include/osg/Vec4f +++ b/include/osg/Vec4f @@ -232,23 +232,6 @@ class Vec4f }; // end of class Vec4f -// streaming operators - -inline std::ostream& operator << (std::ostream& output, const Vec4f& vec) -{ - output << vec._v[0] << " " - << vec._v[1] << " " - << vec._v[2] << " " - << vec._v[3]; - return output; // to enable cascading -} - -inline std::istream& operator >> (std::istream& input, Vec4f& vec) -{ - input >> vec._v[0] >> vec._v[1] >> vec._v[2] >> vec._v[3]; - return input; -} - /** Compute the dot product of a (Vec3,1.0) and a Vec4f. */ inline Vec4f::value_type operator * (const Vec3f& lhs,const Vec4f& rhs) diff --git a/include/osg/io_utils b/include/osg/io_utils new file mode 100644 index 000000000..bbb9f0df9 --- /dev/null +++ b/include/osg/io_utils @@ -0,0 +1,163 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSG_IO_UTILS +#define OSG_IO_UTILS 1 + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace osg { + + +////////////////////////////////////////////////////////////////////////// +// Vec2f streaming operators +inline std::ostream& operator << (std::ostream& output, const Vec2f& vec) +{ + output << vec._v[0] << " " << vec._v[1]; + return output; // to enable cascading +} + +inline std::istream& operator >> (std::istream& input, Vec2f& vec) +{ + input >> vec._v[0] >> vec._v[1]; + return input; +} + +////////////////////////////////////////////////////////////////////////// +// Vec2d steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec2d& vec) +{ + output << vec._v[0] << " " << vec._v[1]; + return output; // to enable cascading +} + +inline std::istream& operator >> (std::istream& input, Vec2d& vec) +{ + input >> vec._v[0] >> vec._v[1]; + return input; +} + +////////////////////////////////////////////////////////////////////////// +// Vec3f steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec3f& vec) +{ + output << vec._v[0] << " " + << vec._v[1] << " " + << vec._v[2]; + return output; // to enable cascading +} + +inline std::istream& operator >> (std::istream& input, Vec3f& vec) +{ + input >> vec._v[0] >> vec._v[1] >> vec._v[2]; + return input; +} + + +////////////////////////////////////////////////////////////////////////// +// Vec3d steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec3d& vec) +{ + output << vec._v[0] << " " + << vec._v[1] << " " + << vec._v[2]; + return output; // to enable cascading +} + +inline std::istream& operator >> (std::istream& input, Vec3d& vec) +{ + input >> vec._v[0] >> vec._v[1] >> vec._v[2]; + return input; +} + + +////////////////////////////////////////////////////////////////////////// +// Vec3f steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec4f& vec) +{ + output << vec._v[0] << " " + << vec._v[1] << " " + << vec._v[2] << " " + << vec._v[3]; + return output; // to enable cascading +} + +inline std::istream& operator >> (std::istream& input, Vec4f& vec) +{ + input >> vec._v[0] >> vec._v[1] >> vec._v[2] >> vec._v[3]; + return input; +} + + + +////////////////////////////////////////////////////////////////////////// +// Vec4d steaming operators. +inline std::ostream& operator << (std::ostream& output, const Vec4d& vec) +{ + output << vec._v[0] << " " + << vec._v[1] << " " + << vec._v[2] << " " + << vec._v[3]; + return output; // to enable cascading +} +inline std::istream& operator >> (std::istream& input, Vec4d& vec) +{ + input >> vec._v[0] >> vec._v[1] >> vec._v[2] >> vec._v[3]; + return input; +} + + +////////////////////////////////////////////////////////////////////////// +// Matrxf steaming operators. +inline std::ostream& operator<< (std::ostream& os, const Matrixf& m ) +{ + os << "{"< #include #include +#include using namespace osg; diff --git a/src/osg/ImpostorSprite.cpp b/src/osg/ImpostorSprite.cpp index 7b6b9eb67..506e2a219 100644 --- a/src/osg/ImpostorSprite.cpp +++ b/src/osg/ImpostorSprite.cpp @@ -25,7 +25,6 @@ #include #include - using namespace osg; ImpostorSprite::ImpostorSprite() @@ -113,10 +112,6 @@ bool ImpostorSprite::computeBound() const if (!_bbox.valid()) { notify(WARN) << "******* ImpostorSprite::computeBound() problem"<