00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkDistanceMetric_h
00018 #define __itkDistanceMetric_h
00019
00020 #include "itkArray.h"
00021 #include "itkFunctionBase.h"
00022 #include "itkMeasurementVectorTraits.h"
00023
00024 namespace itk {
00025 namespace Statistics {
00026
00044 template< class TVector >
00045 class ITK_EXPORT DistanceMetric : public FunctionBase< TVector, double >
00046 {
00047 public:
00049 typedef DistanceMetric Self;
00050 typedef FunctionBase< TVector, double > Superclass;
00051 typedef SmartPointer< Self > Pointer;
00052 typedef SmartPointer<const Self> ConstPointer;
00053
00055 typedef TVector MeasurementVectorType;
00056
00060 typedef unsigned int MeasurementVectorSizeType;
00061
00063 itkTypeMacro(DistanceMetric, FunctionBase);
00064
00065 typedef Array< double > OriginType;
00066
00073 void SetOrigin(const OriginType& x);
00074 itkGetConstReferenceMacro(Origin, OriginType);
00076
00079 virtual double Evaluate(const MeasurementVectorType &x) const = 0;
00080
00086 virtual double Evaluate(const MeasurementVectorType &x1,
00087 const MeasurementVectorType &x2) const = 0;
00088
00090 virtual void SetMeasurementVectorSize( MeasurementVectorSizeType s )
00091 {
00092
00093 MeasurementVectorType m;
00094 if( MeasurementVectorTraits::IsResizable( m ) )
00095 {
00096
00097
00098
00099 if( s == this->m_MeasurementVectorSize )
00100 {
00101 return;
00102 }
00103 else
00104 {
00105 this->m_MeasurementVectorSize = s;
00106 this->Modified();
00107 }
00108 }
00109 else
00110 {
00111
00112 MeasurementVectorType m3;
00113 MeasurementVectorSizeType defaultLength = MeasurementVectorTraits::GetLength( m3 );
00114
00115 if( defaultLength != s )
00116 {
00117 itkExceptionMacro("Attempting to change the measurement \
00118 vector size of a non-resizable vector type");
00119 }
00120 }
00121 }
00123
00125 itkGetConstMacro( MeasurementVectorSize, MeasurementVectorSizeType );
00126
00127 protected:
00128 DistanceMetric();
00129 virtual ~DistanceMetric() {}
00130 void PrintSelf(std::ostream& os, Indent indent) const;
00131
00132 private:
00133
00134 OriginType m_Origin;
00135
00137 MeasurementVectorSizeType m_MeasurementVectorSize;
00138 };
00139
00140 }
00141 }
00142
00143 #ifndef ITK_MANUAL_INSTANTIATION
00144 #include "itkDistanceMetric.txx"
00145 #endif
00146
00147 #endif
00148