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() {}
00114
00116 CovariantVector(const Self& r): BaseArray(r) {}
00117 CovariantVector(const ValueType r[Dimension]): BaseArray(r) {}
00118
00120 CovariantVector& operator= (const Self& r);
00121 CovariantVector& operator= (const ValueType r[Dimension]);
00122
00124 const Self& operator*=(const ValueType &value);
00125
00127 const Self& operator/=(const ValueType &value);
00128
00130 const Self& operator+=(const Self &vec);
00131
00133 const Self& operator-=(const Self &vec);
00134
00136 Self operator-() const;
00137
00139 Self operator+(const Self &vec) const;
00140
00142 Self operator-(const Self &vec) const;
00143
00146 Self operator*(const ValueType& val) const;
00147
00151 ValueType operator*(const Self &vec) const;
00152
00155 ValueType operator*(const Vector<T,NVectorDimension> &vec) const;
00156
00159 Self operator/(const ValueType& val) const;
00160
00162 RealValueType GetNorm( void ) const;
00163
00165 void Normalize(void);
00166
00168 RealValueType GetSquaredNorm( void ) const;
00169
00171 void PrintSelf(std::ostream& os, Indent indent) const;
00172
00175 template < typename TCoordRepB >
00176 void CastFrom( const CovariantVector<TCoordRepB,NVectorDimension> & pa )
00177 {
00178 for(unsigned int i=0; i<NVectorDimension; i++ )
00179 {
00180 (*this)[i] = static_cast<T>( pa[i] );
00181 }
00182 }
00183
00184
00185 };
00186
00187
00188 }
00189
00190
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkCovariantVector.txx"
00193 #endif
00194
00195
00196 #endif