ITK  4.6.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  static void SetLength(Point< T, D > & m, const unsigned int s)
129  {
130  if ( s != D )
131  {
132  itkGenericExceptionMacro(<< "Cannot set the size of a Point of length "
133  << D << " to " << s);
134  }
136  }
138 
140  static unsigned int GetLength(const Point< T, D > &)
141  {
142  return D;
143  }
144 
146  static unsigned int GetLength()
147  {
148  return D;
149  }
150 
151  static void AssignToArray( const Self & v, MeasurementVectorType & mv )
152  {
153  mv = v;
154  }
155 
156  template<typename TArray>
157  static void AssignToArray( const Self & v, TArray & mv )
158  {
159  for( unsigned int i=0; i<D; i++ )
160  {
161  mv[i] = v[i];
162  }
163  }
164 
168  static const Self ITKCommon_EXPORT Zero;
169  static const Self ITKCommon_EXPORT One;
170 };
171 } // end namespace itk
172 
173 #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 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)
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:51
NumericTraits< T >::AccumulateType ElementAccumulateType
static const Self ITKCommon_EXPORT Zero
Point< ElementAccumulateType, D > AccumulateType