--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __ivq__VTK__ImagePathToPolyDataFilter__h__
+#define __ivq__VTK__ImagePathToPolyDataFilter__h__
+
+#include <vtkPolyDataAlgorithm.h>
+
+namespace ivq
+{
+ namespace VTK
+ {
+ /**
+ */
+ template< class _TPath >
+ class ImagePathToPolyDataFilter
+ : public vtkPolyDataAlgorithm
+ {
+ public:
+ typedef ImagePathToPolyDataFilter Self;
+ typedef _TPath TPath;
+
+ public:
+ vtkTypeMacro( ImagePathToPolyDataFilter, vtkPolyDataAlgorithm );
+
+ public:
+ static Self* New( );
+
+ const TPath* GetInput( ) const;
+ void SetInput( const TPath* path );
+
+ protected:
+ ImagePathToPolyDataFilter( );
+ virtual ~ImagePathToPolyDataFilter( );
+
+ int RequestData(
+ vtkInformation* information,
+ vtkInformationVector** input,
+ vtkInformationVector* output
+ );
+ int RequestInformation(
+ vtkInformation* information,
+ vtkInformationVector** input,
+ vtkInformationVector* output
+ );
+
+ private:
+ // Purposely not implemented
+ ImagePathToPolyDataFilter( const Self& );
+ void operator=( const Self& );
+
+ protected:
+ const TPath* m_Path;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <ivq/VTK/ImagePathToPolyDataFilter.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+#endif // __ivq__VTK__ImagePathToPolyDataFilter__h__
+
+// eof - $RCSfile$
--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __ivq__VTK__ImagePathToPolyDataFilter__hxx__
+#define __ivq__VTK__ImagePathToPolyDataFilter__hxx__
+
+#include <vtkCellArray.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkPointData.h>
+#include <vtkUnsignedIntArray.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+template< class _TPath >
+typename ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+Self* ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+New( )
+{
+ return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPath >
+const typename
+ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+TPath* ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+GetInput( ) const
+{
+ return( this->m_Path );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPath >
+void ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+SetInput( const TPath* path )
+{
+ if( this->m_Path != path )
+ {
+ this->m_Path = path;
+ this->Modified( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TPath >
+ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+ImagePathToPolyDataFilter( )
+ : vtkPolyDataAlgorithm( ),
+ m_Path( NULL )
+{
+ this->SetNumberOfInputPorts( 0 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPath >
+ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+~ImagePathToPolyDataFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TPath >
+int ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+RequestData(
+ vtkInformation* information,
+ vtkInformationVector** input,
+ vtkInformationVector* output
+ )
+{
+ static const unsigned int dim = TPath::PathDimension;
+ if( this->m_Path == 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( ) );
+ vtkSmartPointer< vtkUnsignedIntArray > darray =
+ vtkSmartPointer< vtkUnsignedIntArray >::New( );
+ darray->SetNumberOfComponents( 1 );
+ out->GetPointData( )->SetScalars( darray );
+ vtkPoints* points = out->GetPoints( );
+ vtkCellArray* lines = out->GetLines( );
+
+ // Assign all data
+ const TPath* path = this->GetInput( );
+ 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 ] );
+ darray->InsertNextTuple1( double( i ) );
+ if( i > 0 )
+ {
+ lines->InsertNextCell( 2 );
+ lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
+ lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
+
+ } // fi
+
+ } // rof
+ return( 1 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TPath >
+int ivq::VTK::Image::ImagePathToPolyDataFilter< _TPath >::
+RequestInformation(
+ vtkInformation* information,
+ vtkInformationVector** input,
+ vtkInformationVector* output
+ )
+{
+ return( 1 );
+}
+
+#endif // __ivq__VTK__ImagePathToPolyDataFilterFilter__hxx__
+// eof - $RCSfile$
--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __ivq__VTK__ImageSkeletonToPolyDataFilter__h__
+#define __ivq__VTK__ImageSkeletonToPolyDataFilter__h__
+
+#include <vtkPolyDataAlgorithm.h>
+
+namespace ivq
+{
+ namespace VTK
+ {
+ /**
+ */
+ template< class _TSkeleton >
+ class ImageSkeletonToPolyDataFilter
+ : public vtkPolyDataAlgorithm
+ {
+ public:
+ typedef ImageSkeletonToPolyDataFilter Self;
+ typedef _TSkeleton TSkeleton;
+
+ public:
+ vtkTypeMacro( ImageSkeletonToPolyDataFilter, vtkPolyDataAlgorithm );
+
+ public:
+ static Self* New( );
+
+ const TSkeleton* GetInput( ) const;
+ void SetInput( const TSkeleton* sk );
+
+ protected:
+ ImageSkeletonToPolyDataFilter( );
+ virtual ~ImageSkeletonToPolyDataFilter( );
+
+ int RequestData(
+ vtkInformation* information,
+ vtkInformationVector** input,
+ vtkInformationVector* output
+ );
+ int RequestInformation(
+ vtkInformation* information,
+ vtkInformationVector** input,
+ vtkInformationVector* output
+ );
+
+ private:
+ // Purposely not implemented
+ ImageSkeletonToPolyDataFilter( const Self& );
+ void operator=( const Self& );
+
+ protected:
+ const TSkeleton* m_Skeleton;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#ifndef ITK_MANUAL_INSTANTIATION
+# include <ivq/VTK/Image/ImageSkeletonToPolyDataFilter.hxx>
+#endif // ITK_MANUAL_INSTANTIATION
+
+#endif // __ivq__VTK__ImageSkeletonToPolyDataFilter__h__
+
+// eof - $RCSfile$
--- /dev/null
+// =========================================================================
+// @author Leonardo Florez Valencia
+// @email florez-l@javeriana.edu.co
+// =========================================================================
+#ifndef __ivq__VTK__ImageSkeletonToPolyDataFilter__hxx__
+#define __ivq__VTK__ImageSkeletonToPolyDataFilter__hxx__
+
+#include <vtkCellArray.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+#include <vtkPointData.h>
+#include <vtkUnsignedIntArray.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+typename ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+Self* ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+New( )
+{
+ return( new Self( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+const typename
+ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+TSkeleton* ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+GetInput( ) const
+{
+ return( this->m_Skeleton );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+void ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+SetInput( const TSkeleton* sk )
+{
+ if( this->m_Skeleton != sk )
+ {
+ this->m_Skeleton = sk;
+ this->Modified( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+ImageSkeletonToPolyDataFilter( )
+ : vtkPolyDataAlgorithm( ),
+ m_Skeleton( NULL )
+{
+ this->SetNumberOfInputPorts( 0 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+~ImageSkeletonToPolyDataFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+int ivq::VTK::ImageSkeletonToPolyDataFilter< _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( ) );
+ vtkSmartPointer< vtkUnsignedIntArray > darray =
+ vtkSmartPointer< vtkUnsignedIntArray >::New( );
+ darray->SetNumberOfComponents( 1 );
+ out->GetPointData( )->SetScalars( darray );
+ vtkPoints* points = out->GetPoints( );
+ vtkCellArray* lines = out->GetLines( );
+
+ // Assign all data
+ unsigned int dcount = 0;
+ typename TSkeleton::TMatrix::const_iterator mIt = this->m_Skeleton->BeginEdgesRows( );
+ for( ; mIt != this->m_Skeleton->EndEdgesRows( ); ++mIt )
+ {
+ // TODO: mIt->first; --> this is the row index. <--
+ typename TSkeleton::TMatrixRow::const_iterator rIt = mIt->second.begin( );
+ for( ; rIt != mIt->second.end( ); ++rIt )
+ {
+ // TODO: rIt->first; --> this is the column index.
+ typename TSkeleton::TEdges::const_iterator 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 ] );
+ darray->InsertNextTuple1( double( dcount ) );
+ if( i > 0 )
+ {
+ lines->InsertNextCell( 2 );
+ lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
+ lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
+
+ } // fi
+
+ } // rof
+ dcount++;
+
+ } // rof
+
+ } // rof
+
+ } // rof
+ return( 1 );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+int ivq::VTK::ImageSkeletonToPolyDataFilter< _TSkeleton >::
+RequestInformation(
+ vtkInformation* information,
+ vtkInformationVector** input,
+ vtkInformationVector* output
+ )
+{
+ return( 1 );
+}
+
+#endif // __ivq__VTK__ImageSkeletonToPolyDataFilterFilter__hxx__
+// eof - $RCSfile$