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: 2003/12/15 01:00:46 $ 00007 Version: $Revision: 1.6 $ 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 00038 template< class TMeasurementVector > 00039 class ITK_EXPORT ListSampleBase : public Sample< TMeasurementVector > 00040 { 00041 public: 00043 typedef ListSampleBase Self; 00044 typedef Sample< TMeasurementVector > Superclass; 00045 00047 itkTypeMacro(ListSampleBase, Sample); 00048 00053 typedef typename Superclass::MeasurementVectorType MeasurementVectorType; 00054 typedef typename Superclass::MeasurementType MeasurementType; 00055 typedef typename Superclass::FrequencyType FrequencyType ; 00056 typedef typename Superclass::InstanceIdentifier InstanceIdentifier; 00057 00058 typedef std::vector< InstanceIdentifier > SearchResultVectorType ; 00060 itkStaticConstMacro(MeasurementVectorSize, unsigned int, 00061 TMeasurementVector::Length); 00062 00063 00064 inline void Search(MeasurementVectorType center, double radius, 00065 SearchResultVectorType& result) const 00066 { 00067 if (radius == 0.0) 00068 { 00069 itkGenericExceptionMacro("Search radius should be greater than zero.") ; 00070 } 00071 00072 unsigned int j ; 00073 double squaredRadius ; 00074 double distance ; 00075 double coordinateDistance ; 00076 00077 MeasurementVectorType tempVector ; 00078 unsigned int length = MeasurementVectorType::Length ; 00079 00080 squaredRadius = radius * radius ; 00081 00082 result.clear() ; 00083 for ( InstanceIdentifier id = 0 ; id < this->Size() ; ++id ) 00084 { 00085 distance = 0.0 ; 00086 tempVector = this->GetMeasurementVector( id ) ; 00087 for (j = 0 ; j < length && distance < squaredRadius ; j++) 00088 { 00089 coordinateDistance = (double)tempVector[j] - center[j] ; 00090 if (vnl_math_abs(coordinateDistance) > radius ) 00091 { 00092 distance = squaredRadius ; 00093 } 00094 } 00095 00096 for (j = 0 ; j < length && distance < squaredRadius ; j++) 00097 { 00098 coordinateDistance = (double)tempVector[j] - center[j] ; 00099 distance += coordinateDistance * coordinateDistance ; 00100 } 00101 00102 if (distance < squaredRadius) 00103 { 00104 result.push_back( id ) ; 00105 } 00106 } 00107 } 00108 protected: 00109 ListSampleBase() {} 00110 virtual ~ListSampleBase() {} 00111 00112 private: 00113 ListSampleBase(const Self&) ; //purposely not implemented 00114 void operator=(const Self&) ; //purposely not implemented 00115 }; 00116 00117 } // end of namespace Statistics 00118 } // end of namespace itk 00119 00120 #endif

Generated at Sun Apr 1 02:37:11 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000