freVnlSetupOptimizationOptimizer.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freVnlSetupOptimizationOptimizer.cxx,v $
00007   Language:  C++
00008 
00009 
00010   Copyright (c) Insight Software Consortium. All rights reserved.
00011   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00012 
00013      This software is distributed WITHOUT ANY WARRANTY; without even 
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00015      PURPOSE.  See the above copyright notices for more information.
00016 
00017 =========================================================================*/
00018 
00019 #include "freVnlSetupOptimizationOptimizer.h"
00020 #include "itkCommand.h"
00021 #include "itkEventObject.h"
00022 
00023 namespace FREE
00024 {
00025 
00029 VnlSetupOptimizationOptimizer
00030 ::VnlSetupOptimizationOptimizer()
00031 {
00032   m_CostFunctionAdaptor = 0;
00033   m_Maximize = false;
00034   m_Command = CommandType::New();
00035   m_Command->SetCallbackFunction( this, &VnlSetupOptimizationOptimizer::IterationReport );
00036   m_CachedValue = 0;
00037   m_CachedCurrentPosition.Fill(0);
00038   m_CachedDerivative.Fill(0);
00039 }
00040 
00041 VnlSetupOptimizationOptimizer
00042 ::~VnlSetupOptimizationOptimizer()
00043 {
00044         if( m_CostFunctionAdaptor )
00045   {
00046     delete m_CostFunctionAdaptor;
00047     m_CostFunctionAdaptor = 0;
00048   }
00049 }
00050 
00051 void
00052 VnlSetupOptimizationOptimizer
00053 ::PrintSelf(std::ostream& os, itk::Indent indent) const
00054 {
00055   Superclass::PrintSelf( os, indent );
00056   os << indent << "Maximize flag: "
00057      << (m_Maximize ? "On" : "Off") << std::endl;
00058   os << indent << "Cached Value: " << m_CachedValue << std::endl;
00059   os << indent << "Cached Derivative: " << m_CachedDerivative << std::endl;
00060   os << indent << "Cached current positiion: "
00061      << m_CachedCurrentPosition << std::endl;
00062   os << "Command observer " << m_Command.GetPointer() << std::endl;
00063   os << "Cost Function adaptor" << m_CostFunctionAdaptor << std::endl;
00064 }
00065 
00066 void 
00067 VnlSetupOptimizationOptimizer
00068 ::SetCostFunctionAdaptor( CostFunctionAdaptorType * adaptor )
00069 {
00070 
00071   if( m_CostFunctionAdaptor == adaptor ) 
00072     {
00073     return;
00074     }
00075 
00076   if( m_CostFunctionAdaptor )
00077     {
00078     delete m_CostFunctionAdaptor;
00079     }
00080 
00081   m_CostFunctionAdaptor = adaptor; 
00082 
00083         m_CostFunctionAdaptor->AddObserver( itk::IterationEvent(), m_Command );
00084 }
00085 
00086 const VnlSetupOptimizationOptimizer::CostFunctionAdaptorType * 
00087 VnlSetupOptimizationOptimizer
00088 ::GetCostFunctionAdaptor( void ) const
00089 {
00090   return m_CostFunctionAdaptor;
00091 }
00092 
00093 
00094 VnlSetupOptimizationOptimizer::CostFunctionAdaptorType * 
00095 VnlSetupOptimizationOptimizer
00096 ::GetCostFunctionAdaptor( void )
00097 {
00098   return m_CostFunctionAdaptor;
00099 }
00100 
00101 
00104 VnlSetupOptimizationOptimizer::CostFunctionAdaptorType * 
00105 VnlSetupOptimizationOptimizer
00106 ::GetNonConstCostFunctionAdaptor( void ) const
00107 {
00108   return m_CostFunctionAdaptor;
00109 }
00110 
00117 void
00118 VnlSetupOptimizationOptimizer
00119 ::IterationReport( const itk::EventObject & event ) 
00120 {
00121   const CostFunctionAdaptorType * adaptor = this->GetCostFunctionAdaptor();
00122   m_CachedValue = adaptor->GetCachedValue();
00123   m_CachedDerivative = adaptor->GetCachedDerivative();
00124   m_CachedCurrentPosition = adaptor->GetCachedCurrentParameters();
00125   m_CurrentValue = adaptor->GetCachedValue();
00126   m_CurrentDecomposedValue = adaptor->GetCachedDecomposedValue();
00127   SetCurrentPosition(adaptor->GetCachedCurrentParameters());
00128   this->InvokeEvent( event );
00129 }
00130 
00131 } // end namespace FREE
00132 
00133 

Generated at Sat Oct 13 18:02:13 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000