Commit a95f9b14 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

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

parent 9ca790f5
...@@ -176,10 +176,10 @@ private: ...@@ -176,10 +176,10 @@ private:
* \return ID of vertex with the given coordinates * \return ID of vertex with the given coordinates
*/ */
unsigned int getVertexID( unsigned int nX, unsigned int nY, unsigned int nZ ); unsigned int getVertexID( unsigned int nX, unsigned int nY, unsigned int nZ );
/** /**
* Calculate marching cubes algorithm * Calculate marching cubes algorithm
* *
* \param x number of vertices in X direction * \param x number of vertices in X direction
* \param y number of vertices in Y direction * \param y number of vertices in Y direction
* \param z number of vertices in Z direction * \param z number of vertices in Z direction
...@@ -351,11 +351,11 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g ...@@ -351,11 +351,11 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g
m_tIsoLevel = isoValue; m_tIsoLevel = isoValue;
unsigned int nX = m_nCellsX + 1; // unsigned int nX = m_nCellsX + 1;
unsigned int nY = m_nCellsY + 1; // unsigned int nY = m_nCellsY + 1;
unsigned int nPointsInSlice = nX * nY; // unsigned int nPointsInSlice = nX * nY;
boost::shared_ptr< WProgress > progress; boost::shared_ptr< WProgress > progress;
...@@ -369,7 +369,7 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g ...@@ -369,7 +369,7 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g
boost::shared_ptr< WSpanSpaceBase::cellids_t > cells = spanSpace->findCells( isoValue ); boost::shared_ptr< WSpanSpaceBase::cellids_t > cells = spanSpace->findCells( isoValue );
for( typename WSpanSpaceBase::cellids_t::const_iterator i = cells->begin(); i < cells->end(); ++i ) 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 else
......
...@@ -146,14 +146,14 @@ public: ...@@ -146,14 +146,14 @@ public:
private: private:
int m_depth; //!< depth of KdTree int m_depth; //!< depth of KdTree
/** /**
* Sort method for the nth_element function * Sort method for the nth_element function
* *
* \param i first cell which is compared to secound cell * \param i first cell which is compared to secound cell
* \param j secound cell which is compared to the first cell * \param j secound cell which is compared to the first cell
* *
* \return for even numbers true if the first cell has a smaller minimum isovalue and * \return for even numbers true if the first cell has a smaller minimum isovalue and
* for odd numbers true if the secound cell has a bigger maximum isovalue * for odd numbers true if the secound cell has a bigger maximum isovalue
*/ */
bool sortValues( cells_t i, cells_t j ); bool sortValues( cells_t i, cells_t j );
...@@ -196,7 +196,7 @@ template< class T > bool WSpanSpaceKdTree< T >::sortValues( cells_t i, cells_t j ...@@ -196,7 +196,7 @@ template< class T > bool WSpanSpaceKdTree< T >::sortValues( cells_t i, cells_t j
+-------> min = x = 1 +-------> min = x = 1
*/ */
if( m_depth % 2 == 1 ) // choos x or y axis if( m_depth % 2 == 1 ) // choos x or y axis
{ {
// for even numbers like (0, 2, 4) // for even numbers like (0, 2, 4)
// the function returns true if the first cell has a smaller minimum isovalue // the function returns true if the first cell has a smaller minimum isovalue
return ( i.m_minMax.m_min < j.m_minMax.m_min ); return ( i.m_minMax.m_min < j.m_minMax.m_min );
...@@ -241,7 +241,7 @@ public: ...@@ -241,7 +241,7 @@ public:
typedef MinMax< T > minmax_t; //!< minmax type used for KdCells typedef MinMax< T > minmax_t; //!< minmax type used for KdCells
typedef KdCells< T > cells_t; //!< the typ for KdCells typedef KdCells< T > cells_t; //!< the typ for KdCells
typedef std::vector< cells_t > kdCells_t; //!< vector of KdCells typedef std::vector< cells_t > kdCells_t; //!< vector of KdCells
/** /**
* Virtual function of SpanSpace algorithm * Virtual function of SpanSpace algorithm
* *
...@@ -256,7 +256,7 @@ public: ...@@ -256,7 +256,7 @@ public:
virtual ~WSpanSpace() virtual ~WSpanSpace()
{ {
} }
/** /**
* Find cells with given isovalue * Find cells with given isovalue
* *
...@@ -279,7 +279,7 @@ private: ...@@ -279,7 +279,7 @@ private:
* \return minMax isovalue * \return minMax isovalue
*/ */
minmax_t getCellMinMax( unsigned int coordX, unsigned int coordY, unsigned int coordZ ); minmax_t getCellMinMax( unsigned int coordX, unsigned int coordY, unsigned int coordZ );
/** /**
* Calculate the id of a cell * Calculate the id of a cell
* *
...@@ -330,14 +330,10 @@ private: ...@@ -330,14 +330,10 @@ private:
template< class T > boost::shared_ptr< WSpanSpaceBase::cellids_t > WSpanSpace<T>::findCells( double iso ) const 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 ); boost::shared_ptr< cellids_t > cellVector( new cellids_t );
T isoValue = static_cast< T >( iso ); T isoValue = static_cast< T >( iso );
// fill cellVec with content // fill cellVec with content
searchKdTree( isoValue, *cellVector ); searchKdTree( isoValue, *cellVector );
wlog::debug( "sleep" );
sleep( 20 );
wlog::debug( "WSpanSpace" ) << "active cells:" << cellVector->size(); wlog::debug( "WSpanSpace" ) << "active cells:" << cellVector->size();
return cellVector; return cellVector;
} }
......
...@@ -47,13 +47,14 @@ ...@@ -47,13 +47,14 @@
#include "core/common/WProgress.h" #include "core/common/WProgress.h"
#include "core/dataHandler/WDataHandler.h" #include "core/dataHandler/WDataHandler.h"
#include "core/dataHandler/WSubject.h" #include "core/dataHandler/WSubject.h"
#include "core/graphicsEngine/algorithms/WSpanSpace.h" #include "core/common/algorithms/WSpanSpace.h"
#include "core/graphicsEngine/algorithms/WMarchingCubesAlgorithm.h" #include "core/common/algorithms/WMarchingCubesAlgorithm.h"
#include "core/graphicsEngine/algorithms/WMarchingLegoAlgorithm.h" // #include "core/common/algorithms/WMarchingLegoAlgorithm.h"
#include "core/graphicsEngine/callbacks/WGEFunctorCallback.h" #include "core/graphicsEngine/callbacks/WGEFunctorCallback.h"
#include "core/graphicsEngine/shaders/WGEPropertyUniform.h" #include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h" #include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefine.h" #include "core/graphicsEngine/shaders/WGEShaderPropertyDefine.h"
#include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
#include "core/graphicsEngine/WGEColormapping.h" #include "core/graphicsEngine/WGEColormapping.h"
#include "core/graphicsEngine/WGEUtils.h" #include "core/graphicsEngine/WGEUtils.h"
#include "core/kernel/WKernel.h" #include "core/kernel/WKernel.h"
...@@ -102,7 +103,7 @@ const std::string WMIsosurface::getName() const ...@@ -102,7 +103,7 @@ const std::string WMIsosurface::getName() const
const std::string WMIsosurface::getDescription() const const std::string WMIsosurface::getDescription() const
{ {
return "This module implements the marching cubes" 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" " for a given isovalue on data given on a grid only consisting of cubes. It yields"
" the surface as triangle soup."; " the surface as triangle soup.";
} }
...@@ -127,7 +128,7 @@ public: ...@@ -127,7 +128,7 @@ public:
m_progress( mainProgress ) m_progress( mainProgress )
{ {
} }
/** /**
* Initial spanSpace algorith * Initial spanSpace algorith
* *
...@@ -154,10 +155,30 @@ void WMIsosurface::moduleMain() ...@@ -154,10 +155,30 @@ void WMIsosurface::moduleMain()
m_moduleState.add( m_input->getDataChangedCondition() ); m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_recompute ); 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 // signal ready state
ready(); 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 = 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 // loop until the module container requests the module to quit
while( !m_shutdownFlag() ) while( !m_shutdownFlag() )
...@@ -230,14 +251,14 @@ void WMIsosurface::moduleMain() ...@@ -230,14 +251,14 @@ void WMIsosurface::moduleMain()
++*progress; ++*progress;
debugLog() << "Rendering surface ..."; debugLog() << "Rendering surface ...";
//renderMesh(); renderMesh();
m_output->updateData( m_triMesh ); m_output->updateData( m_triMesh );
debugLog() << "Done!"; debugLog() << "Done!";
progress->finish(); progress->finish();
} }
WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getScene()->remove( m_moduleNode ); WKernel::getRunningKernel()->getGraphicsEngine()->getViewer()->getScene()->remove( postNode );
} }
void WMIsosurface::connectors() void WMIsosurface::connectors()
...@@ -341,7 +362,7 @@ namespace ...@@ -341,7 +362,7 @@ namespace
boost::shared_ptr<WProgressCombiner> progress ) boost::shared_ptr<WProgressCombiner> progress )
{ {
boost::shared_ptr< WValueSet< T > > vals( 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." ); WAssert( vals, "Data type and data type indicator must fit." );
return AlgoBase::generateSurface( x, y, z, matrix, vals->rawDataVectorPointer(), isoValue, spanSpace, progress ); return AlgoBase::generateSurface( x, y, z, matrix, vals->rawDataVectorPointer(), isoValue, spanSpace, progress );
} }
...@@ -394,14 +415,17 @@ void WMIsosurface::generateSurfacePre( double isoValue ) ...@@ -394,14 +415,17 @@ void WMIsosurface::generateSurfacePre( double isoValue )
WAssert( ( *m_dataSet ).getValueSet()->order() == 0, "This module only works on scalars." ); WAssert( ( *m_dataSet ).getValueSet()->order() == 0, "This module only works on scalars." );
WMarchingCubesAlgorithm mcAlgo; 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< WValueSetBase > valueSet( m_dataSet->getValueSet() );
boost::shared_ptr<MCBase> algo; boost::shared_ptr<MCBase> algo;
if( m_useMarchingLego->get( true ) ) if( m_useMarchingLego->get( true ) )
{ {
algo = createAlgo<WMarchingLegoAlgorithm>( valueSet->getDataType() ); // algo = createAlgo<WMarchingLegoAlgorithm>( valueSet->getDataType() );
} }
else else
{ {
...@@ -415,7 +439,6 @@ void WMIsosurface::generateSurfacePre( double isoValue ) ...@@ -415,7 +439,6 @@ void WMIsosurface::generateSurfacePre( double isoValue )
valueSet, valueSet,
isoValue, m_spanSpace, m_progress ); isoValue, m_spanSpace, m_progress );
// Set the info properties // Set the info properties
m_nbTriangles->set( m_triMesh->triangleSize() ); m_nbTriangles->set( m_triMesh->triangleSize() );
m_nbVertices->set( m_triMesh->vertSize() ); m_nbVertices->set( m_triMesh->vertSize() );
...@@ -443,6 +466,7 @@ void WMIsosurface::renderMesh() ...@@ -443,6 +466,7 @@ void WMIsosurface::renderMesh()
osg::ref_ptr< osg::DrawElementsUInt > surfaceElement( new osg::DrawElementsUInt( osg::PrimitiveSet::TRIANGLES, 0 ) ); osg::ref_ptr< osg::DrawElementsUInt > surfaceElement( new osg::DrawElementsUInt( osg::PrimitiveSet::TRIANGLES, 0 ) );
std::vector< size_t > tris = m_triMesh->getTriangles(); std::vector< size_t > tris = m_triMesh->getTriangles();
debugLog() << "Hallo " << tris.size();
surfaceElement->reserve( tris.size() ); surfaceElement->reserve( tris.size() );
for( unsigned int vertId = 0; vertId < tris.size(); ++vertId ) for( unsigned int vertId = 0; vertId < tris.size(); ++vertId )
...@@ -487,26 +511,15 @@ void WMIsosurface::renderMesh() ...@@ -487,26 +511,15 @@ void WMIsosurface::renderMesh()
surfaceGeometry->setUseDisplayList( false ); surfaceGeometry->setUseDisplayList( false );
surfaceGeometry->setUseVertexBufferObjects( true ); surfaceGeometry->setUseVertexBufferObjects( true );
// ------------------------------------------------ m_shader->apply( m_surfaceGeode );
// Shader stuff
osg::ref_ptr< WGEShader > shader = osg::ref_ptr< WGEShader >( new WGEShader( "WMIsosurface", m_localPath ) ); // enable transparency
shader->addPreprocessor( WGEShaderPreprocessor::SPtr( wge::enableTransparency( m_surfaceGeode );
new WGEShaderPropertyDefineOptions< WPropBool >( m_useTextureProp, "COLORMAPPING_DISABLED", "COLORMAPPING_ENABLED" ) )
);
state->addUniform( new WGEPropertyUniform< WPropInt >( "u_opacity", m_opacityProp ) );
shader->apply( m_surfaceGeode );
// Colormapping // Colormapping
WGEColormapping::apply( m_surfaceGeode, shader ); WGEColormapping::apply( m_surfaceGeode, m_shader );
m_moduleNode->insert( m_surfaceGeode ); 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 ) ) ); m_moduleNode->addUpdateCallback( new WGEFunctorCallback< osg::Node >( boost::bind( &WMIsosurface::updateGraphicsCallback, this ) ) );
} }
......
...@@ -160,6 +160,11 @@ private: ...@@ -160,6 +160,11 @@ private:
osg::ref_ptr< osg::Geode > m_surfaceGeode; //!< Pointer to geode containing the surface. osg::ref_ptr< osg::Geode > m_surfaceGeode; //!< Pointer to geode containing the surface.
boost::shared_ptr< WSpanSpaceBase > m_spanSpace; //!< Pointer to span space algorithm. boost::shared_ptr< WSpanSpaceBase > m_spanSpace; //!< Pointer to span space algorithm.
/**
* The shader
*/
osg::ref_ptr< WGEShader > m_shader;
}; };
#endif // WMISOSURFACE_H #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