ITK  6.0.0
Insight Toolkit
itkInPlaceImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 <type_traits>
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_MOVE(InPlaceImageFilter);
81 
87 
89  itkOverrideGetNameOfClassMacro(InPlaceImageFilter);
90 
92  using typename Superclass::OutputImageType;
93  using typename Superclass::OutputImagePointer;
94  using typename Superclass::OutputImageRegionType;
95  using typename Superclass::OutputImagePixelType;
96 
98  using InputImageType = TInputImage;
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);
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  if (std::is_same_v<TInputImage, TOutputImage>)
152  {
153  this->InternalAllocateOutputs();
154  }
155  else // the type are different we can't run in place
156  {
157  this->m_RunningInPlace = false;
158  this->Superclass::AllocateOutputs();
159  }
160  }
172  void
173  ReleaseInputs() override;
174 
179  itkGetConstMacro(RunningInPlace, bool);
180 
181 private:
182  void
183  InternalAllocateOutputs();
184 
185  bool m_InPlace{ true }; // enable the possibility of in-place
186  bool m_RunningInPlace{ false };
187 };
188 } // end namespace itk
189 
190 #ifndef ITK_MANUAL_INSTANTIATION
191 # include "itkInPlaceImageFilter.hxx"
192 #endif
193 
194 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::InPlaceImageFilter::AllocateOutputs
void AllocateOutputs() override
Definition: itkInPlaceImageFilter.h:149
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
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:55
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
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
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