Skip to content

Commit

Permalink
STYLE: Remove p->Initialize() calls directly after p = T::New()
Browse files Browse the repository at this point in the history
`T::New()` already initializes the object it returns.

Using Notepad++, Replace in Files, doing:

    Find what:  (\w+)([ ]+= .+::New\(\);\r\n)[\r\n]* [ ]+\1->Initialize\(\);
    Replace with: $1$2
    Filters: itk*.* !+\test
    Directory: D:\src\ITK\Modules
    [v] Match case
    (*) Regular expression

Manually removed an obsolete comment saying `Clear elements`.
  • Loading branch information
N-Dekker committed Nov 21, 2024
1 parent ac021d0 commit 9e724f3
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ BSplineTransformInitializer<TTransform, TImage>::InitializeTransform() const
using CoordRepType = typename ImagePointType::CoordRepType;

using PointSetType = PointSet<CoordRepType, SpaceDimension>;
auto cornerPoints = PointSetType::New();
cornerPoints->Initialize();
autocornerPoints = PointSetType::New();


using PointType = typename PointSetType::PointType;
using PointIdentifier = typename PointSetType::PointIdentifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,15 +498,15 @@ N4BiasFieldCorrectionImageFilter<TInputImage, TMaskImage, TOutputImage>::UpdateB

const typename ImporterType::OutputImageType * parametricFieldEstimate = importer->GetOutput();

PointSetPointer fieldPoints = PointSetType::New();
fieldPoints->Initialize();
PointSetPointerfieldPoints = PointSetType::New();

auto & pointSTLContainer = fieldPoints->GetPoints()->CastToSTLContainer();
pointSTLContainer.reserve(numberOfIncludedPixels);
auto & pointDataSTLContainer = fieldPoints->GetPointData()->CastToSTLContainer();
pointDataSTLContainer.reserve(numberOfIncludedPixels);

auto weights = BSplineFilterType::WeightsContainerType::New();
weights->Initialize();
autoweights = BSplineFilterType::WeightsContainerType::New();

auto & weightSTLContainer = weights->CastToSTLContainer();
weightSTLContainer.reserve(numberOfIncludedPixels);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ DisplacementFieldToBSplineImageFilter<TInputImage, TInputPointSet, TOutputImage>
itkExceptionMacro("The number of input points does not match the number of weight elements.");
}

auto fieldPoints = InputPointSetType::New();
fieldPoints->Initialize();
autofieldPoints = InputPointSetType::New();


auto weights = WeightsContainerType::New();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ FastMarchingImageToNodePairContainerAdaptor<TInput, TOutput, TImage>::SetPointsF
{
if (iLabel == Traits::Alive || iLabel == Traits::InitialTrial || iLabel == Traits::Forbidden)
{
NodePairContainerPointer nodes = NodePairContainerType::New();
nodes->Initialize();
NodePairContainerPointernodes = NodePairContainerType::New();


using IteratorType = ImageRegionConstIteratorWithIndex<ImageType>;
IteratorType it(image, image->GetBufferedRegion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ WindowConvergenceMonitoringFunction<TScalar>::GetConvergenceValue() const -> Rea
bspliner->SetNumberOfControlPoints(ncps);
bspliner->SetNumberOfWorkUnits(1);

auto energyProfileWindow = EnergyProfileType::New();
energyProfileWindow->Initialize();
autoenergyProfileWindow = EnergyProfileType::New();


for (unsigned int n = 0; n < this->m_WindowSize; ++n)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ LandmarkBasedTransformInitializer<TTransform, TFixedImage, TMovingImage>::Intern
}

// Set a pointSet from the input landmarks.
auto pointSet = PointSetType::New();
pointSet->Initialize();
autopointSet = PointSetType::New();


PointsContainerConstIterator fixedIt = this->m_FixedLandmarks.begin();
PointsContainerConstIterator movingIt = this->m_MovingLandmarks.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ typename LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet, TInt
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet, TInternalComputationValueType>::
GetLabeledFixedPointSet(const LabelType label) const
{
auto fixedPointSet = FixedPointSetType::New();
fixedPointSet->Initialize();
autofixedPointSet = FixedPointSetType::New();


typename FixedPointSetType::PointIdentifier count{};

Expand All @@ -155,8 +155,8 @@ typename LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet, TInt
LabeledPointSetToPointSetMetricv4<TFixedPointSet, TMovingPointSet, TInternalComputationValueType>::
GetLabeledMovingPointSet(const LabelType label) const
{
auto movingPointSet = MovingPointSetType::New();
movingPointSet->Initialize();
automovingPointSet = MovingPointSetType::New();


typename MovingPointSetType::PointIdentifier count{};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ typename BSplineSyNImageRegistrationMethod<TFixedImage, TMovingImage, TOutputTra
}
}

auto gradientPointSet = BSplinePointSetType::New();
gradientPointSet->Initialize();
autogradientPointSet = BSplinePointSetType::New();


if (fixedPointSets[0]->GetNumberOfPoints() > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,8 @@ ImageRegistrationMethodv4<TFixedImage, TMovingImage, TTransform, TVirtualImage,

for (SizeValueType n = 0; n < numberOfLocalMetrics; ++n)
{
auto samplePointSet = MetricSamplePointSetType::New();
samplePointSet->Initialize();
autosamplePointSet = MetricSamplePointSetType::New();


using SamplePointType = typename MetricSamplePointSetType::PointType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ TimeVaryingBSplineVelocityFieldImageRegistrationMethod<TFixedImage,
this->m_OutputTransform->IntegrateVelocityField();

// Keep track of velocityFieldPointSet from the previous iteration
VelocityFieldPointSetPointer velocityFieldPointSetFromPreviousIteration = VelocityFieldPointSetType::New();
velocityFieldPointSetFromPreviousIteration->Initialize();
VelocityFieldPointSetPointervelocityFieldPointSetFromPreviousIteration = VelocityFieldPointSetType::New();

VelocityFieldPointSetPointer velocityFieldPointSet = VelocityFieldPointSetType::New();
velocityFieldPointSet->Initialize();

auto velocityFieldWeights = WeightsContainerType::New();
velocityFieldWeights->Initialize();
VelocityFieldPointSetPointervelocityFieldPointSet = VelocityFieldPointSetType::New();


autovelocityFieldWeights = WeightsContainerType::New();


// Monitor the convergence
using ConvergenceMonitoringType = itk::Function::WindowConvergenceMonitoringFunction<RealType>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ BayesianClassifierInitializationImageFilter<TInputImage, TProbabilityPrecisionTy
covarianceEstimatorsContainer->Reserve(m_NumberOfClasses);

m_MembershipFunctionContainer = MembershipFunctionContainerType::New();
m_MembershipFunctionContainer->Initialize(); // Clear elements
for (unsigned int i = 0; i < m_NumberOfClasses; ++i)
{
meanEstimatorsContainer->InsertElement(i, new typename GaussianMembershipFunctionType::MeanVectorType(1));
Expand Down

0 comments on commit 9e724f3

Please sign in to comment.