Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __cmtkTypes_h_included_
00034 #define __cmtkTypes_h_included_
00035
00036 #include <cmtkconfig.h>
00037
00038 #include <Base/cmtkMathUtil.h>
00039
00040 #include <stdlib.h>
00041 #include <limits.h>
00042 #include <cfloat>
00043 #include <cstddef>
00044
00045 #ifdef HAVE_VALUES_H
00046 # include <values.h>
00047 #endif
00048
00049 #ifdef _MSC_VER
00050 typedef unsigned short ushort;
00051 #endif
00052
00053 #ifndef NULL
00054 #define NULL 0
00055 #endif
00056
00057 #ifndef _HAVE_BYTE_
00058 typedef unsigned char byte;
00059 #define _HAVE_BYTE_
00060 #endif // #ifndef _HAVE_BYTE_
00061
00062 namespace
00063 cmtk
00064 {
00065
00068
00074 enum
00075 {
00077 AXIS_X = 0,
00079 AXIS_Y = 1,
00081 AXIS_Z = 2
00082 };
00083
00085 typedef enum
00086 {
00088 DATACLASS_GREY,
00090 DATACLASS_LABEL,
00092 DATACLASS_UNKNOWN
00093 } DataClass;
00094
00096 DataClass StringToDataClass( const char *dataClassStr );
00097
00099 const char* DataClassToString( const DataClass dataClass );
00100
00102 typedef enum
00103 {
00105 TYPE_BYTE = 0,
00107 TYPE_CHAR = 1,
00109 TYPE_SHORT = 2,
00111 TYPE_USHORT = 3,
00113 TYPE_INT = 4,
00115 TYPE_UINT = 5,
00117 TYPE_FLOAT = 6,
00119 TYPE_DOUBLE = 7,
00121 TYPE_NONE = -1
00122 } ScalarDataType;
00123
00125 extern const char* DataTypeName[];
00126
00127 #ifdef CMTK_DATA_FLOAT
00128 namespace Types
00129 {
00133 typedef float DataItem;
00134 }
00135 const ScalarDataType TYPE_ITEM = TYPE_FLOAT;
00136 #define CMTK_ITEM_MAX FLT_MAX
00137 #define CMTK_ITEM_MIN FLT_MIN
00138 #define CMTK_ITEM_NAN CMTK_FLOAT_NAN
00139 #else
00140 namespace Types
00141 {
00142 typedef double DataItem;
00143 }
00144 const ScalarDataType TYPE_ITEM = TYPE_DOUBLE;
00145 #define CMTK_ITEM_MAX DBL_MAX
00146 #define CMTK_ITEM_MIN DBL_MIN
00147 #define CMTK_ITEM_NAN CMTK_DOUBLE_NAN
00148 #endif // #ifdef CMTK_DATA_FLOAT
00149
00150 namespace Types
00151 {
00152
00154 template<class T>
00155 class Range
00156 {
00157 public:
00159 Range() {}
00160
00162 Range( const T& lowerBound, const T& upperBound ) : m_LowerBound( lowerBound ), m_UpperBound( upperBound ) {}
00163
00165 template<class T2>
00166 explicit Range( const Range<T2>& range ) : m_LowerBound( range.m_LowerBound ), m_UpperBound( range.m_UpperBound ) {}
00167
00169 T Width() const
00170 {
00171 return this->m_UpperBound - this->m_LowerBound;
00172 }
00173
00175 T m_LowerBound;
00176
00178 T m_UpperBound;
00179 };
00180
00182 typedef Range<DataItem> DataItemRange;
00183
00184 }
00185
00186 #ifdef CMTK_COORDINATES_FLOAT
00187
00190 namespace Types
00191 {
00192 typedef float Coordinate;
00193 }
00194 const ScalarDataType TYPE_COORDINATE = TYPE_FLOAT;
00195 #else
00196
00197 namespace Types
00198 {
00199 typedef double Coordinate;
00200 }
00201 const ScalarDataType TYPE_COORDINATE = TYPE_DOUBLE;
00202 #endif
00203
00205 size_t TypeItemSize ( const ScalarDataType dtype );
00206
00208 ScalarDataType SelectDataTypeInteger( const byte itemSize,const bool signBit );
00209
00211 ScalarDataType GetSignedDataType( const ScalarDataType dtype );
00212
00214 ScalarDataType GetDifferenceDataType( const ScalarDataType dtype1, const ScalarDataType dtype2 );
00215
00217 ScalarDataType GetUnsignedDataType( const ScalarDataType dtype );
00218
00219 namespace
00220 Types
00221 {
00222
00224 template<class T1,class T2>
00225 class Combined
00226 {
00227 };
00228
00230 template<>
00231 class Combined<float,float>
00232 {
00233 public:
00235 typedef float Type;
00236 };
00237
00239 template<>
00240 class Combined<float,double>
00241 {
00242 public:
00244 typedef double Type;
00245 };
00246
00248 template<>
00249 class Combined<double,float>
00250 {
00251 public:
00253 typedef double Type;
00254 };
00255
00257 template<>
00258 class Combined<double,double>
00259 {
00260 public:
00262 typedef double Type;
00263 };
00264
00265 }
00266
00268
00269 }
00270
00271 #endif // #ifndef __cmtkTypes_h_included_