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

itkExtractImageFilterRegionCopier.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkExtractImageFilterRegionCopier.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-15 12:45:53 $
00007   Version:   $Revision: 1.8 $
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   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
00018 
00019 =========================================================================*/
00020 #ifndef __itkExtractImageFilterRegionCopier_h
00021 #define __itkExtractImageFilterRegionCopier_h
00022 
00023 #include "itkImageToImageFilterDetail.h"
00024 
00025 namespace itk
00026 {
00027 
00028 namespace ImageToImageFilterDetail
00029 {
00030  
00034 template <unsigned int T1, unsigned int T2>
00035 void ExtractImageFilterCopyRegion(const typename
00036                                   BinaryUnsignedIntDispatch<T1, T2>::FirstEqualsSecondType &firstEqualsSecond,
00037                                   ImageRegion<T1> &destRegion,
00038                                   const ImageRegion<T2> &srcRegion,
00039                                   const ImageRegion<T1> &)
00040 {
00041   ImageToImageFilterDefaultCopyRegion<T1, T2>(firstEqualsSecond, destRegion, srcRegion);
00042 }
00043 
00044   
00045 
00049 template <unsigned int T1, unsigned int T2>
00050 void ExtractImageFilterCopyRegion(const typename
00051                                   BinaryUnsignedIntDispatch<T1, T2>::FirstLessThanSecondType &firstLessThanSecond,
00052                                   ImageRegion<T1> &destRegion,
00053                                   const ImageRegion<T2> &srcRegion,
00054                                   const ImageRegion<T1> &totalInputExtractionRegion)
00055 {
00056   ImageToImageFilterDefaultCopyRegion<T1, T2>(firstLessThanSecond, destRegion, srcRegion);
00057 
00058 }
00059 
00060 
00077 template <unsigned int T1, unsigned int T2>
00078 void ExtractImageFilterCopyRegion(const typename
00079                                   BinaryUnsignedIntDispatch<T1, T2>::FirstGreaterThanSecondType &,
00080                                   ImageRegion<T1> &destRegion,
00081                                   const ImageRegion<T2> &srcRegion,
00082                                   const ImageRegion<T1> &totalInputExtractionRegion)
00083 {
00084   // Source dimension is less than the destination dimension, so look
00085   // at the m_TotalExtractionRegion and see what values in size are 0.
00086   // With these values, lock the destRegion.Index to the corresponding index
00087   unsigned int dim;
00088   Index<T1> destIndex;
00089   Size<T1>  destSize;
00090   const Index<T2> &srcIndex = srcRegion.GetIndex();
00091   const Size<T2> &srcSize = srcRegion.GetSize();
00092   int count = 0;
00093   for (dim=0; dim < T1; ++dim)
00094     {
00095     //for dimensions to be removed
00096     if (!totalInputExtractionRegion.GetSize()[dim])
00097       {
00098       destIndex[dim] = totalInputExtractionRegion.GetIndex()[dim];
00099       destSize[dim] = 1;
00100       }
00101     //for all other dimension
00102     else
00103       {
00104       destIndex[dim] = srcIndex[count];
00105       destSize[dim] = srcSize[count];
00106       count++;
00107       }
00108     }
00109   destRegion.SetIndex(destIndex);
00110   destRegion.SetSize(destSize);
00111 }
00113 
00131 template <unsigned int T1, unsigned int T2>
00132 class ITK_EXPORT ExtractImageFilterRegionCopier
00133   : public ImageRegionCopier<T1, T2>
00134 {
00135 public:
00136   virtual void operator()(ImageRegion<T1> &destRegion,
00137                           const ImageRegion<T2> &srcRegion,
00138                           const ImageRegion<T1> &totalInputExtractionRegion) const
00139   {
00140     typedef typename BinaryUnsignedIntDispatch<T1, T2>::ComparisonType ComparisonType;
00141     ExtractImageFilterCopyRegion<T1, T2>(ComparisonType(),
00142                                          destRegion, srcRegion, totalInputExtractionRegion);
00143   }
00144 
00146   virtual void operator() (ImageRegion<T1> &destRegion,
00147                            const ImageRegion<T2> &srcRegion) const
00148     {
00149     ImageRegionCopier<T1,T2>::operator()(destRegion, srcRegion);
00150     }
00151 };
00153 
00154 } //end namespace ImageToImageFilterDetail
00155 } //end namespace itk
00156 
00157 #endif
00158 

Generated at Wed Nov 5 21:17:29 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000