Skip to content
Snippets Groups Projects
Commit 0be6be4b authored by Floris Berendsen's avatar Floris Berendsen
Browse files

Revert "Revert "Merge branch 'ELASTIX-9-blueprints' of...

Revert "Revert "Merge branch 'ELASTIX-9-blueprints' of https://github.com/kaspermarstal/SuperElastix into ELASTIX-12-implement-componentdatabase""

This reverts commit 620dd446a6a6c01657e9d96aa12091ce23886966.
parent d24c114f
No related branches found
No related tags found
No related merge requests found
Showing
with 448 additions and 19 deletions
macro( ElastixComponent COMPONENT )
ElastixModuleCheckName( ${COMPONENT} )
set( ELASTIX_COMPONENT_{$COMPONENT}_DEFINED TRUE )
endmacro()
macro( ElastixComponentCheckName COMPONENT )
if( NOT "${_name}" MATCHES "^[a-zA-Z][a-zA-Z0-9]*$" )
message( FATAL_ERROR "Invalid component name: ${COMPONENT}" )
endif()
endmacro()
\ No newline at end of file
# ---------------------------------------------------------------------
# Private helper macros
macro( _elxmodule_check_name MODULE )
if( NOT "${_name}" MATCHES "^[a-zA-Z_]*$" )
message( FATAL_ERROR "Invalid module name: ${MODULE}" )
endif()
list( FIND ELXMODULE_ALL "${MODULE}" MODULE_FOUND )
if( ${MODULE_FOUND} EQUAL -1 )
message( FATAL_ERROR "Module not found: ${MODULE}")
endif()
endmacro()
macro( _elxmodule_enable MODULE )
_elxmodule_check_name( ${MODULE} )
if( NOT ${MODULE}_ENABLED )
set( "${MODULE}_ENABLED" ON )
add_subdirectory( "${${MODULE}_SOURCE_DIR}" )
if( ${MODULE}_INCLUDE_DIRS )
include_directories( ${${MODULE}_INCLUDE_DIRS} )
endif()
if( ${MODULE}_LIBRARIES )
link_directories( ${${MODULE}_LIBRARY_DIR} )
endif()
if( ${${MODULE}_LIBRARIES} )
list( APPEND ELASTIX_LIBRARIES
${${MODULE}_LIBRARIES}
)
endif()
# TODO: Add recursive dependency walk
# foreach( DEPENDENCY IN LISTS ${MODULE}_DEPENDS )
# _elxmodule_enable( ${DEPENDENCY} )
# endforeach()
endif()
endmacro()
macro( _elxmodule_disable MODULE )
# TODO
endmacro()
macro( _elxmodules_initialize )
set( ELXMODULE_ALL )
file( GLOB MODULE_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/Modules/*/ELXMODULE_*.cmake"
)
message( STATUS "Found the following elastix modules:")
foreach( MODULE_FILE ${MODULE_FILES})
get_filename_component( MODULE_PATH ${MODULE_FILE} PATH )
get_filename_component( MODULE ${MODULE_FILE} NAME_WE )
message( STATUS " ${MODULE}" )
option( "USE_${MODULE}" OFF )
set( "${MODULE}_ENABLED" OFF )
set( ${MODULE}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${MODULE_PATH} )
set( ${MODULE}_BINARY_DIR ${CMAKE_BINARY_DIR}/${MODULE_PATH} )
set( ${MODULE}_LIBRARIES )
list(APPEND ELXMODULE_ALL ${MODULE} )
endforeach()
endmacro()
_elxmodules_initialize()
# ---------------------------------------------------------------------
# Public interface
macro( elxmodule_enable MODULE )
option( USE_${MODULE} ON )
_elxmodule_enable( ${MODULE} )
endmacro()
...@@ -5,7 +5,8 @@ if( MSVC ) ...@@ -5,7 +5,8 @@ if( MSVC )
if( n GREATER 50 ) if( n GREATER 50 )
message( message(
FATAL_ERROR FATAL_ERROR
"ITK source code directory path length is too long for MSVC (${n} > 50)." "Source code directory path length is too long for MSVC (${n} > 50)."
"Please move the source code directory to a directory with a shorter path."
) )
endif() endif()
...@@ -13,11 +14,12 @@ if( MSVC ) ...@@ -13,11 +14,12 @@ if( MSVC )
if( n GREATER 50 ) if( n GREATER 50 )
message( message(
FATAL_ERROR FATAL_ERROR
"ITK build directory path length is too long for MSVC (${n} > 50)." "Build directory path length is too long for MSVC (${n} > 50)."
"Please move the build directory to a directory with a shorter path."
) )
endif() endif()
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj" ) set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj" )
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj" ) set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /bigobj" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj" ) set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /bigobj" )
endif() endif()
\ No newline at end of file
...@@ -8,8 +8,9 @@ set( MSVC_INCREMENTAL_DEFAULT ON ) ...@@ -8,8 +8,9 @@ set( MSVC_INCREMENTAL_DEFAULT ON )
project( Elastix ) project( Elastix )
# Include SuperElastix CMake scripts # Include SuperElastix CMake scripts
list( APPEND CMAKE_MODULE_PATH set( CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/CMake" "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
${CMAKE_MODULE_PATH}
) )
if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" ) if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC" )
...@@ -23,6 +24,11 @@ find_package( ITK REQUIRED ) ...@@ -23,6 +24,11 @@ find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} ) include( ${ITK_USE_FILE} )
include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxITKRequiredModules.cmake" ) include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxITKRequiredModules.cmake" )
# ---------------------------------------------------------------------
# Boost Graph Library
find_package( Boost REQUIRED graph )
include_directories(${Boost_INCLUDE_DIRS})
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Build Elastix # Build Elastix
......
add_subdirectory(
Core
)
include_directories( include )
add_subdirectory( src )
#ifndef __Blueprint_h
#define __Blueprint_h
#include "itkObjectFactory.h"
#include "itkDataObject.h"
#include "elxMacro.h"
#include "elxComponentDescriptor.h"
#include "boost/graph/graph_traits.hpp"
#include "boost/graph/directed_graph.hpp"
namespace elx {
template< class TComponentDescriptor >
class Blueprint : public itk::DataObject
{
public:
elxNewMacro( Blueprint, itk::DataObject );
typedef TComponentDescriptor ComponentDescriptorType;
typedef typename TComponentDescriptor::ComponentNameType ComponentNameType;
typedef boost::adjacency_list< boost::vecS,
boost::vecS,
boost::directedS,
ComponentDescriptorType > GraphType;
typedef typename boost::graph_traits< GraphType >::vertex_descriptor ComponentType;
typedef typename boost::graph_traits< GraphType >::vertex_iterator ComponentIterator, ComponentIteratorEnd;
typedef boost::vertex_index_t ComponentIndexType;
typedef typename boost::property_map< GraphType, ComponentIndexType >::type ComponentIndexMapType;
typedef typename boost::graph_traits< GraphType >::edge_descriptor ConnectionDescriptorType;
typedef typename boost::graph_traits< GraphType >::edge_iterator ConnectionIterator, ConnectionIteratorEnd;
typedef typename boost::graph_traits< GraphType >::in_edge_iterator InputIterator, InputIteratorEnd;
typedef typename boost::graph_traits< GraphType >::out_edge_iterator OutputIterator, OutputIteratorEnd;
int TestFunction( void );
bool AddComponent( ComponentDescriptorType component );
bool SetComponent( ComponentIndexType componentIndex, ComponentDescriptorType component );
ComponentDescriptorType GetComponent( ComponentIndexType componentIndex );
bool RemoveComponent( ComponentDescriptorType component );
bool SetConnection( ComponentIndexType upstream, ComponentIndexType downstream );
ConnectionDescriptorType GetConnection( ConnectionDescriptorType Connection );
bool RemoveConnection( ConnectionDescriptorType connection );
void PrintGraph( void );
private:
GraphType m_Graph;
};
}
#endif // #define __Blueprint_h
\ No newline at end of file
#ifndef __ComponentDescriptor_h
#define __ComponentDescriptor_h
#include "elxMacro.h"
#include "itkDataObject.h"
namespace elx {
class ComponentDescriptor : public itk::DataObject
{
public:
elxNewMacro( ComponentDescriptor, itk::DataObject );
// Identifier to find component in the component database
typedef std::string ComponentNameType;
// TODO: Setter should validate ComponentName exists in ComponentDatabase
itkSetMacro( ComponentName, ComponentNameType );
itkGetMacro( ComponentName, ComponentNameType );
private:
ComponentNameType m_ComponentName;
};
}
#endif // __ComponentDescriptor_h
message( STATUS "In directory ${CMAKE_CURRENT_LIST_DIR}" )
add_library( Blueprints
elxComponentDescriptor.cxx
elxBlueprint.cxx
)
\ No newline at end of file
#ifndef __Blueprint_hxx
#define __Blueprint_hxx
#include <boost/graph/graphviz.hpp>
#include "elxBlueprint.h"
namespace elastix {
void
Blueprint< ComponentDescriptor >
::Blueprint( void )
{
this->SetGraph( GraphType );
}
ComponentDescriptorType
Blueprint< ComponentDescriptor >
::AddComponent( ComponentDescriptorType component )
{
// TODO: Check that the component is in the ComponentDatabase
this->Modified();
return this->m_Graph->add_vertex( component );
}
bool
Blueprint< ComponentDescriptor >
::SetComponent( ComponentDescriptorType component )
{
this->Modified();
return this->m_Graph->remove_vertex( connection );
}
bool
Blueprint< ComponentDescriptor >
::RemoveComponent( ComponentDescriptorType component )
{
this->Modified();
return this->m_Graph->remove_vertex( connection );
}
bool
Blueprint< ComponentDescriptor >
::AddConnection( ComponentDescriptorType upsteam, ComponentDescriptorType downstream )
{
this->Modified();
return this->m_Graph->add_edge( upstream, downstream );
}
ConnectionDescriptorType
Blueprint< ComponentDescriptor >
::GetConnection( ConnectionDescriptorType Connection )
{
this->Modified();
}
void
Blueprint< ComponentDescriptor >
::RemoveConnection( ConnectionType connection )
{
this->Modified();
this->m_Graph->remove_edge( connection );
}
void
Blueprint< ComponentDescriptor >
::PrintGraph( void )
{
// TODO: Link to graphviz library
// boost::write_graphviz(std::cout, this->m_Graph);
std::cout << "Printed graph" << std::endl;
}
void
Blueprint< ComponentDescriptor >
::TestFunction( void )
{ return 0; }
}
#endif // __Blueprint_hxx
\ No newline at end of file
#ifndef __ComponentDescriptor_hxx
#define __ComponentDescriptor_hxx
#include "elxComponentDescriptor.h"
// TODO: Need enum for component name?
namespace elx {
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName )
{
this->SetComponentName( componentName );
this->SetComponentUniqueId( this->GenerateUniqueId() );
this->SetParameterMap( this->ParameterMapType() );
}
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName,
const ComponentUniqueIdType componentUniqueId )
{
this->SetComponentName( componentName );
this->SetComponentUniqueId( componentUniqueId );
this->SetParameterMap( this->ParameterMapType() );
}
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName,
const ComponentIdType componentUniqueId,
const ParameterMapType parameterMap )
{
this->SetComponentName( componentName );
this->SetComponentUniqueId( componentUniqueId );
this->SetParameterMap( parameterMap );
}
ComponentDescriptor::ComponentIdType
ComponentDescriptor
::GenerateUniqueId()
{
}
} // namespace elx
#endif // __ComponentDescriptor_hxx
\ No newline at end of file
project( ELXMODULE_CORE )
# TODO: Include directures using the module API
include_directories(
Common/include
Blueprints/include
)
add_subdirectory( Common ) add_subdirectory( Common )
add_subdirectory( Blueprints ) add_subdirectory( Blueprints )
set( "${PROJECT_NAME}_LIBRARIES"
Blueprints
)
set( DOCUMENTATION
"This module contains the core components of elastix library such as the component database and component pipeline instantiation functionality."
)
elxmodule_enable( ELXMODULE_CORE
DEPENDS
ELXMODULE_COMMON
DESCRIPTION
"${DOCUMENTATION}"
)
cmake_minimum_required( VERSION 2.8 ) cmake_minimum_required( VERSION 2.8 )
#--------------------------------------------------------------------- # ---------------------------------------------------------------------
project( ElastixSuperBuild ) project( ElastixSuperBuild )
find_package( Git REQUIRED ) find_package( Git REQUIRED )
...@@ -15,7 +15,7 @@ set( CMAKE_MODULE_PATH ...@@ -15,7 +15,7 @@ set( CMAKE_MODULE_PATH
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "SuperBuild install directory" FORCE) set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "SuperBuild install directory" FORCE)
#--------------------------------------------------------------------- # ---------------------------------------------------------------------
# Elastix SuperBuild configuration # Elastix SuperBuild configuration
# Build release by default # Build release by default
...@@ -29,13 +29,16 @@ option( ELASTIX_BUILD_EXAMPLES "Enable building examples." ON ) ...@@ -29,13 +29,16 @@ option( ELASTIX_BUILD_EXAMPLES "Enable building examples." ON )
# Build tests by default # Build tests by default
option( ELASTIX_BUILD_TESTING "Enable building tests." ON ) option( ELASTIX_BUILD_TESTING "Enable building tests." ON )
if( ELASTIX_BUILD_TESTING ) if( ELASTIX_BUILD_TESTING )
option( ELASTIX_BUILD_BENCHMARKING "Enable building benchmarks." ON ) option( ELASTIX_BUILD_BENCHMARKING "Enable building benchmarks." ON )
option( ELASTIX_BUILD_DASHBOARD "Enable building benchmarks." ON ) option( ELASTIX_BUILD_DASHBOARD "Enable building benchmarks." ON )
endif() endif()
#--------------------------------------------------------------------- # Do not build dashboard by default
option( ELASTIX_BUILD_DASHBOARD "Enable building dashboard." OFF )
# ---------------------------------------------------------------------
# Build ITK # Build ITK
set( ITK_VERSION_MAJOR "4" ) set( ITK_VERSION_MAJOR "4" )
...@@ -54,7 +57,19 @@ else() ...@@ -54,7 +57,19 @@ else()
list( APPEND ELASTIX_DEPENDENCIES ITK ) list( APPEND ELASTIX_DEPENDENCIES ITK )
endif() endif()
#--------------------------------------------------------------------- # ---------------------------------------------------------------------
# Boost Graph Library
mark_as_advanced( USE_SYSTEM_BOOST )
option( USE_SYSTEM_BOOST "Use an installed version of BOOST" OFF )
if( USE_SYSTEM_BOOST )
find_package( BOOST REQUIRED graph )
else()
include( ExternalBoost )
list( APPEND ELASTIX_DEPENDENCIES BOOST )
endif()
# ---------------------------------------------------------------------
# Build Elastix # Build Elastix
include( Elastix ) include( Elastix )
......
...@@ -6,10 +6,12 @@ ExternalProject_Add( ${proj} ...@@ -6,10 +6,12 @@ ExternalProject_Add( ${proj}
BINARY_DIR ${proj}-build BINARY_DIR ${proj}-build
CMAKE_ARGS CMAKE_ARGS
--no-warn-unused-cli --no-warn-unused-cli
-DELASTIX_BUILD_EXAMPLES:BOOL=${ELASTIX_BUILD_EXAMPLES}
-DELASTIX_BUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING} -DELASTIX_BUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DELASTIX_BUILD_BENCHMARKING:BOOL=${ELASTIX_BUILD_BENCHMARKING} -DELASTIX_BUILD_BENCHMARKING:BOOL=${ELASTIX_BUILD_BENCHMARKING}
-DELASTIX_BUILD_DASHBOARD:BOOL=${ELASTIX_BUILD_DASHBOARD} -DELASTIX_BUILD_DASHBOARD:BOOL=${ELASTIX_BUILD_DASHBOARD}
-DITK_DIR:PATH=${ITK_DIR} -DITK_DIR:PATH=${ITK_DIR}
-DBOOST_ROOT:PATH=${BOOST_ROOT}
DEPENDS ${ELASTIX_DEPENDENCIES} DEPENDS ${ELASTIX_DEPENDENCIES}
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )
\ No newline at end of file
set( PROJECT BOOST )
# Note: It IS important to download different files on different OS's:
# on Unix-like systems, we need the file persmissions (only available in the .tar.gz),
# while on Windows, we need CR/LF line feeds (only available in the .zip)
set( BOOST_CONFIGURE_COMMAND )
if( UNIX )
set( BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz")
set( BOOST_MD5 51528a0e3b33d9e10aaa311d9eb451e3 )
set( BOOST_CONFIGURE_COMMAND ./bootstrap.sh )
set( BOOST_BUILD_COMMAND ./b2 )
else()
if( WIN32 )
set( BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.zip")
set( BOOST_MD5 08d29a2d85db3ebc8c6fdfa3a1f2b83c )
set( BOOST_CONFIGURE_COMMAND cmd /C bootstrap.bat msvc )
set( BOOST_BUILD_COMMAND b2.exe )
endif()
endif()
set( BOOST_BUILD_DIR "${CMAKE_INSTALL_PREFIX}/${PROJECT}-build/" )
ExternalProject_Add( BOOST
BUILD_IN_SOURCE 1
URL "${BOOST_URL}"
URL_MD5 ${BOOST_MD5}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ${BOOST_CONFIGURE_COMMAND}
--prefix=${BOOST_BUILD_DIR}/lib
BUILD_COMMAND ${BOOST_BUILD_COMMAND} install
--prefix=${BOOST_BUILD_DIR}
--with-graph
--variant=release
--jobs=4
INSTALL_COMMAND ""
)
set( BOOST_ROOT ${BOOST_BUILD_DIR} )
set( proj ITK ) set( PROJECT ITK )
set( ITK_REPOSITORY https://github.com/InsightSoftwareConsortium/ITK.git ) set( ITK_REPOSITORY https://github.com/InsightSoftwareConsortium/ITK.git )
set( ITK_TAG "v${ITK_VERSION_STRING}") set( ITK_TAG "v${ITK_VERSION_STRING}")
ExternalProject_Add( ${proj} ExternalProject_Add( ${PROJECT}
GIT_REPOSITORY ${ITK_REPOSITORY} GIT_REPOSITORY ${ITK_REPOSITORY}
GIT_TAG ${ITK_TAG} GIT_TAG ${ITK_TAG}
UPDATE_COMMAND "" UPDATE_COMMAND ""
SOURCE_DIR ${proj} SOURCE_DIR ${PROJECT}
BINARY_DIR ${proj}-build BINARY_DIR ${PROJECT}-build
CMAKE_ARGS CMAKE_ARGS
--no-warn-unused-cli --no-warn-unused-cli
-DBUILD_EXAMPLES:BOOL=OFF -DBUILD_EXAMPLES:BOOL=OFF
...@@ -21,4 +21,4 @@ ExternalProject_Add( ${proj} ...@@ -21,4 +21,4 @@ ExternalProject_Add( ${proj}
) )
ExternalProject_Get_Property( ITK install_dir ) ExternalProject_Get_Property( ITK install_dir )
set( ITK_DIR "${install_dir}/lib/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}" ) set( ITK_DIR "${install_dir}/lib/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}" )
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
set( ElastixUnitTestFilenames set( ElastixUnitTestFilenames
elxExampleUnitTest.cxx elxExampleUnitTest.cxx
elxBluePrintTest.cxx
itkRegistration.cxx itkRegistration.cxx
itkFactory.cxx itkFactory.cxx
) )
...@@ -34,7 +35,6 @@ configure_file( ...@@ -34,7 +35,6 @@ configure_file(
) )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
add_library( DataManager elxDataManager.cxx ) add_library( DataManager elxDataManager.cxx )
list( APPEND TEST_LIBRARIES list( APPEND TEST_LIBRARIES
......
#include "elxBlueprint.h"
#include "elxComponentDescriptor.h"
#include "gtest/gtest.h"
namespace elx {
TEST( Blueprint, Instantiation )
{
typedef Blueprint< ComponentDescriptor > BlueprintType;
BlueprintType::Pointer blueprint;
EXPECT_NO_THROW( blueprint = BlueprintType::New() );
typedef BlueprintType::ComponentDescriptorType ComponentDescriptorType;
ComponentDescriptorType::Pointer componentDescriptor;
EXPECT_NO_THROW( componentDescriptor = ComponentDescriptorType::New() );
typedef ComponentDescriptorType::ComponentNameType ComponentNameType;
ComponentNameType componentName;
EXPECT_NO_THROW( componentName = ComponentNameType("Metric") );
EXPECT_NO_THROW( componentDescriptor->SetComponentName( componentName ) );
EXPECT_NO_THROW( blueprint->TestFunction() );
ASSERT_TRUE( true );
}
} // namespace elx
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment