]> Creatis software - FrontAlgorithms.git/blobdiff - plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx
...
[FrontAlgorithms.git] / plugins / fpa / ExtractPathFromMinimumSpanningTree.cxx
index 7e41b4f6dc337bd7d20295c40ac4c2ea94668556..0f717abc9e932917458844d187c55b43ffd80226 100644 (file)
@@ -31,7 +31,7 @@ _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 );
   if     ( mst2 != NULL ) this->_GD0( mst2 );
@@ -45,16 +45,27 @@ void fpaPlugins::ExtractPathFromMinimumSpanningTree::
 _GD0( _TMST* mst )
 {
   typedef fpa::Base::ExtractPathFromMinimumSpanningTree< _TMST > _TFilter;
-  typedef
-    cpExtensions::DataStructures::ImageIndexesContainer< _TMST::Dimension >
-    _TVertices;
-  auto vertices = this->GetInputData( "Seeds" )->GetITK< _TVertices >( );
+  auto vertices = this->GetInputData< vtkPoints >( "Seeds" );
   if( vertices == NULL )
     this->_Error( "No valid vertices." );
-  if( vertices->Get( ).size( ) < 2 )
+  if( vertices->GetNumberOfPoints( ) < 2 )
     this->_Error( "Not enough vertices." );
-  auto v0 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex0" ) ];
-  auto v1 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex1" ) ];
+
+  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 >( );
@@ -64,7 +75,7 @@ _GD0( _TMST* mst )
   filter->Update( );
 
   // Connect output and finish
-  this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
 }
 
 // eof - $RCSfile$