Commit ba1eb5a7 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[MERGE]

parents 0aafa7da 2081ad51
...@@ -12,7 +12,7 @@ allowOnlyOneFiberDataSet = yes # This will prevent you from accidently loading m ...@@ -12,7 +12,7 @@ allowOnlyOneFiberDataSet = yes # This will prevent you from accidently loading m
# default=HUD # default=HUD
## A list of modules that will be provided through the GUI. ## A list of modules that will be provided through the GUI.
## If the list is empty all available modules are provided. ## If the list is empty all available modules are provided.
whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Mesh Reader,Voxelizer,Superquadric Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI whiteList = Arbitrary Plane,Coordinate System,Image Extractor,Paint Texture,Arbitrary Rois,Bounding Box,Distance Map Isosurface,Gauss Filtering,HUD,Isosurface,Isosurface Raytracer,LIC,Read Mesh,Voxelizer,Superquadric Glyphs,Triangle Mesh Renderer,Vector Plot,Write NIfTI
## Specify a ";" separated list of additional paths for modules. The order of appearance is the order of loading. The following additional rules apply here: ## Specify a ";" separated list of additional paths for modules. The order of appearance is the order of loading. The following additional rules apply here:
## 1. if the directory contains one or more libOWmodule_XYZ it/they get loaded ## 1. if the directory contains one or more libOWmodule_XYZ it/they get loaded
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
#include <vector> #include <vector>
#include "../../dataHandler/WDataSetFibers.h" #include "../kernel/WKernel.h"
#include "../../kernel/WKernel.h"
#include "WFiberDrawable.h" #include "WFiberDrawable.h"
// The constructor here does nothing. One thing that may be necessary is // The constructor here does nothing. One thing that may be necessary is
...@@ -35,9 +35,7 @@ ...@@ -35,9 +35,7 @@
// time (that is, the vertices drawn change from time to time). // time (that is, the vertices drawn change from time to time).
WFiberDrawable::WFiberDrawable(): WFiberDrawable::WFiberDrawable():
osg::Drawable(), osg::Drawable(),
m_useTubes( false ), m_useTubes( false )
m_globalColoring( true ),
m_customColoring( false )
{ {
setSupportsDisplayList( false ); setSupportsDisplayList( false );
// This contructor intentionally left blank. Duh. // This contructor intentionally left blank. Duh.
...@@ -85,35 +83,17 @@ void WFiberDrawable::drawImplementation( osg::RenderInfo& renderInfo ) const //N ...@@ -85,35 +83,17 @@ void WFiberDrawable::drawImplementation( osg::RenderInfo& renderInfo ) const //N
void WFiberDrawable::drawFibers( osg::RenderInfo& renderInfo ) const //NOLINT void WFiberDrawable::drawFibers( osg::RenderInfo& renderInfo ) const //NOLINT
{ {
boost::shared_ptr< std::vector< size_t > > startIndexes = m_dataset->getLineStartIndexes();
boost::shared_ptr< std::vector< size_t > > pointsPerLine = m_dataset->getLineLengths();
boost::shared_ptr< std::vector< float > > verts = m_dataset->getVertices();
boost::shared_ptr< std::vector< float > > tangents = m_dataset->getTangents();
boost::shared_ptr< std::vector< float > > colors;
if ( m_customColoring )
{
colors = colors = m_dataset->getColorScheme( "Custom Color" )->getColor();
}
else
{
colors = ( m_globalColoring ? m_dataset->getGlobalColors() : m_dataset->getLocalColors() );
}
boost::shared_ptr< std::vector< bool > > active = m_fiberSelector->getBitfield();
osg::State& state = *renderInfo.getState(); osg::State& state = *renderInfo.getState();
state.disableAllVertexArrays(); state.disableAllVertexArrays();
state.setVertexPointer( 3, GL_FLOAT , 0, &( *verts )[0] ); state.setVertexPointer( 3, GL_FLOAT , 0, &( *m_verts )[0] );
state.setColorPointer( 3 , GL_FLOAT , 0, &( *colors )[0] ); state.setColorPointer( 3 , GL_FLOAT , 0, &( *m_colors )[0] );
state.setNormalPointer( GL_FLOAT , 0, &( *tangents )[0] ); //state.setNormalPointer( GL_FLOAT , 0, &( *m_tangents )[0] );
for ( size_t i = 0; i < active->size(); ++i ) for ( size_t i = 0; i < m_active->size(); ++i )
{ {
if ( (*active)[i] ) if ( (*m_active)[i] )
{ {
state.glDrawArraysInstanced( GL_LINE_STRIP, (*startIndexes)[i], (*pointsPerLine)[i], 1); state.glDrawArraysInstanced( GL_LINE_STRIP, (*m_startIndexes)[i], (*m_pointsPerLine)[i], 1);
} }
} }
...@@ -123,38 +103,20 @@ void WFiberDrawable::drawFibers( osg::RenderInfo& renderInfo ) const //NOLINT ...@@ -123,38 +103,20 @@ void WFiberDrawable::drawFibers( osg::RenderInfo& renderInfo ) const //NOLINT
void WFiberDrawable::drawTubes() const void WFiberDrawable::drawTubes() const
{ {
boost::shared_ptr< std::vector< size_t > > startIndexes = m_dataset->getLineStartIndexes(); for( size_t i = 0; i < m_active->size(); ++i )
boost::shared_ptr< std::vector< size_t > > pointsPerLine = m_dataset->getLineLengths();
boost::shared_ptr< std::vector< float > > verts = m_dataset->getVertices();
boost::shared_ptr< std::vector< float > > tangents = m_dataset->getTangents();
boost::shared_ptr< std::vector< float > > colors;
if ( m_customColoring )
{
colors = m_dataset->getColorScheme( "Custom Color" )->getColor();
}
else
{ {
colors = ( m_globalColoring ? m_dataset->getGlobalColors() : m_dataset->getLocalColors() ); if ( (*m_active)[i] )
}
boost::shared_ptr< std::vector< bool > > active = m_fiberSelector->getBitfield();
for( size_t i = 0; i < active->size(); ++i )
{
if ( active->at( i ) )
{ {
glBegin( GL_QUAD_STRIP ); glBegin( GL_QUAD_STRIP );
int idx = startIndexes->at( i ) * 3; int idx = m_startIndexes->at( i ) * 3;
for ( size_t k = 0; k < pointsPerLine->at( i ); ++k ) for ( size_t k = 0; k < m_pointsPerLine->at( i ); ++k )
{ {
glNormal3f( tangents->at( idx ), tangents->at( idx + 1 ), tangents->at( idx + 2 ) ); glNormal3f( m_tangents->at( idx ), m_tangents->at( idx + 1 ), m_tangents->at( idx + 2 ) );
glColor3f( colors->at( idx ), colors->at( idx + 1 ), colors->at( idx + 2 ) ); glColor3f( m_colors->at( idx ), m_colors->at( idx + 1 ), m_colors->at( idx + 2 ) );
glTexCoord1f( -1.0f ); glTexCoord1f( -1.0f );
glVertex3f( verts->at( idx ), verts->at( idx + 1 ), verts->at( idx + 2 ) ); glVertex3f( m_verts->at( idx ), m_verts->at( idx + 1 ), m_verts->at( idx + 2 ) );
glTexCoord1f( 1.0f ); glTexCoord1f( 1.0f );
glVertex3f( verts->at( idx ), verts->at( idx + 1 ), verts->at( idx + 2 ) ); glVertex3f( m_verts->at( idx ), m_verts->at( idx + 1 ), m_verts->at( idx + 2 ) );
idx += 3; idx += 3;
// //
} }
...@@ -162,3 +124,8 @@ void WFiberDrawable::drawTubes() const ...@@ -162,3 +124,8 @@ void WFiberDrawable::drawTubes() const
} }
} }
} }
void WFiberDrawable::setDataset( boost::shared_ptr< const WDataSetFibers > dataset )
{
m_dataset = dataset;
}
...@@ -35,12 +35,8 @@ ...@@ -35,12 +35,8 @@
#include <osg/ShapeDrawable> #include <osg/ShapeDrawable>
#include <osg/Group> #include <osg/Group>
#include "WFiberSelector.h"
class WDataSetFibers;
/** /**
* TODO(schurade): Document this! * Class implements an osg::Drawable that paints fiber representations either using lines or tubes
*/ */
class WFiberDrawable: public osg::Drawable class WFiberDrawable: public osg::Drawable
{ {
...@@ -108,49 +104,46 @@ public: ...@@ -108,49 +104,46 @@ public:
void setUseTubes( bool flag ); void setUseTubes( bool flag );
/** /**
* Set the coloring modes of the fibers. * Set the bounding box of all fibers.
* * \param bb The new bounding box.
* \param globalColoring If true is given global coloring is applied ( default ), else local coloring
*/ */
void setColoringMode( bool globalColoring ); void setBoundingBox( const osg::BoundingBox & bb );
/** /**
* Set the use of custom colors * setter
* * \param bitField selected fibers to draw
* \param custom
*/ */
void setCustomColoring( bool custom ); void setBitfield( boost::shared_ptr< std::vector< bool > > bitField );
/** /**
* In which mode coloring for the fibers is applied. * setter
* * \param idx
* \return True for global, false for local coloring
*/ */
bool getColoringMode() const; void setStartIndexes( boost::shared_ptr< std::vector< size_t > > idx );
/** /**
* Set the bounding box of all fibers. * setter
* \param bb The new bounding box. * \param ppl
*/ */
void setBoundingBox( const osg::BoundingBox & bb ); void setPointsPerLine( boost::shared_ptr< std::vector< size_t > > ppl );
/** /**
* setter * setter
* \param bitField selected fibers to draw * \param verts
*/ */
void setBitfield( boost::shared_ptr< std::vector< bool > > bitField ); void setVerts( boost::shared_ptr< std::vector< float > > verts );
/** /**
* setter * setter
* \param selector the selector object which provides the bitfield for fiber selection * \param tangents
*/ */
void setSelector( boost::shared_ptr< WFiberSelector > selector ); void setTangents( boost::shared_ptr< std::vector< float > > tangents );
/** /**
* setter * setter
* \param colors * \param color
*/ */
void setCustomColors( boost::shared_ptr< std::vector< float > > colors ); void setColor( boost::shared_ptr< std::vector< float > > color );
protected: protected:
private: private:
...@@ -172,54 +165,53 @@ private: ...@@ -172,54 +165,53 @@ private:
bool m_useTubes; //!< flag bool m_useTubes; //!< flag
bool m_globalColoring; //!< True indicates global, false local coloring
bool m_customColoring; //!< True indicates use of custom colors
boost::shared_ptr< std::vector< bool > > m_active; //!< pointer to the bitfield of active fibers boost::shared_ptr< std::vector< bool > > m_active; //!< pointer to the bitfield of active fibers
boost::shared_ptr< WFiberSelector > m_fiberSelector; //!< the selector object which provides the bitfield for fiber selection boost::shared_ptr< std::vector< size_t > > m_startIndexes; //!< pointer to the field of line start indexes
boost::shared_ptr< std::vector< size_t > > m_pointsPerLine; //!< pointer to the field of points per line
boost::shared_ptr< std::vector< float > > m_verts; //!< pointer to the field of vertexes
boost::shared_ptr< std::vector< float > > m_tangents; //!< pointer to the field of line tangents
boost::shared_ptr< std::vector< float > > m_colors; //!< pointer to the field of colors per vertex
}; };
inline void WFiberDrawable::setDataset( boost::shared_ptr< const WDataSetFibers > dataset ) inline void WFiberDrawable::setUseTubes( bool flag )
{ {
m_dataset = dataset; m_useTubes = flag;
} }
inline void WFiberDrawable::setUseTubes( bool flag ) inline void WFiberDrawable::setBoundingBox( const osg::BoundingBox & bb )
{ {
m_useTubes = flag; setBound( bb );
} }
inline void WFiberDrawable::setColoringMode( bool globalColoring ) inline void WFiberDrawable::setBitfield( boost::shared_ptr< std::vector< bool > > bitField )
{ {
m_globalColoring = globalColoring; m_active = bitField;
} }
inline bool WFiberDrawable::getColoringMode() const inline void WFiberDrawable::setStartIndexes( boost::shared_ptr< std::vector< size_t > > idx )
{ {
return m_globalColoring; m_startIndexes = idx;
} }
inline void WFiberDrawable::setCustomColoring( bool custom ) inline void WFiberDrawable::setPointsPerLine( boost::shared_ptr< std::vector< size_t > > ppl )
{ {
m_customColoring = custom; m_pointsPerLine = ppl;
} }
inline void WFiberDrawable::setBoundingBox( const osg::BoundingBox & bb ) inline void WFiberDrawable::setVerts( boost::shared_ptr< std::vector< float > > verts )
{ {
setBound( bb ); m_verts = verts;
} }
inline void WFiberDrawable::setBitfield( boost::shared_ptr< std::vector< bool > > bitField ) inline void WFiberDrawable::setTangents( boost::shared_ptr< std::vector< float > > tangents )
{ {
m_active = bitField; m_tangents = tangents;
} }
inline void WFiberDrawable::setSelector( boost::shared_ptr< WFiberSelector > selector ) inline void WFiberDrawable::setColor( boost::shared_ptr< std::vector< float > > color )
{ {
m_fiberSelector = selector; m_colors = color;
} }
#endif // WFIBERDRAWABLE_H #endif // WFIBERDRAWABLE_H
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <iostream> #include <iostream>
#include "../../kernel/WKernel.h" #include "../kernel/WKernel.h"
#include "WFiberSelector.h" #include "WFiberSelector.h"
...@@ -136,28 +136,33 @@ void WFiberSelector::recalculate() ...@@ -136,28 +136,33 @@ void WFiberSelector::recalculate()
{ {
if ( m_branches.empty() ) if ( m_branches.empty() )
{ {
m_outputBitfield = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_size, true ) ); m_workerBitfield = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_size, true ) );
return;
} }
else else
{ {
m_workerBitfield = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_size, false ) ); m_workerBitfield = boost::shared_ptr< std::vector< bool > >( new std::vector< bool >( m_size, false ) );
}
for ( std::list< boost::shared_ptr< WSelectorBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{
boost::shared_ptr< std::vector< bool > > bf = ( *iter )->getBitField();
for ( size_t i = 0; i < m_size; ++i ) for ( std::list< boost::shared_ptr< WSelectorBranch > >::iterator iter = m_branches.begin(); iter != m_branches.end(); ++iter )
{ {
( *m_workerBitfield )[i] = ( *m_workerBitfield )[i] | ( *bf )[i]; boost::shared_ptr< std::vector< bool > > bf = ( *iter )->getBitField();
for ( size_t i = 0; i < m_size; ++i )
{
( *m_workerBitfield )[i] = ( *m_workerBitfield )[i] | ( *bf )[i];
}
} }
} }
for ( size_t i = 0; i < m_size; ++i )
{
( *m_outputBitfield )[i] = ( *m_workerBitfield )[i];
}
m_dirty = false; m_dirty = false;
m_outputBitfield = m_workerBitfield; //m_outputBitfield = m_workerBitfield;
} }
void WFiberSelector::setDirty() void WFiberSelector::setDirty()
{ {
recalculate();
m_dirty = true; m_dirty = true;
} }
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <list> #include <list>
#include <vector> #include <vector>
#include "../../dataHandler/WDataSetFibers.h" #include "../dataHandler/WDataSetFibers.h"
#include "WSelectorRoi.h" #include "WSelectorRoi.h"
#include "WSelectorBranch.h" #include "WSelectorBranch.h"
...@@ -102,20 +102,6 @@ protected: ...@@ -102,20 +102,6 @@ protected:
*/ */
void slotRemoveBranch( boost::shared_ptr< WRMBranch > branch ); void slotRemoveBranch( boost::shared_ptr< WRMBranch > branch );
/**
* setter
* \param colors
*/
void setCustomColors( boost::shared_ptr< std::vector< float > > colors );
/**
* getter
* \return colors
*/
boost::shared_ptr< std::vector< float > > getCustomColors();
private: private:
/** /**
* update the bitfield when there was a change in the roi structure * update the bitfield when there was a change in the roi structure
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "../../common/WAssert.h" #include "../common/WAssert.h"
#include "../../common/WLogger.h" #include "../common/WLogger.h"
#include "WKdTree.h" #include "WKdTree.h"
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include "../../common/WThreadedRunner.h" #include "../common/WThreadedRunner.h"
/** /**
* implements the compare function for std::nth_element on a point array * implements the compare function for std::nth_element on a point array
......
...@@ -61,6 +61,9 @@ void WRMBranch::propertyChanged() ...@@ -61,6 +61,9 @@ void WRMBranch::propertyChanged()
void WRMBranch::addRoi( osg::ref_ptr< WROI > roi ) void WRMBranch::addRoi( osg::ref_ptr< WROI > roi )
{ {
m_rois.push_back( roi ); m_rois.push_back( roi );
boost::function< void() > changeRoiSignal = boost::bind( &WRMBranch::setDirty, this );
roi->addChangeNotifier( changeRoiSignal );
setDirty(); setDirty();
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <vector> #include <vector>
#include "WSelectorRoi.h" #include "WSelectorRoi.h"
#include "../../kernel/WRMBranch.h" #include "../kernel/WRMBranch.h"
/** /**
* TODO(schurade): Document this! * TODO(schurade): Document this!
......
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//#include "../../../graphicsEngine/WGraphicsEngine.h" //#include "../../../graphicsEngine/WGraphicsEngine.h"
#include "../../graphicsEngine/WROIBox.h" #include "../graphicsEngine/WROIBox.h"
#include "../../graphicsEngine/WROIArbitrary.h" #include "../graphicsEngine/WROIArbitrary.h"
#include "WSelectorRoi.h" #include "WSelectorRoi.h"
......
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
#include <vector> #include <vector>
#include "../../dataHandler/WDataSetFibers.h" #include "../dataHandler/WDataSetFibers.h"
#include "../../graphicsEngine/WROI.h" #include "../graphicsEngine/WROI.h"
#include "WKdTree.h" #include "WKdTree.h"
/** /**
......
...@@ -25,12 +25,13 @@ ...@@ -25,12 +25,13 @@
#include <iostream> #include <iostream>
#include "../../graphicsEngine/WGEUtils.h" #include "../../graphicsEngine/WGEUtils.h"
#include "WDendrogram.h" #include "WDendrogramGeode.h"
/** /**
* Class implements a dendrogram as an osg geode * Class implements a dendrogram as an osg geode
*/ */
WDendrogram::WDendrogram( WHierarchicalTree* tree, size_t cluster, size_t minClusterSize, float xSize, float ySize, float xOffset, float yOffset ) : WDendrogramGeode::WDendrogramGeode( WHierarchicalTree* tree, size_t cluster, size_t minClusterSize,
float xSize, float ySize, float xOffset, float yOffset ) :
osg::Geode(), osg::Geode(),
m_tree( tree ), m_tree( tree ),
m_rootCluster( cluster ), m_rootCluster( cluster ),
...@@ -43,11 +44,11 @@ WDendrogram::WDendrogram( WHierarchicalTree* tree, size_t cluster, size_t minClu ...@@ -43,11 +44,11 @@ WDendrogram::WDendrogram( WHierarchicalTree* tree, size_t cluster, size_t minClu
create(); create();
} }
WDendrogram::~WDendrogram() WDendrogramGeode::~WDendrogramGeode()
{ {
} }
void WDendrogram::create() void WDendrogramGeode::create()
{ {
m_colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array ); m_colors = osg::ref_ptr<osg::Vec4Array>( new osg::Vec4Array );