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: 2010-02-02 13:45:16 $
00007   Version:   $Revision: 1.12 $
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   typedef SmartPointer< Self >         Pointer;
00055   typedef SmartPointer<const Self>     ConstPointer;
00056 
00058   itkTypeMacro(ListSampleBase, Sample);
00059 
00061   typedef typename Superclass::MeasurementVectorType     MeasurementVectorType;
00062   typedef typename Superclass::MeasurementVectorSizeType MeasurementVectorSizeType;
00063   typedef typename Superclass::MeasurementType           MeasurementType;
00064   typedef typename Superclass::FrequencyType             FrequencyType;
00065   typedef typename Superclass::InstanceIdentifier        InstanceIdentifier;
00066 
00069   typedef std::vector< InstanceIdentifier > SearchResultVectorType;
00070 
00073   inline void Search(MeasurementVectorType center, double radius, 
00074                      SearchResultVectorType& result) const
00075     {
00076     if (radius == 0.0)
00077       {
00078       itkGenericExceptionMacro("Search radius should be greater than zero.");
00079       }
00080 
00081     unsigned int j;
00082     double squaredRadius;
00083     double distance;
00084     double coordinateDistance;
00085     
00086     MeasurementVectorType tempVector;
00087     
00088     squaredRadius = radius * radius;
00089     
00090     result.clear();
00091     for ( InstanceIdentifier identifier = 0; identifier < this->Size(); ++identifier )
00092       {
00093       distance = 0.0;
00094       tempVector = this->GetMeasurementVector( identifier );
00095       for (j = 0; j < this->GetMeasurementVectorSize() && distance < squaredRadius; j++)
00096         {
00097         coordinateDistance = (double)tempVector[j] - center[j];
00098         if (vnl_math_abs(coordinateDistance) > radius )
00099           {
00100           distance = squaredRadius;
00101           }
00102         }
00103       
00104       for (j = 0; j < this->GetMeasurementVectorSize() && distance < squaredRadius; j++)
00105         {
00106         coordinateDistance = (double)tempVector[j] - center[j];
00107         distance += coordinateDistance * coordinateDistance;
00108         }
00109       
00110       if (distance < squaredRadius)
00111         {
00112         result.push_back( identifier );
00113         }
00114       }
00115     }
00116   
00117 protected:
00118   ListSampleBase() {}
00119   virtual ~ListSampleBase() {}
00120   void PrintSelf(std::ostream& os, Indent indent) const
00121     {
00122     Superclass::PrintSelf(os,indent);
00123     }
00124 
00125   
00126 private:
00127   ListSampleBase(const Self&); //purposely not implemented
00128   void operator=(const Self&); //purposely not implemented
00129 
00130 };
00131 
00132 } // end of namespace Statistics 
00133 } // end of namespace itk 
00134 
00135 #endif
00136 

Generated at Fri Apr 16 18:58:36 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000