Skip to content
Snippets Groups Projects
Commit 9fef368b authored by Kasper Marstal's avatar Kasper Marstal
Browse files

Merge branch 'ELASTIX-9-blueprints' into develop

parents 0b4bf195 a998d526
No related branches found
No related tags found
No related merge requests found
Showing
with 410 additions and 33 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( USE_${MODULE} ON )
include( ${${MODULE}_FILE} )
if( ${MODULE}_INCLUDE_DIRS )
include_directories( ${${MODULE}_INCLUDE_DIRS} )
endif()
add_subdirectory( ${${MODULE}_SOURCE_DIR} )
if( ${MODULE}_LIBRARIES )
link_directories( ${${MODULE}_LIBRARY_DIRS} )
list( APPEND ELASTIX_LIBRARIES
${${MODULE}_LIBRARIES}
)
endif()
# TODO: Add recursive dependency walk
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}_FILE" ${CMAKE_SOURCE_DIR}/${MODULE_FILE} )
set( "${MODULE}_ENABLED" OFF )
set( ${MODULE}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${MODULE_PATH} )
set( ${MODULE}_BINARY_DIR ${CMAKE_BINARY_DIR}/${MODULE_PATH} )
set( ${MODULE}_INCLUDE_DIRS )
set( ${MODULE}_LIBRARY_DIRS )
set( ${MODULE}_LIBRARIES )
list(APPEND ELXMODULE_ALL ${MODULE} )
endforeach()
endmacro()
_elxmodules_initialize()
# ---------------------------------------------------------------------
# Public interface
macro( elxmodule_enable MODULE )
_elxmodule_enable( ${MODULE} )
endmacro()
macro( elxmodule_compile MODULE )
project( "${MODULE}" )
add_library( ${MODULE} STATIC "${${MODULE}_SOURCE_FILES}" )
target_link_libraries( ${MODULE} ${ELASTIX_LIBRARIES} )
list( APPEND ${MODULE}_LIBRARIES ${MODULE} )
endmacro()
......@@ -7,6 +7,11 @@ set( MSVC_INCREMENTAL_DEFAULT ON )
# ---------------------------------------------------------------------
project( Elastix )
# Place libraries and executables in the bin directory
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bin"
)
# Include SuperElastix CMake scripts
set( CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/CMake"
......@@ -25,23 +30,16 @@ include( ${ITK_USE_FILE} )
include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxITKRequiredModules.cmake" )
# ---------------------------------------------------------------------
# Build Elastix
set( ELASTIX_COMMON_INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/Modules/Core/Common/include
)
# Boost Graph Library
find_package( Boost REQUIRED graph )
include_directories( ${Boost_INCLUDE_DIRS} )
set( ELASTIX_CORE_INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/Modules/Core/Blueprints/include
)
set( ELASTIX_INCLUDE_DIRECTORIES
${ELASTIX_COMMON_INCLUDE_DIRECTORIES}
${ELASTIX_CORE_INCLUDE_DIRECTORIES}
)
# ---------------------------------------------------------------------
# Build Elastix
include_directories( ${ELASTIX_INCLUDE_DIRECTORIES} )
add_subdirectory( Modules )
# For now we just enable all modules
include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxModules.cmake" )
elxmodule_enable( elxModuleCore )
# ---------------------------------------------------------------------
# Testing
......
add_subdirectory(
Core
)
#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 "itkObjectFactory.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;
ComponentDescriptor( void ) { this->SetComponentName( ComponentNameType() ); }
ComponentDescriptor( const ComponentNameType componentName );
// TODO: Setter should validate ComponentName exists in ComponentDatabase
itkSetMacro( ComponentName, ComponentNameType );
itkGetMacro( ComponentName, ComponentNameType );
private:
ComponentNameType m_ComponentName;
};
}
#endif // __ComponentDescriptor_h
#ifndef __Blueprint_hxx
#define __Blueprint_hxx
#include <boost/graph/graphviz.hpp>
#include "elxBlueprint.h"
namespace elx {
/*
Blueprint< ComponentDescriptor >::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;
}
*/
template<>
int
Blueprint< ComponentDescriptor >
::TestFunction( void )
{ return 0; }
} // namespace elx
#endif // __Blueprint_hxx
\ No newline at end of file
#ifndef __ComponentDescriptor_cxx
#define __ComponentDescriptor_cxx
#include "elxComponentDescriptor.h"
// TODO: Need enum for component name?
namespace elx {
ComponentDescriptor
::ComponentDescriptor( const ComponentNameType componentName )
{
this->SetComponentName( componentName );
}
} // namespace elx
#endif // __ComponentDescriptor_cxx
\ No newline at end of file
add_subdirectory( Common )
add_subdirectory( Blueprints )
elxmodule_compile( ${MODULE} )
include_directories( include )
set( ${MODULE}_INCLUDE_DIRS
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Common/include
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/include
)
set( ${MODULE}_SOURCE_FILES
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/src/elxComponentDescriptor.cxx
${CMAKE_SOURCE_DIR}/${MODULE_PATH}/Blueprints/src/elxBlueprint.cxx
)
set( ${MODULE}_LIBRARIES
elxModuleCore
)
\ No newline at end of file
cmake_minimum_required( VERSION 2.8 )
#---------------------------------------------------------------------
# ---------------------------------------------------------------------
project( ElastixSuperBuild )
find_package( Git REQUIRED )
......@@ -15,7 +15,7 @@ set( CMAKE_MODULE_PATH
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "SuperBuild install directory" FORCE)
#---------------------------------------------------------------------
# ---------------------------------------------------------------------
# Elastix SuperBuild configuration
# Build release by default
......@@ -29,13 +29,16 @@ option( ELASTIX_BUILD_EXAMPLES "Enable building examples." ON )
# Build tests by default
option( ELASTIX_BUILD_TESTING "Enable building tests." ON )
if( ELASTIX_BUILD_TESTING )
option( ELASTIX_BUILD_BENCHMARKING "Enable building benchmarks." ON )
option( ELASTIX_BUILD_DASHBOARD "Enable building benchmarks." ON )
endif()
#---------------------------------------------------------------------
# Do not build dashboard by default
option( ELASTIX_BUILD_DASHBOARD "Enable building dashboard." OFF )
# ---------------------------------------------------------------------
# Build ITK
set( ITK_VERSION_MAJOR "4" )
......@@ -54,7 +57,19 @@ else()
list( APPEND ELASTIX_DEPENDENCIES ITK )
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
include( Elastix )
......
......@@ -6,10 +6,12 @@ ExternalProject_Add( ${proj}
BINARY_DIR ${proj}-build
CMAKE_ARGS
--no-warn-unused-cli
-DELASTIX_BUILD_EXAMPLES:BOOL=${ELASTIX_BUILD_EXAMPLES}
-DELASTIX_BUILD_TESTING:BOOL=${ELASTIX_BUILD_TESTING}
-DELASTIX_BUILD_BENCHMARKING:BOOL=${ELASTIX_BUILD_BENCHMARKING}
-DELASTIX_BUILD_DASHBOARD:BOOL=${ELASTIX_BUILD_DASHBOARD}
-DITK_DIR:PATH=${ITK_DIR}
-DBOOST_ROOT:PATH=${BOOST_ROOT}
DEPENDS ${ELASTIX_DEPENDENCIES}
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_TAG "v${ITK_VERSION_STRING}")
ExternalProject_Add( ${proj}
ExternalProject_Add( ${PROJECT}
GIT_REPOSITORY ${ITK_REPOSITORY}
GIT_TAG ${ITK_TAG}
UPDATE_COMMAND ""
SOURCE_DIR ${proj}
BINARY_DIR ${proj}-build
SOURCE_DIR ${PROJECT}
BINARY_DIR ${PROJECT}-build
CMAKE_ARGS
--no-warn-unused-cli
-DBUILD_EXAMPLES:BOOL=OFF
......@@ -21,4 +21,4 @@ ExternalProject_Add( ${proj}
)
ExternalProject_Get_Property( ITK install_dir )
set( ITK_DIR "${install_dir}/lib/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}" )
\ No newline at end of file
set( ITK_DIR "${install_dir}/lib/cmake/ITK-${ITK_VERSION_MAJOR}.${ITK_VERSION_MINOR}" )
......@@ -5,6 +5,7 @@
set( ElastixUnitTestFilenames
elxExampleUnitTest.cxx
elxBluePrintTest.cxx
itkRegistration.cxx
)
......@@ -33,7 +34,6 @@ configure_file(
)
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
add_library( DataManager elxDataManager.cxx )
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
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