Commit a95f9b14 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] patched latest changes in. Now compiles and shows _something_

parent 9ca790f5
......@@ -351,11 +351,11 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g
m_tIsoLevel = isoValue;
unsigned int nX = m_nCellsX + 1;
unsigned int nY = m_nCellsY + 1;
// unsigned int nX = m_nCellsX + 1;
// unsigned int nY = m_nCellsY + 1;
unsigned int nPointsInSlice = nX * nY;
// unsigned int nPointsInSlice = nX * nY;
boost::shared_ptr< WProgress > progress;
......@@ -369,7 +369,7 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g
boost::shared_ptr< WSpanSpaceBase::cellids_t > cells = spanSpace->findCells( isoValue );
for( typename WSpanSpaceBase::cellids_t::const_iterator i = cells->begin(); i < cells->end(); ++i )
{
//calculateMarchingCube( ( *i )->m_x, ( *i )->m_y, ( *i )->m_z, vals );
calculateMarchingCube( ( *i )->m_x, ( *i )->m_y, ( *i )->m_z, vals );
}
}
else
......
......@@ -330,14 +330,10 @@ private:
template< class T > boost::shared_ptr< WSpanSpaceBase::cellids_t > WSpanSpace<T>::findCells( double iso ) const
{
wlog::debug( "sleep" );
sleep( 20 );
boost::shared_ptr< cellids_t > cellVector( new cellids_t );
T isoValue = static_cast< T >( iso );
// fill cellVec with content
searchKdTree( isoValue, *cellVector );
wlog::debug( "sleep" );
sleep( 20 );
wlog::debug( "WSpanSpace" ) << "active cells:" << cellVector->size();
return cellVector;
}
......
......@@ -47,13 +47,14 @@
#include "core/common/WProgress.h"
#include "core/dataHandler/WDataHandler.h"
#include "core/dataHandler/WSubject.h"
#include "core/graphicsEngine/algorithms/WSpanSpace.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h"
#include "core/graphicsEngine/algorithms/WMarchingLegoAlgorithm.h"
#include "core/common/algorithms/WSpanSpace.h"
#include "core/common/algorithms/WMarchingCubesAlgorithm.h"
// #include "core/common/algorithms/WMarchingLegoAlgorithm.h"
#include "core/graphicsEngine/callbacks/WGEFunctorCallback.h"
#include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefine.h"
#include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
#include "core/graphicsEngine/WGEColormapping.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/kernel/WKernel.h"
......@@ -102,7 +103,7 @@ const std::string WMIsosurface::getName() const
const std::string WMIsosurface::getDescription() const
{
return "This module implements the marching cubes"
" algorithm with a consistent triangulation. It allows to compute isosurfaces"
" algorithm with a consistent triangulation. It allows one to compute isosurfaces"
" for a given isovalue on data given on a grid only consisting of cubes. It yields"
" the surface as triangle soup.";
}
......@@ -154,10 +155,30 @@ void WMIsosurface::moduleMain()
m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_recompute );
// create the post-processing node which actually does the nice stuff to the rendered image
osg::ref_ptr< WGEPostprocessingNode > postNode = new WGEPostprocessingNode(
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getCamera()
);
// provide the properties of the post-processor to the user
m_properties->addProperty( postNode->getProperties() );
// add to scene
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( postNode );
// signal ready state
ready();
// create shader
m_shader = osg::ref_ptr< WGEShader >( new WGEShader( "WMIsosurface", m_localPath ) );
m_shader->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_useTextureProp, "COLORMAPPING_DISABLED", "COLORMAPPING_ENABLED" ) )
);
m_moduleNode = new WGEManagedGroupNode( m_active );
m_moduleNode->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropInt >( "u_opacity", m_opacityProp ) );
// add it to postproc node and register shader
postNode->insert( m_moduleNode, m_shader );
// loop until the module container requests the module to quit
while( !m_shutdownFlag() )
......@@ -230,14 +251,14 @@ void WMIsosurface::moduleMain()
++*progress;
debugLog() << "Rendering surface ...";
//renderMesh();
renderMesh();
m_output->updateData( m_triMesh );
debugLog() << "Done!";
progress->finish();
}
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getScene()->remove( m_moduleNode );
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getScene()->remove( postNode );
}
void WMIsosurface::connectors()
......@@ -341,7 +362,7 @@ namespace
boost::shared_ptr<WProgressCombiner> progress )
{
boost::shared_ptr< WValueSet< T > > vals(
boost::shared_dynamic_cast< WValueSet< T > >( valueSet ) );
boost::dynamic_pointer_cast< WValueSet< T > >( valueSet ) );
WAssert( vals, "Data type and data type indicator must fit." );
return AlgoBase::generateSurface( x, y, z, matrix, vals->rawDataVectorPointer(), isoValue, spanSpace, progress );
}
......@@ -394,14 +415,17 @@ void WMIsosurface::generateSurfacePre( double isoValue )
WAssert( ( *m_dataSet ).getValueSet()->order() == 0, "This module only works on scalars." );
WMarchingCubesAlgorithm mcAlgo;
WMarchingLegoAlgorithm mlAlgo;
// WMarchingLegoAlgorithm mlAlgo;
boost::shared_ptr< WGridRegular3D > gridRegular3D = boost::dynamic_pointer_cast< WGridRegular3D >( ( *m_dataSet ).getGrid() );
WAssert( gridRegular3D, "Grid is not of type WGridRegular3D." );
m_grid = gridRegular3D;
boost::shared_ptr< WValueSetBase > valueSet( m_dataSet->getValueSet() );
boost::shared_ptr<MCBase> algo;
if( m_useMarchingLego->get( true ) )
{
algo = createAlgo<WMarchingLegoAlgorithm>( valueSet->getDataType() );
// algo = createAlgo<WMarchingLegoAlgorithm>( valueSet->getDataType() );
}
else
{
......@@ -415,7 +439,6 @@ void WMIsosurface::generateSurfacePre( double isoValue )
valueSet,
isoValue, m_spanSpace, m_progress );
// Set the info properties
m_nbTriangles->set( m_triMesh->triangleSize() );
m_nbVertices->set( m_triMesh->vertSize() );
......@@ -443,6 +466,7 @@ void WMIsosurface::renderMesh()
osg::ref_ptr< osg::DrawElementsUInt > surfaceElement( new osg::DrawElementsUInt( osg::PrimitiveSet::TRIANGLES, 0 ) );
std::vector< size_t > tris = m_triMesh->getTriangles();
debugLog() << "Hallo " << tris.size();
surfaceElement->reserve( tris.size() );
for( unsigned int vertId = 0; vertId < tris.size(); ++vertId )
......@@ -487,26 +511,15 @@ void WMIsosurface::renderMesh()
surfaceGeometry->setUseDisplayList( false );
surfaceGeometry->setUseVertexBufferObjects( true );
// ------------------------------------------------
// Shader stuff
m_shader->apply( m_surfaceGeode );
osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >( new WGEShader( "WMIsosurface", m_localPath ) );
shader->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_useTextureProp, "COLORMAPPING_DISABLED", "COLORMAPPING_ENABLED" ) )
);
state->addUniform( new WGEPropertyUniform< WPropInt >( "u_opacity", m_opacityProp ) );
shader->apply( m_surfaceGeode );
// enable transparency
wge::enableTransparency( m_surfaceGeode );
// Colormapping
WGEColormapping::apply( m_surfaceGeode, shader );
WGEColormapping::apply( m_surfaceGeode, m_shader );
m_moduleNode->insert( m_surfaceGeode );
if( !m_moduleNodeInserted )
{
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_moduleNode );
m_moduleNodeInserted = true;
}
m_moduleNode->addUpdateCallback( new WGEFunctorCallback< osg::Node >( boost::bind( &WMIsosurface::updateGraphicsCallback, this ) ) );
}
......
......@@ -160,6 +160,11 @@ private:
osg::ref_ptr< osg::Geode > m_surfaceGeode; //!< Pointer to geode containing the surface.
boost::shared_ptr< WSpanSpaceBase > m_spanSpace; //!< Pointer to span space algorithm.
/**
* The shader
*/
osg::ref_ptr< WGEShader > m_shader;
};
#endif // WMISOSURFACE_H
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