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: 2003/02/26 23:20:31 $
00007   Version:   $Revision: 1.3 $
00008 
00009   Copyright (c) 2002 Insight 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   }
00112 
00113 
00114 
00132   template <unsigned int D1, unsigned int D2>
00133   class ITK_EXPORT ExtractImageFilterRegionCopier
00134     : public ImageRegionCopier<D1, D2>
00135   {
00136   public:
00137     virtual void operator()(ImageRegion<D1> &destRegion,
00138                             const ImageRegion<D2> &srcRegion,
00139                             const ImageRegion<D1> &totalInputExtractionRegion) const
00140     {
00141       ExtractImageFilterCopyRegion<D1, D2>(BinaryUnsignedIntDispatch<D1, D2>::ComparisonType(),
00142                                           destRegion, srcRegion, totalInputExtractionRegion);
00143     }
00144 
00146     virtual void operator() (ImageRegion<D1> &destRegion,
00147                             const ImageRegion<D2> &srcRegion) const
00148     {
00149       ImageRegionCopier<D1,D2>::operator()(destRegion, srcRegion);
00150     }
00151   };
00152 
00153 
00154 
00155 } //end namespace ImageToImageFilterDetail
00156 } //end namespace itk
00157 
00158 #endif

Generated at Fri May 21 01:14:41 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000