1 /*===================================================================
3 The Medical Imaging Interaction Toolkit (MITK)
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 See LICENSE.txt or http://www.mitk.org for details.
15 ===================================================================*/
16 #ifndef _itkSlowPolyLineParametricPath_txx
17 #define _itkSlowPolyLineParametricPath_txx
19 #include "itkSlowPolyLineParametricPath.h"
27 //template<unsigned int VDimension>
28 //typename SlowPolyLineParametricPath<VDimension>::VectorType
29 //SlowPolyLineParametricPath<VDimension>
30 //::EvaluateDerivative(const InputType & input) const
39 template <unsigned int VDimension>
40 SlowPolyLineParametricPath<VDimension>
41 ::SlowPolyLineParametricPath()
43 this->SetDefaultInputStepSize( 0.3 );
47 template<unsigned int VDimension>
48 typename SlowPolyLineParametricPath<VDimension>::OffsetType
49 SlowPolyLineParametricPath<VDimension>
50 ::IncrementInput(InputType & input) const
55 InputType inputStepSize;
56 InputType finalInputValue;
58 IndexType currentImageIndex;
59 IndexType nextImageIndex;
60 IndexType finalImageIndex;
63 inputStepSize = this->GetDefaultInputStepSize();
65 // Are we already at (or past) the end of the input?
66 finalInputValue = this->EndOfInput();
67 currentImageIndex = this->EvaluateToIndex( input );
68 finalImageIndex = this->EvaluateToIndex( finalInputValue );
69 offset = finalImageIndex - currentImageIndex;
70 if( ( offset == this->GetZeroOffset() && input != this->StartOfInput() ) ||
71 ( input >=finalInputValue ) )
73 return this->GetZeroOffset();
78 if( iterationCount++ > 10000 ) {return this->GetZeroOffset(); itkExceptionMacro(<<"Too many iterations");}
80 nextImageIndex = this->EvaluateToIndex( input + inputStepSize );
81 offset = nextImageIndex - currentImageIndex;
84 tooSmall = ( offset == this->GetZeroOffset() );
87 // increase the input step size, but don't go past the end of the input
89 if( (input + inputStepSize) >= finalInputValue ){
90 //inputStepSize = finalInputValue - input;
91 inputStepSize += this->GetDefaultInputStepSize();
96 // Search for an offset dimension that is too big
97 for( unsigned int i=0; i<VDimension && !tooBig; i++ )
99 tooBig = ( offset[i] >= 2 || offset[i] <= -2 );
103 //inputStepSize /= 1.5;
104 inputStepSize -= (this->GetDefaultInputStepSize()/0.5);
108 while( tooSmall || tooBig );
110 input += inputStepSize;
116 * Standard "PrintSelf" method
118 template <unsigned int VDimension>
120 SlowPolyLineParametricPath<VDimension>
121 ::PrintSelf( std::ostream& os, Indent indent) const
123 Superclass::PrintSelf( os, indent );
128 } // end namespaceitk