Commit 5da4f83d authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[MERGE]

parents 9936f96a c4ac1d03
......@@ -77,32 +77,31 @@ void WMainWindow::setupGUI( boost::program_options::variables_map guiConfigurati
m_mainGLWidget->initialize();
setCentralWidget( m_mainGLWidget.get() );
// initially 3 views
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "axial", this, 160, "axialPos" ) );
addDockWidget( Qt::LeftDockWidgetArea, m_navAxial.get() );
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "coronal", this, 200, "coronalPos" ) );
addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal.get() );
m_navSagittal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "sagittal", this, 160, "sagittalPos" ) );
addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal.get() );
connect( m_navAxial.get(), SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
connect( m_navCoronal.get(), SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
connect( m_navSagittal.get(), SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
if( guiConfiguration.count( "ge.bgColor.r" ) && guiConfiguration.count( "ge.bgColor.g" ) && guiConfiguration.count( "ge.bgColor.b" ) )
{
WColor bgColor( guiConfiguration["ge.bgColor.r"].as< float >(),
guiConfiguration["ge.bgColor.g"].as< float >(),
guiConfiguration["ge.bgColor.b"].as< float >() );
m_mainGLWidget->setBgColor( bgColor );
m_navAxial->getGLWidget()->setBgColor( bgColor );
m_navCoronal->getGLWidget()->setBgColor( bgColor );
m_navSagittal->getGLWidget()->setBgColor( bgColor );
}
//TODO(all): this is commented out
// initially 3 views
// m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "axial", 160, "axialPos" ) );
//m_navAxial->getGLWidget()->initialize();
//addDockWidget( Qt::LeftDockWidgetArea, m_navAxial.get() );
//m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "coronal", 200, "coronalPos" ) );
//m_navCoronal->getGLWidget()->initialize();
//addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal.get() );
//m_navSagittal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "sagittal", 160, "sagittalPos" ) );
//m_navSagittal->getGLWidget()->initialize();
//addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal.get() );
//connect( m_navAxial.get(), SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
//connect( m_navCoronal.get(), SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
//connect( m_navSagittal.get(), SIGNAL( navSliderValueChanged( QString, int ) ), &m_propertyManager, SLOT( slotIntChanged( QString, int ) ) );
m_datasetBrowser = new WQtDatasetBrowser();
addDockWidget( Qt::RightDockWidgetArea, m_datasetBrowser );
m_datasetBrowser->addSubject( "subject1" );
......@@ -235,10 +234,9 @@ void WMainWindow::closeEvent( QCloseEvent* e )
// clean up gl widgets
m_mainGLWidget->close();
//TODO(all): this is commented out
//m_navAxial->close();
//m_navCoronal->close();
//m_navSagittal->close();
m_navAxial->close();
m_navCoronal->close();
m_navSagittal->close();
// finally close
e->accept();
......
......@@ -32,8 +32,8 @@
#include "WQtNavGLWidget.h"
WQtNavGLWidget::WQtNavGLWidget( QString title, int maxValue, std::string sliderTitle )
: QDockWidget( title )
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, int maxValue, std::string sliderTitle )
: QDockWidget( title, parent )
{
m_sliderTitle = QString( sliderTitle.c_str() );
......@@ -47,7 +47,8 @@ WQtNavGLWidget::WQtNavGLWidget( QString title, int maxValue, std::string sliderT
QVBoxLayout* layout = new QVBoxLayout();
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString() , panel, WGECamera::ORTHOGRAPHIC ) );
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString(), panel, WGECamera::ORTHOGRAPHIC ) );
m_glWidget->initialize();
layout->addWidget( m_glWidget.get() );
layout->addWidget( slider );
......
......@@ -40,8 +40,10 @@ class WQtNavGLWidget : public QDockWidget
public:
/**
* default constructor
*
* \param parent the parent widget.
*/
explicit WQtNavGLWidget( QString title, int maxValue = 100, std::string sliderTitle="pos" );
explicit WQtNavGLWidget( QString title, QWidget* parent, int maxValue = 100, std::string sliderTitle="pos" );
/**
* destructor
......
......@@ -93,8 +93,16 @@ private:
/**
* Function to create a distance map from Anatomy data set.
* Take from FiberNavigator.
* \param dataSet the data set that is used to compute the distance field.
* The distance is computed to the boundary between foreground an background
*/
boost::shared_ptr< WValueSet< float > > createOffset( boost::shared_ptr< const WDataSetSingle > dataSet );
/**
* Gauss function.
* \param x position of evaluation
* \param sigma standard deviation
*/
double xxgauss( double x, double sigma );
};
......
......@@ -38,17 +38,25 @@
#include "../../dataHandler/WGridRegular3D.h"
#include "WTriangleMesh.h"
/**
* A point consisting of its coordinates and ID
*/
struct WPointXYZId
{
unsigned int newID;
double x, y, z;
unsigned int newID; //!< ID of the point
double x; //!< x coordinates of the point.
double y; //!< y coordinates of the point.
double z; //!< z coordinates of the point.
};
typedef std::map< unsigned int, WPointXYZId > ID2WPointXYZId;
/**
* Encapsulated ids representing a triangle.
*/
struct WMCTriangle
{
unsigned int pointID[3];
unsigned int pointID[3]; //!< The IDs of the vertices of the triangle.
};
typedef std::vector<WMCTriangle> WMCTriangleVECTOR;
......@@ -118,6 +126,7 @@ public:
/**
* Determine what to do if a property was changed.
* \param propertyName Name of the property.
*/
void slotPropertyChanged( std::string propertyName );
......@@ -130,11 +139,17 @@ public:
virtual boost::shared_ptr< WModule > factory() const;
/**
* Generate the triangles for the surface
* Generate the triangles for the surface on the given dataSet (inGrid, vals).
* \param inGrid The grid of the data set
* \param vals the value set of the data set
* \param isoValue The surface will run through all positions with this value.
*/
template< typename T > void generateSurface( boost::shared_ptr< WGrid > inGrid, boost::shared_ptr< WValueSet< T > > vals, double isoValue );
// TODO(wiebel): MC document this;
/**
* Activate the rendering of the computed surface.
* This converts the surface to a WTriangleMesh and calls renderMesh afterwards
*/
void renderSurface();
/**
......@@ -159,14 +174,26 @@ protected:
virtual void properties();
private:
/**
* Prepares and commits everything for rendering with the OSG
* \param mesh The mesh that will be rendered.
*/
void renderMesh( WTriangleMesh* mesh );
boost::shared_ptr< WModuleInputData< boost::shared_ptr< WDataSet > > > m_input; //!< Input connector required by this module.
static const unsigned int m_edgeTable[256]; //!< Lookup table for edges used in the construction of the isosurface.
static const int m_triTable[256][16]; //!< Lookup table for triangles used in the construction of the isosurface.
/**
* Calculates the intersection point of the isosurface with an
* Calculates the intersection point id of the isosurface with an
* edge.
* \param vals the value set that determines the values at the vertices
* \param nX id of cell in x direction
* \param nY id of cell in y direction
* \param nZ id of cell in z direction
* \param nEdgeNo id of the edge the point that will be interpolates lies on
*/
template< typename T > WPointXYZId calculateIntersection( boost::shared_ptr< WValueSet< T > > vals,
unsigned int nX, unsigned int nY, unsigned int nZ, unsigned int nEdgeNo );
......@@ -174,16 +201,32 @@ private:
/**
* Interpolates between two grid points to produce the point at which
* the isosurface intersects an edge.
* \param fX1 x coordinate of first position
* \param fY1 y coordinate of first position
* \param fZ1 z coordinate of first position
* \param fX2 x coordinate of second position
* \param fY2 y coordinate of first position
* \param fZ2 z coordinate of first position
* \param tVal1 scalar value at first position
* \param tVal2 scalar value at second position
*/
WPointXYZId interpolate( double fX1, double fY1, double fZ1, double fX2, double fY2, double fZ2, double tVal1, double tVal2 );
/**
* Returns the edge ID.
* \param nX ID of desired cell along x axis
* \param nY ID of desired cell along y axis
* \param nZ ID of desired cell along z axis
* \param nEdgeNo id of edge inside cell
* \return The id of the edge in the large array.
*/
int getEdgeID( unsigned int nX, unsigned int nY, unsigned int nZ, unsigned int nEdgeNo );
/**
* Returns the vertex ID.
* Returns the ID of the vertex given by by the IDs along the axis
* \param nX ID of desired vertex along x axis
* \param nY ID of desired vertex along y axis
* \param nZ ID of desired vertex along z axis
*/
unsigned int getVertexID( unsigned int nX, unsigned int nY, unsigned int nZ );
......@@ -200,16 +243,17 @@ private:
ID2WPointXYZId m_idToVertices; //!< List of WPointXYZIds which form the isosurface.
WMCTriangleVECTOR m_trivecTriangles; //!< List of WMCTriangleS which form the triangulation of the isosurface.
// TODO(wiebel): MC document this;
void renderMesh( WTriangleMesh* mesh );
/**
* Store the mesh in legacy vtk file format.
* \param fileName the file where the triMesh will be written to
* \param triMesh this mesh will be stored.
*/
bool save( std::string fileName, const WTriangleMesh& triMesh ) const;
/**
* Load meshes saved with WMMarchingCubes::save
* \param fileName the mesh will be loaded from this file
*/
WTriangleMesh load( std::string fileName );
......@@ -231,14 +275,26 @@ private:
std::vector< osg::ref_ptr< osg::Uniform > > m_samplerUniforms; //!< uniforms for ids of textures in shader
};
/**
* Adapter object for realizing callbacks of the node representing the isosurface in the osg
*/
class surfaceNodeCallback : public osg::NodeCallback
{
public:
/**
* Constructor of the callback adapter.
* \param module A function of this module will be called
*/
explicit surfaceNodeCallback( boost::shared_ptr< WMMarchingCubes > module )
{
m_module = module;
}
/**
* Function that is called by the osg and that call the function in the module.
* \param node The node we are called.
* \param nv the visitor calling us.
*/
virtual void operator()( osg::Node* node, osg::NodeVisitor* nv )
{
if ( m_module )
......@@ -248,7 +304,7 @@ public:
traverse( node, nv );
}
private:
boost::shared_ptr< WMMarchingCubes > m_module;
boost::shared_ptr< WMMarchingCubes > m_module; //!< Pointer to the module to which the function that is called belongs to.
};
#endif // WMMARCHINGCUBES_H
......@@ -30,9 +30,12 @@
#include "../../math/WPosition.h"
#include "../../math/WVector3D.h"
/**
* A triangle consisting of 3 id of vertices that represent its corners
*/
struct Triangle
{
size_t pointID[3];
size_t pointID[3]; //!< the ID of the vertices representing the triangle corners
};
/**
......@@ -92,12 +95,14 @@ public:
* Add a new vertex at the position given by internal state variable
* fastAddVertId. Each call increases fastAddVertId by one. Exercise care
* when using this function because it depends on the state of the WTriangleMesh.
* \param newVert The vertex that will be added.
*/
void fastAddVert( const wmath::WPosition& newVert );
/**
* Set vertices to given vector of vertex positions. Be aware that this includes
* a complete copy operation.
* \param vertices A vector of position that will be the vertices of the grid.
*/
void setVertices( const std::vector< wmath::WPosition >& vertices );
......@@ -110,12 +115,16 @@ public:
* Add a new triangle at the position given by internal state variable
* fastAddTriangleId. Each call increases fastAddTriangleId by one. Exercise care
* when using this function because it depends on the state of the WTriangleMesh.
* \param vertA Id of vertex in vertex array that will be the first corner of the new triangle
* \param vertB Id of vertex in vertex array that will be the second corner of the new triangle
* \param vertC Id of vertex in vertex array that will be the third corner of the new triangle
*/
void fastAddTriangle( unsigned int vertA, unsigned int vertB, unsigned int vertC );
/**
* Set triangles to given vector of vertex index triples. Be aware that this includes
* a complete copy operation.
* \param triangles Vector of triangles (i.e. encapsulated vertex IDs) that will be the mesh
*/
void setTriangles( const std::vector< Triangle >& triangles );
......@@ -125,6 +134,7 @@ public:
size_t getFastAddTriangleId() const;
/**
* \param id ID of vertex
* \return position of id-th vertex.
*/
wmath::WPosition getVertex( size_t id ) const
......@@ -133,6 +143,8 @@ public:
}
/**
* \param triId id of the triangle in triangle list
* \param vertId id of the vertex in the triangle's vertex list
* \return global vertex id of the vertId-th vertex of the triId-th triangle.
*/
size_t getTriangleVertexId( size_t triId, size_t vertId ) const
......@@ -141,6 +153,7 @@ public:
}
/**
* \param i ID of the triangle the normal will be computed for.
* \return normal of i-th trinagle. Will be computed in the moment of the call.
* i.e. with no memory overhead but possibly slow.
* Normal will be of length 1.
......@@ -151,6 +164,7 @@ public:
* Get the indices of the triangles surrounding the i-th position.
* This function is slow but const and memory efficient.
* Normal will be of length 1.
* \param i ID of position.
*/
std::vector< unsigned int > getPositionTriangleNeighborsSlow( size_t i ) const;
......@@ -158,6 +172,7 @@ public:
* Get an approximated normal for point with index i.
* The normal is a mean of the the normals of the surrounding triangles.
* This function is slow but const and memory efficient.
* \param i ID of vertex.
*/
wmath::WVector3D getVertexNormalSlow( size_t i ) const;
......@@ -167,6 +182,7 @@ public:
* This function is fast but requires the normals to be precomputed
* and stored by computeVertNormals().
* Normal will be of length 1.
* \param i ID of vertex.
*/
wmath::WVector3D getVertexNormal( size_t i ) const;
......
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