ITK  4.13.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() {}
40  virtual ~Cast() {}
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:
103 
105 
108 
109 
110  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
111 
113  itkNewMacro(Self);
114 
116  itkTypeMacro(CastImageFilter, InPlaceImageFilter);
117 
118 #ifdef ITK_USE_CONCEPT_CHECKING
119  // Begin concept checking
120  itkConceptMacro( InputConvertibleToOutputCheck,
121  ( Concept::Convertible< typename TInputImage::PixelType,
122  typename TOutputImage::PixelType > ) );
123  // End concept checking
124 #endif
125 
126 protected:
127  CastImageFilter();
128  // virtual ~CastImageFilter() {} default OK
129 
130  void GenerateOutputInformation() ITK_OVERRIDE;
131 
132  void GenerateData() ITK_OVERRIDE;
133 
134  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) ITK_OVERRIDE;
135 
136 private:
137  ITK_DISALLOW_COPY_AND_ASSIGN(CastImageFilter);
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.
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
bool operator==(const Cast &other) const
Superclass::OutputImageRegionType OutputImageRegionType
InPlaceImageFilter< TInputImage, TOutputImage > Superclass
OutputImageType::RegionType OutputImageRegionType
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.