+++ /dev/null
-#include <cpExtensions/Visualization/SkeletonToPolyData.h>
-
-#include <vtkCellArray.h>
-#include <vtkInformation.h>
-#include <vtkInformationVector.h>
-#include <vtkSmartPointer.h>
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-typename cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-Self* cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-const typename
-cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-TSkeleton* cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-GetInput( ) const
-{
- return( this->m_Skeleton );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-SetInput( const TSkeleton* sk )
-{
- if( this->m_Skeleton != sk )
- {
- this->m_Skeleton = sk;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-SkeletonToPolyData( )
- : vtkPolyDataAlgorithm( ),
- m_Skeleton( NULL )
-{
- this->SetNumberOfInputPorts( 0 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-~SkeletonToPolyData( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-int cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- typedef typename _TSkeleton::TPath _TPath;
- static const unsigned int dim = _TPath::PathDimension;
-
- if( this->m_Skeleton == NULL )
- return( 0 );
-
- // Get output
- vtkInformation* info = output->GetInformationObject( 0 );
- vtkPolyData* out = vtkPolyData::SafeDownCast(
- info->Get( vtkDataObject::DATA_OBJECT( ) )
- );
-
- // Prepare data
- out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
- out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
- vtkPoints* points = out->GetPoints( );
- vtkCellArray* lines = out->GetLines( );
-
- // Assign all data
- auto mIt = this->m_Skeleton->BeginEdgesRows( );
- for( ; mIt != this->m_Skeleton->EndEdgesRows( ); ++mIt )
- {
- // TODO: mIt->first; --> this is the row index. <--
- auto rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- // TODO: rIt->first; --> this is the column index.
- auto eIt = rIt->second.begin( );
- for( ; eIt != rIt->second.end( ); ++eIt )
- {
- _TPath* path = *eIt;
- for( unsigned long i = 0; i < path->GetSize( ); ++i )
- {
- auto pnt = path->GetPoint( i );
- if( dim == 1 )
- points->InsertNextPoint( pnt[ 0 ], 0, 0 );
- else if( dim == 2 )
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
- else
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
- if( i > 0 )
- {
- lines->InsertNextCell( 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
-
- } // fi
-
- } // rof
-
- } // rof
-
- } // rof
-
- } // rof
- return( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-int cpExtensions::Visualization::SkeletonToPolyData< _TSkeleton >::
-RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- return( 1 );
-}
-
-// -------------------------------------------------------------------------
-#include <cpExtensions/DataStructures/Skeleton.h>
-
-template class cpExtensions::Visualization::SkeletonToPolyData< cpExtensions::DataStructures::Skeleton< 1 > >;
-template class cpExtensions::Visualization::SkeletonToPolyData< cpExtensions::DataStructures::Skeleton< 2 > >;
-template class cpExtensions::Visualization::SkeletonToPolyData< cpExtensions::DataStructures::Skeleton< 3 > >;
-template class cpExtensions::Visualization::SkeletonToPolyData< cpExtensions::DataStructures::Skeleton< 4 > >;
-
-// eof - $RCSfile$