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

itkListSample.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkListSample.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:29:46 $ 00007 Version: $Revision: 1.17 $ 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 __itkListSample_h 00018 #define __itkListSample_h 00019 00020 #include "itkObjectFactory.h" 00021 #include "itkMacro.h" 00022 #include "itkListSampleBase.h" 00023 #include "itkFixedArray.h" 00024 #include "itkSmartPointer.h" 00025 00026 #include <vector> 00027 00028 namespace itk{ 00029 namespace Statistics{ 00030 00041 template< class TMeasurementVector > 00042 class ITK_EXPORT ListSample : public ListSampleBase< TMeasurementVector > 00043 { 00044 public: 00046 typedef ListSample Self; 00047 typedef ListSampleBase< TMeasurementVector > Superclass; 00048 typedef SmartPointer< Self > Pointer; 00049 00051 itkTypeMacro(ListSample, ListSampleBase); 00052 00054 itkNewMacro(Self) ; 00055 00060 typedef typename Superclass::MeasurementVectorType MeasurementVectorType; 00061 typedef typename Superclass::MeasurementType MeasurementType; 00062 typedef typename Superclass::FrequencyType FrequencyType ; 00063 typedef typename Superclass::InstanceIdentifier InstanceIdentifier; 00064 typedef typename Superclass::SearchResultVectorType SearchResultVectorType ; 00065 00066 typedef MeasurementVectorType ValueType ; 00067 00069 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00070 Superclass::MeasurementVectorSize); 00071 00073 typedef std::vector< MeasurementVectorType > InternalDataContainerType ; 00074 00079 void Resize( unsigned int n ) 00080 { m_InternalContainer.resize(n) ; } 00081 00083 void Clear() 00084 { m_InternalContainer.clear() ; } 00085 00087 void PushBack( MeasurementVectorType mv ) 00088 { m_InternalContainer.push_back( mv ) ; } 00089 00091 unsigned int Size() const 00092 { return static_cast<unsigned int>( m_InternalContainer.size() ); } 00093 00096 MeasurementVectorType GetMeasurementVector(const InstanceIdentifier &id) ; 00097 00100 void SetMeasurement(const InstanceIdentifier &id, 00101 const unsigned int &dim, 00102 const MeasurementType &value) ; 00103 00106 void SetMeasurementVector(const InstanceIdentifier &id, 00107 const MeasurementVectorType &mv) ; 00108 00110 FrequencyType GetFrequency(const InstanceIdentifier &id) const ; 00111 00113 FrequencyType GetTotalFrequency() const 00114 { return static_cast<FrequencyType>( m_InternalContainer.size() ); } 00115 00117 class Iterator; 00118 friend class Iterator; 00119 00121 Iterator Begin() 00122 { 00123 Iterator iter(m_InternalContainer.begin(), 0); 00124 return iter; 00125 } 00126 00128 Iterator End() 00129 { 00130 Iterator iter(m_InternalContainer.end(), m_InternalContainer.size()); 00131 return iter; 00132 } 00133 00134 class Iterator 00135 { 00136 public: 00137 00138 Iterator(){} 00139 00140 Iterator(typename InternalDataContainerType::iterator iter, 00141 InstanceIdentifier iid) 00142 :m_Iter(iter), m_InstanceIdentifier(iid) 00143 {} 00144 00145 FrequencyType GetFrequency() const 00146 { return 1 ;} 00147 00148 MeasurementVectorType GetMeasurementVector() 00149 { return (MeasurementVectorType&) *m_Iter ;} 00150 00151 InstanceIdentifier GetInstanceIdentifier() const 00152 { return m_InstanceIdentifier ;} 00153 00154 Iterator& operator++() 00155 { ++m_Iter ; ++m_InstanceIdentifier ; return *this ;} 00156 00157 Iterator& operator--() 00158 { 00159 --m_Iter ; 00160 00161 if ( m_InstanceIdentifier > 1 ) 00162 m_InstanceIdentifier; 00163 00164 return *this ; 00165 } 00166 00167 bool operator!=(const Iterator &it) 00168 { return (m_Iter != it.m_Iter) ;} 00169 00170 bool operator==(const Iterator &it) 00171 { return (m_Iter == it.m_Iter) ;} 00172 00173 Iterator& operator = (const Iterator iter) 00174 { 00175 m_Iter = iter.m_Iter; 00176 m_InstanceIdentifier = iter.m_InstanceIdentifier ; 00177 return *this ; 00178 } 00179 00180 Iterator(const Iterator &iter) 00181 { 00182 m_Iter = iter.m_Iter; 00183 m_InstanceIdentifier = iter.m_InstanceIdentifier ; 00184 } 00185 00186 private: 00187 typename InternalDataContainerType::iterator m_Iter ; 00188 InstanceIdentifier m_InstanceIdentifier ; 00189 } ; 00190 00191 protected: 00192 ListSample() ; 00193 virtual ~ListSample() {} 00194 void PrintSelf(std::ostream& os, Indent indent) const; 00195 00196 private: 00197 ListSample(const Self&) ; //purposely not implemented 00198 void operator=(const Self&) ; //purposely not implemented 00199 00200 InternalDataContainerType m_InternalContainer ; 00201 }; 00202 00203 } // end of namespace Statistics 00204 } // end of namespace itk 00205 00206 #ifndef ITK_MANUAL_INSTANTIATION 00207 #include "itkListSample.txx" 00208 #endif 00209 00210 #endif

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