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
00125 typedef PixelType IOPixelType;
00126
00129 typedef DefaultPixelAccessor< PixelType > AccessorType;
00130
00134 typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
00135
00140 itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00141
00143 typedef ImportImageContainer<unsigned long, PixelType> PixelContainer;
00144
00146 typedef typename Superclass::IndexType IndexType;
00147
00149 typedef typename Superclass::OffsetType OffsetType;
00150
00152 typedef typename Superclass::SizeType SizeType;
00153
00155 typedef typename Superclass::RegionType RegionType;
00156
00161 typedef typename Superclass::SpacingType SpacingType;
00162
00165 typedef typename Superclass::PointType PointType;
00166
00168 typedef typename PixelContainer::Pointer PixelContainerPointer;
00169 typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00170
00173 void Allocate();
00174
00178 void SetRegions(RegionType region)
00179 {
00180 this->SetLargestPossibleRegion(region);
00181 this->SetBufferedRegion(region);
00182 this->SetRequestedRegion(region);
00183 };
00185
00186 void SetRegions(SizeType size)
00187 {
00188 RegionType region; region.SetSize(size);
00189 this->SetLargestPossibleRegion(region);
00190 this->SetBufferedRegion(region);
00191 this->SetRequestedRegion(region);
00192 };
00193
00196 virtual void Initialize();
00197
00200 void FillBuffer (const TPixel& value);
00201
00207 void SetPixel(const IndexType &index, const TPixel& value)
00208 {
00209 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00210 (*m_Buffer)[offset] = value;
00211 }
00212
00217 const TPixel& GetPixel(const IndexType &index) const
00218 {
00219 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00220 return ( (*m_Buffer)[offset] );
00221 }
00222
00227 TPixel& GetPixel(const IndexType &index)
00228 {
00229 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00230 return ( (*m_Buffer)[offset] );
00231 }
00232
00237 TPixel & operator[](const IndexType &index)
00238 { return this->GetPixel(index); }
00239
00244 const TPixel& operator[](const IndexType &index) const
00245 { return this->GetPixel(index); }
00246
00249 TPixel *GetBufferPointer()
00250 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00251 const TPixel *GetBufferPointer() const
00252 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00254
00256 PixelContainer* GetPixelContainer()
00257 { return m_Buffer.GetPointer(); }
00258
00259 const PixelContainer* GetPixelContainer() const
00260 { return m_Buffer.GetPointer(); }
00261
00264 void SetPixelContainer( PixelContainer *container );
00265
00267 AccessorType GetPixelAccessor( void )
00268 { return AccessorType(); }
00269
00271 const AccessorType GetPixelAccessor( void ) const
00272 { return AccessorType(); }
00273
00279 virtual void SetSpacing( const SpacingType ) {}
00280 virtual void SetSpacing( const double [VImageDimension] ) {}
00281 virtual void SetSpacing( const float [VImageDimension] ) {}
00282 virtual void SetOrigin( const PointType ) {}
00283 virtual void SetOrigin( const double [VImageDimension] ) {}
00284 virtual void SetOrigin( const float [VImageDimension] ) {}
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311 protected:
00312 SpecialCoordinatesImage();
00313 void PrintSelf(std::ostream& os, Indent indent) const;
00314 virtual ~SpecialCoordinatesImage() {};
00315 private:
00316 SpecialCoordinatesImage(const Self&);
00317 void operator=(const Self&);
00318
00320 PixelContainerPointer m_Buffer;
00321 };
00322 }
00323
00324
00325
00326 #define ITK_TEMPLATE_SpecialCoordinatesImage(_, EXPORT, x, y) namespace itk { \
00327 _(2(class EXPORT SpecialCoordinatesImage< ITK_TEMPLATE_2 x >)) \
00328 namespace Templates { typedef SpecialCoordinatesImage< ITK_TEMPLATE_2 x > \
00329 SpecialCoordinatesImage##y; } \
00330 }
00331
00332 #if ITK_TEMPLATE_EXPLICIT
00333 # include "Templates/itkSpecialCoordinatesImage+-.h"
00334 #endif
00335
00336 #if ITK_TEMPLATE_TXX
00337 # include "itkSpecialCoordinatesImage.txx"
00338 #endif
00339
00340 #endif
00341
00342