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

Numerics/Statistics/itkSample.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSample.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-04 19:29:53 $
00007   Version:   $Revision: 1.27 $
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 __itkSample_h
00018 #define __itkSample_h
00019 
00020 #include <vector>
00021 
00022 #include "itkMacro.h"
00023 #include "itkPoint.h"
00024 #include "itkSize.h"
00025 #include "itkObject.h"
00026 #include "itkFixedArray.h"
00027 #include "itkMeasurementVectorTraits.h"
00028 #include "itkNumericTraits.h"
00029 
00030 namespace itk { 
00031 namespace Statistics {
00032 
00062 template < class TMeasurementVector >
00063 class ITK_EXPORT Sample : public Object
00064 {
00065 public:
00067   typedef Sample                   Self;  
00068   typedef Object                   Superclass;
00069   typedef SmartPointer< Self >     Pointer;
00070   typedef SmartPointer<const Self> ConstPointer;
00071 
00073   itkTypeMacro(Sample, Object);
00074 
00076   typedef TMeasurementVector MeasurementVectorType;
00077 
00080   typedef typename MeasurementVectorType::ValueType   MeasurementType;
00081 
00083   typedef float FrequencyType;
00084 
00086   typedef NumericTraits<FrequencyType>::AccumulateType TotalFrequencyType;
00087 
00090   typedef unsigned long InstanceIdentifier;
00091 
00093   typedef unsigned int  MeasurementVectorSizeType;
00094 
00096   virtual unsigned int Size() const = 0;
00097 
00100   virtual const MeasurementVectorType & 
00101     GetMeasurementVector(const InstanceIdentifier &id) const = 0;
00102 
00105   virtual FrequencyType GetFrequency(const InstanceIdentifier &id) const = 0;
00106 
00108   virtual TotalFrequencyType GetTotalFrequency() const 
00109     = 0;
00110 
00111   
00113   virtual void SetMeasurementVectorSize( const MeasurementVectorSizeType s )
00114     {
00115     MeasurementVectorType m;
00116     MeasurementVectorSizeType defaultLength = MeasurementVectorTraits::GetLength( m );
00117     if( (defaultLength != 0) && (s!=defaultLength) )
00118       {
00119       return; // Do not do anything.
00120       //itkExceptionMacro( << "Cannot instantiate a sample with a fixed length "
00121       // << "container and resize it later. Create it with itk::Array if you like.");
00122       }
00123     this->m_MeasurementVectorSize = s;
00124     }
00125   itkGetConstMacro( MeasurementVectorSize, MeasurementVectorSizeType );
00127 
00128   
00129 protected:
00130   Sample()
00131     {
00132     m_MeasurementVectorSize = MeasurementVectorTraits::GetLength( 
00133                                         MeasurementVectorType() );
00134     }
00135 
00136   virtual ~Sample() {}
00137   void PrintSelf(std::ostream& os, Indent indent) const
00138     {
00139     Superclass::PrintSelf(os,indent);
00140     os << indent << "Length of measurement vectors in the sample: " << 
00141       m_MeasurementVectorSize << std::endl;
00142     }
00143 
00144 
00145   
00146 private:
00147   Sample(const Self&); //purposely not implemented
00148   void operator=(const Self&); //purposely not implemented
00149 
00150   MeasurementVectorSizeType m_MeasurementVectorSize;
00151 }; // end of class
00152 
00153 } // end of namespace Statistics 
00154 } // end of namespace itk
00155 
00156 #endif
00157 

Generated at Thu May 28 11:26:22 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000