Skip to content

Commit

Permalink
STYLE: Use range-based for loops to iterate over faceList variables
Browse files Browse the repository at this point in the history
Removed the local `fit` variables and `FaceListTypeIt` typedefs that have become
unnecessary with this change.
  • Loading branch information
N-Dekker authored and dzenanz committed Dec 5, 2022
1 parent c28be8b commit 2de7e24
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 133 deletions.
Expand Up @@ -131,8 +131,6 @@ ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreaded
faceList = fC(this->GetInput(), outputRegionForThread, m_Kernel.GetRadius());


typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator fit;

// Setup the kernel that spans the immediate neighbors of the current
// input pixel - used to determine if that pixel abuts a non-object
// pixel, i.e., is a boundary pixel
Expand All @@ -143,16 +141,16 @@ ObjectMorphologyImageFilter<TInputImage, TOutputImage, TKernel>::DynamicThreaded

OutputNeighborhoodIteratorType oSNIter;
InputNeighborhoodIteratorType iSNIter;
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
oSNIter = OutputNeighborhoodIteratorType(m_Kernel.GetRadius(), this->GetOutput(), *fit);
oSNIter = OutputNeighborhoodIteratorType(m_Kernel.GetRadius(), this->GetOutput(), face);
// No need to overwrite on output...and m_BoundaryCondition is
// templated over inputImageType - and cannot be applied to the
// output image
// oSNIter.OverrideBoundaryCondition(m_BoundaryCondition);
oSNIter.GoToBegin();

iSNIter = InputNeighborhoodIteratorType(bKernelSize, this->GetInput(), *fit);
iSNIter = InputNeighborhoodIteratorType(bKernelSize, this->GetInput(), face);
iSNIter.OverrideBoundaryCondition(m_BoundaryCondition);
iSNIter.GoToBegin();

Expand Down
Expand Up @@ -151,7 +151,6 @@ NormalizedCorrelationImageFilter<TInputImage, TMaskImage, TOutputImage, TOperato
// Process non-boundary region and each of the boundary faces.
// These are N-d regions which border the edge of the buffer.
ConstNeighborhoodIterator<InputImageType> bit;
typename FaceListType::iterator fit;
ImageRegionIterator<OutputImageType> it;
ImageRegionConstIterator<MaskImageType> mit;
unsigned int i;
Expand All @@ -163,13 +162,13 @@ NormalizedCorrelationImageFilter<TInputImage, TMaskImage, TOutputImage, TOperato
OutputPixelRealType zero = NumericTraits<OutputPixelType>::ZeroValue();

