Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Replace Fill(0) on local variables with {} initialization #4897

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Modules/Core/Common/include/itkExtractImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,9 @@ ExtractImageFilter<TInputImage, TOutputImage>::SetExtractionRegion(InputImageReg
"InputImageDimension must be greater than OutputImageDimension");
m_ExtractionRegion = extractRegion;

InputImageSizeType inputSize = extractRegion.GetSize();
OutputImageSizeType outputSize;
outputSize.Fill(0);
OutputImageIndexType outputIndex;
outputIndex.Fill(0);
InputImageSizeType inputSize = extractRegion.GetSize();
OutputImageSizeType outputSize{};
OutputImageIndexType outputIndex{};

/**
* check to see if the number of non-zero entries in the extraction region
Expand Down Expand Up @@ -131,8 +129,7 @@ ExtractImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()

typename OutputImageType::SpacingType outputSpacing;
typename OutputImageType::DirectionType outputDirection;
typename OutputImageType::PointType outputOrigin;
outputOrigin.Fill(0.0);
typename OutputImageType::PointType outputOrigin{};

if (static_cast<unsigned int>(OutputImageDimension) > static_cast<unsigned int>(InputImageDimension))
{
Expand Down
5 changes: 2 additions & 3 deletions Modules/Core/Common/include/itkImageAlgorithm.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ ImageAlgorithm::EnlargeRegionOverBox(const typename InputImageType::RegionType &

for (unsigned int count = 0; count < numberOfInputCorners; ++count)
{
ContinuousInputIndexType currentInputCornerIndex;
currentInputCornerIndex.Fill(0);
unsigned int localCount = count;
ContinuousInputIndexType currentInputCornerIndex{};
unsigned int localCount = count;

// For each dimension, set the current index to either
// the highest or lowest index along this dimension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ FillImage(itk::Image<itk::Index<VDimension>, VDimension> * img)
using ImageType = itk::Image<IndexType, VDimension>;
const itk::Size<VDimension> size = img->GetRequestedRegion().GetSize();

unsigned int i;
IndexType loop;
loop.Fill(0);
unsigned int i;
IndexType loop{};
itk::ImageRegionIterator<ImageType> it(img, img->GetRequestedRegion());

while (!it.IsAtEnd())
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/include/itkTriangleCell.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ TriangleCell<TCellInterface>::ComputeCircumCenter(PointsContainer * iPoints) ->

if (sum_weights != 0.)
{
PointType oP;
oP.Fill(0.);
PointType oP{};

for (i = 0; i < 3; ++i)
{
Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Common/include/itkTriangleHelper.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,7 @@ auto
TriangleHelper<TPoint>::ComputeCircumCenter(const PointType & iP1, const PointType & iP2, const PointType & iP3)
-> PointType
{
PointType oPt;

oPt.Fill(0.0);
PointType oPt{};

CoordRepType a = iP2.SquaredEuclideanDistanceTo(iP3);
CoordRepType b = iP1.SquaredEuclideanDistanceTo(iP3);
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/src/itkAnatomicalOrientation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ AnatomicalOrientation::ConvertPositiveEnumToDirection(PositiveEnum orientationEn
const AnatomicalOrientation o(orientationEnum);

CoordinateEnum terms[Dimension] = { o.GetPrimaryTerm(), o.GetSecondaryTerm(), o.GetTertiaryTerm() };
DirectionType direction;
direction.Fill(0.0);
DirectionType direction{};

for (unsigned int i = 0; i < Dimension; ++i)
{
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/src/itkSpatialOrientationAdapter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ SpatialOrientationAdapter::ToDirectionCosines(const OrientationType & Or)
(static_cast<uint32_t>(Or) >>
static_cast<uint32_t>(SpatialOrientationEnums::CoordinateMajornessTerms::ITK_COORDINATE_TertiaryMinor)) &
0xff);
DirectionType direction;
direction.Fill(0.0);
DirectionType direction{};
for (unsigned int i = 0; i < DirectionType::ColumnDimensions; ++i)
{
switch (terms[i])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ template <typename TImageType>
auto
FiniteDifferenceFunction<TImageType>::ComputeNeighborhoodScales() const -> const NeighborhoodScalesType
{
NeighborhoodScalesType neighborhoodScales;

neighborhoodScales.Fill(0.0);
NeighborhoodScalesType neighborhoodScales{};
for (unsigned int i = 0; i < ImageDimension; ++i)
{
if (this->m_Radius[i] > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ GaussianBlurImageFunction<TInputImage, TOutput>::RecomputeContinuousGaussianKern
{
for (unsigned int direction = 0; direction < Self::ImageDimension; ++direction)
{
typename NeighborhoodType::SizeType size;
size.Fill(0);
typename NeighborhoodType::SizeType size{};
size[direction] = static_cast<SizeValueType>(m_Sigma[direction] * m_Extent[direction]);

NeighborhoodType gaussianNeighborhood;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ GaussianDerivativeImageFunction<TInputImage, TOutput>::RecomputeGaussianKernel()
// Set the derivative of the Gaussian first
OperatorNeighborhoodType dogNeighborhood;
typename GaussianDerivativeSpatialFunctionType::InputType pt;
typename NeighborhoodType::SizeType size;
size.Fill(0);
typename NeighborhoodType::SizeType size{};
size[direction] = static_cast<SizeValueType>(m_Sigma[direction] * m_Extent[direction]);
dogNeighborhood.SetRadius(size);
m_ImageNeighborhoodOffsets[direction] = GenerateRectangularImageNeighborhoodOffsets(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ VectorLinearInterpolateImageFunction<TInputImage, TCoordRep>::EvaluateAtContinuo
* neighbors. The weight for each neighbor is the fraction overlap
* of the neighbor pixel with respect to a pixel centered on point.
*/
OutputType output;
output.Fill(0.0);
OutputType output{};

