Commit 12a20b2d authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents e2a4b31d 764e1087
......@@ -145,3 +145,8 @@ wmath::WVector3D WDataSetVector::getVectorAt( size_t index ) const
return wmath::WVector3D( 0, 0, 0 );
}
bool WDataSetVector::isTexture() const
{
return false;
}
......@@ -81,6 +81,13 @@ public:
*/
wmath::WVector3D getVectorAt( size_t index ) const;
/**
* Determines whether this dataset can be used as a texture.
*
* \return true if usable as texture.
*/
virtual bool isTexture() const;
/**
* Overwrites the isVectorDataSet check.
*
......
......@@ -83,23 +83,33 @@ wmath::WMatrix< double > WLoaderNIfTI::convertMatrix( const mat44& in )
boost::shared_ptr< WDataSet > WLoaderNIfTI::load()
{
nifti_image* header = nifti_image_read( m_fileName.c_str(), 0 );
WAssert( header, "Error during file access to NIfTI file. This probably means that the file is corrupted." );
WAssert( header->ndim >= 3,
"The NIfTI file contains data that has less than the three spatial dimension. OpenWalnut is not able to handle this." );
int columns = header->dim[1];
int rows = header->dim[2];
int frames = header->dim[3];
boost::shared_ptr< WValueSetBase > newValueSet;
boost::shared_ptr<WGrid> newGrid;
boost::shared_ptr< WGrid > newGrid;
nifti_image* filedata = nifti_image_read( m_fileName.c_str(), 1 );
unsigned int vDim = header->dim[4];
unsigned int vDim;
if( header->ndim >= 4 )
{
vDim = header->dim[4];
}
else
{
vDim = 1;
}
unsigned int order = ( ( vDim == 1 ) ? 0 : 1 ); // TODO(all): Does recognize vectors and scalars only so far.
unsigned int countVoxels = columns * rows * frames;
#ifdef DEBUG
//nifti_image_infodump( header );
#endif
switch( header->datatype )
{
case DT_UNSIGNED_CHAR:
......
......@@ -26,8 +26,6 @@
#include <osg/Array>
#include <GL/glu.h>
#include "../common/math/WPosition.h"
#include "WGEUtils.h"
......@@ -45,30 +43,5 @@ osg::ref_ptr< osg::Vec3Array > wge::osgVec3Array( const std::vector< wmath::WPos
osg::Vec3 wge::unprojectFromScreen( const osg::Vec3 screen, osg::ref_ptr< osg::Camera > camera )
{
double* modelView;
double* projection;
double dviewport[4];
modelView = camera->getViewMatrix().ptr();
projection = camera->getProjectionMatrix().ptr();
dviewport[0] = camera->getViewport()->x();
dviewport[1] = camera->getViewport()->y();
dviewport[2] = camera->getViewport()->width();
dviewport[3] = camera->getViewport()->height();
double x, y, z;
GLint viewport[4];
viewport[0] = static_cast< GLint >( dviewport[0] );
viewport[1] = static_cast< GLint >( dviewport[1] );
viewport[2] = static_cast< GLint >( dviewport[2] );
viewport[3] = static_cast< GLint >( dviewport[3] );
gluUnProject( screen[0], screen[1], screen[2], modelView, projection, viewport, &x, &y, &z );
osg::Vec3 world;
world[0] = x;
world[1] = y;
world[2] = z;
return world;
return screen * osg::Matrix::inverse( camera->getViewMatrix() * camera->getProjectionMatrix() * camera->getViewport()->computeWindowMatrix() );
}
......@@ -293,7 +293,7 @@ void WMainWindow::moduleSpecificSetup( boost::shared_ptr< WModule > module )
boost::shared_ptr< WMData > dataModule = boost::shared_static_cast< WMData >( module );
// grab data and identify type
if ( dataModule->getDataSet()->isA< WDataSetSingle >() )
if ( dataModule->getDataSet()->isA< WDataSetSingle >() && dataModule->getDataSet()->isTexture() )
{
// it is a dataset single
// load a nav slice module if a WDataSetSingle is available!?
......
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