Skip to content

Commit

Permalink
STYLE: Replace Size var; var.Fill with auto var = Size::Filled
Browse files Browse the repository at this point in the history
Using Notepad++, Replace in Files, doing:

    Find what: ^([ ]+ )(typename )?(.*Size.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\4\.Fill\(
    Replace with: $1auto $4 = $3::Filled\(
    Filters: itk*.h;itk*.hxx;itk*.cxx
    [v] Match case
    (*) Regular expression

Follow-up to pull request #4887
commit be250b8
"STYLE: Replace `size.Fill` with `auto size = Size::Filled` in tests"
  • Loading branch information
N-Dekker authored and dzenanz committed Oct 29, 2024
1 parent 6a66f93 commit 7fd1e73
Show file tree
Hide file tree
Showing 41 changed files with 62 additions and 117 deletions.
3 changes: 1 addition & 2 deletions Modules/Core/Common/include/itkDerivativeOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ namespace itk
using DerivativeOperatorType = itk::DerivativeOperator<float, 2>;
DerivativeOperatorType derivativeOperator;
derivativeOperator.SetDirection(0); // X dimension
itk::Size<2> radius;
radius.Fill(1); // A radius of 1 in both dimensions is a 3x3 operator
auto radius = itk::Size<2>::Filled(1); // A radius of 1 in both dimensions is a 3x3 operator
derivativeOperator.CreateToRadius(radius);
\endcode
* and creates a kernel that looks like:
Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Common/include/itkLaplacianOperator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ LaplacianOperator<TPixel, VDimension, TAllocator>::GenerateCoefficients() -> Coe

// Here we set the radius to 1's, here the
// operator is 3x3 for 2D, 3x3x3 for 3D.
SizeType r;

r.Fill(1);
auto r = SizeType::Filled(1);
this->SetRadius(r);

// Create a vector of the correct size to hold the coefficients.
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/include/itkSobelOperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ namespace itk
* 1) Set the direction by calling \code SetDirection \endcode
* 2) call
\code
itk::Size<2> radius;
radius.Fill(1);
auto radius = itk::Size<2>::Filled(1);
sobelOperator.CreateToRadius(radius);
\endcode
* 3) You may optionally scale the coefficients of this operator using the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ CovarianceImageFunction<TInputImage, TCoordRep>::EvaluateAtIndex(const IndexType
mean.fill(PixelComponentRealType{});

// Create an N-d neighborhood kernel, using a zeroflux boundary condition
typename InputImageType::SizeType kernelSize;
kernelSize.Fill(m_NeighborhoodRadius);
auto kernelSize = InputImageType::SizeType::Filled(m_NeighborhoodRadius);

ConstNeighborhoodIterator<InputImageType> it(
kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ ScatterMatrixImageFunction<TInputImage, TCoordRep>::EvaluateAtIndex(const IndexT
}

// Create an N-d neighborhood kernel, using a zeroflux boundary condition
typename InputImageType::SizeType kernelSize;
kernelSize.Fill(m_NeighborhoodRadius);
auto kernelSize = InputImageType::SizeType::Filled(m_NeighborhoodRadius);

ConstNeighborhoodIterator<InputImageType> it(
kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ VarianceImageFunction<TInputImage, TCoordRep>::EvaluateAtIndex(const IndexType &
}

// Create an N-d neighborhood kernel, using a zeroflux boundary condition
typename InputImageType::SizeType kernelSize;
kernelSize.Fill(m_NeighborhoodRadius);
auto kernelSize = InputImageType::SizeType::Filled(m_NeighborhoodRadius);

ConstNeighborhoodIterator<InputImageType> it(
kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ VectorMeanImageFunction<TInputImage, TCoordRep>::EvaluateAtIndex(const IndexType
}

// Create an N-d neighborhood kernel, using a zeroflux boundary condition
typename InputImageType::SizeType kernelSize;
kernelSize.Fill(m_NeighborhoodRadius);
auto kernelSize = InputImageType::SizeType::Filled(m_NeighborhoodRadius);

ConstNeighborhoodIterator<InputImageType> it(
kernelSize, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ class ITK_TEMPLATE_EXPORT WindowedSincInterpolateImageFunction : public Interpol
SizeType
GetRadius() const override
{
SizeType radius;
radius.Fill(VRadius);
auto radius = SizeType::Filled(VRadius);
return radius;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ WindowedSincInterpolateImageFunction<TInputImage, VRadius, TWindowFunction, TBou
}

// Set the radius for the neighborhood
Size<ImageDimension> radius;
radius.Fill(VRadius);
auto radius = Size<ImageDimension>::Filled(VRadius);

// Initialize the neighborhood
IteratorType it(radius, image, image->GetBufferedRegion());
Expand Down Expand Up @@ -145,8 +144,7 @@ WindowedSincInterpolateImageFunction<TInputImage, VRadius, TWindowFunction, TBou
}

// Position the neighborhood at the index of interest
Size<ImageDimension> radius;
radius.Fill(VRadius);
auto radius = Size<ImageDimension>::Filled(VRadius);
IteratorType nit(radius, this->GetInputImage(), this->GetInputImage()->GetBufferedRegion());
nit.SetLocation(baseIndex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,7 @@ BSplineDeformableTransform<TParametersValueType, VDimension, VSplineOrder>::Comp
// Zero all components of jacobian
jacobian.SetSize(SpaceDimension, this->GetNumberOfParameters());
jacobian.Fill(0.0);
SizeType supportSize;
supportSize.Fill(SplineOrder + 1);
auto supportSize = SizeType::Filled(SplineOrder + 1);

ContinuousIndexType index =
this->m_CoefficientImages[0]
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Transform/include/itkBSplineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ BSplineTransform<TParametersValueType, VDimension, VSplineOrder>::BSplineTransfo

DirectionType meshDirection;
meshDirection.SetIdentity();
MeshSizeType meshSize;
meshSize.Fill(1);
auto meshSize = MeshSizeType::Filled(1);

this->m_FixedParameters.SetSize(VDimension * (VDimension + 3));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ BinaryDilateImageFilter<TInputImage, TOutputImage, TKernel>::GenerateData()
typename InputImageType::ConstPointer input = this->GetInput();

// Get values from superclass
InputPixelType foregroundValue = this->GetForegroundValue();
InputPixelType backgroundValue = this->GetBackgroundValue();
KernelType kernel = this->GetKernel();
InputSizeType radius;
radius.Fill(1);
InputPixelType foregroundValue = this->GetForegroundValue();
InputPixelType backgroundValue = this->GetBackgroundValue();
KernelType kernel = this->GetKernel();
auto radius = InputSizeType::Filled(1);
typename TOutputImage::RegionType outputRegion = output->GetBufferedRegion();

// compute the size of the temp image. It is needed to create the progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ BinaryErodeImageFilter<TInputImage, TOutputImage, TKernel>::GenerateData()
typename InputImageType::ConstPointer input = this->GetInput();

// Get values from superclass
InputPixelType foregroundValue = this->GetForegroundValue();
InputPixelType backgroundValue = this->GetBackgroundValue();
KernelType kernel = this->GetKernel();
InputSizeType radius;
radius.Fill(1);
InputPixelType foregroundValue = this->GetForegroundValue();
InputPixelType backgroundValue = this->GetBackgroundValue();
KernelType kernel = this->GetKernel();
auto radius = InputSizeType::Filled(1);
typename TOutputImage::RegionType outputRegion = output->GetBufferedRegion();

// compute the size of the temp image. It is needed to create the progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ BinaryMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::AnalyzeKernel()
ImageRegionIteratorWithIndex<BoolImageType> kernelImageItIndex(tmpSEImage, tmpSEImage->GetRequestedRegion());

// Neighborhood iterator on SE element temp image
InputSizeType padBy;
padBy.Fill(1);
auto padBy = InputSizeType::Filled(1);
NeighborhoodIterator<BoolImageType> SEoNeighbIt(padBy, tmpSEImage, tmpSEImage->GetRequestedRegion());
SEoNeighbIt.OverrideBoundaryCondition(&cbc);
SizeValueType neighborhoodSize = SEoNeighbIt.Size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::InitializePatchWeight

// Allocate the patch weights (mask) as an image.
// Done in physical space.
typename WeightsImageType::SizeType physicalSize;
physicalSize.Fill(physicalDiameter);
auto physicalSize = WeightsImageType::SizeType::Filled(physicalDiameter);
typename WeightsImageType::RegionType physicalRegion(physicalSize);
auto physicalWeightsImage = WeightsImageType::New();
physicalWeightsImage->SetRegions(physicalRegion);
Expand Down Expand Up @@ -681,8 +680,7 @@ typename PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::ThreadDataSt
using FaceCalculatorType = typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>;
using FaceListType = typename FaceCalculatorType::FaceListType;

typename InputImageType::SizeType radius;
radius.Fill(1);
auto radius = InputImageType::SizeType::Filled(1);

if (m_NumIndependentComponents != 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ ContourDirectedMeanDistanceImageFilter<TInputImage1, TInputImage2>::ThreadedGene
InputImage1ConstPointer input = this->GetInput();

// Find the data-set boundary "faces"
SizeType radius;
radius.Fill(1);
auto radius = SizeType::Filled(1);

using FaceListType = typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImage1Type>::FaceListType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ FastMarchingImageFilterBase<TInput, TOutput>::FastMarchingImageFilterBase()
m_StartIndex.Fill(0);
m_LastIndex.Fill(0);

OutputSizeType outputSize;
outputSize.Fill(16);
auto outputSize = OutputSizeType::Filled(16);

NodeType outputIndex{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>::ThreadedCompute2ndDeri
typename OutputImageType::Pointer input = m_GaussianFilter->GetOutput();

// Set iterator radius
Size<ImageDimension> radius;
radius.Fill(1);
auto radius = Size<ImageDimension>::Filled(1);

// Find the data-set boundary "faces"
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
Expand Down Expand Up @@ -322,8 +321,7 @@ CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>::FollowEdge(IndexType
ListNodeType * node;

// Assign iterator radius
Size<ImageDimension> radius;
radius.Fill(1);
auto radius = Size<ImageDimension>::Filled(1);

ConstNeighborhoodIterator<TOutputImage> oit(
radius, multiplyImageFilterOutput, multiplyImageFilterOutput->GetRequestedRegion());
Expand Down Expand Up @@ -398,8 +396,7 @@ CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>::ThreadedCompute2ndDeri
typename InputImageType::Pointer output = m_UpdateBuffer1;

// Set iterator radius
Size<ImageDimension> radius;
radius.Fill(1);
auto radius = Size<ImageDimension>::Filled(1);

// Find the data-set boundary "faces"
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ MaskFeaturePointSelectionFilter<TImage, TMask, TFeatures>::GenerateData()
if (m_ComputeStructureTensors)
{
// tensor calculations access points in 2 X m_BlockRadius + 1 radius
SizeType onesSize;
onesSize.Fill(1);
auto onesSize = SizeType::Filled(1);
// Define the area in which tensors are going to be computed.
const SizeType blockSize = m_BlockRadius + m_BlockRadius + onesSize;
safeIndex += blockSize;
Expand Down Expand Up @@ -231,8 +230,7 @@ MaskFeaturePointSelectionFilter<TImage, TMask, TFeatures>::GenerateData()

Matrix<SpacePrecisionType, ImageDimension, 1> gradI; // vector declared as column matrix

SizeType radius;
radius.Fill(1); // iterate over neighbourhood of a voxel
auto radius = SizeType::Filled(1); // iterate over neighbourhood of a voxel

RegionType center;
center.SetSize(radius);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ LabelMapContourOverlayImageFilter<TLabelMap, TFeatureImage, TOutputImage>::Label
m_Opacity = 0.5;
m_Type = CONTOUR;
m_Priority = HIGH_LABEL_ON_TOP;
SizeType s;
s.Fill(1);
auto s = SizeType::Filled(1);
m_ContourThickness = SizeType(s);
s.Fill(0);
m_DilationRadius = SizeType(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ BSplineControlPointImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenera
collapsedPhiLattices[i] = PointDataImageType::New();
collapsedPhiLattices[i]->CopyInformation(inputPtr);

typename PointDataImageType::SizeType size;
size.Fill(1);
auto size = PointDataImageType::SizeType::Filled(1);
for (unsigned int j = 0; j < i; ++j)
{
size[j] = inputPtr->GetLargestPossibleRegion().GetSize()[j];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage>::Threade
collapsedPhiLattices[i] = PointDataImageType::New();
collapsedPhiLattices[i]->CopyInformation(this->m_PhiLattice);

typename PointDataImageType::SizeType size;
size.Fill(1);
auto size = PointDataImageType::SizeType::Filled(1);
for (unsigned int j = 0; j < i; ++j)
{
size[j] = this->m_PhiLattice->GetLargestPossibleRegion().GetSize()[j];
Expand Down Expand Up @@ -886,8 +885,7 @@ BSplineScatteredDataPointSetToImageFilter<TInputPointSet, TOutputImage>::Threade
collapsedPhiLattices[i]->SetSpacing(this->m_PhiLattice->GetSpacing());
collapsedPhiLattices[i]->SetDirection(this->m_PhiLattice->GetDirection());

typename PointDataImageType::SizeType size;
size.Fill(1);
auto size = PointDataImageType::SizeType::Filled(1);
for (unsigned int j = 0; j < i; ++j)
{
size[j] = this->m_PhiLattice->GetLargestPossibleRegion().GetSize()[j];
Expand Down
6 changes: 2 additions & 4 deletions Modules/Filtering/ImageGrid/include/itkTileImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ TileImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()

// Determine the last dimension for the tile image. This dimension will
// be large enough to accommodate left-over images.
OutputSizeType outputSize;
outputSize.Fill(1);
auto outputSize = OutputSizeType::Filled(1);

if (m_Layout[OutputImageDimension - 1] == 0)
{
Expand All @@ -216,8 +215,7 @@ TileImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
m_Layout[OutputImageDimension - 1] = outputSize[OutputImageDimension - 1];
}

OutputSizeType tileSize;
tileSize.Fill(1);
auto tileSize = OutputSizeType::Filled(1);

for (unsigned int i = 0; i < OutputImageDimension; ++i)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ class ScanlineFilterCommon

LineRegion.SetSize(PretendSize);
fakeImage->SetRegions(LineRegion);
PretendSizeType kernelRadius;
kernelRadius.Fill(1);
auto kernelRadius = PretendSizeType::Filled(1);
LineNeighborhoodType lnit(kernelRadius, fakeImage, LineRegion);

if (wholeNeighborhood)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ ShapeLabelMapFilter<TImage, TLabelImage>::ComputeFeretDiameter(LabelObjectType *
IndexListType idxList;

using NeighborIteratorType = typename itk::ConstNeighborhoodIterator<LabelImageType>;
SizeType neighborHoodRadius;
neighborHoodRadius.Fill(1);
auto neighborHoodRadius = SizeType::Filled(1);
NeighborIteratorType it(neighborHoodRadius, m_LabelImage, m_LabelImage->GetBufferedRegion());
ConstantBoundaryCondition<LabelImageType> lcbc;
// Use label + 1 to have a label different of the current label on the border
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ ReconstructionImageFilter<TInputImage, TOutputImage, TCompare>::GenerateData()
NOutputIterator outNIt;
InputIteratorType mskIt;
CNInputIterator mskNIt;
ISizeType kernelRadius;
kernelRadius.Fill(1);
auto kernelRadius = ISizeType::Filled(1);
if (m_UseInternalCopy)
{
FaceCalculatorType faceCalculator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ ValuedRegionalExtremaImageFilter<TInputImage, TOutputImage, TFunction1, TFunctio
// Note : all comments refer to finding regional minima, because
// it is briefer and clearer than trying to describe both regional
// maxima and minima processes at the same time
ISizeType kernelRadius;
kernelRadius.Fill(1);
auto kernelRadius = ISizeType::Filled(1);
NOutputIterator outNIt(kernelRadius, output, output->GetRequestedRegion());
setConnectivity(&outNIt, m_FullyConnected);

Expand Down
13 changes: 5 additions & 8 deletions Modules/Filtering/Smoothing/include/itkBoxUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ BoxAccumulateFunction(const TInputImage * inputImage,
using InputIterator = ImageRegionConstIterator<TInputImage>;

using NOutputIterator = ShapedNeighborhoodIterator<TOutputImage>;
InputIterator inIt(inputImage, inputRegion);
typename TInputImage::SizeType kernelRadius;
kernelRadius.Fill(1);
InputIterator inIt(inputImage, inputRegion);
auto kernelRadius = TInputImage::SizeType::Filled(1);

NOutputIterator noutIt(kernelRadius, outputImage, outputRegion);
// this iterator is fully connected
Expand Down Expand Up @@ -165,8 +164,7 @@ std::vector<typename TImage::OffsetType>
CornerOffsets(const TImage * im)
{
using NIterator = ShapedNeighborhoodIterator<TImage>;
typename TImage::SizeType unitradius;
unitradius.Fill(1);
auto unitradius = TImage::SizeType::Filled(1);
NIterator n1(unitradius, im, im->GetRequestedRegion());
unsigned int centerIndex = n1.GetCenterNeighborhoodIndex();
typename NIterator::OffsetType offset;
Expand Down Expand Up @@ -564,9 +562,8 @@ BoxSquareAccumulateFunction(const TInputImage * inputImage,
using InputIterator = ImageRegionConstIterator<TInputImage>;

using NOutputIterator = ShapedNeighborhoodIterator<TOutputImage>;
InputIterator inIt(inputImage, inputRegion);
typename TInputImage::SizeType kernelRadius;
kernelRadius.Fill(1);
InputIterator inIt(inputImage, inputRegion);
auto kernelRadius = TInputImage::SizeType::Filled(1);

NOutputIterator noutIt(kernelRadius, outputImage, outputRegion);
// this iterator is fully connected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ FFTDiscreteGaussianImageFilter<TInputImage, TOutputImage>::GenerateKernelImage()
kernelSource->SetOrigin(inputOrigin);
kernelSource->SetDirection(this->GetInput()->GetDirection());

KernelSizeType kernelSize;
kernelSize.Fill(1);
auto kernelSize = KernelSizeType::Filled(1);
for (size_t dim = 0; dim < this->GetFilterDimensionality(); ++dim)
{
kernelSize[dim] = static_cast<SizeValueType>(this->GetKernelRadius(dim)) * 2 + 1;
Expand Down
Loading

0 comments on commit 7fd1e73

Please sign in to comment.