ITK  5.4.0
Insight Toolkit
itkNumericTraitsCovariantVectorPixel.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#ifndef itkNumericTraitsCovariantVectorPixel_h
19#define itkNumericTraitsCovariantVectorPixel_h
20
21#include "itkNumericTraits.h"
22#include "itkCovariantVector.h"
23
24namespace itk
25{
43template <typename T, unsigned int D>
45{
46private:
52
53public:
55 using ValueType = T;
56
58
61
64
68
71
74
77
80
86 static const Self
87 max(const Self &)
88 {
89 return MakeFilled<Self>(NumericTraits<T>::max());
90 }
91
92 static const Self
93 min(const Self &)
94 {
95 return MakeFilled<Self>(NumericTraits<T>::min());
96 }
97
98 static const Self
100 {
101 return MakeFilled<Self>(NumericTraits<T>::max());
102 }
103
104 static const Self
106 {
107 return MakeFilled<Self>(NumericTraits<T>::min());
108 }
109
110 static const Self
112 {
113 return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
114 }
115
116 static const Self
118 {
119 return Self{};
120 }
121
122 static const Self
124 {
125 return MakeFilled<Self>(NumericTraits<T>::OneValue());
126 }
127
128 static const Self
130 {
131 return NonpositiveMin();
132 }
133
134 static const Self
136 {
137 return ZeroValue();
138 }
139
140 static const Self
141 OneValue(const Self &)
142 {
143 return OneValue();
144 }
145
146 static constexpr bool IsSigned = std::is_signed_v<ValueType>;
147 static constexpr bool IsInteger = std::is_integral_v<ValueType>;
149
153 static void
154 SetLength(CovariantVector<T, D> & m, const unsigned int s)
155 {
156 if (s != D)
157 {
158 itkGenericExceptionMacro("Cannot set the size of a CovariantVector of length " << D << " to " << s);
159 }
160 m.Fill(T{});
161 }
165 static unsigned int
167 {
168 return D;
169 }
170
172 static unsigned int
174 {
175 return D;
176 }
177
178 static void
180 {
181 mv = v;
182 }
183
184 template <typename TArray>
185 static void
186 AssignToArray(const Self & v, TArray & mv)
187 {
188 for (unsigned int i = 0; i < D; ++i)
189 {
190 mv[i] = v[i];
191 }
192 }
193
197 static const Self ITKCommon_EXPORT Zero;
198 static const Self ITKCommon_EXPORT One;
199};
200} // end namespace itk
201
202#endif // itkNumericTraitsCovariantVectorPixel_h
Pixel-wise addition of two images.
A templated class holding a n-Dimensional covariant vector.
void Fill(const ValueType &)
static unsigned int GetLength(const CovariantVector< T, D > &)
typename NumericTraits< T >::AccumulateType ElementAccumulateType
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
static void SetLength(CovariantVector< T, D > &m, const unsigned int s)
Define additional traits for native types such as int or float.
static constexpr bool IsInteger
static constexpr bool IsSigned
static constexpr T NonpositiveMin()
static constexpr bool IsComplex
AddImageFilter Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....