ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkMembershipFunctionBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 {
56 template< typename TVector >
58  public FunctionBase< TVector, double >
59 {
60 public:
66 
69 
71  typedef TVector MeasurementVectorType;
72 
74  typedef unsigned int MeasurementVectorSizeType;
75 
79  virtual double Evaluate(const MeasurementVectorType & x) const ITK_OVERRIDE = 0;
80 
89  {
90  // Test whether the vector type is resizable or not
92 
94  {
95  // then this is a resizable vector type
96  //
97  // if the new size is the same as the previou size, just return
98  if ( s == this->m_MeasurementVectorSize )
99  {
100  return;
101  }
102  else
103  {
104  this->m_MeasurementVectorSize = s;
105  this->Modified();
106  }
107  }
108  else
109  {
110  // If this is a non-resizable vector type
112  MeasurementVectorSizeType defaultLength =
114  // and the new length is different from the default one, then throw an
115  // exception
116  if ( defaultLength != s )
117  {
118  itkExceptionMacro(
119  "Attempting to change the measurement vector size of a non-resizable vector type" );
120  }
121  }
122  }
123 
125  itkGetConstMacro(MeasurementVectorSize, MeasurementVectorSizeType);
126 
127 protected:
129  {
132  }
133 
134  virtual ~MembershipFunctionBase(void) {}
135 
136  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
137  {
138  Superclass::PrintSelf(os, indent);
139  os << indent << "Length of measurement vectors: "
140  << m_MeasurementVectorSize << std::endl;
141  }
142 
143 private:
144  MembershipFunctionBase(const Self &) ITK_DELETE_FUNCTION;
145  void operator=(const Self &) ITK_DELETE_FUNCTION;
146 
148 
149 }; // end of class
150 } // end of namespace Statistics
151 } // end namespace itk
152 
153 #endif
void PrintSelf(std::ostream &os, Indent indent) const override
FunctionBase< TVector, double > Superclass
static bool IsResizable(const TVectorType &)
static unsigned int GetLength()
Base class for all ITK function objects.
MembershipFunctionBase defines common interfaces for membership functions.
virtual double Evaluate(const MeasurementVectorType &x) const override=0
virtual void Modified() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void PrintSelf(std::ostream &os, Indent indent) const override
virtual void SetMeasurementVectorSize(MeasurementVectorSizeType s)