]> Creatis software - FrontAlgorithms.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 4 May 2017 00:03:10 +0000 (19:03 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Thu, 4 May 2017 00:03:10 +0000 (19:03 -0500)
37 files changed:
CMakeLists.txt
cmake/KitwareTools.cmake [deleted file]
cmake/fpaBaseConfig.cmake [moved from cmake/BaseConfig.cmake with 56% similarity]
cmake/fpaConfig.cmake.in [new file with mode: 0644]
examples/RegionGrow_Mori.cxx
lib/CMakeLists.txt [new file with mode: 0644]
lib/fpa/Base/Dijkstra.h [moved from libs/fpa/Base/Dijkstra.h with 100% similarity]
lib/fpa/Base/Dijkstra.hxx [moved from libs/fpa/Base/Dijkstra.hxx with 100% similarity]
lib/fpa/Base/Functors/InvertValue.h [moved from libs/fpa/Base/Functors/InvertValue.h with 100% similarity]
lib/fpa/Base/Functors/VertexParentBase.h [moved from libs/fpa/Base/Functors/VertexParentBase.h with 100% similarity]
lib/fpa/Base/MarksInterface.h [moved from libs/fpa/Base/MarksInterface.h with 100% similarity]
lib/fpa/Base/MarksInterface.hxx [moved from libs/fpa/Base/MarksInterface.hxx with 100% similarity]
lib/fpa/Base/MinimumSpanningTree.h [moved from libs/fpa/Base/MinimumSpanningTree.h with 100% similarity]
lib/fpa/Base/MinimumSpanningTree.hxx [moved from libs/fpa/Base/MinimumSpanningTree.hxx with 100% similarity]
lib/fpa/Base/MoriRegionGrow.h [moved from libs/fpa/Base/MoriRegionGrow.h with 100% similarity]
lib/fpa/Base/MoriRegionGrow.hxx [moved from libs/fpa/Base/MoriRegionGrow.hxx with 100% similarity]
lib/fpa/Base/RegionGrow.h [moved from libs/fpa/Base/RegionGrow.h with 100% similarity]
lib/fpa/Base/RegionGrow.hxx [moved from libs/fpa/Base/RegionGrow.hxx with 100% similarity]
lib/fpa/Base/SeedsInterface.h [moved from libs/fpa/Base/SeedsInterface.h with 100% similarity]
lib/fpa/Base/SeedsInterface.hxx [moved from libs/fpa/Base/SeedsInterface.hxx with 100% similarity]
lib/fpa/CMakeLists.txt [new file with mode: 0644]
lib/fpa/Image/Dijkstra.h [moved from libs/fpa/Image/Dijkstra.h with 100% similarity]
lib/fpa/Image/Filter.h [moved from libs/fpa/Image/Filter.h with 100% similarity]
lib/fpa/Image/Filter.hxx [moved from libs/fpa/Image/Filter.hxx with 100% similarity]
lib/fpa/Image/Functors/GaussianWeight.h [moved from libs/fpa/Image/Functors/GaussianWeight.h with 100% similarity]
lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.h [moved from libs/fpa/Image/Functors/RegionGrow/BinaryThreshold.h with 100% similarity]
lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx [moved from libs/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx with 100% similarity]
lib/fpa/Image/Functors/RegionGrow/Tautology.h [moved from libs/fpa/Image/Functors/RegionGrow/Tautology.h with 100% similarity]
lib/fpa/Image/Functors/VertexIdentity.h [moved from libs/fpa/Image/Functors/VertexIdentity.h with 100% similarity]
lib/fpa/Image/Functors/VertexParentBase.h [moved from libs/fpa/Image/Functors/VertexParentBase.h with 100% similarity]
lib/fpa/Image/MarksInterface.h [moved from libs/fpa/Image/MarksInterface.h with 100% similarity]
lib/fpa/Image/MarksInterface.hxx [moved from libs/fpa/Image/MarksInterface.hxx with 100% similarity]
lib/fpa/Image/MinimumSpanningTree.h [moved from libs/fpa/Image/MinimumSpanningTree.h with 100% similarity]
lib/fpa/Image/MinimumSpanningTreeToImageFilter.h [moved from libs/fpa/Image/MinimumSpanningTreeToImageFilter.h with 100% similarity]
lib/fpa/Image/MinimumSpanningTreeToImageFilter.hxx [moved from libs/fpa/Image/MinimumSpanningTreeToImageFilter.hxx with 100% similarity]
lib/fpa/Image/MoriRegionGrow.h [moved from libs/fpa/Image/MoriRegionGrow.h with 100% similarity]
lib/fpa/Image/RegionGrow.h [moved from libs/fpa/Image/RegionGrow.h with 100% similarity]

index aab256e1837bbca2bc33b69b08253b5c7267785b..6b7dd54a0e7a3e89eb4446f6407656e4be0a6d4e 100644 (file)
@@ -1,54 +1,82 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
+cmake_minimum_required(VERSION 3.0)
 
 ## ========================
 ## == Project definition ==
 ## ========================
 
-SET(prj_NAME FrontAlgorithms)
-SET(prj_MAJOR_VERSION   1)
-SET(prj_MINOR_VERSION   0)
-SET(prj_RELEASE_VERSION 0)
-SET(_subdirs examples) # lib plugins)
-SET(_policies CMP0015 CMP0020 CMP0042)
+set(prj_MAJ_VERSION 0)
+set(prj_MIN_VERSION 1)
+set(prj_REL_VERSION 0)
+set(prj_VERSION "${prj_MAJ_VERSION}.${prj_MIN_VERSION}.${prj_REL_VERSION}")
+set(prj_SHORT_VERSION "${prj_MAJ_VERSION}")
+project(fpa VERSION ${prj_VERSION})
 
 ## ==========================
 ## == Some useful policies ==
 ## ==========================
 
-FOREACH(_p ${_policies})
-  IF(POLICY ${_p})
-    CMAKE_POLICY(SET ${_p} NEW)
-  ENDIF(POLICY ${_p})
-ENDFOREACH(_p)
+set(_policies CMP0015 CMP0020 CMP0042 CMP0053)
+foreach(_p ${_policies})
+  if(POLICY ${_p})
+    cmake_policy(SET ${_p} NEW)
+  endif(POLICY ${_p})
+endforeach(_p)
 
-## ===========================
-## == Project configuration ==
-## ===========================
+## ===============================
+## == Some basic configurations ==
+## ===============================
+
+include(cmake/fpaBaseConfig.cmake)
 
-PROJECT(${prj_NAME})
-SET(prj_VERSION "${prj_MAJOR_VERSION}.${prj_MINOR_VERSION}.${prj_RELEASE_VERSION}")
-SET(prj_SHORT_VERSION "${prj_MAJOR_VERSION}")
+## ==============
+## == Find ITK ==
+## ==============
 
-## =====================================
-## == Functions, packages and options ==
-## =====================================
+find_package(ITK CONFIG REQUIRED)
+include(${ITK_USE_FILE})
 
-INCLUDE(cmake/BaseConfig.cmake)
-INCLUDE(cmake/KitwareTools.cmake)
-#OPTION(USE_cpPlugins "Build cpPlugins-based code" OFF)
-#IF(USE_cpPlugins)
-#  FIND_PACKAGE(cpPlugins)
-#  MARK_AS_ADVANCED(CLEAR cpPlugins_DIR)
-#ENDIF(USE_cpPlugins)
-#INCLUDE(cmake/QtTools.cmake)
-#INCLUDE(cmake/Functions.cmake)
+## =========================
+## == Installation values ==
+## =========================
+
+set(config_install_dir "lib/cmake/${PROJECT_NAME}")
+set(include_install_dir "include")
+set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
+set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
+set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
+set(targets_export_name "${PROJECT_NAME}Targets")
+set(namespace "${PROJECT_NAME}::")
 
 ## ===========================
 ## == Build different parts ==
 ## ===========================
 
-FOREACH(_s ${_subdirs})
-  SUBDIRS(${_s})
-ENDFOREACH(_s)
+subdirs(lib)
+
+## ===============================
+## == Global installation rules ==
+## ===============================
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+  "${version_config}" COMPATIBILITY SameMajorVersion
+  )
+configure_package_config_file(
+  "cmake/${PROJECT_NAME}Config.cmake.in"
+  "${project_config}"
+  INSTALL_DESTINATION "${config_install_dir}"
+  )
+install(
+  FILES
+  "${project_config}"
+  "${version_config}"
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/fpaBaseConfig.cmake"
+  DESTINATION "${config_install_dir}"
+  )
+#install(
+#  EXPORT "${targets_export_name}"
+#  NAMESPACE "${namespace}"
+#  DESTINATION "${config_install_dir}"
+#  )
 
 ## eof - $RCSfile$
