From 4985f4ba986f600298676866c5099b2f84bee50b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Tue, 29 Nov 2016 18:16:06 -0500 Subject: [PATCH] .. --- appli/PipelineEditor/PipelineEditor.cxx | 167 ++++++++--------- appli/PipelineEditor/PipelineEditor.h | 1 - cmake/cpPluginsConfig.cmake.in | 102 +++++----- lib/cpBaseQtApplication/MainWindow.cxx | 176 ++++-------------- lib/cpBaseQtApplication/MainWindow.h | 23 +-- .../Algorithms/SkeletonToImageFilter.h | 81 ++++++++ .../Algorithms/SkeletonToImageFilter.hxx | 119 ++++++++++++ .../ITKNeighborhoodImageIterators.i | 3 + lib/cpPlugins/BaseObjects/Parameters.cxx | 24 --- lib/cpPlugins/Interface/Workspace.cxx | 29 +++ lib/cpPlugins/Interface/Workspace.h | 36 +--- ...rvatureAnisotropicDiffusionImageFilter.cxx | 71 +++++++ ...CurvatureAnisotropicDiffusionImageFilter.h | 32 ++++ .../ITKAnisotropicSmoothing.i | 2 +- .../SignedMaurerDistanceMapImageFilter.cxx | 2 + .../ITKImageGenericFilters_1.i | 3 + .../MinimumMaximumImageCalculator.cxx | 120 ++++++++++++ .../MinimumMaximumImageCalculator.h | 29 +++ plugins/ITKMorphology/ITKMorphology.i | 5 +- 19 files changed, 671 insertions(+), 354 deletions(-) create mode 100644 lib/cpExtensions/Algorithms/SkeletonToImageFilter.h create mode 100644 lib/cpExtensions/Algorithms/SkeletonToImageFilter.hxx create mode 100644 plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.cxx create mode 100644 plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h create mode 100644 plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx create mode 100644 plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h diff --git a/appli/PipelineEditor/PipelineEditor.cxx b/appli/PipelineEditor/PipelineEditor.cxx index 5751a90..f49c2a4 100644 --- a/appli/PipelineEditor/PipelineEditor.cxx +++ b/appli/PipelineEditor/PipelineEditor.cxx @@ -15,7 +15,6 @@ PipelineEditor( int argc, char* argv[], QWidget* parent ) m_UI( new Ui::PipelineEditor ) { // Basic configuration - this->m_SingleWorkspace = true; this->m_BaseWindowTitle = "PipelineEditor - "; this->m_UI->setupUi( this ); this->setCanvas( this->m_UI->Canvas ); @@ -34,14 +33,8 @@ PipelineEditor( int argc, char* argv[], QWidget* parent ) ); // Load command-line given workspace (if any) - this->m_ActiveWS = "empty"; if( argc > 1 ) - { this->_loadWorkspace( argv[ 1 ] ); - this->m_ActiveWS = argv[ 1 ]; - } - else - this->_addWorkspace( this->m_ActiveWS ); } // ------------------------------------------------------------------------- @@ -55,92 +48,94 @@ PipelineEditor:: void PipelineEditor:: _slotView( const std::string& name, bool show ) { - typedef cpExtensions::QT::ActorsWidgetInterface _TViewer; + /* TODO + typedef cpExtensions::QT::ActorsWidgetInterface _TViewer; - // Get filter parameters - std::vector< std::string > tokens; - cpPlugins::Tokenize( tokens, name, "@" ); - if( tokens.size( ) != 2 ) - return; - auto filter_name = tokens[ 1 ]; - auto output_name = tokens[ 0 ]; + // Get filter parameters + std::vector< std::string > tokens; + cpPlugins::Tokenize( tokens, name, "@" ); + if( tokens.size( ) != 2 ) + return; + auto filter_name = tokens[ 1 ]; + auto output_name = tokens[ 0 ]; - // Process data - if( show ) - { - try - { - auto ws = this->workspace( this->m_ActiveWS ); - auto filter = ws->GetFilter( filter_name ); - cpBaseQtApplication_Execute( filter->Update( ) ); - auto image = filter->GetOutputData< vtkImageData >( output_name ); - auto mesh = filter->GetOutputData< vtkPolyData >( output_name ); - _TViewer* viewer = NULL; - if( image != NULL ) - { - int dim = image->GetDataDimension( ); - if( dim == 2 ) - viewer = - this->_configureViewer< cpExtensions::QT::ImageWidget >( - this->m_UI->Viewer - ); - else if( dim == 3 ) - viewer = - this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( - this->m_UI->Viewer - ); - } - else if( mesh != NULL ) - { - viewer = - this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( - this->m_UI->Viewer - ); + // Process data + if( show ) + { + try + { + auto ws = this->workspace( this->m_ActiveWS ); + auto filter = ws->GetFilter( filter_name ); + cpBaseQtApplication_Execute( filter->Update( ) ); + auto image = filter->GetOutputData< vtkImageData >( output_name ); + auto mesh = filter->GetOutputData< vtkPolyData >( output_name ); + _TViewer* viewer = NULL; + if( image != NULL ) + { + int dim = image->GetDataDimension( ); + if( dim == 2 ) + viewer = + this->_configureViewer< cpExtensions::QT::ImageWidget >( + this->m_UI->Viewer + ); + else if( dim == 3 ) + viewer = + this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( + this->m_UI->Viewer + ); + } + else if( mesh != NULL ) + { + viewer = + this->_configureViewer< cpExtensions::QT::SimpleMPRWidget >( + this->m_UI->Viewer + ); - } // fi - if( - dynamic_cast< QWidget* >( viewer ) != - dynamic_cast< QWidget* >( this->m_UI->Viewer ) - ) - { - delete this->m_UI->Viewer; - this->m_UI->Viewer = dynamic_cast< QWidget* >( viewer ); - this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer ); - this->setViewer( viewer ); + } // fi + if( + dynamic_cast< QWidget* >( viewer ) != + dynamic_cast< QWidget* >( this->m_UI->Viewer ) + ) + { + delete this->m_UI->Viewer; + this->m_UI->Viewer = dynamic_cast< QWidget* >( viewer ); + this->m_UI->MainSplitter->insertWidget( 0, this->m_UI->Viewer ); + this->setViewer( viewer ); - } // fi - if( image != NULL ) - { - this->m_Blocker.block( ); - auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer ); - auto imv = dynamic_cast< cpExtensions::QT::ImageWidget* >( viewer ); - if( mpr != NULL ) - mpr->SetImage( image, name ); - else if( imv != NULL ) - imv->SetImage( image, name ); - this->m_Blocker.unblock( ); - } - else if( mesh != NULL ) - { - this->m_Blocker.block( ); - auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer ); - if( mpr != NULL ) - mpr->Add( mesh, name ); - this->m_Blocker.unblock( ); + } // fi + if( image != NULL ) + { + this->m_Blocker.block( ); + auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer ); + auto imv = dynamic_cast< cpExtensions::QT::ImageWidget* >( viewer ); + if( mpr != NULL ) + mpr->SetImage( image, name ); + else if( imv != NULL ) + imv->SetImage( image, name ); + this->m_Blocker.unblock( ); + } + else if( mesh != NULL ) + { + this->m_Blocker.block( ); + auto mpr = dynamic_cast< cpExtensions::QT::SimpleMPRWidget* >( viewer ); + if( mpr != NULL ) + mpr->Add( mesh, name ); + this->m_Blocker.unblock( ); - } // fi - } - catch( std::exception& err ) - { - QMessageBox::critical( - NULL, - QMessageBox::tr( "Error showing data" ), - QMessageBox::tr( err.what( ) ) - ); + } // fi + } + catch( std::exception& err ) + { + QMessageBox::critical( + NULL, + QMessageBox::tr( "Error showing data" ), + QMessageBox::tr( err.what( ) ) + ); - } // yrt + } // yrt - } // fi + } // fi + */ } // ------------------------------------------------------------------------- diff --git a/appli/PipelineEditor/PipelineEditor.h b/appli/PipelineEditor/PipelineEditor.h index 3f4a68b..8c8db35 100644 --- a/appli/PipelineEditor/PipelineEditor.h +++ b/appli/PipelineEditor/PipelineEditor.h @@ -28,7 +28,6 @@ protected slots: private: Ui::PipelineEditor* m_UI; - std::string m_ActiveWS; }; #endif // __PipelineEditor__h__ diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index 0564e9d..7a2c72a 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -2,48 +2,56 @@ ## == Find cpPlugins-cmake tools == ## ================================ +SET(ITK_DIR "@ITK_DIR@") +SET(VTK_DIR "@VTK_DIR@") IF("@Qt4_FOUND@" STREQUAL "TRUE") SET(USE_QT4 ON) + SET(QT_QMAKE_EXECUTABLE "@QT_QMAKE_EXECUTABLE@") ENDIF("@Qt4_FOUND@" STREQUAL "TRUE") ## ==================== ## == Find libraries == ## ==================== -SET(cpPlugins_BaseLibraries "@cpPlugins_BaseLibraries@" CACHE STRING "Internal") -SET(cpPlugins_AllInstances "@cpPlugins_AllInstances@" CACHE STRING "Internal") -MARK_AS_ADVANCED(FORCE cpPlugins_BaseLibraries) +SET( + cpPlugins_AllInstances + "@cpPlugins_AllInstances@" + CACHE STRING "All instances from templated code" + ) MARK_AS_ADVANCED(FORCE cpPlugins_AllInstances) -SET(_all_libs ${cpPlugins_BaseLibraries} ${cpPlugins_AllInstances}) +SET( + _all_libs + cp_tinyxml2 + cpExtensions + cpPlugins + cpPluginsDataObjects + ) +IF(USE_QT4) + LIST(APPEND _all_libs cp_QCustomPlot cpBaseQtApplication) +ENDIF(USE_QT4) +SET(cpPlugins_Libraries ${_all_libs} CACHE STRING "cpPlugins base libraries") +MARK_AS_ADVANCED(FORCE cpPlugins_Libraries) +SET(_all_libs ${cpPlugins_AllInstances} ${cpPlugins_Libraries}) SET(_l_locations) FOREACH(_l ${_all_libs}) - IF(MSVC) - FIND_LIBRARY( - ${_l}_LIB NAMES ${_l} - HINTS - @PROJECT_BINARY_DIR@/$(ConfigurationName) - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) - ELSE(MSVC) - FIND_LIBRARY( - ${_l}_LIB NAMES ${_l} - HINTS - @PROJECT_BINARY_DIR@ - @CMAKE_INSTALL_PREFIX@/bin - @CMAKE_INSTALL_PREFIX@/lib - ) - ENDIF(MSVC) + FIND_LIBRARY( + ${_l}_LIB NAMES ${_l} + PATHS + @PROJECT_BINARY_DIR@ + @CMAKE_INSTALL_PREFIX@/bin + @CMAKE_INSTALL_PREFIX@/lib + ${_l_locations} + ) IF(${_l}_LIB) MARK_AS_ADVANCED(FORCE ${_l}_LIB) GET_FILENAME_COMPONENT(_dir ${${_l}_LIB} DIRECTORY) LIST(APPEND _l_locations ${_dir}) + LIST(REMOVE_DUPLICATES _l_locations) ENDIF(${_l}_LIB) ENDFOREACH(_l) IF(_l_locations) - LIST(REMOVE_DUPLICATES _l_locations) LINK_DIRECTORIES(${_l_locations}) ENDIF(_l_locations) @@ -54,7 +62,6 @@ ENDIF(_l_locations) ## TODO: this is not completely correct!!! INCLUDE_DIRECTORIES( @CMAKE_INSTALL_PREFIX@/include - @CMAKE_INSTALL_PREFIX@/include/cpPlugins/Itk2Vtk @CMAKE_INSTALL_PREFIX@/include/cpPlugins/cpInstances @PROJECT_SOURCE_DIR@ @PROJECT_BINARY_DIR@ @@ -77,42 +84,33 @@ SET( "@cpPlugins_bash_HostCreator_APP@" ) -FOREACH(_prog ${_exec_programs}) - IF(MSVC) - FIND_PROGRAM( - ${_prog}_APP - NAMES ${_prog} - HINTS /usr /usr/local - PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/$(ConfigurationName) - PATH_SUFFIXES bin sbin - DOC "Where is ${_prog}?" - ) - ELSE(MSVC) - FIND_PROGRAM( - ${_prog}_APP - NAMES ${_prog} - HINTS /usr /usr/local - PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@ - PATH_SUFFIXES bin sbin - DOC "Where is ${_prog}?" - ) - ENDIF(MSVC) - MARK_AS_ADVANCED(FORCE ${_prog}_APP) -ENDFOREACH(_prog) +SET(_b_locations) +FOREACH(_p ${_exec_programs}) + FIND_PROGRAM( + ${_p}_APP + NAMES ${_p} + HINTS /usr /usr/local + PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@ ${_b_locations} + PATH_SUFFIXES bin sbin + DOC "Where is ${_prog}?" + ) + IF(${_p}_APP) + MARK_AS_ADVANCED(FORCE ${_p}_APP) + GET_FILENAME_COMPONENT(_dir ${${_p}_APP} DIRECTORY) + LIST(APPEND _b_locations ${_dir}) + LIST(REMOVE_DUPLICATES _b_locations) + ENDIF(${_p}_APP) +ENDFOREACH(_p) ## ========================== ## == Configuration values == ## ========================== -SET(cpPlugins_CONFIG_NUMBER_OF_FILES @cpPlugins_CONFIG_NUMBER_OF_FILES@ CACHE STRING "Internal") -SET(cpPlugins_CONFIG_INTEGER_TYPES @cpPlugins_CONFIG_INTEGER_TYPES@ CACHE STRING "Internal") -SET(cpPlugins_CONFIG_REAL_TYPES @cpPlugins_CONFIG_REAL_TYPES@ CACHE STRING "Internal") -SET(cpPlugins_CONFIG_PROCESS_DIMENSIONS @cpPlugins_CONFIG_PROCESS_DIMENSIONS@ CACHE STRING "Internal") -SET(cpPlugins_CONFIG_VISUAL_DIMENSIONS @cpPlugins_CONFIG_VISUAL_DIMENSIONS@ CACHE STRING "Internal") +SET(cpPlugins_CONFIG_NUMBER_OF_FILES "@cpPlugins_CONFIG_NUMBER_OF_FILES@" CACHE STRING "Internal") +SET(cpPlugins_CONFIG_PROCESS_DIMENSIONS "@cpPlugins_CONFIG_PROCESS_DIMENSIONS@" CACHE STRING "Internal") +SET(cpPlugins_CONFIG_VISUAL_DIMENSIONS "@cpPlugins_CONFIG_VISUAL_DIMENSIONS@" CACHE STRING "Internal") MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_NUMBER_OF_FILES) -MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_INTEGER_TYPES) -MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_REAL_TYPES) MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_PROCESS_DIMENSIONS) MARK_AS_ADVANCED(FORCE cpPlugins_CONFIG_VISUAL_DIMENSIONS) diff --git a/lib/cpBaseQtApplication/MainWindow.cxx b/lib/cpBaseQtApplication/MainWindow.cxx index 9b16236..ac8858e 100644 --- a/lib/cpBaseQtApplication/MainWindow.cxx +++ b/lib/cpBaseQtApplication/MainWindow.cxx @@ -16,7 +16,6 @@ MainWindow( ) : Superclass( parent ), m_LastSaveFileName( "" ), - m_SingleWorkspace( false ), m_BaseWindowTitle( "cpBaseQtApplication" ), m_Canvas( NULL ), m_Navigator( NULL ), @@ -34,6 +33,7 @@ MainWindow( QMessageBox::critical( this, "Error guessing plugins.", err.what( ) ); } // yrt + this->_clearWorkspace( ); } // ------------------------------------------------------------------------- @@ -45,25 +45,17 @@ cpBaseQtApplication::MainWindow:: // ------------------------------------------------------------------------- cpBaseQtApplication::MainWindow:: TWorkspace* cpBaseQtApplication::MainWindow:: -workspace( const std::string& wname ) +workspace( ) { - auto wIt = this->m_Workspaces.find( wname ); - if( wIt != this->m_Workspaces.end( ) ) - return( wIt->second.GetPointer( ) ); - else - return( NULL ); + return( this->m_Workspace ); } // ------------------------------------------------------------------------- const cpBaseQtApplication::MainWindow:: TWorkspace* cpBaseQtApplication::MainWindow:: -workspace( const std::string& wname ) const +workspace( ) const { - auto wIt = this->m_Workspaces.find( wname ); - if( wIt != this->m_Workspaces.end( ) ) - return( wIt->second.GetPointer( ) ); - else - return( NULL ); + return( this->m_Workspace ); } // ------------------------------------------------------------------------- @@ -136,9 +128,8 @@ setViewer( cpExtensions::QT::ActorsWidgetInterface* v ) if( this->m_Viewer != NULL ) { auto interactors = this->m_Viewer->GetInteractors( ); - for( auto wIt : this->m_Workspaces ) - for( auto i : interactors ) - wIt.second->AddInteractor( i ); + for( auto i : interactors ) + this->m_Workspace->AddInteractor( i ); } // fi } @@ -218,136 +209,39 @@ _loadPluginsFromPath( ) // ------------------------------------------------------------------------- void cpBaseQtApplication::MainWindow:: -_clearWorkspaces( ) -{ - this->m_Workspaces.clear( ); -} - -// ------------------------------------------------------------------------- -void cpBaseQtApplication::MainWindow:: -_addWorkspace( const std::string& name ) +_clearWorkspace( ) { - auto wIt = this->m_Workspaces.find( name ); - if( wIt == this->m_Workspaces.end( ) ) + this->setWindowTitle( this->m_BaseWindowTitle.c_str( ) ); + this->m_Workspace = TWorkspace::New( ); + if( this->m_Canvas != NULL ) { - if( this->m_SingleWorkspace ) - this->m_Workspaces.clear( ); - this->m_Workspaces[ name ] = TWorkspace::New( ); - if( this->m_Canvas != NULL ) - this->m_Canvas->setWorkspace( this->m_Workspaces[ name ] ); - if( this->m_Viewer != NULL ) - { - auto interactors = this->m_Viewer->GetInteractors( ); - auto wIt = this->m_Workspaces.find( name ); - for( auto i : interactors ) - wIt->second->AddInteractor( i ); - - } // fi - this->setWindowTitle( ( this->m_BaseWindowTitle + name ).c_str( ) ); + this->m_Canvas->clear( ); + this->m_Canvas->setWorkspace( this->m_Workspace ); } // fi -} - -// ------------------------------------------------------------------------- -void cpBaseQtApplication::MainWindow:: -_addWorkspace( ) -{ - bool ok; - QString text = - QInputDialog::getText( - this, "Creating a new workspace...", - "New workspace name: ", - QLineEdit::Normal, - "new_workspace", - &ok - ); - if( ok && !text.isEmpty( ) ) - this->_addWorkspace( text.toStdString( ) ); -} - -// ------------------------------------------------------------------------- -void cpBaseQtApplication::MainWindow:: -_saveWorkspace( const std::string& wname, const std::string& fname ) -{ - auto wIt = this->m_Workspaces.find( wname ); - if( wIt != this->m_Workspaces.end( ) ) + if( this->m_Viewer != NULL ) { - try - { - wIt->second->Save( fname ); - this->m_LastSaveFileName = fname; - } - catch( std::exception& err ) - { - QMessageBox::critical( - this, - QMessageBox::tr( "Error saving workspace" ), - QMessageBox::tr( err.what( ) ) - ); - - } // yrt - } - else - QMessageBox::critical( - this, - "Error saving workspace", - ( - std::string( "Workspace \"" ) + wname + - std::string( "\" does not exist." ) - ).c_str( ) - ); + // TODO: this->m_Viewer->clear( ); + auto interactors = this->m_Viewer->GetInteractors( ); + for( auto i : interactors ) + this->m_Workspace->AddInteractor( i ); + + } // fi } // ------------------------------------------------------------------------- void cpBaseQtApplication::MainWindow:: -_saveWorkspace( const std::string& wname, bool force ) +_saveWorkspace( const std::string& fname ) { - auto wIt = this->m_Workspaces.find( wname ); - if( wIt != this->m_Workspaces.end( ) ) - { - if( this->m_LastSaveFileName == "" || force ) - { - QFileDialog dlg( this ); - dlg.setFileMode( QFileDialog::AnyFile ); - dlg.setDirectory( "." ); - dlg.setAcceptMode( QFileDialog::AcceptSave ); - dlg.setNameFilter( - QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" ) - ); - dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) ); - dlg.setWindowTitle( - ( - std::string( "Saving \"" ) + wIt->first + std::string( "\"..." ) - ).c_str( ) - ); - if( dlg.exec( ) ) - this->_saveWorkspace( - wIt->first, dlg.selectedFiles( ).begin( )->toStdString( ) - ); - } - else - this->_saveWorkspace( wIt->first, this->m_LastSaveFileName ); - } - else - QMessageBox::critical( - this, - "Error saving workspace", - ( - std::string( "Workspace \"" ) + wname + - std::string( "\" does not exist." ) - ).c_str( ) - ); + this->m_LastSaveFileName = fname; + this->m_Workspace->Save( this->m_LastSaveFileName ); } // ------------------------------------------------------------------------- void cpBaseQtApplication::MainWindow:: _saveWorkspace( ) { - for( - auto wIt = this->m_Workspaces.begin( ); - wIt != this->m_Workspaces.end( ); - ++wIt - ) + if( this->m_LastSaveFileName == "" ) { QFileDialog dlg( this ); dlg.setFileMode( QFileDialog::AnyFile ); @@ -357,17 +251,12 @@ _saveWorkspace( ) QFileDialog::tr( "Workspace file (*.wxml);;All files (*)" ) ); dlg.setDefaultSuffix( QFileDialog::tr( "wxml" ) ); - dlg.setWindowTitle( - ( - std::string( "Saving \"" ) + wIt->first + std::string( "\"..." ) - ).c_str( ) - ); + dlg.setWindowTitle( "Saving workspace" ); if( dlg.exec( ) ) - this->_saveWorkspace( - wIt->first, dlg.selectedFiles( ).begin( )->toStdString( ) - ); - - } // rof + this->_saveWorkspace( dlg.selectedFiles( ).begin( )->toStdString( ) ); + } + else + this->_saveWorkspace( this->m_LastSaveFileName ); } // ------------------------------------------------------------------------- @@ -376,10 +265,11 @@ _loadWorkspace( const std::string& fname ) { try { - this->_addWorkspace( fname ); - this->m_Workspaces[ fname ]->Load( fname ); + this->_clearWorkspace( ); + this->m_Workspace->Load( fname ); + this->m_LastSaveFileName = ""; if( this->m_Canvas != NULL ) - this->m_Canvas->setWorkspace( this->m_Workspaces[ fname ] ); + this->m_Canvas->setWorkspace( this->m_Workspace ); } catch( std::exception& err ) { diff --git a/lib/cpBaseQtApplication/MainWindow.h b/lib/cpBaseQtApplication/MainWindow.h index 53aebf2..a29ad0f 100644 --- a/lib/cpBaseQtApplication/MainWindow.h +++ b/lib/cpBaseQtApplication/MainWindow.h @@ -74,8 +74,8 @@ namespace cpBaseQtApplication ); virtual ~MainWindow( ); - TWorkspace* workspace( const std::string& wname ); - const TWorkspace* workspace( const std::string& wname ) const; + TWorkspace* workspace( ); + const TWorkspace* workspace( ) const; Pipeline::Canvas* canvas( ); const Pipeline::Canvas* canvas( ) const; @@ -105,13 +105,9 @@ namespace cpBaseQtApplication void _loadPluginsFromPath( const std::string& path ); void _loadPluginsFromPath( ); - void _clearWorkspaces( ); + void _clearWorkspace( ); - virtual void _addWorkspace( const std::string& name ); - void _addWorkspace( ); - - void _saveWorkspace( const std::string& wname, const std::string& fname ); - void _saveWorkspace( const std::string& wname, bool force ); + void _saveWorkspace( const std::string& fname ); void _saveWorkspace( ); void _loadWorkspace( const std::string& fname ); @@ -120,13 +116,12 @@ namespace cpBaseQtApplication void _actorsProperties( ); protected: - Blocker m_Blocker; - std::string m_RunPath; - TPlugins::Pointer m_Plugins; - std::string m_LastSaveFileName; - std::map< std::string, TWorkspace::Pointer > m_Workspaces; + Blocker m_Blocker; + std::string m_RunPath; + TPlugins::Pointer m_Plugins; + std::string m_LastSaveFileName; + TWorkspace::Pointer m_Workspace; - bool m_SingleWorkspace; std::string m_BaseWindowTitle; Pipeline::Canvas* m_Canvas; diff --git a/lib/cpExtensions/Algorithms/SkeletonToImageFilter.h b/lib/cpExtensions/Algorithms/SkeletonToImageFilter.h new file mode 100644 index 0000000..8c9d8fe --- /dev/null +++ b/lib/cpExtensions/Algorithms/SkeletonToImageFilter.h @@ -0,0 +1,81 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __cpExtensions__Algorithms__SkeletonToImageFilter__h__ +#define __cpExtensions__Algorithms__SkeletonToImageFilter__h__ + +#include +#include + +// ------------------------------------------------------------------------- +namespace cpExtensions +{ + namespace Algorithms + { + /** + */ + template< class _TSkeleton, class _TImage > + class SkeletonToImageFilter + : public itk::ImageSource< _TImage > + { + public: + // Basic types + typedef SkeletonToImageFilter Self; + typedef itk::ImageSource< _TImage > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef _TSkeleton TSkeleton; + typedef _TImage TImage; + typedef typename _TImage::IndexType TIndex; + typedef typename _TImage::PixelType TPixel; + typedef typename _TImage::PointType TPoint; + typedef typename _TImage::RegionType TRegion; + typedef itk::ImageBase< _TImage::ImageDimension > TImageBase; + + public: + itkNewMacro( Self ); + itkTypeMacro( SkeletonToImageFilter, itk::ImageSource ); + + itkGetConstMacro( InsideValue, TPixel ); + itkGetConstMacro( OutsideValue, TPixel ); + + itkSetMacro( InsideValue, TPixel ); + itkSetMacro( OutsideValue, TPixel ); + + public: + const TImageBase* GetTemplateImage( ) const; + void SetTemplateImage( const TImageBase* image ); + + const TSkeleton* GetSkeleton( ) const; + void SetSkeleton( const TSkeleton* skeleton ); + + protected: + SkeletonToImageFilter( ); + virtual ~SkeletonToImageFilter( ); + + virtual void GenerateData( ) cpExtensions_OVERRIDE; + + private: + // Purposely not implemented + SkeletonToImageFilter( const Self& ); + void operator=( const Self& ); + + protected: + TPixel m_InsideValue; + TPixel m_OutsideValue; + }; + + } // ecapseman + +} // ecapseman + +// ------------------------------------------------------------------------- +#ifndef ITK_MANUAL_INSTANTIATION +# include +#endif // ITK_MANUAL_INSTANTIATION + +#endif // __cpExtensions__Algorithms__SkeletonToImageFilter__h__ + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Algorithms/SkeletonToImageFilter.hxx b/lib/cpExtensions/Algorithms/SkeletonToImageFilter.hxx new file mode 100644 index 0000000..1f428c9 --- /dev/null +++ b/lib/cpExtensions/Algorithms/SkeletonToImageFilter.hxx @@ -0,0 +1,119 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __cpExtensions__Algorithms__SkeletonToImageFilter__hxx__ +#define __cpExtensions__Algorithms__SkeletonToImageFilter__hxx__ + +// ------------------------------------------------------------------------- +template< class _TSkeleton, class _TImage > +const typename +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +TImageBase* +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +GetTemplateImage( ) const +{ + return( + dynamic_cast< const TImageBase* >( + this->itk::ProcessObject::GetInput( 0 ) + ) + ); +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton, class _TImage > +void +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +SetTemplateImage( const TImageBase* image ) +{ + this->itk::ProcessObject::SetNthInput( + 0, const_cast< TImageBase* >( image ) + ); +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton, class _TImage > +const typename +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +TSkeleton* +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +GetSkeleton( ) const +{ + return( + dynamic_cast< const TSkeleton* >( + this->itk::ProcessObject::GetInput( 1 ) + ) + ); +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton, class _TImage > +void +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +SetSkeleton( const TSkeleton* skeleton ) +{ + this->itk::ProcessObject::SetNthInput( + 1, const_cast< TSkeleton* >( skeleton ) + ); +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton, class _TImage > +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +SkeletonToImageFilter( ) + : Superclass( ), + m_InsideValue( TPixel( 1 ) ), + m_OutsideValue( TPixel( 0 ) ) +{ + this->SetNumberOfRequiredInputs( 2 ); +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton, class _TImage > +cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +~SkeletonToImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +template< class _TSkeleton, class _TImage > +void cpExtensions::Algorithms::SkeletonToImageFilter< _TSkeleton, _TImage >:: +GenerateData( ) +{ + const TSkeleton* sk = this->GetSkeleton( ); + const TImageBase* im = this->GetTemplateImage( ); + TImage* out = this->GetOutput( 0 ); + + out->SetLargestPossibleRegion( im->GetLargestPossibleRegion( ) ); + out->SetRequestedRegion( im->GetRequestedRegion( ) ); + out->SetBufferedRegion( im->GetBufferedRegion( ) ); + out->SetSpacing( im->GetSpacing( ) ); + out->SetOrigin( im->GetOrigin( ) ); + out->SetDirection( im->GetDirection( ) ); + out->Allocate( ); + out->FillBuffer( this->m_OutsideValue ); + + // Fill skeleton + auto mIt = sk->BeginEdgesRows( ); + for( ; mIt != sk->EndEdgesRows( ); ++mIt ) + { + auto rIt = mIt->second.begin( ); + for( ; rIt != mIt->second.end( ); ++rIt ) + { + auto eIt = rIt->second.begin( ); + for( ; eIt != rIt->second.end( ); ++eIt ) + { + auto path = *eIt; + for( unsigned int i = 0; i < path->GetSize( ); ++i ) + out->SetPixel( path->GetVertex( i ), this->m_InsideValue ); + + } // rof + + } // rof + + } // rof +} + +#endif // __cpExtensions__Algorithms__SkeletonToImageFilter__hxx__ + +// eof - $RCSfile$ diff --git a/lib/cpInstances/ITKNeighborhoodImageIterators.i b/lib/cpInstances/ITKNeighborhoodImageIterators.i index dd592ce..466da61 100644 --- a/lib/cpInstances/ITKNeighborhoodImageIterators.i +++ b/lib/cpInstances/ITKNeighborhoodImageIterators.i @@ -31,4 +31,7 @@ instances itk::#it#< itk::Image< #pi#, #pdims# >, itk::#co#< itk::Image< #pi#, # tinclude itkNeighborhoodAlgorithm:h|hxx instances itk::NeighborhoodAlgorithm::ImageBoundaryFacesCalculator< itk::Image< #pi#, #pdims# > > +tinclude itkNeighborhoodInnerProduct:h|hxx +instances itk::NeighborhoodInnerProduct< itk::Image< #pi#, #pdims# >, #pi#, #pi# > + ** eof - $RCSfile$ diff --git a/lib/cpPlugins/BaseObjects/Parameters.cxx b/lib/cpPlugins/BaseObjects/Parameters.cxx index 227898c..cfb5f83 100644 --- a/lib/cpPlugins/BaseObjects/Parameters.cxx +++ b/lib/cpPlugins/BaseObjects/Parameters.cxx @@ -197,12 +197,8 @@ void cpPlugins::BaseObjects::Parameters:: ConfigureAsRealTypesChoices( const std::string& name ) { std::vector< std::string > choices; -#ifdef cpPlugins_CONFIG_REAL_TYPES_float choices.push_back( "float" ); -#endif // cpPlugins_CONFIG_REAL_TYPES_float -#ifdef cpPlugins_CONFIG_REAL_TYPES_double choices.push_back( "double" ); -#endif // cpPlugins_CONFIG_REAL_TYPES_double this->ConfigureAsChoices( name, choices ); } @@ -211,22 +207,14 @@ void cpPlugins::BaseObjects::Parameters:: ConfigureAsIntTypesChoices( const std::string& name ) { std::vector< std::string > choices; -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char choices.push_back( "char" ); choices.push_back( "uchar" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_char -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short choices.push_back( "short" ); choices.push_back( "ushort" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_short -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int choices.push_back( "int" ); choices.push_back( "uint" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_int -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long choices.push_back( "long" ); choices.push_back( "ulong" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_long this->ConfigureAsChoices( name, choices ); } @@ -235,28 +223,16 @@ void cpPlugins::BaseObjects::Parameters:: ConfigureAsScalarTypesChoices( const std::string& name ) { std::vector< std::string > choices; -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_char choices.push_back( "char" ); choices.push_back( "uchar" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_char -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_short choices.push_back( "short" ); choices.push_back( "ushort" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_short -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_int choices.push_back( "int" ); choices.push_back( "uint" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_int -#ifdef cpPlugins_CONFIG_INTEGER_TYPES_long choices.push_back( "long" ); choices.push_back( "ulong" ); -#endif // cpPlugins_CONFIG_INTEGER_TYPES_long -#ifdef cpPlugins_CONFIG_REAL_TYPES_float choices.push_back( "float" ); -#endif // cpPlugins_CONFIG_REAL_TYPES_float -#ifdef cpPlugins_CONFIG_REAL_TYPES_double choices.push_back( "double" ); -#endif // cpPlugins_CONFIG_REAL_TYPES_double this->ConfigureAsChoices( name, choices ); } diff --git a/lib/cpPlugins/Interface/Workspace.cxx b/lib/cpPlugins/Interface/Workspace.cxx index 5b80a36..8eca620 100644 --- a/lib/cpPlugins/Interface/Workspace.cxx +++ b/lib/cpPlugins/Interface/Workspace.cxx @@ -1,6 +1,35 @@ #include #include +// ------------------------------------------------------------------------- +cpPlugins::Interface::Workspace:: +Pointer cpPlugins::Interface::Workspace:: +New( ) +{ + Pointer smartPtr = new Self; + smartPtr->UnRegister( ); + return( smartPtr ); +} + +// ------------------------------------------------------------------------- +itk::LightObject::Pointer cpPlugins::Interface::Workspace:: +CreateAnother( ) const +{ + itk::LightObject::Pointer smartPtr; + smartPtr = Self::New( ).GetPointer( ); + return( smartPtr ); +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::Workspace:: +Pointer cpPlugins::Interface::Workspace:: +Clone( ) const +{ + Pointer rval = + dynamic_cast< Self* >( this->InternalClone( ).GetPointer( ) ); + return( rval ); +} + // ------------------------------------------------------------------------- void cpPlugins::Interface::Workspace:: Clear( ) diff --git a/lib/cpPlugins/Interface/Workspace.h b/lib/cpPlugins/Interface/Workspace.h index 73db780..7d76c05 100644 --- a/lib/cpPlugins/Interface/Workspace.h +++ b/lib/cpPlugins/Interface/Workspace.h @@ -38,10 +38,14 @@ namespace cpPlugins */ public: - itkNewMacro( Self ); itkTypeMacro( Workspace, itk::Object ); public: + // Factory methods + static Pointer New( ); + virtual itk::LightObject::Pointer CreateAnother( ) const cpPlugins_OVERRIDE; + Pointer Clone( ) const; + // Workspace IO void Load( const std::string& fname ); void Save( const std::string& fname ) const; @@ -72,36 +76,6 @@ namespace cpPlugins // Interactors void AddInteractor( vtkRenderWindowInteractor* iren ); - // Exposed ports - /* TODO - const TExposedPorts& GetExposedInputs( ) const; - const TExposedPorts& GetExposedOutputs( ) const; - cpPlugins::BaseObjects::DataObject* GetExposedOutput( - const std::string& name - ); - const cpPlugins::BaseObjects::DataObject* GetExposedOutput( - const std::string& name - ) const; - bool ExposeInput( - const std::string& name, - const std::string& filter, const std::string& filter_input - ); - bool ExposeOutput( - const std::string& name, - const std::string& filter, const std::string& filter_output - ); - void HideInput( const std::string& name ); - void HideOutput( const std::string& name ); - bool RenameExposedInput( - const std::string& old_name, - const std::string& new_name - ); - bool RenameExposedOutput( - const std::string& old_name, - const std::string& new_name - ); - */ - // Connection management bool Connect( const std::string& origin_filter, diff --git a/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.cxx b/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.cxx new file mode 100644 index 0000000..775b7c0 --- /dev/null +++ b/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.cxx @@ -0,0 +1,71 @@ +#include +#include + +#include + +// ------------------------------------------------------------------------- +cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter:: +CurvatureAnisotropicDiffusionImageFilter( ) + : Superclass( ) +{ + typedef cpInstances::Image _TImage; + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureOutput< _TImage >( "Output" ); + + this->m_Parameters.ConfigureAsUint( "NumberOfIterations", 5 ); + this->m_Parameters.ConfigureAsBool( "UseImageSpacing", false ); + this->m_Parameters.ConfigureAsReal( "ConductanceParameter", 3 ); + this->m_Parameters.ConfigureAsReal( "TimeStep", 0.0625 ); + this->m_Parameters.ConfigureAsRealTypesChoices( "OutputResolution" ); +} + +// ------------------------------------------------------------------------- +cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter:: +~CurvatureAnisotropicDiffusionImageFilter( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "No valid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter:: +_GD0( _TImage* image ) +{ + std::string out_res = + this->m_Parameters.GetSelectedChoice( "OutputResolution" ); + if( out_res == "float" ) this->_GD1< _TImage, float >( image ); + if( out_res == "double" ) this->_GD1< _TImage, double >( image ); +} + +// ------------------------------------------------------------------------- +template< class _TImage, class _TScalar > +void cpPluginsITKAnisotropicSmoothing::CurvatureAnisotropicDiffusionImageFilter:: +_GD1( _TImage* image ) +{ + typedef itk::Image< _TScalar, _TImage::ImageDimension > _TOutImage; + typedef + itk::CurvatureAnisotropicDiffusionImageFilter< _TImage, _TOutImage > + _TFilter; + + // Configure filter + _TFilter* filter = this->_CreateITK< _TFilter >( ); + filter->SetInput( image ); + filter->SetNumberOfIterations( this->m_Parameters.GetUint( "NumberOfIterations" ) ); + filter->SetUseImageSpacing( this->m_Parameters.GetBool( "UseImageSpacing" ) ); + filter->SetConductanceParameter( this->m_Parameters.GetReal( "ConductanceParameter" ) ); + filter->SetTimeStep( this->m_Parameters.GetReal( "TimeStep" ) ); + filter->Update( ); + + // Connect output + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); +} + +// eof - $RCSfile$ diff --git a/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h b/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h new file mode 100644 index 0000000..d11d39e --- /dev/null +++ b/plugins/ITKAnisotropicSmoothing/CurvatureAnisotropicDiffusionImageFilter.h @@ -0,0 +1,32 @@ +#ifndef __cpPluginsITKAnisotropicSmoothing__CurvatureAnisotropicDiffusionImageFilter__h__ +#define __cpPluginsITKAnisotropicSmoothing__CurvatureAnisotropicDiffusionImageFilter__h__ + +#include +#include + +namespace cpPluginsITKAnisotropicSmoothing +{ + /** + */ + class cpPluginsITKAnisotropicSmoothing_EXPORT CurvatureAnisotropicDiffusionImageFilter + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + CurvatureAnisotropicDiffusionImageFilter, + cpPlugins::BaseObjects::ProcessObject, + ImageSmoothing + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* image ); + + template< class _TImage, class _TScalar > + inline void _GD1( _TImage* image ); + }; + +} // ecapseman + +#endif // __cpPluginsITKAnisotropicSmoothing__CurvatureAnisotropicDiffusionImageFilter__h__ + +// eof - $RCSfile$ diff --git a/plugins/ITKAnisotropicSmoothing/ITKAnisotropicSmoothing.i b/plugins/ITKAnisotropicSmoothing/ITKAnisotropicSmoothing.i index 3077c6a..d87073b 100644 --- a/plugins/ITKAnisotropicSmoothing/ITKAnisotropicSmoothing.i +++ b/plugins/ITKAnisotropicSmoothing/ITKAnisotropicSmoothing.i @@ -1,6 +1,6 @@ header #define ITK_MANUAL_INSTANTIATION -define functions=ScalarAnisotropicDiffusionFunction;GradientNDAnisotropicDiffusionFunction +define functions=ScalarAnisotropicDiffusionFunction;GradientNDAnisotropicDiffusionFunction;CurvatureNDAnisotropicDiffusionFunction tinclude itk#functions#:h|hxx instances itk::#functions#< itk::Image< #scalar_types#, #pdims# > > diff --git a/plugins/ITKDistanceMapFilters/SignedMaurerDistanceMapImageFilter.cxx b/plugins/ITKDistanceMapFilters/SignedMaurerDistanceMapImageFilter.cxx index e62f1df..5f5cc64 100644 --- a/plugins/ITKDistanceMapFilters/SignedMaurerDistanceMapImageFilter.cxx +++ b/plugins/ITKDistanceMapFilters/SignedMaurerDistanceMapImageFilter.cxx @@ -35,6 +35,7 @@ void cpPluginsITKDistanceMapFilters::SignedMaurerDistanceMapImageFilter:: _GenerateData( ) { auto o = this->GetInputData( "Input" ); + std::cout << o << std::endl; cpPlugins_Demangle_Image_ScalarPixels_VisualDims_1( o, _GD0 ) this->_Error( "Invalid input image dimension." ); } @@ -59,6 +60,7 @@ _GD1( _TImage* image ) typedef itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap > _TFilter; + std::cout << "_Z" << typeid( _TFilter ).name( ) << std::endl; // Get parameters double bv = this->m_Parameters.GetReal( "BackgroundValue" ); diff --git a/plugins/ITKImageGenericFilters_1/ITKImageGenericFilters_1.i b/plugins/ITKImageGenericFilters_1/ITKImageGenericFilters_1.i index 29f0e0f..2fa060e 100644 --- a/plugins/ITKImageGenericFilters_1/ITKImageGenericFilters_1.i +++ b/plugins/ITKImageGenericFilters_1/ITKImageGenericFilters_1.i @@ -9,4 +9,7 @@ define o_scalars=#scalar_types# tinclude itk#filters_1#:h|hxx instances itk::#filters_1#< itk::Image< #i_scalars#, #pdims# >, itk::Image< #o_scalars#, #pdims# > > +tinclude itkMinimumMaximumImageCalculator:h|hxx +instances itk::MinimumMaximumImageCalculator< itk::Image< #scalar_types#, #pdims# > > + ** eof - $RCSfile$ diff --git a/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx b/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx new file mode 100644 index 0000000..69bc70b --- /dev/null +++ b/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.cxx @@ -0,0 +1,120 @@ +#include +#include +#include + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: +MinimumMaximumImageCalculator( ) + : Superclass( ) +{ + typedef cpInstances::Image _TImage; + typedef cpInstances::Mesh _TMesh; + + this->_ConfigureInput< _TImage >( "Input", true, false ); + this->_ConfigureOutput< _TMesh >( "Maximum" ); + this->_ConfigureOutput< _TMesh >( "Minimum" ); +} + +// ------------------------------------------------------------------------- +cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: +~MinimumMaximumImageCalculator( ) +{ +} + +// ------------------------------------------------------------------------- +void cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: +_GenerateData( ) +{ + auto o = this->GetInputData( "Input" ); + cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 ) + this->_Error( "Invalid input image." ); +} + +// ------------------------------------------------------------------------- +template< class _TImage > +void cpPluginsITKImageGenericFilters_1::MinimumMaximumImageCalculator:: +_GD0( _TImage* input ) +{ + typedef itk::MinimumMaximumImageCalculator< _TImage > _TFilter; + typedef typename _TImage::IndexType _TIndex; + typedef typename _TImage::PointType _TPoint; + + auto filter = this->_CreateITK< _TFilter >( ); + filter->SetImage( input ); + filter->Compute( ); + + _TIndex min_idx = filter->GetIndexOfMinimum( ); + _TIndex max_idx = filter->GetIndexOfMaximum( ); + + _TPoint min_pnt, max_pnt; + input->TransformIndexToPhysicalPoint( min_idx, min_pnt ); + input->TransformIndexToPhysicalPoint( max_idx, max_pnt ); + + auto min_pd = this->GetOutputData< vtkPolyData >( "Minimum" ); + if( min_pd == NULL ) + { + auto points = vtkSmartPointer< vtkPoints >::New( ); + auto verts = vtkSmartPointer< vtkCellArray >::New( ); + auto lines = vtkSmartPointer< vtkCellArray >::New( ); + auto polys = vtkSmartPointer< vtkCellArray >::New( ); + auto strips = vtkSmartPointer< vtkCellArray >::New( ); + auto pd = vtkSmartPointer< vtkPolyData >::New( ); + pd->SetPoints( points ); + pd->SetVerts( verts ); + pd->SetLines( lines ); + pd->SetPolys( polys ); + pd->SetStrips( strips ); + + points->InsertNextPoint( 0, 0, 0 ); + verts->InsertNextCell( 1 ); + verts->InsertCellPoint( 0 ); + + this->GetOutput( "Minimum" )->SetVTK( pd ); + min_pd = this->GetOutputData< vtkPolyData >( "Minimum" ); + + } // fi + + if( _TImage::ImageDimension == 1 ) + min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], 0, 0 ); + else if( _TImage::ImageDimension == 2 ) + min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], 0 ); + else if( _TImage::ImageDimension > 2 ) + min_pd->GetPoints( )->SetPoint( 0, min_pnt[ 0 ], min_pnt[ 1 ], min_pnt[ 2 ] ); + + auto max_pd = this->GetOutputData< vtkPolyData >( "Maximum" ); + if( max_pd == NULL ) + { + auto points = vtkSmartPointer< vtkPoints >::New( ); + auto verts = vtkSmartPointer< vtkCellArray >::New( ); + auto lines = vtkSmartPointer< vtkCellArray >::New( ); + auto polys = vtkSmartPointer< vtkCellArray >::New( ); + auto strips = vtkSmartPointer< vtkCellArray >::New( ); + auto pd = vtkSmartPointer< vtkPolyData >::New( ); + pd->SetPoints( points ); + pd->SetVerts( verts ); + pd->SetLines( lines ); + pd->SetPolys( polys ); + pd->SetStrips( strips ); + + points->InsertNextPoint( 0, 0, 0 ); + verts->InsertNextCell( 1 ); + verts->InsertCellPoint( 0 ); + + this->GetOutput( "Maximum" )->SetVTK( pd ); + max_pd = this->GetOutputData< vtkPolyData >( "Maximum" ); + + } // fi + + if( _TImage::ImageDimension == 1 ) + max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], 0, 0 ); + else if( _TImage::ImageDimension == 2 ) + max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], 0 ); + else if( _TImage::ImageDimension > 2 ) + max_pd->GetPoints( )->SetPoint( 0, max_pnt[ 0 ], max_pnt[ 1 ], max_pnt[ 2 ] ); +} + +// eof - $RCSfile$ diff --git a/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h b/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h new file mode 100644 index 0000000..50519b1 --- /dev/null +++ b/plugins/ITKImageGenericFilters_1/MinimumMaximumImageCalculator.h @@ -0,0 +1,29 @@ +#ifndef __cpPluginsITKImageGenericFilters_1__MinimumMaximumImageCalculator__h__ +#define __cpPluginsITKImageGenericFilters_1__MinimumMaximumImageCalculator__h__ + +#include +#include + +namespace cpPluginsITKImageGenericFilters_1 +{ + /** + */ + class cpPluginsITKImageGenericFilters_1_EXPORT MinimumMaximumImageCalculator + : public cpPlugins::BaseObjects::ProcessObject + { + cpPluginsObject( + MinimumMaximumImageCalculator, + cpPlugins::BaseObjects::ProcessObject, + ImageFeatures + ); + + protected: + template< class _TImage > + inline void _GD0( _TImage* input ); + }; + +} // ecapseman + +#endif // __cpPluginsImageGenericFilters__MinimumMaximumImageCalculator__h__ + +// eof - $RCSfile$ diff --git a/plugins/ITKMorphology/ITKMorphology.i b/plugins/ITKMorphology/ITKMorphology.i index 0ac9aab..212fd21 100644 --- a/plugins/ITKMorphology/ITKMorphology.i +++ b/plugins/ITKMorphology/ITKMorphology.i @@ -1,6 +1,7 @@ -header #define ITK_MANUAL_INSTANTIATION +** TODO: +header #undef ITK_MANUAL_INSTANTIATION tinclude itkBinaryFillholeImageFilter:h|hxx -instances itk::BinaryFillholeImageFilter< itk::Image< #scalar_types#, #pdims# > > +instances itk::BinaryFillholeImageFilter< itk::Image< #scalar_types#, #vdims# > > ** eof - $RCSfile$ -- 2.47.1