-// -------------------------------------------------------------------------
-template< unsigned int D >
-void cpPlugins::Interface::PolyLineParametricPath::
-_VTK( itk::DataObject* ref_image )
-{
- typedef itk::PolyLineParametricPath< D > _TPath;
- typedef typename _TPath::VertexListType _TVertices;
- typedef typename _TPath::ContinuousIndexType _TIndex;
- typedef itk::ImageBase< D > _TImage;
- typedef typename _TImage::PointType _TPoint;
-
- _TPath* path =
- dynamic_cast< _TPath* >( this->m_RealDataObject.GetPointer( ) );
- if( path == NULL )
- return;
- const _TVertices* vertices = path->GetVertexList( );
- if( vertices == NULL )
- return;
- const _TImage* image = dynamic_cast< const _TImage* >( ref_image );
-
- vtkSmartPointer< vtkPoints > points =
- vtkSmartPointer< vtkPoints >::New( );
- vtkSmartPointer< vtkCellArray > lines =
- vtkSmartPointer< vtkCellArray >::New( );
- double x, y, z;
- for( unsigned int i = 0; i < vertices->Size( ); ++i )
- {
- _TIndex idx = vertices->GetElement( i );
- if( image != NULL )
- {
- _TPoint pnt;
- image->TransformContinuousIndexToPhysicalPoint( idx, pnt );
- x = double( pnt[ 0 ] );
- y = double( pnt[ 1 ] );
- z = ( D >= 3 )? double( pnt[ 2 ] ): double( 0 );
- }
- else
- {
- x = double( idx[ 0 ] );
- y = double( idx[ 1 ] );
- z = ( D >= 3 )? double( idx[ 2 ] ): double( 0 );
-
- } // fi
- points->InsertNextPoint( x, y, z );
- if( i > 0 )
- {
- lines->InsertNextCell( 2 );
- lines->InsertCellPoint( i - 1 );
- lines->InsertCellPoint( i );
-
- } // fi
-
- } // rof
- this->m_PolyData->SetPoints( points );
- this->m_PolyData->SetLines( lines );
-}
-