Skip to content

Commit c371082

Browse files
committed
COMP: Update clang-format for ITKv6 style
1 parent e20bd0b commit c371082

File tree

5 files changed

+346
-25
lines changed

5 files changed

+346
-25
lines changed

.clang-format

Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
## This config file is only relevant for clang-format version 19.1.7
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 https://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_19.1.7} --modified
14+
## EXAMPLE apply code style enforcement after commit:
15+
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.7} --last
16+
---
17+
# This configuration requires clang-format version 19.1.7 exactly.
18+
Language: Cpp
19+
AccessModifierOffset: -2
20+
AlignAfterOpenBracket: Align
21+
AlignArrayOfStructures: None
22+
AlignConsecutiveAssignments:
23+
Enabled: false
24+
AcrossEmptyLines: false
25+
AcrossComments: false
26+
AlignCompound: false
27+
AlignFunctionPointers: false
28+
PadOperators: true
29+
AlignConsecutiveBitFields:
30+
Enabled: false
31+
AcrossEmptyLines: false
32+
AcrossComments: false
33+
AlignCompound: false
34+
AlignFunctionPointers: false
35+
PadOperators: false
36+
AlignConsecutiveDeclarations:
37+
Enabled: true
38+
AcrossEmptyLines: false
39+
AcrossComments: false
40+
AlignCompound: false
41+
AlignFunctionPointers: false
42+
PadOperators: true
43+
AlignConsecutiveMacros:
44+
Enabled: false
45+
AcrossEmptyLines: false
46+
AcrossComments: false
47+
AlignCompound: false
48+
AlignFunctionPointers: false
49+
PadOperators: false
50+
AlignConsecutiveShortCaseStatements:
51+
Enabled: false
52+
AcrossEmptyLines: false
53+
AcrossComments: false
54+
AlignCaseArrows: false
55+
AlignCaseColons: false
56+
AlignConsecutiveTableGenBreakingDAGArgColons:
57+
Enabled: false
58+
AcrossEmptyLines: false
59+
AcrossComments: false
60+
AlignCompound: false
61+
AlignFunctionPointers: false
62+
PadOperators: false
63+
AlignConsecutiveTableGenCondOperatorColons:
64+
Enabled: false
65+
AcrossEmptyLines: false
66+
AcrossComments: false
67+
AlignCompound: false
68+
AlignFunctionPointers: false
69+
PadOperators: false
70+
AlignConsecutiveTableGenDefinitionColons:
71+
Enabled: false
72+
AcrossEmptyLines: false
73+
AcrossComments: false
74+
AlignCompound: false
75+
AlignFunctionPointers: false
76+
PadOperators: false
77+
AlignEscapedNewlines: Left
78+
AlignOperands: Align
79+
AlignTrailingComments:
80+
Kind: Always
81+
OverEmptyLines: 0
82+
AllowAllArgumentsOnNextLine: true
83+
AllowAllParametersOfDeclarationOnNextLine: false
84+
AllowBreakBeforeNoexceptSpecifier: Never
85+
AllowShortBlocksOnASingleLine: Never
86+
AllowShortCaseExpressionOnASingleLine: true
87+
AllowShortCaseLabelsOnASingleLine: false
88+
AllowShortCompoundRequirementOnASingleLine: true
89+
AllowShortEnumsOnASingleLine: true
90+
#AllowShortFunctionsOnASingleLine: Inline Only merge functions defined inside a class. Implies empty.
91+
#AllowShortFunctionsOnASingleLine: None (in configuration: None) Never merge functions into a single line.
92+
AllowShortFunctionsOnASingleLine: All
93+
AllowShortIfStatementsOnASingleLine: Never
94+
AllowShortLambdasOnASingleLine: All
95+
AllowShortLoopsOnASingleLine: false
96+
AlwaysBreakAfterDefinitionReturnType: None
97+
AlwaysBreakBeforeMultilineStrings: false
98+
AttributeMacros:
99+
- __capability
100+
BinPackArguments: false
101+
BinPackParameters: false
102+
BitFieldColonSpacing: Both
103+
BraceWrapping:
104+
AfterCaseLabel: true
105+
AfterClass: true
106+
AfterControlStatement: Always
107+
AfterEnum: true
108+
AfterExternBlock: true
109+
AfterFunction: true
110+
AfterNamespace: true
111+
AfterObjCDeclaration: true
112+
AfterStruct: true
113+
AfterUnion: true
114+
BeforeCatch: true
115+
BeforeElse: true
116+
BeforeLambdaBody: false
117+
BeforeWhile: false
118+
IndentBraces: false
119+
SplitEmptyFunction: false
120+
SplitEmptyRecord: false
121+
SplitEmptyNamespace: false
122+
BreakAdjacentStringLiterals: true
123+
BreakAfterAttributes: Leave
124+
BreakAfterJavaFieldAnnotations: false
125+
BreakAfterReturnType: All
126+
BreakArrays: true
127+
BreakBeforeBinaryOperators: None
128+
BreakBeforeConceptDeclarations: Always
129+
BreakBeforeBraces: Custom
130+
BreakBeforeInlineASMColon: OnlyMultiline
131+
BreakBeforeTernaryOperators: true
132+
BreakConstructorInitializers: BeforeComma
133+
BreakFunctionDefinitionParameters: false
134+
BreakInheritanceList: BeforeComma
135+
BreakStringLiterals: true
136+
BreakTemplateDeclarations: Yes
137+
## The following line allows larger lines in non-documentation code
138+
ColumnLimit: 120
139+
CommentPragmas: '^ IWYU pragma:'
140+
CompactNamespaces: false
141+
ConstructorInitializerIndentWidth: 2
142+
ContinuationIndentWidth: 2
143+
Cpp11BracedListStyle: false
144+
DerivePointerAlignment: false
145+
DisableFormat: false
146+
EmptyLineAfterAccessModifier: Never
147+
EmptyLineBeforeAccessModifier: LogicalBlock
148+
ExperimentalAutoDetectBinPacking: false
149+
FixNamespaceComments: true
150+
ForEachMacros:
151+
- foreach
152+
- Q_FOREACH
153+
- BOOST_FOREACH
154+
IfMacros:
155+
- KJ_IF_MAYBE
156+
IncludeBlocks: Preserve
157+
IncludeCategories:
158+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
159+
Priority: 2
160+
SortPriority: 0
161+
CaseSensitive: false
162+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
163+
Priority: 3
164+
SortPriority: 0
165+
CaseSensitive: false
166+
- Regex: '.*'
167+
Priority: 1
168+
SortPriority: 0
169+
CaseSensitive: false
170+
IncludeIsMainRegex: '(Test)?$'
171+
IncludeIsMainSourceRegex: ''
172+
IndentAccessModifiers: false
173+
IndentCaseBlocks: false
174+
IndentCaseLabels: true
175+
IndentExternBlock: AfterExternBlock
176+
IndentGotoLabels: true
177+
IndentPPDirectives: AfterHash
178+
IndentRequiresClause: true
179+
IndentWidth: 2
180+
IndentWrappedFunctionNames: false
181+
InsertBraces: false
182+
InsertNewlineAtEOF: false
183+
InsertTrailingCommas: None
184+
IntegerLiteralSeparator:
185+
Binary: 0
186+
BinaryMinDigits: 0
187+
Decimal: 0
188+
DecimalMinDigits: 0
189+
Hex: 0
190+
HexMinDigits: 0
191+
JavaScriptQuotes: Leave
192+
JavaScriptWrapImports: true
193+
KeepEmptyLines:
194+
AtEndOfFile: false
195+
AtStartOfBlock: true
196+
AtStartOfFile: true
197+
LambdaBodyIndentation: Signature
198+
LineEnding: DeriveLF
199+
MacroBlockBegin: ''
200+
MacroBlockEnd: ''
201+
MainIncludeChar: Quote
202+
MaxEmptyLinesToKeep: 2
203+
NamespaceIndentation: None
204+
ObjCBinPackProtocolList: Auto
205+
ObjCBlockIndentWidth: 2
206+
ObjCBreakBeforeNestedBlockParam: true
207+
ObjCSpaceAfterProperty: true
208+
ObjCSpaceBeforeProtocolList: false
209+
PackConstructorInitializers: BinPack
210+
PenaltyBreakAssignment: 2
211+
PenaltyBreakBeforeFirstCallParameter: 19
212+
PenaltyBreakComment: 300
213+
## The following line allows larger lines in non-documentation code
214+
PenaltyBreakFirstLessLess: 120
215+
PenaltyBreakOpenParenthesis: 0
216+
PenaltyBreakScopeResolution: 500
217+
PenaltyBreakString: 1000
218+
PenaltyBreakTemplateDeclaration: 10
219+
PenaltyExcessCharacter: 1000000
220+
PenaltyIndentedWhitespace: 0
221+
PenaltyReturnTypeOnItsOwnLine: 200
222+
PointerAlignment: Middle
223+
PPIndentWidth: -1
224+
QualifierAlignment: Custom
225+
QualifierOrder:
226+
- friend
227+
- static
228+
- inline
229+
- constexpr
230+
- const
231+
- type
232+
ReferenceAlignment: Pointer
233+
ReflowComments: true
234+
RemoveBracesLLVM: false
235+
RemoveParentheses: Leave
236+
RemoveSemicolon: false
237+
RequiresClausePosition: OwnLine
238+
RequiresExpressionIndentation: OuterScope
239+
SeparateDefinitionBlocks: Leave
240+
ShortNamespaceLines: 1
241+
SkipMacroDefinitionBody: false
242+
# We may want to sort the includes as a separate pass
243+
SortIncludes: Never
244+
SortJavaStaticImport: Before
245+
# We may want to revisit this later
246+
SortUsingDeclarations: Never
247+
SpaceAfterCStyleCast: false
248+
SpaceAfterLogicalNot: false
249+
SpaceAfterTemplateKeyword: true
250+
SpaceAroundPointerQualifiers: Default
251+
SpaceBeforeAssignmentOperators: true
252+
SpaceBeforeCaseColon: false
253+
SpaceBeforeCpp11BracedList: false
254+
SpaceBeforeCtorInitializerColon: true
255+
SpaceBeforeInheritanceColon: true
256+
SpaceBeforeJsonColon: false
257+
SpaceBeforeParens: ControlStatements
258+
SpaceBeforeParensOptions:
259+
AfterControlStatements: true
260+
AfterForeachMacros: true
261+
AfterFunctionDefinitionName: false
262+
AfterFunctionDeclarationName: false
263+
AfterIfMacros: true
264+
AfterOverloadedOperator: false
265+
AfterPlacementOperator: true
266+
AfterRequiresInClause: false
267+
AfterRequiresInExpression: false
268+
BeforeNonEmptyParentheses: false
269+
SpaceBeforeRangeBasedForLoopColon: true
270+
SpaceBeforeSquareBrackets: false
271+
SpaceInEmptyBlock: false
272+
SpacesBeforeTrailingComments: 1
273+
SpacesInAngles: Never
274+
SpacesInContainerLiterals: false
275+
SpacesInLineCommentPrefix:
276+
Minimum: 1
277+
Maximum: -1
278+
SpacesInParens: Never
279+
SpacesInParensOptions:
280+
ExceptDoubleParentheses: false
281+
InCStyleCasts: false
282+
InConditionalStatements: false
283+
InEmptyParentheses: false
284+
Other: false
285+
SpacesInSquareBrackets: false
286+
Standard: Latest
287+
StatementAttributeLikeMacros:
288+
- Q_EMIT
289+
StatementMacros:
290+
- Q_UNUSED
291+
- QT_REQUIRE_VERSION
292+
- ITK_GCC_PRAGMA_PUSH
293+
- ITK_GCC_PRAGMA_POP
294+
- ITK_GCC_SUPPRESS_Wfloat_equal
295+
- ITK_GCC_SUPPRESS_Wformat_nonliteral
296+
- ITK_GCC_SUPPRESS_Warray_bounds
297+
- ITK_CLANG_PRAGMA_PUSH
298+
- ITK_CLANG_PRAGMA_POP
299+
- ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
300+
- ITK_CLANG_SUPPRESS_Wduplicate_enum
301+
- CLANG_PRAGMA_PUSH
302+
- CLANG_PRAGMA_POP
303+
- CLANG_SUPPRESS_Wfloat_equal
304+
- INTEL_PRAGMA_WARN_PUSH
305+
- INTEL_PRAGMA_WARN_POP
306+
- INTEL_SUPPRESS_warning_1292
307+
- itkTemplateFloatingToIntegerMacro
308+
- itkLegacyMacro
309+
TableGenBreakInsideDAGArg: DontBreak
310+
TabWidth: 2
311+
UseTab: Never
312+
VerilogBreakBetweenInstancePorts: true
313+
WhitespaceSensitiveMacros:
314+
- BOOST_PP_STRINGIZE
315+
- CF_SWIFT_NAME
316+
- NS_SWIFT_NAME
317+
- PP_STRINGIZE
318+
- STRINGIZE
319+
...

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3
11-
12-
- uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@master
10+
- uses: actions/checkout@v5
11+
- uses: InsightSoftwareConsortium/ITKClangFormatLinterAction@main

