Commit 7fe39bd8 authored by David Geistert's avatar David Geistert

[CHANGE] add debug code to simultaneously measure the time of the raw marching...

[CHANGE] add debug code to simultaneously measure the time of the raw marching cubes algorithm and the span space optimization
parent 301b0a92
......@@ -28,6 +28,7 @@
#include <algorithm>
#include <vector>
#include <map>
#include <sys/time.h>
#include <boost/tuple/tuple.hpp>
#include "boost/tuple/tuple_comparison.hpp"
......@@ -343,6 +344,10 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g
boost::shared_ptr< WSpanSpaceBase > spanSpace,
boost::shared_ptr< WProgressCombiner > mainProgress )
{
timeval timer1, timer2;
long millis;
double activeCells = 0, allCells;
WAssert( vals, "No value set provided." );
m_idToVertices.clear();
......@@ -358,31 +363,14 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g
// unsigned int nX = m_nCellsX + 1;
// unsigned int nY = m_nCellsY + 1;
// unsigned int nPointsInSlice = nX * nY;
boost::shared_ptr< WProgress > progress;
// Generate isosurface.
if( spanSpace )
{
// Span Space optimized
progress = boost::shared_ptr< WProgress >( new WProgress( "Marching Cubes" ) );
mainProgress->addSubProgress( progress );
boost::shared_ptr< WSpanSpace< T > > sstyped = boost::dynamic_pointer_cast< WSpanSpace< T > >( spanSpace );
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 );
}
}
else
{
progress = boost::shared_ptr< WProgress >( new WProgress( "Marching Cubes", m_nCellsZ ) );
mainProgress->addSubProgress( progress );
// calculate normal marching cubes algorithm
gettimeofday( &timer1, NULL );
for( unsigned int z = 0; z < m_nCellsZ; z++ )
{
++*progress;
......@@ -395,7 +383,26 @@ template<typename T> boost::shared_ptr<WTriangleMesh> WMarchingCubesAlgorithm::g
}
}
}
gettimeofday( &timer2, NULL );
millis = ( (timer2.tv_sec * 1000) + (timer2.tv_usec / 1000) ) - ( (timer1.tv_sec * 1000) + (timer1.tv_usec / 1000) );
wlog::info( "Time - MC" ) << millis;
// calculate marching cubes algorithm
gettimeofday( &timer1, NULL );
boost::shared_ptr< WSpanSpace< T > > sstyped = boost::dynamic_pointer_cast< WSpanSpace< T > >( spanSpace );
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 );
activeCells++;
}
gettimeofday( &timer2, NULL );
millis = ( (timer2.tv_sec * 1000) + (timer2.tv_usec / 1000) ) - ( (timer1.tv_sec * 1000) + (timer1.tv_usec / 1000) );
wlog::info( "Time - SS" ) << millis;
// debug - show how many cells are active
allCells = m_nCellsZ * m_nCellsY * m_nCellsX;
wlog::info( "Cells" ) << allCells << " - " << activeCells << " -> " << (activeCells / allCells ) * 100;
unsigned int nextID = 0;
boost::shared_ptr< WTriangleMesh > triMesh( new WTriangleMesh( m_idToVertices.size(), m_trivecTriangles.size() ) );
......
......@@ -29,6 +29,7 @@
#include <algorithm>
#include <utility>
#include <tr1/functional>
#include <sys/time.h>
#include "../../common/WLogger.h"
#include "../../common/WProgressCombiner.h"
......@@ -341,6 +342,8 @@ template< class T > boost::shared_ptr< WSpanSpaceBase::cellids_t > WSpanSpace<T>
template< class T > WSpanSpace<T>::WSpanSpace( size_t nbCoordsX, size_t nbCoordsY, size_t nbCoordsZ,
const std::vector< T >* vals, boost::shared_ptr< WProgressCombiner > mainProgress )
{
timeval timer1, timer2;
m_nCellsX = nbCoordsX - 1;
m_nCellsY = nbCoordsY - 1;
m_nCellsZ = nbCoordsZ - 1;
......@@ -365,7 +368,12 @@ template< class T > WSpanSpace<T>::WSpanSpace( size_t nbCoordsX, size_t nbCoords
progressSpan->finish();
WSpanSpaceKdTree< T > kdTree;
gettimeofday( &timer1, NULL );
m_kdTreeNode = kdTree.createTree( m_spanSpace, 0, 0, m_spanSpace.size() );
gettimeofday( &timer2, NULL );
long millis = ( (timer2.tv_sec * 1000) + (timer2.tv_usec / 1000) ) - ( (timer1.tv_sec * 1000) + (timer1.tv_usec / 1000) );
wlog::info( "build" ) << millis;
}
template< class T > void WSpanSpace<T>::searchKdTree( double isovalue,
......
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