00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html 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 00018 00019 #include "mitkImageToImageFilter.h" 00020 00021 mitk::ImageToImageFilter::ImageToImageFilter() 00022 { 00023 // Modify superclass default values, can be overridden by subclasses 00024 this->SetNumberOfRequiredInputs(1); 00025 } 00026 00027 mitk::ImageToImageFilter::~ImageToImageFilter() 00028 { 00029 } 00030 00034 void mitk::ImageToImageFilter::SetInput(const mitk::ImageToImageFilter::InputImageType *input) 00035 { 00036 // Process object is not const-correct so the const_cast is required here 00037 this->ProcessObject::SetNthInput(0, 00038 const_cast< mitk::ImageToImageFilter::InputImageType * >( input ) ); 00039 } 00040 00041 00045 void mitk::ImageToImageFilter::SetInput( unsigned int index, const mitk::ImageToImageFilter::InputImageType * image ) 00046 { 00047 if( index+1 > this->GetNumberOfInputs() ) 00048 { 00049 this->SetNumberOfRequiredInputs( index + 1 ); 00050 } 00051 // Process object is not const-correct so the const_cast is required here 00052 this->ProcessObject::SetNthInput(index, 00053 const_cast< mitk::ImageToImageFilter::InputImageType *>( image ) ); 00054 } 00055 00056 00057 00061 const mitk::ImageToImageFilter::InputImageType *mitk::ImageToImageFilter::GetInput(void) 00062 { 00063 if (this->GetNumberOfInputs() < 1) 00064 { 00065 return 0; 00066 } 00067 00068 return static_cast<const mitk::ImageToImageFilter::InputImageType * > 00069 (this->ProcessObject::GetInput(0) ); 00070 } 00071 00075 const mitk::ImageToImageFilter::InputImageType *mitk::ImageToImageFilter::GetInput(unsigned int idx) 00076 { 00077 return static_cast< const mitk::ImageToImageFilter::InputImageType * > 00078 (this->ProcessObject::GetInput(idx)); 00079 } 00080 00081 00082 00083 //----------------------------------------------------------------------- 00084 // 00085 void mitk::ImageToImageFilter::GenerateInputRequestedRegion() 00086 { 00087 Superclass::GenerateInputRequestedRegion(); 00088 00089 for (unsigned int idx = 0; idx < this->GetNumberOfInputs(); ++idx) 00090 { 00091 if (this->GetInput(idx)) 00092 { 00093 mitk::ImageToImageFilter::InputImagePointer input = 00094 const_cast< mitk::ImageToImageFilter::InputImageType * > ( this->GetInput(idx) ); 00095 00096 // Use the function object RegionCopier to copy the output region 00097 // to the input. The default region copier has default implementations 00098 // to handle the cases where the input and output are the same 00099 // dimension, the input a higher dimension than the output, and the 00100 // input a lower dimension than the output. 00101 InputImageRegionType inputRegion; 00102 // this->CallCopyRegion(inputRegion, this->GetOutput()->GetRequestedRegion()); @FIXME ?? 00103 // input->SetRequestedRegion( inputRegion ); @FIXME ?? 00104 input->SetRequestedRegion( this->GetOutput() ); // ersatz. @FIXME ?? 00105 } 00106 } 00107 } 00108 00109 void mitk::ImageToImageFilter::PrintSelf(std::ostream& os, itk::Indent indent) const 00110 { 00111 Superclass::PrintSelf(os, indent); 00112 }