using ScalarRealType = typename NumericTraits<PixelType>::ScalarRealType;
ScalarRealType totalOverlap{};
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Mesh/include/itkBinaryMask3DMeshSource.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ BinaryMask3DMeshSource<TInputImage, TOutputMesh>::BinaryMask3DMeshSource()
// Modify superclass default values, can be overridden by subclasses
this->SetNumberOfRequiredInputs(1);

SizeType size;
size.Fill(0);
SizeType size{};
m_RegionOfInterest.SetSize(size);

this->GetOutput()->GetPoints()->Reserve(m_NodeLimit);
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Mesh/include/itkSimplexMesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,7 @@ SimplexMesh<TPixelType, VDimension, TMeshTraits>::ComputeNormal(PointIdentifier
this->GetPoint(neighbors[2], &n3);

// compute normals
CovariantVectorType normal;
normal.Fill(0.0);
CovariantVectorType normal{};
CovariantVectorType z;
z.SetVnlVector(vnl_cross_3d((n2 - n1).GetVnlVector(), (n3 - n1).GetVnlVector()));
z.Normalize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ class ITK_TEMPLATE_EXPORT SimplexMeshToTriangleMeshFilter : public MeshToMeshFil
{
using PointIdIterator = typename SimplexPolygonType::PointIdIterator;
PointIdIterator it = poly->PointIdsBegin();
InputPointType center;
center.Fill(0);
InputPointType center{};

InputPointType p;
p.Fill(0);
InputPointType p{};

while (it != poly->PointIdsEnd())
{
Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Mesh/src/itkSimplexMeshGeometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ namespace itk
SimplexMeshGeometry::SimplexMeshGeometry()
{
double c = 1.0 / 3.0;
PointType p;

p.Fill(0.0);
PointType p{};

pos.Fill(0);
oldPos.Fill(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ QuadEdgeMeshEulerOperatorCreateCenterVertexFunction<TMesh, TQEType>::Evaluate(QE
this->m_Mesh->DeleteFace(e->GetLeft());

// create new point geometry
unsigned int sum = 0;
VectorType vec;
vec.Fill(0);
unsigned int sum = 0;
VectorType vec{};
PointIdentifier pid = this->m_Mesh->FindFirstUnusedPointIndex();
using AssociatedBarycenters = std::map<QEType *, PointIdentifier>;
AssociatedBarycenters m_AssocBary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ template <unsigned int TPointDimension>
LineSpatialObjectPoint<TPointDimension>::LineSpatialObjectPoint()
{
unsigned int ii = 0;
CovariantVectorType normal;
normal.Fill(0);
CovariantVectorType normal{};
while (ii < TPointDimension - 1)
{
this->m_NormalArrayInObjectSpace[ii] = normal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ MetaDTITubeConverter<VDimension>::MetaObjectToSpatialObject(const MetaObjectType

auto it2 = tube->GetPoints().begin();

itk::CovariantVector<double, VDimension> v;
v.Fill(0.0);
itk::Vector<double, VDimension> t;
t.Fill(0.0);
itk::CovariantVector<double, VDimension> v{};
itk::Vector<double, VDimension> t{};

for (unsigned int identifier = 0; identifier < tube->GetPoints().size(); ++identifier)
{
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/SpatialObjects/include/itkTubeSpatialObject.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,9 @@ TubeSpatialObject<TDimension, TTubePointType>::ComputeTangentsAndNormals()
((TubePointType *)(this->GetPoint(it1)))->SetTangentInObjectSpace(tb);
}

CovariantVectorType prevN1;
prevN1.Fill(0);
CovariantVectorType prevN1{};
prevN1[TDimension - 1] = 1;
CovariantVectorType prevN2;
prevN2.Fill(0);
CovariantVectorType prevN2{};
prevN2[TDimension - 2] = 1;

it1 = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ ExtractSliceImageFilter<TInputImage, TOutputImage>::SetExtractionRegion(InputIma
"InputImageDimension must be greater than OutputImageDimension");
m_ExtractionRegion = extractRegion;

unsigned int nonzeroSizeCount = 0;
InputImageSizeType inputSize = extractRegion.GetSize();
OutputImageSizeType outputSize;
outputSize.Fill(0);
OutputImageIndexType outputIndex;
outputIndex.Fill(0);
unsigned int nonzeroSizeCount = 0;
InputImageSizeType inputSize = extractRegion.GetSize();
OutputImageSizeType outputSize{};
OutputImageIndexType outputIndex{};

/**
* check to see if the number of non-zero entries in the extraction region
Expand Down Expand Up @@ -144,8 +142,7 @@ ExtractSliceImageFilter<TInputImage, TOutputImage>::GenerateOutputInformation()

typename OutputImageType::SpacingType outputSpacing;
typename OutputImageType::DirectionType outputDirection;
typename OutputImageType::PointType outputOrigin;
outputOrigin.Fill(0.0);
typename OutputImageType::PointType outputOrigin{};

if (static_cast<unsigned int>(OutputImageDimension) > static_cast<unsigned int>(InputImageDimension))
{
Expand Down
6 changes: 2 additions & 4 deletions Modules/Core/Transform/include/itkBSplineTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ BSplineTransform<TParametersValueType, VDimension, VSplineOrder>::BSplineTransfo
// dir[0][2],dir[1][2],dir[2][2]]


OriginType meshOrigin;
meshOrigin.Fill(0.0);
OriginType meshOrigin{};
PhysicalDimensionsType meshPhysical;
meshPhysical.Fill(1.0);

Expand Down Expand Up @@ -305,8 +304,7 @@ BSplineTransform<TParametersValueType, VDimension, VSplineOrder>::SetFixedParame

// Set the origin parameters
using PointType = typename ImageType::PointType;
PointType origin;
origin.Fill(0.0);
PointType origin{};
for (unsigned int i = 0; i < VDimension; ++i)
{
ScalarType gridSpacing = meshPhysical[i] / static_cast<ScalarType>(meshSize[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ BSplineTransformInitializer<TTransform, TImage>::InitializeTransform() const

for (unsigned int d = 0; d < cornerPoints->GetNumberOfPoints(); ++d)
{
PointType corner;
corner.Fill(0.0);
PointType corner{};
cornerPoints->GetPoint(d, &corner);

RealType distance = corner.SquaredEuclideanDistanceTo(bbox->GetMinimum());
Expand Down Expand Up @@ -179,8 +178,7 @@ BSplineTransformInitializer<TTransform, TImage>::InitializeTransform() const
PointIdentifier oppositeCornerId =
(static_cast<PointIdentifier>(1) << static_cast<PointIdentifier>(i)) ^ transformDomainOriginId;

PointType corner;
corner.Fill(0.0);
PointType corner{};
cornerPoints->GetPoint(oppositeCornerId, &corner);

VectorType vector = corner - transformDomainOrigin;
Expand Down Expand Up @@ -216,8 +214,7 @@ BSplineTransformInitializer<TTransform, TImage>::InitializeTransform() const

for (unsigned int d = 0; d < SpaceDimension; ++d)
{
PointType corner;
corner.Fill(0.0);
PointType corner{};
cornerPoints->GetPoint(minCornerId[d], &corner);

VectorType vector = corner - transformDomainOrigin;
Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Transform/include/itkTransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,7 @@ Transform<TParametersValueType, VInputDimension, VOutputDimension>::
PreservationOfPrincipalDirectionDiffusionTensor3DReorientation(const InputDiffusionTensor3DType & inputTensor,
const InverseJacobianPositionType & jacobian) const
{
Matrix<TParametersValueType, 3, 3> matrix;

matrix.Fill(0.0);
Matrix<TParametersValueType, 3, 3> matrix{};
for (unsigned int i = 0; i < 3; ++i)
{
matrix(i, i) = 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ template <typename TInputImage, typename TOutputImage>
void
PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>::Initialize()
{
typename InputImageType::IndexType requiredIndex;
requiredIndex.Fill(0);
typename InputImageType::IndexType requiredIndex{};
const typename InputImageType::RegionType largestRegion = this->GetInput()->GetLargestPossibleRegion();
const PatchRadiusType radius = this->GetPatchRadiusInVoxels();
PatchRadiusType two;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ TimeVaryingBSplineVelocityFieldTransform<TParametersValueType, VDimension>::Inte

using BSplineFilterType = BSplineControlPointImageFilter<VelocityFieldType, VelocityFieldType>;

typename BSplineFilterType::ArrayType closeDimensions;
closeDimensions.Fill(0);
typename BSplineFilterType::ArrayType closeDimensions{};
if (this->m_TemporalPeriodicity)
{
closeDimensions[VDimension] = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ TimeVaryingVelocityFieldIntegrationImageFilter<TTimeVaryingVelocityField, TDispl
// Solve the initial value problem using fourth-order Runge-Kutta
// y' = f(t, y), y(t_0) = y_0

VectorType zeroVector;
zeroVector.Fill(0.0);
VectorType zeroVector{};

// Initial conditions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,7 @@ DanielssonDistanceMapImageFilter<TInputImage, TOutputImage, TVoronoiImage>::Gene

// Process image.

OffsetType offset;
offset.Fill(0);
OffsetType offset{};

SizeValueType i = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,9 @@ SignedMaurerDistanceMapImageFilter<TInputImage, TOutputImage>::ThreadedGenerateD
// The result of this division is the offsetIndex, which is the index offset relative to the region of this thread.
// The true pixel location (idx) is provided by the sum of the offsetIndex and the startIndex.
InputSizeValueType index;
OutputIndexType offsetIndex;
offsetIndex.Fill(0);
OutputIndexType offsetIndex{};
InputSizeValueType tempRow = NumberOfRows[m_CurrentDimension];
OutputIndexType idx;
idx.Fill(0);
OutputIndexType idx{};

for (InputSizeValueType n = 0; n < tempRow; ++n)
{
Expand Down
3 changes: 1 addition & 2 deletions Modules/Filtering/FFT/test/itkFFTTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ test_fft(unsigned int * SizeOfDimensions)
// Set up spacing and origin to test passing of metadata
typename RealImageType::PointType origin;
typename RealImageType::SpacingType spacing;
typename RealImageType::DirectionType direction;
direction.Fill(0.0);
typename RealImageType::DirectionType direction{};
for (unsigned int i = 0; i < VImageDimensions; ++i)
{
origin[i] = static_cast<typename RealImageType::PointValueType>(i) + 1.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ FastMarchingImageFilterBase<TInput, TOutput>::FastMarchingImageFilterBase()
OutputSizeType outputSize;
outputSize.Fill(16);

NodeType outputIndex;
outputIndex.Fill(0);
NodeType outputIndex{};

m_OutputRegion.SetSize(outputSize);
m_OutputRegion.SetIndex(outputIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ MaskFeaturePointSelectionFilter<TImage, TMask, TFeatures>::GenerateData()
// compute and add structure tensor into pointData
if (m_ComputeStructureTensors)
{
StructureTensorType tensor;
tensor.Fill(0);
StructureTensorType tensor{};

Matrix<SpacePrecisionType, ImageDimension, 1> gradI; // vector declared as column matrix

Expand Down
Loading