Skip to content

Commit 5305a6f

Browse files
hjmjohnsonclaude
andcommitted
STYLE: Replace declare-then-Fill(N) with MakeFilled<T>(N)
Using find_declare_then_init.py --pattern fill_nonzero, replaced the two-line pattern: Type var; var.Fill(N); with the single-line form: auto var = itk::MakeFilled<Type>(N); // test files auto var = MakeFilled<Type>(N); // .hxx (already in itk::) across 44 files in Modules/ (excluding Remote/, BridgeOpenCV, BridgeVXL, and itkVectorMeanImageFunction.hxx which uses VariableLengthVector). Follow-up to commit 6cb6bf9 by N-Dekker "STYLE: Replace `T var; var.Fill(x)` with `auto var = MakeFilled<T>(x)`" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b94cca5 commit 5305a6f

44 files changed

Lines changed: 90 additions & 160 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/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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ 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

5555
origin.Fill(0.0);
56-
spacing.Fill(1.0);
5756

5857
image->SetOrigin(origin);
5958
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ 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

7777
origin.Fill(0.0);
78-
spacing.Fill(1.0);
7978

8079
image->SetOrigin(origin);
8180
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);

Modules/Core/Transform/test/itkBSplineDeformableTransformTest.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,10 @@ itkBSplineDeformableTransformTest1()
152152
*/
153153
using PointType = TransformType::InputPointType;
154154

155-
PointType inputPoint;
155+
auto inputPoint = itk::MakeFilled<PointType>(9.0);
156156
PointType outputPoint;
157157

158158
// point within the grid support region
159-
inputPoint.Fill(9.0);
160159
outputPoint = transform->TransformPoint(inputPoint);
161160

162161
std::cout << "Input Point: " << inputPoint << std::endl;

0 commit comments

Comments
 (0)