VSToolsT.hh 3.03 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


Henrik Zimmer's avatar
Henrik Zimmer committed
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#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
 #include <float.h>

 namespace std {

   inline int isnan(double x)
   {
     return _isnan(x);
   } 

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

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

62
63
64
65
66
   inline int isfinite(double x)
     {
       return _finite(x);
     }

67
68
69
  }

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

 inline double round ( double _value ) {
77
   return nearbyint(_value);
78
79
80
81
82
83
84
85
86
87
 }


#endif


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