diff --git a/.clang-format b/.clang-format index 411b009..45b9502 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,4 @@ -## This config file is only relevant for clang-format version 8.0.0 +## This config file is only relevant for clang-format version 19.1.4 ## ## Examples of each format style can be found on the in the clang-format documentation ## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option @@ -10,142 +10,309 @@ ## maintaining a consistent code style. ## ## EXAMPLE apply code style enforcement before commit: -# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --modified +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --modified ## EXAMPLE apply code style enforcement after commit: -# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --last +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --last --- -# This configuration requires clang-format version 8.0.0 exactly. -BasedOnStyle: Mozilla +# This configuration requires clang-format version 19.1.4 exactly. Language: Cpp AccessModifierOffset: -2 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: true -AlignEscapedNewlines: Right -AlignOperands: true -AlignTrailingComments: true -# clang 9.0 AllowAllArgumentsOnNextLine: true -# clang 9.0 AllowAllConstructorInitializersOnNextLine: true +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Inline -# clang 9.0 AllowShortLambdasOnASingleLine: All -# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never -AllowShortIfStatementsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +#AllowShortFunctionsOnASingleLine: Inline Only merge functions defined inside a class. Implies empty. +#AllowShortFunctionsOnASingleLine: None (in configuration: None) Never merge functions into a single line. +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: All AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - __capability BinPackArguments: false BinPackParameters: false -BreakBeforeBraces: Custom +BitFieldColonSpacing: Both BraceWrapping: - # clang 9.0 feature AfterCaseLabel: false + AfterCaseLabel: true AfterClass: true - AfterControlStatement: true + AfterControlStatement: Always AfterEnum: true + AfterExternBlock: true AfterFunction: true AfterNamespace: true AfterObjCDeclaration: true AfterStruct: true AfterUnion: true - AfterExternBlock: true BeforeCatch: true BeforeElse: true -## This is the big change from historical ITK formatting! -# Historically ITK used a style similar to https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style -# with indented braces, and not indented code. This style is very difficult to automatically -# maintain with code beautification tools. Not indenting braces is more common among -# formatting tools. + BeforeLambdaBody: false + BeforeWhile: false IndentBraces: false SplitEmptyFunction: false SplitEmptyRecord: false SplitEmptyNamespace: false +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: All +BreakArrays: true BreakBeforeBinaryOperators: None -#clang 6.0 BreakBeforeInheritanceComma: true -BreakInheritanceList: BeforeComma +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline BreakBeforeTernaryOperators: true -#clang 6.0 BreakConstructorInitializersBeforeComma: true BreakConstructorInitializers: BeforeComma -BreakAfterJavaFieldAnnotations: false +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeComma BreakStringLiterals: true +BreakTemplateDeclarations: Yes ## The following line allows larger lines in non-documentation code ColumnLimit: 120 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 2 ContinuationIndentWidth: 2 Cpp11BracedListStyle: false DerivePointerAlignment: false DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true ForEachMacros: - foreach - Q_FOREACH - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE IncludeBlocks: Preserve IncludeCategories: - Regex: '^"(llvm|llvm-c|clang|clang-c)/' Priority: 2 + SortPriority: 0 + CaseSensitive: false - Regex: '^(<|"(gtest|gmock|isl|json)/)' Priority: 3 + SortPriority: 0 + CaseSensitive: false - Regex: '.*' Priority: 1 + SortPriority: 0 + CaseSensitive: false IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false IndentCaseLabels: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true IndentPPDirectives: AfterHash +IndentRequiresClause: true IndentWidth: 2 IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 JavaScriptQuotes: Leave JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: true + AtStartOfFile: true +LambdaBodyIndentation: Signature +LineEnding: DeriveLF MacroBlockBegin: '' MacroBlockEnd: '' +MainIncludeChar: Quote MaxEmptyLinesToKeep: 2 NamespaceIndentation: None ObjCBinPackProtocolList: Auto ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: false +PackConstructorInitializers: BinPack PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 19 PenaltyBreakComment: 300 ## The following line allows larger lines in non-documentation code PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Middle +PPIndentWidth: -1 +QualifierAlignment: Custom +QualifierOrder: + - friend + - static + - inline + - constexpr + - const + - type +ReferenceAlignment: Pointer ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false # We may want to sort the includes as a separate pass -SortIncludes: false +SortIncludes: Never +SortJavaStaticImport: Before # We may want to revisit this later -SortUsingDeclarations: false +SortUsingDeclarations: Never SpaceAfterCStyleCast: false -# SpaceAfterLogicalNot: false +SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false SpacesBeforeTrailingComments: 1 -SpacesInAngles: false +SpacesInAngles: Never SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false SpacesInSquareBrackets: false -Standard: Cpp11 +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT StatementMacros: - Q_UNUSED - QT_REQUIRE_VERSION + - ITK_GCC_PRAGMA_PUSH + - ITK_GCC_PRAGMA_POP + - ITK_GCC_SUPPRESS_Wfloat_equal + - ITK_GCC_SUPPRESS_Wformat_nonliteral + - ITK_GCC_SUPPRESS_Warray_bounds + - ITK_CLANG_PRAGMA_PUSH + - ITK_CLANG_PRAGMA_POP + - ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant + - CLANG_PRAGMA_PUSH + - CLANG_PRAGMA_POP + - CLANG_SUPPRESS_Wfloat_equal + - INTEL_PRAGMA_WARN_PUSH + - INTEL_PRAGMA_WARN_POP + - INTEL_SUPPRESS_warning_1292 + - itkTemplateFloatingToIntegerMacro + - itkLegacyMacro +TableGenBreakInsideDAGArg: DontBreak TabWidth: 2 UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE ... diff --git a/clang-format b/clang-format new file mode 100644 index 0000000..45b9502 --- /dev/null +++ b/clang-format @@ -0,0 +1,318 @@ +## This config file is only relevant for clang-format version 19.1.4 +## +## Examples of each format style can be found on the in the clang-format documentation +## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option +## +## The clang-format binaries can be downloaded as part of the clang binary distributions +## from https://releases.llvm.org/download.html +## +## Use the script Utilities/Maintenance/clang-format.bash to faciliate +## maintaining a consistent code style. +## +## EXAMPLE apply code style enforcement before commit: +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --modified +## EXAMPLE apply code style enforcement after commit: +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_19.1.4} --last +--- +# This configuration requires clang-format version 19.1.4 exactly. +Language: Cpp +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: true +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseArrows: false + AlignCaseColons: false +AlignConsecutiveTableGenBreakingDAGArgColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenCondOperatorColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignConsecutiveTableGenDefinitionColons: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + AlignFunctionPointers: false + PadOperators: false +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowBreakBeforeNoexceptSpecifier: Never +AllowShortBlocksOnASingleLine: Never +AllowShortCaseExpressionOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: true +AllowShortEnumsOnASingleLine: true +#AllowShortFunctionsOnASingleLine: Inline Only merge functions defined inside a class. Implies empty. +#AllowShortFunctionsOnASingleLine: None (in configuration: None) Never merge functions into a single line. +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AttributeMacros: + - __capability +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterExternBlock: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakAdjacentStringLiterals: true +BreakAfterAttributes: Leave +BreakAfterJavaFieldAnnotations: false +BreakAfterReturnType: All +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Custom +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakFunctionDefinitionParameters: false +BreakInheritanceList: BeforeComma +BreakStringLiterals: true +BreakTemplateDeclarations: Yes +## The following line allows larger lines in non-documentation code +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: AfterHash +IndentRequiresClause: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLines: + AtEndOfFile: false + AtStartOfBlock: true + AtStartOfFile: true +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MainIncludeChar: Quote +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: false +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +## The following line allows larger lines in non-documentation code +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakScopeResolution: 500 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Middle +PPIndentWidth: -1 +QualifierAlignment: Custom +QualifierOrder: + - friend + - static + - inline + - constexpr + - const + - type +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 1 +SkipMacroDefinitionBody: false +# We may want to sort the includes as a separate pass +SortIncludes: Never +SortJavaStaticImport: Before +# We may want to revisit this later +SortUsingDeclarations: Never +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterPlacementOperator: true + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: false +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + ExceptDoubleParentheses: false + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION + - ITK_GCC_PRAGMA_PUSH + - ITK_GCC_PRAGMA_POP + - ITK_GCC_SUPPRESS_Wfloat_equal + - ITK_GCC_SUPPRESS_Wformat_nonliteral + - ITK_GCC_SUPPRESS_Warray_bounds + - ITK_CLANG_PRAGMA_PUSH + - ITK_CLANG_PRAGMA_POP + - ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant + - CLANG_PRAGMA_PUSH + - CLANG_PRAGMA_POP + - CLANG_SUPPRESS_Wfloat_equal + - INTEL_PRAGMA_WARN_PUSH + - INTEL_PRAGMA_WARN_POP + - INTEL_SUPPRESS_warning_1292 + - itkTemplateFloatingToIntegerMacro + - itkLegacyMacro +TableGenBreakInsideDAGArg: DontBreak +TabWidth: 2 +UseTab: Never +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... diff --git a/include/itkSWCMeshIO.h b/include/itkSWCMeshIO.h index 3dd6bac..36f3754 100644 --- a/include/itkSWCMeshIO.h +++ b/include/itkSWCMeshIO.h @@ -31,9 +31,9 @@ namespace itk { /** \class SWCMeshIOEnums - * + * * \brief enums for the SWCMeshIO class. - * + * * \ingroup IOMeshSWC */ class SWCMeshIOEnums @@ -139,7 +139,8 @@ class IOMeshSWC_EXPORT SWCMeshIO : public MeshIOBase Write() override; using HeaderContentType = std::vector; - void SetHeaderContent(const HeaderContentType & headerContent); + void + SetHeaderContent(const HeaderContentType & headerContent); itkGetConstReferenceMacro(HeaderContent, HeaderContentType); // using SampleIdentifierType = int16_t; @@ -158,8 +159,10 @@ class IOMeshSWC_EXPORT SWCMeshIO : public MeshIOBase using ParentIdentifierContainerType = VectorContainer; /** Set/Get the sample identifiers. */ - void SetSampleIdentifiers(const SampleIdentifierContainerType *); - const SampleIdentifierContainerType * GetSampleIdentifiers() const; + void + SetSampleIdentifiers(const SampleIdentifierContainerType *); + const SampleIdentifierContainerType * + GetSampleIdentifiers() const; /** Set/Get the type identifiers. * 0 - undefined @@ -171,17 +174,23 @@ class IOMeshSWC_EXPORT SWCMeshIO : public MeshIOBase * 6 - unspecified neurite * 7 - glia processes */ - void SetTypeIdentifiers(const TypeIdentifierContainerType *); - const TypeIdentifierContainerType * GetTypeIdentifiers() const; + void + SetTypeIdentifiers(const TypeIdentifierContainerType *); + const TypeIdentifierContainerType * + GetTypeIdentifiers() const; /** Set/Get the Radius in micrometers (half the node thickness). */ - void SetRadii(const RadiusContainerType *); - const RadiusContainerType * GetRadii() const; + void + SetRadii(const RadiusContainerType *); + const RadiusContainerType * + GetRadii() const; /** Set/Get the parent sample identifiers. */ - void SetParentIdentifiers(const ParentIdentifierContainerType *); - const ParentIdentifierContainerType * GetParentIdentifiers() const; + void + SetParentIdentifiers(const ParentIdentifierContainerType *); + const ParentIdentifierContainerType * + GetParentIdentifiers() const; /** Set/Get the content of the point data on the input/output itk::Mesh. */ itkGetConstMacro(PointDataContent, SWCMeshIOEnums::SWCPointData); @@ -213,46 +222,42 @@ class IOMeshSWC_EXPORT SWCMeshIO : public MeshIOBase { switch (m_PointDataContent) { - case SWCMeshIOEnums::SWCPointData::SampleIdentifier: - { + case SWCMeshIOEnums::SWCPointData::SampleIdentifier: { m_SampleIdentifiers->resize(this->GetNumberOfPoints()); for (SizeValueType ii = 0; ii < this->m_NumberOfPoints; ++ii) { m_SampleIdentifiers->SetElement(ii, static_cast(buffer[ii])); } - } - break; - case SWCMeshIOEnums::SWCPointData::TypeIdentifier: - { + } + break; + case SWCMeshIOEnums::SWCPointData::TypeIdentifier: { m_TypeIdentifiers->resize(this->GetNumberOfPoints()); for (SizeValueType ii = 0; ii < this->m_NumberOfPoints; ++ii) { m_TypeIdentifiers->SetElement(ii, static_cast(buffer[ii])); } - } - break; - case SWCMeshIOEnums::SWCPointData::Radius: - { + } + break; + case SWCMeshIOEnums::SWCPointData::Radius: { m_Radii->resize(this->GetNumberOfPoints()); for (SizeValueType ii = 0; ii < this->m_NumberOfPoints; ++ii) { m_Radii->SetElement(ii, static_cast(buffer[ii])); } - } - break; - case SWCMeshIOEnums::SWCPointData::ParentIdentifier: - { + } + break; + case SWCMeshIOEnums::SWCPointData::ParentIdentifier: { m_ParentIdentifiers->resize(this->GetNumberOfPoints()); for (SizeValueType ii = 0; ii < this->m_NumberOfPoints; ++ii) { m_ParentIdentifiers->SetElement(ii, static_cast(buffer[ii])); } - } - break; + } + break; } } @@ -300,16 +305,16 @@ class IOMeshSWC_EXPORT SWCMeshIO : public MeshIOBase using PointIndexToSampleIdentifierType = std::unordered_map; private: - HeaderContentType m_HeaderContent; + HeaderContentType m_HeaderContent; SampleIdentifierContainerType::Pointer m_SampleIdentifiers; - TypeIdentifierContainerType::Pointer m_TypeIdentifiers; - RadiusContainerType::Pointer m_Radii; + TypeIdentifierContainerType::Pointer m_TypeIdentifiers; + RadiusContainerType::Pointer m_Radii; ParentIdentifierContainerType::Pointer m_ParentIdentifiers; - PointsBufferContainerType::Pointer m_PointsBuffer; - CellsBufferContainerType::Pointer m_CellsBuffer; - SampleIdentifierToPointIndexType m_SampleIdentifierToPointIndex; - PointIndexToParentPointIndexType m_PointIndexToParentPointIndex; - PointIndexToSampleIdentifierType m_PointIndexToSampleIdentifier; + PointsBufferContainerType::Pointer m_PointsBuffer; + CellsBufferContainerType::Pointer m_CellsBuffer; + SampleIdentifierToPointIndexType m_SampleIdentifierToPointIndex; + PointIndexToParentPointIndexType m_PointIndexToParentPointIndex; + PointIndexToSampleIdentifierType m_PointIndexToSampleIdentifier; SWCMeshIOEnums::SWCPointData m_PointDataContent{ SWCMeshIOEnums::SWCPointData::TypeIdentifier }; }; diff --git a/src/itkSWCMeshIO.cxx b/src/itkSWCMeshIO.cxx index b2a71fb..6e18d37 100644 --- a/src/itkSWCMeshIO.cxx +++ b/src/itkSWCMeshIO.cxx @@ -28,7 +28,7 @@ std::ostream & operator<<(std::ostream & out, const SWCMeshIOEnums::SWCPointData value) { return out << [value] { - switch(value) + switch (value) { case SWCMeshIOEnums::SWCPointData::SampleIdentifier: return "SWCMeshIOEnums::SWCPointData::SampleIdentifier"; @@ -40,13 +40,11 @@ operator<<(std::ostream & out, const SWCMeshIOEnums::SWCPointData value) return "SWCMeshIOEnums::SWCPointData::ParentIdentifier"; default: return "INVALID VALUE FOR SWCMeshIOEnums"; - } }(); } -SWCMeshIO -::SWCMeshIO() +SWCMeshIO ::SWCMeshIO() { this->AddSupportedWriteExtension(".swc"); @@ -64,8 +62,7 @@ ::SWCMeshIO() SWCMeshIO::~SWCMeshIO() = default; bool -SWCMeshIO -::CanReadFile(const char * fileName) +SWCMeshIO ::CanReadFile(const char * fileName) { if (!itksys::SystemTools::FileExists(fileName, true)) { @@ -81,8 +78,7 @@ ::CanReadFile(const char * fileName) } bool -SWCMeshIO -::CanWriteFile(const char * fileName) +SWCMeshIO ::CanWriteFile(const char * fileName) { if (itksys::SystemTools::GetFilenameLastExtension(fileName) != ".swc") { @@ -93,8 +89,7 @@ ::CanWriteFile(const char * fileName) } void -SWCMeshIO -::ReadMeshInformation() +SWCMeshIO ::ReadMeshInformation() { // Define input file stream and attach it to input file std::ifstream inputFile; @@ -119,9 +114,8 @@ ::ReadMeshInformation() } else { - m_HeaderContent.push_back(line.substr(first+1)); + m_HeaderContent.push_back(line.substr(first + 1)); } - } SizeValueType numberOfPoints = 0; @@ -218,10 +212,9 @@ ::ReadMeshInformation() } void -SWCMeshIO -::ReadPoints(void * buffer) +SWCMeshIO ::ReadPoints(void * buffer) { - auto * data = static_cast(buffer); + auto * data = static_cast(buffer); const SizeValueType numberOfValues = this->m_PointDimension * this->GetNumberOfPoints(); for (SizeValueType ii = 0; ii < numberOfValues; ++ii) { @@ -230,8 +223,7 @@ ::ReadPoints(void * buffer) } void -SWCMeshIO -::ReadCells(void * buffer) +SWCMeshIO ::ReadCells(void * buffer) { auto * data = static_cast(buffer); @@ -252,60 +244,57 @@ ::ReadCells(void * buffer) } void -SWCMeshIO -::ReadPointData(void * buffer) +SWCMeshIO ::ReadPointData(void * buffer) { const SizeValueType numberOfPoints = this->GetNumberOfPoints(); switch (m_PointDataContent) { case SWCMeshIOEnums::SWCPointData::SampleIdentifier: - { + { auto * data = static_cast(buffer); for (SizeValueType ii = 0; ii < numberOfPoints; ++ii) { data[ii] = m_SampleIdentifiers->GetElement(ii); } - } - break; + } + break; case SWCMeshIOEnums::SWCPointData::TypeIdentifier: - { + { auto * data = static_cast(buffer); for (SizeValueType ii = 0; ii < numberOfPoints; ++ii) { data[ii] = m_TypeIdentifiers->GetElement(ii); } - } - break; + } + break; case SWCMeshIOEnums::SWCPointData::Radius: - { + { auto * data = static_cast(buffer); for (SizeValueType ii = 0; ii < numberOfPoints; ++ii) { data[ii] = m_Radii->GetElement(ii); } - } - break; + } + break; case SWCMeshIOEnums::SWCPointData::ParentIdentifier: - { + { auto * data = static_cast(buffer); for (SizeValueType ii = 0; ii < numberOfPoints; ++ii) { data[ii] = m_ParentIdentifiers->GetElement(ii); } - } - break; + } + break; } } void -SWCMeshIO -::ReadCellData(void * itkNotUsed(buffer)) +SWCMeshIO ::ReadCellData(void * itkNotUsed(buffer)) {} void -SWCMeshIO -::WriteMeshInformation() +SWCMeshIO ::WriteMeshInformation() { // Check file name if (this->m_FileName.empty()) @@ -332,8 +321,7 @@ ::WriteMeshInformation() } void -SWCMeshIO -::WritePoints(void * buffer) +SWCMeshIO ::WritePoints(void * buffer) { // Write points switch (this->m_PointComponentType) @@ -427,7 +415,8 @@ ::WritePoints(void * buffer) if (ii < m_SampleIdentifiers->size()) { m_PointIndexToSampleIdentifier[ii] = m_SampleIdentifiers->GetElement(ii); - } else + } + else { m_PointIndexToSampleIdentifier[ii] = ii; } @@ -435,8 +424,7 @@ ::WritePoints(void * buffer) } void -SWCMeshIO -::WriteCells(void * buffer) +SWCMeshIO ::WriteCells(void * buffer) { // Check file name if (this->m_FileName.empty()) @@ -530,8 +518,7 @@ ::WriteCells(void * buffer) } void -SWCMeshIO -::WritePointData(void * buffer) +SWCMeshIO ::WritePointData(void * buffer) { // Write points switch (this->m_PointPixelComponentType) @@ -621,13 +608,11 @@ ::WritePointData(void * buffer) } void -SWCMeshIO -::WriteCellData(void * itkNotUsed(buffer)) +SWCMeshIO ::WriteCellData(void * itkNotUsed(buffer)) {} void -SWCMeshIO -::Write() +SWCMeshIO ::Write() { if (this->m_FileName.empty()) { @@ -644,12 +629,12 @@ ::Write() << this->m_FileName); } - const auto sampleIdentifiersSize = m_SampleIdentifiers->size(); - const auto typeIdentifiersSize = m_TypeIdentifiers->size(); - const auto radiiSize = m_Radii->size(); - const auto parentIdentifiersSize = m_ParentIdentifiers->size(); + const auto sampleIdentifiersSize = m_SampleIdentifiers->size(); + const auto typeIdentifiersSize = m_TypeIdentifiers->size(); + const auto radiiSize = m_Radii->size(); + const auto parentIdentifiersSize = m_ParentIdentifiers->size(); const std::string sep(" "); - SizeValueType pointsIndex = itk::NumericTraits::ZeroValue(); + SizeValueType pointsIndex = itk::NumericTraits::ZeroValue(); for (SizeValueType ii = 0; ii < this->m_NumberOfPoints; ++ii) { if (ii < sampleIdentifiersSize) @@ -658,7 +643,7 @@ ::Write() } else { - outputFile << ii+1; + outputFile << ii + 1; } outputFile << sep; @@ -704,8 +689,7 @@ ::Write() } void -SWCMeshIO -::PrintSelf(std::ostream & os, Indent indent) const +SWCMeshIO ::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); @@ -713,8 +697,7 @@ ::PrintSelf(std::ostream & os, Indent indent) const } void -SWCMeshIO -::SetSampleIdentifiers(const SampleIdentifierContainerType * sampleIdentifiers) +SWCMeshIO ::SetSampleIdentifiers(const SampleIdentifierContainerType * sampleIdentifiers) { const SizeValueType size = sampleIdentifiers->Size(); m_SampleIdentifiers->resize(size); @@ -726,15 +709,13 @@ ::SetSampleIdentifiers(const SampleIdentifierContainerType * sampleIdentifiers) } auto -SWCMeshIO -::GetSampleIdentifiers() const -> const SampleIdentifierContainerType * +SWCMeshIO ::GetSampleIdentifiers() const -> const SampleIdentifierContainerType * { return m_SampleIdentifiers; } void -SWCMeshIO -::SetTypeIdentifiers(const TypeIdentifierContainerType * typeIdentifiers) +SWCMeshIO ::SetTypeIdentifiers(const TypeIdentifierContainerType * typeIdentifiers) { const SizeValueType size = typeIdentifiers->Size(); m_TypeIdentifiers->resize(size); @@ -746,15 +727,13 @@ ::SetTypeIdentifiers(const TypeIdentifierContainerType * typeIdentifiers) } auto -SWCMeshIO -::GetTypeIdentifiers() const -> const TypeIdentifierContainerType * +SWCMeshIO ::GetTypeIdentifiers() const -> const TypeIdentifierContainerType * { return m_TypeIdentifiers; } void -SWCMeshIO -::SetRadii(const RadiusContainerType * radii) +SWCMeshIO ::SetRadii(const RadiusContainerType * radii) { const SizeValueType size = radii->Size(); m_Radii->resize(size); @@ -766,15 +745,13 @@ ::SetRadii(const RadiusContainerType * radii) } auto -SWCMeshIO -::GetRadii() const -> const RadiusContainerType * +SWCMeshIO ::GetRadii() const -> const RadiusContainerType * { return m_Radii; } void -SWCMeshIO -::SetParentIdentifiers(const ParentIdentifierContainerType * parentIdentifiers) +SWCMeshIO ::SetParentIdentifiers(const ParentIdentifierContainerType * parentIdentifiers) { const SizeValueType size = parentIdentifiers->Size(); m_ParentIdentifiers->resize(size); @@ -786,15 +763,13 @@ ::SetParentIdentifiers(const ParentIdentifierContainerType * parentIdentifiers) } auto -SWCMeshIO -::GetParentIdentifiers() const -> const ParentIdentifierContainerType * +SWCMeshIO ::GetParentIdentifiers() const -> const ParentIdentifierContainerType * { return m_ParentIdentifiers; } void -SWCMeshIO -::SetHeaderContent(const HeaderContentType & headerContent) +SWCMeshIO ::SetHeaderContent(const HeaderContentType & headerContent) { m_HeaderContent.resize(headerContent.size()); for (size_t ii = 0; ii < headerContent.size(); ++ii) diff --git a/src/itkSWCMeshIOFactory.cxx b/src/itkSWCMeshIOFactory.cxx index 424ddf3..3b0f52d 100644 --- a/src/itkSWCMeshIOFactory.cxx +++ b/src/itkSWCMeshIOFactory.cxx @@ -53,7 +53,7 @@ SWCMeshIOFactory::GetDescription() const // Undocumented API used to register during static initialization. // DO NOT CALL DIRECTLY. void IOMeshSWC_EXPORT - SWCMeshIOFactoryRegister__Private() +SWCMeshIOFactoryRegister__Private() { ObjectFactoryBase::RegisterInternalFactoryOnce(); }