Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __itkNDImageBase_h
00016 #define __itkNDImageBase_h
00017
00018 #include "itkImage.h"
00019 #include "itkArray.h"
00020 #include <string>
00021 #include "itkImageFileWriter.h"
00022
00023
00024 namespace itk
00025 {
00026
00054 template < class TPixel >
00055 class NDImageBase : public Object
00056 {
00057 public:
00058
00060 typedef NDImageBase Self;
00061 typedef Object Superclass;
00062 typedef SmartPointer<Self> Pointer;
00063 typedef SmartPointer<const Self> ConstPointer;
00064
00066
00067
00068
00069
00071 itkTypeMacro( NDImageBase, Object );
00072
00073 typedef DataObject DataObjectType;
00074 typedef DataObjectType::Pointer DataObjectPointer;
00075
00077 typedef typename Image<TPixel,2>::PixelType PixelType;
00078 typedef typename Image<TPixel,2>::ValueType ValueType;
00079 typedef typename Image<TPixel,2>::InternalPixelType InternalPixelType;
00080 typedef typename Image<TPixel,2>::AccessorType AccessorType;
00081 typedef typename Image<TPixel,2>::PixelContainer PixelContainer;
00082 typedef typename Image<TPixel,2>::PixelContainerPointer PixelContainerPointer;
00083 typedef typename Image<TPixel,2>::PixelContainerConstPointer PixelContainerConstPointer;
00084
00085 typedef typename ImageBase<2>::SpacingType Spacing2DType;
00086 typedef typename ImageBase<2>::PointType Point2DType;
00087
00088 typedef typename Spacing2DType::ValueType SpacingValueType;
00089 typedef typename Point2DType::ValueType PointValueType;
00090 typedef typename ImageBase<2>::IndexValueType IndexValueType;
00091 typedef typename ImageBase<2>::SizeValueType SizeValueType;
00092 typedef typename ImageBase<2>::OffsetValueType OffsetValueType;
00093
00099 typedef Array<IndexValueType> IndexType;
00100 typedef Array<SizeValueType> SizeType;
00101 typedef Array<SpacingValueType> SpacingType;
00102 typedef Array<PointValueType> PointType;
00103 typedef Array<OffsetValueType> OffsetType;
00108
00109
00118
00119 virtual void SetRegions(SizeType size) = 0;
00120 virtual void SetRequestedRegion(DataObject *data) = 0;
00121
00122 virtual void Allocate(void) = 0;
00123 virtual void Initialize(void) = 0;
00124
00125 virtual void FillBuffer (const TPixel& value) = 0;
00126
00127 virtual void SetPixel(const IndexType &index, const TPixel& value) = 0;
00128 virtual const TPixel& GetPixel(const IndexType &index) const = 0;
00129 virtual TPixel& GetPixel(const IndexType &index) = 0;
00130
00131 TPixel & operator[](const IndexType &index)
00132 { return this->GetPixel(index); }
00133 const TPixel& operator[](const IndexType &index) const
00134 { return this->GetPixel(index); }
00135
00136 virtual TPixel *GetBufferPointer() = 0;
00137 virtual const TPixel *GetBufferPointer() const = 0;
00138 virtual PixelContainer* GetPixelContainer() = 0;
00139 virtual const PixelContainer* GetPixelContainer() const = 0;
00140 virtual void SetPixelContainer( PixelContainer *container ) = 0;
00141
00142 virtual AccessorType GetPixelAccessor( void ) = 0;
00143 virtual const AccessorType GetPixelAccessor( void ) const = 0;
00144
00145
00146 virtual void SetSpacing( const SpacingType & spacing ) = 0;
00147 virtual void SetOrigin( const PointType & origin ) = 0;
00148
00149
00150
00151 virtual SpacingType GetSpacing(void) = 0;
00152 virtual PointType GetOrigin(void) = 0;
00153
00156 virtual void CopyInformation(const DataObject *data) = 0;
00157 virtual const OffsetValueType *GetOffsetTable() const = 0;
00158 virtual OffsetValueType ComputeOffset(const IndexType &ind) const = 0;
00159 virtual IndexType ComputeIndex(OffsetValueType offset) const = 0;
00160
00164 virtual unsigned int ImageDimension(void) = 0;
00165 virtual unsigned int GetImageDimension(void) = 0;
00166
00168 virtual DataObject * GetImage(void) = 0;
00169 virtual ProcessObject * GetWriter(void) = 0;
00170 virtual ProcessObject * GetReader(void) = 0;
00171
00172 virtual void SetImageIOWriter (ImageIOBase *_arg) = 0;
00173 virtual ImageIOBase * GetImageIOWriter(void) = 0;
00174 virtual void SetImageIOReader (ImageIOBase *_arg) = 0;
00175 virtual ImageIOBase * GetImageIOReader(void) = 0;
00176
00178 virtual void Write(void) = 0;
00179
00181 virtual void Read(void) = 0;
00182
00184 virtual void CreateNewImage(void) = 0;
00185
00187 virtual void SetOutputFileName(const char *) = 0;
00188 virtual void SetInputFileName(const char *) = 0;
00189 virtual const char * GetOutputFileName(void) = 0;
00190 virtual const char * GetInputFileName(void) = 0;
00191
00192
00193 static Pointer NewNDImage(unsigned int dim);
00194
00195 protected:
00196
00197 NDImageBase(){};
00198 virtual ~NDImageBase(){};
00199
00200
00201
00202 private:
00203
00204 NDImageBase( const Self& );
00205 void operator=( const Self& );
00206
00207 };
00208
00209 }
00210
00211 #include "itkNDImageTemplate.h"
00212
00213
00214 namespace itk
00215 {
00216
00217 template < class TPixel>
00218 typename NDImageBase<TPixel>::Pointer
00219 NDImageBase<TPixel>::NewNDImage(unsigned int dim)
00220 {
00221 switch (dim)
00222 {
00223 case 1:
00224 return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 1>::New().GetPointer() );
00225 case 2:
00226 return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 2>::New().GetPointer() );
00227 case 3:
00228 return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 3>::New().GetPointer() );
00229 case 4:
00230 return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 4>::New().GetPointer() );
00231 case 5:
00232 return dynamic_cast< NDImageBase<TPixel> * >( NDImageTemplate<TPixel, 5>::New().GetPointer() );
00233
00234
00235
00236
00237 default:
00238 return 0;
00239 }
00240
00241 }
00242
00243 }
00244
00245
00246 #endif // end #ifndef __itkNDImageBase_h
00247