Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkCovariantVector.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkCovariantVector.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/01/14 16:31:36 $
00007   Version:   $Revision: 1.30 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
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 } // end namespace itk
00189   
00190 
00191 #ifndef ITK_MANUAL_INSTANTIATION
00192 #include "itkCovariantVector.txx"
00193 #endif
00194 
00195 
00196 #endif 

Generated at Tue Mar 29 23:49:25 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000