#include "SeedWidget.h" #include #include #include #include #include // ------------------------------------------------------------------------- cpPlugins::Widgets::SeedWidget:: SeedWidget( ) : Superclass( ), m_Configured( false ) { this->_AddInput( "ReferenceImage" ); this->_AddOutput< cpPlugins::Interface::PointList >( "Output" ); this->m_Parameters->ConfigureAsBool( "SeedsAreInRealSpace" ); this->m_Parameters->SetBool( "SeedsAreInRealSpace", true ); } // ------------------------------------------------------------------------- cpPlugins::Widgets::SeedWidget:: ~SeedWidget( ) { } // ------------------------------------------------------------------------- std::string cpPlugins::Widgets::SeedWidget:: _GenerateData( ) { typedef itk::ImageBase< 2 > _2DImage; typedef itk::ImageBase< 3 > _3DImage; auto image = this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" ); if( image == NULL ) return( "SeedWidget: No input image." ); itk::DataObject* itk_image = image->GetITK< _2DImage >( ); if( itk_image != NULL ) return( this->_GD0< _2DImage >( itk_image ) ); else { itk_image = image->GetITK< _3DImage >( ); if( itk_image != NULL ) return( this->_GD0< _3DImage >( itk_image ) ); } // fi return( "SeedWidget: Input image dimension not supported." ); } // ------------------------------------------------------------------------- template< class I > std::string cpPlugins::Widgets::SeedWidget:: _GD0( itk::DataObject* image ) { typedef cpExtensions::Interaction::ImageInteractorStyle _S; I* base_image = dynamic_cast< I* >( image ); auto out = this->GetOutputData< cpPlugins::Interface::PointList >( "Output" ); double aux_pnt[ 3 ]; unsigned int dim = ( I::ImageDimension < 3 )? I::ImageDimension: 3; out->Clear( ); // MPR if( this->m_MPRViewer != NULL ) { for( unsigned int i = 0; i < 4; ++i ) { _S* s = dynamic_cast< _S* >( this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( ) ); if( s != NULL ) { if( this->m_Configured ) { for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) { s->GetSeedAsPoint( i, aux_pnt ); typename I::PointType seed; for( unsigned int d = 0; d < dim; ++d ) seed[ d ] = aux_pnt[ d ]; out->AddPoint( seed ); } // rof } else s->SeedWidgetOn( ); } // fi } // rof } // fi // Single interactor _S* s = dynamic_cast< _S* >( this->m_SingleInteractor ); if( s != NULL ) { if( this->m_Configured ) { for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) { s->GetSeedAsPoint( i, aux_pnt ); typename I::PointType seed; for( unsigned int d = 0; d < dim; ++d ) seed[ d ] = aux_pnt[ d ]; out->AddPoint( seed ); } // rof } else s->SeedWidgetOn( ); } // fi /* TODO auto iIt = this->m_Interactors.begin( ); for( ; iIt != this->m_Interactors.end( ); ++iIt ) { _S* s = dynamic_cast< _S* >( ( *iIt )->GetInteractorStyle( ) ); if( s != NULL ) { if( this->m_Configured ) { for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) { s->GetSeedAsPoint( i, aux_pnt ); typename I::PointType seed; for( unsigned int d = 0; d < dim; ++d ) seed[ d ] = aux_pnt[ d ]; out->AddPoint( seed ); } // rof } else s->SeedWidgetOn( ); } // fi } // rof */ this->m_Configured = true; return( "" ); } // eof - $RCSfile$