-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$
+++ /dev/null
-# ========================
-# == Find Kitware tools ==
-# ========================
-
-FIND_PACKAGE(ITK REQUIRED)
-INCLUDE(${ITK_USE_FILE})
-
-## eof - $RCSfile$
## == 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
--- /dev/null
+@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$
+#include <chrono>
#include <iomanip>
#include <itkCommand.h>
#include <itkImage.h>
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( ) );
{
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 );
}
--- /dev/null
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+subdirs(fpa)
+
+## eof - $RCSfile$
--- /dev/null
+
+## =====================
+## == 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$