00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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&) ;
00198
void operator=(
const Self&) ;
00199
00200
InternalDataContainerType m_InternalContainer ;
00201 };
00202
00203 }
00204 }
00205
00206
#ifndef ITK_MANUAL_INSTANTIATION
00207
#include "itkListSample.txx"
00208
#endif
00209
00210
#endif