From c79c30861c2076ee1a30dc0ee916e832b8f6fe6c Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Wed, 8 Apr 2026 21:33:12 -0500 Subject: [PATCH] STYLE: Replace declare-then-assign with initialization at declaration Merge the two-line pattern: Type var; var = expr; into the single-line form: const Type var = expr; across 49 files in Modules/ and Examples/. Variables that are never modified after initialization are marked const. Explicit types are used throughout -- auto is NOT used unless the type is blatantly obvious from the RHS (cast or T::New()). This follows the clang-tidy modernize-use-auto criteria (iterators, new, casts only) rather than AAA ("auto almost always"), per review feedback from N-Dekker and dzenanz. Scope-shrink: where a variable was declared at function scope but only used inside a loop body, the declaration is moved into the loop to reduce its scope. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Common/test/itkAnnulusOperatorGTest.cxx | 3 +- ...BSplineInterpolationWeightFunctionTest.cxx | 4 +- ...ndomNonRepeatingIteratorWithIndexGTest.cxx | 6 +-- Modules/Core/Common/test/itkVersorTest.cxx | 4 +- ...itkBSplineInterpolateImageFunctionTest.cxx | 5 +-- .../itkBSplineDeformableTransformTest2.cxx | 8 ++-- .../itkBSplineDeformableTransformTest3.cxx | 8 ++-- .../itkBSplineTransformInitializerTest1.cxx | 14 +++---- .../test/itkBSplineTransformTest2.cxx | 8 ++-- .../test/itkBSplineTransformTest3.cxx | 8 ++-- ...kComposeScaleSkewVersor3DTransformTest.cxx | 36 ++++++----------- .../test/itkEuler2DTransformTest.cxx | 12 ++---- .../test/itkQuaternionRigidTransformTest.cxx | 39 +++++++------------ .../test/itkRigid2DTransformTest.cxx | 3 +- .../test/itkRigid3DTransformTest.cxx | 27 +++++-------- .../itkScaleSkewVersor3DTransformTest.cxx | 27 +++++-------- .../test/itkScaleVersor3DTransformTest.cxx | 27 +++++-------- .../test/itkSimilarity2DTransformTest.cxx | 21 ++++------ .../test/itkSimilarity3DTransformTest.cxx | 27 +++++-------- .../test/itkVersorRigid3DTransformTest.cxx | 27 +++++-------- .../Transform/test/itkVersorTransformTest.cxx | 27 +++++-------- .../LabelMap/test/itkLabelMapTest.cxx | 6 +-- .../test/itkDCMTKImageIONoPreambleTest.cxx | 3 +- .../test/itkGDCMImagePositionPatientTest.cxx | 3 +- ...ianRandomSpatialNeighborSubsamplerTest.cxx | 4 +- .../test/itkImageToHistogramFilterTest.cxx | 5 +-- ...ormRandomSpatialNeighborSubsamplerTest.cxx | 4 +- ...tkEuclideanDistancePointSetMetricTest2.cxx | 3 +- .../test/itkDemonsRegistrationFilterTest.cxx | 7 ++-- ...feomorphicDemonsRegistrationFilterTest.cxx | 7 ++-- ...tricForcesDemonsRegistrationFilterTest.cxx | 7 ++-- ...tkLevelSetMotionRegistrationFilterTest.cxx | 7 ++-- ...tricForcesDemonsRegistrationFilterTest.cxx | 7 ++-- .../itkCollidingFrontsImageFilterTest.cxx | 3 +- .../test/itkShapePriorMAPCostFunctionTest.cxx | 3 +- ...ePriorSegmentationLevelSetFunctionTest.cxx | 6 +-- ...ltiLevelSetChanAndVeseInternalTermTest.cxx | 5 +-- .../test/itkMultiLevelSetDenseImageTest.cxx | 5 +-- .../test/itkMultiLevelSetEvolutionTest.cxx | 5 +-- .../test/itkTwoLevelSetMalcolmImage2DTest.cxx | 4 +- .../test/itkTwoLevelSetShiImage2DTest.cxx | 4 +- .../itkTwoLevelSetWhitakerImage2DTest.cxx | 4 +- 42 files changed, 152 insertions(+), 291 deletions(-) diff --git a/Modules/Core/Common/test/itkAnnulusOperatorGTest.cxx b/Modules/Core/Common/test/itkAnnulusOperatorGTest.cxx index 96fb519601f..90d1646888d 100644 --- a/Modules/Core/Common/test/itkAnnulusOperatorGTest.cxx +++ b/Modules/Core/Common/test/itkAnnulusOperatorGTest.cxx @@ -47,8 +47,7 @@ TEST(AnnulusOperator, CreateAndInspect) EXPECT_NO_THROW(normalizedAnnulus.CreateOperator()); - OperatorType::SizeType normalizedAnnulusSize; - normalizedAnnulusSize = normalizedAnnulus.GetSize(); + const OperatorType::SizeType normalizedAnnulusSize = normalizedAnnulus.GetSize(); std::cout << std::endl; std::cout << "Annulus, N = " << normalizedAnnulusSize << ", r = " << normalizedAnnulus.GetInnerRadius() diff --git a/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx b/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx index 5d5e66ea0ad..4dccfc344cd 100644 --- a/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx +++ b/Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx @@ -255,10 +255,8 @@ itkBSplineInterpolationWeightFunctionTest(int, char *[]) std::cout << "Number Of Weights: " << numberOfWeights << std::endl; auto position = itk::MakeFilled(4.15); - WeightsType weights; IndexType startIndex; - - weights = function->Evaluate(position); + WeightsType weights = function->Evaluate(position); std::cout << "Position: " << position << std::endl; std::cout << "Weights: " << weights << std::endl; diff --git a/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexGTest.cxx b/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexGTest.cxx index b0bf0578b58..c7b5fc6d667 100644 --- a/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexGTest.cxx +++ b/Modules/Core/Common/test/itkImageRandomNonRepeatingIteratorWithIndexGTest.cxx @@ -82,12 +82,11 @@ TEST(ImageRandomNonRepeatingIteratorWithIndex, SupportsSubregions) it.SetNumberOfSamples(numberOfPixelsSize0); it.GoToBegin(); { - ImageType::IndexType indexFill0; // Because the random iterator does not repeat, this should // fill the image with indices while (!it.IsAtEnd()) { - indexFill0 = it.GetIndex(); + const ImageType::IndexType indexFill0 = it.GetIndex(); it.Set(indexFill0); ++it; } @@ -117,10 +116,9 @@ TEST(ImageRandomNonRepeatingIteratorWithIndex, SupportsSubregions) std::cout << "Verifying const iterator... "; std::cout << "Random walk of the Iterator over the image " << std::endl; - ImageType::IndexType indexConstMatch; while (!cot.IsAtEnd()) { - indexConstMatch = cot.GetIndex(); + const ImageType::IndexType indexConstMatch = cot.GetIndex(); EXPECT_EQ(cot.Get(), indexConstMatch) << "Values don't correspond to what was stored " << std::endl << "Test failed at index " << indexConstMatch << " value is " << cot.Get() << std::endl; diff --git a/Modules/Core/Common/test/itkVersorTest.cxx b/Modules/Core/Common/test/itkVersorTest.cxx index 2ce1039dab7..eba1470f0fc 100644 --- a/Modules/Core/Common/test/itkVersorTest.cxx +++ b/Modules/Core/Common/test/itkVersorTest.cxx @@ -271,9 +271,7 @@ itkVersorTest(int, char *[]) const ValueType cosangle = std::cos(angle / 2.0); const ValueType sinangle = std::sin(angle / 2.0); - VectorType xb; - - xb = xa * sinangle; + const VectorType xb = xa * sinangle; if (itk::Math::Absolute(qa.GetX() - xb[0]) > epsilon) { diff --git a/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx b/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx index db4565e0f88..5a476032aa4 100644 --- a/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx +++ b/Modules/Core/ImageFunction/test/itkBSplineInterpolateImageFunctionTest.cxx @@ -220,10 +220,9 @@ TestContinuousIndexDerivative(const TInterpolator * interp, if (isInside) { - typename TInterpolator::CovariantVectorType value; - const double value2 = interp->EvaluateAtContinuousIndex(index); + const double value2 = interp->EvaluateAtContinuousIndex(index); std::cout << "Interpolated Value: " << value2 << '\n'; - value = interp->EvaluateDerivativeAtContinuousIndex(index); + const typename TInterpolator::CovariantVectorType value = interp->EvaluateDerivativeAtContinuousIndex(index); std::cout << " Value: "; for (int i = 0; i < ImageDimension3D; ++i) { diff --git a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx index 516a278e678..559df89a404 100644 --- a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx +++ b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest2.cxx @@ -204,17 +204,15 @@ class BSplineDeformableTransformTest2Helper fi.GoToBegin(); - typename TransformType::InputPointType fixedPoint; - typename TransformType::OutputPointType movingPoint; - typename DeformationFieldType::IndexType index; + typename TransformType::InputPointType fixedPoint; VectorType displacement; while (!fi.IsAtEnd()) { - index = fi.ComputeIndex(); + const typename DeformationFieldType::IndexType index = fi.ComputeIndex(); field->TransformIndexToPhysicalPoint(index, fixedPoint); - movingPoint = bsplineTransform->TransformPoint(fixedPoint); + const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint); displacement[0] = movingPoint[0] - fixedPoint[0]; displacement[1] = movingPoint[1] - fixedPoint[1]; fi.Set(displacement); diff --git a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx index 47a7b9ad88f..ed43ff33637 100644 --- a/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx +++ b/Modules/Core/Transform/test/itkBSplineDeformableTransformTest3.cxx @@ -218,17 +218,15 @@ class BSplineDeformableTransformTest3Helper fi.GoToBegin(); - typename TransformType::InputPointType fixedPoint; - typename TransformType::OutputPointType movingPoint; - typename DeformationFieldType::IndexType index; + typename TransformType::InputPointType fixedPoint; VectorType displacement; while (!fi.IsAtEnd()) { - index = fi.ComputeIndex(); + const typename DeformationFieldType::IndexType index = fi.ComputeIndex(); field->TransformIndexToPhysicalPoint(index, fixedPoint); - movingPoint = bsplineTransform->TransformPoint(fixedPoint); + const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint); displacement[0] = movingPoint[0] - fixedPoint[0]; displacement[1] = movingPoint[1] - fixedPoint[1]; fi.Set(displacement); diff --git a/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx b/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx index 4585fd59cc9..02d011b5291 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformInitializerTest1.cxx @@ -164,20 +164,16 @@ itkBSplineTransformInitializerTest1(int argc, char * argv[]) fi.GoToBegin(); - TransformType::InputPointType fixedPoint; - TransformType::OutputPointType movingPoint; - TransformType::JacobianType jacobian; - DeformationFieldType::IndexType index; - - VectorType displacement; + TransformType::InputPointType fixedPoint; + TransformType::JacobianType jacobian; while (!fi.IsAtEnd()) { - index = fi.ComputeIndex(); + const DeformationFieldType::IndexType index = fi.ComputeIndex(); field->TransformIndexToPhysicalPoint(index, fixedPoint); - movingPoint = bsplineTransform->TransformPoint(fixedPoint); + const TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint); bsplineTransform->ComputeJacobianWithRespectToParameters(fixedPoint, jacobian); - displacement = movingPoint - fixedPoint; + const VectorType displacement = movingPoint - fixedPoint; fi.Set(displacement); ++fi; } diff --git a/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx b/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx index 947d7191bf8..bfbd4486269 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformTest2.cxx @@ -180,17 +180,15 @@ class BSplineTransformTest2Helper fi.GoToBegin(); - typename TransformType::InputPointType fixedPoint; - typename TransformType::OutputPointType movingPoint; - typename DeformationFieldType::IndexType index; + typename TransformType::InputPointType fixedPoint; VectorType displacement; while (!fi.IsAtEnd()) { - index = fi.ComputeIndex(); + const typename DeformationFieldType::IndexType index = fi.ComputeIndex(); field->TransformIndexToPhysicalPoint(index, fixedPoint); - movingPoint = bsplineTransform->TransformPoint(fixedPoint); + const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint); displacement[0] = movingPoint[0] - fixedPoint[0]; displacement[1] = movingPoint[1] - fixedPoint[1]; fi.Set(displacement); diff --git a/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx b/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx index 1dfec23a8e5..fd166c43d86 100644 --- a/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx +++ b/Modules/Core/Transform/test/itkBSplineTransformTest3.cxx @@ -205,17 +205,15 @@ class BSplineTransformTest3Helper fi.GoToBegin(); - typename TransformType::InputPointType fixedPoint; - typename TransformType::OutputPointType movingPoint; - typename DeformationFieldType::IndexType index; + typename TransformType::InputPointType fixedPoint; VectorType displacement; while (!fi.IsAtEnd()) { - index = fi.ComputeIndex(); + const typename DeformationFieldType::IndexType index = fi.ComputeIndex(); field->TransformIndexToPhysicalPoint(index, fixedPoint); - movingPoint = bsplineTransform->TransformPoint(fixedPoint); + const typename TransformType::OutputPointType movingPoint = bsplineTransform->TransformPoint(fixedPoint); displacement[0] = movingPoint[0] - fixedPoint[0]; displacement[1] = movingPoint[1] - fixedPoint[1]; fi.Set(displacement); diff --git a/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx b/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx index 33f906814fd..bf6d67c5ddb 100644 --- a/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkComposeScaleSkewVersor3DTransformTest.cxx @@ -135,11 +135,9 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) // Rotate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 1, 4, 9 }; const TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; - q = versor.Transform(p); + const TransformType::OutputPointType q = versor.Transform(p); - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -163,11 +161,9 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = versor.Transform(p); + const TransformType::OutputVectorType q = versor.Transform(p); - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -191,11 +187,9 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = versor.Transform(p); + const TransformType::OutputCovariantVectorType q = versor.Transform(p); - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -222,11 +216,9 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) p[1] = 4; p[2] = 9; - TransformType::OutputVnlVectorType q; - q = versor.Transform(p); + const TransformType::OutputVnlVectorType q = versor.Transform(p); - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -266,8 +258,7 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) transform->SetCenter(center); - TransformType::OutputPointType transformedPoint; - transformedPoint = transform->TransformPoint(center); + const TransformType::OutputPointType transformedPoint = transform->TransformPoint(center); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(center[i] - transformedPoint[i]) > epsilon) @@ -487,12 +478,9 @@ itkComposeScaleSkewVersor3DTransformTest(int, char *[]) pnt[i] = randomNumberDistribution(randomNumberEngine); } - TransformType::OutputPointType tPnt; - tPnt = transform->TransformPoint(pnt); - TransformType::OutputPointType tPnt2; - tPnt2 = transform2->TransformPoint(pnt); - TransformType::OutputPointType tPnt3; - tPnt3 = transform3->TransformPoint(pnt); + const TransformType::OutputPointType tPnt = transform->TransformPoint(pnt); + const TransformType::OutputPointType tPnt2 = transform2->TransformPoint(pnt); + const TransformType::OutputPointType tPnt3 = transform3->TransformPoint(pnt); for (unsigned int i = 0; i < 3; ++i) { diff --git a/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx b/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx index 0ab41681b28..6f4015cc295 100644 --- a/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkEuler2DTransformTest.cxx @@ -86,8 +86,7 @@ itkEuler2DTransformTest(int, char *[]) q[0] = p[0] * costh - p[1] * sinth; q[1] = p[0] * sinth + p[1] * costh; - EulerTransformType::OutputPointType r; - r = eulerTransform->TransformPoint(p); + EulerTransformType::OutputPointType r = eulerTransform->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -199,15 +198,13 @@ itkEuler2DTransformTest(int, char *[]) p1[0] = 96.8; p1[1] = -3.2; - TransformType::InputPointType p2; - p2 = t1->TransformPoint(p1); + const TransformType::InputPointType p2 = t1->TransformPoint(p1); // Test inverse TransformType::Pointer t22; t1->CloneInverseTo(t22); - TransformType::InputPointType p3; - p3 = t22->TransformPoint(p2); + const TransformType::InputPointType p3 = t22->TransformPoint(p2); std::cout << "Test CloneInverseTo(): "; if (!CheckEqual(p1, p3)) @@ -244,8 +241,7 @@ itkEuler2DTransformTest(int, char *[]) TransformType::Pointer t3; t1->CloneTo(t3); - TransformType::InputPointType p4; - p4 = t3->TransformPoint(p1); + const TransformType::InputPointType p4 = t3->TransformPoint(p1); std::cout << "Test Clone(): "; if (!CheckEqual(p2, p4)) diff --git a/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx b/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx index dc711326bea..188f8565b5c 100644 --- a/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx +++ b/Modules/Core/Transform/test/itkQuaternionRigidTransformTest.cxx @@ -86,10 +86,8 @@ itkQuaternionRigidTransformTest(int, char *[]) // Translate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 10, 10, 10 }; const TransformType::InputPointType p = pInit; - TransformType::InputPointType q; - q = p + itransVector; - TransformType::OutputPointType r; - r = translation->TransformPoint(p); + const TransformType::InputPointType q = p + itransVector; + const TransformType::OutputPointType r = translation->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -113,8 +111,7 @@ itkQuaternionRigidTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 10, 10, 10 }; TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = translation->TransformVector(p); + const TransformType::OutputVectorType q = translation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - p[i]) > epsilon) @@ -137,8 +134,7 @@ itkQuaternionRigidTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 10, 10, 10 }; TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = translation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType q = translation->TransformCovariantVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - p[i]) > epsilon) @@ -163,8 +159,7 @@ itkQuaternionRigidTransformTest(int, char *[]) p[0] = 11; p[1] = 7; p[2] = 15; - TransformType::OutputVnlVectorType q; - q = translation->TransformVector(p); + const TransformType::OutputVnlVectorType q = translation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - p[i]) > epsilon) @@ -265,8 +260,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -296,8 +290,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -327,8 +320,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -361,8 +353,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -593,8 +584,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = x * sinth + y * costh + center[1] + itranslation[1]; q[2] = z + center[2] + itranslation[2]; - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -624,8 +614,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -655,8 +644,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -689,8 +677,7 @@ itkQuaternionRigidTransformTest(int, char *[]) q[1] = p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) diff --git a/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx b/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx index f9b0ae4b356..48683897112 100644 --- a/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkRigid2DTransformTest.cxx @@ -463,8 +463,7 @@ itkRigid2DTransformTest(int, char *[]) p1[0] = 96.8; p1[1] = -3.2; - TransformType::InputPointType p2; - p2 = t1->TransformPoint(p1); + const TransformType::InputPointType p2 = t1->TransformPoint(p1); // Test inverse TransformType::Pointer t2; diff --git a/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx b/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx index f316ac97de3..9d0ccda584a 100644 --- a/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkRigid3DTransformTest.cxx @@ -183,10 +183,8 @@ itkRigid3DTransformTest(int, char *[]) // Translate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 10, 10, 10 }; const TransformType::InputPointType p = pInit; - TransformType::InputPointType q; - q = p + ioffset; - TransformType::OutputPointType r; - r = translation->TransformPoint(p); + const TransformType::InputPointType q = p + ioffset; + const TransformType::OutputPointType r = translation->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -210,8 +208,7 @@ itkRigid3DTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 10, 10, 10 }; TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = translation->TransformVector(p); + const TransformType::OutputVectorType q = translation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - p[i]) > epsilon) @@ -234,8 +231,7 @@ itkRigid3DTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 10, 10, 10 }; TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = translation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType q = translation->TransformCovariantVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - p[i]) > epsilon) @@ -260,8 +256,7 @@ itkRigid3DTransformTest(int, char *[]) p[0] = 11; p[1] = 7; p[2] = 15; - TransformType::OutputVnlVectorType q; - q = translation->TransformVector(p); + const TransformType::OutputVnlVectorType q = translation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - p[i]) > epsilon) @@ -357,8 +352,7 @@ itkRigid3DTransformTest(int, char *[]) q[1] = -p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -388,8 +382,7 @@ itkRigid3DTransformTest(int, char *[]) q[1] = -p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -419,8 +412,7 @@ itkRigid3DTransformTest(int, char *[]) q[1] = -p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < N; ++i) { @@ -454,8 +446,7 @@ itkRigid3DTransformTest(int, char *[]) q[1] = -p[0] * sinth + p[1] * costh; q[2] = p[2]; - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) diff --git a/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx b/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx index f1ef81cd1b4..b84ef4bb113 100644 --- a/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkScaleSkewVersor3DTransformTest.cxx @@ -139,11 +139,9 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) // Rotate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 1, 4, 9 }; const TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; - q = versor.Transform(p); + const TransformType::OutputPointType q = versor.Transform(p); - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -167,11 +165,9 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = versor.Transform(p); + const TransformType::OutputVectorType q = versor.Transform(p); - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -195,11 +191,9 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = versor.Transform(p); + const TransformType::OutputCovariantVectorType q = versor.Transform(p); - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -226,11 +220,9 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) p[1] = 4; p[2] = 9; - TransformType::OutputVnlVectorType q; - q = versor.Transform(p); + const TransformType::OutputVnlVectorType q = versor.Transform(p); - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -270,8 +262,7 @@ itkScaleSkewVersor3DTransformTest(int, char *[]) transform->SetCenter(center); - TransformType::OutputPointType transformedPoint; - transformedPoint = transform->TransformPoint(center); + const TransformType::OutputPointType transformedPoint = transform->TransformPoint(center); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(center[i] - transformedPoint[i]) > epsilon) diff --git a/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx b/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx index f55eb8f1ef7..424ede279f3 100644 --- a/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkScaleVersor3DTransformTest.cxx @@ -152,11 +152,9 @@ itkScaleVersor3DTransformTest(int, char *[]) // Rotate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 1, 4, 9 }; const TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; - q = versor.Transform(p); + const TransformType::OutputPointType q = versor.Transform(p); - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -180,11 +178,9 @@ itkScaleVersor3DTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = versor.Transform(p); + const TransformType::OutputVectorType q = versor.Transform(p); - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -208,11 +204,9 @@ itkScaleVersor3DTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = versor.Transform(p); + const TransformType::OutputCovariantVectorType q = versor.Transform(p); - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -239,11 +233,9 @@ itkScaleVersor3DTransformTest(int, char *[]) p[1] = 4; p[2] = 9; - TransformType::OutputVnlVectorType q; - q = versor.Transform(p); + const TransformType::OutputVnlVectorType q = versor.Transform(p); - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -283,8 +275,7 @@ itkScaleVersor3DTransformTest(int, char *[]) transform->SetCenter(center); - TransformType::OutputPointType transformedPoint; - transformedPoint = transform->TransformPoint(center); + const TransformType::OutputPointType transformedPoint = transform->TransformPoint(center); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(center[i] - transformedPoint[i]) > epsilon) diff --git a/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx b/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx index ec0b2a4522b..749ae4968f0 100644 --- a/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkSimilarity2DTransformTest.cxx @@ -62,9 +62,8 @@ itkSimilarity2DTransformTest(int, char *[]) SimilarityTransformType::InputPointType::ValueType pInit[2] = { 10, 10 }; SimilarityTransformType::InputPointType p = pInit; - SimilarityTransformType::OutputPointType r; - r = transform->TransformPoint(p); + SimilarityTransformType::OutputPointType r = transform->TransformPoint(p); for (unsigned int i = 0; i < N; ++i) { if (itk::Math::Absolute(p[i] - r[i]) > epsilon) @@ -260,15 +259,13 @@ itkSimilarity2DTransformTest(int, char *[]) p1[0] = 96.8; p1[1] = -3.2; - TransformType::InputPointType p2; - p2 = t1->TransformPoint(p1); + const TransformType::InputPointType p2 = t1->TransformPoint(p1); // Test inverse TransformType::Pointer t2; t1->CloneInverseTo(t2); - TransformType::InputPointType p3; - p3 = t2->TransformPoint(p2); + const TransformType::InputPointType p3 = t2->TransformPoint(p2); std::cout << "Test CloneInverseTo(): "; if (!CheckEqual(p1, p3)) @@ -305,8 +302,7 @@ itkSimilarity2DTransformTest(int, char *[]) TransformType::Pointer t3; t1->CloneTo(t3); - TransformType::InputPointType p4; - p4 = t3->TransformPoint(p1); + const TransformType::InputPointType p4 = t3->TransformPoint(p1); std::cout << "Test Clone(): "; if (!CheckEqual(p2, p4)) @@ -435,15 +431,13 @@ itkSimilarity2DTransformTest(int, char *[]) p1[0] = 96.8; p1[1] = -3.2; - TransformType::InputPointType p2; - p2 = t1->TransformPoint(p1); + const TransformType::InputPointType p2 = t1->TransformPoint(p1); // Test inverse TransformType::Pointer t2; t1->CloneInverseTo(t2); - TransformType::InputPointType p3; - p3 = t2->TransformPoint(p2); + const TransformType::InputPointType p3 = t2->TransformPoint(p2); std::cout << "Test CloneInverseTo(): "; if (!CheckEqual(p1, p3)) @@ -480,8 +474,7 @@ itkSimilarity2DTransformTest(int, char *[]) TransformType::Pointer t3; t1->CloneTo(t3); - TransformType::InputPointType p4; - p4 = t3->TransformPoint(p1); + const TransformType::InputPointType p4 = t3->TransformPoint(p1); std::cout << "Test Clone(): "; if (!CheckEqual(p2, p4)) diff --git a/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx b/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx index 15c08ba2c7d..f6e0fb4b15f 100644 --- a/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkSimilarity3DTransformTest.cxx @@ -141,11 +141,9 @@ itkSimilarity3DTransformTest(int, char *[]) // Rotate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 1, 4, 9 }; const TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; - q = versor.Transform(p); + const TransformType::OutputPointType q = versor.Transform(p); - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -169,11 +167,9 @@ itkSimilarity3DTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = versor.Transform(p); + const TransformType::OutputVectorType q = versor.Transform(p); - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -196,11 +192,9 @@ itkSimilarity3DTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = versor.Transform(p); + const TransformType::OutputCovariantVectorType q = versor.Transform(p); - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -227,11 +221,9 @@ itkSimilarity3DTransformTest(int, char *[]) p[1] = 4; p[2] = 9; - TransformType::OutputVnlVectorType q; - q = versor.Transform(p); + const TransformType::OutputVnlVectorType q = versor.Transform(p); - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -270,8 +262,7 @@ itkSimilarity3DTransformTest(int, char *[]) transform->SetCenter(center); - TransformType::OutputPointType transformedPoint; - transformedPoint = transform->TransformPoint(center); + const TransformType::OutputPointType transformedPoint = transform->TransformPoint(center); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(center[i] - transformedPoint[i]) > epsilon) diff --git a/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx b/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx index 7fd51dca1d7..a42eeca49b2 100644 --- a/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx +++ b/Modules/Core/Transform/test/itkVersorRigid3DTransformTest.cxx @@ -133,11 +133,9 @@ itkVersorRigid3DTransformTest(int, char *[]) // Rotate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 1, 4, 9 }; const TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; - q = versor.Transform(p); + const TransformType::OutputPointType q = versor.Transform(p); - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -161,11 +159,9 @@ itkVersorRigid3DTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = versor.Transform(p); + const TransformType::OutputVectorType q = versor.Transform(p); - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -189,11 +185,9 @@ itkVersorRigid3DTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = versor.Transform(p); + const TransformType::OutputCovariantVectorType q = versor.Transform(p); - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -220,11 +214,9 @@ itkVersorRigid3DTransformTest(int, char *[]) p[1] = 4; p[2] = 9; - TransformType::OutputVnlVectorType q; - q = versor.Transform(p); + const TransformType::OutputVnlVectorType q = versor.Transform(p); - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -264,8 +256,7 @@ itkVersorRigid3DTransformTest(int, char *[]) transform->SetCenter(center); - TransformType::OutputPointType transformedPoint; - transformedPoint = transform->TransformPoint(center); + const TransformType::OutputPointType transformedPoint = transform->TransformPoint(center); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(center[i] - transformedPoint[i]) > epsilon) diff --git a/Modules/Core/Transform/test/itkVersorTransformTest.cxx b/Modules/Core/Transform/test/itkVersorTransformTest.cxx index 8d6164bb40a..029e9a0bfd8 100644 --- a/Modules/Core/Transform/test/itkVersorTransformTest.cxx +++ b/Modules/Core/Transform/test/itkVersorTransformTest.cxx @@ -130,11 +130,9 @@ itkVersorTransformTest(int, char *[]) // Rotate an itk::Point constexpr TransformType::InputPointType::ValueType pInit[3]{ 1, 4, 9 }; const TransformType::InputPointType p = pInit; - TransformType::OutputPointType q; - q = versor.Transform(p); + const TransformType::OutputPointType q = versor.Transform(p); - TransformType::OutputPointType r; - r = rotation->TransformPoint(p); + const TransformType::OutputPointType r = rotation->TransformPoint(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -158,11 +156,9 @@ itkVersorTransformTest(int, char *[]) // Translate an itk::Vector TransformType::InputVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputVectorType p = pInit; - TransformType::OutputVectorType q; - q = versor.Transform(p); + const TransformType::OutputVectorType q = versor.Transform(p); - TransformType::OutputVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -186,11 +182,9 @@ itkVersorTransformTest(int, char *[]) // Translate an itk::CovariantVector TransformType::InputCovariantVectorType::ValueType pInit[3] = { 1, 4, 9 }; const TransformType::InputCovariantVectorType p = pInit; - TransformType::OutputCovariantVectorType q; - q = versor.Transform(p); + const TransformType::OutputCovariantVectorType q = versor.Transform(p); - TransformType::OutputCovariantVectorType r; - r = rotation->TransformCovariantVector(p); + const TransformType::OutputCovariantVectorType r = rotation->TransformCovariantVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -217,11 +211,9 @@ itkVersorTransformTest(int, char *[]) p[1] = 4; p[2] = 9; - TransformType::OutputVnlVectorType q; - q = versor.Transform(p); + const TransformType::OutputVnlVectorType q = versor.Transform(p); - TransformType::OutputVnlVectorType r; - r = rotation->TransformVector(p); + const TransformType::OutputVnlVectorType r = rotation->TransformVector(p); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(q[i] - r[i]) > epsilon) @@ -261,8 +253,7 @@ itkVersorTransformTest(int, char *[]) transform->SetCenter(center); - TransformType::OutputPointType transformedPoint; - transformedPoint = transform->TransformPoint(center); + const TransformType::OutputPointType transformedPoint = transform->TransformPoint(center); for (unsigned int i = 0; i < 3; ++i) { if (itk::Math::Absolute(center[i] - transformedPoint[i]) > epsilon) diff --git a/Modules/Filtering/LabelMap/test/itkLabelMapTest.cxx b/Modules/Filtering/LabelMap/test/itkLabelMapTest.cxx index dbd7d72047f..b7ea11bbd5d 100644 --- a/Modules/Filtering/LabelMap/test/itkLabelMapTest.cxx +++ b/Modules/Filtering/LabelMap/test/itkLabelMapTest.cxx @@ -118,12 +118,10 @@ itkLabelMapTest(int argc, char * argv[]) loCheck = map->GetLabelObject(idx); itkAssertOrThrowMacro((loCheck == lo), "Add/GetLabelObject failed"); - LabelObjectVectorType loVector; - loVector = map->GetLabelObjects(); + const LabelObjectVectorType loVector = map->GetLabelObjects(); itkAssertOrThrowMacro((loVector[0] == lo), "GetLabelObjects failed"); - LabelVectorType loLabels; - loLabels = map->GetLabels(); + const LabelVectorType loLabels = map->GetLabels(); itkAssertOrThrowMacro((loLabels[0] == 1), "GetLabels failed"); auto lo2 = LabelObjectType::New(); diff --git a/Modules/IO/DCMTK/test/itkDCMTKImageIONoPreambleTest.cxx b/Modules/IO/DCMTK/test/itkDCMTKImageIONoPreambleTest.cxx index 49fd4814fca..729af3b9638 100644 --- a/Modules/IO/DCMTK/test/itkDCMTKImageIONoPreambleTest.cxx +++ b/Modules/IO/DCMTK/test/itkDCMTKImageIONoPreambleTest.cxx @@ -56,8 +56,7 @@ itkDCMTKImageIONoPreambleTest(int argc, char * argv[]) ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update()); - InputImageType::SizeType extentSize; - extentSize = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); + const InputImageType::SizeType extentSize = reader->GetOutput()->GetLargestPossibleRegion().GetSize(); std::cout << "Read image dimensions: (" << extentSize[0] << ", " << extentSize[1] << ", " << extentSize[2] << ')' << std::endl; if (extentSize[0] == 0 || extentSize[1] == 0 || extentSize[2] == 0) diff --git a/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx b/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx index 13f1c8d8c8d..e3fa093fffe 100644 --- a/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx +++ b/Modules/IO/GDCM/test/itkGDCMImagePositionPatientTest.cxx @@ -109,8 +109,7 @@ itkGDCMImagePositionPatientTest(int argc, char * argv[]) reader->SetFileName(filename.str().c_str()); reader->Update(); - Image3DType::PointType readerOrigin3D; - readerOrigin3D = reader->GetOutput()->GetOrigin(); + const Image3DType::PointType readerOrigin3D = reader->GetOutput()->GetOrigin(); if ((itk::Math::NotExactlyEquals(readerOrigin3D[0], origin3D[0])) || (itk::Math::NotExactlyEquals(readerOrigin3D[1], origin3D[1])) || (itk::Math::NotExactlyEquals(readerOrigin3D[2], origin3D[2]))) diff --git a/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx b/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx index 1e4011a51fe..3688d30641f 100644 --- a/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx +++ b/Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx @@ -41,7 +41,6 @@ itkGaussianRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) using FloatImage = itk::Image; using RegionType = FloatImage::RegionType; - using IndexType = FloatImage::IndexType; using SizeType = FloatImage::SizeType; using BoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition; using AdaptorType = itk::Statistics::ImageToNeighborhoodSampleAdaptor; @@ -110,8 +109,7 @@ itkGaussianRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) for (SamplerType::SubsampleConstIterator sIt = subsample->Begin(); sIt != subsample->End(); ++sIt) { - IndexType index; - index = sIt.GetMeasurementVector()[0].GetIndex(); + const FloatImage::IndexType index = sIt.GetMeasurementVector()[0].GetIndex(); inImage->SetPixel(index, 255); } diff --git a/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx b/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx index bc969ac912b..daab4cd81a3 100644 --- a/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx +++ b/Modules/Numerics/Statistics/test/itkImageToHistogramFilterTest.cxx @@ -48,12 +48,11 @@ itkImageToHistogramFilterTest(int, char *[]) itk::ImageRegionIteratorWithIndex it(image, region); it.GoToBegin(); - RGBPixelType pixel; - RGBImageType::IndexType index; + RGBPixelType pixel; while (!it.IsAtEnd()) { - index = it.GetIndex(); + const RGBImageType::IndexType index = it.GetIndex(); pixel.SetRed(index[0]); pixel.SetGreen(index[1]); pixel.SetBlue(index[2]); diff --git a/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx b/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx index 9732ca2c5ca..7fae35d5a99 100644 --- a/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx +++ b/Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx @@ -42,7 +42,6 @@ itkUniformRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) using FloatImage = itk::Image; using RegionType = FloatImage::RegionType; - using IndexType = FloatImage::IndexType; using SizeType = FloatImage::SizeType; using BoundaryCondition = itk::ZeroFluxNeumannBoundaryCondition; using AdaptorType = itk::Statistics::ImageToNeighborhoodSampleAdaptor; @@ -119,8 +118,7 @@ itkUniformRandomSpatialNeighborSubsamplerTest(int argc, char * argv[]) for (SamplerType::SubsampleConstIterator sIt = subsample->Begin(); sIt != subsample->End(); ++sIt) { - IndexType index; - index = sIt.GetMeasurementVector()[0].GetIndex(); + const FloatImage::IndexType index = sIt.GetMeasurementVector()[0].GetIndex(); inImage->SetPixel(index, 255); } diff --git a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx index 4243a5a886d..5913c55294f 100644 --- a/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx +++ b/Modules/Registration/Metricsv4/test/itkEuclideanDistancePointSetMetricTest2.cxx @@ -159,10 +159,9 @@ itkEuclideanDistancePointSetMetricTest2Run() bool passed = true; for (itk::SizeValueType n = 0; n < fixedPoints->GetNumberOfPoints(); ++n) { - PointType transformedPoint; fixedPoint = fixedPoints->GetPoint(n); movingPoint = movingPoints->GetPoint(n); - transformedPoint = displacementTransform->TransformPoint(fixedPoint); + const PointType transformedPoint = displacementTransform->TransformPoint(fixedPoint); for (unsigned int d = 0; d < Dimension; ++d) { if (itk::Math::NotExactlyEquals(transformedPoint[d], movingPoint[d])) diff --git a/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx index a90663a7baf..8e44631deaf 100644 --- a/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx @@ -67,13 +67,12 @@ FillWithCircle(TImage * image, Iterator it(image, image->GetBufferedRegion()); it.GoToBegin(); - typename TImage::IndexType index; - const double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); while (!it.IsAtEnd()) { - index = it.GetIndex(); - double distance = 0; + const typename TImage::IndexType index = it.GetIndex(); + double distance = 0; for (unsigned int j = 0; j < TImage::ImageDimension; ++j) { distance += itk::Math::sqr(static_cast(index[j]) - center[j]); diff --git a/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx index 8cbbffc53c7..84314980348 100644 --- a/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkDiffeomorphicDemonsRegistrationFilterTest.cxx @@ -60,13 +60,12 @@ FillWithCircle(TImage * image, Iterator it(image, image->GetBufferedRegion()); it.GoToBegin(); - typename TImage::IndexType index; - const double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); for (; !it.IsAtEnd(); ++it) { - index = it.GetIndex(); - double distance = 0; + const typename TImage::IndexType index = it.GetIndex(); + double distance = 0; for (unsigned int j = 0; j < TImage::ImageDimension; ++j) { distance += itk::Math::sqr(static_cast(index[j]) - center[j]); diff --git a/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx index c63b9136734..4055ec9e658 100644 --- a/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkFastSymmetricForcesDemonsRegistrationFilterTest.cxx @@ -66,13 +66,12 @@ FillWithCircle(TImage * image, Iterator it(image, image->GetBufferedRegion()); it.GoToBegin(); - typename TImage::IndexType index; - const double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); for (; !it.IsAtEnd(); ++it) { - index = it.GetIndex(); - double distance = 0; + const typename TImage::IndexType index = it.GetIndex(); + double distance = 0; for (unsigned int j = 0; j < TImage::ImageDimension; ++j) { distance += itk::Math::sqr(static_cast(index[j]) - center[j]); diff --git a/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx index af1d628a605..864a6420856 100644 --- a/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkLevelSetMotionRegistrationFilterTest.cxx @@ -72,13 +72,12 @@ FillWithCircle(typename TImage::Pointer & image, it.GoToBegin(); - typename TImage::IndexType index; - const double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); while (!it.IsAtEnd()) { - index = it.GetIndex(); - double distance = 0; + const typename TImage::IndexType index = it.GetIndex(); + double distance = 0; for (unsigned int j = 0; j < TImage::ImageDimension; ++j) { distance += itk::Math::sqr(static_cast(index[j]) - center[j]); diff --git a/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx b/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx index 0fe6dbf2510..f7c94cb8ad4 100644 --- a/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx +++ b/Modules/Registration/PDEDeformable/test/itkSymmetricForcesDemonsRegistrationFilterTest.cxx @@ -55,13 +55,12 @@ FillWithCircle(TImage * image, Iterator it(image, image->GetBufferedRegion()); it.GoToBegin(); - typename TImage::IndexType index; - const double r2 = itk::Math::sqr(radius); + const double r2 = itk::Math::sqr(radius); while (!it.IsAtEnd()) { - index = it.GetIndex(); - double distance = 0; + const typename TImage::IndexType index = it.GetIndex(); + double distance = 0; for (unsigned int j = 0; j < TImage::ImageDimension; ++j) { distance += itk::Math::sqr(static_cast(index[j]) - center[j]); diff --git a/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx b/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx index e8a189f7d07..5e880135c0e 100644 --- a/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkCollidingFrontsImageFilterTest.cxx @@ -122,8 +122,7 @@ itkCollidingFrontsImageFilterTest(int argc, char * argv[]) for (; !iterator.IsAtEnd(); ++iterator) { - InternalImageType::IndexType tempIndex; - tempIndex = iterator.ComputeIndex(); + InternalImageType::IndexType tempIndex = iterator.ComputeIndex(); tempIndex -= offset; double distance = 0.0; for (int j = 0; j < 2; ++j) diff --git a/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx b/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx index c4bcce09690..8ad40b252b9 100644 --- a/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkShapePriorMAPCostFunctionTest.cxx @@ -101,9 +101,8 @@ itkShapePriorMAPCostFunctionTest(int, char *[]) while (!iter.IsAtEnd()) { - ImageType::IndexType index; + const ImageType::IndexType index = iter.GetIndex(); ShapeFunctionType::PointType point; - index = iter.GetIndex(); input->TransformIndexToPhysicalPoint(index, point); const float value = shape->Evaluate(point); diff --git a/Modules/Segmentation/LevelSets/test/itkShapePriorSegmentationLevelSetFunctionTest.cxx b/Modules/Segmentation/LevelSets/test/itkShapePriorSegmentationLevelSetFunctionTest.cxx index 96418a81c58..8fa49c30a9f 100644 --- a/Modules/Segmentation/LevelSets/test/itkShapePriorSegmentationLevelSetFunctionTest.cxx +++ b/Modules/Segmentation/LevelSets/test/itkShapePriorSegmentationLevelSetFunctionTest.cxx @@ -140,9 +140,8 @@ itkShapePriorSegmentationLevelSetFunctionTest(int, char *[]) while (!iter.IsAtEnd()) { - ImageType::IndexType index; + const ImageType::IndexType index = iter.GetIndex(); ShapeFunctionType::PointType point; - index = iter.GetIndex(); input->TransformIndexToPhysicalPoint(index, point); iter.Set(shape->Evaluate(point)); ++iter; @@ -199,9 +198,8 @@ itkShapePriorSegmentationLevelSetFunctionTest(int, char *[]) while (!citer.IsAtEnd()) { - CharImageType::IndexType index; + const ImageType::IndexType index = citer.GetIndex(); ShapeFunctionType::PointType point; - index = citer.GetIndex(); input->TransformIndexToPhysicalPoint(index, point); if (shape->Evaluate(point) < 0.0) { diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx index bb70cc8a511..3d11a27188a 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetChanAndVeseInternalTermTest.cxx @@ -73,8 +73,7 @@ itkMultiLevelSetChanAndVeseInternalTermTest(int, char *[]) input2->Allocate(); input2->FillBuffer(value); - ImageType::IndexType idx; - IdListType list_ids; + IdListType list_ids; auto id_image = IdListImageType::New(); id_image->SetRegions(region); @@ -98,7 +97,7 @@ itkMultiLevelSetChanAndVeseInternalTermTest(int, char *[]) while (!it1.IsAtEnd()) { - idx = it1.GetIndex(); + const ImageType::IndexType idx = it1.GetIndex(); list_ids.clear(); if ((idx[0] < 5) && (idx[1] < 5)) diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx index 7bd3f03fe73..3c858ec8694 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetDenseImageTest.cxx @@ -52,8 +52,7 @@ itkMultiLevelSetDenseImageTest(int, char *[]) input2->Allocate(); input2->FillBuffer(value); - ImageType::IndexType idx; - IdListType list_ids; + IdListType list_ids; auto id_image = IdListImageType::New(); id_image->SetRegions(region); @@ -67,7 +66,7 @@ itkMultiLevelSetDenseImageTest(int, char *[]) while (!it1.IsAtEnd()) { - idx = it1.GetIndex(); + const ImageType::IndexType idx = it1.GetIndex(); list_ids.clear(); if ((idx[0] < 5) && (idx[1] < 5)) diff --git a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx index bc132eb148b..207b849a4db 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkMultiLevelSetEvolutionTest.cxx @@ -83,8 +83,7 @@ itkMultiLevelSetEvolutionTest(int, char *[]) input2->Allocate(); input2->FillBuffer(value); - ImageType::IndexType idx; - IdListType list_ids; + IdListType list_ids; auto id_image = IdListImageType::New(); id_image->SetRegions(region); @@ -98,7 +97,7 @@ itkMultiLevelSetEvolutionTest(int, char *[]) while (!it1.IsAtEnd()) { - idx = it1.GetIndex(); + const ImageType::IndexType idx = it1.GetIndex(); list_ids.clear(); if ((idx[0] < 5) && (idx[1] < 5)) diff --git a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx index d10b6643462..b86f5c3112d 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetMalcolmImage2DTest.cxx @@ -234,11 +234,9 @@ itkTwoLevelSetMalcolmImage2DTest(int argc, char * argv[]) OutputIteratorType oIt(outputImage, outputImage->GetLargestPossibleRegion()); oIt.GoToBegin(); - OutputImageType::IndexType idx; - while (!oIt.IsAtEnd()) { - idx = oIt.GetIndex(); + const OutputImageType::IndexType idx = oIt.GetIndex(); oIt.Set(level_set0->Evaluate(idx)); ++oIt; } diff --git a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx index 24094d40447..1fb0f859901 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetShiImage2DTest.cxx @@ -233,11 +233,9 @@ itkTwoLevelSetShiImage2DTest(int argc, char * argv[]) OutputIteratorType oIt(outputImage, outputImage->GetLargestPossibleRegion()); oIt.GoToBegin(); - OutputImageType::IndexType idx; - while (!oIt.IsAtEnd()) { - idx = oIt.GetIndex(); + const OutputImageType::IndexType idx = oIt.GetIndex(); oIt.Set(level_set0->Evaluate(idx)); ++oIt; } diff --git a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx index ceebef9d2dc..f1e554c8447 100644 --- a/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx +++ b/Modules/Segmentation/LevelSetsv4/test/itkTwoLevelSetWhitakerImage2DTest.cxx @@ -237,11 +237,9 @@ itkTwoLevelSetWhitakerImage2DTest(int argc, char * argv[]) OutputIteratorType oIt(outputImage, outputImage->GetLargestPossibleRegion()); oIt.GoToBegin(); - OutputImageType::IndexType idx; - while (!oIt.IsAtEnd()) { - idx = oIt.GetIndex(); + const OutputImageType::IndexType idx = oIt.GetIndex(); oIt.Set(level_set1->GetLabelMap()->GetPixel(idx)); ++oIt; }