|
ITK
6.0.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); \
236 ITK_MACROEND_NOOP_STATEMENT
238 #define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(ArrayType) \
239 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, char); \
240 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, signed char); \
241 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned char); \
242 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, short); \
243 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned short); \
244 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, int); \
245 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned int); \
246 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, long); \
247 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned long); \
248 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, long long); \
249 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned long long); \
250 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, float); \
251 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, double); \
252 ITK_MACROEND_NOOP_STATEMENT
269 #define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(type, componenttype, rows, cols) \
271 class MeshConvertPixelTraits<type<componenttype, rows, cols>> \
274 using TargetType = type<componenttype, rows, cols>; \
275 using ComponentType = componenttype; \
276 static unsigned int \
277 GetNumberOfComponents() \
279 return rows * cols; \
281 static unsigned int \
282 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
284 return rows * cols; \
286 static ComponentType \
287 GetNthComponent(int c, const TargetType & pixel) \
289 const unsigned int row = c / cols; \
290 const unsigned int col = c % cols; \
291 return pixel[row][col]; \
294 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
296 const unsigned int row = i / cols; \
297 const unsigned int col = i % cols; \
298 pixel[row][col] = v; \
300 static ComponentType \
301 GetScalarValue(const TargetType & pixel) \
303 return pixel[0][0]; \
312 #define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, Type) \
313 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 1, 1); \
314 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 2, 2); \
315 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 3, 3); \
316 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 4, 4); \
317 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 5, 5); \
318 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE(ArrayType, Type, 6, 6); \
319 ITK_MACROEND_NOOP_STATEMENT
321 #define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_TYPES_MACRO(ArrayType) \
322 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, char); \
323 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, signed char); \
324 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned char); \
325 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, short); \
326 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned short); \
327 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, int); \
328 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned int); \
329 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, long); \
330 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned long); \
331 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, long long); \
332 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned long long); \
333 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, float); \
334 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, double); \
335 ITK_MACROEND_NOOP_STATEMENT
352 #define ITK_MESH_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(componenttype) \
354 class MeshConvertPixelTraits<std::complex<componenttype>> \
357 using TargetType = std::complex<componenttype>; \
358 using ComponentType = componenttype; \
359 static unsigned int \
360 GetNumberOfComponents() \
364 static unsigned int \
365 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
369 static ComponentType \
370 GetNthComponent(int i, TargetType & pixel) \
374 return pixel.imag(); \
378 return pixel.real(); \
382 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
386 pixel = TargetType(v, pixel.imag()); \
390 pixel = TargetType(pixel.real(), v); \
393 static ComponentType \
394 GetScalarValue(const TargetType & pixel) \
396 return std::norm(pixel); \
403 #define ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(type, componenttype) \
405 class MeshConvertPixelTraits<type<componenttype>> \
408 using TargetType = type<componenttype>; \
409 using ComponentType = componenttype; \
410 static unsigned int \
411 GetNumberOfComponents() \
415 static unsigned int \
416 GetNumberOfComponents(const TargetType & pixel) \
418 return pixel.Size(); \
420 static ComponentType \
421 GetNthComponent(int c, const TargetType & pixel) \
426 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
430 static ComponentType \
431 GetScalarValue(const TargetType & pixel) \
437 #define ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE_ALL_TYPES_MACRO(ArrayType) \
438 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, char); \
439 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, signed char); \
440 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned char); \
441 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, short); \
442 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned short); \
443 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, int); \
444 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned int); \
445 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, long); \
446 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned long); \
447 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, long long); \
448 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned long long); \
449 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, float); \
450 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, double); \
451 ITK_MACROEND_NOOP_STATEMENT
static unsigned int GetNumberOfComponents()
static ComponentType GetScalarValue(const PixelType &pixel)
static unsigned int GetNumberOfComponents(const PixelType &)
ITK_MESH_DEFAULTCONVERTTRAITS_OFFSET_TYPE(1)
ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE_ALL_TYPES_MACRO(Array)
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)