Commit aa1535da authored by Kasper Marstal's avatar Kasper Marstal
Browse files

Merge branch 'elastix-152-build-commandline-program-in-superbuild' into develop

parents 97d5929b fd498a0e
#=========================================================================
#
# Copyright Leiden University Medical Center, Erasmus University Medical
# Center and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#=========================================================================
cmake_minimum_required( VERSION 3.0.2 )
project(SuperElastixExamples)
if( NOT CMAKE_PROJECT_NAME STREQUAL "SuperElastix" )
# Examples are build as an external project, need to import dependencies
set(CMAKE_CXX_STANDARD 11)
find_package( SuperElastix )
include( ${SUPERELASTIX_USE_FILE} )
find_package( ITK )
include( ${ITK_USE_FILE} )
message( STATUS "ELASTIX_USE_FILE: ${ELASTIX_USE_FILE}")
include( ${ELASTIX_USE_FILE} )
endif()
add_subdirectory( CommandlineProgram )
\ No newline at end of file
......@@ -17,39 +17,20 @@
#
#=========================================================================
set( COMMANDLINE_SOURCE_DIR
${CMAKE_SOURCE_DIR}/Modules/CommandLine
)
# Export include files
set( COMMANDLINE_INCLUDE_DIRS
${COMMANDLINE_SOURCE_DIR}/include
)
# Collect header files for Visual Studio Project
# http://stackoverflow.com/questions/8316104/specify-how-cmake-creates-visual-studio-project
file(GLOB COMMANDLINE_HEADER_FILES "${COMMANDLINE_SOURCE_DIR}/*/include/*.*")
# Module source files
set( COMMANDLINE_SOURCE_FILES
${COMMANDLINE_SOURCE_DIR}/src/selxCommandLine.cxx
${CMAKE_CURRENT_SOURCE_DIR}/src/selxSuperElastix.cxx
)
message(STATUS "BOOST_LIBRARYDIR: ${BOOST_LIBRARYDIR}")
message(STATUS "BOOST_ROOT: ${BOOST_ROOT}")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
#set(Boost_USE_STATIC_RUNTIME OFF)
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib)
message(STATUS "BOOST_LIBRARYDIR: ${BOOST_LIBRARYDIR}")
find_package(Boost COMPONENTS program_options system filesystem REQUIRED)
#find_package(Boost REQUIRED)
include_directories( ${COMMANDLINE_INCLUDE_DIRS} )
# Compile executable
add_executable( SuperElastix ${COMMANDLINE_SOURCE_FILES} ${COMMANDLINE_HEADER_FILES} )
target_link_libraries( SuperElastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES})
add_executable( superelastix ${COMMANDLINE_SOURCE_FILES} ${COMMANDLINE_HEADER_FILES} )
target_link_libraries( superelastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES})
......@@ -41,6 +41,7 @@ macro( _selxmodule_enable MODULE_NAME )
if( ${MODULE_NAME}_INCLUDE_DIRS )
include_directories( ${${MODULE_NAME}_INCLUDE_DIRS} )
list( APPEND SUPERELASTIX_INCLUDE_DIRS ${${MODULE_NAME}_INCLUDE_DIRS} )
endif()
if( ${MODULE_NAME}_LIBRARIES )
......@@ -63,6 +64,7 @@ endmacro()
macro( _selxmodules_initialize )
set( SUPERELASTIX_MODULES )
set( SUPERELASTIX_INCLUDE_DIRS )
set( SUPERELASTIX_LIBRARIES )
set( SUPERELASTIX_TESTS )
......
......@@ -30,10 +30,14 @@ enable_language(C)
enable_language(CXX)
set( CMAKE_CXX_STANDARD 11 )
# Place libraries and executables in the bin directory
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}/bin"
)
# Place executables in the bin directory
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" )
# Place shared libraries in the lib directory
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
# Place static libraries in the lib directory
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" )
# Include SuperElastix CMake scripts
list( APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake" )
......@@ -88,6 +92,7 @@ include_directories( ${Boost_INCLUDE_DIRS} )
# For now we just enable all modules
include( selxModules )
selxmodule_enable( ModuleCore )
selxmodule_enable( ModuleLog )
selxmodule_enable( ModuleExamples )
selxmodule_enable( ModuleSinksAndSources )
selxmodule_enable( ModuleItkSmoothingRecursiveGaussianImageFilter )
......@@ -95,8 +100,6 @@ selxmodule_enable( ModuleItkImageRegistrationMethodv4 )
selxmodule_enable( ModuleItkSyNImageRegistrationMethod )
selxmodule_enable( ModuleElastix )
selxmodule_enable( ModuleController )
#selxmodule_enable( ModuleCommandLine )
include(${CMAKE_SOURCE_DIR}/Modules/CommandLine/CommandLine.cmake)
# TODO: Build tests depending on enabled modules
# ---------------------------------------------------------------------
......@@ -110,7 +113,7 @@ if( ${SUPERELASTIX_BUILD_TESTING} )
add_subdirectory( Testing )
endif()
# -----------------------------------------------------------brkdwn----------
# ---------------------------------------------------------------------
# Build Documentation
mark_as_advanced( SUPERELASTIX_BUILD_DOXYGEN )
......@@ -119,15 +122,23 @@ option( SUPERELASTIX_BUILD_DOXYGEN "Enable building Doxygen documentation." OFF
mark_as_advanced( SUPERELASTIX_BUILD_READTHEDOCS )
option( SUPERELASTIX_BUILD_READTHEDOCS "Enable building readthedocs.org documentation." OFF )
# ---------------------------------------------------------------------
# Enable other projects to use SuperElastix via CMake's find_packge() and a use-file
set( SUPERELASTIX_CONFIG_DIR ${CMAKE_CURRENT_BINARY_DIR} )
set( SUPERELASTIX_BINARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} )
configure_file( SuperElastixConfig.cmake.in SuperElastixConfig.cmake @ONLY IMMEDIATE )
configure_file( UseSuperElastix.cmake.in UseSuperElastix.cmake COPYONLY IMMEDIATE )
# ---------------------------------------------------------------------
# Install
# When building the "INSTALL" project of SuperElastix these files are installed
# Copy the SuperElastix executable
install(TARGETS "SuperElastix"
RUNTIME DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/installed"
)
# install(TARGETS "SuperElastix"
# RUNTIME DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/installed"
# )
# Copy some of the configuration files
install(FILES "${SUPERELASTIX_UNITTEST_CONFIGURATION_DATA_DIR}/itkv4_SVF_ANTsCC.json"
......
......@@ -30,6 +30,7 @@
#include <string.h>
#include "selxMacro.h"
namespace selx
{
template< int Dimensionality, class TPixel >
......
......@@ -77,7 +77,7 @@ ElastixComponent< Dimensionality, TPixel >::Set( itkImageMovingInterface< Dimens
// connect the itk pipeline
this->m_elastixFilter->SetMovingImage( movingImage );
// In the current transformix filter an input image is required even if we want a deformation field only.
this->m_transformixFilter->SetInput( movingImage );
this->m_transformixFilter->SetMovingImage( movingImage );
return 0;
}
......
......@@ -40,7 +40,7 @@ class MonolithicElastixComponent :
itkImageMovingInterface< Dimensionality, TPixel >
>,
Providing<
elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >, itk::Image< TPixel, Dimensionality >>,
elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >, itk::Image< TPixel, Dimensionality > >,
itkImageInterface< Dimensionality, TPixel >,
RunRegistrationInterface
>
......@@ -72,7 +72,7 @@ public:
typedef elxParameterObjectType::Pointer elxParameterObjectPointer;
typedef typename elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >,
itk::Image< TPixel, Dimensionality >>::elastixTransformParameterObject elastixTransformParameterObject;
itk::Image< TPixel, Dimensionality > >::elastixTransformParameterObject elastixTransformParameterObject;
// Accepting Interfaces:
virtual int Set( itkImageFixedInterface< Dimensionality, TPixel > * ) override;
......
......@@ -38,7 +38,7 @@ class MonolithicTransformixComponent :
Accepting<
itkImageDomainFixedInterface< Dimensionality >,
itkImageMovingInterface< Dimensionality, TPixel >,
elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >, itk::Image< TPixel, Dimensionality >>
elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >, itk::Image< TPixel, Dimensionality > >
>,
Providing<
itkImageInterface< Dimensionality, TPixel >,
......@@ -68,7 +68,7 @@ public:
typedef elastix::TransformixFilter< MovingImageType > TransformixFilterType;
typedef elastixTransformParameterObjectInterface< itk::Image< TPixel, Dimensionality >,
itk::Image< TPixel, Dimensionality >> elastixTransformParameterObjectInterfaceType;
itk::Image< TPixel, Dimensionality > > elastixTransformParameterObjectInterfaceType;
// Accepting Interfaces:
virtual int Set( itkImageDomainFixedInterface< Dimensionality > * ) override;
......
......@@ -35,7 +35,7 @@ MonolithicTransformixComponent< Dimensionality, TPixel >::MonolithicTransformixC
//TODO m_elastixFilter returns a nullptr GetTransformParameterObject instead of a valid object. However, we need this object to satisfy the input conditions of m_transformixFilter
elxParameterObjectPointer trxParameterObject = elxParameterObjectType::New();
//typename elxParameterObjectType::ParameterMapType defaultParameters = elxParameterObject->GetDefaultParameterMap("rigid");
//typename elxParameterObjectType::ParameterMapType defaultParameters = elxParameterObject->Get ParameterMap("rigid");
//elxParameterObject->SetParameterMap(defaultParameters);
//m_transformixFilter->SetTransformParameterObject(m_elastixFilter->GetTransformParameterObject());
m_transformixFilter->SetTransformParameterObject( trxParameterObject ); // supply a dummy object
......@@ -109,7 +109,7 @@ MonolithicTransformixComponent< Dimensionality, TPixel >::Set( itkImageMovingInt
{
auto movingImage = component->GetItkImageMoving();
// connect the itk pipeline
this->m_transformixFilter->SetInput( movingImage );
this->m_transformixFilter->SetMovingImage( movingImage );
return 0;
}
......
......@@ -58,7 +58,7 @@ public:
ItkImageSourceMovingComponent< 2, float >,
ItkImageSourceFixedComponent< 3, double >,
ItkImageSourceMovingComponent< 3, double >,
RegistrationControllerComponent< >> RegisterComponents;
RegistrationControllerComponent< > > RegisterComponents;
typedef SuperElastixFilter< RegisterComponents > SuperElastixFilterType;
......
......@@ -31,8 +31,8 @@ namespace selx
template< int Dimensionality, class TPixel >
class ItkSmoothingRecursiveGaussianImageFilterComponent :
public SuperElastixComponent<
Accepting< itkImageInterface< Dimensionality, TPixel >>,
Providing< itkImageInterface< Dimensionality, TPixel >>
Accepting< itkImageInterface< Dimensionality, TPixel > >,
Providing< itkImageInterface< Dimensionality, TPixel > >
>
{
public:
......@@ -46,7 +46,7 @@ public:
typedef TPixel PixelType;
typedef itk::SmoothingRecursiveGaussianImageFilter< itk::Image< PixelType, Dimensionality >,
itk::Image< PixelType, Dimensionality >> TheItkFilterType;
itk::Image< PixelType, Dimensionality > > TheItkFilterType;
typedef itk::Image< PixelType, Dimensionality > ItkImageType;
typedef typename ItkImageType::Pointer
ItkImagePointer;
......
#=========================================================================
#
# Copyright Leiden University Medical Center, Erasmus University Medical
# Center and contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#=========================================================================
set( MODULE ModuleLog )
# Export include files
set( ${MODULE}_INCLUDE_DIRS
${${MODULE}_SOURCE_DIR}/include
)
# Collect header files for Visual Studio Project
file(GLOB ${MODULE}_HEADER_FILES "${${MODULE}_SOURCE_DIR}/include/*.*")
# Export libraries
set( ${MODULE}_LIBRARIES
${MODULE}
)
# Export tests
set( ${MODULE}_TESTS
${${MODULE}_SOURCE_DIR}/test/selxLogComponentTest.cxx
)
# Module source files
set( ${MODULE}_SOURCE_FILES
${${MODULE}_SOURCE_DIR}/src/selxLogComponent.cxx
)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib)
find_package(Boost COMPONENTS log REQUIRED)
# Compile library
add_library( ${MODULE} STATIC "${${MODULE}_SOURCE_FILES}" ${${MODULE}_HEADER_FILES})
target_link_libraries( ${MODULE} ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES} )
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef selxLogComponent_h
#define selxLogComponent_h
#include "selxInterfaces.h"
#include "selxSuperElastixComponent.h"
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
namespace selx
{
class LogComponent :
public SuperElastixComponent<
Accepting< >,
Providing
<
LogInterface
>
>
{
public:
//@kasper: somehow the selxNewMacro does not work. The itkNewMacro, however works. Something to figure out why...
//selxNewMacro( LogComponent, ComponentBase );
/** Standard class typedefs. */
typedef LogComponent Self;
typedef ComponentBase Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
/** New macro for creation of through the object factory. */
//selxNewMacro(Self, ComponentBase);
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(LogComponent, ComponentBase);
LogComponent();
virtual ~LogComponent(){};
virtual std::stringstream Log( boost::log::trivial::severity_level severity_level ) override;
virtual bool MeetsCriterion(const CriterionType & criterion) override;
static const char * GetDescription() { return "Log Component"; }
private:
boost::log::trivial::severity_level m_LogLevel;
};
}
#endif // selxLogComponent_h
\ No newline at end of file
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef selxLogComponent_cxx
#define selxLogComponent_cxx
#include "selxLogComponent.h"
#include "selxMacro.h"
namespace selx
{
LogComponent
::LogComponent( void )
{
// this->m_LogLevel = boost::log::trivial::severity_level::info;
}
std::stringstream
LogComponent
::Log( boost::log::trivial::severity_level severity_level )
{
//return BOOST_LOG_TRIVIAL( ::boost::log::keywords::severity = severity_level );
return std::stringstream();
}
bool
LogComponent
::MeetsCriterion( const CriterionType & criterion )
{
bool meetsCriteria( false );
if( criterion.first == "LogLevel" )
{
meetsCriteria = true;
//for( auto const & criterionValue : criterion.second ) // auto&& preferred?
//{
//if( criterionValue != "INFO" ) // e.g. "GradientDescent", "SupportsSparseSamples
//{
// meetsCriteria = false;
//}
//}
}
return meetsCriteria;
}
}
#endif // selxLogComponent_cxx
/*=========================================================================
*
* Copyright Leiden University Medical Center, Erasmus University Medical
* Center and contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#include "selxLogComponent.h"
#include "gtest/gtest.h"
using namespace selx;
TEST( selxLogComponent, Initialization )
{
LogComponent::Pointer logger = LogComponent::New();
EXPECT_TRUE( true );
}
\ No newline at end of file
......@@ -33,7 +33,7 @@ namespace selx
template< int Dimensionality, class TPixel >
class DisplacementFieldItkImageFilterSinkComponent :
public SuperElastixComponent<
Accepting< DisplacementFieldItkImageSourceInterface< Dimensionality, TPixel >>,
Accepting< DisplacementFieldItkImageSourceInterface< Dimensionality, TPixel > >,
Providing< SinkInterface >
>
{
......
......@@ -34,7 +34,7 @@ namespace selx
template< int Dimensionality, class TPixel >
class ItkImageSinkComponent :
public SuperElastixComponent<
Accepting< itkImageInterface< Dimensionality, TPixel >>,
Accepting< itkImageInterface< Dimensionality, TPixel > >,
Providing< SinkInterface >
>
{
......
......@@ -33,7 +33,7 @@ template< int Dimensionality, class TPixel >
class ItkImageSourceComponent :
public SuperElastixComponent<
Accepting< >,
Providing< SourceInterface, itkImageInterface< Dimensionality, TPixel >>
Providing< SourceInterface, itkImageInterface< Dimensionality, TPixel > >
>
{
public:
......
......@@ -35,7 +35,7 @@ class ItkImageSourceFixedComponent :
Accepting< >,
Providing< SourceInterface,
itkImageFixedInterface< Dimensionality, TPixel >,
itkImageDomainFixedInterface< Dimensionality >>
itkImageDomainFixedInterface< Dimensionality > >
>
{
public:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment