00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkPointSetToListAdaptor.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:47 $ 00007 Version: $Revision: 1.9 $ 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 __itkPointSetToListAdaptor_h 00018 #define __itkPointSetToListAdaptor_h 00019 00020 #include <typeinfo> 00021 00022 #include "itkPointSet.h" 00023 #include "itkListSampleBase.h" 00024 #include "itkSmartPointer.h" 00025 00026 namespace itk{ 00027 namespace Statistics{ 00028 00042 template < class TPointSet > 00043 class ITK_EXPORT PointSetToListAdaptor : 00044 public ListSampleBase< typename TPointSet::PointType > 00045 { 00046 public: 00048 typedef PointSetToListAdaptor Self; 00049 typedef ListSampleBase< typename TPointSet::PointType > Superclass ; 00050 typedef SmartPointer< Self > Pointer; 00051 00053 itkTypeMacro(PointSetToListAdaptor, ListSampleBase) ; 00054 00056 itkNewMacro(Self) ; 00057 00059 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00060 TPointSet::PointDimension); 00061 00063 typedef TPointSet PointSetType; 00064 typedef typename TPointSet::Pointer PointSetPointer ; 00065 typedef typename TPointSet::PointIdentifier InstanceIdentifier; 00066 typedef typename TPointSet::PointsContainerPointer PointsContainerPointer ; 00067 typedef typename TPointSet::PointsContainerIterator PointsContainerIterator ; 00068 typedef typename TPointSet::PointType PointType ; 00069 00070 00073 typedef typename Superclass::MeasurementType MeasurementType ; 00074 typedef typename Superclass::MeasurementVectorType MeasurementVectorType; 00075 typedef MeasurementVectorType ValueType ; 00076 typedef typename Superclass::FrequencyType FrequencyType ; 00077 00079 void SetPointSet(TPointSet* pointSet) ; 00080 00082 TPointSet* GetPointSet() ; 00083 00085 unsigned int Size() const ; 00086 00089 MeasurementVectorType GetMeasurementVector(const InstanceIdentifier &id) ; 00090 00093 void SetMeasurement(const InstanceIdentifier &id, 00094 const unsigned int &dim, 00095 const MeasurementType &value) ; 00096 00098 FrequencyType GetFrequency(const InstanceIdentifier &id) const ; 00099 00101 FrequencyType GetTotalFrequency() const ; 00102 00104 class Iterator; 00105 friend class Iterator; 00106 00108 Iterator Begin() 00109 { 00110 Iterator iter(m_PointsContainer->Begin()); 00111 return iter; 00112 } 00113 00115 Iterator End() 00116 { 00117 Iterator iter(m_PointsContainer->End()); 00118 return iter; 00119 } 00120 00121 class Iterator 00122 { 00123 public: 00124 00125 Iterator(){} 00126 00127 Iterator(PointsContainerIterator iter) 00128 :m_Iter(iter) 00129 {} 00130 00131 FrequencyType GetFrequency() const 00132 { return 1 ;} 00133 00134 MeasurementVectorType GetMeasurementVector() 00135 { return (MeasurementVectorType&) m_Iter.Value() ;} 00136 00137 InstanceIdentifier GetInstanceIdentifier() const 00138 { return m_Iter.Index() ;} 00139 00140 Iterator& operator++() 00141 { ++m_Iter ; return *this ;} 00142 00143 Iterator& operator--() 00144 { --m_Iter ; return *this ;} 00145 00146 bool operator!=(const Iterator &it) 00147 { return (m_Iter != it.m_Iter) ;} 00148 00149 bool operator==(const Iterator &it) 00150 { return (m_Iter == it.m_Iter) ;} 00151 00152 Iterator& operator = (const Iterator &iter) 00153 { 00154 m_Iter = iter.m_Iter; 00155 return iter ; 00156 } 00157 00158 Iterator(const Iterator &iter) 00159 { m_Iter = iter.m_Iter; } 00160 00161 private: 00162 PointsContainerIterator m_Iter ; 00163 } ; 00164 00165 protected: 00166 PointSetToListAdaptor() ; 00167 virtual ~PointSetToListAdaptor() {} 00168 void PrintSelf(std::ostream& os, Indent indent) const; 00169 00170 private: 00171 PointSetToListAdaptor(const Self&) ; //purposely not implemented 00172 void operator=(const Self&) ; //purposely not implemented 00173 00175 PointSetPointer m_PointSet ; 00178 PointsContainerPointer m_PointsContainer ; 00180 PointType m_TempPoint ; 00181 } ; // end of class PointSetToListAdaptor 00182 00183 } // end of namespace Statistics 00184 } // end of namespace itk 00185 00186 00187 #ifndef ITK_MANUAL_INSTANTIATION 00188 #include "itkPointSetToListAdaptor.txx" 00189 #endif 00190 00191 #endif