ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkTestingExtractSliceImageFilter.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 __itkTestingExtractSliceImageFilter_h
00019 #define __itkTestingExtractSliceImageFilter_h
00020 
00021 #include "itkSmartPointer.h"
00022 #include "itkExtractImageFilterRegionCopier.h"
00023 
00024 namespace itk
00025 {
00026 namespace Testing
00027 {
00081 template< class TInputImage, class TOutputImage >
00082 class ITK_EXPORT ExtractSliceImageFilter:
00083   public ImageSource< TOutputImage >
00084 {
00085 public:
00087   typedef ExtractSliceImageFilter         Self;
00088   typedef ImageSource< TOutputImage >     Superclass;
00089   typedef SmartPointer< Self >            Pointer;
00090   typedef SmartPointer< const Self >      ConstPointer;
00091 
00093   itkNewMacro(Self);
00094 
00096   itkTypeMacro(ExtractSliceImageFilter, ImageSource);
00097 
00099   typedef TInputImage  InputImageType;
00100   typedef TOutputImage OutputImageType;
00101 
00103   typedef typename TOutputImage::RegionType OutputImageRegionType;
00104   typedef typename TInputImage::RegionType  InputImageRegionType;
00105 
00107   typedef typename TOutputImage::PixelType OutputImagePixelType;
00108   typedef typename TInputImage::PixelType  InputImagePixelType;
00109 
00111   typedef typename TOutputImage::IndexType OutputImageIndexType;
00112   typedef typename TInputImage::IndexType  InputImageIndexType;
00113   typedef typename TOutputImage::SizeType  OutputImageSizeType;
00114   typedef typename TInputImage::SizeType   InputImageSizeType;
00115 
00116   typedef enum DirectionCollaspeStrategyEnum {
00117     DIRECTIONCOLLAPSETOUNKOWN=0,
00118     DIRECTIONCOLLAPSETOIDENTITY=1,
00119     DIRECTIONCOLLAPSETOSUBMATRIX=2,
00120     DIRECTIONCOLLAPSETOGUESS=3
00121   } DIRECTIONCOLLAPSESTRATEGY;
00122 
00123 
00148   void SetDirectionCollapseToStrategy(const DIRECTIONCOLLAPSESTRATEGY choosenStrategy)
00149     {
00150     switch(choosenStrategy)
00151       {
00152     case DIRECTIONCOLLAPSETOGUESS:
00153     case DIRECTIONCOLLAPSETOIDENTITY:
00154     case DIRECTIONCOLLAPSETOSUBMATRIX:
00155       break;
00156     case DIRECTIONCOLLAPSETOUNKOWN:
00157     default:
00158       itkExceptionMacro( << "Invalid Strategy Choosen for itk::ExtractSliceImageFilter" );
00159       }
00161 
00162     this->m_DirectionCollaspeStrategy=choosenStrategy;
00163     this->Modified();
00164     }
00165 
00174   DIRECTIONCOLLAPSESTRATEGY GetDirectionCollapseToStrategy() const
00175     {
00176     return this->m_DirectionCollaspeStrategy;
00177     }
00178 
00180   void SetDirectionCollapseToGuess()
00181     {
00182     this->SetDirectionCollapseToStrategy(DIRECTIONCOLLAPSETOGUESS);
00183     }
00184 
00186   void SetDirectionCollapseToIdentity()
00187     {
00188     this->SetDirectionCollapseToStrategy(DIRECTIONCOLLAPSETOIDENTITY);
00189     }
00190 
00192   void SetDirectionCollapseToSubmatrix()
00193     {
00194     this->SetDirectionCollapseToStrategy(DIRECTIONCOLLAPSETOSUBMATRIX);
00195     }
00196 
00197 
00199   itkStaticConstMacro(InputImageDimension, unsigned int,
00200                       TInputImage::ImageDimension);
00201   itkStaticConstMacro(OutputImageDimension, unsigned int,
00202                       TOutputImage::ImageDimension);
00204 
00205   typedef ImageToImageFilterDetail::ExtractImageFilterRegionCopier<
00206     itkGetStaticConstMacro(InputImageDimension),
00207     itkGetStaticConstMacro(OutputImageDimension) > ExtractSliceImageFilterRegionCopierType;
00208 
00214   void SetExtractionRegion(InputImageRegionType extractRegion);
00215   itkGetConstMacro(ExtractionRegion, InputImageRegionType);
00217 
00219   using Superclass::SetInput;
00220   virtual void SetInput(const TInputImage *image);
00221   const TInputImage * GetInput(void) const;
00223 
00224 #ifdef ITK_USE_CONCEPT_CHECKING
00225 
00226   itkConceptMacro( InputCovertibleToOutputCheck,
00227                    ( Concept::Convertible< InputImagePixelType, OutputImagePixelType > ) );
00228 
00230 #endif
00231 protected:
00232   ExtractSliceImageFilter();
00233   ~ExtractSliceImageFilter() {}
00234   void PrintSelf(std::ostream & os, Indent indent) const;
00236 
00245   virtual void GenerateOutputInformation();
00246 
00256   virtual void CallCopyOutputRegionToInputRegion(InputImageRegionType & destRegion,
00257                                                  const OutputImageRegionType & srcRegion);
00258 
00267   void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread,
00268                             ThreadIdType threadId);
00269 
00270   InputImageRegionType m_ExtractionRegion;
00271 
00272   OutputImageRegionType m_OutputImageRegion;
00273 private:
00274   ExtractSliceImageFilter(const Self &); //purposely not implemented
00275   void operator=(const Self &);     //purposely not implemented
00276 
00277   DIRECTIONCOLLAPSESTRATEGY m_DirectionCollaspeStrategy;
00278 };
00279 } // end namespace Testing
00280 } // end namespace itk
00281 
00282 #ifndef ITK_MANUAL_INSTANTIATION
00283 #include "itkTestingExtractSliceImageFilter.hxx"
00284 #endif
00285 
00286 #endif
00287