00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#ifndef __itkImageBase_h
00021
#define __itkImageBase_h
00022
00023
#include "itkDataObject.h"
00024
#include "itkProcessObject.h"
00025
#include "itkIndex.h"
00026
#include "itkOffset.h"
00027
#include "itkSize.h"
00028
#include "itkImageRegion.h"
00029
00030
namespace itk
00031 {
00032
00039
template <
typename TImage>
00040 struct GetImageDimension
00041 {
00042
itkStaticConstMacro(ImageDimension,
unsigned int, TImage::ImageDimension);
00043 };
00044
00045
00073
template<
unsigned int VImageDimension=2>
00074 class ITK_EXPORT ImageBase :
public DataObject
00075 {
00076
public:
00078 typedef ImageBase
Self;
00079 typedef DataObject Superclass;
00080 typedef SmartPointer<Self> Pointer;
00081 typedef SmartPointer<const Self> ConstPointer;
00082
00084
itkNewMacro(
Self);
00085
00087
itkTypeMacro(ImageBase,
DataObject);
00088
00093
itkStaticConstMacro(ImageDimension,
unsigned int, VImageDimension );
00094
00096 typedef Index<VImageDimension> IndexType;
00097 typedef typename IndexType::IndexValueType
IndexValueType;
00098
00101 typedef Offset<VImageDimension> OffsetType;
00102 typedef typename OffsetType::OffsetValueType
OffsetValueType;
00103
00105 typedef Size<VImageDimension> SizeType;
00106 typedef typename SizeType::SizeValueType
SizeValueType;
00107
00109 typedef ImageRegion<VImageDimension> RegionType;
00110
00112
void Initialize();
00113
00115 static unsigned int GetImageDimension()
00116 {
return VImageDimension; }
00117
00122
virtual const double* GetSpacing() const;
00123
00128 virtual const
double * GetOrigin() const;
00129
00136 virtual
void SetLargestPossibleRegion(const RegionType ®ion);
00137
00144 virtual const
RegionType& GetLargestPossibleRegion()
const
00145
{
return m_LargestPossibleRegion;};
00146
00150
virtual void SetBufferedRegion(
const RegionType ®ion);
00151
00155 virtual const RegionType& GetBufferedRegion()
const
00156
{
return m_BufferedRegion;};
00157
00165
virtual void SetRequestedRegion(
const RegionType ®ion);
00166
00174
virtual void SetRequestedRegion(
DataObject *data);
00175
00180 virtual const RegionType& GetRequestedRegion()
const
00181
{
return m_RequestedRegion;};
00182
00192 const OffsetValueType *GetOffsetTable()
const {
return m_OffsetTable; };
00193
00196 OffsetValueType ComputeOffset(
const IndexType &ind)
const
00197 {
00198
00199
OffsetValueType offset=0;
00200
const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex();
00201
00202
00203
00204
for (
int i=VImageDimension-1; i > 0; i--)
00205 {
00206 offset += (ind[i] - bufferedRegionIndex[i])*m_OffsetTable[i];
00207 }
00208 offset += (ind[0] - bufferedRegionIndex[0]);
00209
00210
return offset;
00211 }
00212
00215 IndexType ComputeIndex(OffsetValueType offset)
const
00216
{
00217 IndexType index;
00218
const IndexType &bufferedRegionIndex = m_BufferedRegion.GetIndex();
00219
00220
for (
int i=VImageDimension-1; i > 0; i--)
00221 {
00222 index[i] = static_cast<IndexValueType>(offset / m_OffsetTable[i]);
00223 offset -= (index[i] * m_OffsetTable[i]);
00224 index[i] += bufferedRegionIndex[i];
00225 }
00226 index[0] = bufferedRegionIndex[0] + static_cast<IndexValueType>(offset);
00227
00228
return index;
00229 }
00230
00240
virtual void CopyInformation(
const DataObject *data);
00241
00249
virtual void UpdateOutputInformation();
00250
00254
virtual void SetRequestedRegionToLargestPossibleRegion();
00255
00265
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion();
00266
00275
virtual bool VerifyRequestedRegion();
00276
00277
protected:
00278 ImageBase();
00279 ~ImageBase();
00280
virtual void PrintSelf(std::ostream& os, Indent indent)
const;
00281
00286
void ComputeOffsetTable();
00287
00288
protected:
00290
double m_Spacing[VImageDimension];
00291
double m_Origin[VImageDimension];
00292
private:
00293 ImageBase(
const Self&);
00294 void operator=(
const Self&);
00295
00296
OffsetValueType m_OffsetTable[VImageDimension+1];
00297
00298
RegionType m_LargestPossibleRegion;
00299
RegionType m_RequestedRegion;
00300
RegionType m_BufferedRegion;
00301 };
00302
00303
00304 }
00305
00306
#ifndef ITK_MANUAL_INSTANTIATION
00307
#include "itkImageBase.txx"
00308
#endif
00309
00310
#endif
00311