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: 2004/12/29 15:12:03 $
00007   Version:   $Revision: 1.7 $
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 "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   /* It is ILLEGAL in C++ to make a templated member function virtual! */
00277   /* Therefore, we must just let templates take care of everything.    */
00278   /*
00279   template<class TCoordRep>
00280   virtual bool TransformPhysicalPointToContinuousIndex(
00281               const Point<TCoordRep, VImageDimension>& point,
00282               ContinuousIndex<TCoordRep, VImageDimension>& index   ) const = 0;
00283   
00284   template<class TCoordRep>
00285   virtual bool TransformPhysicalPointToIndex(
00286             const Point<TCoordRep, VImageDimension>&,
00287             IndexType & index                                ) const = 0;
00288 
00289   template<class TCoordRep>
00290   virtual void TransformContinuousIndexToPhysicalPoint(
00291             const ContinuousIndex<TCoordRep, VImageDimension>& index,
00292             Point<TCoordRep, VImageDimension>& point        ) const = 0;
00293 
00294   template<class TCoordRep>
00295   virtual void TransformIndexToPhysicalPoint(
00296                       const IndexType & index,
00297                       Point<TCoordRep, VImageDimension>& point ) const = 0;
00298   */
00299 
00300 protected:
00301   SpecialCoordinatesImage();
00302   void PrintSelf(std::ostream& os, Indent indent) const;
00303   virtual ~SpecialCoordinatesImage() {};
00304 private:
00305   SpecialCoordinatesImage(const Self&); //purposely not implemented
00306   void operator=(const Self&); //purposely not implemented
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 } // end namespace itk
00330 #ifndef ITK_MANUAL_INSTANTIATION
00331 #include "itkSpecialCoordinatesImage.txx"
00332 #endif
00333 
00334 #endif
00335 

Generated at Wed Mar 30 00:12:06 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000