]> Creatis software - FrontAlgorithms.git/blob - plugins/ImageAlgorithms/SkeletonFilter.cxx
03689aa5e023bf9e66ea97912bb9ee1c31cb9ccd
[FrontAlgorithms.git] / plugins / ImageAlgorithms / SkeletonFilter.cxx
1 #include <ImageAlgorithms/SkeletonFilter.h>
2 #include <cpInstances/DataObjects/Image.h>
3 #include <cpInstances/DataObjects/Skeleton.h>
4
5 #include <itkImage.h>
6
7 /* TODO
8    #include <fpa/Image/SkeletonFilter.h>
9    #include <vtkPolyData.h>
10 */
11
12 // -------------------------------------------------------------------------
13 fpaPluginsImageAlgorithms::SkeletonFilter::
14 SkeletonFilter( )
15   : Superclass( )
16 {
17   typedef cpInstances::DataObjects::Image    _TImage;
18   typedef cpInstances::DataObjects::Skeleton _TSkeleton;
19   typedef cpPlugins::Pipeline::DataObject _TData;
20
21   this->_ConfigureInput< _TImage >( "Input", true, false );
22   this->_ConfigureInput< _TData >( "Seeds", true, false );
23   this->_ConfigureOutput< _TSkeleton >( "Skeleton" );
24   this->_ConfigureOutput< _TImage >( "Marks" );
25 }
26
27 // -------------------------------------------------------------------------
28 fpaPluginsImageAlgorithms::SkeletonFilter::
29 ~SkeletonFilter( )
30 {
31 }
32
33 // -------------------------------------------------------------------------
34 void fpaPluginsImageAlgorithms::SkeletonFilter::
35 _GenerateData( )
36 {
37   auto o = this->GetInputData( "Input" );
38   cpPlugins_Demangle_Image_RealPixels_AllDims_1( o, _GD0 )
39     this->_Error( "Invalid input image." );
40 }
41
42 // -------------------------------------------------------------------------
43 template< class _TImage >
44 void fpaPluginsImageAlgorithms::SkeletonFilter::
45 _GD0( _TImage* image )
46 {
47   /* TODO
48      typedef fpa::Image::SkeletonFilter< _TImage > _TFilter;
49      auto filter = this->_CreateITK< _TFilter >( );
50      filter->SetInput( image );
51
52      auto seeds = this->GetInputData< vtkPolyData >( "Seeds" );
53      if( seeds != NULL )
54      {
55      typename _TImage::PointType pnt;
56      typename _TImage::IndexType idx;
57      unsigned int dim =
58      ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
59
60      for( int i = 0; i < seeds->GetNumberOfPoints( ); ++i )
61      {
62      double buf[ 3 ];
63      seeds->GetPoint( i, buf );
64      pnt.Fill( 0 );
65      for( unsigned int d = 0; d < dim; ++d )
66      pnt[ d ] = buf[ d ];
67
68      if( image->TransformPhysicalPointToIndex( pnt, idx ) )
69      filter->AddSeed( idx, 0 );
70
71      } // rof
72
73      } // fi
74
75      filter->Update( );
76      this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) );
77      this->GetOutput( "Marks" )->SetITK( filter->GetMarks( ) );
78   */
79 }
80
81 // eof - $RCSfile$