#ifndef __itkPhaseCorrelationOptimizer_txx #define __itkPhaseCorrelationOptimizer_txx #include "itkPhaseCorrelationOptimizer.h" namespace itk { /* * Constructor */ template < typename TImage > PhaseCorrelationOptimizer ::PhaseCorrelationOptimizer() { this->SetNumberOfRequiredInputs( 1 ); this->SetNumberOfRequiredOutputs( 1 ); // for the parameters m_Offset.Fill( 0 ); OffsetOutputPointer offsetDecorator = static_cast< OffsetOutputType * >( this->MakeOutput(0).GetPointer() ); this->ProcessObject::SetNthOutput( 0, offsetDecorator.GetPointer() ); itkDebugMacro( "output is " << this->GetOutput()->Get() ); } /** * */ template < typename TImage > void PhaseCorrelationOptimizer ::PrintSelf(std::ostream& os, Indent indent) const { Superclass::PrintSelf(os,indent); os << indent << "Offset: " << m_Offset << std::endl; } /** * */ template < typename TImage > void PhaseCorrelationOptimizer ::GenerateData() { if (!m_Updating) { this->Update(); } else { OffsetType empty; empty.Fill( 0 ); try { this->ComputeOffset(); } catch( ExceptionObject& err ) { itkDebugMacro( "exception called while computing offset - passing" ); m_Offset = empty; // pass exception to caller throw err; } } // write the result to the output OffsetOutputType * output = static_cast< OffsetOutputType * >( this->ProcessObject::GetOutput(0) ); output->Set(m_Offset); } template < typename TImage > void PhaseCorrelationOptimizer ::SetInput( const ImageType * image ) { itkDebugMacro("setting input image to " << image ); if ( this->GetInput(0) != image ) { this->ProcessObject::SetNthInput(0, const_cast< ImageType * >( image ) ); this->Modified(); } } /* * Get Output */ template < typename TImage > const typename PhaseCorrelationOptimizer::OffsetOutputType * PhaseCorrelationOptimizer ::GetOutput() const { return static_cast< const OffsetOutputType * >( this->ProcessObject::GetOutput(0) ); } template < typename TImage > DataObject::Pointer PhaseCorrelationOptimizer ::MakeOutput(unsigned int output) { switch (output) { case 0: return static_cast(OffsetOutputType::New().GetPointer()); break; default: itkExceptionMacro("MakeOutput request for an output number larger than the expected number of outputs"); return 0; } } } //end namespace itk #endif