1 #include "SeedWidget.h"
3 #include <cpPlugins/Interface/Image.h>
4 #include <cpPlugins/Interface/PointList.h>
5 #include <cpPlugins/Interface/SimpleMPRWidget.h>
6 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
8 #include <vtkRenderWindowInteractor.h>
10 // -------------------------------------------------------------------------
11 cpPlugins::Widgets::SeedWidget::
16 this->_AddInput( "ReferenceImage" );
17 this->_AddOutput< cpPlugins::Interface::PointList >( "Output" );
19 this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" );
20 this->m_Parameters->SetBool( "SeedsAreInRealSpace", true );
23 // -------------------------------------------------------------------------
24 cpPlugins::Widgets::SeedWidget::
29 // -------------------------------------------------------------------------
30 std::string cpPlugins::Widgets::SeedWidget::
33 typedef itk::ImageBase< 2 > _2DImage;
34 typedef itk::ImageBase< 3 > _3DImage;
36 cpPlugins::Interface::Image* image =
37 this->GetInput< cpPlugins::Interface::Image >( "ReferenceImage" );
39 return( "SeedWidget: No input image." );
41 itk::DataObject* itk_image = image->GetITK< _2DImage >( );
42 if( itk_image != NULL )
43 return( this->_GD0< _2DImage >( itk_image ) );
46 itk_image = image->GetITK< _3DImage >( );
47 if( itk_image != NULL )
48 return( this->_GD0< _3DImage >( itk_image ) );
52 return( "SeedWidget: Input image dimension not supported." );
55 // -------------------------------------------------------------------------
57 std::string cpPlugins::Widgets::SeedWidget::
58 _GD0( itk::DataObject* image )
60 typedef cpExtensions::Interaction::ImageInteractorStyle _S;
62 I* base_image = dynamic_cast< I* >( image );
63 cpPlugins::Interface::PointList* out =
64 this->GetOutput< cpPlugins::Interface::PointList >( "Output" );
66 unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3;
71 if( this->m_MPRViewer != NULL )
73 for( unsigned int i = 0; i < 4; ++i )
77 this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
81 if( this->m_Configured )
83 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
85 s->GetSeedAsPoint( i, aux_pnt );
86 typename I::PointType seed;
87 for( unsigned int d = 0; d < dim; ++d )
88 seed[ d ] = aux_pnt[ d ];
89 out->AddPoint( seed );
103 _S* s = dynamic_cast< _S* >( this->m_SingleInteractor.GetPointer( ) );
106 if( this->m_Configured )
108 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
110 s->GetSeedAsPoint( i, aux_pnt );
111 typename I::PointType seed;
112 for( unsigned int d = 0; d < dim; ++d )
113 seed[ d ] = aux_pnt[ d ];
114 out->AddPoint( seed );
124 auto iIt = this->m_Interactors.begin( );
125 for( ; iIt != this->m_Interactors.end( ); ++iIt )
127 _S* s = dynamic_cast< _S* >( ( *iIt )->GetInteractorStyle( ) );
130 if( this->m_Configured )
132 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
134 s->GetSeedAsPoint( i, aux_pnt );
135 typename I::PointType seed;
136 for( unsigned int d = 0; d < dim; ++d )
137 seed[ d ] = aux_pnt[ d ];
138 out->AddPoint( seed );
149 this->m_Configured = true;