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

itkListSampleBase.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkListSampleBase.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-04 15:23:53 $
00007   Version:   $Revision: 1.11 $
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 __itkListSampleBase_h
00018 #define __itkListSampleBase_h
00019 
00020 #include "itkSample.h"
00021 
00022 #include <vector>
00023 
00024 namespace itk { 
00025 namespace Statistics {
00026 
00047 template< class TMeasurementVector >
00048 class ITK_EXPORT ListSampleBase : public Sample< TMeasurementVector >
00049 {
00050 public:
00052   typedef ListSampleBase               Self;
00053   typedef Sample< TMeasurementVector > Superclass;
00054 
00056   itkTypeMacro(ListSampleBase, Sample);
00057 
00059   typedef typename Superclass::MeasurementVectorType     MeasurementVectorType;
00060   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00061   typedef typename Superclass::MeasurementType           MeasurementType;
00062   typedef typename Superclass::FrequencyType             FrequencyType;
00063   typedef typename Superclass::InstanceIdentifier        InstanceIdentifier;
00064 
00067   typedef std::vector< InstanceIdentifier > SearchResultVectorType;
00068 
00071   inline void Search(MeasurementVectorType center, double radius, 
00072                      SearchResultVectorType& result) const
00073     {
00074     if (radius == 0.0)
00075       {
00076       itkGenericExceptionMacro("Search radius should be greater than zero.");
00077       }
00078 
00079     unsigned int j;
00080     double squaredRadius;
00081     double distance;
00082     double coordinateDistance;
00083     
00084     MeasurementVectorType tempVector;
00085     
00086     squaredRadius = radius * radius;
00087     
00088     result.clear();
00089     for ( InstanceIdentifier identifier = 0; identifier < this->Size(); ++identifier )
00090       {
00091       distance = 0.0;
00092       tempVector = this->GetMeasurementVector( identifier );
00093       for (j = 0; j < this->GetMeasurementVectorSize() && distance < squaredRadius; j++)
00094         {
00095         coordinateDistance = (double)tempVector[j] - center[j];
00096         if (vnl_math_abs(coordinateDistance) > radius )
00097           {
00098           distance = squaredRadius;
00099           }
00100         }
00101       
00102       for (j = 0; j < this->GetMeasurementVectorSize() && distance < squaredRadius; j++)
00103         {
00104         coordinateDistance = (double)tempVector[j] - center[j];
00105         distance += coordinateDistance * coordinateDistance;
00106         }
00107       
00108       if (distance < squaredRadius)
00109         {
00110         result.push_back( identifier );
00111         }
00112       }
00113     }
00114   
00115 protected:
00116   ListSampleBase() {}
00117   virtual ~ListSampleBase() {}
00118   void PrintSelf(std::ostream& os, Indent indent) const
00119     {
00120     Superclass::PrintSelf(os,indent);
00121     }
00122 
00123   
00124 private:
00125   ListSampleBase(const Self&); //purposely not implemented
00126   void operator=(const Self&); //purposely not implemented
00127 
00128 };
00129 
00130 } // end of namespace Statistics 
00131 } // end of namespace itk 
00132 
00133 #endif
00134 

Generated at Tue Sep 15 03:53:01 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000