Skip to content

Commit 7255f33

Browse files
authored
Merge pull request #73 from thewtex/clang-format
STYLE: Use ITK clang-format style
2 parents 444a3fe + 1f39292 commit 7255f33

6 files changed

+72
-79
lines changed

{{cookiecutter.project_name}}/include/itkMinimalStandardRandomVariateGenerator.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,26 @@ namespace Statistics
5050
*
5151
* \ingroup {{ cookiecutter.module_name }}
5252
*/
53-
class {{ cookiecutter.module_name }}_EXPORT MinimalStandardRandomVariateGenerator:
54-
public RandomVariateGeneratorBase
53+
class {{ cookiecutter.module_name }}_EXPORT MinimalStandardRandomVariateGenerator : public RandomVariateGeneratorBase
5554
{
5655
public:
5756
ITK_DISALLOW_COPY_AND_ASSIGN(MinimalStandardRandomVariateGenerator);
5857

5958
/** Standard class typedefs. */
6059
using Self = MinimalStandardRandomVariateGenerator;
6160
using Superclass = RandomVariateGeneratorBase;
62-
using Pointer = SmartPointer< Self >;
63-
using ConstPointer = SmartPointer< const Self >;
61+
using Pointer = SmartPointer<Self>;
62+
using ConstPointer = SmartPointer<const Self>;
6463

6564
using IntegerType = uint32_t;
6665

6766
using NormalGeneratorType = itk::Statistics::NormalVariateGenerator;
6867

6968
/** Run-time type information (and related methods). */
70-
itkTypeMacro( MinimalStandardRandomVariateGenerator, RandomVariateGeneratorBase);
69+
itkTypeMacro(MinimalStandardRandomVariateGenerator, RandomVariateGeneratorBase);
7170

7271
/** Method for creation through the object factory. */
73-
itkNewMacro( Self );
72+
itkNewMacro(Self);
7473

7574
/** initialize with a simple IntegerType */
7675
void Initialize(int randomSeed);
@@ -85,7 +84,6 @@ class {{ cookiecutter.module_name }}_EXPORT MinimalStandardRandomVariateGenerato
8584
void PrintSelf(std::ostream & os, Indent indent) const override;
8685

8786
private:
88-
8987
NormalGeneratorType::Pointer m_NormalGenerator;
9088
};
9189

{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ namespace itk
3333
* \ingroup {{ cookiecutter.module_name }}
3434
*
3535
*/
36-
template< typename TInputImage, typename TOutputImage >
37-
class {{ cookiecutter.filter_name }}: public ImageToImageFilter< TInputImage, TOutputImage >
36+
template <typename TInputImage, typename TOutputImage>
37+
class {{ cookiecutter.filter_name }} : public ImageToImageFilter<TInputImage, TOutputImage>
3838
{
3939
public:
4040
ITK_DISALLOW_COPY_AND_ASSIGN({{ cookiecutter.filter_name }});
@@ -48,39 +48,37 @@ class {{ cookiecutter.filter_name }}: public ImageToImageFilter< TInputImage, TO
4848
using OutputPixelType = typename OutputImageType::PixelType;
4949

5050
/** Standard class typedefs. */
51-
using Self = {{ cookiecutter.filter_name }}< InputImageType, OutputImageType >;
52-
using Superclass = ImageToImageFilter< InputImageType, OutputImageType >;
53-
using Pointer = SmartPointer< Self >;
54-
using ConstPointer = SmartPointer< const Self >;
51+
using Self = {{ cookiecutter.filter_name }}<InputImageType, OutputImageType>;
52+
using Superclass = ImageToImageFilter<InputImageType, OutputImageType>;
53+
using Pointer = SmartPointer<Self>;
54+
using ConstPointer = SmartPointer<const Self>;
5555

5656
/** Run-time type information. */
57-
itkTypeMacro( {{ cookiecutter.filter_name }}, ImageToImageFilter );
57+
itkTypeMacro({{ cookiecutter.filter_name }}, ImageToImageFilter);
5858

5959
/** Standard New macro. */
60-
itkNewMacro( Self );
60+
itkNewMacro(Self);
6161

6262
protected:
6363
{{ cookiecutter.filter_name }}();
6464
~{{ cookiecutter.filter_name }}() override = default;
6565

66-
void PrintSelf( std::ostream& os, Indent indent ) const override;
66+
void PrintSelf(std::ostream & os, Indent indent) const override;
6767

6868
using OutputRegionType = typename OutputImageType::RegionType;
6969

70-
void DynamicThreadedGenerateData( const OutputRegionType & outputRegion) override;
70+
void DynamicThreadedGenerateData(const OutputRegionType & outputRegion) override;
7171

7272
private:
73-
74-
7573
#ifdef ITK_USE_CONCEPT_CHECKING
7674
// Add concept checking such as
7775
// itkConceptMacro( FloatingPointPixel, ( itk::Concept::IsFloatingPoint< typename InputImageType::PixelType > ) );
7876
#endif
7977
};
80-
}
78+
} // namespace itk
8179

