ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkNumericTraitsPointPixel.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 itkNumericTraitsPointPixel_h
19 #define itkNumericTraitsPointPixel_h
20 
21 #include "itkNumericTraits.h"
22 #include "itkPoint.h"
23 
24 namespace itk
25 {
31 template< typename T, unsigned int D >
32 class NumericTraits< Point< T , D > >
33 {
34 private:
35 
41 
42 public:
43 
45  typedef T ValueType;
47 
50 
53 
57 
60 
63 
66 
69 
75  static const Self max(const Self &)
76  {
77  return Self( NumericTraits< T >::max() );
78  }
79 
80  static const Self min(const Self &)
81  {
82  return Self( NumericTraits< T >::min() );
83  }
84 
85  static const Self max()
86  {
87  return Self( NumericTraits< T >::max() );
88  }
89 
90  static const Self min()
91  {
92  return Self( NumericTraits< T >::min() );
93  }
94 
95  static const Self NonpositiveMin()
96  {
98  }
99 
100  static const Self ZeroValue()
101  {
103  }
104 
105  static const Self OneValue()
106  {
108  }
109 
110  static const Self NonpositiveMin(const Self &)
111  {
112  return NonpositiveMin();
113  }
114 
115  static const Self ZeroValue(const Self &)
116  {
117  return ZeroValue();
118  }
119 
120  static const Self OneValue(const Self &)
121  {
122  return OneValue();
123  }
124 
128 
132  static void SetLength(Point< T, D > & m, const unsigned int s)
133  {
134  if ( s != D )
135  {
136  itkGenericExceptionMacro(<< "Cannot set the size of a Point of length "
137  << D << " to " << s);
138  }
140  }
142 
144  static unsigned int GetLength(const Point< T, D > &)
145  {
146  return D;
147  }
148 
150  static unsigned int GetLength()
151  {
152  return D;
153  }
154 
155  static void AssignToArray( const Self & v, MeasurementVectorType & mv )
156  {
157  mv = v;
158  }
159 
160  template<typename TArray>
161  static void AssignToArray( const Self & v, TArray & mv )
162  {
163  for( unsigned int i=0; i<D; i++ )
164  {
165  mv[i] = v[i];
166  }
167  }
168 
172  static const Self ITKCommon_EXPORT Zero;
173  static const Self ITKCommon_EXPORT One;
174 };
175 } // end namespace itk
176 
177 #endif // itkNumericTraitsPointPixel_h
static void AssignToArray(const Self &v, TArray &mv)
static const Self ZeroValue(const Self &)
static unsigned int GetLength(const Point< T, D > &)
static const Self ITKCommon_EXPORT One
NumericTraits< T >::RealType ElementRealType
static const Self NonpositiveMin(const Self &)
static const bool IsSigned
static const Self OneValue(const Self &)
NumericTraits< T >::FloatType ElementFloatType
NumericTraits< T >::PrintType ElementPrintType
static void SetLength(Point< T, D > &m, const unsigned int s)
static void AssignToArray(const Self &v, MeasurementVectorType &mv)
static const bool IsInteger
static const bool IsComplex
Define additional traits for native types such as int or float.
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:52
NumericTraits< T >::AccumulateType ElementAccumulateType
static const Self ITKCommon_EXPORT Zero
Point< ElementAccumulateType, D > AccumulateType