X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FSkeletonToPolyData.cxx;fp=lib%2FcpExtensions%2FVisualization%2FSkeletonToPolyData.cxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=5aa7d207de3730e7fd6a8a6a5874cbe4a57f012c;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/SkeletonToPolyData.cxx b/lib/cpExtensions/Visualization/SkeletonToPolyData.cxx deleted file mode 100644 index 5aa7d20..0000000 --- a/lib/cpExtensions/Visualization/SkeletonToPolyData.cxx +++ /dev/null @@ -1,147 +0,0 @@ -#include - -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -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 - -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$