ITK  6.0.0
Insight Toolkit
itkNumericTraitsPointPixel.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 itkNumericTraitsPointPixel_h
19#define itkNumericTraitsPointPixel_h
20
21#include "itkNumericTraits.h"
22#include "itkPoint.h"
23
24namespace itk
25{
31template <typename T, unsigned int D>
32class NumericTraits<Point<T, D>>
33{
34private:
40
41public:
43 using ValueType = T;
45
48
51
55
58
61
64
67
73 static const Self
74 max(const Self &)
75 {
76 return MakeFilled<Self>(NumericTraits<T>::max());
77 }
78
79 static const Self
80 min(const Self &)
81 {
82 return MakeFilled<Self>(NumericTraits<T>::min());
83 }
84
85 static const Self
87 {
88 return MakeFilled<Self>(NumericTraits<T>::max());
89 }
90
91 static const Self
93 {
94 return MakeFilled<Self>(NumericTraits<T>::min());
95 }
96
97 static const Self
99 {
100 return MakeFilled<Self>(NumericTraits<T>::NonpositiveMin());
101 }
102
103 static const Self
105 {
106 return Self{};
107 }
108
109 static const Self
111 {
112 return MakeFilled<Self>(NumericTraits<T>::OneValue());
113 }
114
115 static const Self
117 {
118 return NonpositiveMin();
119 }
120
121 static const Self
123 {
124 return ZeroValue();
125 }
126
127 static const Self
128 OneValue(const Self &)
129 {
130 return OneValue();
131 }
132
133 static constexpr bool IsSigned = std::is_signed_v<ValueType>;
134 static constexpr bool IsInteger = std::is_integral_v<ValueType>;
136
140 static void
141 SetLength(Point<T, D> & m, const unsigned int s)
142 {
143 if (s != D)
144 {
145 itkGenericExceptionMacro("Cannot set the size of a Point of length " << D << " to " << s);
146 }
147 m.Fill(T{});
148 }
152 static unsigned int
154 {
155 return D;
156 }
157
159 static unsigned int
161 {
162 return D;
163 }
164
165 static void
167 {
168 mv = v;
169 }
170
171 template <typename TArray>
172 static void
173 AssignToArray(const Self & v, TArray & mv)
174 {
175 for (unsigned int i = 0; i < D; ++i)
176 {
177 mv[i] = v[i];
178 }
179 }
180
184 static const Self ITKCommon_EXPORT Zero;
185 static const Self ITKCommon_EXPORT One;
186};
187} // end namespace itk
188
189#endif // itkNumericTraitsPointPixel_h
Pixel-wise addition of two images.
void Fill(const ValueType &)
static unsigned int GetLength(const Point< T, D > &)
typename NumericTraits< T >::AccumulateType ElementAccumulateType
static const Self OneValue(const Self &)
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
static const Self NonpositiveMin(const Self &)
typename NumericTraits< T >::RealType ElementRealType
typename NumericTraits< T >::AbsType ElementAbsType
typename NumericTraits< T >::FloatType ElementFloatType
static const Self ITKCommon_EXPORT Zero
static const Self ITKCommon_EXPORT One
static void AssignToArray(const Self &v, TArray &mv)
static void SetLength(Point< T, D > &m, const unsigned int s)
typename NumericTraits< T >::PrintType ElementPrintType
static const Self ZeroValue(const Self &)
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
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:54
AddImageFilter Self
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....