|
ITK
5.2.0
Insight Toolkit
|
Go to the documentation of this file.
19 #ifndef itkMeshConvertPixelTraits_h
20 #define itkMeshConvertPixelTraits_h
45 template <
typename PixelType>
57 return PixelType::GetNumberOfComponents();
63 return PixelType::GetNumberOfComponents();
70 return pixel.GetNthComponent(c);
77 pixel.SetNthComponent(c, v);
84 return pixel.GetScalarValue();
89 #define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \
91 class MeshConvertPixelTraits<type> \
94 using ComponentType = type; \
96 GetNumberOfComponents() \
100 static unsigned int \
101 GetNumberOfComponents(const type & itkNotUsed(pixel)) \
105 static ComponentType \
106 GetNthComponent(int itkNotUsed(c), const type & pixel) \
111 SetNthComponent(int, type & pixel, const ComponentType & v) \
116 GetScalarValue(const type & pixel) \
137 #undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
143 #define ITK_MESH_DEFAULTCONVERTTRAITS_OFFSET_TYPE(dimension) \
145 class MeshConvertPixelTraits<Offset<dimension>> \
148 using TargetType = Offset<dimension>; \
149 using ComponentType = TargetType::OffsetValueType; \
150 static unsigned int \
151 GetNumberOfComponents() \
155 static unsigned int \
156 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
160 static ComponentType \
161 GetNthComponent(int c, const TargetType & pixel) \
166 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
170 static ComponentType \
171 GetScalarValue(const TargetType & pixel) \
189 #define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type, componenttype, dimension) \
191 class MeshConvertPixelTraits<type<componenttype, dimension>> \
194 using TargetType = type<componenttype, dimension>; \
195 using ComponentType = componenttype; \
196 static unsigned int \
197 GetNumberOfComponents() \
201 static unsigned int \
202 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
206 static ComponentType \
207 GetNthComponent(int c, const TargetType & pixel) \
212 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
216 static ComponentType \
217 GetScalarValue(const TargetType & pixel) \
229 #define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, Type) \
230 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 1) \
231 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 2) \
232 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 3) \
233 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 4) \
234 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 5) \
235 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 6)
237 #define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(ArrayType) \
238 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, char); \
239 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, signed char); \
240 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned char); \
241 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, short int); \
242 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned short int); \
243 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, int); \
244 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned int); \
245 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, long int); \
246 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned long int); \
247 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, long long int); \
248 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned long long int); \
249 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, float); \
250 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, double);
267 #define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(type, componenttype, rows, cols) \
269 class MeshConvertPixelTraits<type<componenttype, rows, cols>> \
272 using TargetType = type<componenttype, rows, cols>; \
273 using ComponentType = componenttype; \
274 static unsigned int \
275 GetNumberOfComponents() \
277 return rows * cols; \
279 static unsigned int \
280 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
282 return rows * cols; \
284 static ComponentType \
285 GetNthComponent(int c, const TargetType & pixel) \
287 const unsigned int row = c / cols; \
288 const unsigned int col = c % cols; \
289 return pixel[row][col]; \
292 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
294 const unsigned int row = i / cols; \
295 const unsigned int col = i % cols; \
296 pixel[row][col] = v; \
298 static ComponentType \
299 GetScalarValue(const TargetType & pixel) \
301 return pixel[0][0]; \
310 #define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, Type) \
311 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 1, 1) \
312 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 2, 2) \
313 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 3, 3) \
314 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 4, 4) \
315 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 5, 5) \
316 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 6, 6)
318 #define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_TYPES_MACRO(ArrayType) \
319 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, char); \
320 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, signed char); \
321 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned char); \
322 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, short int); \
323 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned short int); \
324 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, int); \
325 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned int); \
326 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, long int); \
327 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned long int); \
328 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, long long int); \
329 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned long long int); \
330 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, float); \
331 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, double);
348 #define ITK_MESH_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(componenttype) \
350 class MeshConvertPixelTraits<::std::complex<componenttype>> \
353 using TargetType = ::std::complex<componenttype>; \
354 using ComponentType = componenttype; \
355 static unsigned int \
356 GetNumberOfComponents() \
360 static unsigned int \
361 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
365 static ComponentType \
366 GetNthComponent(int i, TargetType & pixel) \
370 return pixel.imag(); \
374 return pixel.real(); \
378 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
382 pixel = TargetType(v, pixel.imag()); \
386 pixel = TargetType(pixel.real(), v); \
389 static ComponentType \
390 GetScalarValue(const TargetType & pixel) \
392 return std::norm(pixel); \
399 #define ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(type, componenttype) \
401 class MeshConvertPixelTraits<type<componenttype>> \
404 using TargetType = type<componenttype>; \
405 using ComponentType = componenttype; \
406 static unsigned int \
407 GetNumberOfComponents() \
411 static unsigned int \
412 GetNumberOfComponents(const TargetType & pixel) \
414 return pixel.Size(); \
416 static ComponentType \
417 GetNthComponent(int c, const TargetType & pixel) \
422 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
426 static ComponentType \
427 GetScalarValue(const TargetType & pixel) \
433 #define ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE_ALL_TYPES_MACRO(ArrayType) \
434 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, char); \
435 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, signed char); \
436 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned char); \
437 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, short int); \
438 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned short int); \
439 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, int); \
440 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned int); \
441 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, long int); \
442 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned long int); \
443 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, long long int); \
444 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned long long int); \
445 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, float); \
446 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, double);
static unsigned int GetNumberOfComponents()
static ComponentType GetScalarValue(const PixelType &pixel)
static unsigned int GetNumberOfComponents(const PixelType &)
ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE_ALL_TYPES_MACRO(Array)
#define ITK_MESH_DEFAULTCONVERTTRAITS_OFFSET_TYPE(dimension)
typename PixelType::ComponentType ComponentType
Traits class used to by ConvertPixels to convert blocks of pixels.
ITK_MESH_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(float)
ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(Vector)
ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_TYPES_MACRO(Matrix)
static void SetNthComponent(int c, PixelType &pixel, const ComponentType &v)
ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
static ComponentType GetNthComponent(int c, const PixelType &pixel)