Skip to content

Commit

Permalink
STYLE: Use auto for variables initialized by New() in Examples
Browse files Browse the repository at this point in the history
Replace initializations of the form `T::Pointer var = T::New()`
(sometimes starting with `typename`) with `auto var = T::New()` in `Examples` to
reduce code redundancy

In accordance with C++ Core Guidelines, August 19, 2021:
"ES.11: Use `auto` to avoid redundant repetition of type names"
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-auto

Following PR #2826
and commit 828453d.
  • Loading branch information
jhlegarreta committed Dec 26, 2021
1 parent 5a21ea9 commit 41cedd7
Show file tree
Hide file tree
Showing 274 changed files with 1,613 additions and 1,824 deletions.
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Image/Image1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ main(int, char *[])
// Software Guide : EndLatex
//
// Software Guide : BeginCodeSnippet
ImageType::Pointer image = ImageType::New();
auto image = ImageType::New();
// Software Guide : EndCodeSnippet


Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Image/Image2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ main(int, char * argv[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
// Software Guide : EndCodeSnippet

// Software Guide : BeginLatex
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Image/Image3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ main(int, char *[])
using ImageType = itk::Image<unsigned short, 3>;

// Then the image object can be created
ImageType::Pointer image = ImageType::New();
auto image = ImageType::New();

// The image region should be initialized
const ImageType::SizeType size = {
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Image/Image4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ main(int, char *[])
{
constexpr unsigned int Dimension = 3;
using ImageType = itk::Image<unsigned short, Dimension>;
ImageType::Pointer image = ImageType::New();
auto image = ImageType::New();

const ImageType::SizeType size = {
{ 200, 200, 200 }
Expand Down
4 changes: 2 additions & 2 deletions Examples/DataRepresentation/Image/Image5.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ main(int argc, char * argv[])
// Software Guide : EndLatex
//
// Software Guide : BeginCodeSnippet
ImportFilterType::Pointer importFilter = ImportFilterType::New();
auto importFilter = ImportFilterType::New();
// Software Guide : EndCodeSnippet

// Software Guide : BeginLatex
Expand Down Expand Up @@ -241,7 +241,7 @@ main(int argc, char * argv[])

// Software Guide : BeginCodeSnippet
using WriterType = itk::ImageFileWriter<ImageType>;
WriterType::Pointer writer = WriterType::New();
auto writer = WriterType::New();

writer->SetFileName(argv[1]);
writer->SetInput(importFilter->GetOutput());
Expand Down
4 changes: 2 additions & 2 deletions Examples/DataRepresentation/Image/ImageAdaptor1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ main(int argc, char * argv[])
using ImageType = itk::Image<InputPixelType, Dimension>;

using ImageAdaptorType = itk::ImageAdaptor<ImageType, CastPixelAccessor>;
ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
auto adaptor = ImageAdaptorType::New();
// Software Guide : EndCodeSnippet

// Software Guide : BeginLatex
Expand All @@ -124,7 +124,7 @@ main(int argc, char * argv[])

// Software Guide : BeginCodeSnippet
using ReaderType = itk::ImageFileReader<ImageType>;
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
// Software Guide : EndCodeSnippet


Expand Down
8 changes: 4 additions & 4 deletions Examples/DataRepresentation/Image/ImageAdaptor2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ main(int argc, char * argv[])
using ImageAdaptorType =
itk::ImageAdaptor<ImageType, RedChannelPixelAccessor>;

ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
auto adaptor = ImageAdaptorType::New();
// Software Guide : EndCodeSnippet


Expand All @@ -124,7 +124,7 @@ main(int argc, char * argv[])

// Software Guide : BeginCodeSnippet
using ReaderType = itk::ImageFileReader<ImageType>;
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
// Software Guide : EndCodeSnippet

reader->SetFileName(argv[1]);
Expand Down Expand Up @@ -152,9 +152,9 @@ main(int argc, char * argv[])
using RescalerType =
itk::RescaleIntensityImageFilter<ImageAdaptorType, OutputImageType>;

RescalerType::Pointer rescaler = RescalerType::New();
auto rescaler = RescalerType::New();
using WriterType = itk::ImageFileWriter<OutputImageType>;
WriterType::Pointer writer = WriterType::New();
auto writer = WriterType::New();
// Software Guide : EndCodeSnippet


Expand Down
10 changes: 5 additions & 5 deletions Examples/DataRepresentation/Image/ImageAdaptor3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ main(int argc, char * argv[])
itk::GradientRecursiveGaussianImageFilter<InputImageType,
VectorImageType>;

GradientFilterType::Pointer gradient = GradientFilterType::New();
auto gradient = GradientFilterType::New();
// Software Guide : EndCodeSnippet


Expand All @@ -155,7 +155,7 @@ main(int argc, char * argv[])
using ImageAdaptorType =
itk::ImageAdaptor<VectorImageType, itk::VectorPixelAccessor>;

ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
auto adaptor = ImageAdaptorType::New();
// Software Guide : EndCodeSnippet


Expand Down Expand Up @@ -186,7 +186,7 @@ main(int argc, char * argv[])

// Software Guide : BeginCodeSnippet
using ReaderType = itk::ImageFileReader<InputImageType>;
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
gradient->SetInput(reader->GetOutput());

reader->SetFileName(argv[1]);
Expand All @@ -211,9 +211,9 @@ main(int argc, char * argv[])
using OutputImageType = itk::Image<unsigned char, Dimension>;
using RescalerType =
itk::RescaleIntensityImageFilter<ImageAdaptorType, OutputImageType>;
RescalerType::Pointer rescaler = RescalerType::New();
auto rescaler = RescalerType::New();
using WriterType = itk::ImageFileWriter<OutputImageType>;
WriterType::Pointer writer = WriterType::New();
auto writer = WriterType::New();

writer->SetFileName(argv[2]);

Expand Down
8 changes: 4 additions & 4 deletions Examples/DataRepresentation/Image/ImageAdaptor4.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ main(int argc, char * argv[])
using ImageAdaptorType =
itk::ImageAdaptor<ImageType, itk::ThresholdingPixelAccessor>;

ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
auto adaptor = ImageAdaptorType::New();
// Software Guide : EndCodeSnippet


Expand Down Expand Up @@ -176,7 +176,7 @@ main(int argc, char * argv[])

// Software Guide : BeginCodeSnippet
using ReaderType = itk::ImageFileReader<ImageType>;
ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();

Expand All @@ -187,9 +187,9 @@ main(int argc, char * argv[])
using RescalerType =
itk::RescaleIntensityImageFilter<ImageAdaptorType, ImageType>;

RescalerType::Pointer rescaler = RescalerType::New();
auto rescaler = RescalerType::New();
using WriterType = itk::ImageFileWriter<ImageType>;
WriterType::Pointer writer = WriterType::New();
auto writer = WriterType::New();


writer->SetFileName(argv[2]);
Expand Down
4 changes: 2 additions & 2 deletions Examples/DataRepresentation/Image/RGBImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ main(int, char * argv[])
using ReaderType = itk::ImageFileReader<ImageType>;
// Software Guide : EndCodeSnippet

ReaderType::Pointer reader = ReaderType::New();
const char * const filename = argv[1];
auto reader = ReaderType::New();
const char * const filename = argv[1];
reader->SetFileName(filename);
reader->Update();

Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Image/VectorImage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ main(int, char *[])
// Software Guide : EndCodeSnippet

// Then the image object can be created
ImageType::Pointer image = ImageType::New();
auto image = ImageType::New();

// The image region should be initialized
const ImageType::IndexType start = {
Expand Down
4 changes: 2 additions & 2 deletions Examples/DataRepresentation/Mesh/ImageToPointSet.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ main(int argc, char * argv[])
using PointSetType = itk::PointSet<PixelType, Dimension>;
using ReaderType = itk::ImageFileReader<ImageType>;

ReaderType::Pointer reader = ReaderType::New();
auto reader = ReaderType::New();

const char * inputFilename = argv[1];
reader->SetFileName(inputFilename);
Expand All @@ -67,7 +67,7 @@ main(int argc, char * argv[])
return EXIT_FAILURE;
}

PointSetType::Pointer pointSet = PointSetType::New();
auto pointSet = PointSetType::New();


using IteratorType = itk::ImageRegionConstIterator<ImageType>;
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/Mesh1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();
// Software Guide : EndCodeSnippet


Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/Mesh2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();

MeshType::PointType p0;
MeshType::PointType p1;
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/Mesh3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();

using PointType = MeshType::PointType;
PointType point;
Expand Down
7 changes: 3 additions & 4 deletions Examples/DataRepresentation/Mesh/MeshCellVisitor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CustomTriangleVisitor
int
main(int, char *[])
{
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();


// Creating the points and inserting them in the mesh
Expand Down Expand Up @@ -269,8 +269,7 @@ main(int, char *[])


// Software Guide : BeginCodeSnippet
TriangleVisitorInterfaceType::Pointer triangleVisitor =
TriangleVisitorInterfaceType::New();
auto triangleVisitor = TriangleVisitorInterfaceType::New();
// Software Guide : EndCodeSnippet


Expand All @@ -286,7 +285,7 @@ main(int, char *[])

// Software Guide : BeginCodeSnippet
using CellMultiVisitorType = CellType::MultiVisitor;
CellMultiVisitorType::Pointer multiVisitor = CellMultiVisitorType::New();
auto multiVisitor = CellMultiVisitorType::New();
// Software Guide : EndCodeSnippet


Expand Down
16 changes: 6 additions & 10 deletions Examples/DataRepresentation/Mesh/MeshCellVisitor2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class CustomTetrahedronVisitor
int
main(int, char *[])
{
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();

// Creating the points and inserting them in the mesh
//
Expand Down Expand Up @@ -397,17 +397,13 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
VertexVisitorInterfaceType::Pointer vertexVisitor =
VertexVisitorInterfaceType::New();
auto vertexVisitor = VertexVisitorInterfaceType::New();

LineVisitorInterfaceType::Pointer lineVisitor =
LineVisitorInterfaceType::New();
auto lineVisitor = LineVisitorInterfaceType::New();

TriangleVisitorInterfaceType::Pointer triangleVisitor =
TriangleVisitorInterfaceType::New();
auto triangleVisitor = TriangleVisitorInterfaceType::New();

TetrahedronVisitorInterfaceType::Pointer tetrahedronVisitor =
TetrahedronVisitorInterfaceType::New();
auto tetrahedronVisitor = TetrahedronVisitorInterfaceType::New();
// Software Guide : EndCodeSnippet


Expand Down Expand Up @@ -451,7 +447,7 @@ main(int, char *[])

// Software Guide : BeginCodeSnippet
using CellMultiVisitorType = CellType::MultiVisitor;
CellMultiVisitorType::Pointer multiVisitor = CellMultiVisitorType::New();
auto multiVisitor = CellMultiVisitorType::New();
// Software Guide : EndCodeSnippet


Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/MeshCellsIteration.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ main(int, char *[])
using TriangleType = itk::TriangleCell<CellType>;
using TetrahedronType = itk::TetrahedronCell<CellType>;

MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();


// Creating the points and inserting them in the mesh
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/MeshKComplex.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();

MeshType::PointType point0;
MeshType::PointType point1;
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/MeshPolyLine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();

MeshType::PointType point0;
MeshType::PointType point1;
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/MeshTraits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
MeshType::Pointer mesh = MeshType::New();
auto mesh = MeshType::New();

using PointType = MeshType::PointType;
PointType point;
Expand Down
2 changes: 1 addition & 1 deletion Examples/DataRepresentation/Mesh/PointSet1.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ main(int, char *[])
// Software Guide : EndLatex

// Software Guide : BeginCodeSnippet
PointSetType::Pointer pointsSet = PointSetType::New();
auto pointsSet = PointSetType::New();
// Software Guide : EndCodeSnippet


Expand Down
4 changes: 2 additions & 2 deletions Examples/DataRepresentation/Mesh/PointSet2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ main(int, char *[])


// Software Guide : BeginCodeSnippet
PointsContainer::Pointer points = PointsContainer::New();
auto points = PointsContainer::New();
// Software Guide : EndCodeSnippet


Expand Down Expand Up @@ -117,7 +117,7 @@ main(int, char *[])
points->InsertElement(pointId++, p1);
// Software Guide : EndCodeSnippet

PointSetType::Pointer pointSet = PointSetType::New();
auto pointSet = PointSetType::New();

// Software Guide : BeginLatex
//
Expand Down
4 changes: 2 additions & 2 deletions Examples/DataRepresentation/Mesh/PointSet3.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ main(int, char *[])


// A point set is instantiated here
PointSetType::Pointer pointSet = PointSetType::New();
auto pointSet = PointSetType::New();


// Software Guide : BeginLatex
Expand Down Expand Up @@ -137,7 +137,7 @@ main(int, char *[])


// Software Guide : BeginCodeSnippet
PointDataContainer::Pointer pointData = PointDataContainer::New();
auto pointData = PointDataContainer::New();
// Software Guide : EndCodeSnippet


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ main(int, char *[])

// Software Guide : BeginCodeSnippet
using PointSetType = itk::PointSet<PixelType, Dimension>;
PointSetType::Pointer pointSet = PointSetType::New();
auto pointSet = PointSetType::New();
// Software Guide : EndCodeSnippet


Expand Down
Loading

0 comments on commit 41cedd7

Please sign in to comment.