From: Leonardo Flórez-Valencia Date: Thu, 4 May 2017 00:03:10 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=617f49bff4a6db5ed51b4f767c3634d1915fdced;p=FrontAlgorithms.git ... --- diff --git a/CMakeLists.txt b/CMakeLists.txt index aab256e..6b7dd54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 35ae868..0000000 --- a/cmake/KitwareTools.cmake +++ /dev/null @@ -1,8 +0,0 @@ -# ======================== -# == Find Kitware tools == -# ======================== - -FIND_PACKAGE(ITK REQUIRED) -INCLUDE(${ITK_USE_FILE}) - -## eof - $RCSfile$ diff --git a/cmake/BaseConfig.cmake b/cmake/fpaBaseConfig.cmake similarity index 56% rename from cmake/BaseConfig.cmake rename to cmake/fpaBaseConfig.cmake index d177604..3fdc8ab 100644 --- a/cmake/BaseConfig.cmake +++ b/cmake/fpaBaseConfig.cmake @@ -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 index 0000000..635eea3 --- /dev/null +++ b/cmake/fpaConfig.cmake.in @@ -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$ diff --git a/examples/RegionGrow_Mori.cxx b/examples/RegionGrow_Mori.cxx index cf20cfa..7677fe5 100644 --- a/examples/RegionGrow_Mori.cxx +++ b/examples/RegionGrow_Mori.cxx @@ -1,3 +1,4 @@ +#include #include #include #include @@ -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 index 0000000..f4c0955 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,8 @@ + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ) +subdirs(fpa) + +## eof - $RCSfile$ diff --git a/libs/fpa/Base/Dijkstra.h b/lib/fpa/Base/Dijkstra.h similarity index 100% rename from libs/fpa/Base/Dijkstra.h rename to lib/fpa/Base/Dijkstra.h diff --git a/libs/fpa/Base/Dijkstra.hxx b/lib/fpa/Base/Dijkstra.hxx similarity index 100% rename from libs/fpa/Base/Dijkstra.hxx rename to lib/fpa/Base/Dijkstra.hxx diff --git a/libs/fpa/Base/Functors/InvertValue.h b/lib/fpa/Base/Functors/InvertValue.h similarity index 100% rename from libs/fpa/Base/Functors/InvertValue.h rename to lib/fpa/Base/Functors/InvertValue.h diff --git a/libs/fpa/Base/Functors/VertexParentBase.h b/lib/fpa/Base/Functors/VertexParentBase.h similarity index 100% rename from libs/fpa/Base/Functors/VertexParentBase.h rename to lib/fpa/Base/Functors/VertexParentBase.h diff --git a/libs/fpa/Base/MarksInterface.h b/lib/fpa/Base/MarksInterface.h similarity index 100% rename from libs/fpa/Base/MarksInterface.h rename to lib/fpa/Base/MarksInterface.h diff --git a/libs/fpa/Base/MarksInterface.hxx b/lib/fpa/Base/MarksInterface.hxx similarity index 100% rename from libs/fpa/Base/MarksInterface.hxx rename to lib/fpa/Base/MarksInterface.hxx diff --git a/libs/fpa/Base/MinimumSpanningTree.h b/lib/fpa/Base/MinimumSpanningTree.h similarity index 100% rename from libs/fpa/Base/MinimumSpanningTree.h rename to lib/fpa/Base/MinimumSpanningTree.h diff --git a/libs/fpa/Base/MinimumSpanningTree.hxx b/lib/fpa/Base/MinimumSpanningTree.hxx similarity index 100% rename from libs/fpa/Base/MinimumSpanningTree.hxx rename to lib/fpa/Base/MinimumSpanningTree.hxx diff --git a/libs/fpa/Base/MoriRegionGrow.h b/lib/fpa/Base/MoriRegionGrow.h similarity index 100% rename from libs/fpa/Base/MoriRegionGrow.h rename to lib/fpa/Base/MoriRegionGrow.h diff --git a/libs/fpa/Base/MoriRegionGrow.hxx b/lib/fpa/Base/MoriRegionGrow.hxx similarity index 100% rename from libs/fpa/Base/MoriRegionGrow.hxx rename to lib/fpa/Base/MoriRegionGrow.hxx diff --git a/libs/fpa/Base/RegionGrow.h b/lib/fpa/Base/RegionGrow.h similarity index 100% rename from libs/fpa/Base/RegionGrow.h rename to lib/fpa/Base/RegionGrow.h diff --git a/libs/fpa/Base/RegionGrow.hxx b/lib/fpa/Base/RegionGrow.hxx similarity index 100% rename from libs/fpa/Base/RegionGrow.hxx rename to lib/fpa/Base/RegionGrow.hxx diff --git a/libs/fpa/Base/SeedsInterface.h b/lib/fpa/Base/SeedsInterface.h similarity index 100% rename from libs/fpa/Base/SeedsInterface.h rename to lib/fpa/Base/SeedsInterface.h diff --git a/libs/fpa/Base/SeedsInterface.hxx b/lib/fpa/Base/SeedsInterface.hxx similarity index 100% rename from libs/fpa/Base/SeedsInterface.hxx rename to lib/fpa/Base/SeedsInterface.hxx diff --git a/lib/fpa/CMakeLists.txt b/lib/fpa/CMakeLists.txt new file mode 100644 index 0000000..a3ef666 --- /dev/null +++ b/lib/fpa/CMakeLists.txt @@ -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$ diff --git a/libs/fpa/Image/Dijkstra.h b/lib/fpa/Image/Dijkstra.h similarity index 100% rename from libs/fpa/Image/Dijkstra.h rename to lib/fpa/Image/Dijkstra.h diff --git a/libs/fpa/Image/Filter.h b/lib/fpa/Image/Filter.h similarity index 100% rename from libs/fpa/Image/Filter.h rename to lib/fpa/Image/Filter.h diff --git a/libs/fpa/Image/Filter.hxx b/lib/fpa/Image/Filter.hxx similarity index 100% rename from libs/fpa/Image/Filter.hxx rename to lib/fpa/Image/Filter.hxx diff --git a/libs/fpa/Image/Functors/GaussianWeight.h b/lib/fpa/Image/Functors/GaussianWeight.h similarity index 100% rename from libs/fpa/Image/Functors/GaussianWeight.h rename to lib/fpa/Image/Functors/GaussianWeight.h diff --git a/libs/fpa/Image/Functors/RegionGrow/BinaryThreshold.h b/lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.h similarity index 100% rename from libs/fpa/Image/Functors/RegionGrow/BinaryThreshold.h rename to lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.h diff --git a/libs/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx b/lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx similarity index 100% rename from libs/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx rename to lib/fpa/Image/Functors/RegionGrow/BinaryThreshold.hxx diff --git a/libs/fpa/Image/Functors/RegionGrow/Tautology.h b/lib/fpa/Image/Functors/RegionGrow/Tautology.h similarity index 100% rename from libs/fpa/Image/Functors/RegionGrow/Tautology.h rename to lib/fpa/Image/Functors/RegionGrow/Tautology.h diff --git a/libs/fpa/Image/Functors/VertexIdentity.h b/lib/fpa/Image/Functors/VertexIdentity.h similarity index 100% rename from libs/fpa/Image/Functors/VertexIdentity.h rename to lib/fpa/Image/Functors/VertexIdentity.h diff --git a/libs/fpa/Image/Functors/VertexParentBase.h b/lib/fpa/Image/Functors/VertexParentBase.h similarity index 100% rename from libs/fpa/Image/Functors/VertexParentBase.h rename to lib/fpa/Image/Functors/VertexParentBase.h diff --git a/libs/fpa/Image/MarksInterface.h b/lib/fpa/Image/MarksInterface.h similarity index 100% rename from libs/fpa/Image/MarksInterface.h rename to lib/fpa/Image/MarksInterface.h diff --git a/libs/fpa/Image/MarksInterface.hxx b/lib/fpa/Image/MarksInterface.hxx similarity index 100% rename from libs/fpa/Image/MarksInterface.hxx rename to lib/fpa/Image/MarksInterface.hxx diff --git a/libs/fpa/Image/MinimumSpanningTree.h b/lib/fpa/Image/MinimumSpanningTree.h similarity index 100% rename from libs/fpa/Image/MinimumSpanningTree.h rename to lib/fpa/Image/MinimumSpanningTree.h diff --git a/libs/fpa/Image/MinimumSpanningTreeToImageFilter.h b/lib/fpa/Image/MinimumSpanningTreeToImageFilter.h similarity index 100% rename from libs/fpa/Image/MinimumSpanningTreeToImageFilter.h rename to lib/fpa/Image/MinimumSpanningTreeToImageFilter.h diff --git a/libs/fpa/Image/MinimumSpanningTreeToImageFilter.hxx b/lib/fpa/Image/MinimumSpanningTreeToImageFilter.hxx similarity index 100% rename from libs/fpa/Image/MinimumSpanningTreeToImageFilter.hxx rename to lib/fpa/Image/MinimumSpanningTreeToImageFilter.hxx diff --git a/libs/fpa/Image/MoriRegionGrow.h b/lib/fpa/Image/MoriRegionGrow.h similarity index 100% rename from libs/fpa/Image/MoriRegionGrow.h rename to lib/fpa/Image/MoriRegionGrow.h diff --git a/libs/fpa/Image/RegionGrow.h b/lib/fpa/Image/RegionGrow.h similarity index 100% rename from libs/fpa/Image/RegionGrow.h rename to lib/fpa/Image/RegionGrow.h