00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkVectorImageToImageAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-03-03 15:11:40 $ 00007 Version: $Revision: 1.10 $ 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 __itkVectorImageToImageAdaptor_h 00018 #define __itkVectorImageToImageAdaptor_h 00019 00020 #include "itkImageAdaptor.h" 00021 #include "itkVectorImage.h" 00022 00023 namespace itk 00024 { 00025 namespace Accessor 00026 { 00027 00042 template <class TType > 00043 class ITK_EXPORT VectorImageToImagePixelAccessor 00044 { 00045 public: 00046 00047 typedef unsigned int VectorLengthType; 00048 00051 typedef TType ExternalType; 00052 00055 typedef VariableLengthVector< TType > InternalType; 00056 00058 typedef TType PixelType; 00059 00060 inline void Set(InternalType output, const ExternalType & input) const 00061 { 00062 output[m_ComponentIdx] = input; 00063 } 00064 00065 inline ExternalType Get( const InternalType & input ) const 00066 { 00067 ExternalType output; 00068 output = input[m_ComponentIdx]; 00069 return output; 00070 } 00071 00072 void SetExtractComponentIdx( VectorLengthType idx ) 00073 { 00074 m_ComponentIdx = idx; 00075 } 00076 VectorLengthType GetExtractComponentIdx() const 00077 { 00078 return m_ComponentIdx; 00079 } 00080 00081 VectorImageToImagePixelAccessor() : m_ComponentIdx( 0 ) {}; 00082 virtual ~VectorImageToImagePixelAccessor() {}; 00083 00084 private: 00085 VectorLengthType m_ComponentIdx; 00086 }; 00087 00088 } // end namespace Accessor 00089 00107 template<class TPixelType, unsigned int Dimension> 00108 class ITK_EXPORT VectorImageToImageAdaptor : public 00109 ImageAdaptor< VectorImage< TPixelType, Dimension >, 00110 Accessor::VectorImageToImagePixelAccessor< TPixelType > > 00111 { 00112 public: 00114 typedef VectorImageToImageAdaptor Self; 00115 typedef VectorImage< TPixelType, Dimension > VectorImageType; 00116 typedef ImageAdaptor< VectorImageType, 00117 Accessor::VectorImageToImagePixelAccessor< TPixelType > > Superclass; 00118 typedef SmartPointer<Self> Pointer; 00119 typedef SmartPointer<const Self> ConstPointer; 00120 00122 itkNewMacro(Self); 00123 00125 itkTypeMacro( VectorImageToImageAdaptor, ImageAdaptor ); 00126 00129 typedef typename Superclass::PixelContainer PixelContainer; 00130 typedef typename Superclass::PixelContainerPointer PixelContainerPointer; 00131 typedef typename Superclass::PixelContainerConstPointer PixelContainerConstPointer; 00132 typedef typename Superclass::IOPixelType IOPixelType; 00133 00135 typedef typename VectorImageType::VectorLengthType VectorLengthType; 00136 00137 // Set/GetMethods to set the component to be extracted. 00138 void SetExtractComponentIndex( VectorLengthType componentIdx ) 00139 { 00140 this->GetPixelAccessor().SetExtractComponentIdx( componentIdx ); 00141 } 00142 00143 // Set/GetMethods to set the component to be extracted. 00144 VectorLengthType GetExtractComponentIndex() const 00145 { 00146 return this->GetPixelAccessor().GetExtractComponentIdx(); 00147 } 00148 00149 protected: 00150 VectorImageToImageAdaptor() {} 00151 virtual ~VectorImageToImageAdaptor() {} 00152 00153 private: 00154 VectorImageToImageAdaptor(const Self&); //purposely not implemented 00155 void operator=(const Self&); //purposely not implemented 00156 00157 }; 00158 00159 00160 } // end namespace itk 00161 00162 #endif 00163