Skip to content

Commit a63e366

Browse files
committed
STYLE: One declaration per line for readability
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
1 parent 1582014 commit a63e366

File tree

6 files changed

+31
-75
lines changed

6 files changed

+31
-75
lines changed

src/Core/Common/BoundingBoxOfAPointSet/Code.cxx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,11 @@ main()
3636
PointsContainerPointer points = pointSet->GetPoints();
3737

3838
// Create points
39-
PointType p0, p1, p2;
40-
41-
p0[0] = 0.0;
42-
p0[1] = 0.0;
43-
p0[2] = 0.0;
44-
p1[0] = 0.1;
45-
p1[1] = 0.0;
46-
p1[2] = 0.0;
47-
p2[0] = 0.0;
48-
p2[1] = 0.1;
49-
p2[2] = 0.0;
39+
// Create points
40+
using PointType = PointSetType::PointType;
41+
const PointType p0({ 0.0, 0.0, 0.0 });
42+
const PointType p1({ 0.1, 0.0, 0.0 });
43+
const PointType p2({ 0.0, 0.1, 0.0 });
5044

5145
points->InsertElement(0, p0);
5246
points->InsertElement(1, p1);

src/Core/Common/CreateAPointSet/Code.cxx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,9 @@ main()
3333

3434
// Create points
3535
using PointType = PointSetType::PointType;
36-
PointType p0, p1, p2;
37-
38-
p0[0] = 0.0;
39-
p0[1] = 0.0;
40-
p0[2] = 0.0;
41-
p1[0] = 0.1;
42-
p1[1] = 0.0;
43-
p1[2] = 0.0;
44-
p2[0] = 0.0;
45-
p2[1] = 0.1;
46-
p2[2] = 0.0;
36+
const PointType p0({ 0.0, 0.0, 0.0 });
37+
const PointType p1({ 0.1, 0.0, 0.0 });
38+
const PointType p2({ 0.0, 0.1, 0.0 });
4739

4840
points->InsertElement(0, p0);
4941
points->InsertElement(1, p1);

src/Core/Mesh/AddPointsAndEdges/Code.cxx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,10 @@ CreatePointOnlyMesh()
4242
auto mesh = MeshType::New();
4343

4444
// Create points
45-
MeshType::PointType p0, p1, p2, p3;
46-
47-
p0[0] = -1.0;
48-
p0[1] = -1.0;
49-
p0[2] = 0.0; // first point ( -1, -1, 0 )
50-
p1[0] = 1.0;
51-
p1[1] = -1.0;
52-
p1[2] = 0.0; // second point ( 1, -1, 0 )
53-
p2[0] = 1.0;
54-
p2[1] = 1.0;
55-
p2[2] = 0.0; // third point ( 1, 1, 0 )
56-
p3[0] = 1.0;
57-
p3[1] = 1.0;
58-
p3[2] = 1.0; // third point ( 1, 1, 1 )
45+
const MeshType::PointType p0({ -1.0, -1.0, 0 });
46+
const MeshType::PointType p1({ 1.0, -1.0, 0.0 });
47+
const MeshType::PointType p2({ 1.0, 1.0, 0.0 });
48+
const MeshType::PointType p3({ 1.0, 1.0, 1.0 });
5949

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

