From 7877c55770f4fc55e00d061b3506106174625830 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 24 Feb 2003 12:02:00 +0000 Subject: [PATCH] Implemented an osg::minimum and osg::maximum template functions to replace the std::min/max functions previously used in parts of the osg, since the std::min/max methods do not seem implemented under IRIX. --- include/osg/Math | 10 ++++++++++ src/osg/ApplicationUsage.cpp | 5 ++--- src/osg/State.cpp | 14 ++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/osg/Math b/include/osg/Math index 7dae34bfe..12f670f17 100644 --- a/include/osg/Math +++ b/include/osg/Math @@ -108,6 +108,16 @@ const double PI = 3.14159265358979323846; const double PI_2 = 1.57079632679489661923; const double PI_4 = 0.78539816339744830962; +/** return the minimum of two values, equivilant to std::min. + * std::min not used because of STL implementation under IRIX contains no std::min.*/ +template +inline T minimum(T lhs,T rhs) { return lhs +inline T maximum(T lhs,T rhs) { return lhs>rhs?lhs:rhs; } + template inline T clampTo(T v,T minimum,T maximum) { return vmaximum?maximum:v; } diff --git a/src/osg/ApplicationUsage.cpp b/src/osg/ApplicationUsage.cpp index c041d24b2..1f5f959a3 100644 --- a/src/osg/ApplicationUsage.cpp +++ b/src/osg/ApplicationUsage.cpp @@ -1,6 +1,5 @@ #include - -#include +#include using namespace osg; @@ -54,7 +53,7 @@ void ApplicationUsage::write(std::ostream& output, const ApplicationUsage::Usage citr!=um.end(); ++citr) { - maxNumCharsInOptions = std::max(maxNumCharsInOptions,(unsigned int)citr->first.length()); + maxNumCharsInOptions = maximum(maxNumCharsInOptions,(unsigned int)citr->first.length()); } unsigned int fullWidth = widthOfOutput; diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 30728c035..99ff88ff5 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -15,8 +15,6 @@ #include #include -#include - using namespace osg; State::State() @@ -198,8 +196,8 @@ void State::captureCurrentState(StateSet& stateset) const } -// revert to using std::max for consistency, std::max should be defined by STLport on VS. -// // visual studio 6.0 doesn't appear to define std::max?!? So do our own here.. +// revert to using maximum for consistency, maximum should be defined by STLport on VS. +// // visual studio 6.0 doesn't appear to define maximum?!? So do our own here.. // template // T mymax(const T& a,const T& b) // { @@ -225,9 +223,9 @@ void State::apply(const StateSet* dstate) const StateSet::TextureAttributeList& ds_textureAttributeList = dstate->getTextureAttributeList(); unsigned int unit; - unsigned int unitMax = std::max(static_cast(ds_textureModeList.size()),static_cast(ds_textureAttributeList.size())); - unitMax = std::max(static_cast(unitMax),static_cast(_textureModeMapList.size())); - unitMax = std::max(static_cast(unitMax),static_cast(_textureAttributeMapList.size())); + unsigned int unitMax = maximum(static_cast(ds_textureModeList.size()),static_cast(ds_textureAttributeList.size())); + unitMax = maximum(static_cast(unitMax),static_cast(_textureModeMapList.size())); + unitMax = maximum(static_cast(unitMax),static_cast(_textureAttributeMapList.size())); for(unit=0;unit