ITK  5.2.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  * http://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 
25 namespace itk
26 {
27 namespace Statistics
28 {
57 template <typename TVector>
58 class ITK_TEMPLATE_EXPORT MembershipFunctionBase : public FunctionBase<TVector, double>
59 {
60 public:
61  ITK_DISALLOW_COPY_AND_MOVE(MembershipFunctionBase);
62 
68 
70  itkTypeMacro(MembershipFunctionBase, FunctionBase);
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
96 
98  {
99  // then this is a resizable vector type
100  //
101  // if the new size is the same as the previou size, just return
102  if (s == this->m_MeasurementVectorSize)
103  {
104  return;
105  }
106  else
107  {
108  this->m_MeasurementVectorSize = s;
109  this->Modified();
110  }
111  }
112  else
113  {
114  // If this is a non-resizable vector type
117  // and the new length is different from the default one, then throw an
118  // exception
119  if (defaultLength != s)
120  {
121  itkExceptionMacro("Attempting to change the measurement vector size of a non-resizable vector type");
122  }
123  }
124  }
125 
127  itkGetConstMacro(MeasurementVectorSize, MeasurementVectorSizeType);
128 
129 protected:
131  {
133  }
134 
135  ~MembershipFunctionBase() override = default;
136 
137  void
138  PrintSelf(std::ostream & os, Indent indent) const override
139  {
140  Superclass::PrintSelf(os, indent);
141  os << indent << "Length of measurement vectors: " << m_MeasurementVectorSize << std::endl;
142  }
143 
144 private:
146 
147 }; // end of class
148 } // end of namespace Statistics
149 } // end namespace itk
150 
151 #endif
itk::Statistics::MembershipFunctionBase::MembershipFunctionBase
MembershipFunctionBase()
Definition: itkMembershipFunctionBase.h:130
itk::Statistics::MembershipFunctionBase
MembershipFunctionBase defines common interfaces for membership functions.
Definition: itkMembershipFunctionBase.h:58
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Statistics::MembershipFunctionBase::m_MeasurementVectorSize
MeasurementVectorSizeType m_MeasurementVectorSize
Definition: itkMembershipFunctionBase.h:145
itkFunctionBase.h
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkNumericTraitsCovariantVectorPixel.h
itk::Statistics::MembershipFunctionBase< TMeasurementVector >::MeasurementVectorType
TMeasurementVector MeasurementVectorType
Definition: itkMembershipFunctionBase.h:73
itk::Statistics::MembershipFunctionBase::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkMembershipFunctionBase.h:138
itk::FunctionBase
Base class for all ITK function objects.
Definition: itkFunctionBase.h:44
itkMeasurementVectorTraits.h
itk::Statistics::MeasurementVectorTraits::IsResizable
static bool IsResizable(const TVectorType &)
Definition: itkMeasurementVectorTraits.h:62
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::NumericTraits::GetLength
static unsigned int GetLength()
Definition: itkNumericTraits.h:208
itk::Statistics::MembershipFunctionBase< TMeasurementVector >::MeasurementVectorSizeType
unsigned int MeasurementVectorSizeType
Definition: itkMembershipFunctionBase.h:76
itk::Statistics::MembershipFunctionBase::SetMeasurementVectorSize
virtual void SetMeasurementVectorSize(MeasurementVectorSizeType s)
Definition: itkMembershipFunctionBase.h:92