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

ENH: ELASTIX-6 Add ComponentDescriptor and Blueprint classes

parent 70637666
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,11 @@ find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )
include( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/elxITKRequiredModules.cmake" )
# ---------------------------------------------------------------------
# Boost Graph Library
find_package( Boost REQUIRED graph )
include_directories(${Boost_INCLUDE_DIRS})
# ---------------------------------------------------------------------
# Build Elastix
......
include_directories( include )
#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 boost::adjacency_list< boost::listS,
boost::listS,
boost::directedS,
ComponentDescriptorType > GraphType;
typedef typename boost::graph_traits< GraphType >::vertex_descriptor ComponentType;
typedef typename boost::graph_traits< GraphType >::vertex_iterator ComponentIterator, ComponentIteratorEnd;
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;
void SetGraph( GraphType graph ) { this->m_Graph = graph; };
GraphType GetGraph( void ) const { return m_Graph; };
void AddComponent( ComponentDescriptorType component );
void RemoveComponent( ComponentDescriptorType component );
void AddConnection( ComponentDescriptorType upstream, ComponentDescriptorType downstream );
void RemoveConnection( ConnectionDescriptorType connection );
private:
GraphType m_Graph;
};
}
#endif // #define __Blueprint_h
\ No newline at end of file
#ifndef __ComponentDescriptor_h
#define __ComponentDescriptor_h
#include "elxMacro.h"
#include "itkLightObject.h"
namespace elx {
class ComponentDescriptor : public itk::LightObject
{
public:
elxNewMacro( ComponentDescriptor, itk::LightObject );
typedef std::string ComponentNameType;
typedef std::map< std::string, std::vector< std::string > > ParameterMapType;
void SetComponentName( ComponentNameType componentName ) { this->m_ComponentName = componentName; };
ComponentNameType GetComponentName( void ) { return this->m_ComponentName; };
private:
ComponentNameType m_ComponentName;
ParameterMapType m_ParameterMap;
};
}
#endif // __ComponentDescriptor_h
\ 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->m_Graph = GraphType;
}
ComponentDescriptorType
Blueprint< ComponentDescriptor >
::AddComponent( ComponentDescriptorType component )
{
this->Modified();
return this->m_Graph->add_vertex( component );
}
void
Blueprint< ComponentDescriptor >
::RemoveComponent( ComponentDescriptorType component )
{
this->Modified();
this->m_Graph->remove_vertex( connection );
}
void
Blueprint< ComponentDescriptor >
::AddConnection( ComponentDescriptorType upsteam, ComponentDescriptorType downstream )
{
this->Modified();
this->m_Graph->add_edge( upstream, downstream );
}
void
Blueprint< ComponentDescriptor >
::RemoveConnection( ConnectionType connection )
{
this->Modified();
this->m_Graph->remove_edge( connection );
}
void Blueprint< ComponentDescriptor >
::PrintSelf( void )
{
boost::write_graphviz(std::cout, this->m_Graph);
}
}
#endif // __Blueprint_hxx
\ No newline at end of file
add_subdirectory( Common )
add_subdirectory( Blueprints )
add_subdirectory( BluePrints )
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,18 @@ 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" ON )
if( USE_SYSTEM_BOOST )
find_package( BOOST REQUIRED graph )
else()
message( FATAL_ERROR "BOOST is not yet integrated with the SuperBuild. Install BOOST on your system, set USE_SYSTEM_BOOST to ON and re-run CMake." )
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
)
#include "elxBlueprint.h"
#include "elxComponentDescriptor.h"
#include "gtest/gtest.h"
namespace elx {
TEST( Blueprint, Instantiation )
{
typedef Blueprint< ComponentDescriptor > BlueprintType;
BlueprintType::Pointer blueprint = BlueprintType::New();
typedef BlueprintType::ComponentDescriptorType ComponentDescriptorType;
ComponentDescriptorType::Pointer componentDescriptor = ComponentDescriptorType::New();
typedef ComponentDescriptorType::ComponentNameType ComponentNameType;
ComponentNameType componentName = ComponentNameType("Metric");
componentDescriptor->SetComponentName( componentName );
// We would like to save all data in the graph itself, but the following is
// not possible because the component (of type itk::LightObject has private copy
// constructor. How do we save data in graph and make this as itk-like as possible?
// Ideally when a component descriptor is changed the blueprint calls Modified() on itself
// blueprint->AddComponent( (*componentDescriptor) );
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