1 #include "SeedWidget.h"
3 #include <cpPlugins/Interface/Image.h>
4 #include <cpPlugins/Interface/PointList.h>
5 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
7 #include <vtkRenderWindowInteractor.h>
9 // -------------------------------------------------------------------------
10 cpPlugins::Widgets::SeedWidget::
15 this->_AddInput( "ReferenceImage" );
16 this->_AddOutput< cpPlugins::Interface::PointList >( "Output" );
18 this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
19 this->m_Parameters->SetBool( "SeedsAreInRealSpace", true );
22 // -------------------------------------------------------------------------
23 cpPlugins::Widgets::SeedWidget::
28 // -------------------------------------------------------------------------
29 std::string cpPlugins::Widgets::SeedWidget::
32 typedef itk::ImageBase< 2 > _2DImage;
33 typedef itk::ImageBase< 3 > _3DImage;
35 cpPlugins::Interface::Image* image =
36 this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" );
38 return( "SeedWidget: No input image." );
40 itk::DataObject* itk_image = image->GetITK< _2DImage >( );
41 if( itk_image != NULL )
42 return( this->_GD0< _2DImage >( itk_image ) );
45 itk_image = image->GetITK< _3DImage >( );
46 if( itk_image != NULL )
47 return( this->_GD0< _3DImage >( itk_image ) );
51 return( "SeedWidget: Input image dimension not supported." );
54 // -------------------------------------------------------------------------
56 std::string cpPlugins::Widgets::SeedWidget::
57 _GD0( itk::DataObject* image )
59 typedef cpExtensions::Interaction::ImageInteractorStyle _S;
61 I* base_image = dynamic_cast< I* >( image );
62 cpPlugins::Interface::PointList* out =
63 this->GetOutput< cpPlugins::Interface::PointList >( "Output" );
65 unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
68 auto iIt = this->m_Interactors.begin( );
69 for( ; iIt != this->m_Interactors.end( ); ++iIt )
71 _S* s = dynamic_cast< _S* >( ( *iIt )->GetInteractorStyle( ) );
74 if( this->m_Configured )
76 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
78 s->GetSeedAsPoint( i, aux_pnt );
79 typename I::PointType seed;
80 for( unsigned int d = 0; d < dim; ++d )
81 seed[ d ] = aux_pnt[ d ];
82 out->AddPoint( seed );
92 this->m_Configured = true;