realTemplateSize = static_cast<OutputPixelRealType>(templateSize);
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(normalizedTemplate.GetRadius(), input, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(normalizedTemplate.GetRadius(), input, face);
bit.OverrideBoundaryCondition(this->GetBoundaryCondition());
bit.GoToBegin();

it = ImageRegionIterator<OutputImageType>(output, *fit);
it = ImageRegionIterator<OutputImageType>(output, face);

if (!mask)
{
Expand Down Expand Up @@ -207,7 +206,7 @@ NormalizedCorrelationImageFilter<TInputImage, TMaskImage, TOutputImage, TOperato
{
// Mask is defined, use the same calculation as above but only
// perform it under the mask
mit = ImageRegionConstIterator<MaskImageType>(mask, *fit);
mit = ImageRegionConstIterator<MaskImageType>(mask, face);
while (!bit.IsAtEnd())
{
if (mit.Get())
Expand Down
Expand Up @@ -183,19 +183,16 @@ DisplacementFieldJacobianDeterminantFilter<TInputImage, TRealType, TOutputImage>
outputRegionForThread,
m_NeighborhoodRadius);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<RealVectorImageType>::FaceListType::iterator fit;
fit = faceList.begin();

TotalProgressReporter progress(this, this->GetOutput()->GetRequestedRegion().GetNumberOfPixels());

// Process each of the data set faces. The iterator is reinitialized on each
// face so that it can determine whether or not to check for boundary
// conditions.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIteratorType(
m_NeighborhoodRadius, dynamic_cast<const RealVectorImageType *>(m_RealValuedInputImage.GetPointer()), *fit);
it = ImageRegionIterator<TOutputImage>(this->GetOutput(), *fit);
m_NeighborhoodRadius, dynamic_cast<const RealVectorImageType *>(m_RealValuedInputImage.GetPointer()), face);
it = ImageRegionIterator<TOutputImage>(this->GetOutput(), face);
bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();

Expand Down
Expand Up @@ -191,10 +191,10 @@ ContourDirectedMeanDistanceImageFilter<TInputImage1, TInputImage2>::ThreadedGene

// Process each of the boundary faces. These are N-d regions which border
// the edge of the buffer.
for (auto fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
ImageRegionConstIterator<DistanceMapType> it2(m_DistanceMap, *fit);
bit = ConstNeighborhoodIterator<InputImage1Type>(radius, input, *fit);
ImageRegionConstIterator<DistanceMapType> it2(m_DistanceMap, face);
bit = ConstNeighborhoodIterator<InputImage1Type>(radius, input, face);
unsigned int neighborhoodSize = bit.Size();

bit.OverrideBoundaryCondition(&nbc);
Expand Down
Expand Up @@ -247,8 +247,6 @@ BilateralImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> fC;
faceList = fC(this->GetInput(), outputRegionForThread, m_GaussianKernel.GetRadius());

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator fit;

OutputPixelRealType centerPixel;
OutputPixelRealType val, tableArg, normFactor, rangeGaussian, rangeDistance, pixel, gaussianProduct;

Expand All @@ -264,12 +262,12 @@ BilateralImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(

TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());

for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
// walk the boundary face and the corresponding section of the output
b_iter = NeighborhoodIteratorType(m_GaussianKernel.GetRadius(), this->GetInput(), *fit);
b_iter = NeighborhoodIteratorType(m_GaussianKernel.GetRadius(), this->GetInput(), face);
b_iter.OverrideBoundaryCondition(&BC);
o_iter = ImageRegionIterator<OutputImageType>(this->GetOutput(), *fit);
o_iter = ImageRegionIterator<OutputImageType>(this->GetOutput(), face);

while (!b_iter.IsAtEnd())
{
Expand Down
Expand Up @@ -115,15 +115,13 @@ CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>::ThreadedCompute2ndDeri
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
faceList = bC(input, outputRegionForThread, radius);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType::iterator fit;

// Process the non-boundady region and then each of the boundary faces.
// These are N-d regions which border the edge of the buffer.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
NeighborhoodType bit(radius, input, *fit);
NeighborhoodType bit(radius, input, face);

it = ImageRegionIterator<OutputImageType>(this->m_OutputImage, *fit);
it = ImageRegionIterator<OutputImageType>(this->m_OutputImage, face);
bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();

Expand Down Expand Up @@ -410,8 +408,6 @@ CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>::ThreadedCompute2ndDeri
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
faceList = bC(input, outputRegionForThread, radius);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType::iterator fit;

InputImagePixelType zero = NumericTraits<InputImagePixelType>::ZeroValue();

OutputImagePixelType dx[ImageDimension];
Expand All @@ -427,11 +423,11 @@ CannyEdgeDetectionImageFilter<TInputImage, TOutputImage>::ThreadedCompute2ndDeri

NeighborhoodInnerProduct<OutputImageType> IP;

for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(radius, input, *fit);
bit1 = ConstNeighborhoodIterator<InputImageType>(radius, input1, *fit);
it = ImageRegionIterator<OutputImageType>(output, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(radius, input, face);
bit1 = ConstNeighborhoodIterator<InputImageType>(radius, input1, face);
it = ImageRegionIterator<OutputImageType>(output, face);
bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();
bit1.GoToBegin();
Expand Down
Expand Up @@ -59,17 +59,15 @@ SimpleContourExtractorImageFilter<TInputImage, TOutputImage>::DynamicThreadedGen
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> bC;
faceList = bC(input, outputRegionForThread, this->GetRadius());

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator fit;

TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());

// Process each of the boundary faces. These are N-d regions which border
// the edge of the buffer.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(this->GetRadius(), input, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(this->GetRadius(), input, face);
unsigned int neighborhoodSize = bit.Size();
it = ImageRegionIterator<OutputImageType>(output, *fit);
it = ImageRegionIterator<OutputImageType>(output, face);

bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();
Expand Down
Expand Up @@ -111,8 +111,6 @@ ZeroCrossingImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
faceList = bC(input, outputRegionForThread, radius);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType::iterator fit;

TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());

InputImagePixelType this_one, that, abs_this_one, abs_that;
Expand All @@ -130,10 +128,10 @@ ZeroCrossingImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(

// Process each of the boundary faces. These are N-d regions which border
// the edge of the buffer.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(radius, input, *fit);
it = ImageRegionIterator<OutputImageType>(output, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(radius, input, face);
it = ImageRegionIterator<OutputImageType>(output, face);
bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();

Expand Down
Expand Up @@ -126,18 +126,17 @@ MaskNeighborhoodOperatorImageFilter<TInputImage, TMaskImage, TOutputImage, TOper
// Process non-boundary region and each of the boundary faces.
// These are N-d regions which border the edge of the buffer.
ConstNeighborhoodIterator<InputImageType> bit;
typename FaceListType::iterator fit;
ImageRegionIterator<OutputImageType> it;
ImageRegionConstIterator<MaskImageType> mit;

for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(noperator.GetRadius(), input, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(noperator.GetRadius(), input, face);
bit.OverrideBoundaryCondition(this->GetBoundaryCondition());
bit.GoToBegin();

it = ImageRegionIterator<OutputImageType>(output, *fit);
mit = ImageRegionConstIterator<MaskImageType>(mask, *fit);
it = ImageRegionIterator<OutputImageType>(output, face);
mit = ImageRegionConstIterator<MaskImageType>(mask, face);
while (!bit.IsAtEnd())
{
if (mit.Get())
Expand Down
Expand Up @@ -96,19 +96,18 @@ NeighborhoodOperatorImageFilter<TInputImage, TOutputImage, TOperatorValueType>::
// pixels that correspond to output pixels.
faceList = faceCalculator(input, outputRegionForThread, m_Operator.GetRadius());

typename FaceListType::iterator fit;
ImageRegionIterator<OutputImageType> it;

TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());

// Process non-boundary region and each of the boundary faces.
// These are N-d regions which border the edge of the buffer.
ConstNeighborhoodIterator<InputImageType> bit;
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(m_Operator.GetRadius(), input, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(m_Operator.GetRadius(), input, face);
bit.OverrideBoundaryCondition(m_BoundsCondition);
it = ImageRegionIterator<OutputImageType>(output, *fit);
it = ImageRegionIterator<OutputImageType>(output, face);
bit.GoToBegin();
while (!bit.IsAtEnd())
{
Expand Down
Expand Up @@ -55,8 +55,6 @@ NoiseImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> bC;
faceList = bC(input, outputRegionForThread, this->GetRadius());

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator fit;

TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());

InputRealType value;
Expand All @@ -67,13 +65,13 @@ NoiseImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerateData(

// Process each of the boundary faces. These are N-d regions which border
// the edge of the buffer.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(this->GetRadius(), input, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(this->GetRadius(), input, face);
unsigned int neighborhoodSize = bit.Size();
num = static_cast<InputRealType>(bit.Size());

it = ImageRegionIterator<OutputImageType>(output, *fit);
it = ImageRegionIterator<OutputImageType>(output, face);
bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();

Expand Down
Expand Up @@ -95,7 +95,6 @@ VectorNeighborhoodOperatorImageFilter<TInputImage, TOutputImage>::DynamicThreade
// only concerned with centering the neighborhood operator at the
// pixels that correspond to output pixels.
faceList = faceCalculator(input, outputRegionForThread, m_Operator.GetRadius());
typename FaceListType::iterator fit;

TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());

Expand All @@ -104,10 +103,10 @@ VectorNeighborhoodOperatorImageFilter<TInputImage, TOutputImage>::DynamicThreade
// Process non-boundary region and then each of the boundary faces.
// These are N-d regions which border the edge of the buffer.
ConstNeighborhoodIterator<InputImageType> bit;
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(m_Operator.GetRadius(), input, *fit);
it = ImageRegionIterator<OutputImageType>(output, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(m_Operator.GetRadius(), input, face);
it = ImageRegionIterator<OutputImageType>(output, face);
bit.GoToBegin();
while (!bit.IsAtEnd())
{
Expand Down
Expand Up @@ -153,13 +153,11 @@ GradientImageFilter<TInputImage, TOperatorValueType, TOutputValueType, TOutputIm
typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType faceList =
bC(inputImage, outputRegionForThread, radius);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator fit;
fit = faceList.begin();

TotalProgressReporter progress(this, this->GetOutput()->GetRequestedRegion().GetNumberOfPixels());

// Initialize the x_slice array
ConstNeighborhoodIterator<InputImageType> nit = ConstNeighborhoodIterator<InputImageType>(radius, inputImage, *fit);
ConstNeighborhoodIterator<InputImageType> nit =
ConstNeighborhoodIterator<InputImageType>(radius, inputImage, faceList.front());

std::slice x_slice[InputImageDimension];
const SizeValueType center = nit.Size() / 2;
Expand All @@ -171,10 +169,10 @@ GradientImageFilter<TInputImage, TOperatorValueType, TOutputValueType, TOutputIm
CovariantVectorType gradient;
// Process non-boundary face and then each of the boundary faces.
// These are N-d regions which border the edge of the buffer.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
nit = ConstNeighborhoodIterator<InputImageType>(radius, inputImage, *fit);
ImageRegionIterator<OutputImageType> it = ImageRegionIterator<OutputImageType>(outputImage, *fit);
nit = ConstNeighborhoodIterator<InputImageType>(radius, inputImage, face);
ImageRegionIterator<OutputImageType> it = ImageRegionIterator<OutputImageType>(outputImage, face);
nit.OverrideBoundaryCondition(m_BoundaryCondition);
nit.GoToBegin();

Expand Down
Expand Up @@ -140,13 +140,11 @@ GradientMagnitudeImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerate
NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage> bC;
faceList = bC(input, outputRegionForThread, radius);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<TInputImage>::FaceListType::iterator fit;
fit = faceList.begin();

TotalProgressReporter progress(this, output->GetRequestedRegion().GetNumberOfPixels());

// Process non-boundary face
nit = ConstNeighborhoodIterator<TInputImage>(radius, input, *fit);
nit = ConstNeighborhoodIterator<TInputImage>(radius, input, faceList.front());

std::slice x_slice[ImageDimension];
const SizeValueType center = nit.Size() / 2;
Expand All @@ -157,10 +155,10 @@ GradientMagnitudeImageFilter<TInputImage, TOutputImage>::DynamicThreadedGenerate

// Process each of the boundary faces. These are N-d regions which border
// the edge of the buffer.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIterator<InputImageType>(radius, input, *fit);
it = ImageRegionIterator<OutputImageType>(output, *fit);
bit = ConstNeighborhoodIterator<InputImageType>(radius, input, face);
it = ImageRegionIterator<OutputImageType>(output, face);
bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();

Expand Down
Expand Up @@ -201,18 +201,15 @@ VectorGradientMagnitudeImageFilter<TInputImage, TRealType, TOutputImage>::Dynami
r1.Fill(1);
faceList = bC(m_RealValuedInputImage.GetPointer(), outputRegionForThread, r1);

typename NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<RealVectorImageType>::FaceListType::iterator fit;
fit = faceList.begin();

TotalProgressReporter progress(this, this->GetOutput()->GetRequestedRegion().GetNumberOfPixels());

// Process each of the data set faces. The iterator is reinitialized on each
// face so that it can determine whether or not to check for boundary
// conditions.
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
for (const auto & face : faceList)
{
bit = ConstNeighborhoodIteratorType(r1, m_RealValuedInputImage.GetPointer(), *fit);
it = ImageRegionIterator<TOutputImage>(this->GetOutput(), *fit);
bit = ConstNeighborhoodIteratorType(r1, m_RealValuedInputImage.GetPointer(), face);
it = ImageRegionIterator<TOutputImage>(this->GetOutput(), face);
bit.OverrideBoundaryCondition(&nbc);
bit.GoToBegin();

Expand Down

0 comments on commit 2de7e24

Please sign in to comment.