ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkVectorCastImageFilter.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 __itkVectorCastImageFilter_h
19 #define __itkVectorCastImageFilter_h
20 
23 
24 namespace itk
25 {
42 namespace Functor
43 {
44 template< class TInput, class TOutput >
46 {
47 public:
50  bool operator!=(const VectorCast &) const
51  {
52  return false;
53  }
54 
55  bool operator==(const VectorCast & other) const
56  {
57  return !( *this != other );
58  }
59 
60  inline TOutput operator()(const TInput & A) const
61  {
62  typedef typename TOutput::ValueType OutputValueType;
63 
64  TOutput value;
65  for ( unsigned int k = 0; k < TOutput::Dimension; k++ )
66  {
67  value[k] = static_cast< OutputValueType >( A[k] );
68  }
69  return value;
70  }
71 };
72 }
73 
74 template< class TInputImage, class TOutputImage >
75 class ITK_EXPORT VectorCastImageFilter:
76  public
77  UnaryFunctorImageFilter< TInputImage, TOutputImage,
78  Functor::VectorCast< typename TInputImage::PixelType,
79  typename TOutputImage::PixelType > >
80 {
81 public:
85  TInputImage, TOutputImage,
86  Functor::VectorCast< typename TInputImage::PixelType,
87  typename TOutputImage::PixelType > > Superclass;
88 
91 
93  itkNewMacro(Self);
94 
96  itkTypeMacro(VectorCastImageFilter,
98 
99 #ifdef ITK_USE_CONCEPT_CHECKING
100 
101  itkConceptMacro( InputHasNumericTraitsCheck,
103  itkConceptMacro( OutputHasNumericTraitsCheck,
105  itkConceptMacro( InputConvertibleToOutputCheck,
106  ( Concept::Convertible< typename TInputImage::PixelType::ValueType,
107  typename TOutputImage::PixelType::ValueType > ) );
108 
110 #endif
111 
112 protected:
115 
116 private:
117  VectorCastImageFilter(const Self &); //purposely not implemented
118  void operator=(const Self &); //purposely not implemented
119 };
120 } // end namespace itk
121 
122 #endif
123