Commit 359200e0 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[STYLE] - while (, if ( and for ( fixed for module and qt4gui code. Only ext stays untouched.

parent a4bf98c2
......@@ -100,12 +100,12 @@ void WMHARDIToSphericalHarmonics::moduleMain()
debugLog() << "Module is now ready.";
debugLog() << "Entering main loop";
while ( !m_shutdownFlag() )
while( !m_shutdownFlag() )
{
debugLog() << "Waiting ...";
m_moduleState.wait();
if ( m_shutdownFlag() )
if( m_shutdownFlag() )
{
break;
}
......@@ -114,7 +114,7 @@ void WMHARDIToSphericalHarmonics::moduleMain()
bool dataChanged = ( m_dataSet != newDataSet );
bool dataValid = ( newDataSet );
if ( dataChanged && dataValid )
if( dataChanged && dataValid )
// this condition will become true whenever the new data is different from the current one or our actual data is NULL. This handles all
// cases.
{
......@@ -131,8 +131,8 @@ void WMHARDIToSphericalHarmonics::moduleMain()
m_order->set( 2 );
}
// if ( dataChanged && dataValid )
if ( dataValid )
// if( dataChanged && dataValid )
if( dataValid )
{
debugLog() << "Data changed. Recalculating output.";
......@@ -147,10 +147,10 @@ void WMHARDIToSphericalHarmonics::moduleMain()
// determine a set of indices of which the gradient is not zero
debugLog() << "Determine usable gradients." << std::endl;
std::vector< size_t > validIndices;
for ( size_t i = 0; i < m_dataSet->getNumberOfMeasurements(); i++ )
for( size_t i = 0; i < m_dataSet->getNumberOfMeasurements(); i++ )
{
const WVector3d& grad = m_dataSet->getGradient( i );
if ( (grad[0] != 0.0) || (grad[1] != 0.0) || (grad[2] != 0.0) )
if( (grad[0] != 0.0) || (grad[1] != 0.0) || (grad[2] != 0.0) )
validIndices.push_back( i );
else
S0Indexes.push_back( i );
......@@ -162,7 +162,7 @@ void WMHARDIToSphericalHarmonics::moduleMain()
// build vector with gradients != 0
std::vector< WVector3d > gradients;
for ( std::vector< size_t >::const_iterator it = validIndices.begin(); it != validIndices.end(); it++ )
for( std::vector< size_t >::const_iterator it = validIndices.begin(); it != validIndices.end(); it++ )
gradients.push_back( m_dataSet->getGradient( *it ) );
int order = m_order->get( true );
......@@ -213,7 +213,7 @@ void WMHARDIToSphericalHarmonics::moduleMain()
parameter.m_normalize = m_doNormalisation->get( true );
// data vector to store reprojection residuals
if ( parameter.m_doResidualCalculation )
if( parameter.m_doResidualCalculation )
{
parameter.m_dataResiduals = boost::shared_ptr< std::vector<double> >(
new std::vector<double>( m_dataSet->getValueSet()->size() * parameter.m_validIndices.size() ) );
......@@ -222,7 +222,7 @@ void WMHARDIToSphericalHarmonics::moduleMain()
// const unsigned int threadCount = 1;
std::pair< size_t, size_t > range;
// create Threads
for ( unsigned int i = 0; i < threadCount; i++ )
for( unsigned int i = 0; i < threadCount; i++ )
{
range.first = ( voxelCount / threadCount ) * i;
range.second = ( i == ( threadCount-1 ) ) ? voxelCount : ( voxelCount / threadCount ) * ( i+1 );
......@@ -231,7 +231,7 @@ void WMHARDIToSphericalHarmonics::moduleMain()
}
debugLog() << "Calculation started ... waiting for finish";
for ( unsigned int i = 0; i < m_threads.size(); i++ )
for( unsigned int i = 0; i < m_threads.size(); i++ )
{
m_threads[ i ]->wait();
overallError += m_threads[ i ]->getError();
......@@ -256,7 +256,7 @@ void WMHARDIToSphericalHarmonics::moduleMain()
m_output->updateData( newData );
// create final output data
if ( parameter.m_doResidualCalculation )
if( parameter.m_doResidualCalculation )
{
boost::shared_ptr< WValueSet<double> > residualsData = boost::shared_ptr< WValueSet<double> >(
new WValueSet<double>( 1, parameter.m_validIndices.size(), parameter.m_dataResiduals, W_DT_DOUBLE ) );
......@@ -362,7 +362,7 @@ void WMHARDIToSphericalHarmonics::properties()
void WMHARDIToSphericalHarmonics::stopThreads()
{
for ( std::vector< WSphericalHarmonicsCoefficientsThread* >::iterator it = m_threads.begin(); it != m_threads.end(); it++ )
for( std::vector< WSphericalHarmonicsCoefficientsThread* >::iterator it = m_threads.begin(); it != m_threads.end(); it++ )
{
( *it )->requestStop();
}
......
......@@ -52,9 +52,9 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
{
m_errorCount = 0;
m_overallError = 0.0;
for ( size_t i = m_range.first; i < m_range.second; i++ )
for( size_t i = m_range.first; i < m_range.second; i++ )
{
if ( m_shutdownFlag.get( true ) ) break;
if( m_shutdownFlag.get( true ) ) break;
// get measure vector
WValue< int16_t > allMeasures( m_parameter.m_valueSet->getWValue( i ) );
......@@ -64,7 +64,7 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
// find max S0 value
double S0avg = 0.0;
for ( std::vector< size_t >::const_iterator it = m_parameter.m_S0Indexes.begin(); it != m_parameter.m_S0Indexes.end(); it++ )
for( std::vector< size_t >::const_iterator it = m_parameter.m_S0Indexes.begin(); it != m_parameter.m_S0Indexes.end(); it++ )
{
S0avg += allMeasures[ *it ];
}
......@@ -72,21 +72,21 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
double minVal = 1e99;
double maxVal = -1e99;
for ( std::vector< size_t >::const_iterator it = m_parameter.m_validIndices.begin(); it != m_parameter.m_validIndices.end(); it++, idx++ )
for( std::vector< size_t >::const_iterator it = m_parameter.m_validIndices.begin(); it != m_parameter.m_validIndices.end(); it++, idx++ )
{
measures[ idx ] = S0avg <= 0.0 ? 0.0 :
static_cast<double>( allMeasures[ *it ] ) / S0avg;
if ( measures[ idx ] < minVal ) minVal = measures[ idx ];
if ( measures[ idx ] > maxVal ) maxVal = measures[ idx ];
if( measures[ idx ] < minVal ) minVal = measures[ idx ];
if( measures[ idx ] > maxVal ) maxVal = measures[ idx ];
}
WVector_2 coefficients( ( *m_parameter.m_TransformMatrix ) * measures );
if ( m_parameter.m_doResidualCalculation || m_parameter.m_doErrorCalculation )
if( m_parameter.m_doResidualCalculation || m_parameter.m_doErrorCalculation )
{
WSymmetricSphericalHarmonic currentSphericalHarmonic( coefficients );
for ( idx = 0; idx < m_parameter.m_validIndices.size(); idx++ )
for( idx = 0; idx < m_parameter.m_validIndices.size(); idx++ )
{
double error = static_cast< double >( measures[ idx ] )
- currentSphericalHarmonic.getValue( WUnitSphereCoordinates( m_parameter.m_gradients[ idx ] ) );
......@@ -116,7 +116,7 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
scale *= std::sqrt( 4.0 * piDouble ) / coefficients[ 0 ];
}
for ( size_t j = 0; j < l; j++ )
for( size_t j = 0; j < l; j++ )
{
m_parameter.m_data->operator[]( l*i + j ) = coefficients[ j ];
}
......@@ -125,6 +125,6 @@ void WSphericalHarmonicsCoefficientsThread::threadMain()
double WSphericalHarmonicsCoefficientsThread::getError() const
{
if ( m_errorCount == 0 ) return 0.0;
if( m_errorCount == 0 ) return 0.0;
return m_overallError / static_cast<double>( m_errorCount );
}
......@@ -116,24 +116,24 @@ void WMArbitraryPlane::moduleMain()
m_moduleState.add( m_propCondition );
m_moduleState.add( m_active->getUpdateCondition() );
while ( !m_shutdownFlag() )
while( !m_shutdownFlag() )
{
m_moduleState.wait();
if ( m_shutdownFlag() )
if( m_shutdownFlag() )
{
break;
}
if ( m_showComplete->changed() )
if( m_showComplete->changed() )
{
m_showComplete->get( true );
m_dirty = true;
}
if ( m_active->changed() )
if( m_active->changed() )
{
if ( m_active->get( true ) && m_showManipulators->get() )
if( m_active->get( true ) && m_showManipulators->get() )
{
m_s0->unhide();
m_s1->unhide();
......@@ -147,11 +147,11 @@ void WMArbitraryPlane::moduleMain()
}
}
if ( m_showManipulators->changed() )
if( m_showManipulators->changed() )
{
if ( m_showManipulators->get( true ) )
if( m_showManipulators->get( true ) )
{
if ( m_active->get() )
if( m_active->get() )
{
m_s0->unhide();
m_s1->unhide();
......@@ -166,7 +166,7 @@ void WMArbitraryPlane::moduleMain()
}
}
if ( m_buttonReset2Axial->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
if( m_buttonReset2Axial->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
WPosition center = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
m_s0->setPosition( center );
......@@ -176,7 +176,7 @@ void WMArbitraryPlane::moduleMain()
m_dirty = true;
}
if ( m_buttonReset2Coronal->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
if( m_buttonReset2Coronal->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
WPosition center = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
m_s0->setPosition( center );
......@@ -186,7 +186,7 @@ void WMArbitraryPlane::moduleMain()
m_dirty = true;
}
if ( m_buttonReset2Sagittal->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
if( m_buttonReset2Sagittal->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
WPosition center = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
m_s0->setPosition( center );
......@@ -257,14 +257,14 @@ void WMArbitraryPlane::updatePlane()
{
m_geode->removeDrawables( 0, 1 );
if ( m_attach2Crosshair->get() )
if( m_attach2Crosshair->get() )
{
m_s0->setPosition( WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition() );
}
WPosition p0 = m_s0->getPosition();
if ( p0 != m_p0 )
if( p0 != m_p0 )
{
WVector3d offset = p0 - m_p0;
m_p0 = p0;
......@@ -304,12 +304,12 @@ void WMArbitraryPlane::updateCallback()
{
WPosition ch = WKernel::getRunningKernel()->getSelectionManager()->getCrosshair()->getPosition();
WPosition cho = getCenterPosition();
if ( ch[0] != cho[0] || ch[1] != cho[1] || ch[2] != cho[2] )
if( ch[0] != cho[0] || ch[1] != cho[1] || ch[2] != cho[2] )
{
setDirty();
}
if ( isDirty() )
if( isDirty() )
{
updatePlane();
}
......
......@@ -121,11 +121,11 @@ void WMArbitraryRois::moduleMain()
ready();
// loop until the module container requests the module to quit
while ( !m_shutdownFlag() )
while( !m_shutdownFlag() )
{
m_moduleState.wait(); // waits for firing of m_moduleState ( dataChanged, shutdown, etc. )
if ( m_shutdownFlag() )
if( m_shutdownFlag() )
{
break;
}
......@@ -142,7 +142,7 @@ void WMArbitraryRois::moduleMain()
initSelectionRoi();
}
if ( m_threshold->changed() )
if( m_threshold->changed() )
{
m_threshold->get( true );
m_showSelector = true;
......@@ -150,7 +150,7 @@ void WMArbitraryRois::moduleMain()
renderMesh();
}
if ( m_finalizeTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
if( m_finalizeTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
m_showSelector = false;
createCutDataset();
......@@ -269,13 +269,13 @@ boost::shared_ptr< std::vector< float > > WMArbitraryRois::cutArea( boost::share
boost::shared_ptr< std::vector< float > > newVals = boost::shared_ptr< std::vector< float > >( new std::vector< float >( nx * ny * nz, 0 ) );
size_t x, y, z;
for ( z = 0; z < nz; ++z )
for( z = 0; z < nz; ++z )
{
for ( y = 0 ; y < ny; ++y )
for( y = 0 ; y < ny; ++y )
{
for ( x = 0 ; x < nx; ++x )
for( x = 0 ; x < nx; ++x )
{
if ( ( x > xMin ) && ( x < xMax ) && ( y > yMin ) && ( y < yMax ) && ( z > zMin ) && ( z < zMax ) )
if( ( x > xMin ) && ( x < xMax ) && ( y > yMin ) && ( y < yMax ) && ( z > zMin ) && ( z < zMax ) )
{
( *newVals )[ x + nx * y + nx * ny * z ] = static_cast< float >( vals->getScalar( x + nx * y + nx * ny * z ) );
}
......@@ -289,7 +289,7 @@ void WMArbitraryRois::renderMesh()
{
m_moduleNode->remove( m_outputGeode );
if ( m_showSelector )
if( m_showSelector )
{
osg::Geometry* surfaceGeometry = new osg::Geometry();
m_outputGeode = osg::ref_ptr< osg::Geode >( new osg::Geode );
......@@ -358,7 +358,7 @@ void WMArbitraryRois::finalizeRoi()
m_threshold->get(),
m_dataSet->getMax(), m_surfaceColor->get( true ) ) );
if ( WKernel::getRunningKernel()->getRoiManager()->getSelectedRoi() == NULL )
if( WKernel::getRunningKernel()->getRoiManager()->getSelectedRoi() == NULL )
{
WKernel::getRunningKernel()->getRoiManager()->addRoi( newRoi );
}
......
......@@ -106,16 +106,16 @@ void WMAtlasCreator::moduleMain()
debugLog() << m_volume.size();
while ( !m_shutdownFlag() )
while( !m_shutdownFlag() )
{
m_moduleState.wait();
if ( m_shutdownFlag() )
if( m_shutdownFlag() )
{
break;
}
if ( m_propReadTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
if( m_propReadTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
boost::filesystem::path fileName = m_propDirectory->get();
m_propReadTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, true );
......@@ -131,7 +131,7 @@ bool WMAtlasCreator::loadPngs( boost::filesystem::path sliceFile )
{
using namespace boost::filesystem; //NOLINT
if ( !exists( sliceFile ) )
if( !exists( sliceFile ) )
{
return false;
}
......@@ -152,18 +152,18 @@ bool WMAtlasCreator::loadPngs( boost::filesystem::path sliceFile )
m_volume.resize( m_xDim * m_yDim * m_zDim, 0 );
directory_iterator end_itr; // default construction yields past-the-end
for ( directory_iterator itr( dirPath ); itr != end_itr; ++itr )
for( directory_iterator itr( dirPath ); itr != end_itr; ++itr )
{
//debugLog() << itr->path().file_string().c_str();
path p( itr->path() );
if ( p.extension() == ".png" )
if( p.extension() == ".png" )
{
addPngToVolume( p );
}
}
for ( size_t i = 0; i < m_regions.size(); ++i )
for( size_t i = 0; i < m_regions.size(); ++i )
{
debugLog() << i << ": " << m_regions[i];
}
......@@ -182,7 +182,7 @@ void WMAtlasCreator::addPngToVolume( boost::filesystem::path image )
size_t pos = boost::lexical_cast<size_t>( number );
if ( pos > 119 )
if( pos > 119 )
{
return;
}
......@@ -190,15 +190,15 @@ void WMAtlasCreator::addPngToVolume( boost::filesystem::path image )
uint8_t id = 0;
bool found = false;
for ( size_t i = 0; i < m_regions.size(); ++i )
for( size_t i = 0; i < m_regions.size(); ++i )
{
if ( m_regions[i] == fn )
if( m_regions[i] == fn )
{
id = static_cast<uint8_t>( i );
found = true;
}
}
if ( !found )
if( !found )
{
m_regions.push_back( fn );
id = static_cast<uint8_t>( m_regions.size() - 1 );
......@@ -211,11 +211,11 @@ void WMAtlasCreator::addPngToVolume( boost::filesystem::path image )
pos /= 2;
++id;
for ( int i = 0; i < m_zDim; ++i )
for( int i = 0; i < m_zDim; ++i )
{
for ( int k = 0; k < m_xDim; ++k )
for( int k = 0; k < m_xDim; ++k )
{
if ( data[k * 3 + ( i * m_xDim * 3 )] != 0 )
if( data[k * 3 + ( i * m_xDim * 3 )] != 0 )
{
m_volume[ pos * m_xDim + ( i * m_xDim * m_yDim ) + k ] = id;
}
......
......@@ -149,7 +149,7 @@ void WCreateSurfaceJob< T >::compute( boost::shared_ptr< WDataSetScalar const >
newValueSet->rawDataVectorPointer(),
0.9,
m_progressCombiner );
if ( triMesh->vertSize() != 0 )
if( triMesh->vertSize() != 0 )
{
( *m_regionMeshes )[job] = triMesh;
}
......@@ -166,7 +166,7 @@ template< typename T > void WCreateSurfaceJob<T>::cutArea( boost::shared_ptr< WV
{
for( size_t k = 0; k < m_grid->size(); ++k )
{
if ( static_cast< size_t >( vals->getScalar( k ) ) == number )
if( static_cast< size_t >( vals->getScalar( k ) ) == number )
{
tempData[ k ] = 1.0;
}
......
......@@ -128,11 +128,11 @@ void WMAtlasSurfaces::moduleMain()
ready();
// loop until the module container requests the module to quit
while ( !m_shutdownFlag() )
while( !m_shutdownFlag() )
{
m_moduleState.wait();
if ( m_shutdownFlag() )
if( m_shutdownFlag() )
{
break;
}
......@@ -161,9 +161,9 @@ void WMAtlasSurfaces::moduleMain()
}
}
if ( m_active->changed() )
if( m_active->changed() )
{
if ( m_active->get( true ) )
if( m_active->get( true ) )
{
m_moduleNode->setNodeMask( 0xFFFFFFFF );
}
......@@ -173,7 +173,7 @@ void WMAtlasSurfaces::moduleMain()
}
}
if ( m_propCreateRoiTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
if( m_propCreateRoiTrigger->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
m_propCreateRoiTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, false );
createRoi();
......@@ -225,7 +225,7 @@ void WMAtlasSurfaces::createSurfaces()
m_possibleSelections = boost::shared_ptr< WItemSelection >( new WItemSelection() );
for (size_t i = 1; i < m_dataSet->getMax() + 1; ++i )
for(size_t i = 1; i < m_dataSet->getMax() + 1; ++i )
{
std::string label = boost::lexical_cast<std::string>( i ) + std::string( " " ) + m_labels[i].second;
m_possibleSelections->addItem( label, "" );
......@@ -237,7 +237,7 @@ void WMAtlasSurfaces::createSurfaces()
void WMAtlasSurfaces::createOSGNode()
{
for ( size_t i = 1; i < m_regionMeshes2->size(); ++i )
for( size_t i = 1; i < m_regionMeshes2->size(); ++i )
{
osg::Geometry* surfaceGeometry = new osg::Geometry();
osg::ref_ptr< osg::Geode > outputGeode = osg::ref_ptr< osg::Geode >( new osg::Geode );
......@@ -295,19 +295,19 @@ void WMAtlasSurfaces::propertyChanged()
void WMAtlasSurfaces::updateGraphics()
{
if ( !m_dirty && !m_aMultiSelection->changed() )
if( !m_dirty && !m_aMultiSelection->changed() )
{
return;
}
WItemSelector s = m_aMultiSelection->get( true );
for ( size_t i = 0; i < m_moduleNode->getNumChildren(); ++i )
for( size_t i = 0; i < m_moduleNode->getNumChildren(); ++i )
{
m_moduleNode->getChild( i )->setNodeMask( 0x0 );
for ( size_t j = 0; j < s.size(); ++j )
for( size_t j = 0; j < s.size(); ++j )
{
if ( s.getItemIndexOfSelected(j) == i )
if( s.getItemIndexOfSelected(j) == i )
{
m_moduleNode->getChild( i )->setNodeMask( 0xFFFFFFFF );
}
......@@ -325,7 +325,7 @@ std::vector< std::string > WMAtlasSurfaces::readFile( const std::string fileName
std::string line;
while ( !ifs.eof() )
while( !ifs.eof() )
{
getline( ifs, line );
......@@ -343,7 +343,7 @@ void WMAtlasSurfaces::loadLabels( std::string fileName )
lines = readFile( fileName );
if ( lines.size() == 0 )
if( lines.size() == 0 )
{
m_labelsLoaded = false;
return;
......@@ -351,17 +351,17 @@ void WMAtlasSurfaces::loadLabels( std::string fileName )
std::vector<std::string>svec;
for ( size_t i = 0; i < lines.size(); ++i )
for( size_t i = 0; i < lines.size(); ++i )
{
svec.clear();
boost::regex reg( "," );
boost::sregex_token_iterator it( lines[i].begin(), lines[i].end(), reg, -1 );
boost::sregex_token_iterator end;
while ( it != end )
while( it != end )
{
svec.push_back( *it++ );
}
if ( svec.size() == 3 )
if( svec.size() == 3 )
{
std::pair< std::string, std::string >newLabel( svec[1], svec[2] );
m_labels[boost::lexical_cast<size_t>( svec[0] )] = newLabel;
......@@ -373,11 +373,11 @@ void WMAtlasSurfaces::loadLabels( std::string fileName )
void WMAtlasSurfaces::createRoi()
{
WItemSelector s = m_aMultiSelection->get( true );
for ( size_t i = 0; i < m_moduleNode->getNumChildren(); ++i )
for( size_t i = 0; i < m_moduleNode->getNumChildren(); ++i )
{
for ( size_t j = 0; j < s.size(); ++j )
for( size_t j = 0; j < s.size(); ++j )
{
if ( s.getItemIndexOfSelected(j) == i )