Skip to content

Commit 1cda164

Browse files
committed
STYLE: Replace Index var; var.Fill with auto var = Index::Filled
Using Notepad++, Replace in Files, doing: Find what: ^([ ]+ )(typename )?(.*Index.*[^ ])[ ]+(\w+);[\r\n]+ [ ]+\4\.Fill\( Replace with: $1auto $4 = $3::Filled\( Filters: itk*.h;itk*.hxx;itk*.cxx [v] Match case (*) Regular expression Follow-up to pull request InsightSoftwareConsortium#4887 commit 504d63b "STYLE: Replace `index.Fill` with `auto index = Index::Filled` in tests"
1 parent 5b8e619 commit 1cda164

File tree

7 files changed

+19
-34
lines changed

7 files changed

+19
-34
lines changed

Modules/Filtering/Denoising/include/itkPatchBasedDenoisingImageFilter.hxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,7 @@ PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::InitializePatchWeight
482482
physicalWeightsImage->Allocate();
483483
physicalWeightsImage->FillBuffer(1.0);
484484

485-
typename WeightsImageType::IndexType centerIndex;
486-
centerIndex.Fill(patchRadius);
485+
auto centerIndex = WeightsImageType::IndexType::Filled(patchRadius);
487486

488487
unsigned int pos = 0;
489488
for (ImageRegionIteratorWithIndex<WeightsImageType> pwIt(physicalWeightsImage, physicalRegion); !pwIt.IsAtEnd();

Modules/Filtering/LabelMap/include/itkAutoCropLabelMapFilter.hxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ AutoCropLabelMapFilter<TInputImage>::GenerateOutputInformation()
5353
}
5454

5555
// find the bounding box of the objects
56-
IndexType minIdx;
57-
minIdx.Fill(NumericTraits<typename TInputImage::IndexValueType>::max());
58-
IndexType maxIdx;
59-
maxIdx.Fill(NumericTraits<typename TInputImage::IndexValueType>::NonpositiveMin());
56+
auto minIdx = IndexType::Filled(NumericTraits<typename TInputImage::IndexValueType>::max());
57+
auto maxIdx = IndexType::Filled(NumericTraits<typename TInputImage::IndexValueType>::NonpositiveMin());
6058

6159
const InputImageType * inputImage = this->GetInput();
6260

Modules/Filtering/LabelMap/include/itkLabelMapMaskImageFilter.hxx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ LabelMapMaskImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
104104
else
105105
{
106106
// Compute the bounding box of all the objects which don't have that label
107-
IndexType mins;
108-
mins.Fill(NumericTraits<IndexValueType>::max());
109-
IndexType maxs;
110-
maxs.Fill(NumericTraits<IndexValueType>::NonpositiveMin());
107+
auto mins = IndexType::Filled(NumericTraits<IndexValueType>::max());
108+
auto maxs = IndexType::Filled(NumericTraits<IndexValueType>::NonpositiveMin());
111109
for (typename InputImageType::ConstIterator loit(this->GetInput()); !loit.IsAtEnd(); ++loit)
112110
{
113111
if (loit.GetLabel() != m_Label)
@@ -168,10 +166,8 @@ LabelMapMaskImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()
168166
// Just find the bounding box of the object with that label
169167

170168
const LabelObjectType * labelObject = input->GetLabelObject(m_Label);
171-
IndexType mins;
172-
mins.Fill(NumericTraits<IndexValueType>::max());
173-
IndexType maxs;
174-
maxs.Fill(NumericTraits<IndexValueType>::NonpositiveMin());
169+
auto mins = IndexType::Filled(NumericTraits<IndexValueType>::max());
170+
auto maxs = IndexType::Filled(NumericTraits<IndexValueType>::NonpositiveMin());
175171
// Iterate over all the lines
176172
typename LabelObjectType::ConstLineIterator lit(labelObject);
177173
while (!lit.IsAtEnd())

Modules/Filtering/LabelMap/include/itkShapeLabelMapFilter.hxx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,11 @@ ShapeLabelMapFilter<TImage, TLabelImage>::ThreadedProcessLabelObject(LabelObject
9696
// Init the vars
9797
SizeValueType nbOfPixels = 0;
9898
ContinuousIndex<double, ImageDimension> centroid{};
99-
IndexType mins;
100-
mins.Fill(NumericTraits<IndexValueType>::max());
101-
IndexType maxs;
102-
maxs.Fill(NumericTraits<IndexValueType>::NonpositiveMin());
103-
SizeValueType nbOfPixelsOnBorder = 0;
104-
double perimeterOnBorder = 0;
105-
MatrixType centralMoments{};
99+
auto mins = IndexType::Filled(NumericTraits<IndexValueType>::max());
100+
auto maxs = IndexType::Filled(NumericTraits<IndexValueType>::NonpositiveMin());
101+
SizeValueType nbOfPixelsOnBorder = 0;
102+
double perimeterOnBorder = 0;
103+
MatrixType centralMoments{};
106104

107105
using LengthType = typename LabelObjectType::LengthType;
108106

Modules/Nonunit/Review/include/itkDiscreteGaussianDerivativeImageFunction.hxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,14 @@ DiscreteGaussianDerivativeImageFunction<TInputImage, TOutput>::RecomputeGaussian
111111
kernelImage->AllocateInitialized();
112112

113113
// Initially the kernel image will be an impulse at the center
114-
typename KernelImageType::IndexType centerIndex;
115-
centerIndex.Fill(2 * m_OperatorArray[0].GetRadius()[0]); // include also
116-
// boundaries
114+
auto centerIndex = KernelImageType::IndexType::Filled(2 * m_OperatorArray[0].GetRadius()[0]); // include also
115+
// boundaries
117116
kernelImage->SetPixel(centerIndex, itk::NumericTraits<TOutput>::OneValue());
118117

119118
// Create an image region to be used later that does not include boundaries
120119
RegionType kernelRegion;
121120
size.Fill(2 * m_OperatorArray[0].GetRadius()[0] + 1);
122-
typename RegionType::IndexType origin;
123-
origin.Fill(m_OperatorArray[0].GetRadius()[0]);
121+
auto origin = RegionType::IndexType::Filled(m_OperatorArray[0].GetRadius()[0]);
124122
kernelRegion.SetSize(size);
125123
kernelRegion.SetIndex(origin);
126124

Modules/Nonunit/Review/include/itkDiscreteGradientMagnitudeGaussianImageFunction.hxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,12 @@ DiscreteGradientMagnitudeGaussianImageFunction<TInputImage, TOutput>::RecomputeG
124124
kernelImage->AllocateInitialized();
125125

126126
// Initially the kernel image will be an impulse at the center
127-
typename KernelImageType::IndexType centerIndex;
128-
centerIndex.Fill(2 * maxRadius); // include also boundaries
127+
auto centerIndex = KernelImageType::IndexType::Filled(2 * maxRadius); // include also boundaries
129128

130129
// Create an image region to be used later that does not include boundaries
131130
RegionType kernelRegion;
132131
size.Fill(2 * maxRadius + 1);
133-
typename RegionType::IndexType origin;
134-
origin.Fill(maxRadius);
132+
auto origin = RegionType::IndexType::Filled(maxRadius);
135133
kernelRegion.SetSize(size);
136134
kernelRegion.SetIndex(origin);
137135

Modules/Nonunit/Review/include/itkDiscreteHessianGaussianImageFunction.hxx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,12 @@ DiscreteHessianGaussianImageFunction<TInputImage, TOutput>::RecomputeGaussianKer
117117
kernelImage->AllocateInitialized();
118118

119119
// Initially the kernel image will be an impulse at the center
120-
typename KernelImageType::IndexType centerIndex;
121-
centerIndex.Fill(2 * maxRadius); // include also boundaries
120+
auto centerIndex = KernelImageType::IndexType::Filled(2 * maxRadius); // include also boundaries
122121

123122
// Create an image region to be used later that does not include boundaries
124123
RegionType kernelRegion;
125124
size.Fill(2 * maxRadius + 1);
126-
typename RegionType::IndexType origin;
127-
origin.Fill(maxRadius);
125+
auto origin = RegionType::IndexType::Filled(maxRadius);
128126
kernelRegion.SetSize(size);
129127
kernelRegion.SetIndex(origin);
130128

0 commit comments

Comments
 (0)