Skip to content

Commit 6fac7f2

Browse files
N-Dekkerhjmjohnson
authored andcommitted
STYLE: Replace Index var; var.Fill with auto var = Index::Filled
Follow-up to ITK pull request InsightSoftwareConsortium/ITK#4906 commit InsightSoftwareConsortium/ITK@3ff56ea
1 parent fe7bd2a commit 6fac7f2

File tree

15 files changed

+19
-38
lines changed

15 files changed

+19
-38
lines changed

src/Core/Common/AddOffsetToIndex/Code.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ main()
2626
{
2727
constexpr unsigned int Dimension = 2;
2828

29-
itk::Index<Dimension> index;
30-
index.Fill(5);
29+
auto index = itk::Index<Dimension>::Filled(5);
3130

3231
itk::Offset<Dimension> offset;
3332
offset.Fill(1);

src/Core/Common/CreateAnImageRegion/Code.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ main()
2626
using RegionType = itk::ImageRegion<Dimension>;
2727
auto size = RegionType::SizeType::Filled(3);
2828

29-
RegionType::IndexType index;
30-
index.Fill(1);
29+
auto index = RegionType::IndexType::Filled(1);
3130

3231
RegionType region(index, size);
3332

src/Core/Common/CropImageBySpecifyingRegion/Code.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ main()
3838

3939
std::cout << "Image largest region: " << image->GetLargestPossibleRegion() << std::endl;
4040

41-
ImageType::IndexType desiredStart;
42-
desiredStart.Fill(3);
41+
auto desiredStart = ImageType::IndexType::Filled(3);
4342

4443
auto desiredSize = ImageType::SizeType::Filled(4);
4544

@@ -60,8 +59,7 @@ main()
6059
output->DisconnectPipeline();
6160
output->FillBuffer(2);
6261

63-
itk::Index<2> index;
64-
index.Fill(5);
62+
auto index = itk::Index<2>::Filled(5);
6563

6664
std::cout << "new largest region: " << output->GetLargestPossibleRegion() << std::endl;
6765
std::cout << "new: " << (int)output->GetPixel(index) << std::endl;

src/Core/Common/DistanceBetweenIndices/Code.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
int
2626
main()
2727
{
28-
itk::Index<2> pixel1;
29-
pixel1.Fill(2);
28+
auto pixel1 = itk::Index<2>::Filled(2);
3029

31-
itk::Index<2> pixel2;
32-
pixel2.Fill(4);
30+
auto pixel2 = itk::Index<2>::Filled(4);
3331

3432
itk::Point<double, 2> p1;
3533
p1[0] = pixel1[0];

src/Core/Common/IterateImageStartingAtSeed/Code.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ CreateImage(ImageType::Pointer image)
7373
// Make a line
7474
for (unsigned int i = 20; i < 50; ++i)
7575
{
76-
itk::Index<2> pixelIndex;
77-
pixelIndex.Fill(i);
76+
auto pixelIndex = itk::Index<2>::Filled(i);
7877

7978
image->SetPixel(pixelIndex, 255);
8079
}

src/Core/ImageFunction/ComputeMedianOfImageAtPixel/Code.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ main()
3535
auto medianImageFunction = MedianImageFunctionType::New();
3636
medianImageFunction->SetInputImage(image);
3737

38-
itk::Index<2> index;
39-
index.Fill(10);
38+
auto index = itk::Index<2>::Filled(10);
4039
std::cout << "Median at " << index << " is " << static_cast<int>(medianImageFunction->EvaluateAtIndex(index))
4140
<< std::endl;
4241
return EXIT_SUCCESS;

src/Core/ImageFunction/MultiplyKernelWithAnImageAtLocation/Code.cxx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,21 @@ main()
4444
neighborhoodOperatorImageFunction->SetInputImage(image);
4545

4646
{
47-
itk::Index<2> index;
48-
index.Fill(20);
47+
auto index = itk::Index<2>::Filled(20);
4948

5049
float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
5150
std::cout << "Sum on border: " << output << std::endl;
5251
}
5352

5453
{
55-
itk::Index<2> index;
56-
index.Fill(35);
54+
auto index = itk::Index<2>::Filled(35);
5755

5856
float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
5957
std::cout << "Sum in center: " << output << std::endl;
6058
}
6159

6260
{
63-
itk::Index<2> index;
64-
index.Fill(7);
61+
auto index = itk::Index<2>::Filled(7);
6562

6663
float output = neighborhoodOperatorImageFunction->EvaluateAtIndex(index);
6764
std::cout << "Sum outside: " << output << std::endl;

src/Filtering/Convolution/ColorNormalizedCorrelation/Code.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ main(int argc, char * argv[])
6060

6161
auto extractFilter = ExtractFilterType::New();
6262

63-
FloatImageType::IndexType start;
64-
start.Fill(50);
63+
auto start = FloatImageType::IndexType::Filled(50);
6564

6665
auto patchSize = FloatImageType::SizeType::Filled(51);
6766

src/Filtering/Convolution/NormalizedCorrelation/Code.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ main(int argc, char * argv[])
4949

5050
auto extractFilter = ExtractFilterType::New();
5151

52-
FloatImageType::IndexType start;
53-
start.Fill(50);
52+
auto start = FloatImageType::IndexType::Filled(50);
5453

5554
auto patchSize = FloatImageType::SizeType::Filled(51);
5655

src/Filtering/DistanceMap/ApproxDistanceMapOfBinary/Code.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ CreateImage(UnsignedCharImageType::Pointer image)
8585
// Create a line of white pixels
8686
for (unsigned int i = 40; i < 60; ++i)
8787
{
88-
itk::Index<2> pixel;
89-
pixel.Fill(i);
88+
auto pixel = itk::Index<2>::Filled(i);
9089
image->SetPixel(pixel, 255);
9190
}
9291
}

0 commit comments

Comments
 (0)