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

itkPoint.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkPoint.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:23 $ 00007 Version: $Revision: 1.52 $ 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 __itkPoint_h 00018 #define __itkPoint_h 00019 00020 #include "itkVector.h" 00021 #include "vnl/vnl_vector_ref.h" 00022 #include "itkIndent.h" 00023 00024 namespace itk 00025 { 00041 template<class TCoordRep, unsigned int NPointDimension=3> 00042 class Point : public FixedArray< TCoordRep, NPointDimension > 00043 { 00044 public: 00046 typedef Point Self; 00047 typedef FixedArray<TCoordRep,NPointDimension> Superclass; 00048 00051 typedef TCoordRep ValueType; 00052 typedef TCoordRep CoordRepType; 00053 00055 itkStaticConstMacro(PointDimension, unsigned int, NPointDimension); 00056 00058 typedef FixedArray<TCoordRep, NPointDimension> BaseArray; 00059 typedef typename BaseArray::Iterator Iterator; 00060 typedef typename BaseArray::ConstIterator ConstIterator; 00061 00063 static unsigned int GetPointDimension() 00064 { return NPointDimension; } 00065 00067 typedef Vector< ValueType, NPointDimension > VectorType; 00068 00070 Point() {} 00071 00073 Point(const Self& r): BaseArray(r) {} 00074 Point(const ValueType r[PointDimension]): BaseArray(r) {} 00075 00077 Point& operator= (const Self& r); 00078 Point& operator= (const ValueType r[PointDimension]); 00079 00081 bool 00082 operator==(const Self &pt) const 00083 { 00084 bool same=true; 00085 for (unsigned int i=0; i < PointDimension && same; i++) 00086 { same = ((*this)[i] == pt[i]); } 00087 return same; 00088 } 00089 00091 bool 00092 operator!=(const Self &pt) const 00093 { 00094 bool same=true; 00095 for (unsigned int i=0; i < PointDimension && same; i++) 00096 { same = ((*this)[i] == pt[i]); } 00097 return !same; 00098 } 00099 00101 const Self& operator+=(const VectorType &vec); 00102 00104 const Self& operator-=(const VectorType &vec); 00105 00107 VectorType operator-(const Self &pnt) const; 00108 00110 Self operator+(const VectorType &vec) const; 00111 00113 Self operator-(const VectorType &vec) const; 00114 00116 VectorType GetVectorFromOrigin() const; 00117 00119 TCoordRep EuclideanDistanceTo( const Self & ) const; 00120 00122 TCoordRep SquaredEuclideanDistanceTo( const Self & ) const; 00123 00125 vnl_vector_ref<TCoordRep> Get_vnl_vector( void ); 00126 00138 void SetToMidPoint( const Self &, const Self & ); 00139 00164 void SetToBarycentricCombination( const Self & A, const Self & B, double alpha ); 00165 00181 void SetToBarycentricCombination( const Self & A, const Self & B, const Self & C, 00182 double weightA, double weightB ); 00183 00196 void SetToBarycentricCombination( const Self * P, const double * weights, unsigned int N); 00197 00198 00201 template < typename TCoordRepB > 00202 void CastFrom( const Point<TCoordRepB,NPointDimension> & pa ) 00203 { 00204 for(unsigned int i=0; i<NPointDimension; i++ ) 00205 { 00206 (*this)[i] = static_cast<TCoordRep>( pa[i] ); 00207 } 00208 } 00209 }; 00210 00211 template< class T, unsigned int NPointDimension > 00212 ITK_EXPORT std::ostream& operator<<(std::ostream& os, 00213 const Point<T,NPointDimension> & v); 00214 00215 template< class T, unsigned int NPointDimension > 00216 ITK_EXPORT std::istream& operator>>(std::istream& is, 00217 Point<T,NPointDimension> & v); 00218 00240 template< class TPointContainer, class TWeightContainer > 00241 ITK_EXPORT class BarycentricCombination 00242 { 00243 public: 00245 typedef TPointContainer PointContainerType; 00246 typedef typename PointContainerType::Pointer PointContainerPointer; 00247 typedef typename PointContainerType::Element PointType; 00248 typedef TWeightContainer WeightContainerType; 00249 00250 BarycentricCombination() {}; 00251 ~BarycentricCombination() {}; 00252 00253 static PointType Evaluate( 00254 const PointContainerPointer & points, 00255 const WeightContainerType & weights ); 00256 }; 00257 00258 00259 00260 00261 00262 } // end namespace itk 00263 00264 #ifndef ITK_MANUAL_INSTANTIATION 00265 #include "itkPoint.txx" 00266 #endif 00267 00268 00269 #endif

Generated at Sat Mar 31 02:27:20 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000