From 3a3ab40d446bca31cae7f0c79d9666f4597ac425 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sat, 27 Oct 2012 03:03:28 -0400 Subject: [PATCH] some work on removing stl.h --- data/pch/mitsuba_precompiled.hpp | 2 +- include/mitsuba/core/platform.h | 49 +++++++++++++++++++ include/mitsuba/core/stl.h | 84 -------------------------------- src/emitters/sun.cpp | 2 +- src/emitters/sunsky.cpp | 2 +- src/libcore/class.cpp | 6 +-- 6 files changed, 55 insertions(+), 90 deletions(-) diff --git a/data/pch/mitsuba_precompiled.hpp b/data/pch/mitsuba_precompiled.hpp index cbe1e530..9d31a26d 100644 --- a/data/pch/mitsuba_precompiled.hpp +++ b/data/pch/mitsuba_precompiled.hpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/mitsuba/core/platform.h b/include/mitsuba/core/platform.h index 00c9791a..e949545e 100644 --- a/include/mitsuba/core/platform.h +++ b/include/mitsuba/core/platform.h @@ -189,6 +189,55 @@ extern MTS_EXPORT_CORE void __mts_set_appdefaults(); #define MTS_AUTORELEASE_BEGIN() #define MTS_AUTORELEASE_END() #endif + MTS_NAMESPACE_END + +/// \cond +// Try to make MSVC++ behave a bit more like C++ +// with an underlying C99 implementation +// (and dn't include this in the documentation) +#if defined(_MSC_VER) + +#include + +#define snprintf _snprintf +#define vsnprintf _vsnprintf + +namespace std { + + inline char tolower(char c) { + return ::tolower(c); + } + + inline char toupper(char c) { + return ::toupper(c); + } + + inline bool isnan(float f) { + return _isnan(f); + } + + inline bool isnan(double f) { + return _isnan(f); + } + + inline bool isfinite(float f) { + return _finite(f); + } + + inline bool isfinite(double f) { + return _finite(f); + } + + inline bool isinf(float f) { + return !_finite(f); + } + + inline bool isinf(double f) { + return !_finite(f); + } +}; +#endif + #endif /* __MITSUBA_CORE_PLATFORM_H_ */ diff --git a/include/mitsuba/core/stl.h b/include/mitsuba/core/stl.h index 05eb48ef..f12a2a6c 100644 --- a/include/mitsuba/core/stl.h +++ b/include/mitsuba/core/stl.h @@ -20,90 +20,6 @@ #if !defined(__MITSUBA_CORE_STL_H_) #define __MITSUBA_CORE_STL_H_ -/* Include some SGI STL extensions, which might be missing */ -#ifdef __GNUC__ -#include -using __gnu_cxx::select2nd; -using __gnu_cxx::compose1; -#else -#include - -/// \cond -// (Don't include in the documentation) -namespace std { - template struct _Select1st : public unary_function<_Pair, typename _Pair::first_type> { - const typename _Pair::first_type& operator()(const _Pair& __x) const { - return __x.first; - } - }; - - template struct _Select2nd : public unary_function<_Pair, typename _Pair::second_type> { - const typename _Pair::second_type& operator()(const _Pair& __x) const { - return __x.second; - } - }; - - template struct select1st : public _Select1st<_Pair> {}; - template struct select2nd : public _Select2nd<_Pair> {}; - - template class unary_compose : public unary_function { - protected: - _Operation1 _M_fn1; - _Operation2 _M_fn2; - public: - unary_compose(const _Operation1& __x, const _Operation2& __y) : _M_fn1(__x), _M_fn2(__y) {} - typename _Operation1::result_type operator()(const typename _Operation2::argument_type& __x) const { - return _M_fn1(_M_fn2(__x)); - } - }; - - template inline unary_compose<_Operation1,_Operation2> compose1(const _Operation1& __fn1, const _Operation2& __fn2) { - return unary_compose<_Operation1,_Operation2>(__fn1, __fn2); - } - -#if defined(_MSC_VER) - #include - - #define snprintf _snprintf - #define vsnprintf _vsnprintf - - inline char tolower(char c) { - return ::tolower(c); - } - - inline char toupper(char c) { - return ::toupper(c); - } - - inline bool isnan(float f) { - return _isnan(f); - } - - inline bool isnan(double f) { - return _isnan(f); - } - - inline bool isfinite(float f) { - return _finite(f); - } - - inline bool isfinite(double f) { - return _finite(f); - } - - inline bool isinf(float f) { - return !_finite(f); - } - - inline bool isinf(double f) { - return !_finite(f); - } -#endif -}; -using std::select2nd; -using std::compose1; -#endif - namespace mitsuba { namespace math { #if defined(__LINUX__) && defined(__x86_64__) diff --git a/src/emitters/sun.cpp b/src/emitters/sun.cpp index f17a7b64..c61e96e7 100644 --- a/src/emitters/sun.cpp +++ b/src/emitters/sun.cpp @@ -178,7 +178,7 @@ public: Spectrum *target = (Spectrum *) bitmap->getFloatData(); Spectrum value = m_radiance * (2 * M_PI * (1-std::cos(m_theta))) * - (bitmap->getWidth() * bitmap->getHeight()) + (Float) (bitmap->getWidth() * bitmap->getHeight()) / (2.0f * M_PI * M_PI * (Float) nSamples); for (size_t i=0; igetWidth() * bitmap->getHeight()) + (Float) (bitmap->getWidth() * bitmap->getHeight()) / (2.0f * M_PI * M_PI * (Float) nSamples); for (size_t i=0; ibegin(), __classes->end(), - compose1(std::ptr_fun(initializeOnce), - select2nd())); + for (ClassMap::iterator it = __classes->begin(); + it != __classes->end(); ++it) + initializeOnce(it->second); m_isInitialized = true; }