-#include <plugins/Plugins/ExtractPathFromMinimumSpanningTree.h>
-#include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/Mesh.h>
-#include <fpa_DataObjects.h>
-
-/* TODO
- #include <vtkFloatArray.h>
- #include <vtkPointData.h>
-*/
+#include <Plugins/ExtractPathFromMinimumSpanningTree.h>
+#include <cpInstances/Image.h>
+#include <cpInstances/PolyLineParametricPath.h>
+#include <vtkPolyData.h>
+#include <fpa/Image/MinimumSpanningTree.h>
// -------------------------------------------------------------------------
fpaPlugins::ExtractPathFromMinimumSpanningTree::
ExtractPathFromMinimumSpanningTree( )
: Superclass( )
{
- typedef cpPlugins::BaseObjects::DataObject _TData;
- typedef cpPlugins::DataObjects::Image _TMST;
- typedef cpPlugins::DataObjects::Mesh _TMesh;
+ typedef cpPlugins::BaseObjects::DataObject _TData;
+ typedef cpInstances::Image _TMST;
+ typedef cpInstances::PolyLineParametricPath _TPath;
this->_ConfigureInput< _TMST >( "MST", true, false );
this->_ConfigureInput< _TData >( "Seeds", true, false );
- this->_ConfigureOutput< _TMesh >( "Paths" );
-
- this->m_Parameters.ConfigureAsUintList( "Indices" );
+ this->_ConfigureOutput< _TPath >( "Output" );
}
// -------------------------------------------------------------------------
_GD0( _TMST* mst )
{
typedef typename _TMST::IndexType _TIndex;
+ typedef typename _TMST::TPath _TPath;
// Get seeds
std::vector< _TIndex > seeds;
auto points = this->GetInputData< vtkPolyData >( "Seeds" );
if( points != NULL )
{
+ if( points->GetNumberOfPoints( ) < 2 )
+ this->_Error( "Not enough seeds (<2)." );
+
typename _TMST::PointType pnt;
typename _TMST::IndexType idx;
unsigned int dim =
( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3;
- for( unsigned int i = 0; i < points->GetNumberOfPoints( ); ++i )
+ for( unsigned int i = 0; i < 2; ++i )
{
double buf[ 3 ];
points->GetPoint( i, buf );
} // fi
- // Prepare result
- auto mesh = this->_CreateVTK< vtkPolyData >( );
- mesh->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
- mesh->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
- mesh->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
- mesh->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
- mesh->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
- /* TODO
- vtkSmartPointer< vtkFloatArray > data =
- vtkSmartPointer< vtkFloatArray >::New( );
- data->SetNumberOfComponents( 1 );
- mesh->GetPointData( )->SetScalars( data );
- */
-
- // Compute
- auto indices = this->m_Parameters.GetUintList( "Indices" );
- for( unsigned int i = 0; i < indices.size( ); i += 2 )
- {
- if( i < indices.size( ) - 1 )
- {
- _TIndex a = seeds[ indices[ i ] ];
- _TIndex b = seeds[ indices[ i + 1 ] ];
-
- auto path = mst->GetEuclideanPath( a, b );
- for( unsigned long j = 0; j < path.size( ); ++j )
- {
- auto p = path[ j ];
- if( _TMST::ImageDimension == 2 )
- mesh->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], 0 );
- else if( _TMST::ImageDimension == 3 )
- mesh->GetPoints( )->InsertNextPoint( p[ 0 ], p[ 1 ], p[ 2 ] );
- if( j > 0 )
- {
- mesh->GetLines( )->InsertNextCell( 2 );
- mesh->GetLines( )->InsertCellPoint( j - 1 );
- mesh->GetLines( )->InsertCellPoint( j );
-
- } // fi
-
- } // rof
-
- } // fi
-
- } // rof
- this->GetOutput( "Paths" )->SetVTK( mesh );
+ typename _TPath::Pointer path;
+ mst->GetPath( path, seeds[ 0 ], seeds[ 1 ] );
+ this->GetOutput( "Output" )->SetITK( path );
}
// eof - $RCSfile$