Skip to content

Commit

Permalink
STYLE: Add const to auto [index, size] = region structured bindings
Browse files Browse the repository at this point in the history
Added `const`, whenever the values of the bindings were not modified, after the
declaration.
  • Loading branch information
N-Dekker committed Jan 14, 2024
1 parent b96bd57 commit b4efee3
Show file tree
Hide file tree
Showing 29 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Modules/Bridge/VTK/include/itkVTKImageExport.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ VTKImageExport<TInputImage>::WholeExtentCallback()
}

InputRegionType region = input->GetLargestPossibleRegion();
auto [index, size] = region;
const auto [index, size] = region;

unsigned int i = 0;
// Fill in the known portion of the extent.
Expand Down Expand Up @@ -386,7 +386,7 @@ VTKImageExport<TInputImage>::DataExtentCallback()
}

InputRegionType region = input->GetBufferedRegion();
auto [index, size] = region;
const auto [index, size] = region;

unsigned int i = 0;
for (; i < InputImageDimension; ++i)
Expand Down
2 changes: 1 addition & 1 deletion Modules/Bridge/VTK/include/itkVTKImageImport.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ VTKImageImport<TOutputImage>::PropagateRequestedRegion(DataObject * outputPtr)
if (m_PropagateUpdateExtentCallback)
{
OutputRegionType region = output->GetRequestedRegion();
auto [index, size] = region;
const auto [index, size] = region;

int updateExtent[6];
unsigned int i = 0;
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/include/itkPeriodicBoundaryCondition.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ PeriodicBoundaryCondition<TInputImage, TOutputImage>::GetInputRequestedRegion(
const RegionType & inputLargestPossibleRegion,
const RegionType & outputRequestedRegion) const -> RegionType
{
auto [imageIndex, imageSize] = inputLargestPossibleRegion;
const auto [imageIndex, imageSize] = inputLargestPossibleRegion;

auto [outputIndex, outputSize] = outputRequestedRegion;
const auto [outputIndex, outputSize] = outputRequestedRegion;

IndexType inputRequestedIndex;
SizeType inputRequestedSize;
Expand Down Expand Up @@ -182,7 +182,7 @@ PeriodicBoundaryCondition<TInputImage, TOutputImage>::GetPixel(const IndexType &
-> OutputPixelType
{
RegionType imageRegion = image->GetLargestPossibleRegion();
auto [imageIndex, imageSize] = imageRegion;
const auto [imageIndex, imageSize] = imageRegion;

IndexType lookupIndex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ ZeroFluxNeumannBoundaryCondition<TInputImage, TOutputImage>::GetInputRequestedRe
const RegionType & inputLargestPossibleRegion,
const RegionType & outputRequestedRegion) const -> RegionType
{
auto [inputIndex, inputSize] = inputLargestPossibleRegion;
const auto [inputIndex, inputSize] = inputLargestPossibleRegion;

auto [outputIndex, outputSize] = outputRequestedRegion;
const auto [outputIndex, outputSize] = outputRequestedRegion;

IndexType requestIndex;
SizeType requestSize;
Expand Down Expand Up @@ -154,7 +154,7 @@ ZeroFluxNeumannBoundaryCondition<TInputImage, TOutputImage>::GetPixel(const Inde
-> OutputPixelType
{
RegionType imageRegion = image->GetLargestPossibleRegion();
auto [imageIndex, imageSize] = imageRegion;
const auto [imageIndex, imageSize] = imageRegion;

IndexType lookupIndex;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/GPUCommon/include/itkGPUImageDataManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ GPUImageDataManager<ImageType>::SetImagePointer(ImageType * img)
using SizeType = typename ImageType::SizeType;

RegionType region = m_Image->GetBufferedRegion();
auto [index, size] = region;
const auto [index, size] = region;

for (unsigned int d = 0; d < ImageDimension; ++d)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ GaussianInterpolateImageFunction<TImageType, TCoordRep>::ComputeBoundingBox()

typename InputImageType::ConstPointer input = this->GetInputImage();
typename InputImageType::SpacingType spacing = input->GetSpacing();
auto [index, size] = input->GetLargestPossibleRegion();
const auto [index, size] = input->GetLargestPossibleRegion();

for (unsigned int d = 0; d < ImageDimension; ++d)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ SpatialObjectToImageStatisticsCalculator<TInputImage, TInputSpatialObject, TSamp
}
auto indMin = m_Image->TransformPhysicalPointToIndex(ptMin);
auto indMax = m_Image->TransformPhysicalPointToIndex(ptMax);
auto [imageIndex, imageSize] = m_Image->GetLargestPossibleRegion();
const auto [imageIndex, imageSize] = m_Image->GetLargestPossibleRegion();
for (unsigned int i = 0; i < Self::ObjectDimension; ++i)
{
if (indMin[i] > indMax[i])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ MRIBiasFieldCorrectionFilter<TInputImage, TOutputImage, TMaskImage>::AdjustSlabR
SlabRegionVectorType & slabs,
OutputImageRegionType requestedRegion)
{
auto [indexFirst, size] = requestedRegion;
const auto [indexFirst, size] = requestedRegion;
OutputImageIndexType indexLast = indexFirst;

for (SizeValueType i = 0; i < ImageDimension; ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ FFTConvolutionImageFilter<TInputImage, TKernelImage, TOutputImage, TInternalPrec
float remainingProgress = 1.0f;

InputRegionType inputLargestRegion = input->GetLargestPossibleRegion();
auto [inputLargestIndex, inputLargestSize] = inputLargestRegion;
const auto [inputLargestIndex, inputLargestSize] = inputLargestRegion;
InputRegionType inputRequestedRegion = input->GetRequestedRegion();
auto [inputRequestedIndex, inputRequestedSize] = inputRequestedRegion;
const auto [inputRequestedIndex, inputRequestedSize] = inputRequestedRegion;
OutputRegionType outputRequestedRegion = this->GetOutput()->GetRequestedRegion();
auto [outputRequestedIndex, outputRequestedSize] = outputRequestedRegion;
const auto [outputRequestedIndex, outputRequestedSize] = outputRequestedRegion;

// Pad the input image such that the requested region, expanded by
// twice the kernel radius, lies entirely within the buffered region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ GaussianSmoothingOnUpdateTimeVaryingVelocityFieldTransform<TParametersValueType,

using TimeVaryingVelocityFieldIndexType = typename VelocityFieldType::IndexType;

auto [startIndex, size] = field->GetLargestPossibleRegion();
const auto [startIndex, size] = field->GetLargestPossibleRegion();

ImageRegionIteratorWithIndex<VelocityFieldType> fieldIt(field, field->GetLargestPossibleRegion());
ImageRegionConstIteratorWithIndex<VelocityFieldType> smoothedFieldIt(smoothField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ HalfToFullHermitianImageFilter<TInputImage>::DynamicThreadedGenerateData(

// Now copy the redundant complex conjugate region, if there is one
// in this thread's output region.
auto [outputRegionIndex, outputRegionSize] = outputRegionForThread;
const auto [outputRegionIndex, outputRegionSize] = outputRegionForThread;
OutputImageIndexType outputRegionMaximumIndex = outputRegionIndex + outputRegionSize;

if (outputRegionMaximumIndex[0] > inputRegionMaximumIndex[0])
Expand All @@ -140,7 +140,7 @@ HalfToFullHermitianImageFilter<TInputImage>::DynamicThreadedGenerateData(
for (unsigned int i = 0; i < ImageDimension; ++i)
{
OutputImageRegionType outputLargestPossibleRegion = outputPtr->GetLargestPossibleRegion();
auto [outputLargestPossibleRegionIndex, outputLargestPossibleRegionSize] = outputLargestPossibleRegion;
const auto [outputLargestPossibleRegionIndex, outputLargestPossibleRegionSize] = outputLargestPossibleRegion;
if (conjugateIndex[i] != outputLargestPossibleRegionIndex[i])
{
index[i] = outputLargestPossibleRegionSize[i] - conjugateIndex[i] + 2 * outputLargestPossibleRegionIndex[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class ITK_TEMPLATE_EXPORT FrequencyShiftedFFTLayoutImageRegionConstIteratorWithI
void
Init()
{
auto [minIndex, sizeImage] = this->m_Image->GetLargestPossibleRegion();
const auto [minIndex, sizeImage] = this->m_Image->GetLargestPossibleRegion();
for (unsigned int dim = 0; dim < ImageType::ImageDimension; ++dim)
{
this->m_ZeroFrequencyIndex[dim] =
Expand Down
2 changes: 1 addition & 1 deletion Modules/Filtering/ImageGrid/include/itkCropImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CropImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
SizeType sz;
OutputImageIndexType idx;

auto [input_idx, input_sz] = inputPtr->GetLargestPossibleRegion();
const auto [input_idx, input_sz] = inputPtr->GetLargestPossibleRegion();

for (unsigned int i = 0; i < InputImageDimension; ++i)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ MirrorPadImageFilter<TInputImage, TOutputImage>::ConvertOutputIndexToInputIndex(
long a, b, c; // Output region goes from a to a+b-1
// Input region goes from c to c+b-1
OutputImageIndexType outputRegionStart = outputRegion.GetIndex();
auto [inputRegionStart, inputSizes] = inputRegion;
const auto [inputRegionStart, inputSizes] = inputRegion;

for (dimCtr = 0; dimCtr < ImageDimension; ++dimCtr)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static bool
VerifyFilterOutput(const ShortImage * inputImage, const FloatImage * outputImage)
{
ShortImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion();
auto [inputIndex, inputSize] = inputRegion;
const auto [inputIndex, inputSize] = inputRegion;

ShortImage::RegionType outputRegion = outputImage->GetLargestPossibleRegion();
itk::ImageRegionConstIteratorWithIndex<FloatImage> outputIterator(outputImage, outputRegion);
Expand Down Expand Up @@ -105,10 +105,10 @@ VerifyFilter(const ShortImage * inputImage,
}

ShortImage::RegionType outputRegion = padFilter->GetOutput()->GetLargestPossibleRegion();
auto [outputIndex, outputSize] = outputRegion;
const auto [outputIndex, outputSize] = outputRegion;

ShortImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion();
auto [inputIndex, inputSize] = inputRegion;
const auto [inputIndex, inputSize] = inputRegion;

ShortImage::IndexType expectedIndex;
ShortImage::SizeType expectedSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ ProjectionImageFilter<TInputImage, TOutputImage, TAccumulator>::DynamicThreadedG

typename TInputImage::RegionType inputRegion = inputImage->GetLargestPossibleRegion();

auto [inputIndex, inputSize] = inputRegion;
const auto [inputIndex, inputSize] = inputRegion;

typename TOutputImage::Pointer outputImage = this->GetOutput();

auto [outputIndexForThread, outputSizeForThread] = outputRegionForThread;
const auto [outputIndexForThread, outputSizeForThread] = outputRegionForThread;

// compute the input region for this thread
typename TInputImage::RegionType inputRegionForThread = inputRegion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CropLabelMapFilter<TInputImage>::GenerateOutputInformation()
SizeType size;
IndexType index;

auto [inputIndex, inputSize] = inputPtr->GetLargestPossibleRegion();
const auto [inputIndex, inputSize] = inputPtr->GetLargestPossibleRegion();

SizeType originalCropSize = m_UpperBoundaryCropSize + m_LowerBoundaryCropSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PadLabelMapFilter<TInputImage>::GenerateOutputInformation()
SizeType size;
IndexType index;

auto [inputIndex, inputSize] = inputPtr->GetLargestPossibleRegion();
const auto [inputIndex, inputSize] = inputPtr->GetLargestPossibleRegion();

SizeType originalPadSize = m_UpperBoundaryPadSize + m_LowerBoundaryPadSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ NeedToDoFace(const TRegion AllImage, const TRegion face, const TLine line)
// find the small dimension of the face - should only be one
typename TRegion::IndexType ISt = AllImage.GetIndex();

auto [FSt, FSz] = face;
const auto [FSt, FSz] = face;

unsigned int smallDim = 0;
for (unsigned int i = 0; i < AllImage.GetImageDimension(); ++i)
Expand Down Expand Up @@ -89,7 +89,7 @@ ComputeStartEnd(const typename TImage::IndexType StartIndex,
unsigned int & end)
{
// compute intersection between ray and box
auto [ImStart, ImSize] = AllImage;
const auto [ImStart, ImSize] = AllImage;
float Tfar = NumericTraits<float>::max();
float Tnear = NumericTraits<float>::NonpositiveMin();
float domdir = NumericTraits<float>::NonpositiveMin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ BinomialBlurImageFilter<TInputImage, TOutputImage>::GenerateData()
tempPtr->Allocate();

// How big is the input image?
auto [startIndex, size] = inputPtr->GetRequestedRegion();
const auto [startIndex, size] = inputPtr->GetRequestedRegion();

// Iterator Typedefs for this routine
using TempIterator = ImageRegionIterator<TTempImage>;
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/GDCM/test/itkGDCMImageReadSeriesWriteTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ itkGDCMImageReadSeriesWriteTest(int argc, char * argv[])
ITK_TEST_SET_GET_VALUE(gdcmIO, seriesWriter->GetImageIO());

ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion();
auto [start, size] = region;
const auto [start, size] = region;


std::string format = outputDirectory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ itkImageFileWriterUpdateLargestPossibleRegionTest(int argc, char * argv[])
writer->SetFileName(argv[2]);

ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion();
auto [index, size] = region;
const auto [index, size] = region;

itk::ImageIORegion ioregion(2);
ioregion.SetIndex(0, index[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class NbTestClass : public NarrowBandImageFilterBase<TInputImageType, TOutputIma
CreateNarrowBand() override
{
// Create a band
auto [tl, sz] = this->GetInput()->GetRequestedRegion();
const auto [tl, sz] = this->GetInput()->GetRequestedRegion();
typename Superclass::IndexType in;

for (in [0] = 32 + tl[0]; in[0] < tl[0] + static_cast<long>(sz[0]); in[0]++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ SpatialNeighborSubsampler<TSample, TRegion>::Search(const InstanceIdentifier & q
SizeType searchSize;
IndexType endIndex;

auto [constraintIndex, constraintSize] = this->m_RegionConstraint;
const auto [constraintIndex, constraintSize] = this->m_RegionConstraint;

IndexType queryIndex;
typename RegionType::OffsetTableType offsetTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ UniformRandomSpatialNeighborSubsampler<TSample, TRegion>::Search(const InstanceI
IndexType searchStartIndex;
IndexType searchEndIndex;

auto [constraintIndex, constraintSize] = this->m_RegionConstraint;
const auto [constraintIndex, constraintSize] = this->m_RegionConstraint;

IndexType queryIndex;
typename RegionType::OffsetTableType offsetTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ MultiResolutionImageRegistrationMethod<TFixedImage, TMovingImage>::PreparePyrami
ScheduleType movingschedule = m_MovingImagePyramid->GetSchedule();
itkDebugMacro("MovingImage schedule: " << movingschedule);

auto [inputStart, inputSize] = m_FixedImageRegion;
const auto [inputStart, inputSize] = m_FixedImageRegion;

const SizeValueType numberOfLevels = m_FixedImagePyramid->GetNumberOfLevels();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod<
gradientField->SetRegions(virtualDomainImage->GetRequestedRegion());
gradientField->Allocate();

auto [gradientFieldIndex, gradientFieldSize] = gradientField->GetRequestedRegion();
const auto [gradientFieldIndex, gradientFieldSize] = gradientField->GetRequestedRegion();

SizeValueType localCount = 0;
for (ImageRegionConstIteratorWithOnlyIndex<DisplacementFieldType> ItG(gradientField,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage>::ConstructActi
ValueType value;
StatusType layer_number;

auto [startIndex, regionSize] = m_OutputImage->GetRequestedRegion();
const auto [startIndex, regionSize] = m_OutputImage->GetRequestedRegion();
using StartIndexValueType = IndexValueType;

for (NeighborhoodIterator<OutputImageType> outputIt(
Expand Down
2 changes: 1 addition & 1 deletion Modules/Video/Core/include/itkImageToVideoFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ ImageToVideoFilter<TInputImage, TOutputVideoStream>::GenerateOutputInformation()

// Get first input frame's largest possible spatial region
InputImageRegionType inputRegion = input->GetLargestPossibleRegion();
auto [inputIndex, inputSize] = inputRegion;
const auto [inputIndex, inputSize] = inputRegion;
typename InputImageType::SpacingType inputSpacing = input->GetSpacing();
typename InputImageType::PointType inputOrigin = input->GetOrigin();

Expand Down

0 comments on commit b4efee3

Please sign in to comment.