Skip to content

Commit ac31561

Browse files
N-Dekkerdzenanz
authored andcommitted
STYLE: Declare local ImageRegion variables const
Replaced lines of code like the following: RegionType region; region.SetIndex(index); region.SetSize(size); With: const RegionType region(index, size); Following C++ Core Guidelines, August 19, 2021, "By default, make objects immutable" https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rconst-immutable
1 parent b524b12 commit ac31561

File tree

63 files changed

+117
-280
lines changed

Some content is hidden

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

63 files changed

+117
-280
lines changed

Modules/Bridge/VTK/include/itkVTKImageExport.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,7 @@ VTKImageExport<TInputImage>::PropagateUpdateExtentCallback(int * extent)
358358
size[i] = (extent[i * 2 + 1] - extent[i * 2]) + 1;
359359
}
360360

361-
InputRegionType region;
362-
region.SetSize(size);
363-
region.SetIndex(index);
361+
const InputRegionType region(index, size);
364362

365363
InputImagePointer input = this->GetInput();
366364
if (!input)

Modules/Bridge/VTK/include/itkVTKImageImport.hxx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ VTKImageImport<TOutputImage>::GenerateOutputInformation()
193193
size[i] = (extent[i * 2 + 1] - extent[i * 2]) + 1;
194194
}
195195

196-
OutputRegionType region;
197-
region.SetIndex(index);
198-
region.SetSize(size);
196+
const OutputRegionType region(index, size);
199197
output->SetLargestPossibleRegion(region);
200198
}
201199
if (m_SpacingCallback)
@@ -325,9 +323,7 @@ VTKImageImport<TOutputImage>::GenerateData()
325323
importSize *= size[i];
326324
}
327325

328-
OutputRegionType region;
329-
region.SetIndex(index);
330-
region.SetSize(size);
326+
const OutputRegionType region(index, size);
331327
output->SetBufferedRegion(region);
332328

333329
void * data = (m_BufferPointerCallback)(m_CallbackUserData);

Modules/Core/Common/include/itkConstNeighborhoodIterator.hxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ auto
201201
ConstNeighborhoodIterator<TImage, TBoundaryCondition>::GetBoundingBoxAsImageRegion() const -> RegionType
202202
{
203203
const IndexValueType zero = NumericTraits<IndexValueType>::ZeroValue();
204-
RegionType ans;
205-
206-
ans.SetIndex(this->GetIndex(zero));
207-
ans.SetSize(this->GetSize());
204+
const RegionType ans(this->GetIndex(zero), this->GetSize());
208205

209206
return ans;
210207
}

Modules/Core/Common/include/itkConstNeighborhoodIteratorWithOnlyIndex.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ auto
121121
ConstNeighborhoodIteratorWithOnlyIndex<TImage>::GetBoundingBoxAsImageRegion() const -> RegionType
122122
{
123123
const IndexValueType zero = NumericTraits<IndexValueType>::ZeroValue();
124-
RegionType ans;
125-
ans.SetIndex(this->GetIndex(zero));
126-
ans.SetSize(this->GetSize());
124+
const RegionType ans(this->GetIndex(zero), this->GetSize());
127125

128126
return ans;
129127
}

Modules/Core/Common/include/itkOctree.hxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,9 @@ Octree<TPixel, ColorTableSize, MappingFunctionType>::GetImage() -> ImageTypePoin
265265
sizes[1] = m_TrueDims[1];
266266
sizes[2] = m_TrueDims[2];
267267
imageSize.SetSize(sizes);
268-
const typename ImageType::IndexType imageIndex = { { 0, 0, 0 } };
269-
typename ImageType::RegionType region;
270-
region.SetSize(imageSize);
271-
region.SetIndex(imageIndex);
272-
auto img = ImageType::New();
268+
const typename ImageType::IndexType imageIndex = { { 0, 0, 0 } };
269+
const typename ImageType::RegionType region(imageIndex, imageSize);
270+
auto img = ImageType::New();
273271
img->SetLargestPossibleRegion(region);
274272
img->SetBufferedRegion(region);
275273
img->SetRequestedRegion(region);

Modules/Core/Mesh/include/itkTriangleMeshToBinaryImageFilter.hxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ TriangleMeshToBinaryImageFilter<TInputMesh, TOutputImage>::GenerateData()
156156
itkExceptionMacro(<< "Must Set Image Size");
157157
}
158158

159-
typename OutputImageType::RegionType region;
160-
161-
region.SetSize(m_Size);
162-
region.SetIndex(m_Index);
159+
const typename OutputImageType::RegionType region(m_Index, m_Size);
163160

164161
OutputImage->SetLargestPossibleRegion(region); //
165162
OutputImage->SetBufferedRegion(region); // set the region

Modules/Core/SpatialObjects/include/itkMetaImageConverter.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ MetaImageConverter<NDimensions, PixelType, TSpatialObjectType>::AllocateImage(co
6565
}
6666
}
6767

68-
RegionType region;
69-
region.SetSize(size);
7068
itk::Index<NDimensions> zeroIndex;
7169
zeroIndex.Fill(0);
72-
region.SetIndex(zeroIndex);
70+
const RegionType region(zeroIndex, size);
7371
rval->SetLargestPossibleRegion(region);
7472
rval->SetBufferedRegion(region);
7573
rval->SetRequestedRegion(region);

Modules/Core/SpatialObjects/include/itkSpatialObjectToImageStatisticsCalculator.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ SpatialObjectToImageStatisticsCalculator<TInputImage, TInputSpatialObject, TSamp
186186
}
187187
}
188188

189-
RegionType region;
190-
region.SetIndex(indMin);
191-
region.SetSize(size);
189+
const RegionType region(indMin, size);
192190

193191
using IteratorType = ImageRegionConstIteratorWithIndex<ImageType>;
194192
IteratorType it = IteratorType(m_Image, region);

Modules/Core/TestKernel/include/itkRandomImageSource.hxx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ RandomImageSource<TOutputImage>::GenerateOutputInformation()
204204

205205
output = this->GetOutput(0);
206206

207-
typename TOutputImage::RegionType largestPossibleRegion;
208-
largestPossibleRegion.SetSize(this->m_Size);
209-
largestPossibleRegion.SetIndex(index);
207+
const typename TOutputImage::RegionType largestPossibleRegion(index, this->m_Size);
210208
output->SetLargestPossibleRegion(largestPossibleRegion);
211209

212210
output->SetSpacing(m_Spacing);

Modules/Core/Transform/include/itkBSplineBaseTransform.hxx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,10 @@ BSplineBaseTransform<TParametersValueType, NDimensions, VSplineOrder>::
265265
this->m_WeightsFunction->Evaluate(index, weights, supportIndex);
266266

267267
// For each dimension, copy the weight to the support region
268-
RegionType supportRegion;
269-
SizeType supportSize;
268+
SizeType supportSize;
270269
supportSize.Fill(SplineOrder + 1);
271-
supportRegion.SetSize(supportSize);
272-
supportRegion.SetIndex(supportIndex);
273-
unsigned long counter = 0;
270+
const RegionType supportRegion(supportIndex, supportSize);
271+
unsigned long counter = 0;
274272

275273
using IteratorType = ImageRegionIterator<ImageType>;
276274

0 commit comments

Comments
 (0)