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 "itkPoint.h"
00025 #include "itkContinuousIndex.h"
00026 #include "itkFixedArray.h"
00027
00028 namespace itk
00029 {
00030
00094 template <class TPixel, unsigned int VImageDimension=2>
00095 class ITK_EXPORT SpecialCoordinatesImage : public ImageBase<VImageDimension>
00096 {
00097 public:
00099 typedef SpecialCoordinatesImage Self;
00100 typedef ImageBase<VImageDimension> Superclass;
00101 typedef SmartPointer<Self> Pointer;
00102 typedef SmartPointer<const Self> ConstPointer;
00103 typedef WeakPointer<const Self> ConstWeakPointer;
00104
00106 itkNewMacro(Self);
00107
00109 itkTypeMacro(SpecialCoordinatesImage, ImageBase);
00110
00113 typedef TPixel PixelType;
00114
00116 typedef TPixel ValueType ;
00117
00122 typedef TPixel InternalPixelType;
00123
00126 typedef DefaultPixelAccessor< PixelType > AccessorType;
00127
00132 itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00133
00135 typedef ImportImageContainer<unsigned long, PixelType> PixelContainer;
00136
00138 typedef typename Superclass::IndexType IndexType;
00139
00141 typedef typename Superclass::OffsetType OffsetType;
00142
00144 typedef typename Superclass::SizeType SizeType;
00145
00147 typedef typename Superclass::RegionType RegionType;
00148
00153 typedef typename Superclass::SpacingType SpacingType;
00154
00157 typedef typename Superclass::PointType PointType;
00158
00160 typedef typename PixelContainer::Pointer PixelContainerPointer;
00161 typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00162
00165 void Allocate();
00166
00170 void SetRegions(RegionType region)
00171 {
00172 this->SetLargestPossibleRegion(region);
00173 this->SetBufferedRegion(region);
00174 this->SetRequestedRegion(region);
00175 };
00176
00177 void SetRegions(SizeType size)
00178 {
00179 RegionType region; region.SetSize(size);
00180 this->SetLargestPossibleRegion(region);
00181 this->SetBufferedRegion(region);
00182 this->SetRequestedRegion(region);
00183 };
00184
00187 virtual void Initialize();
00188
00191 void FillBuffer (const TPixel& value);
00192
00198 void SetPixel(const IndexType &index, const TPixel& value)
00199 {
00200 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00201 (*m_Buffer)[offset] = value;
00202 }
00203
00208 const TPixel& GetPixel(const IndexType &index) const
00209 {
00210 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00211 return ( (*m_Buffer)[offset] );
00212 }
00213
00218 TPixel& GetPixel(const IndexType &index)
00219 {
00220 typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00221 return ( (*m_Buffer)[offset] );
00222 }
00223
00228 TPixel & operator[](const IndexType &index)
00229 { return this->GetPixel(index); }
00230
00235 const TPixel& operator[](const IndexType &index) const
00236 { return this->GetPixel(index); }
00237
00240 TPixel *GetBufferPointer()
00241 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00242 const TPixel *GetBufferPointer() const
00243 { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00244
00246 PixelContainer* GetPixelContainer()
00247 { return m_Buffer.GetPointer(); }
00248
00249 const PixelContainer* GetPixelContainer() const
00250 { return m_Buffer.GetPointer(); }
00251
00254 void SetPixelContainer( PixelContainer *container );
00255
00257 AccessorType GetPixelAccessor( void )
00258 { return AccessorType(); }
00259
00261 const AccessorType GetPixelAccessor( void ) const
00262 { return AccessorType(); }
00263
00269 virtual void SetSpacing( const SpacingType ) {}
00270 virtual void SetSpacing( const double [VImageDimension] ) {}
00271 virtual void SetSpacing( const float [VImageDimension] ) {}
00272 virtual void SetOrigin( const PointType ) {}
00273 virtual void SetOrigin( const double [VImageDimension] ) {}
00274 virtual void SetOrigin( const float [VImageDimension] ) {}
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300 protected:
00301 SpecialCoordinatesImage();
00302 void PrintSelf(std::ostream& os, Indent indent) const;
00303 virtual ~SpecialCoordinatesImage() {};
00304 private:
00305 SpecialCoordinatesImage(const Self&);
00306 void operator=(const Self&);
00307
00309 PixelContainerPointer m_Buffer;
00310 };
00311 #ifdef ITK_EXPLICIT_INSTANTIATION
00312 extern template class SpecialCoordinatesImage<float ,2>;
00313 extern template class SpecialCoordinatesImage<double ,2>;
00314 extern template class SpecialCoordinatesImage<unsigned char ,2>;
00315 extern template class SpecialCoordinatesImage<unsigned short,2>;
00316 extern template class SpecialCoordinatesImage<unsigned int ,2>;
00317 extern template class SpecialCoordinatesImage<signed char ,2>;
00318 extern template class SpecialCoordinatesImage<signed short ,2>;
00319 extern template class SpecialCoordinatesImage<signed int ,2>;
00320 extern template class SpecialCoordinatesImage<float ,3>;
00321 extern template class SpecialCoordinatesImage<double ,3>;
00322 extern template class SpecialCoordinatesImage<unsigned char ,3>;
00323 extern template class SpecialCoordinatesImage<unsigned short,3>;
00324 extern template class SpecialCoordinatesImage<unsigned int ,3>;
00325 extern template class SpecialCoordinatesImage<signed char ,3>;
00326 extern template class SpecialCoordinatesImage<signed short ,3>;
00327 extern template class SpecialCoordinatesImage<signed int ,3>;
00328 #endif
00329 }
00330 #ifndef ITK_MANUAL_INSTANTIATION
00331 #include "itkSpecialCoordinatesImage.txx"
00332 #endif
00333
00334 #endif
00335