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: 2005/09/25 19:02:58 $
00007   Version:   $Revision: 1.12 $
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 
00127   typedef DefaultPixelAccessor< PixelType > AccessorType;
00128 
00132   typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
00133 
00138   itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00139 
00141   typedef ImportImageContainer<unsigned long, PixelType> PixelContainer;
00142 
00144   typedef typename Superclass::IndexType  IndexType;
00145 
00147   typedef typename Superclass::OffsetType OffsetType;
00148 
00150   typedef typename Superclass::SizeType  SizeType;
00151 
00153   typedef typename Superclass::RegionType  RegionType;
00154 
00159   typedef typename Superclass::SpacingType SpacingType;
00160 
00163   typedef typename Superclass::PointType PointType;
00164 
00166   typedef typename PixelContainer::Pointer PixelContainerPointer;
00167   typedef typename PixelContainer::ConstPointer PixelContainerConstPointer;
00168 
00171   void Allocate();
00172 
00176   void SetRegions(RegionType region)
00177     {
00178     this->SetLargestPossibleRegion(region);
00179     this->SetBufferedRegion(region);
00180     this->SetRequestedRegion(region);
00181     };
00182 
00183   void SetRegions(SizeType size)
00184     {
00185     RegionType region; region.SetSize(size);
00186     this->SetLargestPossibleRegion(region);
00187     this->SetBufferedRegion(region);
00188     this->SetRequestedRegion(region);
00189     };
00190 
00193   virtual void Initialize();
00194 
00197   void FillBuffer (const TPixel& value);
00198 
00204   void SetPixel(const IndexType &index, const TPixel& value)
00205     {
00206     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00207     (*m_Buffer)[offset] = value;
00208     }
00209 
00214   const TPixel& GetPixel(const IndexType &index) const
00215   {
00216     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00217     return ( (*m_Buffer)[offset] );
00218   }
00219 
00224   TPixel& GetPixel(const IndexType &index)
00225     {
00226     typename Superclass::OffsetValueType offset = this->ComputeOffset(index);
00227     return ( (*m_Buffer)[offset] );
00228     }
00229 
00234   TPixel & operator[](const IndexType &index)
00235      { return this->GetPixel(index); }
00236 
00241   const TPixel& operator[](const IndexType &index) const
00242      { return this->GetPixel(index); }
00243 
00246   TPixel *GetBufferPointer()
00247     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00248   const TPixel *GetBufferPointer() const
00249     { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00250 
00252   PixelContainer* GetPixelContainer()
00253     { return m_Buffer.GetPointer(); }
00254 
00255   const PixelContainer* GetPixelContainer() const
00256     { return m_Buffer.GetPointer(); }
00257 
00260   void SetPixelContainer( PixelContainer *container );
00261 
00263   AccessorType GetPixelAccessor( void )
00264     { return AccessorType(); }
00265 
00267   const AccessorType GetPixelAccessor( void ) const
00268     { return AccessorType(); }
00269   
00275   virtual void SetSpacing( const SpacingType ) {}
00276   virtual void SetSpacing( const double [VImageDimension] ) {}
00277   virtual void SetSpacing( const float [VImageDimension] ) {}
00278   virtual void SetOrigin( const PointType ) {}
00279   virtual void SetOrigin( const double [VImageDimension] ) {}
00280   virtual void SetOrigin( const float [VImageDimension] ) {}
00281   
00282   /* It is ILLEGAL in C++ to make a templated member function virtual! */
00283   /* Therefore, we must just let templates take care of everything.    */
00284   /*
00285   template<class TCoordRep>
00286   virtual bool TransformPhysicalPointToContinuousIndex(
00287               const Point<TCoordRep, VImageDimension>& point,
00288               ContinuousIndex<TCoordRep, VImageDimension>& index   ) const = 0;
00289   
00290   template<class TCoordRep>
00291   virtual bool TransformPhysicalPointToIndex(
00292             const Point<TCoordRep, VImageDimension>&,
00293             IndexType & index                                ) const = 0;
00294 
00295   template<class TCoordRep>
00296   virtual void TransformContinuousIndexToPhysicalPoint(
00297             const ContinuousIndex<TCoordRep, VImageDimension>& index,
00298             Point<TCoordRep, VImageDimension>& point        ) const = 0;
00299 
00300   template<class TCoordRep>
00301   virtual void TransformIndexToPhysicalPoint(
00302                       const IndexType & index,
00303                       Point<TCoordRep, VImageDimension>& point ) const = 0;
00304   */
00305 
00306 protected:
00307   SpecialCoordinatesImage();
00308   void PrintSelf(std::ostream& os, Indent indent) const;
00309   virtual ~SpecialCoordinatesImage() {};
00310 private:
00311   SpecialCoordinatesImage(const Self&); //purposely not implemented
00312   void operator=(const Self&); //purposely not implemented
00313 
00315   PixelContainerPointer m_Buffer;
00316 };
00317 #ifdef ITK_EXPLICIT_INSTANTIATION
00318    extern template class SpecialCoordinatesImage<float         ,2>;
00319    extern template class SpecialCoordinatesImage<double        ,2>;
00320    extern template class SpecialCoordinatesImage<unsigned char ,2>;
00321    extern template class SpecialCoordinatesImage<unsigned short,2>;
00322    extern template class SpecialCoordinatesImage<unsigned int  ,2>;
00323    extern template class SpecialCoordinatesImage<signed char   ,2>;
00324    extern template class SpecialCoordinatesImage<signed short  ,2>;
00325    extern template class SpecialCoordinatesImage<signed int    ,2>;
00326    extern template class SpecialCoordinatesImage<float         ,3>;
00327    extern template class SpecialCoordinatesImage<double        ,3>;
00328    extern template class SpecialCoordinatesImage<unsigned char ,3>;
00329    extern template class SpecialCoordinatesImage<unsigned short,3>;
00330    extern template class SpecialCoordinatesImage<unsigned int  ,3>;
00331    extern template class SpecialCoordinatesImage<signed char   ,3>;
00332    extern template class SpecialCoordinatesImage<signed short  ,3>;
00333    extern template class SpecialCoordinatesImage<signed int    ,3>;
00334 #endif
00335 } // end namespace itk
00336 #ifndef ITK_MANUAL_INSTANTIATION
00337 #include "itkSpecialCoordinatesImage.txx"
00338 #endif
00339 
00340 #endif
00341 

Generated at Thu May 25 00:06:39 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000