19#ifndef itkMeshConvertPixelTraits_h
20#define itkMeshConvertPixelTraits_h
45template <
typename PixelType>
56 return PixelType::GetNumberOfComponents();
62 return PixelType::GetNumberOfComponents();
69 return pixel.GetNthComponent(c);
76 pixel.SetNthComponent(c, v);
83 return pixel.GetScalarValue();
87#define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type) \
89 class MeshConvertPixelTraits<type> \
92 using ComponentType = type; \
94 GetNumberOfComponents() \
99 GetNumberOfComponents(const type & itkNotUsed(pixel)) \
103 static ComponentType \
104 GetNthComponent(int itkNotUsed(c), const type & pixel) \
109 SetNthComponent(int, type & pixel, const ComponentType & v) \
114 GetScalarValue(const type & pixel) \
135#undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
141#define ITK_MESH_DEFAULTCONVERTTRAITS_OFFSET_TYPE(dimension) \
143 class MeshConvertPixelTraits<Offset<dimension>> \
146 using TargetType = Offset<dimension>; \
147 using ComponentType = TargetType::OffsetValueType; \
148 static unsigned int \
149 GetNumberOfComponents() \
153 static unsigned int \
154 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
158 static ComponentType \
159 GetNthComponent(int c, const TargetType & pixel) \
164 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
168 static ComponentType \
169 GetScalarValue(const TargetType & pixel) \
187#define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(type, componenttype, dimension) \
189 class MeshConvertPixelTraits<type<componenttype, dimension>> \
192 using TargetType = type<componenttype, dimension>; \
193 using ComponentType = componenttype; \
194 static unsigned int \
195 GetNumberOfComponents() \
199 static unsigned int \
200 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
204 static ComponentType \
205 GetNthComponent(int c, const TargetType & pixel) \
210 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
214 static ComponentType \
215 GetScalarValue(const TargetType & pixel) \
227#define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, Type) \
228 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 1); \
229 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 2); \
230 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 3); \
231 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 4); \
232 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 5); \
233 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE(ArrayType, Type, 6); \
234 ITK_MACROEND_NOOP_STATEMENT
236#define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(ArrayType) \
237 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, char); \
238 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, signed char); \
239 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned char); \
240 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, short); \
241 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned short); \
242 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, int); \
243 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned int); \
244 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, long); \
245 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned long); \
246 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, long long); \
247 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, unsigned long long); \
248 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, float); \
249 ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_MACRO(ArrayType, double); \
250 ITK_MACROEND_NOOP_STATEMENT
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); \
317 ITK_MACROEND_NOOP_STATEMENT
319#define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_TYPES_MACRO(ArrayType) \
320 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, char); \
321 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, signed char); \
322 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned char); \
323 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, short); \
324 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned short); \
325 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, int); \
326 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned int); \
327 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, long); \
328 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned long); \
329 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, long long); \
330 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, unsigned long long); \
331 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, float); \
332 ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_MACRO(ArrayType, double); \
333 ITK_MACROEND_NOOP_STATEMENT
350#define ITK_MESH_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(componenttype) \
352 class MeshConvertPixelTraits<std::complex<componenttype>> \
355 using TargetType = std::complex<componenttype>; \
356 using ComponentType = componenttype; \
357 static unsigned int \
358 GetNumberOfComponents() \
362 static unsigned int \
363 GetNumberOfComponents(const TargetType & itkNotUsed(pixel)) \
367 static ComponentType \
368 GetNthComponent(int i, TargetType & pixel) \
372 return pixel.imag(); \
376 return pixel.real(); \
380 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
384 pixel = TargetType(v, pixel.imag()); \
388 pixel = TargetType(pixel.real(), v); \
391 static ComponentType \
392 GetScalarValue(const TargetType & pixel) \
394 return std::norm(pixel); \
401#define ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(type, componenttype) \
403 class MeshConvertPixelTraits<type<componenttype>> \
406 using TargetType = type<componenttype>; \
407 using ComponentType = componenttype; \
408 static unsigned int \
409 GetNumberOfComponents() \
413 static unsigned int \
414 GetNumberOfComponents(const TargetType & pixel) \
416 return pixel.Size(); \
418 static ComponentType \
419 GetNthComponent(int c, const TargetType & pixel) \
424 SetNthComponent(int i, TargetType & pixel, const ComponentType & v) \
428 static ComponentType \
429 GetScalarValue(const TargetType & pixel) \
435#define ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE_ALL_TYPES_MACRO(ArrayType) \
436 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, char); \
437 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, signed char); \
438 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned char); \
439 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, short); \
440 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned short); \
441 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, int); \
442 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned int); \
443 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, long); \
444 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned long); \
445 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, long long); \
446 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, unsigned long long); \
447 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, float); \
448 ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE(ArrayType, double); \
449 ITK_MACROEND_NOOP_STATEMENT
Array class with size defined at construction time.
A templated class holding a n-Dimensional covariant vector.
Simulate a standard C array with copy semantics.
A templated class holding a M x N size Matrix.
Traits class used to by ConvertPixels to convert blocks of pixels.
static unsigned int GetNumberOfComponents(const PixelType &)
static unsigned int GetNumberOfComponents()
static void SetNthComponent(int c, PixelType &pixel, const ComponentType &v)
static ComponentType GetNthComponent(int c, const PixelType &pixel)
typename PixelType::ComponentType ComponentType
static ComponentType GetScalarValue(const PixelType &pixel)
A templated class holding a geometric point in n-Dimensional space.
A templated class holding a n-Dimensional vector.
#define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type)
#define ITK_MESH_DEFAULTCONVERTTRAITS_OFFSET_TYPE(dimension)
#define ITK_MESH_DEFAULTCONVERTTRAITS_ARRAY_TYPE_ALL_TYPES_MACRO(ArrayType)
#define ITK_MESH_DEFAULTCONVERTTRAITS_MATRIX_TYPE_ALL_TYPES_MACRO(ArrayType)
#define ITK_MESH_DEFAULTCONVERTTRAITS_FIXEDARRAY_TYPE_ALL_TYPES_MACRO(ArrayType)
#define ITK_MESH_DEFAULTCONVERTTRAITS_COMPLEX_TYPE(componenttype)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....