Skip to content

Commit

Permalink
STYLE: One declaration per line for readability
Browse files Browse the repository at this point in the history
Multiple declarations in a single statement reduces readability.

Detect local variable declaration statements and update to have only one
statement per declaration.

Initialize values rather than independant assignments of each
element
  • Loading branch information
hjmjohnson committed Nov 26, 2024
1 parent fd491fd commit 96ecbf1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 71 deletions.
16 changes: 5 additions & 11 deletions src/Core/Common/BoundingBoxOfAPointSet/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,11 @@ main()
PointsContainerPointer points = pointSet->GetPoints();

// Create points
PointType p0, p1, p2;

p0[0] = 0.0;
p0[1] = 0.0;
p0[2] = 0.0;
p1[0] = 0.1;
p1[1] = 0.0;
p1[2] = 0.0;
p2[0] = 0.0;
p2[1] = 0.1;
p2[2] = 0.0;
// Create points
using PointType = PointSetType::PointType;
const PointType p0({ 0.0, 0.0, 0.0 });
const PointType p1({ 0.1, 0.0, 0.0 });
const PointType p2({ 0.0, 0.1, 0.0 });

points->InsertElement(0, p0);
points->InsertElement(1, p1);
Expand Down
14 changes: 3 additions & 11 deletions src/Core/Common/CreateAPointSet/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,9 @@ main()

// Create points
using PointType = PointSetType::PointType;
PointType p0, p1, p2;

p0[0] = 0.0;
p0[1] = 0.0;
p0[2] = 0.0;
p1[0] = 0.1;
p1[1] = 0.0;
p1[2] = 0.0;
p2[0] = 0.0;
p2[1] = 0.1;
p2[2] = 0.0;
const PointType p0({ 0.0, 0.0, 0.0 });
const PointType p1({ 0.1, 0.0, 0.0 });
const PointType p2({ 0.0, 0.1, 0.0 });

points->InsertElement(0, p0);
points->InsertElement(1, p1);
Expand Down
19 changes: 4 additions & 15 deletions src/Core/Mesh/AddPointsAndEdges/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,10 @@ CreatePointOnlyMesh()
auto mesh = MeshType::New();

// Create points
MeshType::PointType p0, p1, p2, p3;

p0[0] = -1.0;
p0[1] = -1.0;
p0[2] = 0.0; // first point ( -1, -1, 0 )
p1[0] = 1.0;
p1[1] = -1.0;
p1[2] = 0.0; // second point ( 1, -1, 0 )
p2[0] = 1.0;
p2[1] = 1.0;
p2[2] = 0.0; // third point ( 1, 1, 0 )
p3[0] = 1.0;
p3[1] = 1.0;
p3[2] = 1.0; // third point ( 1, 1, 1 )
const MeshType::PointType p0({ -1.0, -1.0, 0 }); // first point ( -1, -1, 0 )
const MeshType::PointType p1({ 1.0, -1.0, 0.0 }); // second point ( 1, -1, 0 )
const MeshType::PointType p2({ 1.0, 1.0, 0.0 }); // third point ( 1, 1, 0 )
const MeshType::PointType p3({ 1.0, 1.0, 1.0 }); // forth point ( 1, 1, 1 )

mesh->SetPoint(0, p0);
mesh->SetPoint(1, p1);
Expand All @@ -68,7 +58,6 @@ CreatePointOnlyMesh()
using PointsIterator = MeshType::PointsContainer::Iterator;

PointsIterator pointIterator = mesh->GetPoints()->Begin();

PointsIterator end = mesh->GetPoints()->End();
while (pointIterator != end)
{
Expand Down
20 changes: 4 additions & 16 deletions src/Core/Mesh/WriteMeshToVTP/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,10 @@ CreateMeshWithEdges()
auto mesh = MeshType::New();

// Create points
MeshType::PointType p0, p1, p2, p3;

p0[0] = -1.0;
p0[1] = -1.0;
p0[2] = 0.0; // first point ( -1, -1, 0 )
p1[0] = 1.0;
p1[1] = -1.0;
p1[2] = 0.0; // second point ( 1, -1, 0 )
p2[0] = 1.0;
p2[1] = 1.0;
p2[2] = 0.0; // third point ( 1, 1, 0 )
p3[0] = 1.0;
p3[1] = 1.0;
p3[2] = 1.0; // third point ( 1, 1, 1 )
const MeshType::PointType p0({ -1.0, -1.0, 0 }); // first point ( -1, -1, 0 )
const MeshType::PointType p1({ 1.0, -1.0, 0.0 }); // second point ( 1, -1, 0 )
const MeshType::PointType p2({ 1.0, 1.0, 0.0 }); // third point ( 1, 1, 0 )
const MeshType::PointType p3({ 1.0, 1.0, 1.0 }); // forth point ( 1, 1, 1 )

mesh->SetPoint(0, p0);
mesh->SetPoint(1, p1);
Expand All @@ -74,7 +64,6 @@ CreateMeshWithEdges()
using PointsIterator = MeshType::PointsContainer::Iterator;

PointsIterator pointIterator = mesh->GetPoints()->Begin();

PointsIterator end = mesh->GetPoints()->End();
while (pointIterator != end)
{
Expand All @@ -86,7 +75,6 @@ CreateMeshWithEdges()
using CellAutoPointer = MeshType::CellType::CellAutoPointer;
using LineType = itk::LineCell<MeshType::CellType>;


CellAutoPointer line0;
line0.TakeOwnership(new LineType);
line0->SetPointId(0, 0); // line between points 0 and 1
Expand Down
29 changes: 11 additions & 18 deletions src/Filtering/ImageGrid/FitSplineIntoPointSet/Code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,26 @@ main()
constexpr unsigned int DataDimension = 2;

using DataType = itk::Vector<float, DataDimension>;

using PointSetType = itk::PointSet<DataType, ParametricDimension>;

auto pointSet = PointSetType::New();

PointSetType::PointType param0, param1, param2;
const PointSetType::PointType param0{ 0.0 };

param0[0] = 0.0;
DataType p0;
p0[0] = 10.0;
p0[1] = 10.0;
const DataType p0({ 10.0, 10.0 });

pointSet->SetPoint(0, param0);
pointSet->SetPointData(0, p0);

param1[0] = 1.0;
DataType p1;
p1[0] = 80.0;
p1[1] = 50.0;
const PointSetType::PointType param1{ 1.0 };
const DataType p1({ 80.0, 50.0 });
pointSet->SetPoint(1, param1);
pointSet->SetPointData(1, p1);

param2[0] = 2.0;
DataType p2;
p2[0] = 180.0;
p2[1] = 180.0;

PointSetType::PointType param2{ 2.0 };
DataType p2({ 100.0, 100.0 });

pointSet->SetPoint(2, param2);
pointSet->SetPointData(2, p2);

Expand All @@ -68,11 +62,10 @@ main()
SplineFilterType::ArrayType closedim;
closedim[0] = 0;

ImageType::PointType parametricDomainOrigin;
parametricDomainOrigin[0] = 0.0;
const ImageType::PointType parametricDomainOrigin{ 0.0 };

ImageType::SpacingType parametricDomainSpacing;
parametricDomainSpacing[0] = 0.0001; // this determines the sampling of the continuous B-spline object.
// this determines the sampling of the continuous B-spline object.
const ImageType::SpacingType parametricDomainSpacing{ 0.0001 };

ImageType::SizeType parametricDomainSize;
parametricDomainSize[0] = 2.0 / parametricDomainSpacing[0] + 1;
Expand Down

0 comments on commit 96ecbf1

Please sign in to comment.