From 941461b8f382ba33c608dfc2a9b1f3e0af7e19e2 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Mon, 11 Apr 2016 18:14:44 -0500 Subject: [PATCH] ... --- appli/bash/CMakeLists.txt | 1 + cmake/cpPluginsConfig.cmake.in | 66 +++--- cmake/cpPlugins_Functions.cmake | 8 +- .../ScalarVectorImagesBaseFilters.i | 1 + plugins/cpPluginsWidgets/SeedWidget.cxx | 212 +++++------------- plugins/cpPluginsWidgets/SeedWidget.h | 6 - 6 files changed, 99 insertions(+), 195 deletions(-) diff --git a/appli/bash/CMakeLists.txt b/appli/bash/CMakeLists.txt index 221ab37..6d2c288 100644 --- a/appli/bash/CMakeLists.txt +++ b/appli/bash/CMakeLists.txt @@ -21,6 +21,7 @@ FOREACH(source ${all_SOURCE_CXX_FILES}) LIBRARY DESTINATION lib ARCHIVE DESTINATION lib/static ) + SET(${name}_APP ${name} CACHE INTERNAL "bash program ${name}") ENDFOREACH(source) ## eof - $RCSfile$ diff --git a/cmake/cpPluginsConfig.cmake.in b/cmake/cpPluginsConfig.cmake.in index a07c54c..0fcd499 100644 --- a/cmake/cpPluginsConfig.cmake.in +++ b/cmake/cpPluginsConfig.cmake.in @@ -3,46 +3,41 @@ # =================================== SET(USE_QT4 "@QT4_FOUND@") - -# ======================= -# == Find dependencies == -# ======================= - -# Find ITK and VTK SET(ITK_DIR @ITK_DIR@) -FIND_PACKAGE(ITK REQUIRED) -INCLUDE(${ITK_USE_FILE}) - SET(VTK_DIR @VTK_DIR@) -FIND_PACKAGE(VTK REQUIRED) -INCLUDE(${VTK_USE_FILE}) - -# Do not use itk-vtk glue ==> problems ahead!!! -IF(ITKVtkGlue_LOADED) - MESSAGE(FATAL_ERROR "ITKVtkGlue module is available. Please re-compile your ITK without it. It could lead to nasty compilation problems... Just waiting for Kitware to solve it.") -ENDIF(ITKVtkGlue_LOADED) - IF(USE_QT4 EQUAL "1") SET(QT_QMAKE_EXECUTABLE @QT_QMAKE_EXECUTABLE@) - FIND_PACKAGE(Qt4 REQUIRED) - INCLUDE(${QT_USE_FILE}) - - ## Check for required vtk-qt4 modules - SET( - vtk_required_modules - vtkGUISupportQt - vtkGUISupportQtOpenGL - ) - FOREACH(vtk_module ${vtk_required_modules}) - IF(NOT ${vtk_module}_LOADED) - MESSAGE( - FATAL_ERROR - "${vtk_module} module is required but not available." - ) - ENDIF(NOT ${vtk_module}_LOADED) - ENDFOREACH(vtk_module) ENDIF(USE_QT4 EQUAL "1") +# =========================== +# == Include cmake scripts == +# =========================== + +FIND_FILE( + cpPlugins_FUNCTIONS + NAMES cpPlugins_Functions.cmake + HINTS /usr/share/cmake /usr/local/share/cmake + PATHS @CMAKE_INSTALL_PREFIX@/share/cmake @PROJECT_SOURCE_DIR@/cmake + DOC "Where is \"cpPlugins_Functions.cmake\"?" + ) +IF(NOT cpPlugins_FUNCTIONS) + MESSAGE(FATAL_ERROR "Where is \"cpPlugins_Functions.cmake\"?") +ENDIF(NOT cpPlugins_FUNCTIONS) +GET_FILENAME_COMPONENT( + cpPlugins_FUNCTIONS_ABSOLUTE ${cpPlugins_FUNCTIONS} + ABSOLUTE + ) +GET_FILENAME_COMPONENT( + cpPlugins_CMAKE_DIR ${cpPlugins_FUNCTIONS_ABSOLUTE} + DIRECTORY + ) +INCLUDE(${cpPlugins_FUNCTIONS}) +INCLUDE(${cpPlugins_CMAKE_DIR}) +INCLUDE(${cpPlugins_CMAKE_DIR}/cpPlugins_Options.cmake) +INCLUDE(${cpPlugins_CMAKE_DIR}/cpPlugins_KitwareTools.cmake) +IF(USE_QT4 EQUAL "1") + INCLUDE(${cpPlugins_CMAKE_DIR}/cpPlugins_Qt4Tools.cmake) +ENDIF(USE_QT4 EQUAL "1") # ========================= # == Include directories == @@ -106,6 +101,7 @@ SET( FOREACH(prog ${exec_PROGRAMS}) IF(MSVC) FIND_PROGRAM( + ${prog}_APP NAMES ${prog} HINTS /usr /usr/local PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@/Debug @PROJECT_BINARY_DIR@/Release @PROJECT_BINARY_DIR@/MinSizeRel @PROJECT_BINARY_DIR@/RelWithDebInfo @@ -114,7 +110,7 @@ FOREACH(prog ${exec_PROGRAMS}) ) ELSE(MSVC) FIND_PROGRAM( - ${prog} + ${prog}_APP NAMES ${prog} HINTS /usr /usr/local PATHS @CMAKE_INSTALL_PREFIX@/bin @PROJECT_BINARY_DIR@ diff --git a/cmake/cpPlugins_Functions.cmake b/cmake/cpPlugins_Functions.cmake index ca9644e..d2ec9ca 100644 --- a/cmake/cpPlugins_Functions.cmake +++ b/cmake/cpPlugins_Functions.cmake @@ -10,8 +10,8 @@ SET(l_NAME "${libprefix}${name}") SET(x_FILE "${CMAKE_CURRENT_BINARY_DIR}/${l_NAME}_Export.h") ADD_CUSTOM_COMMAND( OUTPUT ${h_FILE} ${s_FILE} - DEPENDS cpPlugins_CreateInstances ${i_FILE} - COMMAND cpPlugins_CreateInstances ${i_FILE} ${l_NAME} ${h_FILE} ${s_FILE} + DEPENDS ${cpPlugins_CreateInstances_APP} ${i_FILE} + COMMAND ${cpPlugins_CreateInstances_APP} ${i_FILE} ${l_NAME} ${h_FILE} ${s_FILE} ) IF(EXISTS ${e_FILE}) ADD_LIBRARY(${l_NAME} SHARED ${s_FILE} ${e_FILE}) @@ -38,8 +38,8 @@ FUNCTION(cpPlugins_WrapPlugins libname ver sver headers sources other_sources qt SET(host ${CMAKE_CURRENT_BINARY_DIR}/${libname}_Host.cxx) ADD_CUSTOM_COMMAND( OUTPUT ${host} - DEPENDS cpPlugins_HostCreator ${headers} - COMMAND cpPlugins_HostCreator ${host} ${headers} + DEPENDS ${cpPlugins_HostCreator_APP} ${headers} + COMMAND ${cpPlugins_HostCreator_APP} ${host} ${headers} ) ADD_LIBRARY(${libname} SHARED ${host} ${sources} ${other_sources}) SET_TARGET_PROPERTIES( diff --git a/lib/cpPlugins_Instances/ScalarVectorImagesBaseFilters.i b/lib/cpPlugins_Instances/ScalarVectorImagesBaseFilters.i index c017bf9..4b47a37 100644 --- a/lib/cpPlugins_Instances/ScalarVectorImagesBaseFilters.i +++ b/lib/cpPlugins_Instances/ScalarVectorImagesBaseFilters.i @@ -15,5 +15,6 @@ t itk{#itk_filters}Filter.h * = Base filter types = * ===================== c itk::{#itk_filters}Filter< itk::Image< #pixels, #dims >, itk::Image< itk::CovariantVector< #floats, #dims >, #dims > > +c itk::{#itk_filters}Filter< itk::Image< itk::CovariantVector< #floats, #dims >, #dims >, itk::Image< #floats, #dims > > * eof - $RCSfile$ diff --git a/plugins/cpPluginsWidgets/SeedWidget.cxx b/plugins/cpPluginsWidgets/SeedWidget.cxx index 03e7215..b65d29f 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.cxx +++ b/plugins/cpPluginsWidgets/SeedWidget.cxx @@ -1,6 +1,7 @@ #include "SeedWidget.h" #include +#include #include #include #include @@ -23,9 +24,6 @@ SeedWidget( ) { this->_AddInput( "ReferenceImage" ); this->_AddOutput< cpPlugins::DataObject >( "Output" ); - - this->m_Parameters.ConfigureAsBool( "SeedsAreInRealSpace" ); - this->m_Parameters.SetBool( "SeedsAreInRealSpace", false ); } // ------------------------------------------------------------------------- @@ -49,167 +47,81 @@ template< class _TImage > std::string cpPluginsWidgets::SeedWidget:: _GD0( _TImage* image ) { - if( image != NULL ) - { - if( this->m_Parameters.GetBool( "SeedsAreInRealSpace" ) ) - return( this->_GD1_Points( image ) ); - else - return( this->_GD1_Vertices( image ) ); - } - else - return( "Widgets::SeedWidget: Input image dimension not supported." ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -std::string cpPluginsWidgets::SeedWidget:: -_GD1_Points( _TImage* image ) -{ + typedef + cpExtensions::DataStructures::ImageIndexesContainer< _TImage::ImageDimension > + _TContainer; typedef cpExtensions::Interaction::ImageInteractorStyle _S; - typedef itk::Point< double, _TImage::ImageDimension > _P; - typedef itk::SimpleDataObjectDecorator< std::vector< _P > > _Container; - - auto container = this->_CreateITK< _Container >( ); - double aux_pnt[ 3 ]; - unsigned int dim = ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; - - container->Get( ).clear( ); - - // MPR - if( this->m_MPRViewer != NULL ) + if( image != NULL ) { - for( unsigned int i = 0; i < 4; ++i ) + 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 ) { - _S* s = - dynamic_cast< _S* >( - this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( ) - ); - if( s != NULL ) + for( unsigned int i = 0; i < 4; ++i ) { - if( this->m_Configured ) + _S* s = + dynamic_cast< _S* >( + this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( ) + ); + if( s != NULL ) { - for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) + if( this->m_Configured ) { - s->GetSeedAsPoint( i, aux_pnt ); - _P seed; - for( unsigned int d = 0; d < dim; ++d ) - seed[ d ] = aux_pnt[ d ]; - container->Get( ).push_back( 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 ); - _P seed; - for( unsigned int d = 0; d < dim; ++d ) - seed[ d ] = aux_pnt[ d ]; - container->Get( ).push_back( seed ); + 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 - } - else - s->SeedWidgetOn( ); - - } // fi - this->m_Configured = true; - this->GetOutputData( "Output" )->SetITK( container ); - return( "" ); -} - -// ------------------------------------------------------------------------- -template< class _TImage > -std::string cpPluginsWidgets::SeedWidget:: -_GD1_Vertices( _TImage* image ) -{ - typedef cpExtensions::Interaction::ImageInteractorStyle _S; - typedef - itk::SimpleDataObjectDecorator< std::vector< typename _TImage::IndexType > > - _Container; - auto container = this->_CreateITK< _Container >( ); - - double aux_pnt[ 3 ]; - unsigned int dim = ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; + } // fi - container->Get( ).clear( ); - - // MPR - if( this->m_MPRViewer != NULL ) - { - for( unsigned int i = 0; i < 4; ++i ) + // Single interactor + _S* s = dynamic_cast< _S* >( this->m_SingleInteractor ); + if( s != NULL ) { - _S* s = - dynamic_cast< _S* >( - this->m_MPRViewer->GetInteractor( i )->GetInteractorStyle( ) - ); - if( s != NULL ) + if( this->m_Configured ) { - if( this->m_Configured ) + for( unsigned int i = 0; i < s->GetNumberOfSeeds( ); ++i ) { - 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; - - this->GetOutputData( "Output" )->SetITK( container ); - return( "" ); + 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$ diff --git a/plugins/cpPluginsWidgets/SeedWidget.h b/plugins/cpPluginsWidgets/SeedWidget.h index 2ae4976..52f61c5 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.h +++ b/plugins/cpPluginsWidgets/SeedWidget.h @@ -34,12 +34,6 @@ namespace cpPluginsWidgets template< class _TImage > inline std::string _GD0( _TImage* image ); - template< class _TImage > - inline std::string _GD1_Points( _TImage* image ); - - template< class _TImage > - inline std::string _GD1_Vertices( _TImage* image ); - private: // Purposely not implemented SeedWidget( const Self& ); -- 2.47.1