Skip to content

Commit 0074c8e

Browse files
ENH: Adopt PrintNumericTrait helper toolkit-wide
Convert 513 PrintSelf call sites across 221 files in Modules/ to itk::print_helper::PrintNumericTrait. Handles 1/2-line forms, typename and itk:: variants, member and method-call expressions. Chained-statement form intentionally untouched (1 leftover at Modules/Filtering/ImageFusion/include/itkLabelOverlayImageFilter.hxx:103). No observable runtime change. Co-Authored-By: Jon Haitz Legarreta Gorroño <jhlegarreta@users.noreply.github.com>
1 parent 0e3ce94 commit 0074c8e

222 files changed

Lines changed: 746 additions & 1124 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Modules/Core/Common/include/itkAnnulusOperator.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "itkNeighborhoodOperator.h"
2222
#include "itkVector.h"
23+
#include "itkPrintHelper.h"
2324

2425
namespace itk
2526
{
@@ -225,13 +226,10 @@ class ITK_TEMPLATE_EXPORT AnnulusOperator : public NeighborhoodOperator<TPixel,
225226
os << indent << "Thickness: " << m_Thickness << std::endl;
226227
os << indent << "Normalize: " << m_Normalize << std::endl;
227228
os << indent << "BrightCenter: " << m_BrightCenter << std::endl;
228-
os << indent << "InteriorValue: " << static_cast<typename NumericTraits<PixelType>::PrintType>(m_InteriorValue)
229-
<< std::endl;
230-
os << indent << "AnnulusValue: " << static_cast<typename NumericTraits<PixelType>::PrintType>(m_AnnulusValue)
231-
<< std::endl;
232-
os << indent << "ExteriorValue: " << static_cast<typename NumericTraits<PixelType>::PrintType>(m_ExteriorValue)
233-
<< std::endl;
234-
os << indent << "Spacing: " << static_cast<typename NumericTraits<SpacingType>::PrintType>(m_Spacing) << std::endl;
229+
print_helper::PrintNumericTrait(os, indent, "InteriorValue", m_InteriorValue);
230+
print_helper::PrintNumericTrait(os, indent, "AnnulusValue", m_AnnulusValue);
231+
print_helper::PrintNumericTrait(os, indent, "ExteriorValue", m_ExteriorValue);
232+
print_helper::PrintNumericTrait(os, indent, "Spacing", m_Spacing);
235233
}
236234

237235
protected:

Modules/Core/Common/include/itkBinaryThresholdSpatialFunction.hxx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define itkBinaryThresholdSpatialFunction_hxx
2020

2121