diff --git a/cmake/KitwareTools.cmake b/cmake/KitwareTools.cmake
deleted file mode 100644 (file)
index 35ae868..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# ========================
-# == Find Kitware tools ==
-# ========================
-
-FIND_PACKAGE(ITK REQUIRED)
-INCLUDE(${ITK_USE_FILE})
-
-## eof - $RCSfile$
similarity index 56%
rename from cmake/BaseConfig.cmake
rename to cmake/fpaBaseConfig.cmake
index d177604781fdd748042fb7dffe15eeef77b7a537..3fdc8ab5569efd9b133906e7d6ccb12c54c7d51a 100644 (file)
@@ -4,45 +4,45 @@
 ## ==       c++11, so it only need to be tested on other OS.            ==
 ## =======================================================================
 
-IF(NOT MSVC)
-  INCLUDE(CheckCXXCompilerFlag)
-  CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
-  IF(COMPILER_SUPPORTS_CXX11)
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-  ELSE(COMPILER_SUPPORTS_CXX11)
-    CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
-    IF(COMPILER_SUPPORTS_CXX0X)
-      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
-    ELSE(COMPILER_SUPPORTS_CXX0X)
-      MESSAGE(
+if(NOT MSVC)
+  include(CheckCXXCompilerFlag)
+  check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
+  if(COMPILER_SUPPORTS_CXX11)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+  else(COMPILER_SUPPORTS_CXX11)
+    check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+    if(COMPILER_SUPPORTS_CXX0X)
+      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+    else(COMPILER_SUPPORTS_CXX0X)
+      message(
         FATAL_ERROR
         "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support."
         )
-    ENDIF(COMPILER_SUPPORTS_CXX0X)
-  ENDIF(COMPILER_SUPPORTS_CXX11)
-ENDIF(NOT MSVC)
+    endif(COMPILER_SUPPORTS_CXX0X)
+  endif(COMPILER_SUPPORTS_CXX11)
+endif(NOT MSVC)
 
 ## ===================================================
 ## == Prepare header generator to build shared libs ==
 ## ===================================================
 
-INCLUDE(GenerateExportHeader)
+include(GenerateExportHeader)
 
 ## ==================================================
 ## == Do not allow to build inside the source tree ==
 ## ==================================================
 
-IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
-  MESSAGE(FATAL_ERROR "Building in the source tree is not allowed.")
-ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+if(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+  message(FATAL_ERROR "Building in the source tree is not allowed.")
+endif(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
 
 ## =================================================
 ## == Where to put targets (executables and libs) ==
 ## =================================================
 
-SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
-SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
-MARK_AS_ADVANCED(
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
+mark_as_advanced(
   CMAKE_BACKWARDS_COMPATIBILITY
   EXECUTABLE_OUTPUT_PATH
   LIBRARY_OUTPUT_PATH
diff --git a/cmake/fpaConfig.cmake.in b/cmake/fpaConfig.cmake.in
new file mode 100644 (file)
index 0000000..635eea3
--- /dev/null
@@ -0,0 +1,16 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/fpaBaseConfig.cmake")
+## include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
+check_required_components("@PROJECT_NAME@")
+
+## ==============
+## == Find ITK ==
+## ==============
+
+set(ITK_DIR @ITK_DIR@)
+
+find_package(ITK CONFIG REQUIRED)
+include(${ITK_USE_FILE})
+
+## eof - $RCSfile$
index cf20cfafd70d30b49e6583df461c44ecb8b44ed6..7677fe5b96f5c2fd0b43ad251d3e990c23d8f15b 100644 (file)
@@ -1,3 +1,4 @@
+#include <chrono>
 #include <iomanip>
 #include <itkCommand.h>
 #include <itkImage.h>
@@ -58,23 +59,47 @@ int main( int argc, char* argv[] )
 
   TReader::Pointer reader = TReader::New( );
   reader->SetFileName( input_image_filename );
+  try
+  {
+    reader->Update( );
+  }
+  catch( std::exception& err )
+  {
+    std::cerr << "ERROR: " << err.what( ) << std::endl;
+    return( 1 );
+
+  } // yrt
 
   TFilter::Pointer filter = TFilter::New( );
   filter->SetInput( reader->GetOutput( ) );
   filter->SetThresholdRange( lower, upper, delta );
-  TImage::IndexType seed;
+  TImage::PointType pnt;
   for( int i = 0; i < VDim; ++i )
-    seed[ i ] = std::atoi( argv[ i + 7 ] );
+    pnt[ i ] = std::atof( argv[ i + 7 ] );
+
+  TImage::IndexType seed;
+  if( !( reader->GetOutput( )->TransformPhysicalPointToIndex( pnt, seed ) ) )
+  {
+    std::cerr << "ERROR: seed outside image." << std::endl;
+    return( 1 );
+
+  } // fi
   filter->AddSeed( seed );
 
   // to test ProgressReporter
-  ShowProgressObject progressWatch( filter );
-  typedef itk::SimpleMemberCommand< ShowProgressObject > CommandType;
-  CommandType::Pointer command = CommandType::New();
-  command->SetCallbackFunction( &progressWatch,
-                                &ShowProgressObject::ShowProgress );
-  filter->AddObserver( itk::ProgressEvent( ), command );
+  /* TODO
+     ShowProgressObject progressWatch( filter );
+     typedef itk::SimpleMemberCommand< ShowProgressObject > CommandType;
+     CommandType::Pointer command = CommandType::New();
+     command->SetCallbackFunction( &progressWatch,
+     &ShowProgressObject::ShowProgress );
+     filter->AddObserver( itk::ProgressEvent( ), command );
+  */
+  std::chrono::time_point< std::chrono::system_clock > start, end;
+  start = std::chrono::system_clock::now( );
   filter->Update( );
+  end = std::chrono::system_clock::now( );
+  std::chrono::duration< double > elapsed_seconds = end - start;
 
   TThreshold::Pointer threshold = TThreshold::New( );
   threshold->SetInput( filter->GetOutput( ) );
@@ -108,14 +133,15 @@ int main( int argc, char* argv[] )
   {
     std::cout << data.XValue << " " << data.YValue << " " << data.Diff1 << std::endl;
   }
-  std::cerr
+  std::cout
     << std::endl
     << "# Opt: "
     << curve[ filter->GetOptimumThreshold( ) ].XValue
     << "("
     << filter->GetOptimumThreshold( )
-    << ")"
+     << ")"
     << std::endl;
+  std::cout << "Time: " << elapsed_seconds.count( ) << "s" << std::endl;
   return( 0 );
 }
 
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f4c0955
--- /dev/null
@@ -0,0 +1,8 @@
+
+include_directories(
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${CMAKE_CURRENT_BINARY_DIR}
+  )
+subdirs(fpa)
+
+## eof - $RCSfile$
diff --git a/lib/fpa/CMakeLists.txt b/lib/fpa/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a3ef666
--- /dev/null
@@ -0,0 +1,56 @@
+
+## =====================
+## == Get source code ==
+## =====================
+
+file(GLOB_RECURSE _base_src "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.cxx")
+file(GLOB_RECURSE _base_hdr "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.h")
+file(GLOB_RECURSE _base_hrc "${CMAKE_CURRENT_SOURCE_DIR}/Base/*.hxx")
+file(GLOB_RECURSE _image_src "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.cxx")
+file(GLOB_RECURSE _image_hdr "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.h")
+file(GLOB_RECURSE _image_hrc "${CMAKE_CURRENT_SOURCE_DIR}/Image/*.hxx")
+
+## =====================
+## == Compile library ==
+## =====================
+
+#add_library(fpa SHARED ${_src} ${_hdr} ${_hrc})
+#generate_export_header(fpa)
+#set_property(TARGET fpa PROPERTY VERSION ${prj_VERSION})
+#set_property(TARGET fpa PROPERTY SOVERSION ${prj_SHORT_VERSION})
+#set_property(
+#  TARGET fpa PROPERTY INTERFACE_fpa_MAJOR_VERSION ${prj_MAJ_VERSION}
+#  )
+#set_property(
+#  TARGET fpa APPEND PROPERTY COMPATIBLE_INTERFACE_STRING ${prj_MAJ_VERSION}
+#  )
+#target_link_libraries(fpa PUBLIC ${VTK_LIBRARIES} ${ITK_LIBRARIES})
+
+## ========================
+## == Installation rules ==
+## ========================
+
+#install(
+#  TARGETS fpa
+#  EXPORT "${targets_export_name}"
+#  LIBRARY DESTINATION "lib"
+#  ARCHIVE DESTINATION "lib"
+#  RUNTIME DESTINATION "bin"
+#  INCLUDES DESTINATION "${include_install_dir}"
+#  )
+install(
+  DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+  DESTINATION "${include_install_dir}"
+  FILES_MATCHING PATTERN "*.h"
+  )
+install(
+  DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+  DESTINATION "${include_install_dir}"
+  FILES_MATCHING PATTERN "*.hxx"
+  )
+#install(
+#  FILES "${CMAKE_CURRENT_BINARY_DIR}/fpa_export.h"
+#  DESTINATION "${include_install_dir}/fpa"
+#  )
+
+## eof - $RCSfile$