7060
PointsIterator pointIterator = mesh->GetPoints()->Begin();
71-
7261
PointsIterator end = mesh->GetPoints()->End();
7362
while (pointIterator != end)
7463
{

src/Core/Mesh/AddPointsAndEdges/Code.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def CreatePointOnlyMesh():
2626
mesh = MeshType.New()
2727

2828
# Create points
29-
p0 = [-1.0, -1.0, 0.0] # first point ( -1, -1, 0 )
30-
p1 = [1.0, -1.0, 0.0] # second point ( 1, -1, 0 )
31-
p2 = [1.0, 1.0, 0.0] # third point ( 1, 1, 0 )
32-
p3 = [1.0, 1.0, 1.0] # fourth point ( 1, 1, 1 )
29+
p0 = [-1.0, -1.0, 0.0]
30+
p1 = [1.0, -1.0, 0.0]
31+
p2 = [1.0, 1.0, 0.0]
32+
p3 = [1.0, 1.0, 1.0]
3333

3434
mesh.SetPoint(0, p0)
3535
mesh.SetPoint(1, p1)

src/Core/Mesh/WriteMeshToVTP/Code.cxx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,10 @@ CreateMeshWithEdges()
4848
auto mesh = MeshType::New();
4949

5050
// Create points
51-
MeshType::PointType p0, p1, p2, p3;
52-
53-
p0[0] = -1.0;
54-
p0[1] = -1.0;
55-
p0[2] = 0.0; // first point ( -1, -1, 0 )
56-
p1[0] = 1.0;
57-
p1[1] = -1.0;
58-
p1[2] = 0.0; // second point ( 1, -1, 0 )
59-
p2[0] = 1.0;
60-
p2[1] = 1.0;
61-
p2[2] = 0.0; // third point ( 1, 1, 0 )
62-
p3[0] = 1.0;
63-
p3[1] = 1.0;
64-
p3[2] = 1.0; // third point ( 1, 1, 1 )
51+
const MeshType::PointType p0({ -1.0, -1.0, 0 });
52+
const MeshType::PointType p1({ 1.0, -1.0, 0.0 });
53+
const MeshType::PointType p2({ 1.0, 1.0, 0.0 });
54+
const MeshType::PointType p3({ 1.0, 1.0, 1.0 });
6555

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

7666
PointsIterator pointIterator = mesh->GetPoints()->Begin();
77-
7867
PointsIterator end = mesh->GetPoints()->End();
7968
while (pointIterator != end)
8069
{
@@ -86,7 +75,6 @@ CreateMeshWithEdges()
8675
using CellAutoPointer = MeshType::CellType::CellAutoPointer;
8776
using LineType = itk::LineCell<MeshType::CellType>;
8877

89-
9078
CellAutoPointer line0;
9179
line0.TakeOwnership(new LineType);
9280
line0->SetPointId(0, 0); // line between points 0 and 1

src/Filtering/ImageGrid/FitSplineIntoPointSet/Code.cxx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,26 @@ main()
2828
constexpr unsigned int DataDimension = 2;
2929

3030
using DataType = itk::Vector<float, DataDimension>;
31-
3231
using PointSetType = itk::PointSet<DataType, ParametricDimension>;
3332

3433
auto pointSet = PointSetType::New();
3534

36-
PointSetType::PointType param0, param1, param2;
35+
const PointSetType::PointType param0{ 0.0 };
3736

38-
param0[0] = 0.0;
39-
DataType p0;
40-
p0[0] = 10.0;
41-
p0[1] = 10.0;
37+
const DataType p0({ 10.0, 10.0 });
4238

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

46-
param1[0] = 1.0;
47-
DataType p1;
48-
p1[0] = 80.0;
49-
p1[1] = 50.0;
42+
const PointSetType::PointType param1{ 1.0 };
43+
const DataType p1({ 80.0, 50.0 });
5044
pointSet->SetPoint(1, param1);
5145
pointSet->SetPointData(1, p1);
5246

53-
param2[0] = 2.0;
54-
DataType p2;
55-
p2[0] = 180.0;
56-
p2[1] = 180.0;
47+
48+
PointSetType::PointType param2{ 2.0 };
49+
DataType p2({ 180.0, 180.0 });
50+
5751
pointSet->SetPoint(2, param2);
5852
pointSet->SetPointData(2, p2);
5953

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

71-
ImageType::PointType parametricDomainOrigin;
72-
parametricDomainOrigin[0] = 0.0;
65+
const ImageType::PointType parametricDomainOrigin{ 0.0 };
7366

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

7770
ImageType::SizeType parametricDomainSize;
7871
parametricDomainSize[0] = 2.0 / parametricDomainSpacing[0] + 1;

0 commit comments

Comments
 (0)