00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkCovariantVector_h
00018 #define __itkCovariantVector_h
00019
00020
00021 #include "itkFixedArray.h"
00022 #include "vnl/vnl_vector_ref.h"
00023 #include "itkIndent.h"
00024 #include "itkVector.h"
00025
00026
00027 namespace itk
00028 {
00029
00063 template<class T, unsigned int NVectorDimension=3>
00064 class ITK_EXPORT CovariantVector : public FixedArray<T,NVectorDimension>
00065 {
00066 public:
00068 typedef CovariantVector Self;
00069 typedef FixedArray<T,NVectorDimension> Superclass;
00070
00073 typedef T ValueType;
00074 typedef typename NumericTraits< ValueType >::RealType RealValueType;
00075
00077 itkStaticConstMacro(Dimension, unsigned int, NVectorDimension);
00078
00080 typedef Self CovariantVectorType;
00081
00083 typedef FixedArray<T, NVectorDimension> BaseArray;
00084
00086 static unsigned int GetCovariantVectorDimension()
00087 { return NVectorDimension; }
00088
00090 void SetVnlVector( const vnl_vector<T> & );
00091
00093 vnl_vector_ref<T> GetVnlVector( void );
00094
00096 vnl_vector<T> GetVnlVector( void ) const;
00097
00098
00101 void Set_vnl_vector( const vnl_vector<T> & );
00102
00105 vnl_vector_ref<T> Get_vnl_vector( void );
00106
00109 vnl_vector<T> Get_vnl_vector( void ) const;
00110
00111
00113 CovariantVector(): BaseArray() {}
00114 CovariantVector(const ValueType& r);
00115
00117 CovariantVector(const Self& r): BaseArray(r) {}
00118 CovariantVector(const ValueType r[Dimension]): BaseArray(r) {}
00119
00121 CovariantVector& operator= (const Self& r);
00122 CovariantVector& operator= (const ValueType r[NVectorDimension]);
00123
00125 const Self& operator*=(const ValueType &value);
00126
00128 const Self& operator/=(const ValueType &value);
00129
00131 const Self& operator+=(const Self &vec);
00132
00134 const Self& operator-=(const Self &vec);
00135
00137 Self operator-() const;
00138
00140 Self operator+(const Self &vec) const;
00141
00143 Self operator-(const Self &vec) const;
00144
00147 Self operator*(const ValueType& val) const;
00148
00152 ValueType operator*(const Self &vec) const;
00153
00156 ValueType operator*(const Vector<T,NVectorDimension> &vec) const;
00157
00160 Self operator/(const ValueType& val) const;
00161
00163 RealValueType GetNorm( void ) const;
00164
00166 static unsigned int GetNumberOfComponents() { return NVectorDimension; }
00167
00169 void Normalize(void);
00170
00172 RealValueType GetSquaredNorm( void ) const;
00173
00176 template < typename TCoordRepB >
00177 void CastFrom( const CovariantVector<TCoordRepB,NVectorDimension> & pa )
00178 {
00179 for(unsigned int i=0; i<NVectorDimension; i++ )
00180 {
00181 (*this)[i] = static_cast<T>( pa[i] );
00182 }
00183 }
00184
00185
00186 };
00187
00188
00189 }
00190
00191
00192 #ifndef ITK_MANUAL_INSTANTIATION
00193 #include "itkCovariantVector.txx"
00194 #endif
00195
00196
00197 #endif