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

itkVector.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVector.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/11/13 03:51:29 $
00007   Version:   $Revision: 1.55 $
00008 
00009   Copyright (c) 2002 Insight 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 __itkVector_h
00018 #define __itkVector_h
00019 
00020 #include "itkFixedArray.h"
00021 #include "vnl/vnl_vector_ref.h"
00022 #include "itkIndent.h"
00023 
00024 namespace itk
00025 {
00026 
00055 template<class T, unsigned int NVectorDimension=3>
00056 class Vector : public FixedArray<T,NVectorDimension>
00057 {
00058 public:
00060   typedef Vector  Self;
00061   typedef FixedArray<T,NVectorDimension>  Superclass;
00062   
00065   typedef T ValueType;
00066 
00068   itkStaticConstMacro(Dimension, unsigned int, NVectorDimension);
00069 
00071   typedef Self VectorType;
00072   
00074   typedef FixedArray<T, NVectorDimension>                BaseArray;
00075     
00077   static unsigned int GetVectorDimension() 
00078     { return NVectorDimension; }  
00079 
00081   void Set_vnl_vector( const vnl_vector<T> & );
00082 
00084   vnl_vector_ref<T> Get_vnl_vector( void );
00085 
00087   vnl_vector<T> Get_vnl_vector( void ) const;
00088 
00090   Vector(): BaseArray() { }
00091   Vector(const ValueType& r);
00092   
00094   Vector(const Self& r): BaseArray(r) {}
00095   Vector(const ValueType r[Dimension]): BaseArray(r) {}  
00096     
00098   Vector& operator= (const Self& r);
00099   Vector& operator= (const ValueType r[Dimension]);
00100     
00102   const Self& operator*=(const ValueType &value);
00103 
00105   const Self& operator/=(const ValueType &value);
00106 
00108   const Self& operator+=(const Self &vec);
00109 
00111   const Self& operator-=(const Self &vec);
00112 
00115   Self operator-() const;
00116 
00118   Self operator+(const Self &vec) const;
00119 
00121   Self operator-(const Self &vec) const;
00122 
00125   ValueType operator*(const Self &vec) const;
00126 
00129   Self operator*(const ValueType& val) const;
00130 
00133   Self operator/(const ValueType& val) const;
00134 
00139   bool operator==(const Self& v) const
00140     { return Superclass::operator==(v); }
00141   bool operator!=(const Self& v) const
00142     { return !operator==(v); }
00143    
00145   ValueType GetNorm( void ) const;
00146 
00148   ValueType GetSquaredNorm( void ) const; 
00149 
00151   void Normalize(void);
00152 
00155   template < typename TCoordRepB >
00156   void CastFrom( const Vector<TCoordRepB,NVectorDimension> & pa )
00157   {
00158     for(unsigned int i=0; i<NVectorDimension; i++ )
00159       {
00160       (*this)[i] = static_cast<T>( pa[i] );
00161       }
00162   }
00163 
00164 };
00165 
00166 template< class T, unsigned int NVectorDimension >  
00167 ITK_EXPORT std::ostream& operator<<(std::ostream& os, 
00168                                     const Vector<T,NVectorDimension> & v); 
00169 
00170 template< class T, unsigned int NVectorDimension >  
00171 ITK_EXPORT std::istream& operator>>(std::istream& is, 
00172                                     Vector<T,NVectorDimension> & v); 
00173 
00174 ITK_EXPORT Vector<double,3> operator^( const Vector<double,3> &,
00175                                        const Vector<double,3> &  );
00176 
00177 ITK_EXPORT Vector<float,3> operator^( const Vector<float,3> &,
00178                                       const Vector<float,3> &  );
00179 
00180 ITK_EXPORT Vector<int,3> operator^( const Vector<int,3> &,
00181                                     const Vector<int,3> &  );
00182 
00183 } // end namespace itk
00184   
00185 
00186 #ifndef ITK_MANUAL_INSTANTIATION
00187 #include "itkVector.txx"
00188 #endif
00189 
00190 
00191 #endif 

Generated at Fri May 21 01:15:27 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000