1 #include "SeedWidget.h"
3 #include <cpPlugins/Image.h>
4 #include <cpExtensions/DataStructures/ImageIndexesContainer.h>
5 #include <cpExtensions/QT/SimpleMPRWidget.h>
6 #include <cpExtensions/Interaction/ImageInteractorStyle.h>
7 #include <vtkRenderWindowInteractor.h>
8 #include <itkSimpleDataObjectDecorator.h>
9 #include <itkSimpleDataObjectDecorator.hxx>
11 // -------------------------------------------------------------------------
12 itk::ModifiedTimeType cpPluginsWidgets::SeedWidget::
15 // std::cout << "Seed GetMTime" << std::endl;
16 return( 0 /*this->Superclass::GetMTime( )*/ );
19 // -------------------------------------------------------------------------
20 cpPluginsWidgets::SeedWidget::
25 this->_AddInput( "ReferenceImage" );
26 this->_AddOutput< cpPlugins::DataObject >( "Output" );
29 // -------------------------------------------------------------------------
30 cpPluginsWidgets::SeedWidget::
35 // -------------------------------------------------------------------------
36 void cpPluginsWidgets::SeedWidget::
39 auto image = this->GetInputData( "ReferenceImage" )->GetITK< itk::DataObject >( );
40 cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 );
41 else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 );
42 else this->_Error( "No valid input image." );
45 // -------------------------------------------------------------------------
46 template< class _TImage >
47 void cpPluginsWidgets::SeedWidget::
48 _GD0( _TImage* image )
51 cpExtensions::DataStructures::ImageIndexesContainer< _TImage::ImageDimension >
53 typedef cpExtensions::Interaction::ImageInteractorStyle _S;
57 auto container = this->_CreateITK< _TContainer >( );
59 unsigned int dim = ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3;
60 container->Get( ).clear( );
63 if( this->m_MPRViewer != NULL )
65 for( unsigned int i = 0; i < 4; ++i )
69 this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( )
73 if( this->m_Configured )
75 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
77 s->GetSeedAsPoint( i, aux_pnt );
78 typename _TImage::PointType seed;
79 for( unsigned int d = 0; d < dim; ++d )
80 seed[ d ] = aux_pnt[ d ];
81 typename _TImage::IndexType idx;
82 if( image->TransformPhysicalPointToIndex( seed, idx ) )
83 container->Get( ).push_back( idx );
97 _S* s = dynamic_cast< _S* >( this->m_SingleInteractor );
100 if( this->m_Configured )
102 for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i )
104 s->GetSeedAsPoint( i, aux_pnt );
105 typename _TImage::PointType seed;
106 for( unsigned int d = 0; d < dim; ++d )
107 seed[ d ] = aux_pnt[ d ];
108 typename _TImage::IndexType idx;
109 if( image->TransformPhysicalPointToIndex( seed, idx ) )
110 container->Get( ).push_back( idx );
118 this->m_Configured = true;
119 container->SetReferenceImage( image );
120 this->GetOutputData( "Output" )->SetITK( container );
123 this->_Error( "Input image dimension not supported." );