Skip to content

Commit b51f827

Browse files
committed
ENH: Add .gitattributes to allow running ITK clang-formatting scripts
``` git filter-branch -f \ --tree-filter "~/ITK/Utilities/Maintenance/clang-format.bash --clang-format ~/Dashboard/src/ITK-clang11/clang-format-Linux --tracked" \ master.. ```
1 parent 3982894 commit b51f827

14 files changed

+1510
-1296
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+
...

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Custom attribute to mark sources as using our C++/C code style.
2+
[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat
3+
4+
*.c our-c-style
5+
*.h our-c-style
6+
*.cxx our-c-style
7+
*.hxx our-c-style
8+
*.txx our-c-style
9+
*.txt whitespace=tab-in-indent,no-lf-at-eof
10+
*.cmake whitespace=tab-in-indent,no-lf-at-eof
11+
12+
# ExternalData content links must have LF newlines
13+
*.md5 crlf=input
14+
*.sha512 crlf=input

include/itkNormalizedCorrelationTwoImageToOneImageMetric.h

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,15 @@ namespace itk
4040
* \ingroup RegistrationMetrics
4141
* \ingroup TwoProjectionRegistration
4242
*/
43-
template < typename TFixedImage, typename TMovingImage >
44-
class NormalizedCorrelationTwoImageToOneImageMetric :
45-
public TwoImageToOneImageMetric< TFixedImage, TMovingImage >
43+
template <typename TFixedImage, typename TMovingImage>
44+
class NormalizedCorrelationTwoImageToOneImageMetric : public TwoImageToOneImageMetric<TFixedImage, TMovingImage>
4645
{
4746
public:
4847
ITK_DISALLOW_COPY_AND_ASSIGN(NormalizedCorrelationTwoImageToOneImageMetric);
4948

5049
/** Standard class type alias. */
5150
using Self = NormalizedCorrelationTwoImageToOneImageMetric;
52-
using Superclass = TwoImageToOneImageMetric<TFixedImage, TMovingImage >;
51+
using Superclass = TwoImageToOneImageMetric<TFixedImage, TMovingImage>;
5352

5453
using Pointer = SmartPointer<Self>;
5554
using ConstPointer = SmartPointer<const Self>;
@@ -78,37 +77,41 @@ class NormalizedCorrelationTwoImageToOneImageMetric :
7877

7978

8079
/** Get the derivatives of the match measure. */
81-
void GetDerivative( const TransformParametersType & parameters,
82-
DerivativeType & Derivative ) const override;
80+
void
81+
GetDerivative(const TransformParametersType & parameters, DerivativeType & Derivative) const override;
8382

8483
/** Get the value for single valued optimizers. */
85-
MeasureType GetValue( const TransformParametersType & parameters ) const override;
84+
MeasureType
85+
GetValue(const TransformParametersType & parameters) const override;
8686

8787
/** Get value and derivatives for multiple valued optimizers. */
88-
void GetValueAndDerivative( const TransformParametersType & parameters,
89-
MeasureType& Value, DerivativeType& Derivative ) const override;
88+
void
89+
GetValueAndDerivative(const TransformParametersType & parameters,
90+
MeasureType & Value,
91+
DerivativeType & Derivative) const override;
9092

9193
/** Set/Get SubtractMean boolean. If true, the sample mean is subtracted
9294
* from the sample values in the cross-correlation formula and
9395
* typically results in narrower valleys in the cost fucntion.
9496
* Default value is false. */
95-
itkSetMacro( SubtractMean, bool );
96-
itkGetConstReferenceMacro( SubtractMean, bool );
97-
itkBooleanMacro( SubtractMean );
97+
itkSetMacro(SubtractMean, bool);
98+
itkGetConstReferenceMacro(SubtractMean, bool);
99+
itkBooleanMacro(SubtractMean);
98100

99101
protected:
100102
NormalizedCorrelationTwoImageToOneImageMetric();
101-
~NormalizedCorrelationTwoImageToOneImageMetric() override {};
102-
void PrintSelf(std::ostream& os, Indent indent) const override;
103+
~NormalizedCorrelationTwoImageToOneImageMetric() override{};
104+
void
105+
PrintSelf(std::ostream & os, Indent indent) const override;
103106

104107
private:
105-
bool m_SubtractMean;
108+
bool m_SubtractMean;
106109
};
107110

108111
} // end namespace itk
109112

110113
#ifndef ITK_MANUAL_INSTANTIATION
111-
#include "itkNormalizedCorrelationTwoImageToOneImageMetric.hxx"
114+
# include "itkNormalizedCorrelationTwoImageToOneImageMetric.hxx"
112115
#endif
113116

114117
#endif

0 commit comments

Comments
 (0)