1 #ifndef __itkSlowPolyLineParametricPath_hxx 2 #define __itkSlowPolyLineParametricPath_hxx 24 template <
unsigned int VDimension>
28 this->SetDefaultInputStepSize( 0.3 );
29 m_UseCentralDifference=
true;
32 template<
unsigned int VDimension >
33 typename PolyLineParametricPath< VDimension >::OutputType
40 if ( input > endPoint || itk::Math::FloatAlmostEqual( input, endPoint ) )
42 return vertexList->ElementAt(vertexList->Size() - 1);
44 if (input<0 || itk::Math::FloatAlmostEqual( input, 0.0 ))
46 return vertexList->ElementAt(0);
49 const VertexType vertex0 = vertexList->ElementAt(
int(input)<0.0 ? 0 :
int(input) );
50 const VertexType vertex1 = vertexList->ElementAt(
int(input)+1>=endPoint ? endPoint-1 :
int(input)+1);
52 const double fractionOfLineSegment = input - int(input);
54 const PointType outputPoint = vertex0 + ( vertex1 - vertex0 ) * fractionOfLineSegment;
59 for (
unsigned int i = 0; i < VDimension; i++ )
61 output[i] = outputPoint[i];
67 template<
unsigned int VDimension>
68 typename PolyLineParametricPath<VDimension>::VectorType
72 if (m_UseCentralDifference)
75 const InputType nextTimepoint = std::floor(input + 1.0);
78 const InputType previousTimepoint = std::floor(input - 1.0);
86 for (
unsigned int i = 0; i < VDimension; ++i)
88 partialDerivatives[i] = (nextIndex[i] - prevIndex[i]);
91 if (isDerivativeNormalizedByDistance)
93 double dist = nextIndex.EuclideanDistanceTo(prevIndex);
95 partialDerivatives /= dist;
98 return partialDerivatives;
101 return Superclass::EvaluateDerivative(input);
104 template<
unsigned int VDimension>
120 inputStepSize = this->GetDefaultInputStepSize();
123 finalInputValue = this->EndOfInput();
124 currentImageIndex = this->EvaluateToIndex( input );
125 finalImageIndex = this->EvaluateToIndex( finalInputValue );
126 offset = finalImageIndex - currentImageIndex;
127 if( ( offset == this->GetZeroOffset() && input != this->StartOfInput() ) ||
128 ( input >=finalInputValue ) )
130 return this->GetZeroOffset();
135 if( iterationCount++ > 10000 ) {itkExceptionMacro(<<
"Too many iterations");}
137 nextImageIndex = this->EvaluateToIndex( input + inputStepSize );
138 offset = nextImageIndex - currentImageIndex;
141 tooSmall = ( offset == this->GetZeroOffset() );
146 if( (input + inputStepSize) >= finalInputValue ){
148 inputStepSize += this->GetDefaultInputStepSize();
154 for(
unsigned int i=0; i<VDimension && !tooBig; i++ )
156 tooBig = ( offset[i] >= 2 || offset[i] <= -2 );
161 inputStepSize -= (this->GetDefaultInputStepSize()/0.5);
165 while( tooSmall || tooBig );
167 input += inputStepSize;
175 template <
unsigned int VDimension>
180 Superclass::PrintSelf( os, indent );
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
virtual OffsetType IncrementInput(InputType &input) const ITK_OVERRIDE
SlowPolyLineParametricPath()
Superclass::OutputType OutputType
Superclass::VectorType VectorType
Superclass::PointType PointType
Superclass::InputType InputType
virtual OutputType Evaluate(const InputType &input) const ITK_OVERRIDE
Superclass::VertexType VertexType
Superclass::IndexType IndexType
Superclass::ContinuousIndexType ContinuousIndexType
Superclass::VertexListType VertexListType
VectorType EvaluateDerivative(const InputType &input, bool isDerivativeNormalizedByDistance=false) const
Superclass::OffsetType OffsetType