22+
#include "itkPrintHelper.h"
2223
namespace itk
2324
{
2425

@@ -28,12 +29,8 @@ BinaryThresholdSpatialFunction<TFunction>::PrintSelf(std::ostream & os, Indent i
2829
{
2930
Superclass::PrintSelf(os, indent);
3031

31-
os << indent
32-
<< "LowerThreshold: " << static_cast<typename NumericTraits<FunctionOutputType>::PrintType>(m_LowerThreshold)
33-
<< std::endl;
34-
os << indent
35-
<< "UpperThreshold: " << static_cast<typename NumericTraits<FunctionOutputType>::PrintType>(m_UpperThreshold)
36-
<< std::endl;
32+
print_helper::PrintNumericTrait(os, indent, "LowerThreshold", m_LowerThreshold);
33+
print_helper::PrintNumericTrait(os, indent, "UpperThreshold", m_UpperThreshold);
3734

3835
itkPrintSelfObjectMacro(Function);
3936
}

Modules/Core/Common/include/itkImageDuplicator.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define itkImageDuplicator_hxx
2020

2121
#include "itkImageAlgorithm.h"
22+
#include "itkPrintHelper.h"
2223

2324
namespace itk
2425
{
@@ -64,8 +65,7 @@ ImageDuplicator<TInputImage>::PrintSelf(std::ostream & os, Indent indent) const
6465
itkPrintSelfObjectMacro(InputImage);
6566
itkPrintSelfObjectMacro(DuplicateImage);
6667

67-
os << indent << "InternalImageTime: " << static_cast<NumericTraits<ModifiedTimeType>::PrintType>(m_InternalImageTime)
68-
<< std::endl;
68+
print_helper::PrintNumericTrait(os, indent, "InternalImageTime", m_InternalImageTime);
6969
}
7070
} // end namespace itk
7171

Modules/Core/Common/include/itkMinimumMaximumImageCalculator.hxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define itkMinimumMaximumImageCalculator_hxx
2020

2121
#include "itkImageRegionConstIteratorWithIndex.h"
22+
#include "itkPrintHelper.h"
2223

2324
namespace itk
2425
{
@@ -113,8 +114,8 @@ MinimumMaximumImageCalculator<TInputImage>::PrintSelf(std::ostream & os, Indent
113114
{
114115
Superclass::PrintSelf(os, indent);
115116

116-
os << indent << "Minimum: " << static_cast<typename NumericTraits<PixelType>::PrintType>(m_Minimum) << std::endl;
117-
os << indent << "Maximum: " << static_cast<typename NumericTraits<PixelType>::PrintType>(m_Maximum) << std::endl;
117+
print_helper::PrintNumericTrait(os, indent, "Minimum", m_Minimum);
118+
print_helper::PrintNumericTrait(os, indent, "Maximum", m_Maximum);
118119
os << indent << "Index of Minimum: " << m_IndexOfMinimum << std::endl;
119120
os << indent << "Index of Maximum: " << m_IndexOfMaximum << std::endl;
120121
itkPrintSelfObjectMacro(Image);

Modules/Core/Common/include/itkNeighborhood.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ void
117117
Neighborhood<TPixel, VDimension, TContainer>::PrintSelf(std::ostream & os, Indent indent) const
118118
{
119119
using namespace itk::print_helper;
120-
os << indent << "Size: " << static_cast<typename NumericTraits<SizeType>::PrintType>(m_Size) << std::endl;
121-
os << indent << "Radius: " << static_cast<typename NumericTraits<SizeType>::PrintType>(m_Radius) << std::endl;
120+
print_helper::PrintNumericTrait(os, indent, "Size", m_Size);
121+
print_helper::PrintNumericTrait(os, indent, "Radius", m_Radius);
122122
os << indent << "StrideTable: " << m_StrideTable << std::endl;
123123
os << indent << "OffsetTable: " << m_OffsetTable << std::endl;
124124
}

Modules/Core/Common/include/itkObjectStore.hxx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ ObjectStore<TObjectType>::PrintSelf(std::ostream & os, Indent indent) const
134134
Superclass::PrintSelf(os, indent);
135135

136136
os << indent << "GrowthStrategy: " << m_GrowthStrategy << std::endl;
137-
os << indent << "Size: " << static_cast<NumericTraits<SizeValueType>::PrintType>(m_Size) << std::endl;
138-
os << indent << "LinearGrowthSize: " << static_cast<NumericTraits<SizeValueType>::PrintType>(m_LinearGrowthSize)
139-
<< std::endl;
137+
print_helper::PrintNumericTrait(os, indent, "Size", m_Size);
138+
print_helper::PrintNumericTrait(os, indent, "LinearGrowthSize", m_LinearGrowthSize);
140139
os << indent << "FreeList: " << m_FreeList << std::endl;
141140
}
142141
} // end namespace itk

Modules/Core/Common/include/itkPointSetToImageFilter.hxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "itkBoundingBox.h"
2323
#include "itkNumericTraits.h"
2424
#include "itkMath.h"
25+
#include "itkPrintHelper.h"
2526

2627
namespace itk
2728
{
@@ -227,10 +228,8 @@ PointSetToImageFilter<TInputPointSet, TOutputImage>::PrintSelf(std::ostream & os
227228
os << indent << "Origin: " << m_Origin << std::endl;
228229
os << indent << "Spacing: " << m_Spacing << std::endl;
229230
os << indent << "Direction: " << m_Direction << std::endl;
230-
os << indent << "Inside Value : " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_InsideValue)
231-
<< std::endl;
232-
os << indent << "Outside Value : " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_OutsideValue)
233-
<< std::endl;
231+
print_helper::PrintNumericTrait(os, indent, "Inside Value ", m_InsideValue);
232+
print_helper::PrintNumericTrait(os, indent, "Outside Value ", m_OutsideValue);
234233
}
235234
} // end namespace itk
236235

