Commit 55fc5f30 authored by schurade's avatar schurade
Browse files

[MERGE] with 5c09f5847cc933559fca14f4a72846332d595fd1

parents 62b2e5f3 180b6711
......@@ -59,6 +59,19 @@ section stem from the following website:
\item[Composition] usually has a strong life cycle dependency between instances of the container class and instances of the
contained class(es): If the container is destroyed, normally every instance that it contains is destroyed as well.
\end{description}
\chapter{Code Organization}
\section{Directories}
\begin{description}
\item[\texttt{src}:] The source code of our whole project should reside here. Some things like parts of the build system, or unit test system, are not considered as source code.
\item[\texttt{src/common}:] Here you should find often needed pieces of source code, you want to share for reuse, and may use almost everywhere. E.g. WLimits.h for sharing several limits like \texttt{MAX\_DOUBLE}.
\item[\texttt{src/common/dataStructures}:] Various modules need additional data structures. You may place them here. This is
because of increasing reuse of that data structures. A developer doesn't have to look into every module's directory for
gaining the following information: "Has someone already coded a KD-Tree implementation I can make use of?". A developer should
look into this directory before he starts developing some new data structures. Even if there is just one module using e.g. a
KD-Tree at the moment, maybe someone needs that in the future too. So, place your possibly reusable data structures here!
\end{description}
\chapter{Math}
......@@ -70,7 +83,7 @@ section stem from the following website:
For a general overview on visualization in medicine \cite{Preim:2007:VMT} can be recommended.
\chapter{GUI}
The GUI module is the only part where we allow gui-toolkit related code. For example, this means that the use of any QT class is
The GUI module is the only part where we allow GUI-toolkit related code. For example, this means that the use of any QT class is
prohibited outside the GUI module.
\chapter{GE (Graphics Engine)}
The graphics engine is mainly realized by integrating OpenSceneGraph (OSG) so far.
......
......@@ -25,6 +25,8 @@
#ifndef WLIMITS_H
#define WLIMITS_H
#include <limits>
/**
* Project wide limits for different quantitities.
*/
......@@ -56,6 +58,11 @@ namespace wlimits
* Maximum samplimg frequency of a recording.
*/
const unsigned int MAX_RECORDING_SAMPLING_FREQUENCY = 20000;
/**
* Maximum double value
*/
const double MAX_DOUBLE = std::numeric_limits< double >::max();
}
#endif // WLIMITS_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/>.
//
//---------------------------------------------------------------------------
#include <cassert>
#include <cmath>
#include <string>
#include "WStatusReport.h"
WStatusReport::WStatusReport( unsigned int totalSteps )
: m_totalSteps( totalSteps ),
m_finishedSteps( 0 )
{
}
WStatusReport& WStatusReport::operator++() // prefix increment
{
assert( m_totalSteps > m_finishedSteps );
m_finishedSteps++;
return *this;
}
double WStatusReport::operator+=( unsigned int numSteps )
{
assert( m_totalSteps > m_finishedSteps );
if( m_totalSteps - m_finishedSteps < numSteps )
{
m_finishedSteps = m_totalSteps;
}
else
{
m_finishedSteps += numSteps;
}
return progress();
}
std::string WStatusReport::stringBar( char symbol, unsigned int finalNumOfSymbols ) const
{
unsigned int numSymbols = progress() * finalNumOfSymbols;
return std::string( numSymbols, symbol );
}
//---------------------------------------------------------------------------
//
// 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 WSTATUSREPORT_H
#define WSTATUSREPORT_H
#include <string>
/**
* A counter for reporting the progress of some work.
*/
class WStatusReport
{
friend class WStatusReportTest;
public:
/**
* Constructs a new status reporter with the number of total steps
* which it should reach to reach the 100 percent.
*/
explicit WStatusReport( unsigned int totalSteps );
/**
* Returns the total number of steps which are considered as 100 percent
* work.
*/
unsigned int getTotalSteps() const
{
return m_totalSteps;
}
/**
* Returns the number of steps done so far
*/
unsigned int getFinishedSteps() const
{
return m_finishedSteps;
}
/**
* Returns the progress in percentage done so far: e.g. 0.7 == 70%
*/
double progress() const
{
return static_cast< double >( m_finishedSteps ) / m_totalSteps;
}
/**
* Increments the finished work by one step.
*/
WStatusReport& operator++(); // prefix increment
/**
* Increments the finished work by the number of the given steps.
*
* \return The progress()
*/
double operator+=( unsigned int numSteps );
/**
* Generates a string which represents the progress in terms of
* characters. When reaching 100 percent finally finalNumOfSymbols are
* returned.
*/
std::string stringBar( char symbol = '#', unsigned int finalNumOfSymbols = 50 ) const;
protected:
private:
unsigned int m_totalSteps;
unsigned int m_finishedSteps;
};
#endif // WSTATUSREPORT_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 WSTATUSREPORT_TEST_H
#define WSTATUSREPORT_TEST_H
#include <string>
#include <cxxtest/TestSuite.h>
#include "../WStatusReport.h"
/**
* Unit tests our StatusReporter class
*/
class WStatusReportTest : public CxxTest::TestSuite
{
public:
/**
* Given a certain percentage of progress and a char, and a number
* of total chars to display, the StringBar of a WStatusReporter
* object should be determined.
*/
void testStringBar( void )
{
WStatusReport st( 312 );
st += 189;
std::string expected( 30, '#' );
TS_ASSERT_EQUALS( st.stringBar(), expected );
}
/**
* When incrementing over total and the progress is below 100%, it should
* be accumulated to 100%. But if the progress is already at 100%
* an assert should fail!
*/
void testIncrementOverTotal( void )
{
WStatusReport st( 312 );
st += 311;
st += 9000;
TS_ASSERT_EQUALS( st.progress(), 1.0 );
}
};
#endif // WSTATUSREPORT_TEST_H
......@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <algorithm>
#include <vector>
#include "WDataSetFibers.h"
......@@ -30,3 +31,18 @@ void WDataSetFibers::sortDescLength()
{
std::sort( m_fibers->begin(), m_fibers->end(), wmath::hasGreaterLengthThen );
}
void WDataSetFibers::erase( const std::vector< bool > &unused )
{
assert( unused.size() == m_fibers->size() );
std::vector< wmath::WFiber >::iterator useable = m_fibers->begin();
for( size_t i = 0 ; i < unused.size(); ++i )
{
if( !unused[i] )
{
*useable = ( *m_fibers )[i];
useable++;
}
}
m_fibers->erase( useable, m_fibers->end() );
}
......@@ -67,6 +67,12 @@ public:
*/
void sortDescLength();
/**
* Deletes all those fibers which are marked true in the given
* unused vector.
*/
void erase( const std::vector< bool > &unused );
protected:
private:
......
......@@ -37,7 +37,9 @@
#include "../modules/data/WDataModule.hpp"
#include "../modules/navigationSlices/WNavigationSliceModule.h"
#include "../modules/coordinateSystem/WCoordinateSystem.h"
#include "../modules/FiberDisplay/WFiberDisplay.h"
#include "../modules/fiberDisplay/WFiberDisplay.h"
#include "../modules/fiberCulling/WFiberCulling.h"
#include "../modules/fiberClustering/WFiberClustering.h"
#include "../common/WException.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......
......@@ -23,10 +23,11 @@
//---------------------------------------------------------------------------
#include <algorithm>
#include <vector>
#include <utility>
#include <vector>
#include "WFiber.h"
#include "../common/WLimits.h"
namespace wmath
{
......@@ -65,8 +66,7 @@ namespace wmath
qr = qr / qsize;
for( size_t j = 0; j < rsize; ++j )
{
// TODO(math): MAX_FANTOM_DOUBLE correct this
minSoFar = 9999999999999999999.9; // _FANTOM_DOUBLE;
minSoFar = wlimits::MAX_DOUBLE;
for( size_t i = 0; i < qsize; ++i )
{
if( m[i][j] < minSoFar )
......@@ -82,5 +82,16 @@ namespace wmath
rq = rq / rsize;
return std::make_pair( qr, rq );
}
}
double WFiber::dSt( const WFiber& other, const double thresholdSquare ) const
{
std::pair< double, double > result = dXt_optimized( other, thresholdSquare );
return std::min( result.first, result.second );
}
double WFiber::dLt( const WFiber& other, const double thresholdSquare ) const
{
std::pair< double, double > result = dXt_optimized( other, thresholdSquare );
return std::max( result.first, result.second );
}
}
......@@ -47,8 +47,17 @@ public:
explicit WFiber( const std::vector< WPosition > &points );
/**
* TODO(math): document this method in more detail
* Optimized version which computes dt measure from qr and rq at once.
* Optimized version which computes dt measure from fibers Q and R.
* Since this is not symmetric it computes both: dt(Q,R) and dt(R,Q) at
* once. dt(Q,R) computes the mean euclidian distance of the closest
* points. See Paper from Zhang: doi.ieeecomputersociety.org/10.1109/TVCG.2008.52
*
* \param other The other fiber R
* \param thresholdSquare The threshold, where distances below will be
* ignored for dt() computation. Note that this parameter is given
* as square, since the distanceSquare is much faster to compute then
* just the distance.
* \return Both dt(Q,R) and dt(R,Q).
*/
std::pair< double, double > dXt_optimized( const WFiber &other,
const double thresholdSquare ) const;
......
......@@ -100,8 +100,7 @@ public:
friend std::ostream& operator<<( std::ostream& os, const WLine &rhs )
{
using string_utils::operator<<;
os << rhs.m_points;
return os;
return os << rhs.m_points;
}
protected:
......
......@@ -82,6 +82,31 @@ public:
WFiber fib2( lineData2 );
TS_ASSERT_EQUALS( fib1, fib2 );
}
/**
* The dt(Q,R) measure (mean closest point distance) is not symmetric.
* distances below a certain threshold will be omitted.
*/
void testDTMeasure( void )
{
double threshold = 1.0;
using wmath::WPosition;
std::vector< WPosition > lineData1;
lineData1.push_back( WPosition( 0, 1, 0 ) );
lineData1.push_back( WPosition( 0, 0, 0 ) );
std::vector< WPosition > lineData2;
lineData2.push_back( WPosition( 1, 1, 0 ) );
lineData2.push_back( WPosition( 2, 2, 0 ) );
using wmath::WFiber;
WFiber fib1( lineData1 );
WFiber fib2( lineData2 );
double dt = fib1.dXt_optimized( fib2, threshold ).first;
double expected = std::sqrt( 2.0 ) / 2.0;
TS_ASSERT_EQUALS( dt, expected );
dt = fib1.dXt_optimized( fib2, threshold ).second;
expected = std::sqrt( 5.0 ) / 2.0;
TS_ASSERT_EQUALS( dt, expected );
}
};
#endif // WFIBER_TEST_H
ADD_SUBDIRECTORY( FiberDisplay )
ADD_SUBDIRECTORY( FiberCulling )
ADD_SUBDIRECTORY( fiberDisplay )
ADD_SUBDIRECTORY( fiberCulling )
ADD_SUBDIRECTORY( fiberClustering )
ADD_SUBDIRECTORY( marchingCubes )
//---------------------------------------------------------------------------
//
// 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 <algorithm>
#include "WDXtLookUpTable.h"
WDXtLookUpTable::WDXtLookUpTable( size_t dim )
: _data( ( dim * ( dim-1 ) ) / 2, 0.0 ),
_dim( dim )
{
}
double& WDXtLookUpTable::operator()( size_t i, size_t j )
{
assert( i != j );
if( i > j )
{
std::swap( i, j );
}
return _data.at( i * _dim + j - ( i + 1 ) * ( i + 2 ) / 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 WDXTLOOKUPTABLE_H
#define WDXTLOOKUPTABLE_H
#include <vector>
/**
* Represents a symmetric matrix-like look up table, meaning it stores only
* the elements inside the triangular matrix without the main diagonal.
*
* So in case of a NxN matrix there are only (N^2-N)/2 elements to store.
*
* The reason why this is named DXt look up table is, since is it used as
* look up table for dSt and dLt fiber distance metrics.
*/
class WDXtLookUpTable
{
public:
/**
* Generates new look up table.
*
* \param n the dimmension of the square matrix
*/
explicit WDXtLookUpTable( size_t dim );
/**
* Element acces operator as if the elements where stored as a matrix.
* Note! Acessing elements of the main diagonal is forbidden!
*/
double& operator()( size_t i, size_t j );
private:
/**
* Internal data structure to store the elements.
*/
std::vector< double > _data;
size_t _dim; //!< Matrix dimension
};
#endif // WDXTLOOKUPTABLE_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/>.
//
//---------------------------------------------------------------------------
#include <list>
#include <vector>
#include <boost/shared_ptr.hpp>
#include "WFiberCluster.h"
#include "../../common/WLimits.h"
#include "../../dataHandler/WDataSetFibers.h"
WFiberCluster::WFiberCluster( const boost::shared_ptr< WDataSetFibers > fibs )
{
m_fibs = fibs;
}
WFiberCluster::WFiberCluster( size_t index, const boost::shared_ptr< WDataSetFibers > fibs )
{
m_memberIndices.push_back( index );
m_fibs = fibs;
}
bool WFiberCluster::empty() const
{
return m_memberIndices.empty();
}
void WFiberCluster::merge( WFiberCluster& other ) // NOLINT
{
std::list< size_t >::const_iterator cit = other.m_memberIndices.begin();
for( ; cit != other.m_memberIndices.end(); ++cit)
{
m_memberIndices.push_back( *cit );
}
// make sure that those indices aren't occuring anywhere else
other.clear();
}
double WFiberCluster::minDistance( const WFiberCluster& other, const double proximity_t ) const
{
double result = wlimits::MAX_DOUBLE;
double dist;
std::list< size_t >::const_iterator thisIdx = m_memberIndices.begin();