Commit 447c52a8 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[FIX] - avoid problems if fiber cluster does not match the fiber dataset

parent 78f2ac41
......@@ -63,8 +63,8 @@ WFiberCluster::WFiberCluster( const WFiberCluster::IndexList& indices, const WCo
// init
}
WFiberCluster::WFiberCluster( WFiberCluster::IndexList::const_iterator indicesBegin,
WFiberCluster::IndexList::const_iterator indicesEnd, const WColor& color )
WFiberCluster::WFiberCluster( WFiberCluster::IndexListConstIterator indicesBegin,
WFiberCluster::IndexListConstIterator indicesEnd, const WColor& color )
: WTransferable(),
m_color( color ),
m_centerLineCreationLock( new boost::shared_mutex() ),
......@@ -115,8 +115,8 @@ void WFiberCluster::merge( WFiberCluster& other ) // NOLINT
other.clear();
}
void WFiberCluster::merge( WFiberCluster::IndexList::const_iterator indicesBegin,
WFiberCluster::IndexList::const_iterator indicesEnd )
void WFiberCluster::merge( WFiberCluster::IndexListConstIterator indicesBegin,
WFiberCluster::IndexListConstIterator indicesEnd )
{
// now copy the index list
m_memberIndices.insert( m_memberIndices.end(), indicesBegin, indicesEnd );
......
......@@ -59,6 +59,11 @@ public:
*/
typedef std::list< size_t > IndexList;
/**
* Const iterator on the index list.
*/
typedef IndexList::const_iterator IndexListConstIterator;
/**
* Constructs an cluster with one fiber and a reference to the fiber dataset
* to compute the intercluster distance.
......@@ -83,7 +88,8 @@ public:
* \param indicesEnd end iterator in the predefined index set
* \param color the color of this cluster
*/
WFiberCluster( IndexList::const_iterator indicesBegin, IndexList::const_iterator indicesEnd, const WColor& color = WColor() );
WFiberCluster( IndexListConstIterator indicesBegin,
IndexListConstIterator indicesEnd, const WColor& color = WColor() );
/**
* Copies the specified \ref WFiberCluster Instance. The copy does not contain a valid centerline or longest line.
......@@ -124,7 +130,7 @@ public:
* \param indicesBegin begin iterator in the predefined index set
* \param indicesEnd end iterator in the predefined index set
*/
void merge( IndexList::const_iterator indicesBegin, IndexList::const_iterator indicesEnd );
void merge( IndexListConstIterator indicesBegin, IndexListConstIterator indicesEnd );
/**
* Returns a const reference of all indices inside this cluster
......
......@@ -82,7 +82,9 @@ void WMFiberDisplaySimple::connectors()
);
m_fiberClusteringInput = boost::shared_ptr< WModuleInputData < WDataSetFiberClustering > >(
new WModuleInputData< WDataSetFiberClustering >( shared_from_this(), "fiberClustering", "Optional input to filter the fibers using a clustering." )
new WModuleInputData< WDataSetFiberClustering >( shared_from_this(), "fiberClustering",
"Optional input to filter the fibers using a clustering."
)
);
// As properties, every connector needs to be added to the list of connectors.
......@@ -545,7 +547,8 @@ void WMFiberDisplaySimple::geometryUpdate( osg::Drawable* geometry )
if( m_fiberClusteringUpdate && m_fiberClustering )
{
m_fiberClusteringUpdate = false;
osg::ref_ptr< osg::Vec3Array > attribs = new osg::Vec3Array( m_fibers->getLineStartIndexes()->size() );
size_t maxFibIdx = m_fibers->getLineStartIndexes()->size() - 1;
osg::ref_ptr< osg::Vec3Array > attribs = new osg::Vec3Array( maxFibIdx + 1 );
// now initialize attrib array
for( size_t fidx = 0; fidx < m_fibers->getLineStartIndexes()->size() ; ++fidx )
{
......@@ -559,6 +562,12 @@ void WMFiberDisplaySimple::geometryUpdate( osg::Drawable* geometry )
const WFiberCluster::IndexList& ids = ( *iter ).second->getIndices();
for( WFiberCluster::IndexList::const_iterator fibIter = ids.begin(); fibIter != ids.end(); ++fibIter )
{
// be nice here. If the clustering contains some invalid IDs, ignore it.
if( *fibIter > maxFibIdx )
{
continue;
}
// set the color
( *attribs)[ *fibIter ] = osg::Vec3(
( *iter ).second->getColor().r(),
( *iter ).second->getColor().g(),
......
......@@ -244,7 +244,6 @@ private:
* The plane node.
*/
osg::ref_ptr< osg::Node > m_plane;
};
#endif // WMFIBERDISPLAYSIMPLE_H
......
......@@ -43,7 +43,6 @@ public:
* Constructor. Use the doneCondition to wait for the event to be processed.
*
* \param title the title of the widget to open
* \param doneCondition This condition is fired whenever the widget is really closed.
*/
explicit WCloseCustomDockWidgetEvent( std::string title );
......
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