+#include <plugins/Plugins/SkeletonFilter.h>
+#include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Skeleton.h>
+#include <fpa/Image/SkeletonFilter.h>
+#include <fpa/Image/SkeletonFilter.hxx>
+#include <itkSimpleDataObjectDecorator.hxx>
+
+// -------------------------------------------------------------------------
+fpaPlugins::SkeletonFilter::
+SkeletonFilter( )
+ : Superclass( )
+{
+ typedef cpPlugins::DataObjects::Image _TImage;
+ typedef cpPlugins::DataObjects::Skeleton _TSkeleton;
+
+ this->_ConfigureInput< _TImage >( "DistanceMap", true, false );
+ this->_ConfigureInput< _TImage >( "CostMap", true, false );
+ this->_ConfigureInput< _TImage >( "MST", true, false );
+ this->_ConfigureOutput< _TSkeleton >( "Skeleton" );
+ this->_ConfigureOutput< _TImage >( "Marks" );
+ /* TODO
+ this->_ConfigureOutput< _TMesh >( "EndPoints" );
+ this->_ConfigureOutput< _TMesh >( "Bifurcations" );
+ */
+}
+
+// -------------------------------------------------------------------------
+fpaPlugins::SkeletonFilter::
+~SkeletonFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void fpaPlugins::SkeletonFilter::
+_GenerateData( )
+{
+ auto o = this->GetInputData( "DistanceMap" );
+ cpPlugins_Demangle_ImageScalars_Dims( o, _GD0 );
+ else this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TDistanceMap >
+void fpaPlugins::SkeletonFilter::
+_GD0( _TDistanceMap* dmap )
+{
+ auto cmap = this->GetInputData< _TDistanceMap >( "CostMap" );
+ if( cmap != NULL )
+ this->_GD1( dmap, cmap );
+ else
+ this->_Error( "Temporary error: invalid cost map." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TDistanceMap, class _TCostMap >
+void fpaPlugins::SkeletonFilter::
+_GD1( _TDistanceMap* dmap, _TCostMap* cmap )
+{
+ typedef fpa::Image::SkeletonFilter< _TDistanceMap, _TCostMap > _TFilter;
+ typedef typename _TFilter::TMST _TMST;
+
+ auto mst = this->GetInputData< _TMST >( "MST" );
+ if( mst == NULL )
+ this->_Error( "Invalid MST." );
+
+ auto filter = this->_CreateITK< _TFilter >( );
+ filter->SetDistanceMap( dmap );
+ filter->SetCostMap( cmap );
+ filter->SetMinimumSpanningTree( mst );
+ filter->Update( );
+ this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
+ this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) );
+
+
+ /* TODO
+ auto ep = filter->GetEndPoints( );
+ auto bi = filter->GetBifurcations( );
+
+ auto ep_pd = this->GetOutputData< vtkPolyData >( "EndPoints" );
+ if( ep_pd == NULL )
+ {
+ auto points = vtkSmartPointer< vtkPoints >::New( );
+ auto verts = vtkSmartPointer< vtkCellArray >::New( );
+ auto lines = vtkSmartPointer< vtkCellArray >::New( );
+ auto polys = vtkSmartPointer< vtkCellArray >::New( );
+ auto strips = vtkSmartPointer< vtkCellArray >::New( );
+ auto pd = vtkSmartPointer< vtkPolyData >::New( );
+ pd->SetPoints( points );
+ pd->SetVerts( verts );
+ pd->SetLines( lines );
+ pd->SetPolys( polys );
+ pd->SetStrips( strips );
+
+ this->GetOutput( "EndPoints" )->SetVTK( pd );
+ ep_pd = this->GetOutputData< vtkPolyData >( "EndPoints" );
+
+ } // fi
+
+ for( auto iIt = ep.begin( ); iIt != ep.end( ); ++iIt )
+ {
+ typename _TCostMap::PointType p;
+ cmap->TransformIndexToPhysicalPoint( *iIt, p );
+
+ if( _TCostMap::ImageDimension == 1 )
+ ep_pd->GetPoints( )->InsertNextPoint( p[ 0 ], 0, 0 );
+ else if( _TCostMap::ImageDimension == 2 )
+ ep_pd->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], 0 );
+ else if( _TCostMap::ImageDimension > 2 )
+ ep_pd->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], p[ 2 ] );
+
+ ep_pd->GetVerts( )->InsertNextCell( 1 );
+ ep_pd->GetVerts( )->InsertCellPoint( ep_pd->GetNumberOfPoints( ) - 1 );
+
+ } // rof
+ */
+}
+
+// eof - $RCSfile$