8280
#ifndef ITK_MANUAL_INSTANTIATION
83-
#include "itk{{ cookiecutter.filter_name }}.hxx"
81+
# include "itk{{ cookiecutter.filter_name }}.hxx"
8482
#endif
8583

8684
#endif // itk{{ cookiecutter.filter_name }}

{{cookiecutter.project_name}}/include/itk{{cookiecutter.filter_name}}.hxx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,37 @@
2626
namespace itk
2727
{
2828

29-
template< typename TInputImage, typename TOutputImage >
30-
{{ cookiecutter.filter_name }}< TInputImage, TOutputImage >
29+
template <typename TInputImage, typename TOutputImage>
30+
{{ cookiecutter.filter_name }}<TInputImage, TOutputImage>
3131
::{{ cookiecutter.filter_name }}()
32-
{
33-
}
32+
{}
3433

3534

36-
template< typename TInputImage, typename TOutputImage >
35+
template <typename TInputImage, typename TOutputImage>
3736
void
38-
{{ cookiecutter.filter_name }}< TInputImage, TOutputImage >
39-
::PrintSelf( std::ostream& os, Indent indent ) const
37+
{{ cookiecutter.filter_name }}<TInputImage, TOutputImage>
38+
::PrintSelf(std::ostream & os, Indent indent) const
4039
{
41-
Superclass::PrintSelf( os, indent );
40+
Superclass::PrintSelf(os, indent);
4241
}
4342

4443

45-
template< typename TInputImage, typename TOutputImage >
44+
template <typename TInputImage, typename TOutputImage>
4645
void
47-
{{ cookiecutter.filter_name }}< TInputImage, TOutputImage >
48-
::DynamicThreadedGenerateData( const OutputRegionType & outputRegion)
46+
{{ cookiecutter.filter_name }}<TInputImage, TOutputImage>
47+
::DynamicThreadedGenerateData(const OutputRegionType & outputRegion)
4948
{
50-
OutputImageType * output = this->GetOutput();
49+
OutputImageType * output = this->GetOutput();
5150
const InputImageType * input = this->GetInput();
5251
using InputRegionType = typename InputImageType::RegionType;
5352
InputRegionType inputRegion = InputRegionType(outputRegion.GetSize());
5453

5554
itk::ImageRegionConstIterator<InputImageType> in(input, inputRegion);
56-
itk::ImageRegionIterator<OutputImageType> out(output, outputRegion);
55+
itk::ImageRegionIterator<OutputImageType> out(output, outputRegion);
5756

5857
for (in.GoToBegin(), out.GoToBegin(); !in.IsAtEnd() && !out.IsAtEnd(); ++in, ++out)
5958
{
60-
out.Set( in.Get() );
59+
out.Set(in.Get());
6160
}
6261
}
6362

{{cookiecutter.project_name}}/src/itkMinimalStandardRandomVariateGenerator.cxx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,28 @@ namespace itk
2222
namespace Statistics
2323
{
2424

25-
MinimalStandardRandomVariateGenerator
26-
::MinimalStandardRandomVariateGenerator()
25+
MinimalStandardRandomVariateGenerator ::MinimalStandardRandomVariateGenerator()
2726
{
2827
this->m_NormalGenerator = NormalGeneratorType::New();
29-
this->Initialize( 1 );
28+
this->Initialize(1);
3029
}
3130

3231
void
33-
MinimalStandardRandomVariateGenerator
34-
::Initialize(int randomSeed)
32+
MinimalStandardRandomVariateGenerator ::Initialize(int randomSeed)
3533
{
36-
this->m_NormalGenerator->Initialize( randomSeed );
34+
this->m_NormalGenerator->Initialize(randomSeed);
3735
}
3836

3937

4038
double
41-
MinimalStandardRandomVariateGenerator
42-
::GetVariate()
39+
MinimalStandardRandomVariateGenerator ::GetVariate()
4340
{
4441
return this->m_NormalGenerator->GetVariate();
4542
}
4643

4744

4845
void
49-
MinimalStandardRandomVariateGenerator
50-
::PrintSelf(std::ostream & os, Indent indent) const
46+
MinimalStandardRandomVariateGenerator ::PrintSelf(std::ostream & os, Indent indent) const
5147
{
5248
Superclass::PrintSelf(os, indent);
5349
}

{{cookiecutter.project_name}}/test/itkMinimalStandardRandomVariateGeneratorTest.cxx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,17 @@
2121
#include "itkTestingMacros.h"
2222
#include "itkMath.h"
2323

24-
int itkMinimalStandardRandomVariateGeneratorTest( int, char * [] )
24+
int
25+
itkMinimalStandardRandomVariateGeneratorTest(int, char *[])
2526
{
2627
typedef itk::Statistics::MinimalStandardRandomVariateGenerator GeneratorType;
27-
GeneratorType::Pointer generator = GeneratorType::New();
28-
29-
EXERCISE_BASIC_OBJECT_METHODS( generator, MinimalStandardRandomVariateGenerator, RandomVariateGeneratorBase );
28+
GeneratorType::Pointer generator = GeneratorType::New();
3029

31-
generator->Initialize( 324 );
30+
EXERCISE_BASIC_OBJECT_METHODS(generator, MinimalStandardRandomVariateGenerator, RandomVariateGeneratorBase);
3231

33-
TEST_EXPECT_TRUE( itk::Math::FloatAlmostEqual( generator->GetVariate(), 1.35581 , 4 , 0.0001));
32+
generator->Initialize(324);
33+
34+
TEST_EXPECT_TRUE(itk::Math::FloatAlmostEqual(generator->GetVariate(), 1.35581, 4, 0.0001));
3435

3536
return EXIT_SUCCESS;
3637
}

{{cookiecutter.project_name}}/test/itk{{cookiecutter.filter_name}}Test.cxx

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,81 +16,82 @@
1616
*
1717
*=========================================================================*/
1818

19-
#include "itk{{cookiecutter.filter_name}}.h"
19+
#include "itk{{ cookiecutter.filter_name }}.h"
2020

2121
#include "itkCommand.h"
2222
#include "itkImageFileWriter.h"
2323
#include "itkTestingMacros.h"
2424

25-
namespace{
25+
namespace
26+
{
2627
class ShowProgress : public itk::Command
2728
{
2829
public:
29-
itkNewMacro( ShowProgress );
30+
itkNewMacro(ShowProgress);
3031

3132
void
32-
Execute( itk::Object* caller, const itk::EventObject& event ) override
33+
Execute(itk::Object * caller, const itk::EventObject & event) override
3334
{
34-
Execute( (const itk::Object*)caller, event );
35+
Execute((const itk::Object *)caller, event);
3536
}
3637

3738
void
38-
Execute( const itk::Object* caller, const itk::EventObject& event ) override
39+
Execute(const itk::Object * caller, const itk::EventObject & event) override
3940
{
40-
if ( !itk::ProgressEvent().CheckEvent( &event ) )
41-
{
41+
if (!itk::ProgressEvent().CheckEvent(&event))
42+
{
4243
return;
43-
}
44-
const auto* processObject = dynamic_cast< const itk::ProcessObject* >( caller );
45-
if ( !processObject )
46-
{
44+
}
45+
const auto * processObject = dynamic_cast<const itk::ProcessObject *>(caller);
46+
if (!processObject)
47+
{
4748
return;
48-
}
49+
}
4950
std::cout << " " << processObject->GetProgress();
5051
}
5152
};
52-
}
53+
} // namespace
5354

54-
int itk{{cookiecutter.filter_name}}Test( int argc, char * argv[] )
55+
int itk{{ cookiecutter.filter_name }}Test(int argc, char * argv[])
5556
{
56-
if( argc < 2 )
57-
{
57+
if (argc < 2)
58+
{
5859
std::cerr << "Missing parameters." << std::endl;
5960
std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv);
6061
std::cerr << " outputImage";
6162
std::cerr << std::endl;
6263
return EXIT_FAILURE;
63-
}
64+
}
6465
const char * outputImageFileName = argv[1];
6566

6667
constexpr unsigned int Dimension = 2;
6768
using PixelType = float;
68-
using ImageType = itk::Image< PixelType, Dimension >;
69+
using ImageType = itk::Image<PixelType, Dimension>;
6970

70-
using FilterType = itk::{{cookiecutter.filter_name}}< ImageType, ImageType >;
71+
using FilterType = itk::{{ cookiecutter.filter_name }}<ImageType, ImageType>;
7172
FilterType::Pointer filter = FilterType::New();
7273

73-
EXERCISE_BASIC_OBJECT_METHODS( filter, {{cookiecutter.filter_name}}, ImageToImageFilter );
74+
EXERCISE_BASIC_OBJECT_METHODS(filter, {{ cookiecutter.filter_name }}, ImageToImageFilter);
7475

7576
// Create input image to avoid test dependencies.
7677
ImageType::SizeType size;
77-
size.Fill( 128 );
78+
size.Fill(128);
7879
ImageType::Pointer image = ImageType::New();
79-
image->SetRegions( size );
80+
image->SetRegions(size);
8081
image->Allocate();
8182
image->FillBuffer(1.1f);
8283

8384
ShowProgress::Pointer showProgress = ShowProgress::New();
84-
filter->AddObserver( itk::ProgressEvent(), showProgress );
85+
filter->AddObserver(itk::ProgressEvent(), showProgress);
8586
filter->SetInput(image);
8687

87-
using WriterType = itk::ImageFileWriter< ImageType >;
88+
using WriterType = itk::ImageFileWriter<ImageType>;
8889
WriterType::Pointer writer = WriterType::New();
89-
writer->SetFileName( outputImageFileName );
90-
writer->SetInput( filter->GetOutput() );
90+
writer->SetFileName(outputImageFileName);
91+
writer->SetInput(filter->GetOutput());
9192
writer->SetUseCompression(true);
9293

93-
TRY_EXPECT_NO_EXCEPTION( writer->Update() );
94+
TRY_EXPECT_NO_EXCEPTION(writer->Update());
9495

9596

9697
std::cout << "Test finished." << std::endl;

0 commit comments

Comments
 (0)