ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
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 /*========================================================================= 00019 * 00020 * Portions of this file are subject to the VTK Toolkit Version 3 copyright. 00021 * 00022 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00023 * 00024 * For complete copyright, license and disclaimer of warranty information 00025 * please refer to the NOTICE file at the top of the ITK source tree. 00026 * 00027 *=========================================================================*/ 00028 #ifndef __itkInPlaceImageFilter_h 00029 #define __itkInPlaceImageFilter_h 00030 00031 #include "itkImageToImageFilter.h" 00032 #include "itkIsSame.h" 00033 00034 namespace itk 00035 { 00071 template< class TInputImage, class TOutputImage = TInputImage > 00072 class ITK_EXPORT InPlaceImageFilter:public ImageToImageFilter< TInputImage, TOutputImage > 00073 { 00074 public: 00076 typedef InPlaceImageFilter Self; 00077 typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass; 00078 typedef SmartPointer< Self > Pointer; 00079 typedef SmartPointer< const Self > ConstPointer; 00080 00082 itkTypeMacro(InPlaceImageFilter, ImageToImageFilter); 00083 00085 typedef typename Superclass::OutputImageType OutputImageType; 00086 typedef typename Superclass::OutputImagePointer OutputImagePointer; 00087 typedef typename Superclass::OutputImageRegionType OutputImageRegionType; 00088 typedef typename Superclass::OutputImagePixelType OutputImagePixelType; 00089 00091 typedef TInputImage InputImageType; 00092 typedef typename InputImageType::Pointer InputImagePointer; 00093 typedef typename InputImageType::ConstPointer InputImageConstPointer; 00094 typedef typename InputImageType::RegionType InputImageRegionType; 00095 typedef typename InputImageType::PixelType InputImagePixelType; 00096 00098 itkStaticConstMacro(InputImageDimension, unsigned int, 00099 TInputImage::ImageDimension); 00100 itkStaticConstMacro(OutputImageDimension, unsigned int, 00101 TOutputImage::ImageDimension); 00103 00109 itkSetMacro(InPlace, bool); 00110 itkGetConstMacro(InPlace, bool); 00111 itkBooleanMacro(InPlace); 00113 00122 virtual bool CanRunInPlace() const; 00123 00124 protected: 00125 InPlaceImageFilter(); 00126 ~InPlaceImageFilter(); 00127 00128 virtual void PrintSelf(std::ostream & os, Indent indent) const; 00129 00142 virtual void AllocateOutputs() 00143 { 00144 this->InternalAllocateOutputs(IsSame<TInputImage, TOutputImage>()); 00145 } 00146 00156 virtual void ReleaseInputs(); 00157 00162 itkGetConstMacro(RunningInPlace,bool); 00163 00164 private: 00165 InPlaceImageFilter(const Self &); //purposely not implemented 00166 void operator=(const Self &); //purposely not implemented 00167 00168 // the type are different we can't run in place 00169 void InternalAllocateOutputs( const FalseType& ) 00170 { 00171 this->m_RunningInPlace = false; 00172 this->Superclass::AllocateOutputs(); 00173 } 00174 00175 void InternalAllocateOutputs( const TrueType& ); 00176 00177 bool m_InPlace; // enable the possibility of in-place 00178 bool m_RunningInPlace; 00179 00180 }; 00181 } // end namespace itk 00182 00183 // Define instantiation macro for this template. 00184 #define ITK_TEMPLATE_InPlaceImageFilter(_, EXPORT, TypeX, TypeY) \ 00185 namespace itk \ 00186 { \ 00187 _( 2 ( class EXPORT InPlaceImageFilter< ITK_TEMPLATE_2 TypeX > ) ) \ 00188 namespace Templates \ 00189 { \ 00190 typedef InPlaceImageFilter< ITK_TEMPLATE_2 TypeX > InPlaceImageFilter##TypeY; \ 00191 } \ 00192 } 00193 00194 #if ITK_TEMPLATE_EXPLICIT 00195 #include "Templates/itkInPlaceImageFilter+-.h" 00196 #endif 00197 00198 #if ITK_TEMPLATE_TXX 00199 #include "itkInPlaceImageFilter.hxx" 00200 #endif 00201 00202 #endif 00203