ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkCastImageFilter.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 #ifndef itkCastImageFilter_h
19 #define itkCastImageFilter_h
20 
22 #include "itkProgressReporter.h"
23 
24 
25 namespace itk
26 {
27 namespace Functor
28 {
35 template< typename TInput, typename TOutput >
36 class ITK_TEMPLATE_EXPORT Cast
37 {
38 public:
39  Cast() = default;
40  virtual ~Cast() = default;
41  bool operator!=(const Cast &) const
42  {
43  return false;
44  }
45 
46  bool operator==(const Cast & other) const
47  {
48  return !( *this != other );
49  }
50 
51  inline TOutput operator()(const TInput & A) const
52  {
53  return static_cast< TOutput >( A );
54  }
55 };
56 }
57 
58 
96 template< typename TInputImage, typename TOutputImage >
97 class ITK_TEMPLATE_EXPORT CastImageFilter:
98  public InPlaceImageFilter< TInputImage, TOutputImage >
99 {
100 public:
101  ITK_DISALLOW_COPY_AND_ASSIGN(CastImageFilter);
102 
105 
107 
110 
111 
112  using OutputImageRegionType = typename Superclass::OutputImageRegionType;
113 
115  itkNewMacro(Self);
116 
118  itkTypeMacro(CastImageFilter, InPlaceImageFilter);
119 
120 #ifdef ITK_USE_CONCEPT_CHECKING
121  // Begin concept checking
122  itkConceptMacro( InputConvertibleToOutputCheck,
123  ( Concept::Convertible< typename TInputImage::PixelType,
124  typename TOutputImage::PixelType > ) );
125  // End concept checking
126 #endif
127 
128 protected:
129  CastImageFilter();
130  // virtual ~CastImageFilter() {} default OK
131 
132  void GenerateOutputInformation() override;
133 
134  void GenerateData() override;
135 
136  void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
137 
138 };
139 } // end namespace itk
140 
141 #endif
142 
143 
144 #ifndef ITK_MANUAL_INSTANTIATION
145 #include "itkCastImageFilter.hxx"
146 #endif
Light weight base class for most itk classes.
typename OutputImageType::RegionType OutputImageRegionType
bool operator==(const Cast &other) const
TOutput operator()(const TInput &A) const
Base class for filters that take an image as input and overwrite that image as the output...
bool operator!=(const Cast &) const
#define itkConceptMacro(name, concept)
Casts input pixels to output pixel type.