Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Replace Fill(0.) and Fill(0u) with {} initializer for local variables in tests #4884

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Modules/Bridge/VtkGlue/test/itkImageToVTKImageFilterTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ itkImageToVTKImageFilterTest(int, char *[])
origin[0] = -1.5;
origin[1] = 0.222;
origin[2] = 0;
DirectionType direction;
direction.Fill(0.0);
DirectionType direction{};
direction[0][1] = 1;
direction[1][0] = -1;
direction[2][2] = 0.7;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkImageTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class TestTransform
OutputPointType
TransformPoint(const InputPointType & inputPoint) const
{
OutputPointType outputPoint;
outputPoint.Fill(0.0);
OutputPointType outputPoint{};
// if InputPoint Dimension < 2 then embed point in 2D space
// else project the point to 2D space.
for (unsigned int d = 0; d < std::min(inputPoint.GetPointDimension(), outputPoint.GetPointDimension()); ++d)
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkMatrixTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ itkMatrixTest(int, char *[])

using vnlVectorType = vnl_vector_fixed<NumericType, 3>;

MatrixType matrix;
matrix.Fill(0.0);
MatrixType matrix{};
matrix.SetIdentity();

VectorType v1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ itkRayCastInterpolateImageFunctionTest(int itkNotUsed(argc), char * itkNotUsed(a
image->SetRegions(region);
image->Allocate();

PointType origin;
origin.Fill(0.0);
PointType origin{};

SpacingType spacing;
spacing.Fill(1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ InternalTest(int argc, char * argv[])
imageIterator.GoToBegin();

using PointType = typename InputMeshType::PointType;
PointType point;
point.Fill(0.);
PointType point{};

using PointDataContainer = typename InputMeshType::PointDataContainer;
using PointDataContainerPointer = typename InputMeshType::PointDataContainerPointer;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Mesh/test/itkSphereMeshSourceTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ itkSphereMeshSourceTest(int, char *[])
// itk::Mesh<float>::PointsContainer::Iterator m_output = myoutput->Begin();

IPT * pt_ptr;
IPT pt;
pt.Fill(0.0);
IPT pt{};
pt_ptr = &pt;

for (int i = 0; i < 12; ++i)
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Mesh/test/itkVTKPolyDataWriterTest02.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ itkVTKPolyDataWriterTest02(int argc, char * argv[])

MeshType::Pointer myMesh = mySphereMeshSource->GetOutput();

PointType pt;
pt.Fill(0.);
PointType pt{};

bool testPassed = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1(int argc, char * argv[])
using PointType = SphereMeshSourceType::PointType;
using VectorType = SphereMeshSourceType::VectorType;

PointType center;
center.Fill(0.0);
PointType center{};

VectorType scale;
scale.Fill(1.0);
Expand All @@ -62,8 +61,7 @@ itkQuadEdgeMeshScalarDataVTKPolyDataWriterTest1(int argc, char * argv[])

MeshType::Pointer myMesh = mySphereMeshSource->GetOutput();

PointType pt;
pt.Fill(0.);
PointType pt{};

myMesh->Print(std::cout);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ itkGaussianSpatialObjectTest(int, char *[])
myGaussian->SetSigmaInObjectSpace(sigma);
ITK_TEST_SET_GET_VALUE(sigma, myGaussian->GetSigmaInObjectSpace());

GaussianType::PointType center;
center.Fill(0.0);
GaussianType::PointType center{};
myGaussian->SetCenterInObjectSpace(center);
ITK_TEST_SET_GET_VALUE(center, myGaussian->GetCenterInObjectSpace());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ itkImageMaskSpatialObjectTest3(int, char *[])

ImageType::IndexType index{};

ImageType::DirectionType direction;
direction.Fill(0.0);
ImageType::DirectionType direction{};
direction[0][1] = 1;
direction[1][0] = 1;
direction[2][2] = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ itkBSplineDeformableTransformTest1()
*/

using OriginType = TransformType::OriginType;
OriginType origin;
origin.Fill(0.0);
OriginType origin{};

using RegionType = TransformType::RegionType;
RegionType region;
Expand Down Expand Up @@ -598,8 +597,7 @@ itkBSplineDeformableTransformTest3()
*/

using OriginType = TransformType::OriginType;
OriginType origin;
origin.Fill(0.0);
OriginType origin{};

using RegionType = TransformType::RegionType;
RegionType region;
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Transform/test/itkBSplineTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ itkBSplineTransformTest1()
*/

using OriginType = TransformType::OriginType;
OriginType origin;
origin.Fill(0.0);
OriginType origin{};

using PhysicalDimensionsType = TransformType::PhysicalDimensionsType;
PhysicalDimensionsType dimensions;
Expand Down Expand Up @@ -615,8 +614,7 @@ itkBSplineTransformTest3()
*/

using OriginType = TransformType::OriginType;
OriginType origin;
origin.Fill(0.0);
OriginType origin{};

using PhysicalDimensionsType = TransformType::PhysicalDimensionsType;
PhysicalDimensionsType dimensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ itkQuaternionRigidTransformTest(int, char *[])
rotation->SetIdentity();
rotation->SetRotation(qrotation);

TransformType::OffsetType ioffset;
ioffset.Fill(0.0f);
TransformType::OffsetType ioffset{};

// rotation->ComputeOffset();

Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Transform/test/itkRigid2DTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ itkRigid2DTransformTest(int, char *[])
return EXIT_FAILURE;
}

TransformType::OffsetType ioffset;
ioffset.Fill(0.0f);
TransformType::OffsetType ioffset{};

rotation->SetOffset(ioffset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ itkRigid3DPerspectiveTransformTest(int, char *[])
auto translation = TransformType::New();
translation->SetFocalDistance(focal);

TransformType::OffsetType ioffset;
ioffset.Fill(0.0);
TransformType::OffsetType ioffset{};

translation->SetOffset(ioffset);
ITK_TEST_SET_GET_VALUE(ioffset, translation->GetOffset());
Expand Down Expand Up @@ -170,8 +169,7 @@ itkRigid3DPerspectiveTransformTest(int, char *[])
auto rigid = TransformType::New();
rigid->SetFocalDistance(focal);

TransformType::OffsetType ioffset;
ioffset.Fill(0.0);
TransformType::OffsetType ioffset{};

rigid->SetOffset(ioffset);

Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Transform/test/itkRigid3DTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ itkRigid3DTransformTest(int, char *[])

rotation->SetMatrix(mrotation);

TransformType::OffsetType ioffset;
ioffset.Fill(0.0f);
TransformType::OffsetType ioffset{};

rotation->SetOffset(ioffset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,12 @@ itkTransformGeometryImageFilterTest(int argc, char * argv[])
ITK_TRY_EXPECT_NO_EXCEPTION(inputImage = itk::ReadImage<ImageType>(argv[1]));

// Set up transforms
ImageType::PointType center;
center.Fill(0.0);
ImageType::PointType center{};
center[0] = 2.0; // In mm along X (RL-axis)
center[1] = 5.0; // In mm along Y (AP-axis)
center[2] = 7.0; // In mm along Z (IS-axis)

itk::Vector<double, Dimension> translation;
translation.Fill(0.);
itk::Vector<double, Dimension> translation{};
translation[0] = 10.0; // In mm along X (RL-axis)
translation[1] = 15.0; // In mm along Y (AP-axis)
translation[2] = 20.0; // In mm along Z (IS-axis)
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Transform/test/itkVersorTransformTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,7 @@ itkVersorTransformTest(int, char *[])

// Check the computed parameters

VectorType axis;
axis.Fill(0.0);
VectorType axis{};
axis[2] = 1.0;
VersorType v;
v.Set(axis, a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ itkInverseDisplacementFieldImageFilterTest(int argc, char * argv[])
DisplacementFieldType::SpacingType spacing;
spacing.Fill(1.0);

DisplacementFieldType::PointType origin;
origin.Fill(0.0);
DisplacementFieldType::PointType origin{};

DisplacementFieldType::RegionType region;
DisplacementFieldType::SizeType size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ itkIterativeInverseDisplacementFieldImageFilterTest(int argc, char * argv[])
DisplacementFieldType::SpacingType spacing;
spacing.Fill(1.0);

DisplacementFieldType::PointType origin;
origin.Fill(0.0);
DisplacementFieldType::PointType origin{};

DisplacementFieldType::RegionType region;
DisplacementFieldType::SizeType size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ itkLandmarkDisplacementFieldSourceTest(int argc, char * argv[])
DisplacementFieldType::SpacingType spacing;
spacing.Fill(1.0);

DisplacementFieldType::PointType origin;
origin.Fill(0.0);
DisplacementFieldType::PointType origin{};

DisplacementFieldType::RegionType region;
DisplacementFieldType::SizeType size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ itkTimeVaryingVelocityFieldIntegrationImageFilterTest(int argc, char * argv[])
using DisplacementFieldType = itk::Image<VectorType, 3>;
using TimeVaryingVelocityFieldType = itk::Image<VectorType, 4>;

TimeVaryingVelocityFieldType::PointType origin;
origin.Fill(0.0);
TimeVaryingVelocityFieldType::PointType origin{};

TimeVaryingVelocityFieldType::SpacingType spacing;
spacing.Fill(2.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ itkTimeVaryingVelocityFieldTransformTest(int, char *[])
using DisplacementFieldType = itk::Image<VectorType, ComponentDimension>;
using TimeVaryingVelocityFieldType = itk::Image<VectorType, VelocityFieldDimension>;

TimeVaryingVelocityFieldType::PointType origin;
origin.Fill(0.0);
TimeVaryingVelocityFieldType::PointType origin{};

TimeVaryingVelocityFieldType::SpacingType spacing;
spacing.Fill(2.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ FastMarchingImageFilterBaseTestFunction()
fastMarchingFilter->SetOutputDirection(outputDirection);
ITK_TEST_SET_GET_VALUE(outputDirection, fastMarchingFilter->GetOutputDirection());

typename FastMarchingImageFilterType::OutputPointType outputOrigin;
outputOrigin.Fill(0.0);
typename FastMarchingImageFilterType::OutputPointType outputOrigin{};
fastMarchingFilter->SetOutputOrigin(outputOrigin);
ITK_TEST_SET_GET_VALUE(outputOrigin, fastMarchingFilter->GetOutputOrigin());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest(int, char *[])

using FastMarchingType = itk::FastMarchingQuadEdgeMeshFilterBase<MeshType, MeshType>;

MeshType::PointType center;
center.Fill(0.);
MeshType::PointType center{};

using SphereSourceType = itk::RegularSphereMeshSource<MeshType>;
auto sphere_filter = SphereSourceType::New();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ itkFastMarchingQuadEdgeMeshFilterBaseTest3(int, char *[])
points->Reserve(100);
pointdata->Reserve(100);

MeshType::PointType p;
p.Fill(0.);
MeshType::PointType p{};

int k = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ itkFastMarchingQuadEdgeMeshFilterWithNumberOfElementsTest(int, char *[])

using FastMarchingType = itk::FastMarchingQuadEdgeMeshFilterBase<MeshType, MeshType>;

MeshType::PointType center;
center.Fill(0.);
MeshType::PointType center{};

using SphereSourceType = itk::RegularSphereMeshSource<MeshType>;
auto sphere_filter = SphereSourceType::New();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[])
HessianImageType::Pointer outputImage = filter->GetOutput();

// Get the value at the center of the image, the location of the peak of the Gaussian
PointType center;
center.Fill(0.0);
PointType center{};

IndexType centerIndex = outputImage->TransformPhysicalPointToIndex(center);

Expand Down Expand Up @@ -157,8 +156,7 @@ itkHessianRecursiveGaussianFilterScaleSpaceTest(int, char *[])
HessianImageType::Pointer outputImage = filter->GetOutput();

// Get the value at the center of the image, the location of the peak of the Gaussian
PointType center;
center.Fill(0.0);
PointType center{};

IndexType centerIndex = outputImage->TransformPhysicalPointToIndex(center);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ itkGradientRecursiveGaussianFilterTest(int argc, char * argv[])
//
// Test with a change in image direction
//
myImageType::DirectionType direction;
direction.Fill(0.0);
myImageType::DirectionType direction{};
direction[0][0] = -1.0;
direction[1][1] = -1.0;
direction[2][2] = -1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest(int argc, char * argv[])
ITK_TEST_SET_GET_VALUE(ncps, filter->GetNumberOfControlPoints());


FilterType::ArrayType close;
close.Fill(0u);
FilterType::ArrayType close{};
filter->SetCloseDimension(close);
ITK_TEST_SET_GET_VALUE(close, filter->GetCloseDimension());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest2(int argc, char * argv[])
spacing.Fill(0.01);
ImageType::SizeType size;
size.Fill(101);
ImageType::PointType origin;
origin.Fill(0.0);
ImageType::PointType origin{};

filter->SetSize(size);
filter->SetOrigin(origin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest3(int argc, char * argv[])
ImageType::SizeType size;
// Adding 0.5 to avoid rounding errors
size.Fill(static_cast<unsigned int>(1.0 / spacing[0] + .5) + 1);
ImageType::PointType origin;
origin.Fill(0.0);
ImageType::PointType origin{};

filter->SetSize(size);
filter->SetOrigin(origin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ itkBSplineScatteredDataPointSetToImageFilterTest5(int argc, char * argv[])
size[0] = 1000;
size[1] = 100;

ImageType::PointType origin;
origin.Fill(0.0);
ImageType::PointType origin{};

filter->SetSize(size);
filter->SetOrigin(origin);
Expand Down
3 changes: 1 addition & 2 deletions Modules/Filtering/ImageGrid/test/itkResampleImageTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ itkResampleImageTest(int, char *[])
resample->SetOutputStartIndex(index);
ITK_TEST_SET_GET_VALUE(index, resample->GetOutputStartIndex());

ImageType::PointType origin;
origin.Fill(0.0);
ImageType::PointType origin{};
resample->SetOutputOrigin(origin);
ITK_TEST_SET_GET_VALUE(origin, resample->GetOutputOrigin());

Expand Down
Loading