1 #include <cpExtensions/Visualization/PolyLineParametricPathToPolyData.h>
3 #include <vtkCellArray.h>
4 #include <vtkInformation.h>
5 #include <vtkInformationVector.h>
6 #include <vtkSmartPointer.h>
8 // -------------------------------------------------------------------------
9 template< class _TPolyLine >
11 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
13 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
16 return( new Self( ) );
19 // -------------------------------------------------------------------------
20 template< class _TPolyLine >
22 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
24 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
27 return( this->m_PolyLine );
30 // -------------------------------------------------------------------------
31 template< class _TPolyLine >
33 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
34 SetInput( const TPolyLine* pl )
36 if( this->m_PolyLine != pl )
38 this->m_PolyLine = pl;
44 // -------------------------------------------------------------------------
45 template< class _TPolyLine >
46 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
47 PolyLineParametricPathToPolyData( )
48 : vtkPolyDataAlgorithm( ),
51 this->SetNumberOfInputPorts( 0 );
54 // -------------------------------------------------------------------------
55 template< class _TPolyLine >
56 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
57 ~PolyLineParametricPathToPolyData( )
61 // -------------------------------------------------------------------------
62 template< class _TPolyLine >
64 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
66 vtkInformation* information,
67 vtkInformationVector** input,
68 vtkInformationVector* output
71 static const unsigned int dim = _TPolyLine::PathDimension;
73 if( this->m_PolyLine == NULL )
77 vtkInformation* info = output->GetInformationObject( 0 );
78 vtkPolyData* out = vtkPolyData::SafeDownCast(
79 info->Get( vtkDataObject::DATA_OBJECT( ) )
83 out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
84 out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
85 out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
86 out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
87 out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
88 vtkPoints* points = out->GetPoints( );
89 vtkCellArray* lines = out->GetLines( );
92 for( unsigned long i = 0; i < this->m_PolyLine->GetSize( ); ++i )
94 typename _TPolyLine::TPoint pnt = this->m_PolyLine->GetPoint( i );
95 if( dim == 1 ) points->InsertNextPoint( pnt[ 0 ], 0, 0 );
96 else if( dim == 2 ) points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
97 else points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
100 lines->InsertNextCell( 2 );
101 lines->InsertCellPoint( i - 1 );
102 lines->InsertCellPoint( i );
110 // -------------------------------------------------------------------------
111 template< class _TPolyLine >
113 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
115 vtkInformation* information,
116 vtkInformationVector** input,
117 vtkInformationVector* output
123 // -------------------------------------------------------------------------
124 #include <cpExtensions/DataStructures/PolyLineParametricPath.h>
126 template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 1 > >;
127 template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 2 > >;
128 template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 3 > >;
129 template class cpExtensions::Visualization::PolyLineParametricPathToPolyData< cpExtensions::DataStructures::PolyLineParametricPath< 4 > >;