Skip to content

Commit 495d45b

Browse files
committed
STYLE: Remove IndexType index{0} from region initialization in tests
Removed `IndexType` variables initialized by zero's (`{ 0, ..., 0 }`), that were only there as the index argument of a region initialization. Using Notepad++, Replace in Files (Search Mode: Regular expression), doing: Find what: `^( [ ]+)constexpr IndexType[ ]+(\w+){[0, ]*};[\r\n]+\1(.*[rR]egion.* \w+)\(\2, (.*)\);$` Find what: `^( [ ]+)constexpr IndexType[ ]+(\w+){[0, ]*};[\r\n]+\1(.*[rR]egion.* \w+){ \2, (.*) }];$` Find what: `^( [ ]+)constexpr IndexType[ ]+(\w+){[0, ]*};[\r\n]+\1(.*[rR]egion.* \w+) = { \2, (.*) };$` Replace with: $1$3{ $4 }; Manually fixed itkCenteredVersorTransformInitializerTest.cxx compile errors after removing `index`. Removed `IndexType` that have become unused with this commit. Follow-up to pull request #5627 commit f9885d2 "STYLE: Remove `T::IndexType index{}` from region initialization in tests"
1 parent 2d7b402 commit 495d45b

14 files changed

+34
-64
lines changed

Modules/Core/Common/test/itkConstantBoundaryConditionTest.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ int
121121
itkConstantBoundaryConditionTest(int, char *[])
122122
{
123123
// Test an image to cover one operator() method.
124-
auto image = ImageType::New();
125-
constexpr SizeType imageSize{ 5, 5 };
126-
constexpr IndexType imageIndex{ 0, 0 };
127-
RegionType imageRegion{ imageIndex, imageSize };
124+
auto image = ImageType::New();
125+
constexpr SizeType imageSize{ 5, 5 };
126+
RegionType imageRegion{ imageSize };
128127
image->SetRegions(imageRegion);
129128
image->Allocate();
130129

Modules/Core/Common/test/itkPeriodicBoundaryConditionTest.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ itkPeriodicBoundaryConditionTest(int, char *[])
124124
// Test an image to cover one operator() method.
125125
auto image = ImageType::New();
126126

127-
constexpr SizeType imageSize{ 5, 5 };
128-
constexpr IndexType imageIndex{ 0, 0 };
129-
const RegionType imageRegion(imageIndex, imageSize);
127+
constexpr SizeType imageSize{ 5, 5 };
128+
const RegionType imageRegion{ imageSize };
130129
image->SetRegions(imageRegion);
131130
image->Allocate();
132131

Modules/Core/Common/test/itkZeroFluxBoundaryConditionTest.cxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,8 @@ itkZeroFluxBoundaryConditionTest(int, char *[])
124124
// Test an image to cover one operator() method.
125125
auto image = ImageType::New();
126126

127-
constexpr SizeType imageSize{ 5, 5 };
128-
constexpr IndexType imageIndex{ 0, 0 };
129-
const RegionType imageRegion{ imageIndex, imageSize };
127+
constexpr SizeType imageSize{ 5, 5 };
128+
const RegionType imageRegion{ imageSize };
130129
image->SetRegions(imageRegion);
131130
image->Allocate();
132131

Modules/Filtering/ImageIntensity/test/itkDivideImageFilterTest2.cxx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ itkDivideImageFilterTest2(int, char *[])
4040
// Declare appropriate Iterator types for each image
4141
using OutputImageIteratorType = itk::ImageRegionIteratorWithIndex<OutputImageType>;
4242

43-
44-
// Declare the type of the index to access images
45-
using IndexType = itk::Index<Dimension>;
46-
4743
// Declare the type of the size
4844
using SizeType = itk::Size<Dimension>;
4945

@@ -55,9 +51,8 @@ itkDivideImageFilterTest2(int, char *[])
5551
auto inputImageB = InputImageType2::New();
5652

5753
// Define their size, and start index
58-
constexpr SizeType size{ 2, 2, 2 };
59-
constexpr IndexType start{ 0, 0, 0 };
60-
RegionType region{ start, size };
54+
constexpr SizeType size{ 2, 2, 2 };
55+
RegionType region{ size };
6156

6257
// Initialize Image A
6358
inputImageA->SetRegions(region);

Modules/Filtering/MathematicalMorphology/test/itkOpeningByReconstructionImageFilterTest2.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ itkOpeningByReconstructionImageFilterTest2(int argc, char * argv[])
4141
using OutputImageType = itk::Image<PixelType, Dimension>;
4242
using RegionType = InputImageType::RegionType;
4343
using SizeType = InputImageType::SizeType;
44-
using IndexType = InputImageType::IndexType;
4544
using SpacingType = InputImageType::SpacingType;
4645
using OriginType = InputImageType::PointType;
4746

@@ -56,9 +55,8 @@ itkOpeningByReconstructionImageFilterTest2(int argc, char * argv[])
5655
auto inputImage = InputImageType::New();
5756

5857
// Define regions of input image
59-
auto size = SizeType::Filled(std::stoi(argv[2]));
60-
constexpr IndexType index{};
61-
RegionType region = { index, size };
58+
auto size = SizeType::Filled(std::stoi(argv[2]));
59+
RegionType region{ size };
6260

6361
// fill spacing and origin
6462
OriginType origin;

Modules/Numerics/Statistics/test/itkGaussianRandomSpatialNeighborSubsamplerTest.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ itkGaussianRandomSpatialNeighborSubsamplerTest(int argc, char * argv[])
4848
using SamplerType = itk::Statistics::GaussianRandomSpatialNeighborSubsampler<AdaptorType, RegionType>;
4949
using WriterType = itk::ImageFileWriter<FloatImage>;
5050

51-
auto inImage = FloatImage::New();
52-
auto sz = SizeType::Filled(35);
53-
constexpr IndexType idx{};
54-
const RegionType region{ idx, sz };
51+
auto inImage = FloatImage::New();
52+
auto sz = SizeType::Filled(35);
53+
const RegionType region{ sz };
5554

5655
inImage->SetRegions(region);
5756
inImage->AllocateInitialized();

Modules/Numerics/Statistics/test/itkSpatialNeighborSubsamplerTest.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ itkSpatialNeighborSubsamplerTest(int, char *[])
7777
using SamplerType = itk::Statistics::SpatialNeighborSubsampler<AdaptorType, RegionType>;
7878
using IteratorType = itk::ImageRegionConstIteratorWithIndex<ImageType>;
7979

80-
auto inImage = ImageType::New();
81-
constexpr auto sz = SizeType::Filled(25);
82-
constexpr IndexType idx{};
83-
const RegionType region{ idx, sz };
80+
auto inImage = ImageType::New();
81+
constexpr auto sz = SizeType::Filled(25);
82+
const RegionType region{ sz };
8483

8584
inImage->SetRegions(region);
8685
inImage->AllocateInitialized();

Modules/Numerics/Statistics/test/itkUniformRandomSpatialNeighborSubsamplerTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ itkUniformRandomSpatialNeighborSubsamplerTest(int argc, char * argv[])
5252
auto inImage = FloatImage::New();
5353
constexpr typename SizeType::value_type regionSizeVal = 35;
5454
constexpr auto sz = SizeType::Filled(regionSizeVal);
55-
constexpr IndexType idx{};
56-
const RegionType region{ idx, sz };
55+
const RegionType region{ sz };
5756

5857
inImage->SetRegions(region);
5958
inImage->AllocateInitialized();

Modules/Registration/Common/test/itkCenteredVersorTransformInitializerTest.cxx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ itkCenteredVersorTransformInitializerTest(int, char *[])
5353
// Transform Type
5454
using TransformType = itk::VersorRigid3DTransform<double>;
5555

56-
SizeType size{ { 100, 100, 150 } };
57-
PointType fixedOrigin{};
58-
PointType movingOrigin{ { 29.0, 17.0, 13.0 } };
59-
SpacingType spacing{ { 1.5, 1.5, 1.0 } };
60-
constexpr IndexType index{};
61-
62-
const RegionType region{ index, size };
56+
SizeType size{ { 100, 100, 150 } };
57+
PointType fixedOrigin{};
58+
PointType movingOrigin{ { 29.0, 17.0, 13.0 } };
59+
SpacingType spacing{ { 1.5, 1.5, 1.0 } };
60+
const RegionType region{ size };
6361

6462

6563
auto fixedImage = FixedImageType::New();
@@ -79,9 +77,9 @@ itkCenteredVersorTransformInitializerTest(int, char *[])
7977
SizeType internalSize;
8078
IndexType internalIndex;
8179

82-
internalIndex[0] = index[0] + 20;
83-
internalIndex[1] = index[1] + 30;
84-
internalIndex[2] = index[2] + 10;
80+
internalIndex[0] = 20;
81+
internalIndex[1] = 30;
82+
internalIndex[2] = 10;
8583

8684
internalSize[0] = size[0] - 2 * 20;
8785
internalSize[1] = size[1] - 2 * 30;
@@ -101,9 +99,9 @@ itkCenteredVersorTransformInitializerTest(int, char *[])
10199
}
102100

