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
00076 itkStaticConstMacro(Dimension, unsigned int, NVectorDimension);
00077
00079 typedef Self CovariantVectorType;
00080
00082 typedef FixedArray<T, NVectorDimension> BaseArray;
00083
00085 static unsigned int GetCovariantVectorDimension()
00086 { return NVectorDimension; }
00087
00089 void Set_vnl_vector( const vnl_vector<T> & );
00090
00092 vnl_vector_ref<T> Get_vnl_vector( void );
00093
00095 vnl_vector<T> Get_vnl_vector( void ) const;
00096
00098 CovariantVector() {}
00099
00101 CovariantVector(const Self& r): BaseArray(r) {}
00102 CovariantVector(const ValueType r[Dimension]): BaseArray(r) {}
00103
00105 CovariantVector& operator= (const Self& r);
00106 CovariantVector& operator= (const ValueType r[Dimension]);
00107
00109 const Self& operator*=(const ValueType &value);
00110
00112 const Self& operator/=(const ValueType &value);
00113
00115 const Self& operator+=(const Self &vec);
00116
00118 const Self& operator-=(const Self &vec);
00119
00121 Self operator-() const;
00122
00124 Self operator+(const Self &vec) const;
00125
00127 Self operator-(const Self &vec) const;
00128
00131 Self operator*(const ValueType& val) const;
00132
00136 ValueType operator*(const Self &vec) const;
00137
00140 ValueType operator*(const Vector<T,NVectorDimension> &vec) const;
00141
00144 Self operator/(const ValueType& val) const;
00145
00147 ValueType GetNorm( void ) const;
00148
00150 ValueType GetSquaredNorm( void ) const;
00151
00153 void PrintSelf(std::ostream& os, Indent indent) const;
00154
00157 template < typename TCoordRepB >
00158 void CastFrom( const CovariantVector<TCoordRepB,NVectorDimension> & pa )
00159 {
00160 for(unsigned int i=0; i<NVectorDimension; i++ )
00161 {
00162 (*this)[i] = static_cast<T>( pa[i] );
00163 }
00164 }
00165
00166
00167 };
00168
00169
00170 }
00171
00172
00173 #ifndef ITK_MANUAL_INSTANTIATION
00174 #include "itkCovariantVector.txx"
00175 #endif
00176
00177
00178 #endif