From: Leonardo Flórez-Valencia Date: Fri, 11 Nov 2016 23:26:33 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e67f9079d9ea9941c512a904fb1999b1ed043729;p=FrontAlgorithms.git ... --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4175ddb..fec6ee2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,6 @@ INCLUDE(cmake/Functions.cmake) ## =========================== ## SUBDIRS(appli cmake lib plugins) -SUBDIRS(lib plugins) +SUBDIRS(lib) ## eof - $RCSfile$ diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 02ec213..aebf89f 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -60,6 +60,7 @@ ENDFUNCTION() ## ------------------------------------------------------------------------- FUNCTION( PrepareSourceFiles + out_lib_name out_sources_list out_headers_list out_headers_paths @@ -69,6 +70,7 @@ SET(_sources_extensions .c .cpp .cxx) SET(_headers_extensions .h .hpp .hxx) SET(_qt_ui_extensions .ui) SET(_demangler_extensions .d) +SET(_instances_extensions .i) ## -- Configure inputs SET(_all_files) @@ -98,12 +100,14 @@ SET(_srcs) SET(_hdrs) SET(_qts) SET(_demanglers) +SET(_instances) FOREACH(_file ${_all_files}) GET_FILENAME_COMPONENT(_ext ${_file} EXT) LIST(FIND _sources_extensions ${_ext} _src) LIST(FIND _headers_extensions ${_ext} _hdr) LIST(FIND _qt_ui_extensions ${_ext} _ui) LIST(FIND _demangler_extensions ${_ext} _dem) + LIST(FIND _instances_extensions ${_ext} _ins) IF(NOT ${_src} EQUAL -1) LIST(APPEND _srcs ${_file}) ENDIF(NOT ${_src} EQUAL -1) @@ -116,6 +120,9 @@ FOREACH(_file ${_all_files}) IF(NOT ${_dem} EQUAL -1) LIST(APPEND _demanglers ${_file}) ENDIF(NOT ${_dem} EQUAL -1) + IF(NOT ${_ins} EQUAL -1) + LIST(APPEND _instances ${_file}) + ENDIF(NOT ${_ins} EQUAL -1) ENDFOREACH(_file) # -- Prepare Qt4-based code @@ -156,6 +163,36 @@ FOREACH(_d ${_demanglers}) LIST(APPEND _hdrs ${_d_out}) ENDFOREACH(_d) +## -- Create instances +FOREACH(_i ${_instances}) + STRING( + REPLACE + ${PROJECT_SOURCE_DIR} + ${PROJECT_BINARY_DIR} + _i_bin + ${_i} + ) + GET_FILENAME_COMPONENT(_i_path ${_i_bin} DIRECTORY) + GET_FILENAME_COMPONENT(_out_name ${_i} NAME_WE) + + ## -- Infere source code filenames + MATH(EXPR _last_range "${cpPlugins_CONFIG_NUMBER_OF_FILES}-1") + SET(_out_code "${_i_path}/${_out_name}.h") + LIST(APPEND _hdrs ${_i_path}/${_out_name}.h) + FOREACH(_n RANGE 0 ${_last_range}) + LIST(APPEND _out_code ${_i_path}/${_out_name}_${_n}.cxx) + LIST(APPEND _srcs ${_i_path}/${_out_name}_${_n}.cxx) + ENDFOREACH(_n) + + ## -- Command to write source code + ADD_CUSTOM_COMMAND( + OUTPUT ${_out_code} + DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_i} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_i_path} + COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_i} ${out_lib_name} ${_i_path}/${_out_name} + ) +ENDFOREACH(_i) + ## -- Real compilation SET(_hdrs_paths) FOREACH(_hdr ${_hdrs}) @@ -178,7 +215,7 @@ FUNCTION( lib_name lib_type ) -PrepareSourceFiles(_srcs _hdrs _paths ${ARGN}) +PrepareSourceFiles(${lib_name} _srcs _hdrs _paths ${ARGN}) INCLUDE_DIRECTORIES( ${_paths} ${CMAKE_CURRENT_SOURCE_DIR} @@ -214,87 +251,23 @@ FILE(GLOB_RECURSE _files "${lib_dir}/*") CreateLib(${lib_name} ${lib_type} ${_files} ${ARGN}) ENDFUNCTION() -## ------------------------------------------------------------------------- -FUNCTION( - CompileInstances - out_lib_name - def_file - number_of_files - ) - -### -- Configure inputs to be cmake-path compatible -SET(_src_dir ${CMAKE_CURRENT_SOURCE_DIR}) -SET(_bin_dir ${CMAKE_CURRENT_BINARY_DIR}) -SET(_def_file "${_src_dir}/${def_file}") - -## -- Infere source code filenames -MATH(EXPR _last_range "${number_of_files}-1") -SET(_out_code "${_bin_dir}/${out_lib_name}.h") -FOREACH(_n RANGE 0 ${_last_range}) - LIST(APPEND _out_code ${_bin_dir}/${out_lib_name}_${_n}.cxx) -ENDFOREACH(_n) - -## -- Command to write source code -ADD_CUSTOM_COMMAND( - OUTPUT ${_out_code} - DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_def_file} - COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_def_file} ${out_lib_name} ${_bin_dir} ${number_of_files} - ) - -## -- Create library -CreateLib(${out_lib_name} SHARED "${_out_code}") - -ENDFUNCTION() - ## ------------------------------------------------------------------------- FUNCTION( CreatePlugin lib_name lib_dir - number_of_files ) - GET_FILENAME_COMPONENT(_lib_dir ${lib_dir} REALPATH) FILE(GLOB_RECURSE _files "${_lib_dir}/*") SET(_hdr_to_wrap) -SET(_instances) FOREACH(_file ${_files}) FILE(READ ${_file} _txt) STRING(FIND "${_txt}" "cpPluginsObject" _res) IF(NOT ${_res} EQUAL -1) LIST(APPEND _hdr_to_wrap ${_file}) ENDIF(NOT ${_res} EQUAL -1) - GET_FILENAME_COMPONENT(_ext ${_file} EXT) - IF(${_ext} STREQUAL ".i") - LIST(APPEND _instances ${_file}) - ENDIF(${_ext} STREQUAL ".i") ENDFOREACH(_file) -IF(_instances) - FOREACH(_instance ${_instances}) - STRING( - REPLACE - ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} - _out_dir - ${_lib_dir} - ) - MATH(EXPR _last_range "${number_of_files}-1") - SET(_out_code "${_out_dir}/${lib_name}.h") - FOREACH(_n RANGE 0 ${_last_range}) - LIST(APPEND _out_code ${_out_dir}/${lib_name}_${_n}.cxx) - ENDFOREACH(_n) - - ADD_CUSTOM_COMMAND( - OUTPUT ${_out_code} - DEPENDS ${cpPlugins_bash_CreateInstances_APP} ${_instance} - COMMAND ${CMAKE_COMMAND} -E make_directory ${_out_dir} - COMMAND ${cpPlugins_bash_CreateInstances_APP} ${_instance} ${lib_name} ${_out_dir} ${number_of_files} - ) - LIST(APPEND _files ${_out_code}) - ENDFOREACH(_instance) -ENDIF(_instances) - IF(_hdr_to_wrap) STRING( REPLACE @@ -323,22 +296,25 @@ FUNCTION( app_name app_dir ) -FILE(GLOB_RECURSE _files "${app_dir}/*") -PrepareSourceFiles(_srcs _hdrs _paths ${_files} ${ARGN}) -INCLUDE_DIRECTORIES( - ${_paths} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ) -IF(_srcs) - SET(_app_os_target) - IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - SET(_app_os_target WIN32) - ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - SET(_app_os_target MACOSX_BUNDLE) - ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs}) -ENDIF(_srcs) +OPTION(BUILD_${app_name} "Build ${app_name}" OFF) +IF(BUILD_${app_name}) + FILE(GLOB_RECURSE _files "${app_dir}/*") + PrepareSourceFiles(${app_name} _srcs _hdrs _paths ${_files} ${ARGN}) + INCLUDE_DIRECTORIES( + ${_paths} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) + IF(_srcs) + SET(_app_os_target) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(_app_os_target WIN32) + ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + SET(_app_os_target MACOSX_BUNDLE) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ADD_EXECUTABLE(${app_name} ${_app_os_target} ${_srcs} ${_hdrs}) + ENDIF(_srcs) +ENDIF(BUILD_${app_name}) ENDFUNCTION() ## eof - $RCSfile$ diff --git a/cmake/KitwareTools.cmake b/cmake/KitwareTools.cmake index a120bb2..b4493d2 100644 --- a/cmake/KitwareTools.cmake +++ b/cmake/KitwareTools.cmake @@ -3,9 +3,9 @@ # ====================== FIND_PACKAGE(ITK REQUIRED) -INCLUDE(${ITK_USE_FILE}) - FIND_PACKAGE(VTK REQUIRED) + +INCLUDE(${ITK_USE_FILE}) INCLUDE(${VTK_USE_FILE}) # =================================================== diff --git a/cmake/QtTools.cmake b/cmake/QtTools.cmake index a49b3d5..8e884b0 100644 --- a/cmake/QtTools.cmake +++ b/cmake/QtTools.cmake @@ -2,14 +2,14 @@ ## == Find Qt4 and check if it was well configured == ## ================================================== -SET(QT4_FOUND "0") +OPTION(USE_QT4 "Build Qt4-based code" OFF) IF(USE_QT4) + SET(QT4_FOUND "0") FIND_PACKAGE(Qt4 REQUIRED) INCLUDE(${QT_USE_FILE}) SET( _modules vtkGUISupportQt - vtkGUISupportQtOpenGL ) FOREACH(_m ${_modules}) IF(NOT ${_m}_LOADED) @@ -18,6 +18,11 @@ IF(USE_QT4) ENDIF(NOT ${_m}_LOADED) ENDFOREACH(_m) SET(QT4_FOUND "1") + SET( + cpPlugins_Qt4_VTKWidget + QVTKWidget + CACHE STRING "Base Qt4-based vtkRenderWindow" + ) ENDIF(USE_QT4) ## eof - $RCSfile$ diff --git a/lib/Instances/CMakeLists.txt b/lib/Instances/CMakeLists.txt index 832eaad..a51aa87 100644 --- a/lib/Instances/CMakeLists.txt +++ b/lib/Instances/CMakeLists.txt @@ -1,6 +1,7 @@ ## =========================== ## == Compile each instance == ## =========================== + SET( _all_defs DataObjects @@ -9,23 +10,21 @@ SET( SET(_all_libs) FOREACH(_def ${_all_defs}) - CompileInstances( - fpaInstances_${_def} - fpa_${_def}.i - ${cpPlugins_CONFIG_NUMBER_OF_FILES} + CreateLib( + fpaInstances${_def} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/fpa_${_def}.i ) LIST(APPEND _all_libs fpaInstances_${_def}) ENDFOREACH(_def) TARGET_LINK_LIBRARIES( - fpaInstances_DataObjects + fpaInstancesDataObjects ${ITK_LIBRARIES} ${VTK_LIBRARIES} ${cpPlugins_Instances} ) TARGET_LINK_LIBRARIES( - fpaInstances_Filters - fpaInstances_DataObjects + fpaInstancesFilters + fpaInstancesDataObjects ) SET( diff --git a/lib/fpa/Base/Functors/GaussianModel.hxx b/lib/fpa/Base/Functors/GaussianModel.hxx index e9706a5..6a44ff8 100644 --- a/lib/fpa/Base/Functors/GaussianModel.hxx +++ b/lib/fpa/Base/Functors/GaussianModel.hxx @@ -22,7 +22,7 @@ Evaluate( const TInput& x ) const d *= d; d /= s; d = std::sqrt( d ); - if( d <= double( 2 ) ) // 2sigma + if( d <= double( 1.5 ) ) // 2sigma { this->m_S1 += v; this->m_S2 += v * v; @@ -45,7 +45,6 @@ Evaluate( const TInput& x ) const this->m_N += 1; } // fi - std::cout << v << " " << d << std::endl; return( d ); /* TODO diff --git a/lib/fpa/Base/Functors/Inverse.h b/lib/fpa/Base/Functors/Inverse.h index 0bd1a04..dc8c7a2 100644 --- a/lib/fpa/Base/Functors/Inverse.h +++ b/lib/fpa/Base/Functors/Inverse.h @@ -29,6 +29,9 @@ namespace fpa itkNewMacro( Self ); itkTypeMacro( Inverse, itk::FunctionBase ); + itkGetConstMacro( NegativeValue, _TOutput ); + itkSetMacro( NegativeValue, _TOutput ); + public: virtual TOutput Evaluate( const TInput& x ) const fpa_OVERRIDE; @@ -40,6 +43,9 @@ namespace fpa // Purposely not implemented Inverse( const Self& other ); Self& operator=( const Self& other ); + + protected: + _TOutput m_NegativeValue; }; } // ecapseman diff --git a/lib/fpa/Base/Functors/Inverse.hxx b/lib/fpa/Base/Functors/Inverse.hxx index e2ad9f0..4574cae 100644 --- a/lib/fpa/Base/Functors/Inverse.hxx +++ b/lib/fpa/Base/Functors/Inverse.hxx @@ -9,14 +9,18 @@ Evaluate( const TInput& x ) const { TInput sign = TInput( ( x < TInput( 0 ) )? -1: 1 ); TOutput y = TOutput( 1 ) / ( TOutput( 1 ) + TOutput( x * sign ) ); - return( y * TOutput( sign ) ); + if( sign < TInput( 0 ) ) + return( y * this->m_NegativeValue ); + else + return( y ); } // ------------------------------------------------------------------------- template< class _TInput, class _TOutput > fpa::Base::Functors::Inverse< _TInput, _TOutput >:: Inverse( ) - : Superclass( ) + : Superclass( ), + m_NegativeValue( _TOutput( -1 ) ) { } diff --git a/plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx b/plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx index 2853448..8d3b9c7 100644 --- a/plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx +++ b/plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/plugins/Plugins/InvertCost.cxx b/plugins/Plugins/InvertCost.cxx index 488e88c..d50676a 100644 --- a/plugins/Plugins/InvertCost.cxx +++ b/plugins/Plugins/InvertCost.cxx @@ -15,6 +15,7 @@ InvertCost( ) choices.push_back( "float" ); choices.push_back( "double" ); this->m_Parameters.ConfigureAsChoices( "ResultType", choices ); + this->m_Parameters.ConfigureAsReal( "NegativeValue", -1 ); this->m_Parameters.SetSelectedChoice( "ResultType", "float" ); } @@ -49,6 +50,7 @@ _GD0( ) out->SetITK( f ); } // fi + f->SetNegativeValue( this->m_Parameters.GetReal( "NegativeValue" ) ); } // eof - $RCSfile$