Skip to content

Commit d1b4174

Browse files
authored
Merge pull request InsightSoftwareConsortium#6010 from hjmjohnson/style-sizetype-filled
STYLE: Replace declare-then-Fill(N) with ::Filled(N) factory method
2 parents 4c85a55 + 787267e commit d1b4174

52 files changed

Lines changed: 127 additions & 237 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionTest.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,10 @@ itkBSplineInterpolationWeightFunctionTest(int, char *[])
254254

255255
std::cout << "Number Of Weights: " << numberOfWeights << std::endl;
256256

257-
ContinuousIndexType position;
258-
WeightsType weights;
259-
IndexType startIndex;
257+
auto position = itk::MakeFilled<ContinuousIndexType>(4.15);
258+
WeightsType weights;
259+
IndexType startIndex;
260260

261-
position.Fill(4.15);
262261
weights = function->Evaluate(position);
263262

264263
std::cout << "Position: " << position << std::endl;

Modules/Core/Common/test/itkImageVectorOptimizerParametersHelperTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ testMemoryAccess(OptimizerParametersType & params, ImageVectorPointer imageOfVec
7878
int
7979
itkImageVectorOptimizerParametersHelperTest(int, char *[])
8080
{
81-
SizeType size;
8281
constexpr int dimLength{ 3 };
83-
size.Fill(dimLength);
82+
auto size = itk::MakeFilled<SizeType>(dimLength);
8483

8584
const RegionType region{ size };
8685

Modules/Core/ImageFunction/include/itkGaussianInterpolateImageFunction.hxx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,10 @@ GaussianInterpolateImageFunction<TImageType, TCoordinate>::EvaluateAtContinuousI
109109

110110
RealType sum_me = 0.0;
111111
RealType sum_m = 0.0;
112-
ArrayType dsum_me;
113-
ArrayType dsum_m;
114-
ArrayType dw;
112+
ArrayType dsum_me{};
113+
ArrayType dsum_m{};
114+
ArrayType dw{};
115115

116-
dsum_m.Fill(0.0);
117-
dsum_me.Fill(0.0);
118-
dw.Fill(0.0);
119116

120117
for (ImageRegionConstIteratorWithIndex It(this->GetInputImage(), region); !It.IsAtEnd(); ++It)
121118
{

Modules/Core/ImageFunction/test/itkCentralDifferenceImageFunctionTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ itkCentralDifferenceImageFunctionTest(int, char *[])
6363

6464
function->SetInputImage(image);
6565

66-
ImageType::IndexType index;
66+
auto index = itk::MakeFilled<ImageType::IndexType>(8);
6767

6868
// pick an index inside the image
69-
index.Fill(8);
7069
OutputType indexOutput = function->EvaluateAtIndex(index);
7170
std::cout << "Index: " << index << " Derivative: ";
7271
std::cout << indexOutput << std::endl;

Modules/Core/ImageFunction/test/itkGaussianInterpolateImageFunctionTest.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ itkGaussianInterpolateImageFunctionTest(int, char *[])
4949
image->SetRegions(region);
5050
image->Allocate();
5151

52-
ImageType::PointType origin;
53-
ImageType::SpacingType spacing;
52+
ImageType::PointType origin{};
53+
auto spacing = itk::MakeFilled<ImageType::SpacingType>(1.0);
5454

55-
origin.Fill(0.0);
56-
spacing.Fill(1.0);
5755

5856
image->SetOrigin(origin);
5957
image->SetSpacing(spacing);

Modules/Core/ImageFunction/test/itkLinearInterpolateImageFunctionTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ RunLinearInterpolateTest()
5959
auto variablevectorimage = VariableVectorImageType::New();
6060
variablevectorimage->SetVectorLength(VectorDimension);
6161

62-
SizeType size;
6362
constexpr int dimMaxLength{ 3 };
64-
size.Fill(dimMaxLength);
63+
auto size = itk::MakeFilled<SizeType>(dimMaxLength);
6564

6665
const RegionType region{ size };
6766

Modules/Core/ImageFunction/test/itkNearestNeighborInterpolateImageFunctionTest.cxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ itkNearestNeighborInterpolateImageFunctionTest(int, char *[])
7171
variablevectorimage->SetRegions(region);
7272
variablevectorimage->Allocate();
7373

74-
ImageType::PointType origin;
75-
ImageType::SpacingType spacing;
74+
ImageType::PointType origin{};
75+
auto spacing = itk::MakeFilled<ImageType::SpacingType>(1.0);
7676

77-
origin.Fill(0.0);
78-
spacing.Fill(1.0);
7977

8078
image->SetOrigin(origin);
8179
image->SetSpacing(spacing);

Modules/Core/SpatialObjects/include/itkContourSpatialObject.hxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ ContourSpatialObject<TDimension>::GetOrientationInObjectSpace() const
7373
const ContourPointListType & points = this->GetPoints();
7474
auto it = points.begin();
7575
auto itend = points.end();
76-
PointType minPnt;
77-
PointType maxPnt;
78-
minPnt.Fill(NumericTraits<double>::max());
79-
maxPnt.Fill(NumericTraits<double>::NonpositiveMin());
76+
auto minPnt = MakeFilled<PointType>(NumericTraits<double>::max());
77+
auto maxPnt = MakeFilled<PointType>(NumericTraits<double>::NonpositiveMin());
8078
while (it != itend)
8179
{
8280
PointType curpoint = it->GetPositionInObjectSpace();

Modules/Core/SpatialObjects/include/itkPolygonSpatialObject.hxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ PolygonSpatialObject<TDimension>::GetOrientationInObjectSpace() const
6161
const PolygonPointListType & points = this->GetPoints();
6262
auto it = points.begin();
6363
auto itend = points.end();
64-
PointType minPnt;
65-
PointType maxPnt;
66-
minPnt.Fill(NumericTraits<double>::max());
67-
maxPnt.Fill(NumericTraits<double>::NonpositiveMin());
64+
auto minPnt = MakeFilled<PointType>(NumericTraits<double>::max());
65+
auto maxPnt = MakeFilled<PointType>(NumericTraits<double>::NonpositiveMin());
6866
while (it != itend)
6967
{
7068
PointType curpoint = it->GetPositionInObjectSpace();

Modules/Core/Transform/include/itkKernelTransform.hxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,10 @@ auto
318318
KernelTransform<TParametersValueType, VDimension>::TransformPoint(const InputPointType & thisPoint) const
319319
-> OutputPointType
320320
{
321-
OutputPointType result;
322-
323321
using ValueType = typename OutputPointType::ValueType;
324322

325-
result.Fill(ValueType{});
323+
auto result = MakeFilled<OutputPointType>(ValueType{});
324+
326325

327326
// TODO: It is unclear if the following line is needed.
328327
this->ComputeDeformationContribution(thisPoint, result);

0 commit comments

Comments
 (0)