00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
#ifndef __itkDefaultConvertPixelTraits_h
00019
#define __itkDefaultConvertPixelTraits_h
00020
00021
#include "itkOffset.h"
00022
#include "itkCovariantVector.h"
00023
#include "itkVector.h"
00024
#include "itkPoint.h"
00025
00026
namespace itk
00027 {
00028
00038
template<
typename PixelType>
00039 class DefaultConvertPixelTraits
00040 {
00041
public:
00043 typedef typename PixelType::ComponentType
ComponentType;
00044
00046 static unsigned int GetNumberOfComponents()
00047 {
return PixelType::GetNumberOfComponents();}
00048
00050 static ComponentType GetNthComponent(
int c,
const PixelType& pixel)
00051 {
return pixel.GetNthComponent(c); }
00052
00054 static void SetNthComponent(
int c, PixelType& pixel,
const ComponentType& v)
00055 { pixel.SetNthComponent(c, v); }
00056
00058 static ComponentType GetScalarValue(
const PixelType& pixel)
00059 {
return pixel.GetScalarValue(); }
00060
00061 };
00062
00063 #define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \
00064
template<> \
00065
class DefaultConvertPixelTraits<type> \
00066
{ \
00067
public: \
00068
typedef type ComponentType; \
00069
static unsigned int GetNumberOfComponents() \
00070
{ \
00071
return 1; \
00072
} \
00073
static void SetNthComponent(int , type& pixel, const ComponentType& v) \
00074
{ \
00075
pixel = v; \
00076
} \
00077
static type GetScalarValue(const type& pixel) \
00078
{ \
00079
return pixel; \
00080
} \
00081
};
00082
00083
00084
ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
float)
00085 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
double)
00086 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
int)
00087 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
char)
00088 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
short)
00089 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
unsigned int)
00090 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
unsigned char)
00091 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
unsigned short)
00092 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
long)
00093 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(
unsigned long)
00094
00095 #undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
00096
00097
00098
00099
00100
00101
00102
00103
00104 #define ITK_DEFAULTCONVERTTRAITS_OFFSET_TYPE(dimension) \
00105 template<> \
00106 class DefaultConvertPixelTraits< Offset<dimension> > \
00107 { \
00108
public: \
00109
typedef Offset<dimension> TargetType; \
00110
typedef TargetType::OffsetValueType ComponentType; \
00111
static unsigned int GetNumberOfComponents() \
00112 { \
00113
return dimension; \
00114 } \
00115
static void SetNthComponent(
int i, TargetType & pixel,
const ComponentType& v) \
00116 { \
00117 pixel[i] = v; \
00118 } \
00119
static ComponentType GetScalarValue(
const TargetType& pixel) \
00120 { \
00121
return pixel[0]; \
00122 } \
00123 }; \
00124
00125
00126
00127
ITK_DEFAULTCONVERTTRAITS_OFFSET_TYPE(1)
00128 ITK_DEFAULTCONVERTTRAITS_OFFSET_TYPE(2)
00129 ITK_DEFAULTCONVERTTRAITS_OFFSET_TYPE(3)
00130 ITK_DEFAULTCONVERTTRAITS_OFFSET_TYPE(4)
00131 ITK_DEFAULTCONVERTTRAITS_OFFSET_TYPE(5)
00132
00133
00134
00135
00136
00137
00138
00139
00140 #define ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type,componenttype, dimension) \
00141 template<> \
00142 class DefaultConvertPixelTraits< type< componenttype, dimension> > \
00143 { \
00144
public: \
00145
typedef type< componenttype, dimension > TargetType; \
00146
typedef componenttype ComponentType; \
00147
static unsigned int GetNumberOfComponents() \
00148 { \
00149
return dimension; \
00150 } \
00151
static void SetNthComponent(
int i, TargetType & pixel,
const ComponentType& v) \
00152 { \
00153 pixel[i] = v; \
00154 } \
00155
static ComponentType GetScalarValue(
const TargetType& pixel) \
00156 { \
00157
return pixel[0]; \
00158 } \
00159 }; \
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
float,1)
00172 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
float,2)
00173 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
float,3)
00174 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
float,4)
00175 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
float,5)
00176 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
float,6)
00177 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
double,2)
00178 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
double,3)
00179 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
double,4)
00180 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
double,5)
00181 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Vector,
double,6)
00182
00183 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
float,1)
00184 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
float,2)
00185 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
float,3)
00186 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
float,4)
00187 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
float,5)
00188 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
float,6)
00189 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
double,2)
00190 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
double,3)
00191 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
double,4)
00192 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
double,5)
00193 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(Point,
double,6)
00194
00195 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
float,1)
00196 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
float,2)
00197 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
float,3)
00198 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
float,4)
00199 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
float,5)
00200 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
float,6)
00201 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
double,2)
00202 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
double,3)
00203 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
double,4)
00204 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
double,5)
00205 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(CovariantVector,
double,6)
00206
00207 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
float,1)
00208 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
float,2)
00209 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
float,3)
00210 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
float,4)
00211 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
float,5)
00212 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
float,6)
00213 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
double,2)
00214 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
double,3)
00215 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
double,4)
00216 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
double,5)
00217 ITK_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(FixedArray,
double,6)
00218
00219
00220
00221
00222
00223
00224
00225
00226 }
00227
00228
00229 #endif