]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 11 Nov 2016 23:26:33 +0000 (18:26 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Fri, 11 Nov 2016 23:26:33 +0000 (18:26 -0500)
CMakeLists.txt
cmake/Functions.cmake
cmake/KitwareTools.cmake
cmake/QtTools.cmake
lib/Instances/CMakeLists.txt
lib/fpa/Base/Functors/GaussianModel.hxx
lib/fpa/Base/Functors/Inverse.h
lib/fpa/Base/Functors/Inverse.hxx
plugins/Plugins/ExtractPathFromMinimumSpanningTree.cxx
plugins/Plugins/InvertCost.cxx

index 4175ddb21b911a663c1249ee3db16ee6eff5b697..fec6ee28db555f66b26e333dc251052ae917ed65 100644 (file)
@@ -56,6 +56,6 @@ INCLUDE(cmake/Functions.cmake)
 ## ===========================
 
 ## SUBDIRS(appli cmake lib plugins)
-SUBDIRS(lib plugins)
+SUBDIRS(lib)
 
 ## eof - $RCSfile$
index 02ec213e50c7334162861a890d6f6c3efd20c357..aebf89fa6749738c57a476d73dee13537aafd92c 100644 (file)
@@ -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$
index a120bb210298a03c947e3f64dbc630502be56a1a..b4493d2951ee5a7ed629b51a02589e07c1bd038c 100644 (file)
@@ -3,9 +3,9 @@
 # ======================
 
 FIND_PACKAGE(ITK REQUIRED)
-INCLUDE(${ITK_USE_FILE})
-
 FIND_PACKAGE(VTK REQUIRED)
+
+INCLUDE(${ITK_USE_FILE})
 INCLUDE(${VTK_USE_FILE})
 
 # ===================================================
index a49b3d54e3efa1f937cdab70226a359d3f984436..8e884b046fab187e446b1febfe824311185e6b05 100644 (file)
@@ -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$
index 832eaad4488c09cab198a53ff759193186230c44..a51aa8722e3a92beab440ee5e5eb7624d5021fcb 100644 (file)
@@ -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(
index e9706a547f04a84bdb4739d522ed102b124c9341..6a44ff873f0f16b28a11eb124a36d90c0993a9b8 100644 (file)
@@ -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
index 0bd1a04fe5ecdd0fd352ead3033c946fe5396a2f..dc8c7a24fd43845586395c9fb20e2a4784e2d2ad 100644 (file)
@@ -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
index e2ad9f0092fc0645f0ec8ba679aaa57292a38a46..4574cae2e712e94f77468d787e293b701d1fe3fb 100644 (file)
@@ -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 ) )
 {
 }
 
index 28534483409075e2be92aa048aeda917a388c689..8d3b9c77688d8c24d133838851bd0ca15e311fdb 100644 (file)
@@ -1,6 +1,6 @@
 #include <Plugins/ExtractPathFromMinimumSpanningTree.h>
 #include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/PolyLineParametricPath.h>
+#include <Extensions/PolyLineParametricPath.h>
 #include <vtkPolyData.h>
 #include <fpa/Image/MinimumSpanningTree.h>
 
index 488e88cc420de270cac4dbef28cb76ac61eb4ecb..d50676a95888fca021da134e7b11ba72509cfa9c 100644 (file)
@@ -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$