ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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::Statistics
26{
54
55template <typename TVector>
56class ITK_TEMPLATE_EXPORT MembershipFunctionBase : public FunctionBase<TVector, double>
57{
58public:
59 ITK_DISALLOW_COPY_AND_MOVE(MembershipFunctionBase);
60
68 itkOverrideGetNameOfClassMacro(MembershipFunctionBase);
69
71 using MeasurementVectorType = TVector;
72
74 using MeasurementVectorSizeType = unsigned int;
75
79 double
80 Evaluate(const MeasurementVectorType & x) const override = 0;
81
89 virtual void
91 {
92 // Test whether the vector type is resizable or not
94 {
95 // then this is a resizable vector type
96 //
97 // if the new size is the same as the previous size, just return
98 if (s == this->m_MeasurementVectorSize)
99 {
100 return;
101 }
102
103 this->m_MeasurementVectorSize = s;
104 this->Modified();
105 }
106 else
107 {
108 // If this is a non-resizable vector type
110 // and the new length is different from the default one, then throw an
111 // exception
112 if (defaultLength != s)
113 {
114 itkExceptionMacro("Attempting to change the measurement vector size of a non-resizable vector type");
115 }
116 }
117 }
118
120 itkGetConstMacro(MeasurementVectorSize, MeasurementVectorSizeType);
121
122protected:
126
127 ~MembershipFunctionBase() override = default;
128
129 void
130 PrintSelf(std::ostream & os, Indent indent) const override
131 {
132 Superclass::PrintSelf(os, indent);
133 os << indent << "Length of measurement vectors: " << m_MeasurementVectorSize << std::endl;
134 }
135
136private:
138
139}; // end of class
140} // namespace itk::Statistics
141
142#endif
Control indentation during Print() invocation.
Definition itkIndent.h:50
virtual void PrintSelf(std::ostream &os, Indent indent) const
Define additional traits for native types such as int or float.
static unsigned int GetLength(const T &)
virtual void Modified() const
Implements transparent reference counting.
double Evaluate(const MeasurementVectorType &x) const override=0
virtual void SetMeasurementVectorSize(MeasurementVectorSizeType s)
void PrintSelf(std::ostream &os, Indent indent) const override