00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkSymmetricSecondRankTensor_h
00018 #define __itkSymmetricSecondRankTensor_h
00019
00020
00021 #ifdef SymmetricSecondRankTensor
00022 #undef SymmetricSecondRankTensor
00023 #endif
00024
00025 #include <itkIndent.h>
00026 #include <itkFixedArray.h>
00027 #include <itkMatrix.h>
00028 #include "itkSymmetricEigenAnalysis.h"
00029
00030 namespace itk
00031 {
00032
00073 template < typename TComponent, unsigned int NDimension=3 >
00074 class SymmetricSecondRankTensor: public
00075 FixedArray<TComponent,NDimension*(NDimension+1)/2>
00076 {
00077 public:
00079 typedef SymmetricSecondRankTensor Self;
00080 typedef FixedArray<TComponent,NDimension*(NDimension+1)/2> Superclass;
00081
00083 itkStaticConstMacro(Dimension, unsigned int, NDimension);
00084 itkStaticConstMacro(InternalDimension, unsigned int, NDimension*(NDimension+1)/2);
00086
00088 typedef FixedArray<TComponent,
00089 itkGetStaticConstMacro(InternalDimension)> BaseArray;
00090
00092 typedef FixedArray<TComponent, NDimension> EigenValuesArrayType;
00093
00095 typedef Matrix<TComponent, NDimension, NDimension> MatrixType;
00096 typedef Matrix<TComponent, NDimension, NDimension> EigenVectorsMatrixType;
00097
00099 typedef TComponent ComponentType;
00100 typedef typename Superclass::ValueType ValueType;
00101 typedef typename NumericTraits<ValueType>::RealType AccumulateValueType;
00102 typedef typename NumericTraits<ValueType>::RealType RealValueType;
00103
00104 typedef SymmetricEigenAnalysis< MatrixType,
00105 EigenValuesArrayType, EigenVectorsMatrixType > SymmetricEigenAnalysisType;
00106
00108 SymmetricSecondRankTensor() {this->Fill(0);}
00109
00110 SymmetricSecondRankTensor (const ComponentType& r) { this->Fill(r); }
00111
00112 typedef ComponentType ComponentArrayType[ itkGetStaticConstMacro(InternalDimension) ];
00113
00115 SymmetricSecondRankTensor(const Self& r): BaseArray(r) {}
00116 SymmetricSecondRankTensor(const ComponentArrayType r): BaseArray(r) {}
00118
00120 Self& operator= (const Self& r);
00121 Self& operator= (const ComponentType& r);
00122 Self& operator= (const ComponentArrayType r);
00124
00126 Self operator+(const Self &vec) const;
00127 Self operator-(const Self &vec) const;
00128 const Self & operator+=(const Self &vec);
00129 const Self & operator-=(const Self &vec);
00131
00133 Self operator*(const RealValueType & scalar ) const;
00134 Self operator/(const RealValueType & scalar ) const;
00135 const Self & operator*=(const RealValueType & scalar );
00136 const Self & operator/=(const RealValueType & scalar );
00138
00140 static unsigned int GetNumberOfComponents()
00141 {
00142 return itkGetStaticConstMacro(InternalDimension);
00143 }
00144
00146 ComponentType GetNthComponent(int c) const
00147 { return this->operator[](c); }
00148
00150 void SetNthComponent(int c, const ComponentType& v)
00151 { this->operator[](c) = v; }
00152
00154 ValueType & operator()( unsigned int row, unsigned int col );
00155 const ValueType & operator()( unsigned int row, unsigned int col ) const;
00157
00160 void SetIdentity();
00161
00163 AccumulateValueType GetTrace() const;
00164
00166 void ComputeEigenValues( EigenValuesArrayType & eigenValues ) const;
00167
00170 void ComputeEigenAnalysis( EigenValuesArrayType & eigenValues,
00171 EigenVectorsMatrixType & eigenVectors ) const;
00172
00173 private:
00174
00175
00176 };
00177
00180 typedef std::ostream OutputStreamType;
00181 typedef std::istream InputStreamType;
00182
00183 template< typename TComponent, unsigned int NDimension >
00184 ITK_EXPORT OutputStreamType& operator<<(OutputStreamType& os,
00185 const SymmetricSecondRankTensor<TComponent,NDimension> & c);
00186 template< typename TComponent, unsigned int NDimension >
00187 ITK_EXPORT InputStreamType& operator>>(InputStreamType& is,
00188 SymmetricSecondRankTensor<TComponent,NDimension> & c);
00189
00190 template <typename TValueType, unsigned int VLength>
00191 inline SymmetricSecondRankTensor< TValueType, VLength> operator*
00192 (double d, const SymmetricSecondRankTensor< TValueType, VLength > & f)
00193 {
00194 return f * d;
00195 }
00196
00197
00198
00199 }
00200
00201 #include "itkNumericTraitsTensorPixel.h"
00202
00203
00204
00205 #define ITK_TEMPLATE_SymmetricSecondRankTensor(_, EXPORT, x, y) namespace itk { \
00206 _(2(class EXPORT SymmetricSecondRankTensor< ITK_TEMPLATE_2 x >)) \
00207 namespace Templates { typedef SymmetricSecondRankTensor< ITK_TEMPLATE_2 x > \
00208 SymmetricSecondRankTensor##y; } \
00209 }
00210
00211 #if ITK_TEMPLATE_EXPLICIT
00212 # include "Templates/itkSymmetricSecondRankTensor+-.h"
00213 #endif
00214
00215 #if ITK_TEMPLATE_TXX
00216 # include "itkSymmetricSecondRankTensor.txx"
00217 #endif
00218
00219
00220 #endif
00221