Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

Review/Statistics/itkMembershipFunctionBase.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkMembershipFunctionBase.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-02 05:43:58 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkMembershipFunctionBase_h
00018 #define __itkMembershipFunctionBase_h
00019 
00020 #include "itkFunctionBase.h"
00021 #include "itkMeasurementVectorTraits.h"
00022 
00023 namespace itk  { 
00024 namespace Statistics  {
00025 
00037 template< class TVector >
00038 class ITK_EXPORT MembershipFunctionBase :
00039     public FunctionBase< TVector, double >
00040 {
00041 public:
00043   typedef MembershipFunctionBase                Self;
00044   typedef FunctionBase< TVector, double >       Superclass;
00045   typedef SmartPointer< Self >                  Pointer;
00046   typedef SmartPointer<const Self>              ConstPointer;
00047 
00049   itkTypeMacro(MembershipFunctionBase, FunctionBase);
00050 
00052   typedef TVector                       MeasurementVectorType;
00053 
00055   typedef unsigned int                  MeasurementVectorSizeType;
00056 
00058   virtual double Evaluate(const MeasurementVectorType &x) const = 0;
00059 
00061   virtual void SetMeasurementVectorSize( MeasurementVectorSizeType s )
00062     {
00063     // Test whether the vector type is resizable or not
00064     MeasurementVectorType m;
00065     if( MeasurementVectorTraits::IsResizable( m ) )
00066       {
00067       // then this is a resizable vector type
00068       //
00069       // if the new size is the same as the previou size, just return
00070       if( s == this->m_MeasurementVectorSize )
00071         {
00072         return;
00073         }
00074       else
00075         {
00076         this->m_MeasurementVectorSize = s;
00077         this->Modified();
00078         }
00079       }
00080     else
00081       {
00082       // If this is a non-resizable vector type
00083       MeasurementVectorType m3;
00084       MeasurementVectorSizeType defaultLength = MeasurementVectorTraits::GetLength( m3 );
00085       // and the new length is different from the default one, then throw an exception
00086       if( defaultLength != s )
00087         {
00088         itkExceptionMacro("Attempting to change the measurement \
00089                            vector size of a non-resizable vector type");
00090         }
00091       }
00092     }
00094 
00096   itkGetConstMacro( MeasurementVectorSize, MeasurementVectorSizeType ); 
00097 
00098 protected:
00099   MembershipFunctionBase()  
00100     {
00101     m_MeasurementVectorSize = MeasurementVectorTraits::GetLength( 
00102                                         MeasurementVectorType() );
00103     }
00104 
00105 
00106   virtual ~MembershipFunctionBase(void) {}
00107 
00108   void PrintSelf(std::ostream& os, Indent indent) const
00109     { 
00110     Superclass::PrintSelf(os,indent); 
00111     os << indent << "Length of measurement vectors: " 
00112                 << m_MeasurementVectorSize << std::endl;
00113     }
00114   MeasurementVectorSizeType     m_MeasurementVectorSize;
00115 
00116 }; // end of class
00117 
00118 } // end of namespace Statistics
00119 } // end namespace itk
00120 
00121 #endif
00122 

Generated at Fri Apr 16 19:01:30 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000