Skip to content

Commit 98ad36b

Browse files
author
Lee Newberg
committed
ENH: Updates required by updated ITK.
ENH: Add .clang-format style file. ENH: Use ITK_ prefix for macro names. ENH: Bump to C++14. ENH: Bump to CMake minimum 3.16.3. ENH: Update itk-git-tag in build-test-package.yml. ENH: Use ITK compliant template parameter names.
1 parent 71a190d commit 98ad36b

7 files changed

+192
-37
lines changed

.clang-format

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
## This config file is only relevant for clang-format version 8.0.0
2+
##
3+
## Examples of each format style can be found on the in the clang-format documentation
4+
## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option
5+
##
6+
## The clang-format binaries can be downloaded as part of the clang binary distributions
7+
## from http://releases.llvm.org/download.html
8+
##
9+
## Use the script Utilities/Maintenance/clang-format.bash to faciliate
10+
## maintaining a consistent code style.
11+
##
12+
## EXAMPLE apply code style enforcement before commit:
13+
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --modified
14+
## EXAMPLE apply code style enforcement after commit:
15+
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --last
16+
---
17+
# This configuration requires clang-format version 8.0.0 exactly.
18+
BasedOnStyle: Mozilla
19+
Language: Cpp
20+
AccessModifierOffset: -2
21+
AlignAfterOpenBracket: Align
22+
AlignConsecutiveAssignments: false
23+
AlignConsecutiveDeclarations: true
24+
AlignEscapedNewlines: Right
25+
AlignOperands: true
26+
AlignTrailingComments: true
27+
# clang 9.0 AllowAllArgumentsOnNextLine: true
28+
# clang 9.0 AllowAllConstructorInitializersOnNextLine: true
29+
AllowAllParametersOfDeclarationOnNextLine: false
30+
AllowShortBlocksOnASingleLine: false
31+
AllowShortCaseLabelsOnASingleLine: false
32+
AllowShortFunctionsOnASingleLine: Inline
33+
# clang 9.0 AllowShortLambdasOnASingleLine: All
34+
# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never
35+
AllowShortIfStatementsOnASingleLine: false
36+
AllowShortLoopsOnASingleLine: false
37+
AlwaysBreakAfterDefinitionReturnType: None
38+
AlwaysBreakAfterReturnType: All
39+
AlwaysBreakBeforeMultilineStrings: false
40+
AlwaysBreakTemplateDeclarations: Yes
41+
BinPackArguments: false
42+
BinPackParameters: false
43+
BreakBeforeBraces: Custom
44+
BraceWrapping:
45+
# clang 9.0 feature AfterCaseLabel: false
46+
AfterClass: true
47+
AfterControlStatement: true
48+
AfterEnum: true
49+
AfterFunction: true
50+
AfterNamespace: true
51+
AfterObjCDeclaration: true
52+
AfterStruct: true
53+
AfterUnion: true
54+
AfterExternBlock: true
55+
BeforeCatch: true
56+
BeforeElse: true
57+
## This is the big change from historical ITK formatting!
58+
# Historically ITK used a style similar to https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style
59+
# with indented braces, and not indented code. This style is very difficult to automatically
60+
# maintain with code beautification tools. Not indenting braces is more common among
61+
# formatting tools.
62+
IndentBraces: false
63+
SplitEmptyFunction: false
64+
SplitEmptyRecord: false
65+
SplitEmptyNamespace: false
66+
BreakBeforeBinaryOperators: None
67+
#clang 6.0 BreakBeforeInheritanceComma: true
68+
BreakInheritanceList: BeforeComma
69+
BreakBeforeTernaryOperators: true
70+
#clang 6.0 BreakConstructorInitializersBeforeComma: true
71+
BreakConstructorInitializers: BeforeComma
72+
BreakAfterJavaFieldAnnotations: false
73+
BreakStringLiterals: true
74+
## The following line allows larger lines in non-documentation code
75+
ColumnLimit: 120
76+
CommentPragmas: '^ IWYU pragma:'
77+
CompactNamespaces: false
78+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
79+
ConstructorInitializerIndentWidth: 2
80+
ContinuationIndentWidth: 2
81+
Cpp11BracedListStyle: false
82+
DerivePointerAlignment: false
83+
DisableFormat: false
84+
ExperimentalAutoDetectBinPacking: false
85+
FixNamespaceComments: true
86+
ForEachMacros:
87+
- foreach
88+
- Q_FOREACH
89+
- BOOST_FOREACH
90+
IncludeBlocks: Preserve
91+
IncludeCategories:
92+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
93+
Priority: 2
94+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
95+
Priority: 3
96+
- Regex: '.*'
97+
Priority: 1
98+
IncludeIsMainRegex: '(Test)?$'
99+
IndentCaseLabels: true
100+
IndentPPDirectives: AfterHash
101+
IndentWidth: 2
102+
IndentWrappedFunctionNames: false
103+
JavaScriptQuotes: Leave
104+
JavaScriptWrapImports: true
105+
KeepEmptyLinesAtTheStartOfBlocks: true
106+
MacroBlockBegin: ''
107+
MacroBlockEnd: ''
108+
MaxEmptyLinesToKeep: 2
109+
NamespaceIndentation: None
110+
ObjCBinPackProtocolList: Auto
111+
ObjCBlockIndentWidth: 2
112+
ObjCSpaceAfterProperty: true
113+
ObjCSpaceBeforeProtocolList: false
114+
PenaltyBreakAssignment: 2
115+
PenaltyBreakBeforeFirstCallParameter: 19
116+
PenaltyBreakComment: 300
117+
## The following line allows larger lines in non-documentation code
118+
PenaltyBreakFirstLessLess: 120
119+
PenaltyBreakString: 1000
120+
PenaltyBreakTemplateDeclaration: 10
121+
PenaltyExcessCharacter: 1000000
122+
PenaltyReturnTypeOnItsOwnLine: 200
123+
PointerAlignment: Middle
124+
ReflowComments: true
125+
# We may want to sort the includes as a separate pass
126+
SortIncludes: false
127+
# We may want to revisit this later
128+
SortUsingDeclarations: false
129+
SpaceAfterCStyleCast: false
130+
# SpaceAfterLogicalNot: false
131+
SpaceAfterTemplateKeyword: true
132+
SpaceBeforeAssignmentOperators: true
133+
SpaceBeforeCpp11BracedList: false
134+
SpaceBeforeCtorInitializerColon: true
135+
SpaceBeforeInheritanceColon: true
136+
SpaceBeforeParens: ControlStatements
137+
SpaceBeforeRangeBasedForLoopColon: true
138+
SpaceInEmptyParentheses: false
139+
SpacesBeforeTrailingComments: 1
140+
SpacesInAngles: false
141+
SpacesInContainerLiterals: false
142+
SpacesInCStyleCastParentheses: false
143+
SpacesInParentheses: false
144+
SpacesInSquareBrackets: false
145+
Standard: Cpp11
146+
StatementMacros:
147+
- Q_UNUSED
148+
- QT_REQUIRE_VERSION
149+
TabWidth: 2
150+
UseTab: Never
151+
...

