Commit 74bf01b4 by Dirk Albrecht

[MERGE] with 3364

parents 444bc070 d2cff2e5
......@@ -12,7 +12,7 @@ allowOnlyOneFiberDataSet = yes # This will prevent you from accidently loading m
# default=HUD
## A list of modules that will be provided through the GUI.
## If the list is empty all available modules are provided.
whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Mesh Reader,Voxelizer,Superquadric Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI
whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Read Mesh,Voxelizer,Superquadric Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI
## Specify a ";" separated list of additional paths for modules. The order of appearance is the order of loading. The following additional rules apply here:
## 1. if the directory contains one or more libOWmodule_XYZ it/they get loaded
......
......@@ -113,6 +113,22 @@ IF( OSSIM_FOUND )
# MARK_AS_ADVANCED( OSSIM_LIBDIR )
ENDIF()
# insight toolkit (for image segmentation and registration)
#----------------------------------------------------------
FIND_PACKAGE( ITK QUIET )
OPTION( OW_USE_ITK "Use the insight toolkit for image segmentation" OFF )
IF( ITK_FOUND AND OW_USE_ITK )
INCLUDE( ${ITK_USE_FILE} )
ENDIF( ITK_FOUND AND OW_USE_ITK )
### Eigen #### (for the gauss process, the covariance matrices tend to be sparse and 20x20, but ~70.000 of them)
FIND_PACKAGE( Eigen3 QUIET )
IF( EIGEN3_FOUND )
MESSAGE( STATUS "Found Eigen3 in: ${EIGEN3_INCLUDE_DIR} with version: ${EIGEN3_VERSION}" )
MARK_AS_ADVANCED( EIGEN3_INCLUDE_DIR )
MARK_AS_ADVANCED( EIGEN3_VERSION )
ENDIF()
# other options:
#---------------
# Set default build type
......@@ -136,6 +152,8 @@ IF( CMAKE_GENERATOR MATCHES "Visual Studio" )
SET( CMAKE_SHARED_LINKER_FLAGS " /STACK:10000000 /machine:I386 /NODEFAULTLIB:${EXCLUDE_LIBRARIES}" CACHE STRING "" FORCE )
SET( CMAKE_EXE_LINKER_FLAGS " /STACK:10000000 /machine:I386 /NODEFAULTLIB:${EXCLUDE_LIBRARIES}" CACHE STRING "" FORCE )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"NOMINMAX\"" )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" )
SET( CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows" )
ELSE()
# Unfortunately libstdc++'s header files don't work with mingw in ansi mode (basically libstdc++'s fault)
IF( CMAKE_HOST_SYSTEM MATCHES "Windows" )
......@@ -154,6 +172,11 @@ ELSE()
SET( CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -O0" CACHE STRING "" FORCE )
ENDIF()
IF( ITK_FOUND AND OW_USE_ITK )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOW_USE_ITK" CACHE STRING "" FORCE )
SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DOW_USE_ITK" CACHE STRING "" FORCE )
ENDIF( ITK_FOUND AND OW_USE_ITK )
SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -DDEBUG -O2" CACHE STRING "" FORCE )
ADD_SUBDIRECTORY( dataHandler )
......@@ -186,6 +209,11 @@ ENDIF()
ADD_EXECUTABLE( walnut OpenWalnut.cpp version.h )
TARGET_LINK_LIBRARIES( walnut OWkernel OWdataHandler OWgui OWguiqt4 OWcommon OWge ${Boost_LIBRARIES} )
IF(MSVC_IDE)
SET_TARGET_PROPERTIES( walnut PROPERTIES DEBUG_POSTFIX "d")
SET_TARGET_PROPERTIES( walnut PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
#---------- Shaders -------------
option( OW_COPY_SHADERS "This enables copying shaders with every make call." ON )
if( OW_COPY_SHADERS )
......
......@@ -10,6 +10,10 @@ ADD_SUBDIRECTORY( math )
ADD_LIBRARY( OWcommon SHARED ${COMMON_SRC} ${COMMON_DATASTRUCTURES_SRC} ${COMMON_EXCEPTIONS_SRC} ${MATH_SRC} ${FIBERSIMILARITY_SRC} )
TARGET_LINK_LIBRARIES( OWcommon ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
IF(MSVC_IDE)
SET_TARGET_PROPERTIES( OWcommon PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
# Set the prefix and suffix of dynamically loadable modules to match
# CMAKEs naming of them. The quotes are necessary so the shell doesn't mess
# with these defines. Unfortunately, the Visual Studio has problems handling
......
......@@ -193,3 +193,8 @@ void WItemSelector::unlock()
m_lock.reset();
}
WItemSelector::operator unsigned int() const
{
return getItemIndexOfSelected( 0 );
}
......@@ -218,6 +218,13 @@ public:
*/
void unlock();
/**
* Allow cast from selector to unsigned int.
*
* \return the index of the first selected item in the selection.
*/
operator unsigned int() const;
protected:
/**
......
......@@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <cstdlib>
#include <boost/tokenizer.hpp>
......@@ -70,7 +71,22 @@ boost::filesystem::path WPathHelper::getAppPath()
boost::filesystem::path WPathHelper::getConfigFile()
{
// TODO(ebaum): we should prefer a user config file in ~.walnut.cfg in future. This needs to be platform independent of course.
return getPathHelper()->m_sharePath / "walnut.cfg";
namespace fs = boost::filesystem;
// I know that this work only for linux, but it should not break anything elsewhere.
// Thus, we prefer the file in the home directory now.
std::string homeDir = getenv( "HOME" ) ? getenv( "HOME" ) : "";
std::string linuxDefault= homeDir + "/.walnut.cfg";
boost::filesystem::path configFile;
if( fs::exists( linuxDefault ) )
{
configFile = boost::filesystem::path( linuxDefault );
}
else
{
configFile = getPathHelper()->m_sharePath / "walnut.cfg";
}
return configFile;
}
boost::filesystem::path WPathHelper::getFontPath()
......
......@@ -40,11 +40,6 @@ class OWCOMMON_EXPORT WPathHelper // NOLINT
public:
/**
* Default constructor.
*/
WPathHelper();
/**
* Destructor.
*/
virtual ~WPathHelper();
......@@ -157,6 +152,11 @@ public:
protected:
/**
* Constructors are protected because this is a Singleton.
*/
WPathHelper();
private:
/**
......
......@@ -22,20 +22,15 @@
//
//---------------------------------------------------------------------------
#include <vector>
#include "WRequirement.h"
#include "WROIBitfield.h"
WROIBitfield::WROIBitfield( boost::shared_ptr< std::vector<bool> > bitfield ) :
WROI(),
m_bitfield( bitfield )
WRequirement::WRequirement()
{
// initialize members
}
WROIBitfield::~WROIBitfield()
WRequirement::~WRequirement()
{
// cleanup
}
void WROIBitfield::updateGFX()
{
}
......@@ -22,51 +22,41 @@
//
//---------------------------------------------------------------------------
#ifndef WGAUSSPROCESS_H
#define WGAUSSPROCESS_H
#ifndef WREQUIREMENT_H
#define WREQUIREMENT_H
#include "../../common/datastructures/WFiber.h"
#include "../../common/math/WMatrix.h"
#include "../WDataSetDTI.h"
#include "WExportCommon.h"
/**
* Represents a basic gaussian process with its mean- and covariance function. Basically this aims
* to implement a part of the gaussian process framework as presented by Wasserman et. al:
* http://dx.doi.org/10.1016/j.neuroimage.2010.01.004
* Base class for all possible kinds of requirements. Derive your own kind of requirement from this class. This allows easy checking of required
* features on a target system. Of course this is only useful for things checkable during runtime. You should avoid writing classes for checking
* weather some library is installed or not. This is checked by the linker on the target system.
*/
class WGaussProcess
class OWCOMMON_EXPORT WRequirement // NOLINT
{
public:
/**
* Default constructor.
*/
WGaussProcess();
/**
* Constructs a gaussian process out of a fiber with the help of underlying diffusion tensor
* information.
*
* \param tract One deterministic tractogram
* \param tensors All 2nd order diffusion tensors
* Default constructor.
*/
WGaussProcess( const wmath::WFiber& tract, const WDataSetDTI& tensors );
WRequirement();
/**
* Default destructor.
* Destructor.
*/
virtual ~WGaussProcess();
virtual ~WRequirement();
/**
* Adds up two gaussian processes with adding the mean- and covariance fucntions.
*
* \param other The other gaussian process
* Checks if the requirement is fulfilled on the system. Implement this for your specific case.
*
* \return The new Gaussian Process adding this two processes
* \return true if the specific requirement is fulfilled.
*/
WGaussProcess operator+( const WGaussProcess& other ) const;
virtual bool isComplied() const = 0;
protected:
private:
};
#endif // WGAUSSPROCESS_H
#endif // WREQUIREMENT_H
......@@ -25,6 +25,8 @@
#ifndef WSHAREDASSOCIATIVECONTAINER_H
#define WSHAREDASSOCIATIVECONTAINER_H
#include <utility>
#include <boost/thread.hpp>
#include "WSharedObject.h"
......@@ -49,6 +51,16 @@ public:
typedef typename T::iterator Iterator;
/**
* The type of the elements
*/
typedef typename T::value_type value_type;
/**
* The type of the key used in this associative container
*/
typedef typename T::key_type key_type;
/**
* Default constructor.
*/
WSharedAssociativeContainer();
......@@ -63,6 +75,54 @@ public:
*/
void clear();
/**
* Return true if the container is empty. The sense and non-sense of this method in a multi threaded environment is questionable.
*
* \return true if empty
*/
bool empty() const;
/**
* The current size of the container. 0 if empty. The sense and non-sense of this method in a multi threaded environment is questionable.
*
* \return the size.
*/
size_t size() const;
/**
* The maximum size of a container.
*
* \return the maximum size
*/
size_t max_size() const;
/**
* Count elements with a specific key. The sense and non-sense of this method in a multi threaded environment is questionable.
*
* \param x the key
*
* \return the count, 0 if none found.
*/
size_t count( const key_type& x ) const;
/**
* Erases the element with the specified key.
*
* \param x the key
*
* \return the number of elements erased
*/
size_t erase( const key_type& x );
/**
* Inserts the specified element.
*
* \param x the element to add
*
* \return a pair containing the Iterator pointing to the inserted element and the bool is true if the element not existed before.
*/
std::pair< Iterator, bool > insert( const value_type& x );
protected:
private:
};
......@@ -87,5 +147,47 @@ void WSharedAssociativeContainer< T >::clear()
w->get().clear();
}
template < typename T >
bool WSharedAssociativeContainer< T >::empty() const
{
typename WSharedAssociativeContainer< T >::ReadTicket r = WSharedObject< T >::getReadTicket();
return r->get().empty();
}
template < typename T >
size_t WSharedAssociativeContainer< T >::size() const
{
typename WSharedAssociativeContainer< T >::ReadTicket r = WSharedObject< T >::getReadTicket();
return r->get().size();
}
template < typename T >
size_t WSharedAssociativeContainer< T >::max_size() const
{
typename WSharedAssociativeContainer< T >::ReadTicket r = WSharedObject< T >::getReadTicket();
return r->get().max_size();
}
template < typename T >
size_t WSharedAssociativeContainer< T >::count( const key_type& x ) const
{
typename WSharedAssociativeContainer< T >::ReadTicket r = WSharedObject< T >::getReadTicket();
return r->get().count( x );
}
template < typename T >
size_t WSharedAssociativeContainer< T >::erase( const key_type& x )
{
typename WSharedAssociativeContainer< T >::WriteTicket w = WSharedObject< T >::getWriteTicket();
return w->get().erase( x );
}
template < typename T >
std::pair< typename WSharedAssociativeContainer< T >::Iterator, bool > WSharedAssociativeContainer< T >::insert( const value_type& x )
{
typename WSharedAssociativeContainer< T >::WriteTicket w = WSharedObject< T >::getWriteTicket();
return w->get().insert( x );
}
#endif // WSHAREDASSOCIATIVECONTAINER_H
......@@ -54,6 +54,7 @@ public:
/**
* Class allowing thread-safe access to an object. It provides some convenience methods to read and write lock the access.
* OBSOLETE.
*/
class WSharedObjectAccess
{
......
......@@ -94,9 +94,11 @@ public:
*/
virtual void compute( boost::shared_ptr< InputType const > input, JobType const& job ) = 0;
private:
protected:
//! the input
boost::shared_ptr< InputType const > m_input;
private:
};
template< class Input_T, class Job_T >
......
......@@ -39,65 +39,42 @@ template< typename T > class WMatrix : public WValue< T >
{
public:
/**
* Produces a square matrix with the given number of components.
* The components will be set to zero if T is a type representing numbers.
*
* \param n Number of cols and rows in the matrix
*/
explicit WMatrix( size_t n );
/**
* Produces a matrix with the given number of components.
* The components will be set to zero if T is a type representing numbers.
*
* \param nbRows number of rows in the matrix
* \param nbCols number of columns in the matrix
*/
explicit WMatrix( size_t nbRows, size_t nbCols )
: WValue< T >( nbRows * nbCols )
{
m_nbCols = nbCols;
}
explicit WMatrix( size_t nbRows, size_t nbCols );
/**
* Produces a matrix as copy of the one given as parameter.
* \param newMatrix The matrix to be copied.
*/
WMatrix( const WMatrix& newMatrix )
: WValue< T >( newMatrix )
{
m_nbCols = newMatrix.m_nbCols;
}
WMatrix( const WMatrix& newMatrix );
/**
* Makes the matrix contain the identity matrix, i.e. 1 on the diagonal.
*/
WMatrix& makeIdentity()
{
size_t nbRows = this->size() / m_nbCols;
for( size_t i = 0; i < nbRows; ++i )
{
for( size_t j = 0; j < m_nbCols; ++j )
{
if( i == j )
{
(*this)( i, j ) = 1;
}
else
{
(*this)( i, j ) = 0;
}
}
}
return *this;
}
WMatrix& makeIdentity();
/**
* Get number of rows.
*/
size_t getNbRows() const
{
return this->size() / m_nbCols;
}
size_t getNbRows() const;
/**
* Get number of columns.
*/
size_t getNbCols() const
{
return m_nbCols;
}
size_t getNbCols() const;
/**
* Returns a reference to the component an row i, columns j in order to
......@@ -105,11 +82,7 @@ public:
* \param i row
* \param j column
*/
T& operator()( size_t i, size_t j )
{
WAssert( j < m_nbCols && i * m_nbCols < this->size(), "Index out of bounds." );
return (*this)[i * m_nbCols + j];
}
T& operator()( size_t i, size_t j );
/**
* Returns a const reference to the component an row i, columns j in order to
......@@ -117,40 +90,25 @@ public:
* \param i row
* \param j column
*/
const T& operator()( size_t i, size_t j ) const
{
WAssert( j < m_nbCols && i * m_nbCols < this->size(), "Index out of bounds." );
return (*this)[i * m_nbCols + j];
}
const T& operator()( size_t i, size_t j ) const;
/**
* Compares two matrices and returns true if they are equal.
* \param rhs The right hand side of the comparison
*/
bool operator==( const WMatrix& rhs ) const
{
return WValue< T >::operator==( rhs ) && m_nbCols == rhs.m_nbCols;
}
bool operator==( const WMatrix& rhs ) const;
/**
* Compares two matrices and returns true if they are not equal.
* \param rhs The right hand side of the comparison
*/
bool operator!=( const WMatrix& rhs ) const
{
return WValue< T >::operator!=( rhs ) || m_nbCols != rhs.m_nbCols;
}
bool operator!=( const WMatrix& rhs ) const;
/**
* Assigns the argument WMatrix to this WMatrix.
* \param rhs The right hand side of the assignment
*/
WMatrix& operator=( const WMatrix& rhs )
{
WValue< T >::operator=( rhs );
m_nbCols = rhs.m_nbCols;
return *this;
}
WMatrix& operator=( const WMatrix& rhs );
/**
* Multiplication of two matrices.
......@@ -173,21 +131,139 @@ public:
/**
* Returns the transposed matrix.
*/
WMatrix transposed() const
{
WMatrix result( m_nbCols, getNbRows() );
for ( std::size_t i = 0; i < getNbRows(); i++ )
for ( std::size_t j = 0; j < m_nbCols; j++ )
result( j, i ) = (*this)( i, j);
return result;
}
WMatrix transposed() const;
protected:
private:
size_t m_nbCols; //!< Number of columns of the matrix. The number of rows will be computed by (size/m_nbCols).
};
template< typename T > WMatrix< T >::WMatrix( size_t n )
: WValue< T >( n * n )
{
m_nbCols = n;
}
template< typename T > WMatrix< T >::WMatrix( size_t nbRows, size_t nbCols )
: WValue< T >( nbRows * nbCols )
{
m_nbCols = nbCols;
}
/**
* Produces a matrix as copy of the one given as parameter.
* \param newMatrix The matrix to be copied.
*/
template< typename T > WMatrix< T >::WMatrix( const WMatrix& newMatrix )
: WValue< T >( newMatrix )
{
m_nbCols = newMatrix.m_nbCols;
}
/**
* Makes the matrix contain the identity matrix, i.e. 1 on the diagonal.
*/
template< typename T > WMatrix< T >& WMatrix< T >::makeIdentity()
{
size_t nbRows = this->size() / m_nbCols;
for( size_t i = 0; i < nbRows; ++i )
{
for( size_t j = 0; j < m_nbCols; ++j )
{
if( i == j )
{
(*this)( i, j ) = 1;
}
else
{
(*this)( i, j ) = 0;
}
}
}
return *this;
}
/**
* Get number of rows.
*/
template< typename T > size_t WMatrix< T >::getNbRows() const
{
return this->size() / m_nbCols;
}
/**
* Get number of columns.
*/
template< typename T > size_t WMatrix< T >::getNbCols() const
{
return m_nbCols;
}
/**
* Returns a reference to the component an row i, columns j in order to
* provide access to the component.
* \param i row
* \param j column
*/
template< typename T > T& WMatrix< T >::operator()( size_t i, size_t j )
{
WAssert( j < m_nbCols && i * m_nbCols < this->size(), "Index out of bounds." );
return (*this)[i * m_nbCols + j];
}
/**
* Returns a const reference to the component an row i, columns j in order to
* provide read-only access to the component.
* \param i row
* \param j column
*/
template< typename T > const T& WMatrix< T >::operator()( size_t i, size_t j ) const
{
WAssert( j < m_nbCols && i * m_nbCols < this->size(), "Index out of bounds." );
return (*this)[i * m_nbCols + j];
}
/**
* Compares two matrices and returns true if they are equal.
* \param rhs The right hand side of the comparison
*/
template< typename T > bool WMatrix< T >::operator==( const WMatrix& rhs ) const
{
return WValue< T >::operator==( rhs ) && m_nbCols == rhs.m_nbCols;
}
/**
* Compares two matrices and returns true if they are not equal.
* \param rhs The right hand side of the comparison
*/
template< typename T > bool WMatrix< T >::operator!=( const WMatrix& rhs ) const
{
return WValue< T >::operator!=( rhs ) || m_nbCols != rhs.m_nbCols;
}
/**
* Assigns the argument WMatrix to this WMatrix.
* \param rhs The right hand side of the assignment
*/
template< typename T > WMatrix< T >& WMatrix< T >::operator=( const WMatrix& rhs )
{
WValue< T >::operator=( rhs );
m_nbCols = rhs.m_nbCols;
return *this;
}
/**
* Returns the transposed matrix.
*/
template< typename T > WMatrix< T > WMatrix< T >::transposed() const
{
WMatrix result( m_nbCols, getNbRows() );
for ( std::size_t i = 0; i < getNbRows(); i++ )
for ( std::size_t j = 0; j < m_nbCols; j++ )
result( j, i ) = (*this)( i, j);
return result;
}
template< typename T > WMatrix< T > WMatrix< T >::operator*( const WMatrix< T >& rhs ) const
{
......