Commit 867df56e authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[ADD #157] Now the culling really erases the fibers

parent 4666e6ed
......@@ -34,11 +34,11 @@ WStatusReport::WStatusReport( unsigned int totalSteps )
{
}
double WStatusReport::operator++()
WStatusReport& WStatusReport::operator++() // prefix increment
{
assert( m_totalSteps > m_finishedSteps );
m_finishedSteps++;
return progress();
return *this;
}
double WStatusReport::operator+=( unsigned int numSteps )
......
......@@ -67,10 +67,8 @@ public:
/**
* Increments the finished work by one step.
*
* \return The progress()
*/
double operator++();
WStatusReport& operator++(); // prefix increment
/**
* Increments the finished work by the number of the given steps.
......
......@@ -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,6 +37,7 @@
#include "../modules/data/WDataModule.hpp"
#include "../modules/navigationSlices/WNavigationSliceModule.h"
#include "../modules/fiberDisplay/WFiberDisplay.h"
#include "../modules/fiberCulling/WFiberCulling.h"
#include "../common/WException.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......@@ -187,6 +188,7 @@ void WKernel::loadModules()
using boost::shared_ptr;
shared_ptr< WModule > m = shared_ptr< WModule >( new WNavigationSliceModule() );
// shared_ptr< WModule > m = shared_ptr< WModule >( new WFiberDisplay() );
// shared_ptr< WModule > m = shared_ptr< WModule >( new WFiberCulling() );
WLogger::getLogger()->addLogMessage( "Loading module: " + m->getName(), "Kernel", LL_DEBUG );
m_modules.push_back( m );
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
......@@ -30,8 +32,9 @@
#include "WFiberCulling.h"
#include "../../math/WFiber.h"
#include "../../common/WLogger.h"
#include "../../common/WColor.h"
#include "../../common/WLogger.h"
#include "../../common/WStatusReport.h"
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WSubject.h"
#include "../../dataHandler/WDataSetFibers.h"
......@@ -40,7 +43,10 @@
#include "../../utils/WColorUtils.h"
WFiberCulling::WFiberCulling()
: WModule()
: WModule(),
m_proximity_t( 0.0 ),
m_dSt_culling_t( 0.0 ),
m_saveCulledCurves( false )
{
}
......@@ -91,6 +97,8 @@ void WFiberCulling::threadMain()
cullOutFibers( fiberDS );
std::cout << "done." << std::endl;
// Since the modules run in a separate thread: such loops are possible
while ( !m_FinishRequested )
{
......@@ -109,6 +117,7 @@ void WFiberCulling::cullOutFibers( boost::shared_ptr< WDataSetFibers > fibers )
const double proximity_t_Square = m_proximity_t * m_proximity_t;
std::vector< bool > unusedFibers( numFibers, false );
WStatusReport st( numFibers );
for( size_t i = 0; i < numFibers; ++i ) // loop over all streamlines
{
if( unusedFibers[i] )
......@@ -138,16 +147,18 @@ void WFiberCulling::cullOutFibers( boost::shared_ptr< WDataSetFibers > fibers )
}
}
}
std::cout << "\r" << std::fixed << std::setprecision( 2 );
std::cout << ( ++st ).progress() << " " << st.stringBar() << std::flush;
}
std::cout << std::endl;
// if( m_saveCulledCurves ) {
// saveFib( m_savePath, fibers, unusedFibers );
// std::cout << "Saving culled fibers to " << m_savePath << " done." << std::endl;
// }
// create new DataSet where unused fibers are not contained
// fibers->erase( unusedFibers );
// std::cout << "Erasing done." << std::endl;
// std::cout << "Culled out " << numFibers - fibers->size() << " fibers" << std::endl;
// std::cout << "There are " << fibers->size() << " fibers left." << std::endl;
fibers->erase( unusedFibers );
std::cout << "Erasing done." << std::endl;
std::cout << "Culled out " << numFibers - fibers->size() << " fibers" << std::endl;
std::cout << "There are " << fibers->size() << " fibers left." << std::endl;
}
Markdown is supported
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