00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkPointSetToListAdaptor_h
00018 #define __itkPointSetToListAdaptor_h
00019
00020 #include <typeinfo>
00021
00022 #include "itkPointSet.h"
00023 #include "itkListSample.h"
00024 #include "itkSmartPointer.h"
00025
00026 namespace itk{
00027 namespace Statistics{
00028
00042 template < class TPointSet >
00043 class ITK_EXPORT PointSetToListAdaptor :
00044 public ListSample< typename TPointSet::PointType >
00045 {
00046 public:
00048 typedef PointSetToListAdaptor Self;
00049 typedef ListSample< typename TPointSet::PointType > Superclass ;
00050 typedef SmartPointer< Self > Pointer;
00051
00053 itkTypeMacro(PointSetToListAdaptor, ListSample) ;
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(PointSetPointer pointSet) ;
00080
00082 PointSetPointer GetPointSet() ;
00083
00085 unsigned int Size() const ;
00086
00091 unsigned int Size(const unsigned int &dimension) const ;
00092
00094 unsigned int GetNumberOfInstances() const ;
00095
00098 MeasurementVectorType& GetMeasurementVector(const InstanceIdentifier &id) ;
00099
00102 void SetMeasurement(const InstanceIdentifier &id,
00103 const unsigned int &dim,
00104 const MeasurementType &value) ;
00105
00107 FrequencyType GetFrequency(const InstanceIdentifier &id) const ;
00108
00110 FrequencyType GetTotalFrequency(const unsigned int &dimension) const ;
00111
00113 class Iterator;
00114 friend class Iterator;
00115
00117 Iterator Begin()
00118 {
00119 Iterator iter(m_PointsContainer->Begin());
00120 return iter;
00121 }
00122
00124 Iterator End()
00125 {
00126 Iterator iter(m_PointsContainer->End());
00127 return iter;
00128 }
00129
00130 class Iterator
00131 {
00132 public:
00133
00134 Iterator(){}
00135
00136 Iterator(PointsContainerIterator iter)
00137 :m_Iter(iter)
00138 {}
00139
00140 FrequencyType GetFrequency() const
00141 { return 1 ;}
00142
00143 MeasurementVectorType& GetMeasurementVector()
00144 { return (MeasurementVectorType&) m_Iter.Value() ;}
00145
00146 InstanceIdentifier GetInstanceIdentifier() const
00147 { return m_Iter.Index() ;}
00148
00149 Iterator& operator++()
00150 { ++m_Iter ; return *this ;}
00151
00152 Iterator& operator--()
00153 { --m_Iter ; return *this ;}
00154
00155 bool operator!=(const Iterator &it)
00156 { return (m_Iter != it.m_Iter) ;}
00157
00158 bool operator==(const Iterator &it)
00159 { return (m_Iter == it.m_Iter) ;}
00160
00161 Iterator& operator = (const Iterator &iter)
00162 {
00163 m_Iter = iter.m_Iter;
00164 return iter ;
00165 }
00166
00167 Iterator(const Iterator &iter)
00168 { m_Iter = iter.m_Iter; }
00169
00170 private:
00171 PointsContainerIterator m_Iter ;
00172 } ;
00173
00174 protected:
00175 PointSetToListAdaptor() {}
00176 virtual ~PointSetToListAdaptor() {}
00177 void PrintSelf(std::ostream& os, Indent indent) const;
00178
00179 private:
00180 PointSetToListAdaptor(const Self&) ;
00181 void operator=(const Self&) ;
00182
00184 PointSetPointer m_PointSet ;
00187 PointsContainerPointer m_PointsContainer ;
00189 PointType m_TempPoint ;
00190 } ;
00191
00192 }
00193 }
00194
00195
00196 #ifndef ITK_MANUAL_INSTANTIATION
00197 #include "itkPointSetToListAdaptor.txx"
00198 #endif
00199
00200 #endif