Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkGlobal.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 
00034 
00035 #ifndef __mitkGlobal_h
00036 #define __mitkGlobal_h
00037 
00038 #include "mitkCommonIncludes.h"
00039 #include <math.h>
00040 #include <assert.h>
00041 
00042 #include <string.h>
00043 
00044 #ifdef MITK_OS_LINUX
00045 #include <strings.h>
00046 #define stricmp strcasecmp
00047 #endif
00048 
00049 //I/O Stream & string
00050 #include <iostream> 
00051 #include <sstream>
00052 #include <fstream>  
00053 #include <iomanip>  
00054 #include <string> 
00055 #include <vector>
00056 
00057 // Need these in global namespace so the same code will work with ansi
00058 // and old-style streams.
00059 using std::dec;
00060 using std::hex;
00061 using std::setw;
00062 using std::setfill;
00063 using std::cerr;
00064 using std::cout;
00065 using std::cin;
00066 using std::ios;
00067 using std::endl;
00068 using std::ostream;
00069 using std::istream;
00070 using std::ostringstream;
00071 using std::istringstream;
00072 using std::stringstream;
00073 using std::ofstream;
00074 using std::ifstream;
00075 using std::fstream;
00076 using std::string;
00077 using std::vector;
00078 
00079 typedef unsigned int index_type;
00080 typedef unsigned int size_type;
00081 
00082 typedef string mitkString;
00083 typedef vector<string> mitkStringList;
00084 
00085 // Some constants used throughout the code
00086 #define MITK_LARGE_FLOAT 1.0e+38F
00087 #define MITK_LARGE_INTEGER 2147483647 // 2^31 - 1
00088 
00089 // These types are returned by GetDataType to indicate pixel type.
00090 #define MITK_VOID            0
00091 #define MITK_BIT             1
00092 #define MITK_CHAR            2
00093 #define MITK_UNSIGNED_CHAR   3
00094 #define MITK_SHORT           4
00095 #define MITK_UNSIGNED_SHORT  5
00096 #define MITK_INT             6
00097 #define MITK_UNSIGNED_INT    7
00098 #define MITK_LONG            8
00099 #define MITK_UNSIGNED_LONG   9
00100 #define MITK_FLOAT          10
00101 #define MITK_DOUBLE         11
00102 
00103 // Some constant required for correct template performance
00104 #define MITK_BIT_MIN 0
00105 #define MITK_BIT_MAX 1
00106 #define MITK_CHAR_MIN -128
00107 #define MITK_CHAR_MAX 127
00108 #define MITK_UNSIGNED_CHAR_MIN 0
00109 #define MITK_UNSIGNED_CHAR_MAX 255
00110 #define MITK_SHORT_MIN -32768
00111 #define MITK_SHORT_MAX 32767
00112 #define MITK_UNSIGNED_SHORT_MIN 0
00113 #define MITK_UNSIGNED_SHORT_MAX 65535
00114 #define MITK_INT_MIN (-MITK_LARGE_INTEGER-1)
00115 #define MITK_INT_MAX MITK_LARGE_INTEGER
00116 #define MITK_UNSIGNED_INT_MIN 0
00117 #define MITK_UNSIGNED_INT_MAX 4294967295UL
00118 #define MITK_LONG_MIN (-MITK_LARGE_INTEGER-1)
00119 #define MITK_LONG_MAX MITK_LARGE_INTEGER
00120 #define MITK_UNSIGNED_LONG_MIN 0
00121 #define MITK_UNSIGNED_LONG_MAX 4294967295UL
00122 #define MITK_FLOAT_MIN -MITK_LARGE_FLOAT
00123 #define MITK_FLOAT_MAX MITK_LARGE_FLOAT
00124 #define MITK_DOUBLE_MIN -1.0e+99L
00125 #define MITK_DOUBLE_MAX  1.0e+99L
00126 
00127 // These types are returned to distinguish data object types
00128 #define MITK_DATA_OBJECT                 0
00129 #define MITK_VOLUME                   1000
00130 #define MITK_IC_VOLUME                1001
00131 #define MITK_OOC_VOLUME               1002
00132 #define MITK_PARALLEL_PROJECT_DATA    1003
00133 #define MITK_OUT_OF_CORE_PARALLEL_PROJECT_DATA  1004
00134 #define MITK_COHERENT_VOLUME          1005
00135 
00136 #define MITK_MESH                     2000
00137 #define MITK_TRIANGLE_MESH            2001
00138 #define MITK_IC_TRIANGLE_MESH         2002
00139 #define MITK_OOC_TRIANGLE_MESH        2003
00140 #define MITK_HE_MESH                  2004
00141 #define MITK_HE_TRIANGLE_MESH         2005
00142 #define MITK_HE_IC_TRIANGLE_MESH      2006
00143 #define MITK_HE_OOC_TRIANGLE_MESH     2007
00144 
00145 #define MITK_RAW_DATA                 3000
00146 #define MITK_CT_PROJECTION_DATA       3001
00147 #define MITK_2D_BEAM_PD               3002
00148 #define MITK_2D_BEAM_IC_PD            3003
00149 #define MITK_2D_BEAM_OOC_PD           3004
00150 #define MITK_2D_BEAM_REAL_TIME_PD     3005
00151 #define MITK_CONE_BEAM_PD             3006
00152 #define MITK_CONE_BEAM_IC_PD          3007
00153 #define MITK_CONE_BEAM_OOC_PD         3008
00154 #define MITK_CONE_BEAM_REAL_TIME_PD   3009
00155 #define MITK_TRACKED_BSCAN_DATA       3010
00156 #define MITK_TRACKED_BSCAN_IC_DATA    3011
00157 #define MITK_TRACKED_BSCAN_OOC_DATA   3012
00158 
00159 
00160 #define MITK_IMAGE                    5001
00161 #define MITK_PIECEWISE_FUNCTION       5002
00162 #define MITK_IMAGE_DATA               5003
00163 #define MITK_IMAGE_RAWCT              5004
00164 #define MITK_POLY_DATA                5005
00165 #define MITK_RAWCT_DATA               5006
00166 
00167 #define MITK_LEFTBUTTON    0
00168 #define MITK_MIDDLEBUTTON  1
00169 #define MITK_RIGHTBUTTON   2
00170 
00171 #define MITK_CTRLKEY         0
00172 #define MITK_SHIFTKEY        1
00173 #define MITK_CTRLANDSHIFTKEY 2
00174 
00175 #define MITK_NEAREST_INTERPOLATION 0
00176 #define MITK_LINEAR_INTERPOLATION  1 
00177 #define MITK_BILINEAR_INTERPOLATION 2
00178 
00179 #define MITK_FLOAT_PI  3.14159265358979323846f
00180 #define MITK_DOUBLE_PI 3.14159265358979323846
00181 //
00182 // These swap macros are used for processing endian problem
00183 //
00184 #define Swap16(shortX) shortX = ((shortX & 0x00FF) << 8) | ((shortX & 0xFF00) >> 8)
00185 
00186 #define Swap32(intX) \
00187       intX = ((intX & 0x000000FF) << 24) \
00188            | ((intX & 0x0000FF00) << 8) \
00189            | ((intX & 0x00FF0000) >> 8) \
00190            | ((intX & 0xFF000000) >> 24)
00191 
00192 #define Swap64(lowX,highX) \
00193 {     Swap32(lowX); \
00194       Swap32(highX); \
00195       unsigned long swaptmp = lowX; \
00196       lowX = highX; \
00197       highX = swaptmp; \
00198 }
00199 
00200 //
00201 // Macro for floor of x
00202 //
00203 #define mitkFloorFuncMacro(x)   (((x) < 0.0)?((int)((x)-1.0)):((int)(x)))
00204 
00205 //
00206 // Macro for rounding x
00207 //
00208 #define mitkRoundFuncMacro(x)   (int)((x)+0.5)
00209 
00210 //
00211 // Macro for tri-linear interpolation - do four linear interpolations on
00212 // edges, two linear interpolations between pairs of edges, then a final
00213 // interpolation between faces
00214 //
00215 #define mitkTrilinFuncMacro(v,x,y,z,a,b,c,d,e,f,g,h)         \
00216 {       t00 =   a + (x)*(b-a);      \
00217         t01 =   c + (x)*(d-c);      \
00218         t10 =   e + (x)*(f-e);      \
00219         t11 =   g + (x)*(h-g);      \
00220         t0  = t00 + (y)*(t01-t00);  \
00221         t1  = t10 + (y)*(t11-t10);  \
00222         v   =  t0 + (z)*(t1-t0); }
00223 
00224 //
00225 // This macro is used for  print information in non-member methods
00226 // mitkGenericMessage("this is debug info" << this->SomeVariable);
00227 //
00228 #define mitkGenericMessage(x) \
00229 {     ostringstream mitkmsg; \
00230       mitkmsg << x << "\n"; \
00231       mitkDisplayMessage(mitkmsg.str().c_str());}
00232 
00233 //
00234 // This macro is used to print out debug message in a member function
00235 // of mitkObject derived class
00236 // mitkDebugMessage("this is debug info" << this->SomeVariable);
00237 //
00238 #define mitkDebugMessage(x) \
00239 { if (this->m_Debug ) \
00240     { ostringstream mitkmsg; \
00241       mitkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" << this->GetClassname() << " (" << this << "): " << x  << "\n\n"; \
00242       mitkDisplayMessage(mitkmsg.str().c_str());}}
00243 
00244 //
00245 // This macro is used to print out warning message in a member function
00246 // of mitkObject derived class
00247 // mitkWarningMessage("Warning message" << variable);
00248 //
00249 #define mitkWarningMessage(x) \
00250 {     ostringstream mitkmsg; \
00251       mitkmsg << "Warning: In " __FILE__ ", line " << __LINE__ << "\n" << this->GetClassname() << " (" << this << "): " << x << "\n\n"; \
00252       mitkDisplayMessage(mitkmsg.str().c_str());}
00253 
00254 //
00255 // This macro is used to print out error message in a member function
00256 // of mitkObject derived class
00257 // mitkErrorMessage("Error message" << variable);
00258 //
00259 #define mitkErrorMessage(x) \
00260 {     ostringstream mitkmsg; \
00261       mitkmsg << "ERROR: In " __FILE__ ", line " << __LINE__ << "\n" << this->GetClassname() << " (" << this << "): " << x << "\n\n"; \
00262       mitkDisplayMessage(mitkmsg.str().c_str());\
00263       mitkObject::BreakOnError();}
00264 
00265 #define MITK_TYPE(thisClass,superclass) \
00266   virtual const char *GetClassname() const {return #thisClass;} \
00267   static int IsTypeOf(const char *type) \
00268   { \
00269     if ( !strcmp(#thisClass,type) ) \
00270       { \
00271       return 1; \
00272       } \
00273     return superclass::IsTypeOf(type); \
00274   } \
00275   virtual int IsA(const char *type) \
00276   { \
00277     return this->thisClass::IsTypeOf(type); \
00278   } \
00279   static thisClass* SafeDownCast(mitkObject *o) \
00280   { \
00281     if ( o && o->IsA(#thisClass) ) \
00282       { \
00283       return static_cast<thisClass *>(o); \
00284       } \
00285     return NULL;\
00286   } 
00287 
00288 MITK_COMMON_API char const* mitkGetDataTypeName(int dataType); 
00289 MITK_COMMON_API int mitkGetDataTypeFromName(char const *name);
00290 MITK_COMMON_API int mitkGetDataTypeBits(int dataType);
00291 MITK_COMMON_API int mitkGetDataTypeSize(int dataType);
00292 MITK_COMMON_API double mitkGetDataTypeMin(int dataType);
00293 MITK_COMMON_API double mitkGetDataTypeMax(int dataType);
00294 
00295 #include "mitk_nl/mitk_nl_vector.h"
00296 
00297 typedef double                  ScalarParameterType;
00298 typedef float                   ScalarPixelType;
00299 typedef int                     ScalarIndexType;
00300 typedef mitk_nl_vector<double>  VectorParameterType;
00301 typedef mitk_nl_vector<float>   VectorPixelType;
00302 typedef mitk_nl_vector<int>     VectorIndexType;
00303 
00304 #define MITK_VER_OOC
00305 
00306 #endif
00307 
00308 

Generated on Tue Feb 25 15:00:37 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3