ITK  5.1.0
Insight Toolkit
itkInPlaceImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 /*=========================================================================
19  *
20  * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21  *
22  * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23  *
24  * For complete copyright, license and disclaimer of warranty information
25  * please refer to the NOTICE file at the top of the ITK source tree.
26  *
27  *=========================================================================*/
28 #ifndef itkInPlaceImageFilter_h
29 #define itkInPlaceImageFilter_h
30 
31 #include "itkImageToImageFilter.h"
32 #include "itkIsSame.h"
33 
34 namespace itk
35 {
76 template <typename TInputImage, typename TOutputImage = TInputImage>
77 class ITK_TEMPLATE_EXPORT InPlaceImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
78 {
79 public:
80  ITK_DISALLOW_COPY_AND_ASSIGN(InPlaceImageFilter);
81 
87 
90 
92  using OutputImageType = typename Superclass::OutputImageType;
93  using OutputImagePointer = typename Superclass::OutputImagePointer;
94  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
95  using OutputImagePixelType = typename Superclass::OutputImagePixelType;
96 
98  using InputImageType = TInputImage;
99  using InputImagePointer = typename InputImageType::Pointer;
100  using InputImageConstPointer = typename InputImageType::ConstPointer;
102  using InputImagePixelType = typename InputImageType::PixelType;
103 
105  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
106  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
107 
113  itkSetMacro(InPlace, bool);
114  itkGetConstMacro(InPlace, bool);
115  itkBooleanMacro(InPlace);
117 
126  virtual bool
127  CanRunInPlace() const;
128 
129 protected:
130  InPlaceImageFilter() = default;
131  ~InPlaceImageFilter() override = default;
132 
133  void
134  PrintSelf(std::ostream & os, Indent indent) const override;
135 
148  void
149  AllocateOutputs() override
150  {
151  this->InternalAllocateOutputs(IsSame<TInputImage, TOutputImage>());
152  }
153 
163  void
164  ReleaseInputs() override;
165 
170  itkGetConstMacro(RunningInPlace, bool);
171 
172 private:
173  // the type are different we can't run in place
174  void
175  InternalAllocateOutputs(const FalseType &)
176  {
177  this->m_RunningInPlace = false;
178  this->Superclass::AllocateOutputs();
179  }
180 
181  void
182  InternalAllocateOutputs(const TrueType &);
183 
184  bool m_InPlace{ true }; // enable the possibility of in-place
185  bool m_RunningInPlace{ false };
186 };
187 } // end namespace itk
188 
189 #ifndef ITK_MANUAL_INSTANTIATION
190 # include "itkInPlaceImageFilter.hxx"
191 #endif
192 
193 #endif
itk::InPlaceImageFilter::AllocateOutputs
void AllocateOutputs() override
Definition: itkInPlaceImageFilter.h:149
itk::ImageSource< TImage >::OutputImagePointer
typename OutputImageType::Pointer OutputImagePointer
Definition: itkImageSource.h:91
itk::InPlaceImageFilter::InternalAllocateOutputs
void InternalAllocateOutputs(const FalseType &)
Definition: itkInPlaceImageFilter.h:175
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itkIsSame.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImageToImageFilter< TImage, TImage >::InputImagePixelType
typename InputImageType::PixelType InputImagePixelType
Definition: itkImageToImageFilter.h:133
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::ImageToImageFilter< TImage, TImage >::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter< TImage, TImage >::InputImageType
TImage InputImageType
Definition: itkImageToImageFilter.h:129
itkImageToImageFilter.h
itk::ImageSource< TImage >::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::ImageSource< TImage >::OutputImagePixelType
typename OutputImageType::PixelType OutputImagePixelType
Definition: itkImageSource.h:93
itk::ImageToImageFilter< TImage, TImage >::InputImageRegionType
typename InputImageType::RegionType InputImageRegionType
Definition: itkImageToImageFilter.h:132
itk::ImageToImageFilter< TImage, TImage >::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkImageToImageFilter.h:131
itk::ImageSource< TImage >::OutputImageType
TImage OutputImageType
Definition: itkImageSource.h:90