Skip to content

Commit

Permalink
STYLE: Range-based for-loop in TransformBase::AutomaticScalesEstimation
Browse files Browse the repository at this point in the history
Replaced old for-loops in `AutomaticScalesEstimation` and `AutomaticScalesEstimationStackTransform` by modern C++11 range-based for-loops.
  • Loading branch information
N-Dekker committed Sep 24, 2020
1 parent 38a8799 commit 55b6f3f
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions Core/ComponentBaseClasses/elxTransformBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1858,18 +1858,13 @@ TransformBase< TElastix >
itkExceptionMacro( << "No valid voxels found to estimate the scales." );
}

/** Create iterator over the sample container. */
typename ImageSampleContainerType::ConstIterator iter;
typename ImageSampleContainerType::ConstIterator begin = sampleContainer->Begin();
typename ImageSampleContainerType::ConstIterator end = sampleContainer->End();

/** initialize */
scales.Fill( 0.0 );

/** Read fixed coordinates and get Jacobian. */
for( iter = begin; iter != end; ++iter )
for( const auto& sample : *sampleContainer )
{
const InputPointType & point = ( *iter ).Value().m_ImageCoordinates;
const InputPointType & point = sample.m_ImageCoordinates;
//const JacobianType & jacobian = thisITK->GetJacobian( point );
JacobianType jacobian; NonZeroJacobianIndicesType nzji;
thisITK->GetJacobian( point, jacobian, nzji );
Expand Down Expand Up @@ -1955,17 +1950,12 @@ TransformBase< TElastix >
itkExceptionMacro( << "No valid voxels found to estimate the scales." );
}

/** Create iterator over the sample container. */
typename ImageSampleContainerType::ConstIterator iter;
typename ImageSampleContainerType::ConstIterator begin = sampleContainer->Begin();
typename ImageSampleContainerType::ConstIterator end = sampleContainer->End();

/** Read fixed coordinates and get Jacobian. */
JacobianType jacobian;
NonZeroJacobianIndicesType nzji;
for( iter = begin; iter != end; ++iter )
for( const auto& sample : *sampleContainer )
{
const InputPointType & point = ( *iter ).Value().m_ImageCoordinates;
const InputPointType & point = sample.m_ImageCoordinates;
//const JacobianType & jacobian = thisITK->GetJacobian( point );
thisITK->GetJacobian( point, jacobian, nzji );

Expand Down

0 comments on commit 55b6f3f

Please sign in to comment.