VSToolsT.hh 3 KB
Newer Older
Henrik Zimmer's avatar
Henrik Zimmer committed
1
/*===========================================================================*\
Henrik Zimmer's avatar
Henrik Zimmer committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *                                                                           *
 *                               CoMISo                                      *
 *      Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.rwth-graphics.de                            *
 *                                                                           *
 *---------------------------------------------------------------------------* 
 *  This file is part of CoMISo.                                             *
 *                                                                           *
 *  CoMISo is free software: you can redistribute it and/or modify           *
 *  it under the terms of the GNU General Public License as published by     *
 *  the Free Software Foundation, either version 3 of the License, or        *
 *  (at your option) any later version.                                      *
 *                                                                           *
 *  CoMISo 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            *
 *  GNU General Public License for more details.                             *
 *                                                                           *
 *  You should have received a copy of the GNU General Public License        *
 *  along with CoMISo.  If not, see <http://www.gnu.org/licenses/>.          *
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
23
\*===========================================================================*/ 
Henrik Zimmer's avatar
Henrik Zimmer committed
24

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#ifndef VSTOOLS_HH
#define VSTOOLS_HH


//== FORWARDDECLARATIONS ======================================================

//== NAMESPACES ===============================================================

//== DEFINITION =========================================================

/** These functions are required for Visual Studio to work around missing 
    functions. Basic equivalent functions for double exist in the float 
    header but are named different. So this wrapper makes them standard compatible.
    */
#ifdef WIN32
40 41
#include <math.h>
#include <float.h>
42

43
namespace std {
44

45 46 47 48
inline int isnan(double x)
{
  return _isnan(x);
} 
49

50 51 52 53
// Which idiot defines isinf as a macro somewhere?
#ifdef isinf 
#undef isinf
#endif
54

55 56 57 58
inline int isinf(double x)
{
  return !_finite(x);
} 
59

60 61 62 63
inline int isfinite(double x)
{
  return _finite(x);
}
64

65
}// namespace std
66

67 68
inline double nearbyint(double x) 
{
Henrik Zimmer's avatar
Henrik Zimmer committed
69
   if( x >= 0.0 )
70
     return int( x + 0.5 );
Henrik Zimmer's avatar
Henrik Zimmer committed
71
   else
72
     return int( x - 0.5 );
73
}
74

75 76
inline double round ( double _value ) 
{
77
   return nearbyint(_value);
78
}
79

80
#endif //WIN32
81 82 83 84 85

//=============================================================================
#endif // VSTOOLS_HH defined
//=============================================================================