103101

104-
internalIndex[0] = index[0] + 10;
105-
internalIndex[1] = index[1] + 20;
106-
internalIndex[2] = index[2] + 30;
102+
internalIndex[0] = 10;
103+
internalIndex[1] = 20;
104+
internalIndex[2] = 30;
107105

108106
internalSize[0] = size[0] - 2 * 10;
109107
internalSize[1] = size[1] - 2 * 20;

Modules/Registration/PDEDeformable/test/itkDemonsRegistrationFilterTest.cxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ itkDemonsRegistrationFilterTest(int, char *[])
116116
using ImageType = itk::Image<PixelType, ImageDimension>;
117117
using VectorType = itk::Vector<float, ImageDimension>;
118118
using FieldType = itk::Image<VectorType, ImageDimension>;
119-
using IndexType = ImageType::IndexType;
120119
using SizeType = ImageType::SizeType;
121120
using RegionType = ImageType::RegionType;
122121

@@ -126,9 +125,7 @@ itkDemonsRegistrationFilterTest(int, char *[])
126125
SizeType size;
127126
size.SetSize(sizeArray);
128127

129-
constexpr IndexType index{};
130-
131-
const RegionType region{ index, size };
128+
const RegionType region{ size };
132129

133130
auto moving = ImageType::New();
134131
auto fixed = ImageType::New();

0 commit comments

Comments
 (0)