.github/workflows/build-test-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ jobs:
1313
- os: ubuntu-18.04
1414
c-compiler: "gcc"
1515
cxx-compiler: "g++"
16-
itk-git-tag: "7548a390d71dc25b80e792703ee3cfea17853a99"
16+
itk-git-tag: "c693dbc830859ea10d573301f075e121a4c6c581"
1717
cmake-build-type: "MinSizeRel"
1818
- os: windows-2019
1919
c-compiler: "cl.exe"
2020
cxx-compiler: "cl.exe"
21-
itk-git-tag: "7548a390d71dc25b80e792703ee3cfea17853a99"
21+
itk-git-tag: "c693dbc830859ea10d573301f075e121a4c6c581"
2222
cmake-build-type: "Release"
2323
- os: macos-10.15
2424
c-compiler: "clang"
2525
cxx-compiler: "clang++"
26-
itk-git-tag: "7548a390d71dc25b80e792703ee3cfea17853a99"
26+
itk-git-tag: "c693dbc830859ea10d573301f075e121a4c6c581"
2727
cmake-build-type: "MinSizeRel"
2828

2929
steps:

.github/workflows/clang-format-linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v1
11-
with:
12-
fetch-depth: 1
1311
- uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@master
12+
with:
13+
error-message: 'Code is inconsistent with ITK Coding Style. Add the *action:ApplyClangFormat* PR label to correct.'

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
cmake_minimum_required(VERSION 3.10.2)
1+
cmake_minimum_required(VERSION 3.16.3)
22
project(StructurePreservingColorNormalization)
3-
set(CMAKE_CXX_STANDARD 11)
3+
set(CMAKE_CXX_STANDARD 14)
44

55
if(NOT ITK_SOURCE_DIR)
66
find_package(ITK REQUIRED)

