ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkNumericTraitsDiffusionTensor3DPixel.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 __itkNumericTraitsDiffusionTensor3DPixel_h
19 #define __itkNumericTraitsDiffusionTensor3DPixel_h
20 
21 #include "itkNumericTraits.h"
22 #include "itkDiffusionTensor3D.h"
23 
24 // This file is meant to define numeric traits for tensor pixels types in itk
25 
26 namespace itk
27 {
44 template< typename T >
46 {
47 private:
48 
54 public:
55 
57  typedef T ValueType;
58 
60 
63 
66 
70 
73 
76 
79 
82 
88  static const Self max(const Self &)
89  {
90  return Self( NumericTraits< T >::max() );
91  }
92 
93  static const Self min(const Self &)
94  {
95  return Self( NumericTraits< T >::min() );
96  }
97 
98  static const Self NonpositiveMin(const Self &)
99  {
101  }
102 
103  static const Self ZeroValue(const Self &)
104  {
106  }
107 
108  static const Self OneValue(const Self &)
109  {
111  }
112 
113  static const Self max()
114  {
115  return Self( NumericTraits< T >::max() );
116  }
117 
118  static const Self min()
119  {
120  return Self( NumericTraits< T >::min() );
121  }
122 
123  static const Self NonpositiveMin()
124  {
126  }
127 
128  static const Self ZeroValue()
129  {
131  }
132 
133  static const Self OneValue()
134  {
136  }
137 
142  static void SetLength(DiffusionTensor3D< T > & m, const unsigned int s)
143  {
144  if ( s != 6 )
145  {
146  itkGenericExceptionMacro(<< "Cannot set the size of a DiffusionTensor3D "
147  "to anything other than 6.");
148  }
150  }
152 
154  static unsigned int GetLength(const DiffusionTensor3D< T > &)
155  {
156  return 6;
157  }
158 
160  static unsigned int GetLength()
161  {
162  return 6;
163  }
164 
165  static void AssignToArray( const Self & v, MeasurementVectorType & mv )
166  {
167  mv = v;
168  }
169 
170  template<class TArray>
171  static void AssignToArray( const Self & v, TArray & mv )
172  {
173  for( unsigned int i=0; i<6; i++ )
174  {
175  mv[i] = v[i];
176  }
177  }
178 
182  static const Self ITKCommon_EXPORT Zero;
183  static const Self ITKCommon_EXPORT One;
184 };
185 } // end namespace itk
186 
187 #endif // __itkNumericTraitsTensorPixel_h
188