ITK  6.0.0
Insight Toolkit
itkMembershipFunctionBase.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 itkMembershipFunctionBase_h
19#define itkMembershipFunctionBase_h
20
21#include "itkFunctionBase.h"
24
25namespace itk
26{
27namespace Statistics
28{
57template <typename TVector>
58class ITK_TEMPLATE_EXPORT MembershipFunctionBase : public FunctionBase<TVector, double>
59{
60public:
61 ITK_DISALLOW_COPY_AND_MOVE(MembershipFunctionBase);
62
68
70 itkOverrideGetNameOfClassMacro(MembershipFunctionBase);
71
73 using MeasurementVectorType = TVector;
74
76 using MeasurementVectorSizeType = unsigned int;
77
81 double
82 Evaluate(const MeasurementVectorType & x) const override = 0;
83
91 virtual void
93 {
94 // Test whether the vector type is resizable or not
95 if (MeasurementVectorTraits::IsResizable<MeasurementVectorType>({}))
96 {
97 // then this is a resizable vector type
98 //
99 // if the new size is the same as the previous size, just return
100 if (s == this->m_MeasurementVectorSize)
101 {
102 return;
103 }
104 else
105 {
106 this->m_MeasurementVectorSize = s;
107 this->Modified();
108 }
109 }
110 else
111 {
112 // If this is a non-resizable vector type
114 // and the new length is different from the default one, then throw an
115 // exception
116 if (defaultLength != s)
117 {
118 itkExceptionMacro("Attempting to change the measurement vector size of a non-resizable vector type");
119 }
120 }
121 }
125 itkGetConstMacro(MeasurementVectorSize, MeasurementVectorSizeType);
126
127protected:
129 {
131 }
132
133 ~MembershipFunctionBase() override = default;
134
135 void
136 PrintSelf(std::ostream & os, Indent indent) const override
137 {
138 Superclass::PrintSelf(os, indent);
139 os << indent << "Length of measurement vectors: " << m_MeasurementVectorSize << std::endl;
140 }
141
142private:
143 MeasurementVectorSizeType m_MeasurementVectorSize{};
144
145}; // end of class
146} // end of namespace Statistics
147} // end namespace itk
148
149#endif
Base class for all ITK function objects.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
static unsigned int GetLength()
MembershipFunctionBase defines common interfaces for membership functions.
double Evaluate(const MeasurementVectorType &x) const override=0
virtual void SetMeasurementVectorSize(MeasurementVectorSizeType s)
void PrintSelf(std::ostream &os, Indent indent) const override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....