Commit ccaa6d58 authored by Mathias Goldau's avatar Mathias Goldau

[ADD] Functionality for selecting the cluster which is about to be voxelized

parent 4538705f
......@@ -57,6 +57,7 @@ WMFiberClustering::WMFiberClustering()
m_minClusterSize( 10 ),
m_separatePrimitives( true ),
m_proximity_t( 0.0 ),
m_clusterOutputID( 0 ),
m_lastFibsSize( 0 )
{
}
......@@ -110,9 +111,19 @@ void WMFiberClustering::update()
cluster();
paint();
// TODO(math): For reasons of simplicity just forward one cluster to the voxelizer
m_clusters[0].setDataSetReference( m_fibs );
for( size_t i = 0; i < m_clusters.size(); ++i )
{
m_clusters[ i ].setDataSetReference( m_fibs );
}
boost::shared_ptr< WFiberCluster > c;
c = boost::shared_ptr< WFiberCluster >( &m_clusters[0] );
if( m_clusterOutputID > m_clusters.size() )
{
errorLog() << "Invalid cluster ID for output selected: " << m_clusterOutputID << " using default ID 0";
m_clusterOutputID = 0;
}
debugLog() << "Cluster ID for output: " << m_clusterOutputID;
c = boost::shared_ptr< WFiberCluster >( new WFiberCluster( m_clusters[ m_clusterOutputID ] ) );
m_output->updateData( c );
}
......@@ -343,6 +354,11 @@ void WMFiberClustering::properties()
false,
"All clusters up to this size will be discarded."
)->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addInt( "output cluster id",
m_clusterOutputID,
false,
"Only the cluster with this ID will be connected to the output."
)->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addBool( "separate primitives",
m_separatePrimitives,
false,
......@@ -378,6 +394,20 @@ void WMFiberClustering::slotPropertyChanged( std::string propertyName )
m_proximity_t = m_properties->getValue< double >( propertyName );
update();
}
else if( propertyName == "output cluster id" )
{
m_clusterOutputID = m_properties->getValue< size_t >( propertyName );
boost::shared_ptr< WFiberCluster > c;
if( m_clusterOutputID > m_clusters.size() )
{
errorLog() << "Invalid cluster ID for output selected: " << m_clusterOutputID << " using default ID 0";
m_clusterOutputID = 0;
}
debugLog() << "Cluster ID for output: " << m_clusterOutputID;
// TODO(math): For reasons of simplicity just forward one cluster to the voxelizer
c = boost::shared_ptr< WFiberCluster >( new WFiberCluster( m_clusters[ m_clusterOutputID ] ) );
m_output->updateData( c );
}
else
{
// instead of WLogger we must use std::cerr since WLogger needs to much time!
......
......@@ -185,6 +185,8 @@ private:
*/
double m_proximity_t;
size_t m_clusterOutputID; //!< Specifies which cluster should be connected to the Output
size_t m_lastFibsSize; //!< Last known number of fibers
/**
......
......@@ -37,6 +37,7 @@
*/
class WBresenhamDBL : public WBresenham
{
friend class WBresenhamDBLTest;
public:
/**
* Initializes new raster algo.
......
......@@ -120,16 +120,16 @@ osg::ref_ptr< osg::Geode > WMVoxelizer::genFiberGeode() const
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_STRIP, vertices->size() - fib.size(), fib.size() ) );
}
// TODO(math): This is just a line for testing purposes
vertices->push_back( osg::Vec3( 73, 38, 29 ) );
vertices->push_back( osg::Vec3( 120, 150, 130 ) );
colors->push_back( colors->back() );
colors->push_back( colors->back() );
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_STRIP, vertices->size() - 2, 2 ) );
vertices->push_back( osg::Vec3( 7.2766304016113281e+01, 3.7974670410156250e+01, 2.9449142456054688e+01 ) );
vertices->push_back( osg::Vec3( 1.1976630401611328e+02, 1.4997467041015625e+02, 1.3044914245605469e+02 ) );
colors->push_back( osg::Vec4( 1, 1, 1, 1 ) );
colors->push_back( osg::Vec4( 1, 1, 1, 1 ) );
geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_STRIP, vertices->size() - 2, 2 ) );
// vertices->push_back( osg::Vec3( 73, 38, 29 ) );
// vertices->push_back( osg::Vec3( 120, 150, 130 ) );
// colors->push_back( colors->back() );
// colors->push_back( colors->back() );
// geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_STRIP, vertices->size() - 2, 2 ) );
// vertices->push_back( osg::Vec3( 7.2766304016113281e+01, 3.7974670410156250e+01, 2.9449142456054688e+01 ) );
// vertices->push_back( osg::Vec3( 1.1976630401611328e+02, 1.4997467041015625e+02, 1.3044914245605469e+02 ) );
// colors->push_back( osg::Vec4( 1, 1, 1, 1 ) );
// colors->push_back( osg::Vec4( 1, 1, 1, 1 ) );
// geometry->addPrimitiveSet( new osg::DrawArrays( osg::PrimitiveSet::LINE_STRIP, vertices->size() - 2, 2 ) );
geometry->setVertexArray( vertices );
geometry->setColorArray( colors );
......@@ -227,10 +227,10 @@ void WMVoxelizer::raster( boost::shared_ptr< WRasterAlgorithm > algo ) const
algo->raster( fibs[*cit] );
}
// TODO(math): This is just a line for testing purposes
wmath::WLine l;
l.push_back( wmath::WPosition( 73, 38, 29 ) );
l.push_back( wmath::WPosition( 120, 150, 130 ) );
algo->raster( l );
// wmath::WLine l;
// l.push_back( wmath::WPosition( 73, 38, 29 ) );
// l.push_back( wmath::WPosition( 120, 150, 130 ) );
// algo->raster( l );
}
void WMVoxelizer::connectors()
......
......@@ -107,6 +107,52 @@ public:
TS_ASSERT_EQUALS( m_algo->m_values, expected );
}
/**
* Lines rastered in the 3rd Quadrant should also be traced.
*/
void testRasteringIn3rdQuadrant( void )
{
boost::shared_ptr< WGridRegular3D > grid;
grid = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D( 3, 3, 3, -2, -2, -2, 1, 1, 1 ) );
m_algo = boost::shared_ptr< WBresenham >( new WBresenham( grid, false ) );
wmath::WLine l;
l.push_back( wmath::WPosition( -1.7, -1.7, -1.7 ) );
l.push_back( wmath::WPosition( -0.6, -0.6, -0.6 ) );
l.push_back( wmath::WPosition( -0.4, -0.4, -0.4 ) );
m_algo->raster( l );
std::vector< double > expected( 27, 0.0 );
expected[0] = 1.0;
expected[13] = 1.0;
expected[26] = 1.0;
TS_ASSERT_EQUALS( m_algo->m_values, expected );
}
/**
* If you have a line from A to B then rastering it from B to should be
* equivalent.
*/
void testSymmetry( void )
{
wmath::WLine l;
l.push_back( wmath::WPosition( 0.4, 0.4, 0.4 ) );
l.push_back( wmath::WPosition( 0.6, 0.6, 0.6 ) );
l.push_back( wmath::WPosition( 1.7, 1.7, 1.7 ) );
m_algo->raster( l );
std::vector< double > expected( 27, 0.0 );
expected[0] = 1.0;
expected[13] = 1.0;
expected[26] = 1.0;
TS_ASSERT_EQUALS( m_algo->m_values, expected );
m_algo->m_values[0] = m_algo->m_values[13] = m_algo->m_values[26] = 0.0; // reset the values array
l.clear();
l.push_back( wmath::WPosition( 1.7, 1.7, 1.7 ) );
l.push_back( wmath::WPosition( 0.6, 0.6, 0.6 ) );
l.push_back( wmath::WPosition( 0.4, 0.4, 0.4 ) );
m_algo->raster( l );
TS_ASSERT_EQUALS( m_algo->m_values, expected );
}
/**
* Lines starting in a voxel A and ending in voxel B are rastered exactly
* the same way as all lines starting in A and ending in B as well as
......
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