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

itkImageHelper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageHelper.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-18 17:18:08 $
00007   Version:   $Revision: 1.6 $
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 __itkImageHelper_h
00018 #define __itkImageHelper_h
00019 
00020 #include "itkConceptChecking.h"
00021 
00022 namespace itk
00023 {
00024 
00047 // Forward reference ImageBase
00048 template <
00049   unsigned int NImageDimension
00050   > class ImageBase;
00051 
00052 template <unsigned int NImageDimension, unsigned int NLoop>
00053 class ImageHelper
00054 {
00055 public:
00056   typedef ImageBase<NImageDimension>              ImageType;
00057   typedef typename ImageType::IndexType           IndexType;
00058   typedef typename ImageType::OffsetType          OffsetType;
00059   typedef typename ImageType::IndexValueType      IndexValueType;
00060   typedef typename ImageType::OffsetValueType     OffsetValueType;
00061   typedef Concept::Detail::UniqueType_bool<false> UniqueTypeBoolFalse;
00062   typedef Concept::Detail::UniqueType_bool<true>  UniqueTypeBoolTrue;
00063 
00065   inline static void ComputeIndex(const IndexType &bufferedRegionIndex,
00066                                   OffsetValueType offset,
00067                                   const OffsetValueType offsetTable[],
00068                                   IndexType &index)
00069     {
00070     ImageHelper<NImageDimension,NLoop-1>::
00071     ComputeIndexInner(bufferedRegionIndex,
00072                       offset,
00073                       offsetTable,
00074                       index,
00075                       Concept::Detail::UniqueType_bool<(NLoop==1)>());
00076     }
00077 
00078   inline static void ComputeIndexInner(const IndexType &bufferedRegionIndex,
00079                                        OffsetValueType &offset,
00080                                        const OffsetValueType offsetTable[],
00081                                        IndexType &index,
00082                                        const UniqueTypeBoolFalse& )
00083     {
00084     index[NLoop] = static_cast<IndexValueType>(offset / offsetTable[NLoop]);
00085     offset = offset - (index[NLoop] * offsetTable[NLoop]);
00086     index[NLoop] = index[NLoop] + bufferedRegionIndex[NLoop];
00087     ImageHelper<NImageDimension, NLoop-1>::
00088       ComputeIndexInner(bufferedRegionIndex,
00089                         offset,
00090                         offsetTable,
00091                         index,
00092                         Concept::Detail::UniqueType_bool<(NLoop==1)>());
00093 
00094     }
00095 
00096   inline static void ComputeIndexInner(const IndexType &bufferedRegionIndex,
00097                                        OffsetValueType &offset,
00098                                        const OffsetValueType [],
00099                                        IndexType &index,
00100                                        const UniqueTypeBoolTrue& )
00101     {
00102     // Do last
00103     index[0] = bufferedRegionIndex[0] + static_cast<IndexValueType>(offset);
00104     }
00105 
00106   // ComputeOffset
00107   //
00108   inline static void ComputeOffset(const IndexType &bufferedRegionIndex,
00109                                    const IndexType &index,
00110                                    const OffsetValueType offsetTable[],
00111                                    OffsetValueType &offset)
00112     {
00113     ImageHelper<NImageDimension,NLoop-1>::
00114       ComputeOffsetInner(bufferedRegionIndex,
00115                          index,
00116                          offsetTable,
00117                          offset,
00118                          Concept::Detail::UniqueType_bool<(NLoop==1)>());
00119     }
00120 
00121   inline static void ComputeOffsetInner(const IndexType &bufferedRegionIndex,
00122                                        const IndexType &index,
00123                                        const OffsetValueType offsetTable[],
00124                                        OffsetValueType &offset,
00125                                        const UniqueTypeBoolFalse& )
00126     {
00127     offset = offset + (index[NLoop] - bufferedRegionIndex[NLoop])*offsetTable[NLoop];
00128     ImageHelper<NImageDimension, NLoop-1>::
00129       ComputeOffsetInner(bufferedRegionIndex,
00130                         index,
00131                         offsetTable,
00132                         offset,
00133                         Concept::Detail::UniqueType_bool<(NLoop==1)>());
00134 
00135     }
00136 
00137   inline static void ComputeOffsetInner(const IndexType &bufferedRegionIndex,
00138                                         const IndexType &index,
00139                                         const OffsetValueType [],
00140                                         OffsetValueType &offset,
00141                                         const UniqueTypeBoolTrue& )
00142     {
00143     // Do last
00144     offset = offset + index[0] - bufferedRegionIndex[0];
00145     }
00146 
00147 };
00148 } // end namespace itk
00149 
00150 #endif
00151 

Generated at Mon Jul 12 2010 18:36:31 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000