1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__VTK__Image__PolyLineParametricPathToPolyDataFilter__hxx__
6 #define __fpa__VTK__Image__PolyLineParametricPathToPolyDataFilter__hxx__
8 #include <vtkCellArray.h>
9 #include <vtkInformation.h>
10 #include <vtkInformationVector.h>
11 #include <vtkPointData.h>
12 #include <vtkUnsignedIntArray.h>
13 #include <vtkSmartPointer.h>
15 // -------------------------------------------------------------------------
16 template< class _TPath >
17 typename fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
18 Self* fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
21 return( new Self( ) );
24 // -------------------------------------------------------------------------
25 template< class _TPath >
27 fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
28 TPath* fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
31 return( this->m_PolyLineParametricPath );
34 // -------------------------------------------------------------------------
35 template< class _TPath >
36 void fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
37 SetInput( const TPath* path )
39 if( this->m_PolyLineParametricPath != path )
41 this->m_PolyLineParametricPath = path;
47 // -------------------------------------------------------------------------
48 template< class _TPath >
49 fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
50 PolyLineParametricPathToPolyDataFilter( )
51 : vtkPolyDataAlgorithm( ),
52 m_PolyLineParametricPath( NULL )
54 this->SetNumberOfInputPorts( 0 );
57 // -------------------------------------------------------------------------
58 template< class _TPath >
59 fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
60 ~PolyLineParametricPathToPolyDataFilter( )
64 // -------------------------------------------------------------------------
65 template< class _TPath >
66 int fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
68 vtkInformation* information,
69 vtkInformationVector** input,
70 vtkInformationVector* output
73 static const unsigned int dim = TPath::PathDimension;
74 if( this->m_PolyLineParametricPath == NULL )
78 vtkInformation* info = output->GetInformationObject( 0 );
79 vtkPolyData* out = vtkPolyData::SafeDownCast(
80 info->Get( vtkDataObject::DATA_OBJECT( ) )
84 out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
85 out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
86 out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
87 out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
88 out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
89 vtkSmartPointer< vtkUnsignedIntArray > darray =
90 vtkSmartPointer< vtkUnsignedIntArray >::New( );
91 darray->SetNumberOfComponents( 1 );
92 out->GetPointData( )->SetScalars( darray );
93 vtkPoints* points = out->GetPoints( );
94 vtkCellArray* lines = out->GetLines( );
97 const TPath* path = this->GetInput( );
98 for( unsigned long i = 0; i < path->GetSize( ); ++i )
100 auto pnt = path->GetPoint( i );
102 points->InsertNextPoint( pnt[ 0 ], 0, 0 );
104 points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
106 points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
107 darray->InsertNextTuple1( double( i ) );
110 lines->InsertNextCell( 2 );
111 lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
112 lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
120 // -------------------------------------------------------------------------
121 template< class _TPath >
122 int fpa::VTK::Image::PolyLineParametricPathToPolyDataFilter< _TPath >::
124 vtkInformation* information,
125 vtkInformationVector** input,
126 vtkInformationVector* output
132 #endif // __fpa__VTK__Image__PolyLineParametricPathToPolyDataFilterFilter__hxx__