Modules/Core/Common/include/itkPrintHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ operator<<(std::ostream & os, const T (&arr)[VLength]);
8989
*
9090
* Typical use inside a \c PrintSelf override:
9191
* \code
92-
* itk::print_helper::PrintNumericTrait(os, indent, "Threshold", this->m_Threshold);
92+
* print_helper::PrintNumericTrait(os, indent, "Threshold", this->m_Threshold);
9393
* \endcode
9494
*/
9595
template <typename T>

Modules/Core/Common/include/itkResourceProbe.hxx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,16 @@ ResourceProbe<ValueType, MeanType>::Print(std::ostream & os, Indent indent) cons
5858
{
5959
using namespace print_helper;
6060

61-
os << indent << "StartValue: " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_StartValue)
62-
<< std::endl;
63-
os << indent << "TotalValue: " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_TotalValue)
64-
<< std::endl;
65-
os << indent << "MinimumValue: " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_MinimumValue)
66-
<< std::endl;
67-
os << indent << "MaximumValue: " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_MaximumValue)
68-
<< std::endl;
69-
os << indent
70-
<< "StandardDeviation: " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_StandardDeviation)
71-
<< std::endl;
72-
os << indent << "StandardError: " << static_cast<typename NumericTraits<ValueType>::PrintType>(m_StandardError)
73-
<< std::endl;
74-
75-
os << indent << "NumberOfStarts: " << static_cast<NumericTraits<CountType>::PrintType>(m_NumberOfStarts) << std::endl;
76-
os << indent << "NumberOfStops: " << static_cast<NumericTraits<CountType>::PrintType>(m_NumberOfStops) << std::endl;
77-
os << indent << "NumberOfIteration: " << static_cast<NumericTraits<CountType>::PrintType>(m_NumberOfIteration)
78-
<< std::endl;
61+
print_helper::PrintNumericTrait(os, indent, "StartValue", m_StartValue);
62+
print_helper::PrintNumericTrait(os, indent, "TotalValue", m_TotalValue);
63+
print_helper::PrintNumericTrait(os, indent, "MinimumValue", m_MinimumValue);
64+
print_helper::PrintNumericTrait(os, indent, "MaximumValue", m_MaximumValue);
65+
print_helper::PrintNumericTrait(os, indent, "StandardDeviation", m_StandardDeviation);
66+
print_helper::PrintNumericTrait(os, indent, "StandardError", m_StandardError);
67+
68+
print_helper::PrintNumericTrait(os, indent, "NumberOfStarts", m_NumberOfStarts);
69+
print_helper::PrintNumericTrait(os, indent, "NumberOfStops", m_NumberOfStops);
70+
print_helper::PrintNumericTrait(os, indent, "NumberOfIteration", m_NumberOfIteration);
7971

8072
os << indent << "ProbeValueList: " << m_ProbeValueList << std::endl;
8173

Modules/Core/GPUCommon/include/itkGPUReduction.hxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define itkGPUReduction_hxx
2020

2121
#include "itkMacro.h"
22+
#include "itkPrintHelper.h"
2223

2324
// #define CPU_VERIFY
2425

@@ -59,8 +60,8 @@ GPUReduction<TElement>::PrintSelf(std::ostream & os, Indent indent) const
5960
os << indent << "Size: " << m_Size << std::endl;
6061
itkPrintSelfBooleanMacro(SmallBlock);
6162

62-
os << indent << "GPUResult: " << static_cast<typename NumericTraits<TElement>::PrintType>(m_GPUResult) << std::endl;
63-
os << indent << "CPUResult: " << static_cast<typename NumericTraits<TElement>::PrintType>(m_CPUResult) << std::endl;
63+
print_helper::PrintNumericTrait(os, indent, "GPUResult", m_GPUResult);
64+
print_helper::PrintNumericTrait(os, indent, "CPUResult", m_CPUResult);
6465
}
6566

6667
template <typename TElement>

0 commit comments

Comments
 (0)