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

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: 2005/09/30 14:14:19 $
00007   Version:   $Revision: 1.25 $
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 );
00126 
00127   
00128 protected:
00129   Sample()
00130     {
00131     m_MeasurementVectorSize = 0;
00132     }
00133 
00134   virtual ~Sample() {}
00135   void PrintSelf(std::ostream& os, Indent indent) const
00136   {
00137     Superclass::PrintSelf(os,indent);
00138     os << indent << "Length of measurement vectors in the sample: " << 
00139       m_MeasurementVectorSize << std::endl;
00140   }
00141 
00142 
00143   
00144 private:
00145   Sample(const Self&) ; //purposely not implemented
00146   void operator=(const Self&) ; //purposely not implemented
00147 
00148   MeasurementVectorSizeType m_MeasurementVectorSize;
00149 } ; // end of class
00150 
00151 } // end of namespace Statistics 
00152 } // end of namespace itk
00153 
00154 #endif

Generated at Wed May 24 23:59:21 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000