00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkNthElementImageAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2008-01-13 19:48:38 $ 00007 Version: $Revision: 1.12 $ 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 __itkNthElementImageAdaptor_h 00018 #define __itkNthElementImageAdaptor_h 00019 00020 #include <itkImageAdaptor.h> 00021 #include <itkNthElementPixelAccessor.h> 00022 00023 namespace itk 00024 { 00025 00039 // Create a helper class to help the SunPro CC compiler 00040 // parse the templates for the NthElementImageAdaptor. 00041 // This is used to define the Super class. for NthElementImageAdaptor 00042 template <class TImage, class TOutputPixelType> 00043 class ITK_EXPORT NthElementImageAdaptorHelper 00044 { 00045 public: 00046 typedef NthElementPixelAccessor< 00047 TOutputPixelType, 00048 typename TImage::PixelType> PixelAccessor; 00049 00050 typedef ImageAdaptor<TImage, PixelAccessor> Super; 00051 }; 00052 00053 00054 00055 template <class TImage, class TOutputPixelType> 00056 class ITK_EXPORT NthElementImageAdaptor 00057 : public NthElementImageAdaptorHelper<TImage, TOutputPixelType>::Super 00058 { 00059 public: 00061 typedef NthElementImageAdaptor Self; 00062 typedef typename NthElementImageAdaptorHelper<TImage, TOutputPixelType>::Super Superclass; 00063 typedef SmartPointer<Self> Pointer; 00064 typedef SmartPointer<const Self> ConstPointer; 00065 00067 itkTypeMacro( NthElementImageAdaptor, ImageAdaptor ); 00068 00070 itkNewMacro(Self); 00071 00073 void SelectNthElement( unsigned int nth ) 00074 { this->GetPixelAccessor().SetElementNumber( nth ); 00075 this->Modified(); } 00077 00078 protected: 00079 NthElementImageAdaptor() {} 00080 virtual ~NthElementImageAdaptor() {} 00081 00082 private: 00083 NthElementImageAdaptor(const Self&); //purposely not implemented 00084 void operator=(const Self&); //purposely not implemented 00085 }; 00086 00087 00088 } // end namespace itk 00089 00090 #endif 00091