1 #ifndef __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__HXX__
2 #define __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__HXX__
4 #include <vtkInformation.h>
5 #include <vtkInformationVector.h>
7 // -------------------------------------------------------------------------
8 template< class _TPolyLine >
10 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
12 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
15 return( new Self( ) );
18 // -------------------------------------------------------------------------
19 template< class _TPolyLine >
21 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
23 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
26 return( this->m_PolyLine );
29 // -------------------------------------------------------------------------
30 template< class _TPolyLine >
32 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
34 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
35 GetReferenceImage( ) const
37 return( this->m_ReferenceImage );
40 // -------------------------------------------------------------------------
41 template< class _TPolyLine >
43 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
44 SetInput( const TPolyLine* pl )
46 if( this->m_PolyLine != pl )
48 this->m_PolyLine = pl;
54 // -------------------------------------------------------------------------
55 template< class _TPolyLine >
57 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
58 SetReferenceImage( const TImage* i )
60 if( this->m_ReferenceImage != i )
62 this->m_ReferenceImage = i;
68 // -------------------------------------------------------------------------
69 template< class _TPolyLine >
70 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
71 PolyLineParametricPathToPolyData( )
72 : vtkPolyDataAlgorithm( ),
74 m_ReferenceImage( NULL )
76 this->SetNumberOfInputPorts( 0 );
79 // -------------------------------------------------------------------------
80 template< class _TPolyLine >
81 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
82 ~PolyLineParametricPathToPolyData( )
86 // -------------------------------------------------------------------------
87 template< class _TPolyLine >
89 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
91 vtkInformation* information,
92 vtkInformationVector** input,
93 vtkInformationVector* output
96 static const unsigned int dim = _TPolyLine::PathDimension;
98 if( this->m_PolyLine == NULL )
102 vtkInformation* info = output->GetInformationObject( 0 );
103 vtkPolyData* out = vtkPolyData::SafeDownCast(
104 info->Get( vtkDataObject::DATA_OBJECT( ) )
108 auto lst = this->m_PolyLine->GetVertexList( );
111 vtkPoints* points = out->GetPoints( );
114 points = vtkPoints::New( );
115 out->SetPoints( points );
119 points->SetNumberOfPoints( lst->Size( ) );
122 vtkSmartPointer< vtkCellArray > verts =
123 vtkSmartPointer< vtkCellArray >::New( );
124 vtkSmartPointer< vtkCellArray > lines =
125 vtkSmartPointer< vtkCellArray >::New( );
127 for( unsigned int i = 0; i < lst->Size( ); ++i )
129 auto idx = lst->GetElement( i );
130 if( this->m_ReferenceImage != NULL )
132 typename TImage::PointType pnt;
133 this->m_ReferenceImage->TransformContinuousIndexToPhysicalPoint( idx, pnt );
135 points->SetPoint( i, pnt[ 0 ], 0, 0 );
137 points->SetPoint( i, pnt[ 0 ], pnt[ 1 ], 0 );
139 points->SetPoint( i, pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
144 points->SetPoint( i, idx[ 0 ], 0, 0 );
146 points->SetPoint( i, idx[ 0 ], idx[ 1 ], 0 );
148 points->SetPoint( i, idx[ 0 ], idx[ 1 ], idx[ 2 ] );
151 verts->InsertNextCell( 1 );
152 verts->InsertCellPoint( i );
155 lines->InsertNextCell( 2 );
156 lines->InsertCellPoint( i - 1 );
157 lines->InsertCellPoint( i );
162 out->SetPoints( points );
163 out->SetVerts( verts );
164 out->SetLines( lines );
168 // -------------------------------------------------------------------------
169 template< class _TPolyLine >
171 cpExtensions::Visualization::PolyLineParametricPathToPolyData< _TPolyLine >::
173 vtkInformation* information,
174 vtkInformationVector** input,
175 vtkInformationVector* output
178 vtkInformation* info = output->GetInformationObject( 0 );
181 vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES( ), -1
185 if( this->m_PolyLine != NULL && this->m_ReferenceImage != NULL )
188 typename C::TScalar len = this->m_RGC->GetTotalLength( );
189 typename C::TScalar s0 = this->m_RGC->Gets0( );
190 typename C::TPoint p0 = this->m_RGC->Axis( s0 );
191 typename C::TPoint p1 = this->m_RGC->Axis( s0 + len );
194 vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX( ),
195 double( p0[ 0 ] ), double( p1[ 0 ] ),
196 double( p0[ 1 ] ), double( p1[ 1 ] ),
197 double( p0[ 2 ] ), double( p1[ 2 ] )
205 #endif // __CPEXTENSIONS__VISUALIZATION__POLYLINEPARAMETRICPATHTOPOLYDATA__HXX__