ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkNumericTraitsDiffusionTensor3DPixel.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkNumericTraitsDiffusionTensor3DPixel_h
00019 #define __itkNumericTraitsDiffusionTensor3DPixel_h
00020 
00021 #include "itkNumericTraits.h"
00022 #include "itkDiffusionTensor3D.h"
00023 
00024 // This file is meant to define numeric traits for tensor pixels types in itk
00025 
00026 namespace itk
00027 {
00044 template< typename T >
00045 class NumericTraits< DiffusionTensor3D< T > >
00046 {
00047 private:
00048 
00049   typedef typename NumericTraits< T >::AbsType        ElementAbsType;
00050   typedef typename NumericTraits< T >::AccumulateType ElementAccumulateType;
00051   typedef typename NumericTraits< T >::FloatType      ElementFloatType;
00052   typedef typename NumericTraits< T >::PrintType      ElementPrintType;
00053   typedef typename NumericTraits< T >::RealType       ElementRealType;
00054 public:
00055 
00057   typedef T ValueType;
00058 
00059   typedef DiffusionTensor3D< T > Self;
00060 
00062   typedef DiffusionTensor3D< ElementAbsType > AbsType;
00063 
00065   typedef DiffusionTensor3D< ElementAccumulateType > AccumulateType;
00066 
00069   typedef DiffusionTensor3D< ElementFloatType > FloatType;
00070 
00072   typedef DiffusionTensor3D< ElementPrintType > PrintType;
00073 
00075   typedef DiffusionTensor3D< ElementRealType > RealType;
00076 
00078   typedef ElementRealType ScalarRealType;
00079 
00081   typedef Self MeasurementVectorType;
00082 
00088   static const Self max(const Self &)
00089   {
00090     return Self( NumericTraits< T >::max() );
00091   }
00092 
00093   static const Self min(const Self &)
00094   {
00095     return Self( NumericTraits< T >::min() );
00096   }
00097 
00098   static const Self max()
00099   {
00100     return Self( NumericTraits< T >::max() );
00101   }
00102 
00103   static const Self min()
00104   {
00105     return Self( NumericTraits< T >::min() );
00106   }
00107 
00108   static const Self NonpositiveMin()
00109   {
00110     return Self( NumericTraits< T >::NonpositiveMin() );
00111   }
00112 
00113   static const Self ZeroValue()
00114   {
00115     return Self( NumericTraits< T >::ZeroValue() );
00116   }
00117 
00118   static const Self OneValue()
00119   {
00120     return Self( NumericTraits< T >::OneValue() );
00121   }
00122 
00127   static void SetLength(DiffusionTensor3D< T > & m, const unsigned int s)
00128   {
00129     if ( s != 6 )
00130       {
00131       itkGenericExceptionMacro(<< "Cannot set the size of a DiffusionTensor3D "
00132                                "to anything other than 6.");
00133       }
00134     m.Fill(NumericTraits< T >::Zero);
00135   }
00137 
00139   static unsigned int GetLength(const DiffusionTensor3D< T > &)
00140   {
00141     return 6;
00142   }
00143 
00145   static unsigned int GetLength()
00146   {
00147     return 6;
00148   }
00149 
00150   static void AssignToArray( const Self & v, MeasurementVectorType & mv )
00151   {
00152     mv = v;
00153   }
00154 
00155   template<class TArray>
00156   static void AssignToArray( const Self & v, TArray & mv )
00157   {
00158     for( unsigned int i=0; i<6; i++ )
00159       {
00160       mv[i] = v[i];
00161       }
00162   }
00163 
00167   static const Self ITKCommon_EXPORT Zero;
00168   static const Self ITKCommon_EXPORT One;
00169 };
00170 } // end namespace itk
00171 
00172 #endif // __itkNumericTraitsTensorPixel_h
00173