Commit 1f7b92ac authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[FIX] No segfauts during startup.

parent 291764e6
......@@ -148,29 +148,13 @@ void WMClusterParamDisplay::initSubModules()
m_meshRenderer->getInputConnector( "mesh" )->connect( m_clusterSlicer->getOutputConnector( "meshOutput" ) );
m_meshRenderer->getInputConnector( "colorMap" )->connect( m_clusterSlicer->getOutputConnector( "colorMapOutput" ) );
m_voxelizer->getInputConnector( "tractInput" )->connect( m_detTractClustering->getOutputConnector( "clusterOutput" ) );
m_fiberIC->forward( m_detTractClustering->getInputConnector( "tractInput" ) ); // init rippling
m_fiberIC->forward( m_voxelizer->getInputConnector( "tractInput" ) ); // init rippling
debugLog() << "Wiring done";
// forward properties
m_properties->addProperty( m_detTractClustering->getProperties()->getProperty( "Output cluster ID" ) );
m_properties->addProperty( m_detTractClustering->getProperties()->getProperty( "Max cluster distance" ) );
m_properties->addProperty( m_detTractClustering->getProperties()->getProperty( "Min point distance" ) );
m_properties->addProperty( m_gaussFiltering->getProperties()->getProperty( "Iterations" ) );
m_properties->addProperty( m_meshRenderer->getProperties()->getProperty( "Coloring" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Show|Hide Iso Voxels" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Mean Type" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Show|Hide Slices" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Planes #X-SamplePoints" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Planes #Y-SamplePoints" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Planes Step Width" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "#Planes" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Biggest Component Only" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "Custom Scale" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "MinScale" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "MaxScale" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "MinScaleColor" ) );
m_properties->addProperty( m_clusterSlicer->getProperties()->getProperty( "MaxScaleColor" ) );
m_properties->addProperty( m_voxelizer->getProperties()->getProperty( "Voxels per Unit" ) );
m_properties->addProperty( m_detTractClustering->getProperties()->getProperty( "Start clustering" ) );
m_properties->addPropertyGroup( "MeshRender", "Props" )->addProperty( m_meshRenderer->getProperties() );
m_properties->addPropertyGroup( "Slicer", "Props" )->addProperty( m_clusterSlicer->getProperties() );
m_properties->addPropertyGroup( "Clustering", "Props" )->addProperty( m_detTractClustering->getProperties() );
m_properties->addPropertyGroup( "Voxelizer", "Props" )->addProperty( m_voxelizer->getProperties() );
m_properties->addPropertyGroup( "Gauss", "Props" )->addProperty( m_gaussFiltering->getProperties() );
}
......@@ -49,12 +49,10 @@
#include "core/kernel/WKernel.h"
#include "WMClusterSlicer.h"
// This line is needed by the module loader to actually find your module.
WMClusterSlicer::WMClusterSlicer()
: WModule(),
m_rootNode( osg::ref_ptr< WGEGroupNode >( new WGEGroupNode() ) ),
m_fullUpdate( new WCondition ),
m_rootNode( osg::ref_ptr< WGEManagedGroupNode > ( new WGEManagedGroupNode( m_active ) ) ),
m_fullUpdate( new WCondition() ),
m_maxMean( 0.0 ),
m_minMean( 0.0 )
{
......@@ -128,8 +126,6 @@ void WMClusterSlicer::properties()
void WMClusterSlicer::moduleMain()
{
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
m_moduleState.setResetable( true, true );
m_moduleState.add( m_paramIC->getDataChangedCondition() );
m_moduleState.add( m_triangleMeshIC->getDataChangedCondition() );
......@@ -140,6 +136,8 @@ void WMClusterSlicer::moduleMain()
ready();
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
while( !m_shutdownFlag() )
{
debugLog() << "Waiting...";
......@@ -160,21 +158,21 @@ void WMClusterSlicer::moduleMain()
bool clusterDSChanged = ( m_clusterDS != newClusterDS );
bool dataChanged = clusterDSChanged || clusterChanged || paramDSChanged || meshChanged;
m_clusterDS = newClusterDS;
m_cluster = newCluster;
m_paramDS = newParamDS;
m_mesh = newMesh;
if( !( m_clusterDS.get() && m_cluster.get() && m_paramDS.get() && m_mesh.get() ) )
if( !( newClusterDS && newCluster && newParamDS && newMesh ) )
{
debugLog() << "Invalid data. Waiting for data change again.";
continue;
}
m_clusterDS = newClusterDS;
m_cluster = newCluster;
m_paramDS = newParamDS;
m_mesh = newMesh;
if( dataChanged )
{
infoLog() << "Coverage for isovalue: " << m_isoValue->get() << " is: " << countTractPointsInsideVolume( m_isoValue->get() );
infoLog() << "Recommended isovalue for specified coverage: " << computeOptimalIsoValue();
// infoLog() << "Recommended isovalue for specified coverage: " << computeOptimalIsoValue();
}
if( dataChanged )
......@@ -302,7 +300,7 @@ void WMClusterSlicer::generateSlices()
const double stepWidth = m_planeStepWidth->get( true );
const int meanType = m_meanSelector->get( true );
m_rootNode->remove( m_samplePointsGeode );
m_samplePointsGeode = osg::ref_ptr< WGEGroupNode >( new WGEGroupNode ); // discard old geode
m_samplePointsGeode = osg::ref_ptr< WGEManagedGroupNode >( new WGEManagedGroupNode( m_active ) ); // discard old geode
WVector3d generator = ( centerLine.front() - midPoint( centerLine ) );
generator = cross( generator, centerLine.back() - midPoint( centerLine ) );
......@@ -550,7 +548,7 @@ void WMClusterSlicer::updateDisplay( bool force )
generateSlices(); // for recomputation of sample point geode
m_sliceGeode = osg::ref_ptr< WGEGroupNode >( new WGEGroupNode ); // discard old geode
m_sliceGeode = osg::ref_ptr< WGEManagedGroupNode >( new WGEManagedGroupNode( m_active ) ); // discard old geode
if( m_drawSlices->get( true ) ) // regenerate
{
const double width = m_planeNumX->get() * m_planeStepWidth->get();
......@@ -633,20 +631,3 @@ double WMClusterSlicer::computeOptimalIsoValue( double coverage ) const
}
return m_clusterDS->getMin() + std::abs( m_clusterDS->getMin() - m_clusterDS->getMax() ) * index / static_cast< double >( h.size() );
}
void WMClusterSlicer::activate()
{
if( m_rootNode )
{
if( m_active->get() )
{
m_rootNode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_rootNode->setNodeMask( 0x0 );
}
}
WModule::activate();
}
......@@ -39,7 +39,7 @@
#include "core/dataHandler/datastructures/WFiberCluster.h"
#include "core/dataHandler/datastructures/WJoinContourTree.h"
#include "core/dataHandler/WDataSetScalar.h"
#include "core/graphicsEngine/WGEGroupNode.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "core/graphicsEngine/WGEGeometryUtils.h"
#include "core/graphicsEngine/WTriangleMesh.h"
#include "core/kernel/WModule.h"
......@@ -101,11 +101,6 @@ protected:
*/
virtual void properties();
/**
* Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
*/
virtual void activate();
/**
* Updates either the planes representing the slices or the isovoxels of the volume
*
......@@ -163,7 +158,7 @@ protected:
/**
* The root node used for this modules graphics.
*/
osg::ref_ptr< WGEGroupNode > m_rootNode;
osg::ref_ptr< WGEManagedGroupNode > m_rootNode;
/**
* Separate geode for voxels of the cluster volume
......@@ -173,12 +168,12 @@ protected:
/**
* Separate geode for slices
*/
osg::ref_ptr< WGEGroupNode > m_sliceGeode;
osg::ref_ptr< WGEManagedGroupNode > m_sliceGeode;
/**
* Separate geode for the sample Points
*/
osg::ref_ptr< WGEGroupNode > m_samplePointsGeode;
osg::ref_ptr< WGEManagedGroupNode > m_samplePointsGeode;
/**
* InputConnector for a fiber cluster with its CenterLine
......@@ -210,140 +205,140 @@ protected:
*/
boost::shared_ptr< WModuleOutputData< WTriangleMesh > > m_triangleMeshOC;
/**
* A cluster with its CenterLine
*/
boost::shared_ptr< WFiberCluster > m_cluster;
/**
* Dataset derived from a voxelized cluster
*/
boost::shared_ptr< WDataSetScalar > m_clusterDS;
/**
* Dataset derived from a voxelized cluster
*/
boost::shared_ptr< WDataSetScalar > m_paramDS;
/**
* stores all planes and their average parameters along centerLine
*/
boost::shared_ptr< std::vector< std::pair< double, WPlane > > > m_slices;
/**
* Reference to the TriangleMesh to make intersections
*/
boost::shared_ptr< WTriangleMesh > m_mesh;
/**
* Stores the color for vertices belonging to the intersection with the mesh and the planes
*/
boost::shared_ptr< WColoredVertices > m_colorMap;
/**
* Stores the JoinTree
*/
boost::shared_ptr< WJoinContourTree > m_joinTree;
/**
* Stores the voxels belonging to the cluster volume of a certain iso value
*/
boost::shared_ptr< std::set< size_t > > m_isoVoxels;
/**
* Mesh decomposed into connected components
*/
boost::shared_ptr< std::list< boost::shared_ptr< WTriangleMesh > > > m_components;
/**
* Indicates a complete update of display and computed data (time consuming)
*/
boost::shared_ptr< WCondition > m_fullUpdate;
/**
* En/Disable the display of cluster volume voxels
*/
WPropBool m_drawIsoVoxels;
/**
* En/Disable the display of slices along center line
*/
WPropBool m_drawSlices;
/**
* The isovalue selecting the size of the cluster volume
*/
WPropDouble m_isoValue;
/**
* Selects the mean: 0 == arithmeticMean, 1 == geometricMean, 2 == median (default)
*/
WPropInt m_meanSelector;
/**
* how many sample points in first direction of the slice
*/
WPropInt m_planeNumX;
/**
* how many sample points in the second direction of the slice
*/
WPropInt m_planeNumY;
/**
* distance of the sample points on the slices
*/
WPropDouble m_planeStepWidth;
/**
* rescales the centerline for using more or less slices.
*/
WPropDouble m_centerLineScale;
/**
* If true, first the mesh is decomposed into its components (expensive!) & the biggest will be drawn
*/
WPropBool m_selectBiggestComponentOnly;
/**
* En/Disables alternative mesh coloring strategy
*/
WPropBool m_alternateColoring;
/**
* En/Disables custom color scaling
*/
WPropBool m_customScale;
/**
* A synthetic minMean value. All mean values below are mapped to 0
*/
WPropDouble m_minScale;
/**
* color used for minMean
*/
WPropColor m_minScaleColor;
/**
* A synthetic maxMean value. All mean value above are mapped to 1
*/
WPropDouble m_maxScale;
/**
* color used for maxMean
*/
WPropColor m_maxScaleColor;
/**
* maximum average (of sample points of a plane) parameter value over all planes
*/
double m_maxMean;
/**
* minimum average (of sample points of a plane) parameter value over all planes
*/
double m_minMean;
/**
* A cluster with its CenterLine
*/
boost::shared_ptr< WFiberCluster > m_cluster;
/**
* Dataset derived from a voxelized cluster
*/
boost::shared_ptr< WDataSetScalar > m_clusterDS;
/**
* Dataset derived from a voxelized cluster
*/
boost::shared_ptr< WDataSetScalar > m_paramDS;
/**
* stores all planes and their average parameters along centerLine
*/
boost::shared_ptr< std::vector< std::pair< double, WPlane > > > m_slices;
/**
* Reference to the TriangleMesh to make intersections
*/
boost::shared_ptr< WTriangleMesh > m_mesh;
/**
* Stores the color for vertices belonging to the intersection with the mesh and the planes
*/
boost::shared_ptr< WColoredVertices > m_colorMap;
/**
* Stores the JoinTree
*/
boost::shared_ptr< WJoinContourTree > m_joinTree;
/**
* Stores the voxels belonging to the cluster volume of a certain iso value
*/
boost::shared_ptr< std::set< size_t > > m_isoVoxels;
/**
* Mesh decomposed into connected components
*/
boost::shared_ptr< std::list< boost::shared_ptr< WTriangleMesh > > > m_components;
/**
* Indicates a complete update of display and computed data (time consuming)
*/
boost::shared_ptr< WCondition > m_fullUpdate;
/**
* En/Disable the display of cluster volume voxels
*/
WPropBool m_drawIsoVoxels;
/**
* En/Disable the display of slices along center line
*/
WPropBool m_drawSlices;
/**
* The isovalue selecting the size of the cluster volume
*/
WPropDouble m_isoValue;
/**
* Selects the mean: 0 == arithmeticMean, 1 == geometricMean, 2 == median (default)
*/
WPropInt m_meanSelector;
/**
* how many sample points in first direction of the slice
*/
WPropInt m_planeNumX;
/**
* how many sample points in the second direction of the slice
*/
WPropInt m_planeNumY;
/**
* distance of the sample points on the slices
*/
WPropDouble m_planeStepWidth;
/**
* rescales the centerline for using more or less slices.
*/
WPropDouble m_centerLineScale;
/**
* If true, first the mesh is decomposed into its components (expensive!) & the biggest will be drawn
*/
WPropBool m_selectBiggestComponentOnly;
/**
* En/Disables alternative mesh coloring strategy
*/
WPropBool m_alternateColoring;
/**
* En/Disables custom color scaling
*/
WPropBool m_customScale;
/**
* A synthetic minMean value. All mean values below are mapped to 0
*/
WPropDouble m_minScale;
/**
* color used for minMean
*/
WPropColor m_minScaleColor;
/**
* A synthetic maxMean value. All mean value above are mapped to 1
*/
WPropDouble m_maxScale;
/**
* color used for maxMean
*/
WPropColor m_maxScaleColor;
/**
* maximum average (of sample points of a plane) parameter value over all planes
*/
double m_maxMean;
/**
* minimum average (of sample points of a plane) parameter value over all planes
*/
double m_minMean;
private:
/**
......
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