Skip to content

Commit

Permalink
STYLE: Prefer C++11 type alias over typedef
Browse files Browse the repository at this point in the history
Prefer C++11 type alias over typedef.

Follows the ITK convention adopted in:
https://review.source.kitware.com/%23/c/23103/

Changes done using the script contributed in:
InsightSoftwareConsortium/ITK@2c5d8d0
  • Loading branch information
jhlegarreta authored and dzenanz committed Mar 10, 2025
1 parent 7c6d1d1 commit b3b337b
Show file tree
Hide file tree
Showing 366 changed files with 3,545 additions and 3,898 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ limitations under the License.

enum { Dimension = 3 };

typedef itk::Image< float, Dimension > FloatImageType;
using FloatImageType = itk::Image< float, Dimension >;

void WriteImage( FloatImageType::Pointer i, const std::string & name )
{
typedef itk::ImageFileWriter< FloatImageType > WriterType;
using WriterType = itk::ImageFileWriter< FloatImageType >;
WriterType::Pointer writer = WriterType::New();

writer->SetInput( i );
Expand All @@ -42,11 +42,11 @@ void WriteImage( FloatImageType::Pointer i, const std::string & name )
writer->Update();
}

typedef itk::Image< unsigned short, Dimension > UShortImageType;
using UShortImageType = itk::Image< unsigned short, Dimension >;

