Commit 3ecec853 authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[MERGE]

parents 474c0c8a 0432d768
......@@ -94,7 +94,7 @@ void WProperties2::endIteration()
m_iterationLock.unlock();
}
const WProperties2::PropertyIterator WProperties2::getPropertyIteratorEnd() const
const WProperties2::PropertyIterator WProperties2::getPropertyIteratorEnd()
{
return m_properties.end();
}
......
......@@ -101,7 +101,7 @@ public:
*
* \return the list of properties.
*/
const PropertyIterator getPropertyIteratorEnd() const;
const PropertyIterator getPropertyIteratorEnd();
/**
* Create and add a new property of the template type. For more details see appropriate constructor ow WPropertyVariable.
......
......@@ -108,6 +108,8 @@ protected:
boost::thread* m_Thread;
#else
OpenThreads::Thread *m_Thread;
bool m_firstRun;
#endif
/**
......
......@@ -34,8 +34,8 @@
// prototype instance as singleton
boost::shared_ptr< WPrototyped > WDataSetSingle::m_prototype = boost::shared_ptr< WPrototyped >();
WDataSetSingle::WDataSetSingle( boost::shared_ptr<WValueSetBase> newValueSet,
boost::shared_ptr<WGrid> newGrid )
WDataSetSingle::WDataSetSingle( boost::shared_ptr< WValueSetBase > newValueSet,
boost::shared_ptr< WGrid > newGrid )
: WDataSet()
{
assert( newValueSet );
......@@ -60,12 +60,12 @@ WDataSetSingle::~WDataSetSingle()
{
}
boost::shared_ptr<WValueSetBase> WDataSetSingle::getValueSet() const
boost::shared_ptr< WValueSetBase > WDataSetSingle::getValueSet() const
{
return m_valueSet;
}
boost::shared_ptr<WGrid> WDataSetSingle::getGrid() const
boost::shared_ptr< WGrid > WDataSetSingle::getGrid() const
{
return m_grid;
}
......
......@@ -80,7 +80,16 @@ public:
* \param y index in y direction
* \param z index in z direction
*/
template < typename T > T getValueAt( int x, int y, int z );
template< typename T > T getValueAt( int x, int y, int z );
/**
* Get the value stored at a certain grid position of the data set
*
* \param id The id'th value in the data set
*
* \return Scalar value for that given position
*/
template< typename T > T getValueAt( size_t id );
/**
* Determines whether this dataset can be used as a texture.
......@@ -141,7 +150,7 @@ private:
boost::shared_ptr< WDataTexture3D > m_texture3D;
};
template < typename T > T WDataSetSingle::getValueAt( int x, int y, int z )
template< typename T > T WDataSetSingle::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 );
......@@ -152,4 +161,9 @@ template < typename T > T WDataSetSingle::getValueAt( int x, int y, int z )
return v;
}
template< typename T > T WDataSetSingle::getValueAt( size_t id )
{
boost::shared_ptr< WValueSet< T > > vs = boost::shared_dynamic_cast< WValueSet< T > >( m_valueSet );
return vs->getScalar( id );
}
#endif // WDATASETSINGLE_H
......@@ -25,8 +25,9 @@
#include <cmath>
#include <vector>
#include "WGridRegular3D.h"
#include "../common/exceptions/WOutOfBounds.h"
#include "../math/WLinearAlgebraFunctions.h"
#include "WGridRegular3D.h"
using wmath::WVector3D;
using wmath::WPosition;
......@@ -300,3 +301,47 @@ boost::shared_ptr< std::vector< wmath::WPosition > > WGridRegular3D::getVoxelVer
return result;
}
std::vector< size_t > WGridRegular3D::getNeighbours( size_t id ) const
{
std::vector< size_t > neighbours;
size_t x = id % m_nbPosX;
size_t y = ( id / m_nbPosX ) % m_nbPosY;
size_t z = id / ( m_nbPosX * m_nbPosY );
if( x >= m_nbPosX || y >= m_nbPosY || z >= m_nbPosZ )
{
std::stringstream ss;
ss << "This point: " << id << " is not part of this grid: ";
ss << " nbPosX: " << m_nbPosX;
ss << " nbPosY: " << m_nbPosY;
ss << " nbPosZ: " << m_nbPosZ;
throw WOutOfBounds( ss.str() );
}
// for every neighbour we must check if its not on the boundary, it will be skipped otherwise
if( x > 0 )
{
neighbours.push_back( id - 1 );
}
if( x < m_nbPosX - 1 )
{
neighbours.push_back( id + 1 );
}
if( y > 0 )
{
neighbours.push_back( id - m_nbPosX );
}
if( y < m_nbPosY - 1 )
{
neighbours.push_back( id + m_nbPosX );
}
if( z > 0 )
{
neighbours.push_back( id - ( m_nbPosX * m_nbPosY ) );
}
if( z < m_nbPosZ - 1 )
{
neighbours.push_back( id + ( m_nbPosX * m_nbPosY ) );
}
return neighbours;
}
......@@ -341,6 +341,17 @@ public:
boost::shared_ptr< std::vector< wmath::WPosition > > getVoxelVertices( const wmath::WPosition& point,
const double margin = 0.0 ) const;
/**
* Return the list of neighbour voxels.
*
* \throw WOutOfBounds If the voxel id is outside of the grid.
*
* \param id Number of the voxel for which the neighbours should be computed
*
* \return Vector of voxel ids which are all neighboured
*/
std::vector< size_t > getNeighbours( size_t id ) const;
protected:
private:
/**
......
......@@ -28,11 +28,13 @@
#include <cstdio>
#include <sstream>
#include <string>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <cxxtest/TestSuite.h>
#include "../../common/exceptions/WOutOfBounds.h"
#include "../../math/test/WVector3DTraits.h"
#include "../WGridRegular3D.h"
......@@ -412,21 +414,76 @@ public:
// | | |
// 0,0,0 1,0,0 2,0,0
using boost::shared_ptr;
shared_ptr< WGridRegular3D > g = shared_ptr< WGridRegular3D >( new WGridRegular3D( 3, 3, 3, 0, 0, 0, 1, 1, 1 ) );
WGridRegular3D g( 3, 3, 3, 0, 0, 0, 1, 1, 1 );
// center point of the grid
TS_ASSERT_EQUALS( g->getVoxelNum( wmath::WPosition( 1, 1, 1 ) ), 13 );
TS_ASSERT_EQUALS( g.getVoxelNum( wmath::WPosition( 1, 1, 1 ) ), 13 );
// front lower left corner of the last cell
TS_ASSERT_EQUALS( g->getVoxelNum( wmath::WPosition( 1.5, 1.5, 1.5 ) ), 26 );
TS_ASSERT_EQUALS( g.getVoxelNum( wmath::WPosition( 1.5, 1.5, 1.5 ) ), 26 );
TS_ASSERT_EQUALS( g->getVoxelNum( wmath::WPosition( 1, 1, 0.5 ) ), 13 );
TS_ASSERT_EQUALS( g->getVoxelNum( wmath::WPosition( 0 , 1.5 , 1 ) ), 15 );
TS_ASSERT_EQUALS( g->getVoxelNum( wmath::WPosition( 0.5, 1, 0 ) ), 4 );
TS_ASSERT_EQUALS( g.getVoxelNum( wmath::WPosition( 1, 1, 0.5 ) ), 13 );
TS_ASSERT_EQUALS( g.getVoxelNum( wmath::WPosition( 0 , 1.5 , 1 ) ), 15 );
TS_ASSERT_EQUALS( g.getVoxelNum( wmath::WPosition( 0.5, 1, 0 ) ), 4 );
// origin
TS_ASSERT_EQUALS( g->getVoxelNum( wmath::WPosition( 0, 0, 0 ) ), 0 );
TS_ASSERT_EQUALS( g.getVoxelNum( wmath::WPosition( 0, 0, 0 ) ), 0 );
}
/**
* A voxel inside a grid (not located on a border) has 6 neighbours.
*/
void testNeighboursInsideAGrid( void )
{
WGridRegular3D g( 3, 3, 3, 0, 0, 0, 1, 1, 1 );
size_t data[] = { 12, 14, 10, 16, 4, 22 };
std::vector< size_t > expected( data, data + 6 );
TS_ASSERT_EQUALS( expected, g.getNeighbours( 13 ) );
}
/**
* A voxel with voxel-coordinates 0,0,0 has only three neighbours: 1,0,0; 0,1,0 and 0,0,1.
*/
void testNeighboursOnFrontLowerLeft( void )
{
WGridRegular3D g( 3, 3, 3, 0, 0, 0, 1, 1, 1 );
size_t data[] = { 1, 3, 9 };
std::vector< size_t > expected( data, data + 3 );
TS_ASSERT_EQUALS( expected, g.getNeighbours( 0 ) );
}
/**
* A voxel in the back upper right corner should also have only 3 neighbours.
*/
void testNeighbourOnBackUpperRight( void )
{
WGridRegular3D g( 3, 3, 3, 0, 0, 0, 1, 1, 1 );
size_t data[] = { 25, 23, 17 };
std::vector< size_t > expected( data, data + 3 );
TS_ASSERT_EQUALS( expected, g.getNeighbours( 26 ) );
}
/**
* A Voxel on a border plane should have neighbours on the plane but not
* out side the grid.
*/
void testNeighbourOnLeftBorderPlane( void )
{
WGridRegular3D g( 3, 3, 3, 0, 0, 0, 1, 1, 1 );
size_t data[] = { 13, 9, 15, 3, 21 };
std::vector< size_t > expected( data, data + 5 );
TS_ASSERT_EQUALS( expected, g.getNeighbours( 12 ) );
}
/**
* If the neighbours of a voxel not inside this grid are requested an Exception
* WOutOfBounds should be thrown.
*/
void testNeighbourOfVoxelNotInsideThisGrid( void )
{
WGridRegular3D g( 3, 3, 3, 0, 0, 0, 1, 1, 1 );
TS_ASSERT_THROWS_EQUALS( g.getNeighbours( 27 ), const WOutOfBounds &e, std::string( e.what() ),
"This point: 27 is not part of this grid: nbPosX: 3 nbPosY: 3 nbPosZ: 3" );
}
private:
......
......@@ -31,8 +31,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/signals2/signal.hpp>
#include "../common/WThreadedRunner.h"
#include "../common/WFlag.h"
//#include "../common/WThreadedRunner.h"
//#include "../common/WFlag.h"
#include "../kernel/WModule.h"
#include "../graphicsEngine/WGECamera.h"
#include "WCustomWidget.h"
......
......@@ -39,7 +39,11 @@
WQtGLWidget::WQtGLWidget( std::string nameOfViewer, QWidget* parent, WGECamera::ProjectionMode projectionMode )
#ifdef _WIN32
: QWidget( parent ),
#else
: QGLWidget( parent ),
#endif
m_nameOfViewer( nameOfViewer ),
m_recommendedSize(),
m_isInitialized( new WConditionOneShot(), false ),
......
......@@ -44,7 +44,12 @@ class WColor;
* engine.
* \ingroup gui
*/
class WQtGLWidget: public QGLWidget
class WQtGLWidget
#ifdef _WIN32
: public QWidget
#else
: public QGLWidget
#endif
{
public:
/**
......
......@@ -40,8 +40,8 @@
#include "../common/WPreferences.h"
#include "../common/WStringUtils.h"
#include "WBatchLoader.h"
#include "WModule.h"
#include "WBatchLoader.h"
#include "WModuleFactory.h"
#include "../graphicsEngine/WGraphicsEngine.h"
......
......@@ -172,7 +172,7 @@ const std::set<boost::shared_ptr< WModuleOutputConnector > >& WModule::getOutput
return m_outputConnectors;
}
boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name ) const
boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::string name )
{
// simply search
for( std::set<boost::shared_ptr< WModuleInputConnector > >::iterator listIter = m_inputConnectors.begin();
......@@ -188,7 +188,7 @@ boost::shared_ptr< WModuleInputConnector > WModule::getInputConnector( std::stri
throw WModuleConnectorNotFound( "The connector \"" + name + "\" does not exist in the module \"" + getName() + "\"." );
}
boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name ) const
boost::shared_ptr< WModuleOutputConnector > WModule::getOutputConnector( std::string name )
{
// simply search
for( std::set<boost::shared_ptr< WModuleOutputConnector > >::iterator listIter = m_outputConnectors.begin();
......
......@@ -96,7 +96,7 @@ public:
* \return the connector.
* \throw WModuleConnectorNotFound thrown whenever the module does not provide the specified connector.
*/
boost::shared_ptr< WModuleInputConnector > getInputConnector( std::string name ) const;
boost::shared_ptr< WModuleInputConnector > getInputConnector( std::string name );
/**
* Gives back output connectors.
......@@ -113,7 +113,7 @@ public:
* \return the connector.
* \throw WModuleConnectorNotFound thrown whenever the module does not provide the specified connector.
*/
boost::shared_ptr< WModuleOutputConnector > getOutputConnector( std::string name ) const;
boost::shared_ptr< WModuleOutputConnector > getOutputConnector( std::string name );
/**
* Return a pointer to the properties object of the module
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <string>
......
......@@ -22,6 +22,8 @@
//
//---------------------------------------------------------------------------
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <string>
......@@ -209,7 +211,7 @@ void WMWriteNIfTI::writeToFile( std::string fileName )
if( nifti_set_filenames( outField, fileName.c_str(), 0, 1 ) )
{
throw WException( "NIfTI filename Problem" );
throw WException( std::string( "NIfTI filename Problem" ) );
}
nifti_image_write( outField );
......
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