Commit 09ca7b89 authored by Mario Hlawitschka's avatar Mario Hlawitschka
Browse files

[CHANGE] removed code that is no longer needed that referred to the old way...

[CHANGE] removed code that is no longer needed that referred to the old way transfer functions are handled and did not work anymore due to the new transfer function infrastructure.
parent 2f0f6fd4
......@@ -50,44 +50,44 @@
#include "WMDirectVolumeRendering.xpm"
#include "WMDirectVolumeRendering.h"
// This line is needed by the module loader to actually find your module.
W_LOADABLE_MODULE( WMDirectVolumeRendering )
// This line is needed by the module loader to actually find your module.
W_LOADABLE_MODULE( WMDirectVolumeRendering )
WMDirectVolumeRendering::WMDirectVolumeRendering():
WMDirectVolumeRendering::WMDirectVolumeRendering():
WModule()
{
{
// Initialize members
}
}
WMDirectVolumeRendering::~WMDirectVolumeRendering()
{
WMDirectVolumeRendering::~WMDirectVolumeRendering()
{
// Cleanup!
}
}
boost::shared_ptr< WModule > WMDirectVolumeRendering::factory() const
{
boost::shared_ptr< WModule > WMDirectVolumeRendering::factory() const
{
return boost::shared_ptr< WModule >( new WMDirectVolumeRendering() );
}
}
const char** WMDirectVolumeRendering::getXPMIcon() const
{
const char** WMDirectVolumeRendering::getXPMIcon() const
{
return WMDirectVolumeRendering_xpm;
}
}
const std::string WMDirectVolumeRendering::getName() const
{
const std::string WMDirectVolumeRendering::getName() const
{
// Specify your module name here. This name must be UNIQUE!
return "Direct Volume Rendering";
}
}
const std::string WMDirectVolumeRendering::getDescription() const
{
const std::string WMDirectVolumeRendering::getDescription() const
{
// Specify your module description here. Be detailed. This text is read by the user.
return "Direct volume rendering of regular volumetric data.";
}
}
void WMDirectVolumeRendering::connectors()
{
void WMDirectVolumeRendering::connectors()
{
// The transfer function for our DVR
m_transferFunction = WModuleInputData< WDataSetSingle >::createAndAdd( shared_from_this(), "transfer function", "The 1D transfer function." );
......@@ -100,15 +100,13 @@
// call WModules initialization
WModule::connectors();
}
}
void WMDirectVolumeRendering::properties()
{
void WMDirectVolumeRendering::properties()
{
// Initialize the properties
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_samples = m_properties->addProperty( "Sample count", "The number of samples to walk along the ray during raycasting. A low value "
"may cause artifacts whilst a high value slows down rendering.", 256 );
m_samples->setMin( 1 );
......@@ -124,17 +122,10 @@
WPropertyHelper::PC_SELECTONLYONE::addTo( m_localIlluminationAlgo );
WPropertyHelper::PC_NOTEMPTY::addTo( m_localIlluminationAlgo );
// transfer functions
m_tfLoaderGroup = m_properties->addPropertyGroup( "Transfer function", "Transfer function loading." );
m_tfLoaderEnabled = m_tfLoaderGroup->addProperty( "Enable", "Enable TF loading from file.", false, m_propCondition );
m_tfLoaderFile = m_tfLoaderGroup->addProperty( "File", "The 1D image containing the transfer function.",
WPathHelper::getAppPath(), m_propCondition );
WPropertyHelper::PC_PATHEXISTS::addTo( m_tfLoaderFile );
m_tfLoaderTrigger = m_tfLoaderGroup->addProperty( "Load", "Triggers loading.", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
// additional artifact removal methods
m_improvementGroup = m_properties->addPropertyGroup( "Improvements", "Methods for improving image quality. Most of these methods imply "
"additional calculation/texture overhead and therefore slow down rendering." );
m_stochasticJitterEnabled = m_improvementGroup->addProperty( "Stochastic jitter", "With stochastic jitter, wood-grain artifacts can be "
"removed with the cost of possible noise artifacts.", true,
m_propCondition );
......@@ -143,30 +134,30 @@
"sample count. If disabled, changing the sample count "
"varies brightness of the image.", true,
m_propCondition );
m_maximumIntensityProjectionEnabled = m_improvementGroup->addProperty( "MIP", "If enabled, MIP is used.", true,
m_propCondition );
m_depthProjectionEnabled = m_improvementGroup->addProperty( "Depth Projection", "If enabled, depth projection mode is used", true,
m_maximumIntensityProjectionEnabled = m_improvementGroup->addProperty( "MIP", "If enabled, MIP is used.", false,
m_propCondition );
m_depthProjectionEnabled = m_improvementGroup->addProperty( "Depth Projection", "If enabled, depth projection mode is used", false,
m_propCondition );
WModule::properties();
}
}
void WMDirectVolumeRendering::requirements()
{
void WMDirectVolumeRendering::requirements()
{
m_requirements.push_back( new WGERequirement() );
}
}
/**
/**
* Generates a white noise texture with given resolution.
*
* \param resX the resolution
*
* \return a image with resX*resX resolution.
*/
osg::ref_ptr< osg::Image > genWhiteNoise( size_t resX )
{
osg::ref_ptr< osg::Image > genWhiteNoise( size_t resX )
{
std::srand( time( 0 ) );
osg::ref_ptr< osg::Image > randImage = new osg::Image();
......@@ -183,54 +174,10 @@
}
return randImage;
}
/**
* Example TF generator. This will be extended with some strategy-pattern later.
*
* \return TF as image.
*/
osg::ref_ptr< osg::Image > genTF()
{
const size_t resX = 256;
osg::ref_ptr< osg::Image > tfImage = new osg::Image();
tfImage->allocateImage( resX, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE );
unsigned char *tf = tfImage->data();
for( size_t x = 0; x < resX; ++x )
{
if( x > 127 )
{
double i = ( static_cast< double >( x - 128 ) / 128.0 ) * 2.0 * 15.0;
size_t imod = fmod( i, 2 );
std::cout << imod << std::endl;
if( imod == 0 )
{
tf[ 4 * x + 0 ] = 255;
tf[ 4 * x + 1 ] = 86;
tf[ 4 * x + 2 ] = 86;
tf[ 4 * x + 3 ] = 127;
}
else
{
tf[ 4 * x + 0 ] = 255;
tf[ 4 * x + 1 ] = 191;
tf[ 4 * x + 2 ] = 0;
tf[ 4 * x + 3 ] = 64;
}
}
if( x <= 127 )
{
tf[ 4 * x + 0 ] = 0;
tf[ 4 * x + 1 ] = 94;
tf[ 4 * x + 2 ] = 255;
tf[ 4 * x + 3 ] = 2 * ( 127 - x );
}
}
return tfImage;
}
}
void WMDirectVolumeRendering::moduleMain()
{
void WMDirectVolumeRendering::moduleMain()
{
m_shader = osg::ref_ptr< WGEShader > ( new WGEShader( "WMDirectVolumeRendering", m_localPath ) );
// setup all the defines needed
......@@ -295,8 +242,7 @@
bool dataUpdated = m_input->updated() || m_gradients->updated();
boost::shared_ptr< WDataSetScalar > dataSet = m_input->getData();
bool dataValid = ( dataSet );
bool propUpdated = m_localIlluminationAlgo->changed() || m_tfLoaderEnabled || m_tfLoaderFile->changed() || m_tfLoaderTrigger->changed() ||
m_stochasticJitterEnabled->changed() || m_opacityCorrectionEnabled->changed() ||
bool propUpdated = m_localIlluminationAlgo->changed() || m_stochasticJitterEnabled->changed() || m_opacityCorrectionEnabled->changed() ||
m_maximumIntensityProjectionEnabled->changed() || m_depthProjectionEnabled->changed();
......@@ -420,28 +366,6 @@
}
debugLog() << "end updated transfer function";
}
// // Disabled for debugging transfer function code. (mario)
// // try to load the tf from file if existent
// tfTexEnableDefine->setActive( false );
// if( m_tfLoaderEnabled->get( true ) )
// {
// osg::ref_ptr< osg::Image > tfImg = osgDB::readImageFile( m_tfLoaderFile->get( true ).file_string() );
// if( tfImg )
// {
// // bind it as a texture
// osg::ref_ptr< osg::Texture1D > tfTexture = new osg::Texture1D();
// tfTexture->setImage( tfImg );
// // apply it
// wge::bindTexture( cube, tfTexture, 2, "u_transferFunction" );
// tfTexEnableDefine->setActive( true ); // enable it
// }
// else
// {
// warnLog() << "Transfer function texture could not be loaded from " << m_tfLoaderFile->get( true ).file_string() << ".";
// }
// m_tfLoaderTrigger->get( true );
// }
////////////////////////////////////////////////////////////////////////////////////////////////////
// stochastic jittering texture
......@@ -502,8 +426,6 @@
depthProjectionEnabledDefine->setActive( false );
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// setup all those uniforms
////////////////////////////////////////////////////////////////////////////////////////////////////
......@@ -524,9 +446,6 @@
rootInserted = true;
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( rootNode );
}
// finally, reset the load trigger
m_tfLoaderTrigger->set( WPVBaseTypes::PV_TRIGGER_READY );
}
}
......
......@@ -141,26 +141,6 @@ private:
*/
WPropSelection m_localIlluminationAlgo;
/**
* The group containing the tf loader path and trigger.
*/
WPropGroup m_tfLoaderGroup;
/**
* If true, the texture is used for transfer functions.
*/
WPropBool m_tfLoaderEnabled;
/**
* The path to the file to load.
*/
WPropFilename m_tfLoaderFile;
/**
* Triggered to actually do loading
*/
WPropTrigger m_tfLoaderTrigger;
/**
* All properties for those nice improvement methods.
*/
......
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