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

itkNumericTraitsRGBPixel.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkNumericTraitsRGBPixel.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-07-03 22:16:03 $
00007   Version:   $Revision: 1.14 $
00008 
00009   Copyright (c) Insight Software 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 #ifndef __itkNumericTraitsRGBPixel_h
00018 #define __itkNumericTraitsRGBPixel_h
00019 
00020 #include "itkNumericTraits.h"
00021 #include "itkRGBPixel.h"
00022 
00023 
00024 namespace itk
00025 {
00026 
00027 //
00028 // First we define a macro that can be customized to be used for a sequence of
00029 // specializations or for a generic template instantiation. This Macro covers
00030 // the implementation for good compilers and for Visual Studio 6.0.
00031 //
00032 #define itkNumericTraitsRGBPixelMacro(T) \
00033 template < _TEMPLATE_ARGUMENT_ >  \
00034 class NumericTraits<RGBPixel< T > >  \
00035 { \
00036 public: \
00037   typedef T ValueType; \
00038  \
00039   typedef _TYPENAME_ NumericTraits<T>::AbsType        ElementAbsType; \
00040   typedef _TYPENAME_ NumericTraits<T>::AccumulateType ElementAccumulateType; \
00041   typedef _TYPENAME_ NumericTraits<T>::FloatType      ElementFloatType; \
00042   typedef _TYPENAME_ NumericTraits<T>::PrintType      ElementPrintType; \
00043   typedef _TYPENAME_ NumericTraits<T>::RealType       ElementRealType; \
00044  \
00045   typedef RGBPixel<T>                   Self; \
00046  \
00047   typedef RGBPixel<ElementAbsType>          AbsType; \
00048   typedef RGBPixel<ElementAccumulateType>   AccumulateType; \
00049   typedef RGBPixel<ElementFloatType>        FloatType; \
00050   typedef Self                              PrintType; \
00051   typedef RGBPixel<ElementRealType>         RealType; \
00052  \
00053   typedef ElementRealType ScalarRealType; \
00054  \
00055   static const RealType max( const Self & a ) \
00056     {  \
00057       RealType b(a.Size());  \
00058       b.Fill( NumericTraits< T >::max() ); \
00059       return b; \
00060     } \
00061   static const RealType min( const Self & a ) \
00062     {  \
00063       RealType b(a.Size());  \
00064       b.Fill( NumericTraits< T >::min() ); \
00065       return b; \
00066     } \
00067   static const Self ZeroValue() \
00068   {  \
00069     Self b; \
00070     b.Fill( NumericTraits< T >::Zero ); \
00071     return b; \
00072   } \
00073   static const Self OneValue() \
00074   {  \
00075     Self b; \
00076     b.Fill( NumericTraits< T >::One ); \
00077     return b; \
00078   } \
00079   static const Self ITKCommon_EXPORT Zero; \
00080   static const Self ITKCommon_EXPORT One; \
00081 };
00082 
00083 
00084 //
00085 // Visual Studio 6.0 is not capable of managing the template implementation
00086 // defined at the end of this file. Therefore we provide an alternative
00087 // primitive implementation based on macros that define explicit
00088 // instantiations.
00089 //
00090 #if defined( _MSC_VER ) && ( _MSC_VER < 1310 )
00091 
00092 // These two symbols below are defined empty on purpose
00093 #define _TYPENAME_
00094 #define _TEMPLATE_ARGUMENT_
00095 
00096 //
00097 // List here the specializations of the Traits:
00098 //
00099 itkNumericTraitsRGBPixelMacro( char );
00100 itkNumericTraitsRGBPixelMacro( unsigned char );
00101 itkNumericTraitsRGBPixelMacro( short );
00102 itkNumericTraitsRGBPixelMacro( unsigned short );
00103 itkNumericTraitsRGBPixelMacro( int );
00104 itkNumericTraitsRGBPixelMacro( unsigned int );
00105 itkNumericTraitsRGBPixelMacro( long );
00106 itkNumericTraitsRGBPixelMacro( unsigned long );
00107 itkNumericTraitsRGBPixelMacro( float );
00108 itkNumericTraitsRGBPixelMacro( double );
00109 
00110 #else
00111 
00112 // For all the other good compilers, we provide here a generic implementation
00113 // based on creating types of RGBPixels whose components are the types of the
00114 // NumericTraits from the original RGBPixel components. This implementation
00115 // doesn't require specializations, since it is based on the concept that 
00116 //
00117 //    NumericTraits< RGBAPixle< T > >  is defined piecewise by
00118 //    RGBAPixle< NumericTraits< T > >
00119 //
00120 //
00121 // By defining the following symbols, the Macro above gets customized to become
00122 // a generic template implementation of the traits
00123 //
00124 #define _TYPENAME_            typename
00125 #define _TEMPLATE_ARGUMENT_   class T
00126 
00127 //
00128 // Then we simply call the macro once with the generic template argument T.
00129 //
00130 itkNumericTraitsRGBPixelMacro( T );
00131 
00132 #endif
00133 
00134 
00135 
00136 //
00137 // Finally, to avoid contamination of other files with the symbols defined
00138 // here, we undefine the helper macros
00139 //
00140 #undef _TYPENAME_
00141 #undef _TEMPLATE_ARGUMENT_
00142 
00143 
00144 } // end namespace itk
00145 
00146 #endif // __itkNumericTraitsRGBPixel_h
00147 
00148 

Generated at Wed Nov 5 23:15:31 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000