#include "ExtractPathFromMinimumSpanningTree.h"
-#include <fpa_Instances/Instances.h>
-
-#include <itkDataObject.h>
-#include <itkIndex.h>
-#include <itkSimpleDataObjectDecorator.hxx>
-#include <itkVectorContainer.hxx>
-#include <itkParametricPath.hxx>
-#include <cpPlugins_Instances/Paths.h>
#include <cpPlugins/Path.h>
-#include <fpa/Base/ExtractPathFromMinimumSpanningTree.h>
-#include <fpa/Base/ExtractPathFromMinimumSpanningTree.hxx>
+#include <cpExtensions/DataStructures/ImageIndexesContainer.h>
+#include <fpa_Instances/Backtracking.h>
// -------------------------------------------------------------------------
fpaPlugins::ExtractPathFromMinimumSpanningTree::
}
// -------------------------------------------------------------------------
-std::string fpaPlugins::ExtractPathFromMinimumSpanningTree::
+void fpaPlugins::ExtractPathFromMinimumSpanningTree::
_GenerateData( )
{
typedef fpa::Image::MinimumSpanningTree< 2 > _2DMST;
typedef fpa::Image::MinimumSpanningTree< 3 > _3DMST;
- auto mst = this->GetInputData( "MST" )->GetITK< itk::DataObject >( );
+ auto mst = this->GetInputData< itk::DataObject >( "MST" );
auto mst2 = dynamic_cast< _2DMST* >( mst );
auto mst3 = dynamic_cast< _3DMST* >( mst );
- std::string r = this->_GD0( mst2 );
- if( r != "" ) r = this->_GD0( mst3 );
- return( r );
+ if ( mst2 != NULL ) this->_GD0( mst2 );
+ else if( mst3 != NULL ) this->_GD0( mst3 );
+ else this->_Error( "Invalid input MST." );
}
// -------------------------------------------------------------------------
template< class _TMST >
-std::string fpaPlugins::ExtractPathFromMinimumSpanningTree::
+void fpaPlugins::ExtractPathFromMinimumSpanningTree::
_GD0( _TMST* mst )
{
- typedef fpa::Base::ExtractPathFromMinimumSpanningTree< _TMST > _TFilter;
- typedef typename _TMST::TVertex _TVertex;
- typedef itk::SimpleDataObjectDecorator< std::vector< _TVertex > > _TVertices;
- if( mst == NULL )
- return(
- "fpaPlugins::ExtractPathFromMinimumSpanningTree: No valid input tree."
- );
- auto vertices = this->GetInputData( "Seeds" )->GetITK< _TVertices >( );
+ typedef fpa::Base::ExtractPathFromMinimumSpanningTree< _TMST > _TFilter;
+ auto vertices = this->GetInputData< vtkPoints >( "Seeds" );
if( vertices == NULL )
- return(
- "fpaPlugins::ExtractPathFromMinimumSpanningTree: No valid vertices."
- );
- if( vertices->Get( ).size( ) < 2 )
- return(
- "fpaPlugins::ExtractPathFromMinimumSpanningTree: Not enough vertices."
- );
- auto v0 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex0" ) ];
- auto v1 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex1" ) ];
+ this->_Error( "No valid vertices." );
+ if( vertices->GetNumberOfPoints( ) < 2 )
+ this->_Error( "Not enough vertices." );
+
+ double b0[ 3 ], b1[ 3 ];
+ vertices->GetPoint( this->m_Parameters.GetUint( "Vertex0" ), b0 );
+ vertices->GetPoint( this->m_Parameters.GetUint( "Vertex1" ), b1 );
+
+ typename _TMST::PointType p0, p1;
+ unsigned int dim = ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3;
+ for( unsigned int d = 0; d < dim; ++d )
+ {
+ p0[ d ] = b0[ d ];
+ p1[ d ] = b1[ d ];
+
+ } // rof
+ typename _TMST::TVertex v0, v1;
+ mst->TransformPhysicalPointToIndex( p0, v0 );
+ mst->TransformPhysicalPointToIndex( p1, v1 );
// Create filter and connect input
_TFilter* filter = this->_CreateITK< _TFilter >( );
filter->Update( );
// Connect output and finish
- this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
- return( "" );
+ this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
}
// eof - $RCSfile$