Commit 6b63a8cf authored by schurade's avatar schurade
Browse files

[STYLE]

parent 6de126df
......@@ -57,7 +57,6 @@ WDataSetFibers2::WDataSetFibers2( boost::shared_ptr< std::vector< float > >verti
++i;
//m_pointArray[i] = m_dh->frames - m_pointArray[i];
}
}
void WDataSetFibers2::sortDescLength()
......
......@@ -156,7 +156,6 @@ private:
* Reverse lookup table for which point belongs to which fiber
*/
boost::shared_ptr< std::vector< unsigned int > > m_verticesReverse;
};
#endif // WDATASETFIBERS2_H
......@@ -74,7 +74,8 @@ boost::shared_ptr< WDataSet > WLoaderFibers2::load()
// could be thousands of them
wlog::error( "DataHandler" ) << "Abort loading Fib-VTK file due to: " << e.what();
}
shared_ptr< WDataSetFibers2 > fibers = shared_ptr< WDataSetFibers2 >( new WDataSetFibers2( m_vertices, m_lineStartIndexes, m_lineLengths, m_verticesReverse ) );
shared_ptr< WDataSetFibers2 > fibers = shared_ptr< WDataSetFibers2 >(
new WDataSetFibers2( m_vertices, m_lineStartIndexes, m_lineLengths, m_verticesReverse ) );
fibers->setFileName( m_fileName );
assert( !m_ifs->is_open() );
......@@ -152,7 +153,7 @@ void WLoaderFibers2::readPoints()
}
m_vertices = boost::shared_ptr< std::vector< float > >( new std::vector< float > );
m_vertices->resize( numPoints * 3 );
m_verticesReverse = boost::shared_ptr< std::vector< unsigned int > >( new std::vector< unsigned int > ) ;
m_verticesReverse = boost::shared_ptr< std::vector< unsigned int > >( new std::vector< unsigned int > );
m_verticesReverse->reserve( numPoints );
float *pointData = new float[ 3 * numPoints ];
......@@ -208,8 +209,8 @@ void WLoaderFibers2::readLines()
wiotools::switchByteOrderOfArray( lineData, linesSize );
m_lineStartIndexes = boost::shared_ptr< std::vector< unsigned int > >( new std::vector< unsigned int > ) ;
m_lineLengths = boost::shared_ptr< std::vector< unsigned int > >( new std::vector< unsigned int > ) ;
m_lineStartIndexes = boost::shared_ptr< std::vector< unsigned int > >( new std::vector< unsigned int > );
m_lineLengths = boost::shared_ptr< std::vector< unsigned int > >( new std::vector< unsigned int > );
m_lineStartIndexes->reserve( numLines );
m_lineLengths->reserve( numLines );
......
......@@ -80,7 +80,6 @@ private:
* \param text text info from pick
*/
virtual void updateGFX( std::string text ) = 0;
};
#endif // WROI_H
......@@ -90,7 +90,6 @@ void buildLinesFromPoints( osg::DrawElementsUInt* surfaceElements )
surfaceElements->push_back( 7 );
surfaceElements->push_back( 3 );
surfaceElements->push_back( 4 );
surfaceElements->push_back( 0 );
surfaceElements->push_back( 1 );
......@@ -110,8 +109,7 @@ void setVertices( osg::Vec3Array* vertices, wmath::WPosition minPos, wmath::WPos
}
WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
WROI(),
boxId( maxBoxId++ )
WROI(), boxId( maxBoxId++ )
{
m_minPos = minPos;
m_maxPos = maxPos;
......@@ -128,7 +126,7 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
m_geode = new osg::Geode;
std::stringstream ss;
ss << "ROIBox" << boxId;
ss << "ROIBox" << boxId;
m_geode->setName( ss.str() );
......@@ -162,17 +160,16 @@ WROIBox::WROIBox( wmath::WPosition minPos, wmath::WPosition maxPos ) :
surfaceGeometry->setColorArray( colors );
surfaceGeometry->setColorBinding( osg::Geometry::BIND_OVERALL );
osg::ref_ptr<osg::LightModel> lightModel = new osg::LightModel();
osg::ref_ptr< osg::LightModel > lightModel = new osg::LightModel();
lightModel->setTwoSided( true );
state->setAttributeAndModes( lightModel.get(), osg::StateAttribute::ON );
state->setMode( GL_BLEND, osg::StateAttribute::ON );
state->setMode( GL_BLEND, osg::StateAttribute::ON );
m_isModified = true;
m_isNot = false;
assert( WGraphicsEngine::getGraphicsEngine() );
WGraphicsEngine::getGraphicsEngine()->getScene()->addChild( m_geode );
}
wmath::WPosition WROIBox::getMinPos() const
......@@ -192,32 +189,30 @@ bool WROIBox::isModified()
return tmp;
}
void WROIBox::updateGFX( std::string text )
{
boost::shared_lock<boost::shared_mutex> slock;
slock = boost::shared_lock<boost::shared_mutex>( m_updateLock );
boost::shared_lock< boost::shared_mutex > slock;
slock = boost::shared_lock< boost::shared_mutex >( m_updateLock );
std::stringstream ss;
ss << "\"ROIBox" << boxId << "\"";
if( text.find( "Object ") != std::string::npos
&& text.find( ss.str() ) != std::string::npos )
ss << "\"ROIBox" << boxId << "\"";
if ( text.find( "Object " ) != std::string::npos && text.find( ss.str() ) != std::string::npos )
{
wmath::WPosition newPos( m_pickHandler->getHitPosition() );
if( m_isPicked )
if ( m_isPicked )
{
wmath::WVector3D moveVec = m_pickedPosition - newPos;
osg::Vec3Array* vertices = new osg::Vec3Array;
m_minPos -= moveVec;
m_maxPos -= moveVec;
setVertices( vertices, m_minPos, m_maxPos );
((osg::Geometry*)(m_geode->getDrawable( 0 )))->setVertexArray( vertices );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setVertexArray( vertices );
}
else
{
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back( osg::Vec4( 1.f, .0f, .0f, 0.5f ) );
((osg::Geometry*)(m_geode->getDrawable( 0 )))->setColorArray( colors );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setColorArray( colors );
}
m_pickedPosition = newPos;
m_isModified = true;
......@@ -225,13 +220,12 @@ void WROIBox::updateGFX( std::string text )
m_signalIsModified();
}
if( m_isPicked && text.find( "unpick" ) != std::string::npos )
if ( m_isPicked && text.find( "unpick" ) != std::string::npos )
{
osg::Vec4Array* colors = new osg::Vec4Array;
colors->push_back( osg::Vec4( 0.f, 0.f, 1.f, 0.5f ) );
((osg::Geometry*)(m_geode->getDrawable( 0 )))->setColorArray( colors );
( ( osg::Geometry* ) ( m_geode->getDrawable( 0 ) ) )->setColorArray( colors );
m_isPicked = false;
}
slock.unlock();
}
......@@ -387,12 +387,14 @@ void WMainWindow::newRoi()
{
if ( m_datasetBrowser->getSelectedRoi().get() == NULL )
{
boost::shared_ptr< WROIBox > newRoi = boost::shared_ptr< WROIBox >( new WROIBox( wmath::WPosition( 60., 60., 60.), wmath::WPosition( 80., 80., 80. ) ) );
boost::shared_ptr< WROIBox > newRoi = boost::shared_ptr< WROIBox >( new WROIBox( wmath::WPosition( 60., 60., 60. ),
wmath::WPosition( 80., 80., 80. ) ) );
WKernel::getRunningKernel()->getRoiManager()->addRoi( newRoi );
}
else
{
boost::shared_ptr< WROIBox > newRoi = boost::shared_ptr< WROIBox >( new WROIBox( wmath::WPosition( 60., 60., 60.), wmath::WPosition( 80., 80., 80. ) ) );
boost::shared_ptr< WROIBox > newRoi = boost::shared_ptr< WROIBox >( new WROIBox( wmath::WPosition( 60., 60., 60. ),
wmath::WPosition( 80., 80., 80. ) ) );
WKernel::getRunningKernel()->getRoiManager()->addRoi( newRoi, m_datasetBrowser->getSelectedRoi()->getROI() );
}
}
......@@ -140,7 +140,7 @@ int WQt4Gui::run()
m_kernel->getRootContainer()->addDefaultNotifier( WM_ASSOCIATED, assocSignal );
t_ModuleGenericSignalHandlerType readySignal = boost::bind( &WQt4Gui::slotActivateDatasetOrModuleInBrowser, this, _1 );
m_kernel->getRootContainer()->addDefaultNotifier( WM_READY, readySignal );
boost::function< void ( boost::shared_ptr< WRMROIRepresentation > ) > assocRoiSignal = boost::bind( &WQt4Gui::slotAddRoiToBrowser, this, _1 );
boost::function< void( boost::shared_ptr< WRMROIRepresentation > ) > assocRoiSignal = boost::bind( &WQt4Gui::slotAddRoiToBrowser, this, _1 );
m_kernel->getRoiManager()->addDefaultNotifier( assocRoiSignal );
// now we are initialized
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "WQtRoiTreeItem.h"
#include "WQtRoiHeaderTreeItem.h"
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <string>
#include "WQtRoiTreeItem.h"
WQtRoiTreeItem::WQtRoiTreeItem( QTreeWidgetItem * parent, boost::shared_ptr< WRMROIRepresentation > roi, int type ) :
......
......@@ -23,19 +23,19 @@
//---------------------------------------------------------------------------
#include <algorithm>
#include <vector>
#include "../../common/WLogger.h"
#include "WKdTree.h"
WKdTree::WKdTree( int size, float *pointArray, bool ) :
m_size( size ),
m_pointArray( pointArray )
m_size( size ), m_pointArray( pointArray )
{
m_tree.clear();
m_tree.resize( size );
wlog::debug( "KdTree" ) << " Start building KdTree" ;
wlog::debug( "KdTree" ) << " Start building KdTree";
for ( int i = 0; i < size; ++i )
m_tree[i] = i;
......@@ -54,34 +54,33 @@ WKdTree::WKdTree( int size, float *pointArray, bool ) :
WKdTreeThread *thread3 = new WKdTreeThread( m_pointArray, &m_tree, root + 1, rootRight - 1, 2 );
WKdTreeThread *thread4 = new WKdTreeThread( m_pointArray, &m_tree, rootRight + 1, size - 1, 2 );
wlog::debug( "KdTree" ) << "Start threads" ;
wlog::debug( "KdTree" ) << "Start threads";
thread1->run();
thread2->run();
thread3->run();
thread4->run();
wlog::debug( "KdTree" ) << "All threads started" ;
wlog::debug( "KdTree" ) << "All threads started";
thread1->wait();
thread2->wait();
thread3->wait();
thread4->wait();
wlog::debug( "KdTree" ) << "All threads finished" ;
wlog::debug( "KdTree" ) << "All threads finished";
}
WKdTree::WKdTree( int size, float *pointArray ) :
m_size( size ),
m_pointArray( pointArray )
m_size( size ), m_pointArray( pointArray )
{
wlog::debug( "KdTree" ) << " Start building KdTree" ;
wlog::debug( "KdTree" ) << " Start building KdTree";
m_tree.clear();
m_tree.resize( size );
for ( int i = 0; i < size; ++i )
m_tree[i] = i;
buildTree( 0, size - 1, 0 );
wlog::debug( "KdTree" ) << " Finished building KdTree" ;
wlog::debug( "KdTree" ) << " Finished building KdTree";
}
WKdTree::~WKdTree()
......@@ -101,19 +100,14 @@ void WKdTree::buildTree( int left, int right, int axis )
}
WKdTreeThread::WKdTreeThread( float *pointArray, std::vector< unsigned int >* tree, int left, int right, int axis ) :
WThreadedRunner(),
m_tree( tree ),
m_pointArray( pointArray ),
m_left( left ),
m_right( right ),
m_axis( axis )
WThreadedRunner(), m_tree( tree ), m_pointArray( pointArray ), m_left( left ), m_right( right ), m_axis( axis )
{
}
void WKdTreeThread::threadMain()
{
buildTree( m_left, m_right, m_axis );
wlog::debug( "KdTree" ) << "thread finished" ;
wlog::debug( "KdTree" ) << "thread finished";
}
void WKdTreeThread::buildTree( int left, int right, int axis )
......
......@@ -26,6 +26,7 @@
#define WKDTREE_H
#include <algorithm>
#include <vector>
#include "../../common/WThreadedRunner.h"
......@@ -38,13 +39,13 @@ struct lessy
{
}
bool operator()( const unsigned int& a, const unsigned int& b ) const
bool operator()( const unsigned int& a, const unsigned int& b ) const //NOLINT
{
return data[3* a + pos] < data[3* b + pos];
}
};
class WKdTreeThread : public WThreadedRunner
class WKdTreeThread: public WThreadedRunner
{
public:
WKdTreeThread( float*, std::vector< unsigned int >*, int, int, int );
......@@ -60,24 +61,23 @@ public:
int m_axis;
};
/**
* TODO(schurade): Document this!
*/
class WKdTree
{
public:
WKdTree(int size, float* pointArray, bool );
WKdTree(int size, float* pointArray );
~WKdTree();
WKdTree( int size, float* pointArray, bool );
WKdTree( int size, float* pointArray );
~WKdTree();
std::vector<unsigned int>m_tree;
std::vector< unsigned int > m_tree;
private:
void buildTree(int, int, int);
int m_size;
unsigned int m_root;
float *m_pointArray;
void buildTree( int, int, int );
int m_size;
unsigned int m_root;
float *m_pointArray;
};
#endif // WKDTREE_H
......@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
......
......@@ -68,7 +68,7 @@ void WRMBranch::addBitField( size_t size )
m_bitFields.push_back( bf );
for( std::list< boost::shared_ptr< WRMROIRepresentation> >::iterator iter = m_rois.begin(); iter != m_rois.end(); ++iter )
{
(*iter)->addBitField( size );
( *iter )->addBitField( size );
}
setDirty();
}
......
......@@ -26,6 +26,7 @@
#define WRMBRANCH_H
#include <list>
#include <string>
#include <vector>
#include <boost/enable_shared_from_this.hpp>
......@@ -43,7 +44,7 @@ public:
/**
* TODO(schurade): Document this!
*/
WRMBranch( boost::shared_ptr< WROIManagerFibers > roiManager );
explicit WRMBranch( boost::shared_ptr< WROIManagerFibers > roiManager );
/**
* TODO(schurade): Document this!
......
......@@ -23,6 +23,7 @@
//---------------------------------------------------------------------------
#include <list>
#include <string>
#include <vector>
#include "WRMBranch.h"
......
......@@ -26,6 +26,7 @@
#define WRMROIREPRESENTATION_H
#include <list>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
......
......@@ -27,7 +27,6 @@
#include "WROIManagerFibers.h"
WROIManagerFibers::WROIManagerFibers()
{
}
......@@ -36,79 +35,79 @@ WROIManagerFibers::~WROIManagerFibers()
{
}
void WROIManagerFibers::addRoi( boost::shared_ptr<WROI> newRoi )
void WROIManagerFibers::addRoi( boost::shared_ptr< WROI > newRoi )
{
// create new branch
boost::shared_ptr< WRMBranch > newBranch = boost::shared_ptr< WRMBranch >( new WRMBranch( shared_from_this() ) );
// create roi
boost::shared_ptr< WRMROIRepresentation >rroi = boost::shared_ptr< WRMROIRepresentation >( new WRMROIRepresentation( newRoi, newBranch ) );
boost::shared_ptr< WRMROIRepresentation > rroi = boost::shared_ptr< WRMROIRepresentation >( new WRMROIRepresentation( newRoi, newBranch ) );
// add roi to branch
newBranch->addRoi( rroi );
// add branch to list
m_branches.push_back( newBranch );
// add bit fields
for( std::list< boost::shared_ptr< const WDataSetFibers2> >::iterator iter = m_fiberList.begin(); iter != m_fiberList.end(); ++iter )
for ( std::list< boost::shared_ptr< const WDataSetFibers2 > >::iterator iter = m_fiberList.begin(); iter != m_fiberList.end(); ++iter )
{
newBranch->addBitField( ( *iter ).get()->size() );
}
for( std::list< boost::function< void ( boost::shared_ptr< WRMROIRepresentation > ) > >::iterator iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter )
for ( std::list< boost::function< void( boost::shared_ptr< WRMROIRepresentation > ) > >::iterator iter = m_notifiers.begin(); iter
!= m_notifiers.end(); ++iter )
{
( *iter )( rroi );
}
}
void WROIManagerFibers::addRoi( boost::shared_ptr<WROI> newRoi, boost::shared_ptr<WROI> parentRoi )
void WROIManagerFibers::addRoi( boost::shared_ptr< WROI > newRoi, boost::shared_ptr< WROI > parentRoi )
{
// find branch
boost::shared_ptr< WRMBranch> branch;
boost::shared_ptr< WRMBranch > branch;
std::cout << "add roi" << std::endl;
for( std::list< boost::shared_ptr< WRMBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
for ( std::list< boost::shared_ptr< WRMBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
if ( ( *iter).get()->getFirstRoi()->getROI() == parentRoi )
if ( ( *iter ).get()->getFirstRoi()->getROI() == parentRoi )
{
branch = ( *iter );
std::cout << "branch found" << std::endl;
}
}
// create roi
boost::shared_ptr< WRMROIRepresentation >rroi = boost::shared_ptr< WRMROIRepresentation >( new WRMROIRepresentation( newRoi, branch ) );
boost::shared_ptr< WRMROIRepresentation > rroi = boost::shared_ptr< WRMROIRepresentation >( new WRMROIRepresentation( newRoi, branch ) );
// add bit fields
for( std::list< boost::shared_ptr< const WDataSetFibers2> >::iterator iter = m_fiberList.begin(); iter != m_fiberList.end(); ++iter )
for ( std::list< boost::shared_ptr< const WDataSetFibers2 > >::iterator iter = m_fiberList.begin(); iter != m_fiberList.end(); ++iter )
{
rroi->addBitField( ( *iter ).get()->size() );
}
// add roi to branch
branch->addRoi( rroi );
for( std::list< boost::function< void ( boost::shared_ptr< WRMROIRepresentation > ) > >::iterator iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter )
for ( std::list< boost::function< void( boost::shared_ptr< WRMROIRepresentation > ) > >::iterator iter = m_notifiers.begin(); iter
!= m_notifiers.end(); ++iter )
{
( *iter )( rroi );
}
}
void WROIManagerFibers::removeRoi( boost::shared_ptr<WROI> /*roi */)
void WROIManagerFibers::removeRoi( boost::shared_ptr< WROI > /*roi */ )
{
}
void WROIManagerFibers::addFiberDataset( boost::shared_ptr<const WDataSetFibers2> fibers )
void WROIManagerFibers::addFiberDataset( boost::shared_ptr< const WDataSetFibers2 > fibers )
{
m_fiberList.push_back( fibers );
boost::shared_ptr< std::vector< float > > verts = fibers->getVertices();
m_kdTreeList.push_back( boost::shared_ptr< WKdTree>( new WKdTree( fibers->getVertices()->size() / 3, &((*verts)[0]) , true ) ) );
m_kdTreeList.push_back( boost::shared_ptr< WKdTree >( new WKdTree( fibers->getVertices()->size() / 3, &( ( *verts )[0] ), true ) ) );
//m_kdTreeList.push_back( boost::shared_ptr< WKdTree>( new WKdTree( fibers->getVertices()->size() / 3, &((*verts)[0]) ) ) );
addBitField( fibers->size() );
}
void WROIManagerFibers::removeFiberDataset( boost::shared_ptr<const WDataSetFibers2> /*fibers*/ )
void WROIManagerFibers::removeFiberDataset( boost::shared_ptr< const WDataSetFibers2 > /*fibers*/ )
{
}
boost::shared_ptr<std::vector<bool> > WROIManagerFibers::getBitField( boost::shared_ptr<const WDataSetFibers2> fibers )
boost::shared_ptr< std::vector< bool > > WROIManagerFibers::getBitField( boost::shared_ptr< const WDataSetFibers2 > fibers )
{
if ( m_dirty )
{
......@@ -116,7 +115,7 @@ boost::shared_ptr<std::vector<bool> > WROIManagerFibers::getBitField( boost::sha
}
unsigned int c = 0;
for( std::list< boost::shared_ptr< const WDataSetFibers2 > >::iterator iter = m_fiberList.begin(); iter != m_fiberList.end(); ++iter )
for ( std::list< boost::shared_ptr< const WDataSetFibers2 > >::iterator iter = m_fiberList.begin(); iter != m_fiberList.end(); ++iter )
{
if ( *iter == fibers )
{
......@@ -126,11 +125,11 @@ boost::shared_ptr<std::vector<bool> > WROIManagerFibers::getBitField( boost::sha
}
unsigned int index = 0;
for( std::list< boost::shared_ptr<std::vector<bool> > >::iterator iter = m_bitFields.begin(); iter != m_bitFields.end(); ++iter )
for ( std::list< boost::shared_ptr< std::vector< bool > > >::iterator iter = m_bitFields.begin(); iter != m_bitFields.end(); ++iter )
{
if ( c == index)
if ( c == index )
{
return (*iter);
return ( *iter );
}
++index;
}
......@@ -138,40 +137,40 @@ boost::shared_ptr<std::vector<bool> > WROIManagerFibers::getBitField( boost::sha
void WROIManagerFibers::addBitField( size_t size )
{
boost::shared_ptr<std::vector< bool > >bf = boost::shared_ptr<std::vector< bool > >( new std::vector< bool >( size, false ) );
boost::shared_ptr< std::vector< bool > > bf = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( size, false ) );
m_bitFields.push_back( bf );
for( std::list< boost::shared_ptr<WRMBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
for ( std::list< boost::shared_ptr< WRMBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
(*iter).get()->addBitField( size );
( *iter ).get()->addBitField( size );
}
setDirty();
}
void WROIManagerFibers::recalculate()
{
// std::cout << "roi manager recalc" << std::endl;
boost::shared_ptr< std::vector<bool> > mbf = m_bitFields.front();
// std::cout << "roi manager recalc" << std::endl;
boost::shared_ptr< std::vector< bool > > mbf = m_bitFields.front();
int size = mbf->size();
mbf->clear();
mbf->resize( size, false );
for( std::list< boost::shared_ptr< WRMBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
for ( std::list< boost::shared_ptr< WRMBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
boost::shared_ptr< std::vector<bool> > bf = ( *iter )->getBitField( 0 );
boost::shared_ptr< std::vector< bool > > bf = ( *iter )->getBitField( 0 );
for ( int i = 0 ; i < mbf->size() ; ++i )
for ( int i = 0; i < mbf->size(); ++i )
{
mbf->at( i ) = mbf->at( i ) | bf->at( i );
}
}
// int counter = 0;
// for (int i = 0 ; i < mbf->size() ; ++i)
// {
// if ( mbf->at(i) )
// ++counter;
// }
// std::cout << "active fibers total :" << counter << std::endl;
// int counter = 0;
// for (int i = 0 ; i < mbf->size() ; ++i)
// {
// if ( mbf->at(i) )
// ++counter;
// }
// std::cout << "active fibers total :" << counter << std::endl;
m_dirty = false;
}
......@@ -181,10 +180,10 @@ void WROIManagerFibers::setDirty()
m_dirty = true;