Commit 7b1ae28b authored by reichenbach's avatar reichenbach

[BRANCH] add a branch for changes to the current 3d grid

The current changes include:
- only one transformation matrix + its inverse
- only one constructor

This is supposed to be a starting point, we can add the missing functionality back into the grid from here.

Things to consider:
- please DO NOT re-add any of the additional datafields

Suggestions & TODO:
- use strategy pattern for the transformations
  - efficient storage of transformation parameters
- clean up a lot of the code (eg in encloses and getVoxelNum etc) that does transformations
- ...
parent e63f56d6
This diff is collapsed.
This diff is collapsed.
......@@ -138,8 +138,7 @@ boost::shared_ptr< WDataSetScalar > makeDataSetFromImage( typename itk::Image< T
smat( 3, 1 ) = 0.0;
smat( 3, 2 ) = 0.0;
boost::shared_ptr< WGrid > grid( new WGridRegular3D( s[ 0 ], s[ 1 ], s[ 2 ], smat, img->GetSpacing()[ 0 ],
img->GetSpacing()[ 1 ], img->GetSpacing()[ 2 ] ) );
boost::shared_ptr< WGrid > grid( new WGridRegular3D( s[ 0 ], s[ 1 ], s[ 2 ], smat ) );
std::vector< T > v( s[ 0 ] * s[ 1 ] * s[ 2 ] );
typename itk::Image< T, 3 >::IndexType i;
......
......@@ -37,7 +37,7 @@ namespace wtracking
WAssert( dataset->getGrid(), "" );
Grid3DPtr g = boost::shared_dynamic_cast< WGridRegular3D >( dataset->getGrid() );
WAssert( g, "" );
WAssert( g->enclosesRotated( job.first ), "" );
WAssert( g->encloses( job.first ), "" );
// find matching direction
wmath::WVector3D dir = dirFunc( dataset, job );
......@@ -53,7 +53,7 @@ namespace wtracking
WAssert( t > 0.0, "" );
WAssert( onBoundary( g, job.first + dir * t ), "" );
if( !g->enclosesRotated( job.first + dir * t ) )
if( !g->encloses( job.first + dir * t ) )
{
return false;
}
......@@ -66,7 +66,7 @@ namespace wtracking
while( onBoundary( g, job.first + dir * t ) && i < 50 )
{
t += TRACKING_EPS;
if( !g->enclosesRotated( job.first + dir * t ) )
if( !g->encloses( job.first + dir * t ) )
{
return false;
}
......
......@@ -154,7 +154,7 @@ protected:
// |___ |___ |____| |___ |___ |____|
// 15 11 -1 -3 0 1 2 3
boost::shared_ptr< WGridRegular3D > grid( new WGridRegular3D( 4, 4, 1, 1, 1, 1 ) );
boost::shared_ptr< WGridRegular3D > grid( new WGridRegular3D( 4, 4, 1 ) );
double isoValuesData[] = { 15, 11, -1, -3, 13, 12, 1, 0, 3, 5, 10, 9, 2, 4, 8, 14 }; // NOLINT
std::vector< double > isoValues( isoValuesData, isoValuesData + 16 );
boost::shared_ptr< WValueSet< double > > valueset( new WValueSet< double >( 0, 1, isoValues, W_DT_DOUBLE ) );
......
......@@ -170,11 +170,8 @@ boost::shared_ptr< WDataSet > WReaderNIfTI::load()
throw e;
}
newGrid = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D(
columns, rows, frames,
convertMatrix( header->qto_xyz ),
convertMatrix( header->sto_xyz ),
header->dx, header->dy, header->dz ) );
newGrid = boost::shared_ptr< WGridRegular3D >(
new WGridRegular3D( columns, rows, frames, convertMatrix( header->sto_xyz ) ) );
boost::shared_ptr< WDataSet > newDataSet;
// known description
......
......@@ -50,7 +50,7 @@ public:
float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; // NOLINT array init list
std::vector< float > data( &dataArray[0], &dataArray[0] + sizeof( dataArray ) / sizeof( float ) );
boost::shared_ptr< WValueSetBase > newValueSet( new WValueSet< float >( 1, 6, data, W_DT_FLOAT ) );
boost::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1, 1, 1, 1 ) );
boost::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1 ) );
TS_ASSERT_THROWS_NOTHING( WDataSetDTI( newValueSet, newGrid ) );
}
......@@ -63,7 +63,7 @@ public:
float dataArray[6] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; // NOLINT array init list
std::vector< float > data( &dataArray[0], &dataArray[0] + sizeof( dataArray ) / sizeof( float ) );
boost::shared_ptr< WValueSetBase > newValueSet( new WValueSet< float >( 1, 6, data, W_DT_FLOAT ) );
boost::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1, 1, 1, 1 ) );
boost::shared_ptr< WGrid > newGrid( new WGridRegular3D( 1, 1, 1 ) );
WDataSetDTI dataset( newValueSet, newGrid );
wmath::WTensorSym< 2, 3, float > expected;
expected( 0, 0 ) = 0.0;
......
......@@ -72,7 +72,7 @@ public:
void testInterpolate( void )
{
// create dummies, since they are needed in almost every test
boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >( new WGridRegular3D( 5, 3, 3, 1, 1, 1 ) );
boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >( new WGridRegular3D( 5, 3, 3 ) );
std::vector< double > data( grid->size() );
for( size_t i = 0; i < grid->size(); ++i )
{
......
......@@ -73,7 +73,7 @@ public:
}
// create dummies, since they are needed in almost every test
gridDummy = boost::shared_ptr< WGrid >( new WGridRegular3D( 1, 1, 1, 1, 1, 1 ) );
gridDummy = boost::shared_ptr< WGrid >( new WGridRegular3D( 1, 1, 1 ) );
std::vector< int8_t > data( 1, 1 );
valueSetDummy = boost::shared_ptr< WValueSet< int8_t > >( new WValueSet< int8_t >( 0, 1, data, W_DT_INT8 ) );
}
......@@ -104,7 +104,7 @@ public:
*/
void testGetGrid( void )
{
boost::shared_ptr< WGrid > other = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D( 1, 1, 1, 1, 1, 1 ) );
boost::shared_ptr< WGrid > other = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D( 1, 1, 1 ) );
WDataSetSingle dataSetSingle( valueSetDummy, gridDummy );
TS_ASSERT_EQUALS( dataSetSingle.getGrid(), gridDummy );
TS_ASSERT_DIFFERS( dataSetSingle.getGrid(), other );
......
......@@ -97,7 +97,14 @@ public:
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t.push_back( 4.0f );
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3, 1.0, 0.5, 2.0 ) );
wmath::WMatrix< double > mat( 4, 4 );
mat.makeIdentity();
mat( 0, 0 ) = 1.0;
mat( 1, 1 ) = 0.5;
mat( 2, 2 ) = 2.0;
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3, mat ) );
std::vector< double > v( 27, 4 );
boost::shared_ptr< WValueSet< double > > vs( new WValueSet< double >( 0, 1, v, W_DT_DOUBLE ) );
d.push_back( boost::shared_ptr< WDataSetScalar const >( new WDataSetScalar( vs, g ) ) );
......@@ -145,7 +152,14 @@ public:
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t.push_back( 4.0f );
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3, 1.0, 0.5, 2.0 ) );
wmath::WMatrix< double > mat( 4, 4 );
mat.makeIdentity();
mat( 0, 0 ) = 1.0;
mat( 1, 1 ) = 0.5;
mat( 2, 2 ) = 2.0;
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3, mat ) );
std::vector< double > v( 27, 4 );
boost::shared_ptr< WValueSet< double > > vs( new WValueSet< double >( 0, 1, v, W_DT_DOUBLE ) );
d.push_back( boost::shared_ptr< WDataSetScalar const >( new WDataSetScalar( vs, g ) ) );
......@@ -539,7 +553,14 @@ private:
{
dsets.clear();
times.clear();
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3, 1.0, 0.5, 2.0 ) );
wmath::WMatrix< double > mat( 4, 4 );
mat.makeIdentity();
mat( 0, 0 ) = 1.0;
mat( 1, 1 ) = 0.5;
mat( 2, 2 ) = 2.0;
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3, mat ) );
for( int i = 0; i < number; ++i )
{
std::vector< double > v( 27, data[ i ] );
......
......@@ -71,7 +71,7 @@ public:
*/
void testInterpolate( void )
{
boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >( new WGridRegular3D( 5, 3, 3, 1, 1, 1 ) );
boost::shared_ptr< WGrid > grid = boost::shared_ptr< WGrid >( new WGridRegular3D( 5, 3, 3 ) );
std::vector< double > data( grid->size() * 3 );
for( size_t i = 0; i < grid->size() * 3; ++i )
{
......@@ -130,7 +130,7 @@ public:
*/
void testBoundary_ticket313( void )
{
boost::shared_ptr< WGridRegular3D > grid = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D( 3, 4, 5, 1, 1, 1 ) );
boost::shared_ptr< WGridRegular3D > grid = boost::shared_ptr< WGridRegular3D >( new WGridRegular3D( 3, 4, 5 ) );
bool success = false;
std::vector< double > data( grid->size() * 3 );
for( size_t i = 0; i < grid->size() * 3; ++i )
......
This diff is collapsed.
......@@ -80,7 +80,7 @@ public:
{
values[ k ] = 27 - k;
}
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3, 1, 1, 1 ) );
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 3, 3, 3 ) );
boost::shared_ptr< WValueSet< int > > v( new WValueSet< int >( 0, 1, values, W_DT_SIGNED_INT ) );
boost::shared_ptr< WDataSetScalar > ds( new WDataSetScalar( v, g ) );
......
......@@ -201,7 +201,7 @@ private:
std::vector< int > v( a, a + 16 );
dataType r = DataType< int >::type;
boost::shared_ptr< ValueSetType > vs( new ValueSetType( 1, 2, v, r ) );
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 2, 2, 2, 1.0, 1.0, 1.0 ) );
boost::shared_ptr< WGridRegular3D > g( new WGridRegular3D( 2, 2, 2 ) );
return boost::shared_ptr< WDataSetSingle >( new WDataSetSingle( vs, g ) );
}
......
......@@ -195,13 +195,13 @@ public:
// TODO(wiebel): somehow changing the order of the last multiplication does not find the desired operator*
j.first = wmath::WVector3D( 1.0, 0.0, 0.0 ) + ( x + y + z ) * ( wlimits::FLT_EPS + 0.7 ); // the starting point
j.second = x; // initial direction
TS_ASSERT( g->enclosesRotated( j.first ) );
TS_ASSERT( g->encloses( j.first ) );
wmath::WVector3D v = j.first;
TS_ASSERT( wtracking::WTrackingUtility::followToNextVoxel( ds, j, boost::bind( &This::simpleDirFunc, this, _1, _2 ) ) );
TS_ASSERT( !wtracking::WTrackingUtility::onBoundary( g, j.first ) );
TS_ASSERT( g->enclosesRotated( j.first ) );
TS_ASSERT( g->encloses( j.first ) );
v += x * 0.8;
TS_ASSERT_DELTA( ( j.first - v ).norm(), 0.0, 2.0 * TRACKING_EPS );
}
......@@ -238,7 +238,20 @@ private:
y *= 2.0;
z *= 1.5;
boost::shared_ptr< WGrid > g( new WGridRegular3D( 5, 5, 5, 1.0, 0.0, 0.0, x, y, z, 1.0, 1.0, 1.0 ) );
wmath::WMatrix< double > mat( 4, 4 );
mat.makeIdentity();
mat( 0, 0 ) = x[ 0 ];
mat( 0, 1 ) = x[ 1 ];
mat( 0, 2 ) = x[ 2 ];
mat( 1, 0 ) = y[ 0 ];
mat( 1, 1 ) = y[ 1 ];
mat( 1, 2 ) = y[ 2 ];
mat( 2, 0 ) = z[ 0 ];
mat( 2, 1 ) = z[ 1 ];
mat( 2, 2 ) = z[ 2 ];
mat( 0, 3 ) = 1.0;
boost::shared_ptr< WGrid > g( new WGridRegular3D( 5, 5, 5, mat ) );
data.normalize();
......@@ -437,6 +450,9 @@ public:
wtracking::WThreadedTrackingFunction::JobType job = i.job();
wmath::WVector3D v = g->getOrigin() + 0.75 * x + 0.75 * y + 0.75 * z;
std::cout << g->getOrigin() << std::endl;
TS_ASSERT_DELTA( v[ 0 ], job.first[ 0 ], TRACKING_EPS );
TS_ASSERT_DELTA( v[ 1 ], job.first[ 1 ], TRACKING_EPS );
TS_ASSERT_DELTA( v[ 2 ], job.first[ 2 ], TRACKING_EPS );
......@@ -586,7 +602,20 @@ private:
y *= 2.0;
z *= 1.5;
boost::shared_ptr< WGrid > g( new WGridRegular3D( n, n, n, 1.0, 0.0, 0.0, x, y, z, 1.0, 1.0, 1.0 ) );
wmath::WMatrix< double > mat( 4, 4 );
mat.makeIdentity();
mat( 0, 0 ) = x[ 0 ];
mat( 0, 1 ) = x[ 1 ];
mat( 0, 2 ) = x[ 2 ];
mat( 1, 0 ) = y[ 0 ];
mat( 1, 1 ) = y[ 1 ];
mat( 1, 2 ) = y[ 2 ];
mat( 2, 0 ) = z[ 0 ];
mat( 2, 1 ) = z[ 1 ];
mat( 2, 2 ) = z[ 2 ];
mat( 0, 3 ) = 1.0;
boost::shared_ptr< WGrid > g( new WGridRegular3D( n, n, n, mat ) );
data.normalize();
......
......@@ -195,7 +195,9 @@ void WMData::propertyChanged( boost::shared_ptr< WPropertyBase > property )
else if ( property == m_matrixSelection )
{
boost::shared_ptr< WGridRegular3D > grid = m_dataSet->getTexture()->getGrid();
grid->setActiveMatrix( m_matrixSelection->get( true ).getItemIndexOfSelected( 0 ) );
//grid->setActiveMatrix( m_matrixSelection->get( true ).getItemIndexOfSelected( 0 ) );
WDataHandler::getDefaultSubject()->getChangeCondition()->notify();
m_output->triggerUpdate();
}
......
......@@ -19,4 +19,3 @@ ADD_SUBDIRECTORY( superquadricGlyphs )
ADD_SUBDIRECTORY( template )
ADD_SUBDIRECTORY( triangleMeshRenderer )
ADD_SUBDIRECTORY( vectorPlot )
ADD_SUBDIRECTORY( voxelizer )
......@@ -6,7 +6,6 @@ ADD_SUBDIRECTORY( clusterDisplay )
ADD_SUBDIRECTORY( clusterParamDisplay )
ADD_SUBDIRECTORY( clusterSlicer )
ADD_SUBDIRECTORY( contourTree )
ADD_SUBDIRECTORY( datasetManipulator )
ADD_SUBDIRECTORY( dataTypeConversion )
ADD_SUBDIRECTORY( deterministicFTMori )
ADD_SUBDIRECTORY( detTractClustering )
......@@ -19,7 +18,6 @@ ADD_SUBDIRECTORY( fiberResampling )
ADD_SUBDIRECTORY( gaussProcesses )
ADD_SUBDIRECTORY( imageExtractor )
ADD_SUBDIRECTORY( lineGuidedSlice )
ADD_SUBDIRECTORY( overlayAtlas )
ADD_SUBDIRECTORY( probTractDisplay )
ADD_SUBDIRECTORY( scalarSegmentation )
ADD_SUBDIRECTORY( splineSurface )
......
......@@ -244,10 +244,17 @@ boost::shared_ptr< WGridRegular3D > WMVoxelizer::constructGrid( const std::pair<
size_t nbPosY = std::ceil( bb.second[1] - bb.first[1] ) + 1;
size_t nbPosZ = std::ceil( bb.second[2] - bb.first[2] ) + 1;
wmath::WMatrix< double > mat( 4, 4 );
mat.makeIdentity();
mat( 0, 0 ) = mat( 1, 1 ) = mat( 2, 2 ) = 1.0 / nbVoxelsPerUnit;
mat( 0, 3 ) = bb.first[ 0 ];
mat( 1, 3 ) = bb.first[ 1 ];
mat( 2, 3 ) = bb.first[ 2 ];
boost::shared_ptr< WGridRegular3D > grid( new WGridRegular3D( nbVoxelsPerUnit * nbPosX,
nbVoxelsPerUnit * nbPosY,
nbVoxelsPerUnit * nbPosZ,
bb.first, 1.0 / nbVoxelsPerUnit, 1.0 / nbVoxelsPerUnit, 1.0 / nbVoxelsPerUnit ) );
mat ) );
return grid;
}
......
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