Commit efe2be07 authored by Mathias Goldau's avatar Mathias Goldau

[CHANGE] merged utils and common

[ADD] some missed documentation of WBresenham_test.h
parent 73c2a372
......@@ -104,7 +104,6 @@ ADD_SUBDIRECTORY( math )
ADD_SUBDIRECTORY( dataHandler )
ADD_SUBDIRECTORY( graphicsEngine )
ADD_SUBDIRECTORY( gui )
ADD_SUBDIRECTORY( utils )
ADD_SUBDIRECTORY( kernel )
ADD_SUBDIRECTORY( common )
ADD_SUBDIRECTORY( modules )
......
......@@ -15,7 +15,7 @@ TARGET_LINK_LIBRARIES( common ${Boost_LIBRARIES} )
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${COMMON_SRC}"
"common;utils"
"common"
"WSegmentationFault.cpp"
"WTransferable.cpp"
"WConditionSet.cpp"
......
......@@ -26,7 +26,7 @@
#include <string>
#include <vector>
#include "../utils/WStringUtils.h"
#include "../common/WStringUtils.h"
#include "WColor.h"
WColor::WColor( float red, float green, float blue, float alpha )
......
......@@ -31,7 +31,7 @@
#include <boost/program_options.hpp>
#include "../utils/WIOTools.h"
#include "../common/WIOTools.h"
#include "WProperties.h"
#include "WLogger.h"
......
......@@ -3,6 +3,6 @@ FILE( GLOB COMMON_DATASTRUCTURES_SRC "*.cpp" "*.h" )
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${COMMON_DATASTRUCTURES_SRC}"
"common;utils" # no libs for linking required
"common" # no libs for linking required
)
ENDIF( OW_COMPILE_TESTS )
......@@ -15,7 +15,7 @@ ELSE()
FILE( GLOB DATAHANDLER_IO_SRC "io/*.cpp" "io/*.h" ) # former WLoader
ADD_LIBRARY( dataHandler SHARED ${DATAHANDLER_SRC} ${DATAHANDLER_EXCEPTIONS_SRC} ${DATAHANDLER_IO_SRC} )
TARGET_LINK_LIBRARIES( dataHandler common math utils ${Boost_LIBRARIES} niftiio biosig ${OPENSCENEGRAPH_LIBRARIES})
TARGET_LINK_LIBRARIES( dataHandler common math ${Boost_LIBRARIES} niftiio biosig ${OPENSCENEGRAPH_LIBRARIES})
ENDIF()
# Unit tests
IF( OW_COMPILE_TESTS )
......
......@@ -24,7 +24,7 @@
#include <string>
#include "../utils/WIOTools.h"
#include "../common/WIOTools.h"
#include "WLoader.h"
#include "exceptions/WDHIOFailure.h"
......
......@@ -30,7 +30,7 @@
#include <boost/lexical_cast.hpp>
#include "../../common/WException.h"
#include "../../utils/WStringUtils.h"
#include "../../common/WStringUtils.h"
#include "../WEEG.h"
#include "../WSubject.h"
#include "WLoaderEEGASCII.h"
......
......@@ -32,10 +32,10 @@
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include "../../common/WIOTools.h"
#include "../../common/WLogger.h"
#include "../../common/WStringUtils.h"
#include "../../math/WPosition.h"
#include "../../utils/WIOTools.h"
#include "../../utils/WStringUtils.h"
#include "../WDataSetFibers.h"
#include "../WSubject.h"
#include "WLoaderFibers.h"
......
......@@ -24,7 +24,7 @@
#include <string>
#include "../../utils/WIOTools.h"
#include "../../common/WIOTools.h"
#include "../exceptions/WDHNoSuchFile.h"
#include "WReader.h"
......
......@@ -30,8 +30,8 @@
#include <boost/lexical_cast.hpp>
#include <boost/shared_ptr.hpp>
#include "../../utils/WIOTools.h"
#include "../../utils/WStringUtils.h"
#include "../../common/WIOTools.h"
#include "../../common/WStringUtils.h"
#include "../exceptions/WDHException.h"
#include "../exceptions/WDHIOFailure.h"
#include "WReader.h"
......
......@@ -24,7 +24,7 @@
#include <string>
#include "../../utils/WIOTools.h"
#include "../../common/WIOTools.h"
#include "../exceptions/WDHIOFailure.h"
#include "WWriter.h"
......
......@@ -28,7 +28,7 @@
#include <boost/shared_ptr.hpp>
#include "../../utils/WIOTools.h"
#include "../../common/WIOTools.h"
#include "../WDataSetFibers.h"
#include "../exceptions/WDHIOFailure.h"
#include "WWriterFiberVTK.h"
......
......@@ -29,7 +29,7 @@
#include <boost/shared_ptr.hpp>
#include "../../utils/WIOTools.h"
#include "../../common/WIOTools.h"
#include "../exceptions/WDHIOFailure.h"
#include "WWriterLookUpTableVTK.h"
......
......@@ -34,15 +34,15 @@
#include <QtGui/QFileDialog>
#include "WMainWindow.h" // this has to be included before any other includes
#include "events/WModuleAssocEvent.h"
#include "events/WModuleReadyEvent.h"
#include "../../common/WConditionOneShot.h"
#include "../../common/WIOTools.h"
#include "../../graphicsEngine/WGraphicsEngine.h"
#include "../../kernel/WKernel.h"
#include "../../modules/data/WMData.h"
#include "../../utils/WIOTools.h"
#include "WOpenCustomDockWidgetEvent.h"
#include "../../common/WConditionOneShot.h"
#include "WQt4Gui.h"
#include "events/WModuleAssocEvent.h"
#include "events/WModuleReadyEvent.h"
WQt4Gui::WQt4Gui( int argc, char** argv )
: WGUI( argc, argv )
......
......@@ -11,7 +11,7 @@ ELSE()
ADD_LIBRARY( kernel SHARED ${KERNEL_SRC} ${MODULES_SRC} ${KERNEL_EXCEPTIONS_SRC} )
ENDIF()
TARGET_LINK_LIBRARIES( kernel common dataHandler ge math utils ${OPENSCENEGRAPH_LIBRARIES} )
TARGET_LINK_LIBRARIES( kernel common dataHandler ge math ${OPENSCENEGRAPH_LIBRARIES} )
# Unit tests
......
......@@ -38,15 +38,15 @@
#include <boost/filesystem.hpp>
#include <boost/thread/xtime.hpp>
#include "WModule.h"
#include "WModuleFactory.h"
#include "WBatchLoader.h"
#include "../common/WException.h"
#include "../common/WCondition.h"
#include "../common/WConditionOneShot.h"
#include "../common/WException.h"
#include "../common/WFlag.h"
#include "../common/WPreferences.h"
#include "../utils/WStringUtils.h"
#include "../common/WStringUtils.h"
#include "WBatchLoader.h"
#include "WModule.h"
#include "WModuleFactory.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......
......@@ -12,7 +12,7 @@ ENDIF()
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${MATH_SRC}"
"math;common;utils"
"math;common"
"WMath.cpp" # this declares only a namespace
)
ENDIF( OW_COMPILE_TESTS )
......@@ -29,7 +29,7 @@
#include <cmath>
#include <vector>
#include "../utils/WStringUtils.h"
#include "../common/WStringUtils.h"
namespace wmath
{
......
......@@ -3,7 +3,7 @@ FILE( GLOB FIBERSIMILARITY_SRC "*.cpp" "*.h" )
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${FIBERSIMILARITY_SRC}"
"math;utils"
"math;common"
"WFiberSimilarity.cpp" # This is just an interface
)
ENDIF( OW_COMPILE_TESTS )
......@@ -25,6 +25,7 @@
#include <string>
#include <vector>
#include "../../common/WIOTools.h"
#include "../../dataHandler/WDataSet.h"
#include "../../dataHandler/WDataSetSingle.h"
#include "../../dataHandler/WDataTexture3D.h"
......@@ -35,7 +36,6 @@
#include "../../dataHandler/io/WLoaderEEGASCII.h"
#include "../../dataHandler/io/WLoaderFibers.h"
#include "../../dataHandler/io/WLoaderNIfTI.h"
#include "../../utils/WIOTools.h"
#include "WMData.h"
WMData::WMData():
......
......@@ -34,8 +34,10 @@
#include <osg/Geometry>
#include "../../common/WColor.h"
#include "../../common/WIOTools.h"
#include "../../common/WLogger.h"
#include "../../common/WProgress.h"
#include "../../common/WStringUtils.h"
#include "../../common/datastructures/WDXtLookUpTable.h"
#include "../../common/datastructures/WFiberCluster.h"
#include "../../dataHandler/WDataSetFibers.h"
......@@ -46,9 +48,6 @@
#include "../../kernel/WKernel.h"
#include "../../math/WFiber.h"
#include "../../math/fiberSimilarity/WDLTMetric.h"
#include "../../utils/WColorUtils.h"
#include "../../utils/WIOTools.h"
#include "../../utils/WStringUtils.h"
#include "WMFiberClustering.h"
WMFiberClustering::WMFiberClustering()
......
......@@ -38,7 +38,6 @@
#include "../../kernel/WKernel.h"
#include "../../math/WFiber.h"
#include "../../math/fiberSimilarity/WDSTMetric.h"
#include "../../utils/WColorUtils.h"
#include "WMFiberCulling.h"
WMFiberCulling::WMFiberCulling()
......
......@@ -36,7 +36,6 @@
#include "../../graphicsEngine/WGraphicsEngine.h"
#include "../../kernel/WKernel.h"
#include "../../math/WFiber.h"
#include "../../utils/WColorUtils.h"
#include "WMFiberDisplay.h"
WMFiberDisplay::WMFiberDisplay()
......@@ -75,11 +74,11 @@ osg::ref_ptr< osg::Geode > WMFiberDisplay::genFiberGeode( boost::shared_ptr< con
WColor c;
if( !globalColoring )
{
c = color_utils::getRGBAColorFromDirection( fib[i], fib[i-1] );
c = display_utils::getRGBAColorFromDirection( fib[i], fib[i-1] );
}
else
{
c = color_utils::getRGBAColorFromDirection( fib[0], fib[ fib.size() -1 ] );
c = display_utils::getRGBAColorFromDirection( fib[0], fib[ fib.size() -1 ] );
}
colors->push_back( wge::osgColor( c ) );
}
......
......@@ -139,6 +139,20 @@ private:
osg::ref_ptr< WGEGroupNode > m_osgNode;
};
/**
* Some helper functions for displaying fibers
*/
namespace display_utils
{
/**
* Transforms a direction given via two points into a RGB color.
*
* \param pos1 First point
* \param pos2 Second point
*/
WColor getRGBAColorFromDirection( const wmath::WPosition &pos1, const wmath::WPosition &pos2 );
}
inline const std::string WMFiberDisplay::getName() const
{
return std::string( "Fiber Display Module" );
......@@ -149,4 +163,11 @@ inline const std::string WMFiberDisplay::getDescription() const
return std::string( "Draws fibers out of a WDataSetFibers" );
}
inline WColor display_utils::getRGBAColorFromDirection( const wmath::WPosition &pos1, const wmath::WPosition &pos2 )
{
wmath::WPosition direction( ( pos2 - pos1 ) );
direction.normalize();
return WColor( std::abs( direction[0] ), std::abs( direction[1] ), std::abs( direction[2] ) );
}
#endif // WMFIBERDISPLAY_H
......@@ -29,17 +29,14 @@
#include <cmath>
#include "WMGaussFiltering.h"
#include "../../utils/WStringUtils.h"
#include "../../math/WVector3D.h"
#include "../../math/WPosition.h"
#include "../../common/WStringUtils.h"
#include "../../dataHandler/WGridRegular3D.h"
#include "../../kernel/WKernel.h"
#include "../../graphicsEngine/WShader.h"
#include "../../kernel/WKernel.h"
#include "../../math/WPosition.h"
#include "../../math/WVector3D.h"
#include "../data/WMData.h"
#include "WMGaussFiltering.h"
WMGaussFiltering::WMGaussFiltering():
WModule()
......
......@@ -32,7 +32,7 @@
#include "../../../common/WLogger.h"
#include "../../../math/WPosition.h"
#include "../../../utils/WIOTools.h"
#include "../../../common/WIOTools.h"
#include "../WMMarchingCubes.h"
static WLogger logger;
......
......@@ -22,33 +22,29 @@
//
//---------------------------------------------------------------------------
#include <iostream>
#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include "WMPrototypeBoxManipulation.h"
#include <boost/lexical_cast.hpp>
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/StateSet>
#include <osg/StateAttribute>
#include <osg/PolygonMode>
#include <osg/LightModel>
#include <osg/LineWidth>
#include <osg/PolygonMode>
#include <osg/StateAttribute>
#include <osg/StateSet>
#include "../../utils/WStringUtils.h"
#include "../../math/WVector3D.h"
#include "../../math/WPosition.h"
#include "../../kernel/WKernel.h"
#include "../../common/WStringUtils.h"
#include "../../graphicsEngine/WROIBox.h"
#include "../../kernel/WKernel.h"
#include "../../math/WPosition.h"
#include "../../math/WVector3D.h"
#include "../data/WMData.h"
#include "WMPrototypeBoxManipulation.h"
WMPrototypeBoxManipulation::WMPrototypeBoxManipulation():
WModule()
......
......@@ -41,9 +41,9 @@
#include "../../graphicsEngine/WGraphicsEngine.h"
#include "../../kernel/WKernel.h"
#include "../../math/WFiber.h"
#include "../../utils/WColorUtils.h"
#include "WBresenhamDBL.h"
#include "../../modules/fiberDisplay/WMFiberDisplay.h"
#include "WBresenham.h"
#include "WBresenhamDBL.h"
#include "WMVoxelizer.h"
#include "WRasterAlgorithm.h"
......@@ -114,7 +114,7 @@ osg::ref_ptr< osg::Geode > WMVoxelizer::genFiberGeode() const
for( size_t i = 1; i < fib.size(); ++i )
{
vertices->push_back( osg::Vec3( fib[i][0], fib[i][1], fib[i][2] ) );
colors->push_back( wge::osgColor( color_utils::getRGBAColorFromDirection( fib[i], fib[i-1] ) ) );
colors->push_back( wge::osgColor( display_utils::getRGBAColorFromDirection( fib[i], fib[i-1] ) ) );
}
colors->push_back( colors->back() );
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_STRIP, vertices->size() - fib.size(), fib.size() ) );
......
......@@ -51,6 +51,9 @@ public:
m_algo = boost::shared_ptr< WBresenham >( new WBresenham( grid, false ) );
}
/**
* Clean up after each test
*/
void tearDown( void )
{
m_algo.reset();
......@@ -133,7 +136,7 @@ public:
TS_ASSERT_EQUALS( m_algo->m_values, expected );
}
private:
boost::shared_ptr< WBresenham > m_algo;
boost::shared_ptr< WBresenham > m_algo; //!< test instace of the WBresenham algo
};
#endif // WBRESENHAM_TEST_H
FILE(GLOB UTILS_SRC "*.cpp" "*.h" )
IF( CMAKE_HOST_SYSTEM MATCHES Windows )
ADD_LIBRARY( utils ${UTILS_SRC} )
ELSE()
ADD_LIBRARY( utils SHARED ${UTILS_SRC} )
ENDIF()
TARGET_LINK_LIBRARIES( utils ${Boost_PROGRAM_OPTIONS_LIBRARY} common math )
# Unit tests
IF( OW_COMPILE_TESTS )
CXXTEST_ADD_TESTS_FROM_LIST( "${UTILS_SRC}" "utils;guiqt4;dataHandler;${Boost_LIBRARIES}" )
ENDIF( OW_COMPILE_TESTS )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <cassert>
#include <cmath>
#include "WColorUtils.h"
#include "../common/WColor.h"
#include "../math/WPosition.h"
namespace color_utils
{
WColor getRGBAColorFromDirection( const wmath::WPosition &pos1, const wmath::WPosition &pos2 )
{
wmath::WPosition direction( ( pos2 - pos1 ) );
direction.normalize();
return WColor( std::abs( direction[0] ),
std::abs( direction[1] ),
std::abs( direction[2] ) );
}
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WCOLORUTILS_H
#define WCOLORUTILS_H
#include "../common/WColor.h"
#include "../math/WPosition.h"
/**
* Several helper functions for coloring stuff
*/
namespace color_utils
{
/**
* Transforms a direction given via two points into a RGB color.
*
* \param pos1 First point
* \param pos2 Second point
*/
WColor getRGBAColorFromDirection( const wmath::WPosition &pos1, const wmath::WPosition &pos2 );
}
#endif // WCOLORUTILS_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WCOLORUTILS_TEST_H
#define WCOLORUTILS_TEST_H
#include <cxxtest/TestSuite.h>
#include "../../common/WColor.h"
#include "../../common/test/WColorTraits.h"
#include "../WColorUtils.h"
/**
* Unit tests the functions in color_utils namespace
*/
class WColorUtilsTest : public CxxTest::TestSuite
{
public:
/**
* The color of two positions is mapped as follows to an RGB color:
* absolute value of normalized x-axis distance to red
* absolute value of normalized y-axis distance to green
* absolute value of normalized z-axis distance to blue
*/
void testColorFromDirection( void )
{
wmath::WPosition zero( 0, 0, 0 );
wmath::WPosition one( 1, 1, -1 );
WColor result = color_utils::getRGBAColorFromDirection( zero, one );
WColor expected( 1.0 / sqrt( 3 ), 1.0 / sqrt( 3 ), 1.0 / sqrt( 3 ) );
TS_ASSERT_EQUALS( result, expected );
result = color_utils::getRGBAColorFromDirection( one, zero