]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.cxx
...
[cpPlugins.git] / lib / cpExtensions / Algorithms / PolyLineParametricPathToSimple3DCurve.cxx
1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
4
5 #include <cpExtensions/Algorithms/PolyLineParametricPathToSimple3DCurve.h>
6
7 // -------------------------------------------------------------------------
8 template< class _TPolyLine, class _TCurve >
9 _TPolyLine* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
10 GetInput( )
11 {
12   return( dynamic_cast< _TPolyLine* >( this->Superclass::GetInput( 0 ) ) );
13 }
14
15 // -------------------------------------------------------------------------
16 template< class _TPolyLine, class _TCurve >
17 const _TPolyLine* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
18 GetInput( ) const
19 {
20   return( dynamic_cast< const _TPolyLine* >( this->Superclass::GetInput( 0 ) ) );
21 }
22
23 // -------------------------------------------------------------------------
24 template< class _TPolyLine, class _TCurve >
25 void cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
26 SetInput( _TPolyLine* pl )
27 {
28   this->Superclass::SetNthInput( 0, pl );
29 }
30
31 // -------------------------------------------------------------------------
32 template< class _TPolyLine, class _TCurve >
33 _TCurve* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
34 GetOutput( )
35 {
36   return( dynamic_cast< _TCurve* >( this->Superclass::GetOutput( 0 ) ) );
37 }
38
39 // -------------------------------------------------------------------------
40 template< class _TPolyLine, class _TCurve >
41 const _TCurve* cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
42 GetOutput( ) const
43 {
44   return( dynamic_cast< const _TCurve* >( this->Superclass::GetOutput( 0 ) ) );
45 }
46
47 // -------------------------------------------------------------------------
48 template< class _TPolyLine, class _TCurve >
49 cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
50 PolyLineParametricPathToSimple3DCurve( )
51   : Superclass( ),
52     m_NumberOfSamples( 0 )
53 {
54   this->SetNumberOfRequiredInputs( 1 );
55   this->SetNumberOfRequiredOutputs( 1 );
56   typename _TCurve::Pointer curve = _TCurve::New( );
57   this->Superclass::SetNthOutput( 0, curve );
58 }
59
60 // -------------------------------------------------------------------------
61 template< class _TPolyLine, class _TCurve >
62 cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
63 ~PolyLineParametricPathToSimple3DCurve( )
64 {
65 }
66
67 // -------------------------------------------------------------------------
68 template< class _TPolyLine, class _TCurve >
69 void cpExtensions::Algorithms::PolyLineParametricPathToSimple3DCurve< _TPolyLine, _TCurve >::
70 GenerateData( )
71 {
72   const _TPolyLine* line = this->GetInput( );
73   _TCurve* curve = this->GetOutput( );
74   unsigned long N = this->m_NumberOfSamples;
75   if( N == 0 )
76     N = line->GetSize( );
77   curve->Clear( );
78
79   for( unsigned long n = 0; n < N; ++n )
80   {
81     double u = double( n ) / double( N - 1 );
82     curve->AddPoint( line->GetSmoothPoint( u ) );
83
84   } // rof
85 }
86
87 // -------------------------------------------------------------------------
88 #include <cpExtensions/DataStructures/PolyLineParametricPath.h>
89 #include <cpExtensions/DataStructures/Simple3DCurve.h>
90
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 > >; 
93
94 // eof - $RCSfile$