include/itkStructurePreservingColorNormalizationFilter.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,21 @@ class StructurePreservingColorNormalizationFilter : public ImageToImageFilter< T
293293
// alternates.
294294
#define STRUCTUREPRESERVINGCOLORNORMALIZATIONFILTER_STRICT_EIGEN3_ITERATORS 0
295295
#if STRUCTUREPRESERVINGCOLORNORMALIZATIONFILTER_STRICT_EIGEN3_ITERATORS
296-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
297-
static _Scalar *begin( Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix );
296+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
297+
static TScalar *
298+
begin(Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix);
298299

299-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
300-
static const _Scalar *cbegin( const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix );
300+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
301+
static const TScalar *
302+
cbegin(const Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix);
301303

302-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
303-
static _Scalar *end( Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix );
304+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
305+
static TScalar *
306+
end(Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix);
304307

305-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
306-
static const _Scalar *cend( const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix );
308+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
309+
static const TScalar *
310+
cend(const Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix);
307311

308312
#else
309313
template< typename TMatrix >

include/itkStructurePreservingColorNormalizationFilter.hxx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -769,39 +769,39 @@ StructurePreservingColorNormalizationFilter< TImage >
769769
}
770770

771771
#if STRUCTUREPRESERVINGCOLORNORMALIZATIONFILTER_STRICT_EIGEN3_ITERATORS
772-
template< typename TImage >
773-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
774-
_Scalar *
775-
StructurePreservingColorNormalizationFilter< TImage >
776-
::begin( Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix )
772+
template <typename TImage>
773+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
774+
TScalar *
775+
StructurePreservingColorNormalizationFilter<TImage>::begin(
776+
Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix)
777777
{
778778
return matrix.data();
779779
}
780780

781-
template< typename TImage >
782-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
783-
const _Scalar *
784-
StructurePreservingColorNormalizationFilter< TImage >
785-
::cbegin( const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix )
781+
template <typename TImage>
782+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
783+
const TScalar *
784+
StructurePreservingColorNormalizationFilter<TImage>::cbegin(
785+
const Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix)
786786
{
787787
return matrix.data();
788788
}
789789

790-
template< typename TImage >
791-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
792-
_Scalar *
793-
StructurePreservingColorNormalizationFilter< TImage >
794-
::end( Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix )
790+
template <typename TImage>
791+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
792+
TScalar *
793+
StructurePreservingColorNormalizationFilter<TImage>::end(
794+
Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix)
795795
{
796796
itkAssertOrThrowMacro( std::distance( matrix.data(), &matrix( matrix.rows() - 1, matrix.cols() - 1 ) ) + 1 == matrix.size(), "Bad array stepping" )
797797
return matrix.data() + matrix.size();
798798
}
799799

800-
template< typename TImage >
801-
template< typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols >
802-
const _Scalar *
803-
StructurePreservingColorNormalizationFilter< TImage >
804-
::cend( const Eigen::Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &matrix )
800+
template <typename TImage>
801+
template <typename TScalar, int VRows, int VCols, int VOptions, int VMaxRows, int VMaxCols>
802+
const TScalar *
803+
StructurePreservingColorNormalizationFilter<TImage>::cend(
804+
const Eigen::Matrix<TScalar, VRows, VCols, VOptions, VMaxRows, VMaxCols> & matrix)
805805
{
806806
itkAssertOrThrowMacro( std::distance( matrix.data(), &matrix( matrix.rows() - 1, matrix.cols() - 1 ) ) + 1 == matrix.size(), "Bad array stepping" )
807807
return matrix.data() + matrix.size();

test/itkStructurePreservingColorNormalizationFilterTest.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int itkStructurePreservingColorNormalizationFilterTest( int argc, char * argv[]
109109
// filter->SetColorIndexSuppressedByHematoxylin( 0 );
110110
// filter->SetColorIndexSuppressedByEosin( 1 );
111111

112-
EXERCISE_BASIC_OBJECT_METHODS( filter, StructurePreservingColorNormalizationFilter, ImageToImageFilter );
112+
ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, StructurePreservingColorNormalizationFilter, ImageToImageFilter);
113113

114114
ShowProgress::Pointer showProgress = ShowProgress::New();
115115
filter->AddObserver( itk::ProgressEvent(), showProgress );
@@ -206,7 +206,7 @@ int itkStructurePreservingColorNormalizationFilterTest( int argc, char * argv[]
206206
writer->SetInput( filter->GetOutput() );
207207
writer->SetUseCompression( true );
208208

209-
TRY_EXPECT_NO_EXCEPTION( writer->Update() );
209+
ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());
210210

211211

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

0 commit comments

Comments
 (0)