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: 2004/12/21 22:47:30 $
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   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 D1, unsigned int D2>
00035 void ExtractImageFilterCopyRegion(const typename
00036                                   BinaryUnsignedIntDispatch<D1, D2>::FirstEqualsSecondType &firstEqualsSecond,
00037                                   ImageRegion<D1> &destRegion,
00038                                   const ImageRegion<D2> &srcRegion,
00039                                   const ImageRegion<D1> &)
00040 {
00041   ImageToImageFilterDefaultCopyRegion<D1, D2>(firstEqualsSecond, destRegion, srcRegion);
00042 }
00043 
00044   
00045 
00049 template <unsigned int D1, unsigned int D2>
00050 void ExtractImageFilterCopyRegion(const typename
00051                                   BinaryUnsignedIntDispatch<D1, D2>::FirstLessThanSecondType &firstLessThanSecond,
00052                                   ImageRegion<D1> &destRegion,
00053                                   const ImageRegion<D2> &srcRegion,
00054                                   const ImageRegion<D1> &totalInputExtractionRegion)
00055 {
00056   ImageToImageFilterDefaultCopyRegion<D1, D2>(firstLessThanSecond, destRegion, srcRegion);
00057 
00058 }
00059 
00060 
00077 template <unsigned int D1, unsigned int D2>
00078 void ExtractImageFilterCopyRegion(const typename
00079                                   BinaryUnsignedIntDispatch<D1, D2>::FirstGreaterThanSecondType &,
00080                                   ImageRegion<D1> &destRegion,
00081                                   const ImageRegion<D2> &srcRegion,
00082                                   const ImageRegion<D1> &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<D1> destIndex;
00089   Size<D1>  destSize;
00090   const Index<D2> &srcIndex = srcRegion.GetIndex();
00091   const Size<D2> &srcSize = srcRegion.GetSize();
00092   int count = 0;
00093   for (dim=0; dim < D1; ++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 
00114 
00115 
00133 template <unsigned int D1, unsigned int D2>
00134 class ITK_EXPORT ExtractImageFilterRegionCopier
00135   : public ImageRegionCopier<D1, D2>
00136 {
00137 public:
00138   virtual void operator()(ImageRegion<D1> &destRegion,
00139                           const ImageRegion<D2> &srcRegion,
00140                           const ImageRegion<D1> &totalInputExtractionRegion) const
00141   {
00142     typedef typename BinaryUnsignedIntDispatch<D1, D2>::ComparisonType ComparisonType;
00143     ExtractImageFilterCopyRegion<D1, D2>(ComparisonType(),
00144                                          destRegion, srcRegion, totalInputExtractionRegion);
00145   }
00147 
00149   virtual void operator() (ImageRegion<D1> &destRegion,
00150                            const ImageRegion<D2> &srcRegion) const
00151   {
00152     ImageRegionCopier<D1,D2>::operator()(destRegion, srcRegion);
00153   }
00154 };
00156 
00157 
00158 
00159 } //end namespace ImageToImageFilterDetail
00160 } //end namespace itk
00161 
00162 #endif
00163 

Generated at Tue Jul 29 19:54:24 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000