Skip to content

Commit

Permalink
STYLE: Replace T var = NumericTraits<T>::ZeroValue() with T var{}
Browse files Browse the repository at this point in the history
Replaced initialization by `NumericTraits<T>::ZeroValue()` with empty `{}`
initializers. Did so by Replace in Files, using regular expressions:

    Find what: (\w+)([ ]+\w+) = NumericTraits<\1>::ZeroValue\(\);
    Replace with: $1$2{};

Follow-up to pull request #3950
commmit ef5cc8c
"STYLE: Prefer C++11 zero initializer to ZeroValue", by Hans Johnson.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Mar 10, 2023
1 parent 1c04d7d commit 42b0bfc
Show file tree
Hide file tree
Showing 127 changed files with 311 additions and 311 deletions.
Expand Up @@ -200,7 +200,7 @@ template <typename TImage, typename TBoundaryCondition>
auto
ConstNeighborhoodIterator<TImage, TBoundaryCondition>::GetBoundingBoxAsImageRegion() const -> RegionType
{
const IndexValueType zero = NumericTraits<IndexValueType>::ZeroValue();
const IndexValueType zero{};
const RegionType ans(this->GetIndex(zero), this->GetSize());

return ans;
Expand Down
Expand Up @@ -120,7 +120,7 @@ template <typename TImage>
auto
ConstNeighborhoodIteratorWithOnlyIndex<TImage>::GetBoundingBoxAsImageRegion() const -> RegionType
{
const IndexValueType zero = NumericTraits<IndexValueType>::ZeroValue();
const IndexValueType zero{};
const RegionType ans(this->GetIndex(zero), this->GetSize());

return ans;
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkCovariantVector.hxx
Expand Up @@ -125,7 +125,7 @@ template <typename T, unsigned int VVectorDimension>
auto
CovariantVector<T, VVectorDimension>::GetSquaredNorm() const -> RealValueType
{
RealValueType sum = NumericTraits<RealValueType>::ZeroValue();
RealValueType sum{};

for (unsigned int i = 0; i < VVectorDimension; ++i)
{
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkImageBase.h
Expand Up @@ -446,7 +446,7 @@ class ITK_TEMPLATE_EXPORT ImageBase : public DataObject

for (unsigned int i = 0; i < VImageDimension; ++i)
{
TCoordRep sum = NumericTraits<TCoordRep>::ZeroValue();
TCoordRep sum{};
for (unsigned int j = 0; j < VImageDimension; ++j)
{
sum += this->m_PhysicalPointToIndex[i][j] * (point[j] - this->m_Origin[j]);
Expand Down Expand Up @@ -532,7 +532,7 @@ class ITK_TEMPLATE_EXPORT ImageBase : public DataObject
{
for (unsigned int r = 0; r < VImageDimension; ++r)
{
TCoordRep sum = NumericTraits<TCoordRep>::ZeroValue();
TCoordRep sum{};
for (unsigned int c = 0; c < VImageDimension; ++c)
{
sum += this->m_IndexToPhysicalPoint(r, c) * index[c];
Expand Down Expand Up @@ -613,7 +613,7 @@ class ITK_TEMPLATE_EXPORT ImageBase : public DataObject
for (unsigned int i = 0; i < VImageDimension; ++i)
{
using CoordSumType = typename NumericTraits<TCoordRep>::AccumulateType;
CoordSumType sum = NumericTraits<CoordSumType>::ZeroValue();
CoordSumType sum{};
for (unsigned int j = 0; j < VImageDimension; ++j)
{
sum += direction[i][j] * inputGradient[j];
Expand Down Expand Up @@ -662,7 +662,7 @@ class ITK_TEMPLATE_EXPORT ImageBase : public DataObject
for (unsigned int i = 0; i < VImageDimension; ++i)
{
using CoordSumType = typename NumericTraits<TCoordRep>::AccumulateType;
CoordSumType sum = NumericTraits<CoordSumType>::ZeroValue();
CoordSumType sum{};
for (unsigned int j = 0; j < VImageDimension; ++j)
{
sum += inverseDirection[i][j] * inputGradient[j];
Expand Down
8 changes: 4 additions & 4 deletions Modules/Core/Common/include/itkMatrix.hxx
Expand Up @@ -31,7 +31,7 @@ Vector<T, VRows> Matrix<T, VRows, VColumns>::operator*(const Vector<T, VColumns>
Vector<T, VRows> result;
for (unsigned int r = 0; r < VRows; ++r)
{
T sum = NumericTraits<T>::ZeroValue();
T sum{};
for (unsigned int c = 0; c < VColumns; ++c)
{
sum += m_Matrix(r, c) * vect[c];
Expand All @@ -50,7 +50,7 @@ Point<T, VRows> Matrix<T, VRows, VColumns>::operator*(const Point<T, VColumns> &
Point<T, VRows> result;
for (unsigned int r = 0; r < VRows; ++r)
{
T sum = NumericTraits<T>::ZeroValue();
T sum{};
for (unsigned int c = 0; c < VColumns; ++c)
{
sum += m_Matrix(r, c) * pnt[c];
Expand All @@ -69,7 +69,7 @@ vnl_vector_fixed<T, VRows> Matrix<T, VRows, VColumns>::operator*(const vnl_vecto
vnl_vector_fixed<T, VRows> result;
for (unsigned int r = 0; r < VRows; ++r)
{
T sum = NumericTraits<T>::ZeroValue();
T sum{};
for (unsigned int c = 0; c < VColumns; ++c)
{
sum += m_Matrix(r, c) * inVNLvect[c];
Expand All @@ -88,7 +88,7 @@ CovariantVector<T, VRows> Matrix<T, VRows, VColumns>::operator*(const CovariantV
CovariantVector<T, VRows> result;
for (unsigned int r = 0; r < VRows; ++r)
{
T sum = NumericTraits<T>::ZeroValue();
T sum{};
for (unsigned int c = 0; c < VColumns; ++c)
{
sum += m_Matrix(r, c) * covect[c];
Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkNeighborhoodInnerProduct.hxx
Expand Up @@ -37,7 +37,7 @@ NeighborhoodInnerProduct<TImage, TOperator, TComputation>::Compute(const ConstNe

const typename OperatorType::ConstIterator op_end = op.End();
typename OperatorType::ConstIterator o_it = op.Begin();
AccumulateRealType sum = NumericTraits<AccumulateRealType>::ZeroValue();
AccumulateRealType sum{};

for (unsigned int i = start; o_it < op_end; i += stride, ++o_it)
{
Expand All @@ -63,7 +63,7 @@ NeighborhoodInnerProduct<TImage, TOperator, TComputation>::Compute(
using InputPixelRealType = typename NumericTraits<InputPixelType>::RealType;
using AccumulateRealType = typename NumericTraits<InputPixelRealType>::AccumulateType;

AccumulateRealType sum = NumericTraits<AccumulateRealType>::ZeroValue();
AccumulateRealType sum{};

using OutputPixelValueType = typename NumericTraits<OutputPixelType>::ValueType;

Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkPoint.h
Expand Up @@ -276,7 +276,7 @@ class ITK_TEMPLATE_EXPORT Point : public FixedArray<TCoordRep, VPointDimension>
RealType
SquaredEuclideanDistanceTo(const Point<TCoordRepB, VPointDimension> & pa) const
{
RealType sum = NumericTraits<RealType>::ZeroValue();
RealType sum{};

for (unsigned int i = 0; i < VPointDimension; ++i)
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkResourceProbe.hxx
Expand Up @@ -184,7 +184,7 @@ template <typename ValueType, typename MeanType>
MeanType
ResourceProbe<ValueType, MeanType>::GetMean() const
{
MeanType meanValue = NumericTraits<MeanType>::ZeroValue();
MeanType meanValue{};

if (this->m_NumberOfStops)
{
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/Common/include/itkSymmetricSecondRankTensor.hxx
Expand Up @@ -238,7 +238,7 @@ template <typename T, unsigned int VDimension>
auto
SymmetricSecondRankTensor<T, VDimension>::GetTrace() const -> AccumulateValueType
{
AccumulateValueType trace = NumericTraits<AccumulateValueType>::ZeroValue();
AccumulateValueType trace{};
unsigned int k = 0;

for (unsigned int i = 0; i < Dimension; ++i)
Expand Down Expand Up @@ -350,7 +350,7 @@ SymmetricSecondRankTensor<T, VDimension>::PreMultiply(const MatrixType & m) cons
{
for (unsigned int c = 0; c < VDimension; ++c)
{
AccumulateType sum = NumericTraits<AccumulateType>::ZeroValue();
AccumulateType sum{};
for (unsigned int t = 0; t < VDimension; ++t)
{
sum += m(r, t) * (*this)(t, c);
Expand All @@ -375,7 +375,7 @@ SymmetricSecondRankTensor<T, VDimension>::PostMultiply(const MatrixType & m) con
{
for (unsigned int c = 0; c < VDimension; ++c)
{
AccumulateType sum = NumericTraits<AccumulateType>::ZeroValue();
AccumulateType sum{};
for (unsigned int t = 0; t < VDimension; ++t)
{
sum += (*this)(r, t) * m(t, c);
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/include/itkVariableSizeMatrix.hxx
Expand Up @@ -45,7 +45,7 @@ Array<T> VariableSizeMatrix<T>::operator*(const Array<T> & vect) const
Array<T> result(rows);
for (unsigned int r = 0; r < rows; ++r)
{
T sum = NumericTraits<T>::ZeroValue();
T sum{};
for (unsigned int c = 0; c < cols; ++c)
{
sum += m_Matrix(r, c) * vect[c];
Expand Down
Expand Up @@ -169,7 +169,7 @@ typename FiniteDifferenceImageFilter<TInputImage, TOutputImage>::TimeStepType
FiniteDifferenceImageFilter<TInputImage, TOutputImage>::ResolveTimeStep(const std::vector<TimeStepType> & timeStepList,
const BooleanStdVectorType & valid) const
{
TimeStepType oMin = NumericTraits<TimeStepType>::ZeroValue();
TimeStepType oMin{};
bool flag = false;

// grab first valid value
Expand Down
Expand Up @@ -185,7 +185,7 @@ GPUFiniteDifferenceImageFilter<TInputImage, TOutputImage, TParentImageFilter>::R
const std::vector<TimeStepType> & timeStepList,
const BooleanStdVectorType & valid) const
{
TimeStepType oMin = NumericTraits<TimeStepType>::ZeroValue();
TimeStepType oMin{};
bool flag = false;

auto t_it = timeStepList.begin();
Expand Down
Expand Up @@ -176,7 +176,7 @@ CentralDifferenceImageFunction<TInputImage, TCoordRep, TOutputType>::EvaluateAtI

using PixelType = typename InputImageType::PixelType;
const PixelType * neighPixels[Self::ImageDimension][2];
const PixelType zeroPixel = NumericTraits<PixelType>::ZeroValue();
const PixelType zeroPixel{};
const unsigned int MaxDims = Self::ImageDimension;
bool dimOutOfBounds[Self::ImageDimension];

Expand Down Expand Up @@ -343,7 +343,7 @@ CentralDifferenceImageFunction<TInputImage, TCoordRep, TOutputType>::EvaluateSpe
bool dimOutOfBounds[Self::ImageDimension];
const unsigned int MaxDims = Self::ImageDimension;
PointValueType delta[Self::ImageDimension];
PixelType zeroPixel = NumericTraits<PixelType>::ZeroValue();
PixelType zeroPixel{};

ScalarDerivativeType componentDerivativeOut;
ScalarDerivativeType componentDerivative;
Expand Down Expand Up @@ -523,7 +523,7 @@ CentralDifferenceImageFunction<TInputImage, TCoordRep, TOutputType>::EvaluateAtC
PixelType neighPixels[Self::ImageDimension][2];
bool dimOutOfBounds[Self::ImageDimension];
const unsigned int MaxDims = Self::ImageDimension;
PixelType zeroPixel = NumericTraits<PixelType>::ZeroValue();
PixelType zeroPixel{};

for (unsigned int dim = 0; dim < MaxDims; ++dim)
{
Expand Down
Expand Up @@ -51,7 +51,7 @@ LabelImageGaussianInterpolateImageFunction<TInputImage, TCoordRep, TPixelCompare
}

RealType wmax = 0.0;
OutputType Vmax = NumericTraits<OutputType>::ZeroValue();
OutputType Vmax{};

// Create a map object to store weights for each label encountered
// inside the search region. This is not as efficient as having a
Expand Down
Expand Up @@ -56,7 +56,7 @@ VectorLinearInterpolateImageFunction<TInputImage, TCoordRep>::EvaluateAtContinuo
output.Fill(0.0);

using ScalarRealType = typename NumericTraits<PixelType>::ScalarRealType;
ScalarRealType totalOverlap = NumericTraits<ScalarRealType>::ZeroValue();
ScalarRealType totalOverlap{};

for (unsigned int counter = 0; counter < m_Neighbors; ++counter)
{
Expand Down
Expand Up @@ -186,7 +186,7 @@ typename WindowedSincInterpolateImageFunction<TInputImage, VRadius, TWindowFunct
// Iterate over the neighborhood, taking the correct set
// of weights in each dimension
using PixelType = typename NumericTraits<typename TInputImage::PixelType>::RealType;
PixelType xPixelValue = NumericTraits<PixelType>::ZeroValue();
PixelType xPixelValue{};
for (unsigned int j = 0; j < m_OffsetTableSize; ++j)
{
// Get the offset for this neighbor
Expand Down
Expand Up @@ -105,7 +105,7 @@ InteriorExteriorMeshFilter<TInputMesh, TOutputMesh, TSpatialFunction>::GenerateD
using ValueType = typename TSpatialFunction::OutputType;

using PointIdType = typename TOutputMesh::PointIdentifier;
PointIdType pointId = NumericTraits<PointIdType>::ZeroValue();
PointIdType pointId{};

while (inputPoint != inPoints->End())
{
Expand Down
Expand Up @@ -245,7 +245,7 @@ SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh>::ComputeCellParameters()
outputMesh->AddEdge(firstNewIndex, secondNewIndex);

// splitting cell
PointIdentifier newPointIndex = NumericTraits<PointIdentifier>::ZeroValue();
PointIdentifier newPointIndex{};
auto * polygon = new OutputPolygonType;
InputCellAutoPointer newPolygonPointer1;
newPolygonPointer1.TakeOwnership(polygon);
Expand Down Expand Up @@ -341,7 +341,7 @@ SimplexMeshAdaptTopologyFilter<TInputMesh, TOutputMesh>::ModifyNeighborCells(Cel
{
m_NewSimplexCellPointer.TakeOwnership(new OutputPolygonType);
InputPolygonPointIdIterator pointIt = nextCell->PointIdsBegin();
PointIdentifier cnt = NumericTraits<PointIdentifier>::ZeroValue();
PointIdentifier cnt{};
PointIdentifier first = *pointIt++;
PointIdentifier startId = first;

Expand Down
Expand Up @@ -353,7 +353,7 @@ TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh>::CreateCells()

// create a new cell
m_NewSimplexCellPointer.TakeOwnership(new OutputPolygonType);
PointIdentifier vertexIdx = NumericTraits<PointIdentifier>::ZeroValue();
PointIdentifier vertexIdx{};
CellIdentifier nextIdx = startIdx;
CellFeatureIdentifier featureId = 0;

Expand All @@ -367,7 +367,7 @@ TriangleMeshToSimplexMeshFilter<TInputMesh, TOutputMesh>::CreateCells()
EdgeIdentifierType line = std::make_pair(nextIdx, newIdx);
EdgeIdentifierType lineInv = std::make_pair(newIdx, nextIdx);

CellIdentifier edgeIdx = NumericTraits<CellIdentifier>::ZeroValue();
CellIdentifier edgeIdx{};

if (m_LineCellIndices->IndexExists(line))
{
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Mesh/include/itkVTKPolyDataWriter.hxx
Expand Up @@ -206,7 +206,7 @@ VTKPolyDataWriter<TInputMesh>::GenerateData()
// mesh can be saved.
cellIterator = cells->Begin();

PointIdentifier totalNumberOfPointsInPolygons = NumericTraits<PointIdentifier>::ZeroValue();
PointIdentifier totalNumberOfPointsInPolygons{};
while (cellIterator != cells->End())
{
CellType * cellPointer = cellIterator.Value();
Expand Down
6 changes: 3 additions & 3 deletions Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMesh.hxx
Expand Up @@ -1173,7 +1173,7 @@ QuadEdgeMesh<TPixel, VDimension, TTraits>::AddFace(const PointIdList & points) -
{
typename PointIdList::const_iterator itr = points.begin();
typename PointIdList::const_iterator end = points.end();
PointIdentifier count = NumericTraits<PointIdentifier>::ZeroValue();
PointIdentifier count{};
const PointIdentifier pointId = points[i];
while (itr != end)
{
Expand Down Expand Up @@ -1421,7 +1421,7 @@ QuadEdgeMesh<TPixel, VDimension, TTraits>::ComputeNumberOfPoints() const -> Poin
return (0);
}

PointIdentifier numberOfPoints = NumericTraits<PointIdentifier>::ZeroValue();
PointIdentifier numberOfPoints{};
PointsContainerConstIterator pointIterator = points->Begin();
PointsContainerConstIterator pointEnd = points->End();

Expand All @@ -1447,7 +1447,7 @@ template <typename TPixel, unsigned int VDimension, typename TTraits>
auto
QuadEdgeMesh<TPixel, VDimension, TTraits>::ComputeNumberOfFaces() const -> CellIdentifier
{
CellIdentifier numberOfFaces = NumericTraits<CellIdentifier>::ZeroValue();
CellIdentifier numberOfFaces{};
CellsContainerConstIterator cellIterator = this->GetCells()->Begin();
CellsContainerConstIterator cellEnd = this->GetCells()->End();

Expand Down

0 comments on commit 42b0bfc

Please sign in to comment.