00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkSpecialCoordinatesImage_h
00018 #define __itkSpecialCoordinatesImage_h
00019
00020 #include "itkImageBase.h"
00021 #include "itkImageRegion.h"
00022 #include "itkImportImageContainer.h"
00023 #include "itkDefaultPixelAccessor.h"
00024 #include "itkDefaultPixelAccessorFunctor.h"
00025 #include "itkPoint.h"
00026 #include "itkContinuousIndex.h"
00027 #include "itkFixedArray.h"
00028
00029 namespace itk
00030 {
00031
00095 template <class TPixel, unsigned int VImageDimension=2>
00096 class ITK_EXPORT SpecialCoordinatesImage : public ImageBase<VImageDimension>
00097 {
00098 public:
00100 typedef SpecialCoordinatesImage Self;
00101 typedef ImageBase<VImageDimension> Superclass;
00102 typedef SmartPointer<Self> Pointer;
00103 typedef SmartPointer<const Self> ConstPointer;
00104 typedef WeakPointer<const Self> ConstWeakPointer;
00105
00107 itkNewMacro(Self);
00108
00110 itkTypeMacro(SpecialCoordinatesImage, ImageBase);
00111
00114 typedef TPixel PixelType;
00115
00117 typedef TPixel ValueType ;
00118
00123 typedef TPixel InternalPixelType;
00124
00127 typedef DefaultPixelAccessor< PixelType > AccessorType;
00128
00132 typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
00133
00138 itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00139
00141 typedef ImportImageContainer<unsigned long, PixelType> PixelContainer;
00142
00144 typedef typename Superclass::IndexType IndexType;
00145
00147 typedef typename Superclass::OffsetType OffsetType;
00148
00150 typedef typename Superclass::SizeType SizeType;
00151
00153 typedef typename Superclass::RegionType RegionType;
00154
00159 typedef typename Superclass::SpacingType SpacingType;
00160
00163 typedef typename Superclass::PointType PointType;
00164
00166 typedef typename PixelContainer::Pointer PixelContainerPointer;
00167 typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00168
00171 void Allocate();
00172
00176 void SetRegions(RegionType region)
00177 {
00178 this->SetLargestPossibleRegion(region);
00179 this->SetBufferedRegion(region);
00180 this->SetRequestedRegion(region);
00181 };
00182
00183 void SetRegions(SizeType size)
00184 {
00185 RegionType region; region.SetSize(size);
00186 this->SetLargestPossibleRegion(region);
00187 this->SetBufferedRegion(region);
00188 this->SetRequestedRegion(region);
00189 };
00190
00193 virtual void Initialize();
00194
00197 void FillBuffer (const TPixel& value);
00198
00204 void SetPixel(const IndexType &index, const TPixel& value)
00205 {
00206 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00207 (*m_Buffer)[offset] = value;
00208 }
00209
00214 const TPixel& GetPixel(const IndexType &index) const
00215 {
00216 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00217 return ( (*m_Buffer)[offset] );
00218 }
00219
00224 TPixel& GetPixel(const IndexType &index)
00225 {
00226 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00227 return ( (*m_Buffer)[offset] );
00228 }
00229
00234 TPixel & operator[](const IndexType &index)
00235 { return this->GetPixel(index); }
00236
00241 const TPixel& operator[](const IndexType &index) const
00242 { return this->GetPixel(index); }
00243
00246 TPixel *GetBufferPointer()
00247 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00248 const TPixel *GetBufferPointer() const
00249 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00250
00252 PixelContainer* GetPixelContainer()
00253 { return m_Buffer.GetPointer(); }
00254
00255 const PixelContainer* GetPixelContainer() const
00256 { return m_Buffer.GetPointer(); }
00257
00260 void SetPixelContainer( PixelContainer *container );
00261
00263 AccessorType GetPixelAccessor( void )
00264 { return AccessorType(); }
00265
00267 const AccessorType GetPixelAccessor( void ) const
00268 { return AccessorType(); }
00269
00275 virtual void SetSpacing( const SpacingType ) {}
00276 virtual void SetSpacing( const double [VImageDimension] ) {}
00277 virtual void SetSpacing( const float [VImageDimension] ) {}
00278 virtual void SetOrigin( const PointType ) {}
00279 virtual void SetOrigin( const double [VImageDimension] ) {}
00280 virtual void SetOrigin( const float [VImageDimension] ) {}
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 protected:
00307 SpecialCoordinatesImage();
00308 void PrintSelf(std::ostream& os, Indent indent) const;
00309 virtual ~SpecialCoordinatesImage() {};
00310 private:
00311 SpecialCoordinatesImage(const Self&);
00312 void operator=(const Self&);
00313
00315 PixelContainerPointer m_Buffer;
00316 };
00317 #ifdef ITK_EXPLICIT_INSTANTIATION
00318 extern template class SpecialCoordinatesImage<float ,2>;
00319 extern template class SpecialCoordinatesImage<double ,2>;
00320 extern template class SpecialCoordinatesImage<unsigned char ,2>;
00321 extern template class SpecialCoordinatesImage<unsigned short,2>;
00322 extern template class SpecialCoordinatesImage<unsigned int ,2>;
00323 extern template class SpecialCoordinatesImage<signed char ,2>;
00324 extern template class SpecialCoordinatesImage<signed short ,2>;
00325 extern template class SpecialCoordinatesImage<signed int ,2>;
00326 extern template class SpecialCoordinatesImage<float ,3>;
00327 extern template class SpecialCoordinatesImage<double ,3>;
00328 extern template class SpecialCoordinatesImage<unsigned char ,3>;
00329 extern template class SpecialCoordinatesImage<unsigned short,3>;
00330 extern template class SpecialCoordinatesImage<unsigned int ,3>;
00331 extern template class SpecialCoordinatesImage<signed char ,3>;
00332 extern template class SpecialCoordinatesImage<signed short ,3>;
00333 extern template class SpecialCoordinatesImage<signed int ,3>;
00334 #endif
00335 }
00336 #ifndef ITK_MANUAL_INSTANTIATION
00337 #include "itkSpecialCoordinatesImage.txx"
00338 #endif
00339
00340 #endif
00341