ITK  4.4.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< class TInput, class TOutput >
36 class 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< class TInputImage, class TOutputImage >
97 class ITK_EXPORT CastImageFilter:
98  public UnaryFunctorImageFilter< TInputImage, TOutputImage,
99  Functor::Cast<
100  typename TInputImage::PixelType,
101  typename TOutputImage::PixelType > >
102 {
103 public:
106  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
108  typename TInputImage::PixelType,
109  typename TOutputImage::PixelType >
111 
114 
115 
116  typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
117 
119  itkNewMacro(Self);
120 
123 
124 #ifdef ITK_USE_CONCEPT_CHECKING
125 
126  itkConceptMacro( InputConvertibleToOutputCheck,
127  ( Concept::Convertible< typename TInputImage::PixelType,
128  typename TOutputImage::PixelType > ) );
129 
131 #endif
132 
133 protected:
134  CastImageFilter();
135  // virtual ~CastImageFilter() {} default OK
136 
137  void GenerateData();
138 
139  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId);
140 
141 private:
142  CastImageFilter(const Self &); //purposely not implemented
143  void operator=(const Self &); //purposely not implemented
144 };
145 } // end namespace itk
146 
147 #endif
148 
149 
150 #ifndef ITK_MANUAL_INSTANTIATION
151 #include "itkCastImageFilter.hxx"
152 #endif
153