Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkSpecialCoordinatesImage.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSpecialCoordinatesImage.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-19 12:33:32 $
00007   Version:   $Revision: 1.17 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
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   /* It is ILLEGAL in C++ to make a templated member function virtual! */
00288   /* Therefore, we must just let templates take care of everything.    */
00289   /*
00290   template<class TCoordRep>
00291   virtual bool TransformPhysicalPointToContinuousIndex(
00292               const Point<TCoordRep, VImageDimension>& point,
00293               ContinuousIndex<TCoordRep, VImageDimension>& index   ) const = 0;
00294   
00295   template<class TCoordRep>
00296   virtual bool TransformPhysicalPointToIndex(
00297             const Point<TCoordRep, VImageDimension>&,
00298             IndexType & index                                ) const = 0;
00299 
00300   template<class TCoordRep>
00301   virtual void TransformContinuousIndexToPhysicalPoint(
00302             const ContinuousIndex<TCoordRep, VImageDimension>& index,
00303             Point<TCoordRep, VImageDimension>& point        ) const = 0;
00304 
00305   template<class TCoordRep>
00306   virtual void TransformIndexToPhysicalPoint(
00307                       const IndexType & index,
00308                       Point<TCoordRep, VImageDimension>& point ) const = 0;
00309   */
00310 
00311 protected:
00312   SpecialCoordinatesImage();
00313   void PrintSelf(std::ostream& os, Indent indent) const;
00314   virtual ~SpecialCoordinatesImage() {};
00315 private:
00316   SpecialCoordinatesImage(const Self&); //purposely not implemented
00317   void operator=(const Self&); //purposely not implemented
00318 
00320   PixelContainerPointer m_Buffer;
00321 };
00322 } // end namespace itk
00323 
00324 
00325 // Define instantiation macro for this template.
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 

Generated at Sat Feb 28 13:36:45 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000