void WriteImage( UShortImageType::Pointer i, const std::string & name )
{
typedef itk::ImageFileWriter< UShortImageType > UShortWriterType;
using UShortWriterType = itk::ImageFileWriter< UShortImageType >;
UShortWriterType::Pointer writer = UShortWriterType::New();

writer->SetInput( i );
Expand All @@ -59,12 +59,12 @@ int DoIt( int argc, char * argv[] )
{
PARSE_ARGS;

typedef tube::AtlasSummation AtlasSummationType;
typedef AtlasSummationType::InputPixelType InputPixelType;
typedef itk::Image< InputPixelType, Dimension > InputImageType;
typedef tube::MetaObjectDocument DocumentReaderType;
typedef itk::tube::ImageDocument ImageDocumentType;
typedef DocumentReaderType::ObjectDocumentListType ImageDocumentListType;
using AtlasSummationType = tube::AtlasSummation;
using InputPixelType = AtlasSummationType::InputPixelType;
using InputImageType = itk::Image< InputPixelType, Dimension >;
using DocumentReaderType = tube::MetaObjectDocument;
using ImageDocumentType = itk::tube::ImageDocument;
using ImageDocumentListType = DocumentReaderType::ObjectDocumentListType;
typedef
itk::tube::ObjectDocumentToImageFilter< ImageDocumentType, InputImageType >
DocumentToImageFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ class CompleteImageResampleFilter
{
public:

/** Standard class typedefs. */
typedef CompleteImageResampleFilter Self;
typedef ProcessObject Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;

typedef TInputImage InputImageType;
typedef TOutputImage OutputImageType;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename InputImageType::RegionType InputImageRegionType;
/** Standard class type alias. */
using Self = CompleteImageResampleFilter;
using Superclass = ProcessObject;
using Pointer = SmartPointer< Self >;
using ConstPointer = SmartPointer< const Self >;

using InputImageType = TInputImage;
using OutputImageType = TOutputImage;
using InputImageConstPointer = typename InputImageType::ConstPointer;
using OutputImagePointer = typename OutputImageType::Pointer;
using InputImageRegionType = typename InputImageType::RegionType;

/** Method for creation through the object factory. */
itkNewMacro( Self );
Expand All @@ -77,45 +77,42 @@ class CompleteImageResampleFilter
itkStaticConstMacro( ImageDimension, unsigned int,
TOutputImage::ImageDimension );

/** ResampleImageFilter typedef */
typedef ResampleImageFilter< InputImageType,
/** ResampleImageFilter type alias */
using ResampleImageFilterType = ResampleImageFilter< InputImageType,
OutputImageType,
TInterpolatorPrecisionType >
ResampleImageFilterType;
TInterpolatorPrecisionType >;

/** Transform typedef
/** Transform type alias
*
* Note: The transform needs to have an inverse to determine
* the proper outcome dimensions
*/
typedef TNonSingularTransform TransformType;
typedef typename TransformType::ConstPointer TransformPointerType;
using TransformType = TNonSingularTransform;
using TransformPointerType = typename TransformType::ConstPointer;

/** Interpolator typedef. */
typedef InterpolateImageFunction< InputImageType,
TInterpolatorPrecisionType>
InterpolatorType;
typedef typename InterpolatorType::Pointer InterpolatorPointerType;
/** Interpolator type alias. */
using InterpolatorType = InterpolateImageFunction< InputImageType,
TInterpolatorPrecisionType>;
using InterpolatorPointerType = typename InterpolatorType::Pointer;

/** Image size typedef. */
typedef Size< itkGetStaticConstMacro( ImageDimension ) >
SizeType;
/** Image size type alias. */
using SizeType = Size< itkGetStaticConstMacro( ImageDimension ) >;

/** Image index typedef. */
typedef typename TOutputImage::IndexType IndexType;
/** Image index type alias. */
using IndexType = typename TOutputImage::IndexType;

/** Image point typedef. */
typedef typename InterpolatorType::PointType PointType;
/** Image point type alias. */
using PointType = typename InterpolatorType::PointType;

/** Image pixel value typedef. */
typedef typename TOutputImage::PixelType PixelType;
/** Image pixel value type alias. */
using PixelType = typename TOutputImage::PixelType;

/** Typedef to describe the output image region type. */
typedef typename TOutputImage::RegionType OutputImageRegionType;
using OutputImageRegionType = typename TOutputImage::RegionType;

/** Image spacing typedef */
typedef typename TOutputImage::SpacingType SpacingType;
typedef typename TOutputImage::PointType OriginPointType;
/** Image spacing type alias */
using SpacingType = typename TOutputImage::SpacingType;
using OriginPointType = typename TOutputImage::PointType;

/*
* Set the coordinate transformation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,39 @@ class MeanAndSigmaImageBuilder : public Object
{
public:

typedef MeanAndSigmaImageBuilder Self;
typedef Object Superclass;
typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
using Self = MeanAndSigmaImageBuilder;
using Superclass = Object;
using Pointer = SmartPointer< Self >;
using ConstPointer = SmartPointer< const Self >;

itkStaticConstMacro( ImageDimension, unsigned int,
TInputImageType::ImageDimension );

itkNewMacro( Self );
itkTypeMacro( MeanAndSigmaImageBuilder, Object );

typedef TInputImageType InputImageType;
typedef TOutputMeanImageType OutputMeanImageType;
typedef TOutputSigmaImageType OutputSigmaImageType;
typedef Image<
float, itkGetStaticConstMacro( ImageDimension )> CountImageType;
using InputImageType = TInputImageType;
using OutputMeanImageType = TOutputMeanImageType;
using OutputSigmaImageType = TOutputSigmaImageType;
using CountImageType = Image<
float, itkGetStaticConstMacro( ImageDimension )>;

typedef typename InputImageType::PixelType InputPixelType;
typedef typename OutputMeanImageType::PixelType OutputMeanPixelType;
typedef typename OutputSigmaImageType::PixelType OutputSigmaPixelType;
typedef typename CountImageType::PixelType CountPixelType;
using InputPixelType = typename InputImageType::PixelType;
using OutputMeanPixelType = typename OutputMeanImageType::PixelType;
using OutputSigmaPixelType = typename OutputSigmaImageType::PixelType;
using CountPixelType = typename CountImageType::PixelType;

typedef typename InputImageType::Pointer InputImagePointer;
typedef typename OutputMeanImageType::Pointer OutputMeanImagePointer;
typedef typename OutputSigmaImageType::Pointer OutputSigmaImagePointer;
typedef typename CountImageType::Pointer CountImagePointer;
using InputImagePointer = typename InputImageType::Pointer;
using OutputMeanImagePointer = typename OutputMeanImageType::Pointer;
using OutputSigmaImagePointer = typename OutputSigmaImageType::Pointer;
using CountImagePointer = typename CountImageType::Pointer;

typedef typename InputImageType::RegionType RegionType;
typedef typename InputImageType::SizeType SizeType;
typedef typename InputImageType::SpacingType SpacingType;
typedef typename InputImageType::PointType PointType;
using RegionType = typename InputImageType::RegionType;
using SizeType = typename InputImageType::SizeType;
using SpacingType = typename InputImageType::SpacingType;
using PointType = typename InputImageType::PointType;

typedef Image< float, itkGetStaticConstMacro( ImageDimension ) >
ProcessImageType;
using ProcessImageType = Image< float, itkGetStaticConstMacro( ImageDimension ) >;

/**
* Add an image to the group being summed.
Expand Down Expand Up @@ -222,16 +221,16 @@ class MeanAndSigmaImageBuilder : public Object
~MeanAndSigmaImageBuilder( void ) {}

/** Processing image types */
typedef typename ProcessImageType::PixelType ProcessPixelType;
typedef typename ProcessImageType::Pointer ProcessImagePointer;

typedef ImageRegionConstIterator< InputImageType > InputConstIteratorType;
typedef ImageRegionConstIterator< ProcessImageType > ProcessConstIteratorType;
typedef ImageRegionIterator< ProcessImageType > ProcessIteratorType;
typedef ImageRegionConstIterator< CountImageType > CountConstIteratorType;
typedef ImageRegionIterator< CountImageType > CountIteratorType;
typedef ImageRegionIterator< OutputMeanImageType > OutputMeanIteratorType;
typedef ImageRegionIterator< OutputSigmaImageType > OutputSigmaIteratorType;
using ProcessPixelType = typename ProcessImageType::PixelType;
using ProcessImagePointer = typename ProcessImageType::Pointer;

using InputConstIteratorType = ImageRegionConstIterator< InputImageType >;
using ProcessConstIteratorType = ImageRegionConstIterator< ProcessImageType >;
using ProcessIteratorType = ImageRegionIterator< ProcessImageType >;
using CountConstIteratorType = ImageRegionConstIterator< CountImageType >;
using CountIteratorType = ImageRegionIterator< CountImageType >;
using OutputMeanIteratorType = ImageRegionIterator< OutputMeanImageType >;
using OutputSigmaIteratorType = ImageRegionIterator< OutputSigmaImageType >;

itkSetObjectMacro( SumImage, ProcessImageType );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ MeanAndSigmaImageBuilder< TInputImageType, TOutputMeanImageType,
ProcessImagePointer sumSquareImage = this->GetSumSquareImage();
CountImagePointer validImage = this->GetValidCountImage();

typedef ResampleImageFilter< ProcessImageType, ProcessImageType >
ResampleProcessImageType;
using ResampleProcessImageType = ResampleImageFilter< ProcessImageType, ProcessImageType >;
typename ResampleProcessImageType::Pointer processFilter =
ResampleProcessImageType::New();

Expand All @@ -291,8 +290,7 @@ MeanAndSigmaImageBuilder< TInputImageType, TOutputMeanImageType,
this->SetSumSquareImage( processFilter2->GetOutput() );


typedef ResampleImageFilter<CountImageType, CountImageType>
ResampleCountImageType;
using ResampleCountImageType = ResampleImageFilter<CountImageType, CountImageType>;
typename ResampleCountImageType::Pointer countFilter =
ResampleCountImageType::New();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ class MinimizeImageSizeFilter
{
public:

typedef MinimizeImageSizeFilter Self;
typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
using Self = MinimizeImageSizeFilter;
using Superclass = ImageToImageFilter< TInputImage, TInputImage >;

typedef SmartPointer< Self > Pointer;
typedef SmartPointer< const Self > ConstPointer;
using Pointer = SmartPointer< Self >;
using ConstPointer = SmartPointer< const Self >;

itkNewMacro( Self );
itkTypeMacro( MinimizeImageSizeFilter, ImageToImageFilter );

typedef TInputImage InputImageType;
typedef typename InputImageType::PixelType InputPixelType;
using InputImageType = TInputImage;
using InputPixelType = typename InputImageType::PixelType;

typedef TInputImage OutputImageType;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename OutputImageType::Pointer OutputImagePointer;
using OutputImageType = TInputImage;
using InputImageConstPointer = typename InputImageType::ConstPointer;
using OutputImagePointer = typename OutputImageType::Pointer;

typedef typename InputImageType::RegionType RegionType;
typedef typename InputImageType::SizeType SizeType;
typedef typename InputImageType::IndexType IndexType;
typedef typename InputImageType::PointType PointType;
using RegionType = typename InputImageType::RegionType;
using SizeType = typename InputImageType::SizeType;
using IndexType = typename InputImageType::IndexType;
using PointType = typename InputImageType::PointType;

/** Number of dimensions. */
itkStaticConstMacro( ImageDimension, unsigned int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ MinimizeImageSizeFilter<TInputImage>
}

// resample image to given region parameters
typedef ResampleImageFilter< InputImageType, OutputImageType >
ResampleFilterType;
using ResampleFilterType = ResampleImageFilter< InputImageType, OutputImageType >;
typename ResampleFilterType::Pointer resampleFilter =
ResampleFilterType::New();

Expand All @@ -134,8 +133,7 @@ MinimizeImageSizeFilter< TInputImage >
InputPixelType threshold = GetThresholdValue();
bool isThresAbove = this->GetThresholdAbove();

typedef ImageSliceConstIteratorWithIndex< InputImageType >
ImageSliceConstIteratorType;
using ImageSliceConstIteratorType = ImageSliceConstIteratorWithIndex< InputImageType >;
SizeType size = region.GetSize();

// Run sweep for back end
Expand Down Expand Up @@ -203,8 +201,7 @@ MinimizeImageSizeFilter< TInputImage >
InputPixelType threshold = GetThresholdValue();
bool isThresAbove = this->GetThresholdAbove();

typedef ImageSliceConstIteratorWithIndex< InputImageType>
ImageSliceConstIteratorType;
using ImageSliceConstIteratorType = ImageSliceConstIteratorWithIndex< InputImageType>;
IndexType index = region.GetIndex();
SizeType size = region.GetSize();

Expand Down
Loading

0 comments on commit b3b337b

Please sign in to comment.