ITK  4.2.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 public:
42 
44  typedef T ValueType;
46 
49 
52 
56 
59 
62 
65 
68 
74  static const Self max(const Self &)
75  {
76  return Self( NumericTraits< T >::max() );
77  }
78 
79  static const Self min(const Self &)
80  {
81  return Self( NumericTraits< T >::min() );
82  }
83 
84  static const Self max()
85  {
86  return Self( NumericTraits< T >::max() );
87  }
88 
89  static const Self min()
90  {
91  return Self( NumericTraits< T >::min() );
92  }
93 
94  static const Self NonpositiveMin()
95  {
97  }
98 
99  static const Self ZeroValue()
100  {
102  }
103 
104  static const Self OneValue()
105  {
107  }
108 
109  static const Self NonpositiveMin(const Self &)
110  {
111  return NonpositiveMin();
112  }
113 
114  static const Self ZeroValue(const Self &)
115  {
116  return ZeroValue();
117  }
118 
119  static const Self OneValue(const Self &)
120  {
121  return OneValue();
122  }
123 
127  static void SetLength(Point< T, D > & m, const unsigned int s)
128  {
129  if ( s != D )
130  {
131  itkGenericExceptionMacro(<< "Cannot set the size of a Point of length "
132  << D << " to " << s);
133  }
135  }
137 
139  static unsigned int GetLength(const Point< T, D > &)
140  {
141  return D;
142  }
143 
145  static unsigned int GetLength()
146  {
147  return D;
148  }
149 
150  static void AssignToArray( const Self & v, MeasurementVectorType & mv )
151  {
152  mv = v;
153  }
154 
155  template<class TArray>
156  static void AssignToArray( const Self & v, TArray & mv )
157  {
158  for( unsigned int i=0; i<D; i++ )
159  {
160  mv[i] = v[i];
161  }
162  }
163 
167  static const Self ITKCommon_EXPORT Zero;
168  static const Self ITKCommon_EXPORT One;
169 };
170 } // end namespace itk
171 
172 #endif // __itkNumericTraitsPointPixel_h
173