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/12/04 17:30:20 $ 00007 Version: $Revision: 1.54 $ 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 #ifdef ITK_EXPLICIT_INSTANTIATION 00259 extern template class Point<float ,2>; 00260 extern template class Point<double ,2>; 00261 extern template class Point<float ,3>; 00262 extern template class Point<double ,3>; 00263 #endif 00264 00265 } // end namespace itk 00266 00267 #ifndef ITK_MANUAL_INSTANTIATION 00268 #include "itkPoint.txx" 00269 #endif 00270 00271 00272 #endif

Generated at Sun Apr 1 02:41:05 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000