| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkPolyLineParametricPath.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:45 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
|
| 18 |
|
|
| 19 |
DEF |
#ifndef _itkPolyLineParametricPath_txx |
| 20 |
DEF |
#define _itkPolyLineParametricPath_txx |
| 21 |
|
|
| 22 |
|
#include "itkPolyLineParametricPath.h" |
| 23 |
|
#include <math.h> |
| 24 |
|
|
| 25 |
|
|
| 26 |
EML |
|
| 27 |
|
namespace itk |
| 28 |
|
{ |
| 29 |
|
|
| 30 |
|
template<unsigned int VDimension> |
| 31 |
|
typename PolyLineParametricPath<VDimension>::OutputType |
| 32 |
|
PolyLineParametricPath<VDimension> |
| 33 |
|
::Evaluate( const InputType & input ) const |
| 34 |
|
{ |
| 35 |
|
OutputType output; |
| 36 |
|
PointType outputPoint; |
| 37 |
|
VertexType vertex0; |
| 38 |
|
VertexType vertex1; |
| 39 |
|
double fractionOfLineSegment; |
| 40 |
|
|
| 41 |
|
// Handle the endpoint carefully, since there is no following vertex |
| 42 |
|
if( input >= InputType( m_VertexList->Size() - 1 ) ) |
| 43 |
|
{ |
| 44 |
|
return m_VertexList->ElementAt(m_VertexList->Size() - 1); // the last vertex |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
vertex0 = m_VertexList->ElementAt( int(input) ); |
| 48 |
|
vertex1 = m_VertexList->ElementAt( int(input+1.0) ); |
| 49 |
|
|
| 50 |
|
fractionOfLineSegment = input - int(input); |
| 51 |
|
|
| 52 |
|
outputPoint = vertex0 + (vertex1-vertex0)*fractionOfLineSegment; |
| 53 |
|
|
| 54 |
|
// For some stupid reason, there is no easy way to cast from a point to a |
| 55 |
|
// continuous index. |
| 56 |
|
for( unsigned int i=0; i<VDimension; i++ ) { output[i] = outputPoint[i]; } |
| 57 |
|
|
| 58 |
|
return output; |
| 59 |
|
} |
| 60 |
|
|
| 61 |
|
|
| 62 |
EML |
|
| 63 |
|
//template<unsigned int VDimension> |
| 64 |
|
//typename PolyLineParametricPath<VDimension>::VectorType |
| 65 |
|
//PolyLineParametricPath<VDimension> |
| 66 |
|
//::EvaluateDerivative(const InputType & input) const |
| 67 |
|
//{ |
| 68 |
IND |
//} |
| 69 |
|
|
| 70 |
|
|
| 71 |
EML |
|
| 72 |
|
/** |
| 73 |
|
* Constructor |
| 74 |
|
*/ |
| 75 |
|
template <unsigned int VDimension> |
| 76 |
|
PolyLineParametricPath<VDimension> |
| 77 |
|
::PolyLineParametricPath() |
| 78 |
|
{ |
| 79 |
|
this->SetDefaultInputStepSize( 0.3 ); |
| 80 |
|
m_VertexList = VertexListType::New(); |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
|
| 84 |
EML |
|
| 85 |
|
/** |
| 86 |
|
* Standard "PrintSelf" method |
| 87 |
|
*/ |
| 88 |
|
template <unsigned int VDimension> |
| 89 |
|
void |
| 90 |
|
PolyLineParametricPath<VDimension> |
| 91 |
|
::PrintSelf( std::ostream& os, Indent indent) const |
| 92 |
|
{ |
| 93 |
|
Superclass::PrintSelf( os, indent ); |
| 94 |
|
os << indent << "Verticies: " << m_VertexList << std::endl; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
EML |
|
| 99 |
|
} // end namespaceitk |
| 100 |
|
|
| 101 |
|
#endif |
| 102 |
|
|