/vol/vipdata/irtk/common++/include/irtkCommon.h

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkCommon.h 2 2008-12-23 12:40:14Z dr $
00005   Copyright : Imperial College, Department of Computing
00006               Visual Information Processing (VIP), 2008 onwards
00007   Date      : $Date: 2008-12-23 12:40:14 +0000 (Tue, 23 Dec 2008) $
00008   Version   : $Revision: 2 $
00009   Changes   : $Author: dr $
00010 
00011 =========================================================================*/
00012 
00013 #ifndef _IRTKCOMMON_H
00014 
00015 #define _IRTKCOMMON_H
00016 
00017 // C++ header files
00018 #include <iostream>
00019 #include <iomanip>
00020 #include <fstream>
00021 #include <complex>
00022 #include <algorithm>
00023 #include <string>
00024 #include <limits>
00025 
00026 // C header files
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <limits.h>
00030 #include <float.h>
00031 #include <math.h>
00032 #include <string.h>
00033 
00034 #ifdef HAS_ZLIB
00035 #include <zlib.h>
00036 #endif
00037 
00038 #ifdef WIN32
00039 
00040 // Windows is missing M_PI constants
00041 #define M_PI      3.14159265358979323846
00042 
00043 #define NOMINMAX
00044 
00045 // Windows specific header file
00046 #include <windows.h>
00047 
00048 #endif
00049 
00050 // Use standard namespace
00051 using namespace std;
00052 
00053 #define False 0
00054 #define True  1
00055 
00056 typedef bool Bool;
00057 
00058 #define SetMacro(name,type) \
00059 void Set##name (type arg) { this->_##name = arg; }
00060 
00061 #define GetMacro(name,type) \
00062 type Get##name () { return this->_##name; }
00063 
00064 extern const char *dirname2(const char *path);
00065 extern char       *basename2(const char *filename);
00066 
00067 extern int   ReadInt   (ifstream &in);
00068 extern float ReadFloat (ifstream &in);
00069 extern char *ReadString(ifstream &in);
00070 
00071 #ifdef HAS_ZLIB
00072 extern int   ReadCompressed(gzFile, char *, int, int);
00073 #else
00074 extern int   ReadCompressed(FILE *, char *, int, int);
00075 #endif
00076 
00077 #define round round2
00078 
00079 inline int round(double x)
00080 {
00081   return x > 0 ? int(x + 0.5) : int(x - 0.5);
00082 }
00083 
00084 extern void swap16(char *, char *, int);
00085 extern void swap32(char *, char *, int);
00086 extern void swap64(char *, char *, int);
00087 
00088 // Orientation codes (same as NIFTI)
00089 #define IRTK_L2R  1    /* Left to Right         */
00090 #define IRTK_R2L  2    /* Right to Left         */
00091 #define IRTK_P2A  3    /* Posterior to Anterior */
00092 #define IRTK_A2P  4    /* Anterior to Posterior */
00093 #define IRTK_I2S  5    /* Inferior to Superior  */
00094 #define IRTK_S2I  6    /* Superior to Inferior  */
00095 
00096 #include <irtkObject.h>
00097 #include <irtkCifstream.h>
00098 #include <irtkCofstream.h>
00099 #include <irtkAllocate.h>
00100 #include <irtkDeallocate.h>
00101 #include <irtkException.h>
00102 
00103 #ifdef HAS_VTK
00104 
00105 #include <vtkConfigure.h>
00106 
00107 #endif
00108 
00109 #ifdef HAS_TBB
00110 
00111 #include <tbb/task_scheduler_init.h>
00112 #include <tbb/blocked_range.h>
00113 #include <tbb/parallel_for.h>
00114 #include <tbb/parallel_reduce.h>
00115 #include <tbb/tick_count.h>
00116 #include <tbb/concurrent_queue.h>
00117 
00118 using namespace tbb;
00119 
00120 // Default: Debugging of TBB code
00121 extern int tbb_debug;
00122 
00123 // Default: Number of threads is determined automatically
00124 extern int tbb_no_threads;
00125 
00126 #endif
00127 
00128 #endif