1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #include <cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.h>
7 // -------------------------------------------------------------------------
8 template< class _TPolyLine, class _TCurve >
9 _TPolyLine* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
12 return( dynamic_cast< _TPolyLine* >( this->Superclass::GetInput( 0 ) ) );
15 // -------------------------------------------------------------------------
16 template< class _TPolyLine, class _TCurve >
17 const _TPolyLine* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
20 return( dynamic_cast< const _TPolyLine* >( this->Superclass::GetInput( 0 ) ) );
23 // -------------------------------------------------------------------------
24 template< class _TPolyLine, class _TCurve >
25 void cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
26 SetInput( _TPolyLine* pl )
28 this->Superclass::SetNthInput( 0, pl );
31 // -------------------------------------------------------------------------
32 template< class _TPolyLine, class _TCurve >
33 _TCurve* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
36 return( dynamic_cast< _TCurve* >( this->Superclass::GetOutput( 0 ) ) );
39 // -------------------------------------------------------------------------
40 template< class _TPolyLine, class _TCurve >
41 const _TCurve* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
44 return( dynamic_cast< const _TCurve* >( this->Superclass::GetOutput( 0 ) ) );
47 // -------------------------------------------------------------------------
48 template< class _TPolyLine, class _TCurve >
49 cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
50 PolyLineParametricPathToSimple3DCurve( )
52 m_NumberOfSamples( 0 )
54 this->SetNumberOfRequiredInputs( 1 );
55 this->SetNumberOfRequiredOutputs( 1 );
56 typename _TCurve::Pointer curve = _TCurve::New( );
57 this->Superclass::SetNthOutput( 0, curve );
60 // -------------------------------------------------------------------------
61 template< class _TPolyLine, class _TCurve >
62 cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
63 ~PolyLineParametricPathToSimple3DCurve( )
67 // -------------------------------------------------------------------------
68 template< class _TPolyLine, class _TCurve >
69 void cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
72 const _TPolyLine* line = this->GetInput( );
73 _TCurve* curve = this->GetOutput( );
74 unsigned long N = this->m_NumberOfSamples;
79 for( unsigned long n = 0; n < N; ++n )
81 double u = double( n ) / double( N - 1 );
82 curve->AddPoint( line->GetSmoothPoint( u ) );
87 // -------------------------------------------------------------------------
88 #include <cpExtensions/DataStructures/PolyLineParametricPath.h>
89 #include <cpExtensions/DataStructures/Simple3DCurve.h>
91 template class cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< cpExtensions::DataStructures::PolyLineParametricPath< 3 >, cpExtensions::DataStructures::Simple3DCurve< float > >;
92 template class cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< cpExtensions::DataStructures::PolyLineParametricPath< 3 >, cpExtensions::DataStructures::Simple3DCurve< double > >;