ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkDistanceMetric.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkDistanceMetric_h
19#define itkDistanceMetric_h
20
21#include "itkFunctionBase.h"
23
24namespace itk::Statistics
25{
45template <typename TVector>
46class ITK_TEMPLATE_EXPORT DistanceMetric : public FunctionBase<TVector, double>
47{
48public:
54
56 using MeasurementVectorType = TVector;
57
59
62 using MeasurementVectorSizeType = unsigned int;
63
65 itkOverrideGetNameOfClassMacro(DistanceMetric);
66
68
75 void
77
78 itkGetConstReferenceMacro(Origin, OriginType);
79
82 double
83 Evaluate(const MeasurementVectorType & x) const override = 0;
84
90 virtual double
91 Evaluate(const MeasurementVectorType & x1, const MeasurementVectorType & x2) const = 0;
92
94 virtual void
96 {
97 // Test whether the vector type is resizable or not
99 {
100 // then this is a resizable vector type
101 //
102 // if the new size is the same as the previous size, just return
103 if (s == this->m_MeasurementVectorSize)
104 {
105 return;
106 }
107
108 this->m_MeasurementVectorSize = s;
109 this->Modified();
110 }
111 else
112 {
113 // If this is a non-resizable vector type
115 // and the new length is different from the default one, then throw an
116 // exception
117 if (defaultLength != s)
118 {
119 itkExceptionMacro("Attempting to change the measurement vector size of a non-resizable vector type");
120 }
121 }
122 }
123
125 itkGetConstMacro(MeasurementVectorSize, MeasurementVectorSizeType);
126
127protected:
129 ~DistanceMetric() override = default;
130 void
131 PrintSelf(std::ostream & os, Indent indent) const override;
132
133private:
135
138}; // end of class
139} // namespace itk::Statistics
140
141#ifndef ITK_MANUAL_INSTANTIATION
142# include "itkDistanceMetric.hxx"
143#endif
144
145#endif
Array class with size defined at construction time.
Definition itkArray.h:48
Control indentation during Print() invocation.
Definition itkIndent.h:50
static unsigned int GetLength(const T &)
virtual void Modified() const
Implements transparent reference counting.
SmartPointer< const Self > ConstPointer
virtual double Evaluate(const MeasurementVectorType &x1, const MeasurementVectorType &x2) const =0
void SetOrigin(const OriginType &x)
~DistanceMetric() override=default
virtual void SetMeasurementVectorSize(MeasurementVectorSizeType s)
FunctionBase< TVector, double > Superclass
double Evaluate(const MeasurementVectorType &x) const override=0
void PrintSelf(std::ostream &os, Indent indent) const override