ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkNthElementImageAdaptor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkNthElementImageAdaptor_h
00019 #define __itkNthElementImageAdaptor_h
00020 
00021 #include "itkImageAdaptor.h"
00022 #include "itkNthElementPixelAccessor.h"
00023 
00024 namespace itk
00025 {
00044 // Create a helper class to help the SunPro CC compiler
00045 // parse the templates for the NthElementImageAdaptor.
00046 // This is used to define the Super class.  for NthElementImageAdaptor
00047 template< class TImage, class TOutputPixelType >
00048 class ITK_EXPORT NthElementImageAdaptorHelper
00049 {
00050 public:
00051   typedef  NthElementPixelAccessor<
00052     TOutputPixelType,
00053     typename TImage::PixelType > PixelAccessor;
00054 
00055   typedef  ImageAdaptor< TImage, PixelAccessor > Super;
00056 };
00057 
00058 template< class TImage, class TOutputPixelType >
00059 class ITK_EXPORT NthElementImageAdaptor:
00060   public NthElementImageAdaptorHelper< TImage, TOutputPixelType >::Super
00061 {
00062 public:
00064   typedef NthElementImageAdaptor                                                   Self;
00065   typedef typename NthElementImageAdaptorHelper< TImage, TOutputPixelType >::Super Superclass;
00066   typedef SmartPointer< Self >                                                     Pointer;
00067   typedef SmartPointer< const Self >                                               ConstPointer;
00068 
00070   itkTypeMacro(NthElementImageAdaptor, ImageAdaptor);
00071 
00073   itkNewMacro(Self);
00074 
00076   void SelectNthElement(unsigned int nth)
00077   {
00078     this->GetPixelAccessor().SetElementNumber(nth);
00079     this->Modified();
00080   }
00082 
00083 protected:
00084   NthElementImageAdaptor() {}
00085   virtual ~NthElementImageAdaptor() {}
00086 private:
00087   NthElementImageAdaptor(const Self &); //purposely not implemented
00088   void operator=(const Self &);         //purposely not implemented
00089 };
00090 } // end namespace itk
00091 
00092 #endif
00093