ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkSpecialCoordinatesImage.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkSpecialCoordinatesImage_h
00019 #define __itkSpecialCoordinatesImage_h
00020 
00021 #include "itkImageBase.h"
00022 #include "itkImportImageContainer.h"
00023 #include "itkDefaultPixelAccessor.h"
00024 #include "itkDefaultPixelAccessorFunctor.h"
00025 #include "itkContinuousIndex.h"
00026 
00027 namespace itk
00028 {
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 
00124   typedef PixelType IOPixelType;
00125 
00128   typedef DefaultPixelAccessor< PixelType > AccessorType;
00129 
00133   typedef DefaultPixelAccessorFunctor< Self > AccessorFunctorType;
00134 
00139   itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
00140 
00142   typedef typename Superclass::IndexType IndexType;
00143 
00145   typedef typename Superclass::OffsetType OffsetType;
00146 
00148   typedef typename Superclass::SizeType      SizeType;
00149 
00151   typedef ImportImageContainer< SizeValueType, PixelType > PixelContainer;
00152 
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 
00177   virtual void Initialize();
00178 
00181   void FillBuffer(const TPixel & value);
00182 
00188   void SetPixel(const IndexType & index, const TPixel & value)
00189   {
00190     OffsetValueType offset = this->ComputeOffset(index);
00191     ( *m_Buffer )[offset] = value;
00192   }
00193 
00198   const TPixel & GetPixel(const IndexType & index) const
00199   {
00200     OffsetValueType offset = this->ComputeOffset(index);
00201     return ( ( *m_Buffer )[offset] );
00202   }
00203 
00208   TPixel & GetPixel(const IndexType & index)
00209   {
00210     OffsetValueType offset = this->ComputeOffset(index);
00211     return ( ( *m_Buffer )[offset] );
00212   }
00213 
00218   TPixel & operator[](const IndexType & index) { return this->GetPixel(index); }
00219 
00224   const TPixel & operator[](const IndexType & index) const { return this->GetPixel(index); }
00225 
00228   TPixel * GetBufferPointer() { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00229   const TPixel * GetBufferPointer() const { return m_Buffer ? m_Buffer->GetBufferPointer() : 0; }
00231 
00233   PixelContainer * GetPixelContainer() { return m_Buffer.GetPointer(); }
00234 
00235   const PixelContainer * GetPixelContainer() const { return m_Buffer.GetPointer(); }
00236 
00239   void SetPixelContainer(PixelContainer *container);
00240 
00242   AccessorType GetPixelAccessor(void) { return AccessorType(); }
00243 
00245   const AccessorType GetPixelAccessor(void) const { return AccessorType(); }
00246 
00252   virtual void SetSpacing(const SpacingType &) {}
00253   virtual void SetSpacing(const double[VImageDimension]) {}
00254   virtual void SetSpacing(const float[VImageDimension]) {}
00255   virtual void SetOrigin(const PointType) {}
00256   virtual void SetOrigin(const double[VImageDimension]) {}
00257   virtual void SetOrigin(const float[VImageDimension]) {}
00259 
00260   /* It is ILLEGAL in C++ to make a templated member function virtual! */
00261   /* Therefore, we must just let templates take care of everything.    */
00262   /*
00263   template<class TCoordRep>
00264   virtual bool TransformPhysicalPointToContinuousIndex(
00265               const Point<TCoordRep, VImageDimension>& point,
00266               ContinuousIndex<TCoordRep, VImageDimension>& index   ) const = 0;
00267 
00268   template<class TCoordRep>
00269   virtual bool TransformPhysicalPointToIndex(
00270             const Point<TCoordRep, VImageDimension>&,
00271             IndexType & index                                ) const = 0;
00272 
00273   template<class TCoordRep>
00274   virtual void TransformContinuousIndexToPhysicalPoint(
00275             const ContinuousIndex<TCoordRep, VImageDimension>& index,
00276             Point<TCoordRep, VImageDimension>& point        ) const = 0;
00277 
00278   template<class TCoordRep>
00279   virtual void TransformIndexToPhysicalPoint(
00280                       const IndexType & index,
00281                       Point<TCoordRep, VImageDimension>& point ) const = 0;
00282   */
00283 protected:
00284   SpecialCoordinatesImage();
00285   void PrintSelf(std::ostream & os, Indent indent) const;
00286 
00287   virtual ~SpecialCoordinatesImage() {}
00288 private:
00289   SpecialCoordinatesImage(const Self &); //purposely not implemented
00290   void operator=(const Self &);          //purposely not implemented
00291 
00293   PixelContainerPointer m_Buffer;
00294 };
00295 } // end namespace itk
00296 
00297 // Define instantiation macro for this template.
00298 #define ITK_TEMPLATE_SpecialCoordinatesImage(_, EXPORT, TypeX, TypeY)     \
00299   namespace itk                                                           \
00300   {                                                                       \
00301   _( 2 ( class EXPORT SpecialCoordinatesImage< ITK_TEMPLATE_2 TypeX > ) ) \
00302   namespace Templates                                                     \
00303   {                                                                       \
00304   typedef SpecialCoordinatesImage< ITK_TEMPLATE_2 TypeX >                 \
00305   SpecialCoordinatesImage##TypeY;                                       \
00306   }                                                                       \
00307   }
00308 
00309 #if ITK_TEMPLATE_EXPLICIT
00310 #include "Templates/itkSpecialCoordinatesImage+-.h"
00311 #endif
00312 
00313 #if ITK_TEMPLATE_TXX
00314 #include "itkSpecialCoordinatesImage.hxx"
00315 #endif
00316 
00317 #endif
00318