#include #include #include #include #include #include /* TODO #include #include */ // ------------------------------------------------------------------------- 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_Image_RealPixels_AllDims_1( o, _GD0 ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TDistanceMap > void fpaPlugins::SkeletonFilter:: _GD0( _TDistanceMap* dmap ) { auto o = this->GetInputData( "CostMap" ); cpPlugins_Demangle_Image_RealPixels_2( o, _GD1, _TDistanceMap::ImageDimension, dmap ) this->_Error( "Invalid input image." ); } // ------------------------------------------------------------------------- template< class _TCostMap, class _TDistanceMap > void fpaPlugins::SkeletonFilter:: _GD1( _TCostMap* cmap, _TDistanceMap* dmap ) { 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$