Commit 4b539a5b authored by schurade's avatar schurade
Browse files

[ADD] function to get the value at a single voxel position

parent 8ad9168d
......@@ -27,10 +27,11 @@
#include <boost/shared_ptr.hpp>
#include "WDataSet.h"
#include "WGrid.h"
#include "WGridRegular3D.h"
#include "WValueSet.hpp"
class WValueSetBase;
class WGrid;
#include "WDataSet.h"
/**
* A data set consisting of a set of values based on a grid.
......@@ -60,6 +61,20 @@ public:
*/
boost::shared_ptr< WGrid > getGrid() const;
/**
*
*/
template < typename T > T getValueAt( int x, int y, int z )
{
boost::shared_ptr< WValueSet< T > > vs = boost::shared_dynamic_cast< WValueSet< T > >( m_valueSet );
boost::shared_ptr< WGridRegular3D > grid = boost::shared_dynamic_cast< WGridRegular3D >( m_grid );
size_t id = x + y * grid->getNbCoordsX() + z * grid->getNbCoordsX() * grid->getNbCoordsY();
T v = vs->getScalar( id );
return v;
}
private:
/**
* Stores the reference of the WGrid of this DataSetSingle instance.
......
......@@ -94,7 +94,6 @@ public:
return m_data[i];
}
/**
* Sometimes we need raw access to the data array, for e.g. OpenGL.
*/
......@@ -103,6 +102,7 @@ public:
return &m_data[0];
}
protected:
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