src/itkDICOMOrientation.cxx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -170,49 +170,52 @@ DICOMOrientation::DirectionCosinesToOrientation(const DirectionType & dir)
170170
// but it is DIFFERENT in the meaning of direction in terms of sign-ness.
171171
CoordinateEnum terms[3] = { CoordinateEnum::UNKNOWN, CoordinateEnum::UNKNOWN, CoordinateEnum::UNKNOWN };
172172

173-
std::multimap< double, std::pair<unsigned, unsigned> > value_to_idx;
174-
for (unsigned int c = 0; c < 3; ++c )
173+
std::multimap<double, std::pair<unsigned, unsigned>> value_to_idx;
174+
for (unsigned int c = 0; c < 3; ++c)
175+
{
176+
for (unsigned int r = 0; r < 3; ++r)
175177
{
176-
for (unsigned int r = 0; r < 3; ++r )
177-
{
178-
value_to_idx.emplace(std::abs(dir[c][r]), std::make_pair(c,r));
179-
}
178+
value_to_idx.emplace(std::abs(dir[c][r]), std::make_pair(c, r));
180179
}
180+
}
181181

182182
for (unsigned i = 0; i < 3; ++i)
183-
{
183+
{
184184

185-
auto max_idx = value_to_idx.rbegin()->second;
185+
auto max_idx = value_to_idx.rbegin()->second;
186186
const unsigned int max_c = max_idx.first;
187187
const unsigned int max_r = max_idx.second;
188188

189189
const int max_sgn = Math::sgn(dir[max_c][max_r]);
190190

191191
for (auto it = value_to_idx.begin(); it != value_to_idx.end();)
192192
{
193-
if (it->second.first == max_c || it->second.second == max_r)
193+
if (it->second.first == max_c || it->second.second == max_r)
194194
{
195-
value_to_idx.erase(it++);
195+
value_to_idx.erase(it++);
196196
}
197-
else
197+
else
198198
{
199-
++it;
199+
++it;
200200
}
201201
}
202202

203203
switch (max_c)
204204
{
205-
case 0: {
205+
case 0:
206+
{
206207
// When the dominant axis sign is positive, assign the coordinate for the direction we are increasing towards.
207208
// ITK is in LPS, so that is the positive direction
208209
terms[max_r] = (max_sgn == 1) ? CoordinateEnum::Left : CoordinateEnum::Right;
209210
break;
210211
}
211-
case 1: {
212+
case 1:
213+
{
212214
terms[max_r] = (max_sgn == 1) ? CoordinateEnum::Posterior : CoordinateEnum::Anterior;
213215
break;
214216
}
215-
case 2: {
217+
case 2:
218+
{
216219
terms[max_r] = (max_sgn == 1) ? CoordinateEnum::Superior : CoordinateEnum::Inferior;
217220
break;
218221
}

0 commit comments

Comments
 (0)