00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkVectorImageToImageAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/09/16 15:00:37 $ 00007 Version: $Revision: 1.4 $ 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 00090 00091 00109 template<class TPixelType, unsigned int Dimension> 00110 class ITK_EXPORT VectorImageToImageAdaptor : public 00111 ImageAdaptor< VectorImage< TPixelType, Dimension >, 00112 Accessor::VectorImageToImagePixelAccessor< TPixelType > > 00113 { 00114 public: 00116 typedef VectorImageToImageAdaptor Self; 00117 typedef VectorImage< TPixelType, Dimension > VectorImageType; 00118 typedef ImageAdaptor< VectorImageType, 00119 Accessor::VectorImageToImagePixelAccessor< TPixelType > > Superclass; 00120 typedef SmartPointer<Self> Pointer; 00121 typedef SmartPointer<const Self> ConstPointer; 00122 00124 itkNewMacro(Self); 00125 00127 itkTypeMacro( VectorImageToImagePixelAccessor, ImageAdaptor ); 00128 00131 typedef typename Superclass::PixelContainer PixelContainer; 00132 typedef typename Superclass::PixelContainerPointer PixelContainerPointer; 00133 typedef typename Superclass::PixelContainerConstPointer PixelContainerConstPointer; 00134 00136 typedef typename VectorImageType::VectorLengthType VectorLengthType; 00137 00138 // Set/GetMethods to set the component to be extracted. 00139 void SetExtractComponentIndex( VectorLengthType componentIdx ) 00140 { 00141 this->GetPixelAccessor().SetExtractComponentIdx( componentIdx ); 00142 } 00143 00144 // Set/GetMethods to set the component to be extracted. 00145 VectorLengthType GetExtractComponentIndex() const 00146 { 00147 return this->GetPixelAccessor().GetExtractComponentIdx(); 00148 } 00149 00150 protected: 00151 VectorImageToImageAdaptor() {} 00152 virtual ~VectorImageToImageAdaptor() {} 00153 00154 private: 00155 VectorImageToImageAdaptor(const Self&); //purposely not implemented 00156 void operator=(const Self&); //purposely not implemented 00157 00158 }; 00159 00160 00161 } // end namespace itk 00162 00163 #endif