Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkDefaultConvertPixelTraits.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDefaultConvertPixelTraits.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/05/20 20:20:53 $
00007   Version:   $Revision: 1.5 $
00008 
00009   Copyright (c) 2002 Insight Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkDefaultConvertPixelTraits_h
00019 #define __itkDefaultConvertPixelTraits_h
00020 namespace itk
00021 {
00022   
00032 template<typename PixelType>
00033 class DefaultConvertPixelTraits
00034 {
00035 public:
00037   typedef typename PixelType::ComponentType ComponentType;
00038 
00040   static unsigned int GetNumberOfComponents() 
00041     { return PixelType::GetNumberOfComponents();}
00042   
00044   static ComponentType GetNthComponent(int c, const PixelType& pixel) 
00045     { return pixel.GetNthComponent(c); }
00046 
00048   static void SetNthComponent(int c, PixelType& pixel, const ComponentType& v) 
00049     { pixel.SetNthComponent(c, v); }
00050 
00052   static ComponentType GetScalarValue(const PixelType& pixel)
00053     { return pixel.GetScalarValue(); }
00054 
00055 };
00056 
00057 #define ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(type)                    \
00058 template<>                                                               \
00059 class DefaultConvertPixelTraits<type>                                    \
00060 {                                                                        \
00061 public:                                                                  \
00062   typedef type ComponentType;                                            \
00063   static unsigned int GetNumberOfComponents()                                     \
00064     {                                                                    \
00065       return 1;                                                          \
00066     }                                                                    \
00067   static void SetNthComponent(int , type& pixel, const ComponentType& v) \
00068     {                                                                    \
00069       pixel = v;                                                         \
00070     }                                                                    \
00071   static type GetScalarValue(const type& pixel)                          \
00072     {                                                                    \
00073       return pixel;                                                      \
00074     }                                                                    \
00075 };
00076 
00077 
00078 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(float)
00079 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(double)
00080 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(int)
00081 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(char)
00082 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(short)
00083 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned int)
00084 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned char)
00085 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned short)
00086 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(long)  
00087 ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL(unsigned long)
00088 
00089 #undef ITK_DEFAULTCONVERTTRAITS_NATIVE_SPECIAL
00090   
00091 } // end namespace itk
00092 
00093 
00094 
00095 #endif

Generated at Wed Mar 12 01:12:52 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000