#include "SeedWidget.h" #include #include #include #include #include #include #include // ------------------------------------------------------------------------- itk::ModifiedTimeType cpPluginsWidgets::SeedWidget:: GetMTime( ) const { // std::cout << "Seed GetMTime" << std::endl; return( 0 /*this->Superclass::GetMTime( )*/ ); } // ------------------------------------------------------------------------- cpPluginsWidgets::SeedWidget:: SeedWidget( ) : Superclass( ), m_Configured( false ) { this->_AddInput( "ReferenceImage" ); this->_AddOutput< cpPlugins::DataObject >( "Output" ); } // ------------------------------------------------------------------------- cpPluginsWidgets::SeedWidget:: ~SeedWidget( ) { } // ------------------------------------------------------------------------- std::string cpPluginsWidgets::SeedWidget:: _GenerateData( ) { auto image = this->GetInputData( "ReferenceImage" ); std::string r = cpPlugin_Image_Demangle_Dim( _GD0, image, 3 ); if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, image, 2 ); return( r ); } // ------------------------------------------------------------------------- template< class _TImage > std::string cpPluginsWidgets::SeedWidget:: _GD0( _TImage* image ) { typedef cpExtensions::DataStructures::ImageIndexesContainer< _TImage::ImageDimension > _TContainer; typedef cpExtensions::Interaction::ImageInteractorStyle _S; if( image != NULL ) { auto container = this->_CreateITK< _TContainer >( ); double aux_pnt[ 3 ]; unsigned int dim = ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; container->Get( ).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 _TImage::PointType seed; for( unsigned int d = 0; d < dim; ++d ) seed[ d ] = aux_pnt[ d ]; typename _TImage::IndexType idx; if( image->TransformPhysicalPointToIndex( seed, idx ) ) container->Get( ).push_back( idx ); } // 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 _TImage::PointType seed; for( unsigned int d = 0; d < dim; ++d ) seed[ d ] = aux_pnt[ d ]; typename _TImage::IndexType idx; if( image->TransformPhysicalPointToIndex( seed, idx ) ) container->Get( ).push_back( idx ); } // rof } else s->SeedWidgetOn( ); } // fi this->m_Configured = true; container->SetReferenceImage( image ); this->GetOutputData( "Output" )->SetITK( container ); return( "" ); } else return( "Widgets::SeedWidget: Input image dimension not supported." ); } // eof - $RCSfile$