Commit c3f3a12e authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[ADD] FiberCulling Tab-Widget aka UI for the fiber culling algo improved

parent c0493f46
......@@ -324,7 +324,7 @@ void WMFiberClustering::properties()
false,
"Maximum distance of two fibers in one cluster."
)->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addDouble( "max distance threshold",
m_properties->addDouble( "proximity threshold",
m_proximity_t,
false,
"defines the minimum distance between two fibers which should be considered in distance measure."
......@@ -359,6 +359,16 @@ void WMFiberClustering::slotPropertyChanged( std::string propertyName )
m_maxDistance_t = m_properties->getValue< double >( propertyName );
update();
}
else if( propertyName == "min cluster size" )
{
m_minClusterSize = m_properties->getValue< double >( propertyName );
update();
}
else if( propertyName == "proximity threshold" )
{
m_proximity_t = m_properties->getValue< double >( propertyName );
update();
}
else
{
// instead of WLogger we must use std::cerr since WLogger needs to much time!
......
......@@ -27,6 +27,8 @@
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <osg/Geode>
#include <osg/Geometry>
......@@ -76,8 +78,6 @@ void WMFiberCulling::moduleMain()
continue;
}
update();
m_moduleState.wait(); // waits for firing of m_moduleState ( dataChanged, shutdown, etc. )
}
}
......@@ -105,7 +105,44 @@ void WMFiberCulling::connectors()
void WMFiberCulling::properties()
{
m_properties->addString( "Fibers Display Module", "Display fibers" );
m_properties->addDouble( "min distance threshold",
m_dSt_culling_t,
false,
"Minimum distance of two \"different\" fibers."
)->connect( boost::bind( &WMFiberCulling::slotPropertyChanged, this, _1 ) );
m_properties->addDouble( "proximity threshold",
m_proximity_t,
false,
"defines the minimum distance between two fibers which should be considered in distance measure."
)->connect( boost::bind( &WMFiberCulling::slotPropertyChanged, this, _1 ) );
m_properties->addBool( "GO",
false,
false,
"initiate run"
)->connect( boost::bind( &WMFiberCulling::slotPropertyChanged, this, _1 ) );
}
void WMFiberCulling::slotPropertyChanged( std::string propertyName )
{
std::cout << "prop: " << propertyName << " has changed" << std::endl;
if( propertyName == "GO" )
{
update();
}
else if( propertyName == "min distance threshold" )
{
m_dSt_culling_t = m_properties->getValue< double >( propertyName );
}
else if( propertyName == "proximity threshold" )
{
m_proximity_t = m_properties->getValue< double >( propertyName );
}
else
{
// instead of WLogger we must use std::cerr since WLogger needs to much time!
std::cerr << propertyName << std::endl;
assert( 0 && "This property name is not supported by this function yet." );
}
}
void WMFiberCulling::cullOutFibers()
......@@ -158,7 +195,15 @@ void WMFiberCulling::cullOutFibers()
infoLog() << "Culled out " << numFibers - m_dataset->size() << " fibers";
infoLog() << "There are " << m_dataset->size() << " fibers left.";
// TODO(math): make saving parameter dependent, and apply the desired path for saving
WWriterFiberVTK w( "/tmp/pansen.fib", true );
WWriterFiberVTK w( saveFileName(), true );
w.writeFibs( m_dataset );
}
std::string WMFiberCulling::saveFileName() const
{
std::stringstream newExtension;
newExtension << std::fixed << std::setprecision( 2 );
newExtension << ".pt-" << m_proximity_t << ".dst-" << m_dSt_culling_t << ".fib";
boost::filesystem::path fibFileName( m_dataset->getFileName() );
return fibFileName.replace_extension( newExtension.str() ).string();
}
......@@ -90,6 +90,12 @@ public:
*/
void update();
/**
* Determine what to do if a property was changed.
* \param propertyName Name of the property.
*/
void slotPropertyChanged( std::string propertyName );
protected:
/**
* Entry point after loading the module. Runs in separate thread.
......@@ -103,6 +109,14 @@ protected:
*/
virtual void cullOutFibers();
/**
* Generates the file name for saving the culled fibers out of some
* culling parameters: the proximity threshold and the dSt distance.
*
* \return file name in which to store the culled fibers.
*/
std::string saveFileName() const;
/**
* Proximity threshold, which defines the minimum distance which should be
* considered in the calculation of the mean-minimum-distance of two fibers.
......
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