diff --git a/Modules/Core/Transform/include/itkMultiTransform.hxx b/Modules/Core/Transform/include/itkMultiTransform.hxx index 5bb61fa1c43..57d501a9db1 100644 --- a/Modules/Core/Transform/include/itkMultiTransform.hxx +++ b/Modules/Core/Transform/include/itkMultiTransform.hxx @@ -74,19 +74,15 @@ MultiTransform::GetParameters( /* Resize destructively. But if it's already this size, nothing is done so * it's efficient. */ this->m_Parameters.SetSize(this->GetNumberOfParameters()); - NumberOfParametersType offset{}; - TransformQueueType transforms = this->GetTransformQueue(); - typename TransformQueueType::const_iterator it; - it = transforms.begin(); + NumberOfParametersType offset{}; - do + for (const TransformType * const transform : m_TransformQueue) { - const ParametersType & subParameters = (*it)->GetParameters(); + const ParametersType & subParameters = transform->GetParameters(); /* use vnl_vector data_block() to get data ptr */ std::copy_n(subParameters.data_block(), subParameters.Size(), &(this->m_Parameters.data_block())[offset]); offset += subParameters.Size(); - ++it; - } while (it != transforms.end()); + } return this->m_Parameters; } @@ -109,11 +105,9 @@ MultiTransform::SetParameters( << this->GetNumberOfParameters() << '.'); } - TransformQueueType transforms = this->GetTransformQueue(); NumberOfParametersType offset{}; - auto it = transforms.begin(); - do + for (TransformType * const transform : m_TransformQueue) { /* If inputParams is same object as m_Parameters, we just pass * each sub-transforms own m_Parameters in. This is needed to @@ -122,17 +116,16 @@ MultiTransform::SetParameters( * parameters to update member variable states. A hack. */ if (&inputParameters == &this->m_Parameters) { - (*it)->SetParameters((*it)->GetParameters()); + transform->SetParameters(transform->GetParameters()); } else { - const size_t parameterSize = (*it)->GetParameters().Size(); - (*it)->CopyInParameters(&(inputParameters.data_block())[offset], - &(inputParameters.data_block())[offset] + parameterSize); + const size_t parameterSize = transform->GetParameters().Size(); + transform->CopyInParameters(&(inputParameters.data_block())[offset], + &(inputParameters.data_block())[offset] + parameterSize); offset += static_cast(parameterSize); } - ++it; - } while (it != transforms.end()); + } } @@ -145,20 +138,16 @@ MultiTransform::GetFixedParame * it's efficient. */ this->m_FixedParameters.SetSize(this->GetNumberOfFixedParameters()); - NumberOfParametersType offset{}; - typename TransformQueueType::const_iterator it; - TransformQueueType transforms = this->GetTransformQueue(); - it = transforms.begin(); + NumberOfParametersType offset{}; - do + for (const TransformType * const transform : m_TransformQueue) { - const FixedParametersType & subFixedParameters = (*it)->GetFixedParameters(); + const FixedParametersType & subFixedParameters = transform->GetFixedParameters(); /* use vnl_vector data_block() to get data ptr */ std::copy_n( subFixedParameters.data_block(), subFixedParameters.Size(), &(this->m_FixedParameters.data_block())[offset]); offset += subFixedParameters.Size(); - ++it; - } while (it != transforms.end()); + } return this->m_FixedParameters; } @@ -178,21 +167,18 @@ MultiTransform::SetFixedParame /* Assumes input params are concatenation of the parameters of the * sub transforms. */ - TransformQueueType transforms = this->GetTransformQueue(); NumberOfParametersType offset{}; /* Why is this done? Seems unnecessary. */ this->m_FixedParameters = inputParameters; - auto it = transforms.begin(); - do + for (TransformType * const transform : m_TransformQueue) { - const size_t fixedParameterSize = (*it)->GetFixedParameters().Size(); - (*it)->CopyInFixedParameters(&(this->m_FixedParameters.data_block())[offset], - &(this->m_FixedParameters.data_block())[offset] + fixedParameterSize); + const size_t fixedParameterSize = transform->GetFixedParameters().Size(); + transform->CopyInFixedParameters(&(this->m_FixedParameters.data_block())[offset], + &(this->m_FixedParameters.data_block())[offset] + fixedParameterSize); offset += static_cast(fixedParameterSize); - ++it; - } while (it != transforms.end()); + } } @@ -318,15 +304,13 @@ template ::GetInverse(Self * inverse) const { - typename TransformQueueType::const_iterator it; - // NOTE: MultiTransform delegates to // individual transform for setting FixedParameters // inverse->SetFixedParameters( this->GetFixedParameters() ); inverse->ClearTransformQueue(); - for (it = this->m_TransformQueue.begin(); it != this->m_TransformQueue.end(); ++it) + for (const TransformType * const transform : m_TransformQueue) { - TransformTypePointer inverseTransform = ((*it)->GetInverseTransform()).GetPointer(); + TransformTypePointer inverseTransform = (transform->GetInverseTransform()).GetPointer(); if (!inverseTransform) { inverse->ClearTransformQueue(); @@ -350,11 +334,10 @@ MultiTransform::PrintSelf(std: Superclass::PrintSelf(os, indent); os << indent << "TransformQueue: " << std::endl; - typename TransformQueueType::const_iterator cit; - for (cit = this->m_TransformQueue.begin(); cit != this->m_TransformQueue.end(); ++cit) + for (const TransformType * const transform : m_TransformQueue) { os << indent << ">>>>>>>>>" << std::endl; - (*cit)->Print(os, indent); + transform->Print(os, indent); } }