Skip to content

Commit

Permalink
STYLE: Replace itkStaticConstMacro with static constexpr
Browse files Browse the repository at this point in the history
Use static constexpr directly now that C++11 conformance
is required by all compilers.

:%s/itkStaticConstMacro *( *\([^,]*\),[ \_s]*\([^,]*\),\_s*\([^)]*\)) */static constexpr \2 \1 = \3/ge

'itkStaticConstMacro(name, type, value)' became unconditionally
identical to 'static constexpr type name = value' with ITK commit
aec95193ab00e1322039911e1032da00f3a103b6 "ENH: Update compiler macros (#810)",
maekclena, 7 May 2019.

'itkGetStaticConstMacro(name)' became unconditionally identical to
'(Self::name)' with ITK commit 84e490b81e3f3c2b0edb89ae7b9de53bfc52f2b2
"Removing some outdated compiler conditionals", Hans Johnson, 31 July
2010.

Most 'itkStaticConstMacro' calls were removed by ITK commit 5c14741e1e063a132ea7e7ee69c5bd0a4e49af74
  • Loading branch information
hjmjohnson committed Jan 26, 2025
1 parent 3bd685c commit 1fa911b
Show file tree
Hide file tree
Showing 54 changed files with 129 additions and 129 deletions.
4 changes: 2 additions & 2 deletions ImageRegistration/itkANTSImageRegistrationOptimizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ ANTSImageRegistrationOptimizer<TDimension, TReal>::ComposeDiffs(DisplacementFiel
DisplacementFieldPointer fieldout,
TReal timesign)
{
typedef Point<TReal, itkGetStaticConstMacro(ImageDimension)> VPointType;
typedef Point<TReal, Self::ImageDimension> VPointType;

// field->SetSpacing( fieldtowarpby->GetSpacing() );
// field->SetOrigin( fieldtowarpby->GetOrigin() );
Expand Down Expand Up @@ -2597,7 +2597,7 @@ ANTSImageRegistrationOptimizer<TDimension, TReal>::IntegratePointVelocity(TReal
TReal finishtimein,
IndexType velind)
{
typedef Point<TReal, itkGetStaticConstMacro(ImageDimension + 1)> xPointType;
typedef Point<TReal, Self::ImageDimension + 1> xPointType;
this->m_Debug = false;


Expand Down
6 changes: 3 additions & 3 deletions ImageRegistration/itkANTSImageRegistrationOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ANTSImageRegistrationOptimizer final : public Object
typedef double TComp;
typedef TReal RealType;

typedef Image<RealType, itkGetStaticConstMacro(Dimension)> ImageType;
typedef Image<RealType, Self::Dimension> ImageType;
typedef typename ImageType::Pointer ImagePointer;

typedef itk::MatrixOffsetTransformBase<TComp, ImageDimension, ImageDimension> TransformType;
Expand Down Expand Up @@ -106,10 +106,10 @@ class ANTSImageRegistrationOptimizer final : public Object
typedef typename ParserType::OptionType OptionType;

typedef GeneralToBSplineDisplacementFieldFilter<DisplacementFieldType> BSplineFilterType;
typedef FixedArray<RealType, itkGetStaticConstMacro(ImageDimension)> ArrayType;
typedef FixedArray<RealType, Self::ImageDimension> ArrayType;

/** Typedefs for similarity metrics */
typedef ANTSSimilarityMetric<itkGetStaticConstMacro(Dimension), TReal> SimilarityMetricType;
typedef ANTSSimilarityMetric<Self::Dimension, TReal> SimilarityMetricType;
typedef typename SimilarityMetricType::Pointer SimilarityMetricPointer;
typedef std::vector<SimilarityMetricPointer> SimilarityMetricListType;

Expand Down
2 changes: 1 addition & 1 deletion ImageRegistration/itkANTSImageTransformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ANTSImageTransformation final : public Object
static constexpr unsigned int ImageDimension = TDimension;

typedef TReal RealType;
typedef Image<RealType, itkGetStaticConstMacro(Dimension)> ImageType;
typedef Image<RealType, Self::Dimension> ImageType;
/** declare transformation types */

typedef itk::MatrixOffsetTransformBase<TComp, TDimension, TDimension> AffineTransformType;
Expand Down
6 changes: 3 additions & 3 deletions ImageRegistration/itkANTSLabeledPointSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class ANTSLabeledPointSet : public Object
static constexpr unsigned int Dimension = TDimension;

typedef float RealType;
typedef Image<RealType, itkGetStaticConstMacro(Dimension)> ImageType;
typedef Image<RealType, Self::Dimension> ImageType;
typedef typename ImageType::Pointer ImagePointer;
typedef Vector<RealType, itkGetStaticConstMacro(Dimension)> VectorType;
typedef Image<VectorType, itkGetStaticConstMacro(Dimension)> DisplacementFieldType;
typedef Vector<RealType, Self::Dimension> VectorType;
typedef Image<VectorType, Self::Dimension> DisplacementFieldType;

/** Point Types for landmarks and labeled point-sets */
typedef long PointDataVectorType;
Expand Down
6 changes: 3 additions & 3 deletions ImageRegistration/itkANTSSimilarityMetric.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class ANTSSimilarityMetric final : public Object
static constexpr unsigned int Dimension = TDimension;

typedef TReal RealType;
typedef Image<RealType, itkGetStaticConstMacro(Dimension)> ImageType;
typedef Image<RealType, Self::Dimension> ImageType;
typedef typename ImageType::Pointer ImagePointer;
typedef Vector<RealType, itkGetStaticConstMacro(Dimension)> VectorType;
typedef Image<VectorType, itkGetStaticConstMacro(Dimension)> DisplacementFieldType;
typedef Vector<RealType, Self::Dimension> VectorType;
typedef Image<VectorType, Self::Dimension> DisplacementFieldType;

/** Point Types for landmarks and labeled point-sets */
typedef itk::ANTSLabeledPointSet<Dimension> LabeledPointSetType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class AvantsMutualInformationRegistrationFunction final
// DefaultInterpolatorType;

/** Covariant vector type. */
typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
typedef CovariantVector<double, Self::ImageDimension> CovariantVectorType;

/** Gradient calculator type. */
typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
Expand Down Expand Up @@ -227,8 +227,8 @@ class AvantsMutualInformationRegistrationFunction final

/** Types inherited from Superclass. */
typedef TranslationTransform<CoordinateRepresentationType,
// itkGetStaticConstMacro(ImageDimension),
itkGetStaticConstMacro(ImageDimension)>
// Self::ImageDimension,
Self::ImageDimension>
TransformType;

typedef ImageToImageMetric<TFixedImage, TMovingImage> Metricclass;
Expand Down Expand Up @@ -738,7 +738,7 @@ modified to round. 6- The normalization is done based on NomberOfHistogramBins-1
* image derivatives from the BSpline interpolator. Otherwise,
* image derivatives are computed using central differencing.
*/
typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> ImageDerivativesType;
typedef CovariantVector<double, Self::ImageDimension> ImageDerivativesType;

/** Boolean to indicate if the interpolator BSpline. */
bool m_InterpolatorIsBSpline;
Expand Down
8 changes: 4 additions & 4 deletions ImageRegistration/itkCrossCorrelationRegistrationFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class CrossCorrelationRegistrationFunction final
typedef typename Superclass::DisplacementFieldTypePointer DisplacementFieldTypePointer;
typedef typename TDisplacementField::PixelType VectorType;

typedef CovariantVector<float, itkGetStaticConstMacro(ImageDimension)> GradientPixelType;
typedef Image<GradientPixelType, itkGetStaticConstMacro(ImageDimension)> GradientImageType;
typedef CovariantVector<float, Self::ImageDimension> GradientPixelType;
typedef Image<GradientPixelType, Self::ImageDimension> GradientImageType;
typedef SmartPointer<GradientImageType> GradientImagePointer;
typedef GradientRecursiveGaussianImageFilter<MetricImageType, GradientImageType> GradientImageFilterType;
typedef typename GradientImageFilterType::Pointer GradientImageFilterPointer;
typedef Image<float, itkGetStaticConstMacro(ImageDimension)> BinaryImageType;
typedef Image<float, Self::ImageDimension> BinaryImageType;
typedef typename BinaryImageType::Pointer BinaryImagePointer;

/** Inherit some enums from the superclass. */
Expand All @@ -111,7 +111,7 @@ class CrossCorrelationRegistrationFunction final
typedef LinearInterpolateImageFunction<MovingImageType, CoordRepType> DefaultInterpolatorType;

/** Covariant vector type. */
typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
typedef CovariantVector<double, Self::ImageDimension> CovariantVectorType;

/** Gradient calculator type. */
typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class JensenHavrdaCharvatTsallisLabeledPointSetMetric : public PointSetToPointSe
/** Run-time type information (and related methods) */
itkOverrideGetNameOfClassMacro(JensenHavrdaCharvatTsallisLabeledPointSetMetric);

itkStaticConstMacro(PointDimension, unsigned int, TPointSet::PointDimension);
static constexpr unsigned int PointDimension = TPointSet::PointDimension;

/** Types transferred from the base class */
typedef typename Superclass::TransformType TransformType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class JensenHavrdaCharvatTsallisPointSetMetric : public PointSetToPointSetMetric
/** Run-time type information (and related methods) */
itkOverrideGetNameOfClassMacro(JensenHavrdaCharvatTsallisPointSetMetric);

itkStaticConstMacro(PointDimension, unsigned int, TPointSet::PointDimension);
static constexpr unsigned int PointDimension = TPointSet::PointDimension;

/** Types transferred from the base class */
typedef typename Superclass::TransformType TransformType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class JensenTsallisBSplineRegistrationFunction
/**
* Inherit some enums from the superclass.
*/
itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
itkStaticConstMacro(PointDimension, unsigned int, TFixedPointSet::PointDimension);
static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
static constexpr unsigned int PointDimension = TFixedPointSet::PointDimension;

typedef typename Superclass::NeighborhoodType NeighborhoodType;
typedef typename Superclass::FloatOffsetType FloatOffsetType;
Expand Down Expand Up @@ -87,7 +87,7 @@ class JensenTsallisBSplineRegistrationFunction
* BSpline typedefs
*/
/** Typedefs for B-spline filter */
typedef PointSet<VectorType, itkGetStaticConstMacro(ImageDimension)> BSplinePointSetType;
typedef PointSet<VectorType, Self::ImageDimension> BSplinePointSetType;
typedef BSplineScatteredDataPointSetToImageFilter<BSplinePointSetType, DisplacementFieldType> BSplineFilterType;
typedef typename BSplineFilterType::WeightsContainerType BSplineWeightsType;
typedef typename BSplineFilterType::PointDataImageType ControlPointLatticeType;
Expand Down
4 changes: 2 additions & 2 deletions ImageRegistration/itkPICSLAdvancedNormalizationToolKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PICSLAdvancedNormalizationToolKit final : public Object
static constexpr unsigned int Dimension = TDimension;
typedef double TComp;
typedef TReal RealType;
typedef Image<RealType, itkGetStaticConstMacro(Dimension)> ImageType;
typedef Image<RealType, Self::Dimension> ImageType;
typedef typename ImageType::Pointer ImagePointer;
typedef typename ImageType::PixelType PixelType;

Expand All @@ -63,7 +63,7 @@ class PICSLAdvancedNormalizationToolKit final : public Object
typedef typename LabeledPointSetType::PointSetType PointSetType;

/** Typedefs for similarity metrics */
typedef ANTSSimilarityMetric<itkGetStaticConstMacro(Dimension), TReal> SimilarityMetricType;
typedef ANTSSimilarityMetric<Self::Dimension, TReal> SimilarityMetricType;
typedef typename SimilarityMetricType::Pointer SimilarityMetricPointer;
typedef std::vector<SimilarityMetricPointer> SimilarityMetricListType;
typedef typename SimilarityMetricType::MetricType MetricBaseType;
Expand Down
8 changes: 4 additions & 4 deletions ImageRegistration/itkProbabilisticRegistrationFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class ProbabilisticRegistrationFunction final
typedef typename Superclass::DisplacementFieldTypePointer DisplacementFieldTypePointer;
typedef typename TDisplacementField::PixelType VectorType;

typedef CovariantVector<float, itkGetStaticConstMacro(ImageDimension)> GradientPixelType;
typedef Image<GradientPixelType, itkGetStaticConstMacro(ImageDimension)> GradientImageType;
typedef CovariantVector<float, Self::ImageDimension> GradientPixelType;
typedef Image<GradientPixelType, Self::ImageDimension> GradientImageType;
typedef SmartPointer<GradientImageType> GradientImagePointer;
typedef GradientRecursiveGaussianImageFilter<MetricImageType, GradientImageType> GradientImageFilterType;
typedef typename GradientImageFilterType::Pointer GradientImageFilterPointer;
typedef Image<float, itkGetStaticConstMacro(ImageDimension)> BinaryImageType;
typedef Image<float, Self::ImageDimension> BinaryImageType;
typedef typename BinaryImageType::Pointer BinaryImagePointer;

/** Inherit some enums from the superclass. */
Expand All @@ -111,7 +111,7 @@ class ProbabilisticRegistrationFunction final
typedef LinearInterpolateImageFunction<MovingImageType, CoordRepType> DefaultInterpolatorType;

/** Covariant vector type. */
typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
typedef CovariantVector<double, Self::ImageDimension> CovariantVectorType;

/** Gradient calculator type. */
typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class SpatialMutualInformationRegistrationFunction final
// DefaultInterpolatorType;

/** Covariant vector type. */
typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
typedef CovariantVector<double, Self::ImageDimension> CovariantVectorType;

/** Gradient calculator type. */
typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
Expand Down Expand Up @@ -224,8 +224,8 @@ class SpatialMutualInformationRegistrationFunction final

/** Types inherited from Superclass. */
typedef TranslationTransform<CoordinateRepresentationType,
// itkGetStaticConstMacro(ImageDimension),
itkGetStaticConstMacro(ImageDimension)>
// Self::ImageDimension,
Self::ImageDimension>
TransformType;

typedef ImageToImageMetric<TFixedImage, TMovingImage> Metricclass;
Expand Down Expand Up @@ -742,7 +742,7 @@ class SpatialMutualInformationRegistrationFunction final
* image derivatives from the BSpline interpolator. Otherwise,
* image derivatives are computed using central differencing.
*/
typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> ImageDerivativesType;
typedef CovariantVector<double, Self::ImageDimension> ImageDerivativesType;

/** Boolean to indicate if the interpolator BSpline. */
bool m_InterpolatorIsBSpline;
Expand Down
4 changes: 2 additions & 2 deletions ImageRegistration/itkSyNDemonsRegistrationFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class SyNDemonsRegistrationFunction final
typedef typename Superclass::DisplacementFieldTypePointer DisplacementFieldTypePointer;

/** Inherit some enums from the superclass. */
itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
static constexpr unsigned int ImageDimension = Superclass::ImageDimension;

/** Inherit some enums from the superclass. */
typedef typename Superclass::PixelType PixelType;
Expand All @@ -96,7 +96,7 @@ class SyNDemonsRegistrationFunction final
typedef LinearInterpolateImageFunction<MovingImageType, CoordRepType> DefaultInterpolatorType;

/** Covariant vector type. */
typedef CovariantVector<double, itkGetStaticConstMacro(ImageDimension)> CovariantVectorType;
typedef CovariantVector<double, Self::ImageDimension> CovariantVectorType;

/** Fixed image gradient calculator type. */
typedef CentralDifferenceImageFunction<FixedImageType> GradientCalculatorType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class VectorParameterizedNeighborhoodOperatorImageFilter final : public ImageToI
typedef typename TParamImage::PixelType ParameterImageTypePixelType;

/** Determine image dimension. */
itkStaticConstMacro(ImageDimension, unsigned int, TOutputImage::ImageDimension);
static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;

/** Image typedef support */
typedef TInputImage InputImageType;
Expand All @@ -93,8 +93,8 @@ class VectorParameterizedNeighborhoodOperatorImageFilter final : public ImageToI
/** Superclass typedefs. */
typedef typename Superclass::OutputImageRegionType OutputImageRegionType;

typedef itk::GaussianOperator<ScalarValueType, itkGetStaticConstMacro(ImageDimension)> OperatorType;
// Neighborhood<ScalarValueType, itkGetStaticConstMacro(ImageDimension)>
typedef itk::GaussianOperator<ScalarValueType, Self::ImageDimension> OperatorType;
// Neighborhood<ScalarValueType, Self::ImageDimension>

/** Sets the operator that is used to filter the image. Note
* that the operator is stored as an internal COPY (it
Expand Down
6 changes: 3 additions & 3 deletions ImageSegmentation/antsAtroposSegmentationImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ class AtroposSegmentationImageFilter final : public ImageToImageFilter<TInputIma
itkOverrideGetNameOfClassMacro(AtroposSegmentationImageFilter);

/** Dimension of the images. */
itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
itkStaticConstMacro(ClassifiedImageDimension, unsigned int, TClassifiedImage::ImageDimension);
itkStaticConstMacro(MaskImageDimension, unsigned int, TMaskImage::ImageDimension);
static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
static constexpr unsigned int ClassifiedImageDimension = TClassifiedImage::ImageDimension;
static constexpr unsigned int MaskImageDimension = TMaskImage::ImageDimension;

/** Typedef support of input types. */
typedef TInputImage ImageType;
Expand Down
10 changes: 5 additions & 5 deletions Temporary/antsFastMarchingImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ class FMarchingImageFilter final : public ImageToImageFilter<TSpeedImage, TLevel
typedef typename SpeedImageType::ConstPointer SpeedImageConstPointer;

/** Dimension of the level set and the speed image. */
itkStaticConstMacro(SetDimension, unsigned int, LevelSetType::SetDimension);
itkStaticConstMacro(SpeedImageDimension, unsigned int, SpeedImageType::ImageDimension);
static constexpr unsigned int SetDimension = LevelSetType::SetDimension;
static constexpr unsigned int SpeedImageDimension = SpeedImageType::ImageDimension;

/** Index typedef support. */
typedef Index<itkGetStaticConstMacro(SetDimension)> IndexType;
typedef Index<Self::SetDimension> IndexType;

/** Enum of Fast Marching algorithm point types. FarPoints represent far
* away points; TrialPoints represent points within a narrowband of the
Expand All @@ -185,14 +185,14 @@ class FMarchingImageFilter final : public ImageToImageFilter<TSpeedImage, TLevel
};

/** LabelImage typedef support. */
typedef Image<unsigned char, itkGetStaticConstMacro(SetDimension)> LabelImageType;
typedef Image<unsigned char, Self::SetDimension> LabelImageType;
typedef NeighborhoodIterator<LabelImageType> NeighborhoodIteratorType;

/** LabelImagePointer typedef support. */
typedef typename LabelImageType::Pointer LabelImagePointer;

/** ConnectedComponentImage typedef support. */
typedef Image<unsigned int, itkGetStaticConstMacro(SetDimension)> ConnectedComponentImageType;
typedef Image<unsigned int, Self::SetDimension> ConnectedComponentImageType;

/** ConnectedComponentImagePointer typedef support. */
typedef typename ConnectedComponentImageType::Pointer ConnectedComponentImagePointer;
Expand Down
2 changes: 1 addition & 1 deletion Temporary/itkFEMConformalMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class FEMConformalMap : public ProcessObject

typedef double RealType;
typedef vnl_vector<RealType> VectorType;
typedef vnl_vector_fixed<RealType, itkGetStaticConstMacro(ImageDimension)> FixedVectorType;
typedef vnl_vector_fixed<RealType, Self::ImageDimension> FixedVectorType;
typedef vnl_matrix<double> MatrixType;

/** FEM types */
Expand Down
2 changes: 1 addition & 1 deletion Temporary/itkFEMDiscConformalMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class FEMDiscConformalMap : public ProcessObject

typedef float RealType;
typedef vnl_vector<RealType> VectorType;
typedef vnl_vector_fixed<RealType, itkGetStaticConstMacro(ImageDimension)> FixedVectorType;
typedef vnl_vector_fixed<RealType, Self::ImageDimension> FixedVectorType;
typedef vnl_matrix<double> MatrixType;

typedef Image<float, 2> FlatImageType;
Expand Down
Loading

0 comments on commit 1fa911b

Please sign in to comment.