diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..399e250 --- /dev/null +++ b/.clang-format @@ -0,0 +1,151 @@ +## This config file is only relevant for clang-format version 8.0.0 +## +## 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 http://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_8.0.0} --modified +## EXAMPLE apply code style enforcement after commit: +# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --last +--- +# This configuration requires clang-format version 8.0.0 exactly. +BasedOnStyle: Mozilla +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 +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +# clang 9.0 AllowShortLambdasOnASingleLine: All +# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: All +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Custom +BraceWrapping: + # clang 9.0 feature AfterCaseLabel: false + AfterClass: true + AfterControlStatement: true + AfterEnum: 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. + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakBeforeBinaryOperators: None +#clang 6.0 BreakBeforeInheritanceComma: true +BreakInheritanceList: BeforeComma +BreakBeforeTernaryOperators: true +#clang 6.0 BreakConstructorInitializersBeforeComma: true +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +## 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 +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: true +IndentPPDirectives: AfterHash +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +## The following line allows larger lines in non-documentation code +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Middle +ReflowComments: true +# We may want to sort the includes as a separate pass +SortIncludes: false +# We may want to revisit this later +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +# SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 2 +UseTab: Never +... diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c598f42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +# Custom attribute to mark sources as using our C++/C code style. +[attr]our-c-style whitespace=tab-in-indent,no-lf-at-eof hooks.style=KWStyle,clangformat + +*.c our-c-style +*.h our-c-style +*.cxx our-c-style +*.hxx our-c-style +*.txx our-c-style +*.txt whitespace=tab-in-indent,no-lf-at-eof +*.cmake whitespace=tab-in-indent,no-lf-at-eof + +# ExternalData content links must have LF newlines +*.md5 crlf=input +*.sha512 crlf=input diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 62f68ac..efccad4 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -1,7 +1,7 @@ set(CTEST_PROJECT_NAME "ITK") set(CTEST_NIGHTLY_START_TIME "1:00:00 UTC") -set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_METHOD "https") set(CTEST_DROP_SITE "open.cdash.org") set(CTEST_DROP_LOCATION "/submit.php?project=Insight") set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/include/itkCartesianToPolarTransform.h b/include/itkCartesianToPolarTransform.h index 069b3e3..407ec3b 100644 --- a/include/itkCartesianToPolarTransform.h +++ b/include/itkCartesianToPolarTransform.h @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,31 +47,30 @@ namespace itk * * Dimension must be at least 2. * - * \author Jakub Bican, Department of Image Processing, Institute of Information Theory and Automation, Academy of Sciences of the Czech Republic. + * \author Jakub Bican, Department of Image Processing, Institute of Information Theory and Automation, Academy of + * Sciences of the Czech Republic. * * \ingroup Transforms * \ingroup PolarTransform */ -template < - typename TParametersValueType=double, // Data type for scalars (float or double) - unsigned int NDimensions=3> // Number of dimensions -class ITK_TEMPLATE_EXPORT CartesianToPolarTransform : - public Transform< TParametersValueType, NDimensions, NDimensions > +template // Number of dimensions +class ITK_TEMPLATE_EXPORT CartesianToPolarTransform : public Transform { public: ITK_DISALLOW_COPY_AND_ASSIGN(CartesianToPolarTransform); /** Standard class type alias. */ using Self = CartesianToPolarTransform; - using Superclass = Transform< TParametersValueType, NDimensions, NDimensions >; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Superclass = Transform; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; /** New macro for creation of through the object factory.*/ - itkNewMacro( Self ); + itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro( CartesianToPolarTransform, Transform ); + itkTypeMacro(CartesianToPolarTransform, Transform); /** Dimension of the domain space. */ static constexpr unsigned int SpaceDimension = NDimensions; @@ -106,61 +105,69 @@ class ITK_TEMPLATE_EXPORT CartesianToPolarTransform : * This method transforms first two dimensions of a point from cartesian * coordinates to polar coordinates . */ - OutputPointType TransformPoint(const InputPointType &point ) const override; + OutputPointType + TransformPoint(const InputPointType & point) const override; /** Method to transform a vector - not applicable for this type of transform. */ - OutputVectorType TransformVector(const InputVectorType &) const override - { + OutputVectorType + TransformVector(const InputVectorType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return OutputVectorType(); - } + } /** Method to transform a vnl_vector - not applicable for this type of transform. */ - OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override - { + OutputVnlVectorType + TransformVector(const InputVnlVectorType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return OutputVnlVectorType(); - } + } /** Method to transform a vector - not applicable for this type of transform. */ - typename Superclass::OutputVectorPixelType TransformVector( - const typename Superclass::InputVectorPixelType &, const InputPointType &) const override - { + typename Superclass::OutputVectorPixelType + TransformVector(const typename Superclass::InputVectorPixelType &, const InputPointType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return typename Superclass::OutputVectorPixelType(); - } + } using Superclass::TransformVector; /** Method to transform a CovariantVector - not applicable for this type of transform. */ - OutputCovariantVectorType TransformCovariantVector( - const InputCovariantVectorType &) const override - { + OutputCovariantVectorType + TransformCovariantVector(const InputCovariantVectorType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return OutputCovariantVectorType(); - } + } using Superclass::TransformCovariantVector; - void ComputeJacobianWithRespectToParameters( const InputPointType &, JacobianType & ) const override - { + void + ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &) const override + { itkExceptionMacro(<< "Method not implemented yet."); - } + } - void SetParameters(const ParametersType &) override {} + void + SetParameters(const ParametersType &) override + {} - void SetFixedParameters(const ParametersType &) override {} + void + SetFixedParameters(const ParametersType &) override + {} /** Set the location of the center of the polar coordinate system. */ - itkSetMacro( Center, InputPointType ); - itkGetConstReferenceMacro( Center, InputPointType ); + itkSetMacro(Center, InputPointType); + itkGetConstReferenceMacro(Center, InputPointType); - /** Set an angular offset for the polar coordinate transform. + /** Set an angular offset for the polar coordinate transform. * * Defaults to 0.0 */ - itkSetMacro( AngleOffset, typename OutputPointType::ValueType ); - itkGetConstReferenceMacro( AngleOffset, typename OutputPointType::ValueType ); + itkSetMacro(AngleOffset, typename OutputPointType::ValueType); + itkGetConstReferenceMacro(AngleOffset, typename OutputPointType::ValueType); /** Enable/Disable to use constant arc increment instead of constant angular increment. * @@ -175,19 +182,20 @@ class ITK_TEMPLATE_EXPORT CartesianToPolarTransform : ~CartesianToPolarTransform() override; /** Print contents of an CartesianToPolarTransform. */ - void PrintSelf(std::ostream &os, Indent indent) const override; + void + PrintSelf(std::ostream & os, Indent indent) const override; private: - InputPointType m_Center; + InputPointType m_Center; typename OutputPointType::ValueType m_AngleOffset = 0; - bool m_ConstArcIncr = false; -}; //class CartesianToPolarTransform + bool m_ConstArcIncr = false; +}; // class CartesianToPolarTransform -} // namespace itk +} // namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkCartesianToPolarTransform.hxx" +# include "itkCartesianToPolarTransform.hxx" #endif #endif diff --git a/include/itkCartesianToPolarTransform.hxx b/include/itkCartesianToPolarTransform.hxx index f10337f..40e4e9f 100644 --- a/include/itkCartesianToPolarTransform.hxx +++ b/include/itkCartesianToPolarTransform.hxx @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,57 +24,51 @@ namespace itk { -template -CartesianToPolarTransform -::CartesianToPolarTransform(): - Superclass(ParametersDimension) +template +CartesianToPolarTransform::CartesianToPolarTransform() + : Superclass(ParametersDimension) { - this->m_Center.Fill( 0.0 ); + this->m_Center.Fill(0.0); } -template -CartesianToPolarTransform -::~CartesianToPolarTransform() -{ -} +template +CartesianToPolarTransform::~CartesianToPolarTransform() = default; -template +template void -CartesianToPolarTransform -::PrintSelf(std::ostream &os, Indent indent) const +CartesianToPolarTransform::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf(os,indent); + Superclass::PrintSelf(os, indent); os << indent << "Center: " << m_Center << std::endl; } -template +template typename CartesianToPolarTransform::OutputPointType -CartesianToPolarTransform -::TransformPoint(const InputPointType &inputPoint) const +CartesianToPolarTransform::TransformPoint(const InputPointType & inputPoint) const { - OutputPointType outputPoint( inputPoint ); + OutputPointType outputPoint(inputPoint); const InputPointType vector = inputPoint - this->m_Center; - outputPoint[1] = std::sqrt( vector[0] * vector[0] + vector[1] * vector[1] ); // r= sqrt(x^2 + y^2) - outputPoint[0] = std::acos( vector[0] / outputPoint[1] ); // alpha = acos(x/r) + outputPoint[1] = std::sqrt(vector[0] * vector[0] + vector[1] * vector[1]); // r= sqrt(x^2 + y^2) + outputPoint[0] = std::acos(vector[0] / outputPoint[1]); // alpha = acos(x/r) outputPoint[0] += m_AngleOffset; // add offset before 2*pi adjustment to keep values within [-pi,pi] - if( vector[1] < 0.0 ) - { + if (vector[1] < 0.0) + { outputPoint[0] = Math::twopi - outputPoint[0]; - } + } - if(m_ConstArcIncr) - { + if (m_ConstArcIncr) + { outputPoint[0] *= outputPoint[1]; // arc= r*alpha - } - + } + return outputPoint; } -} // namespace +} // namespace itk #endif diff --git a/include/itkPolarToCartesianTransform.h b/include/itkPolarToCartesianTransform.h index 001030e..c7cad2d 100644 --- a/include/itkPolarToCartesianTransform.h +++ b/include/itkPolarToCartesianTransform.h @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,30 +45,30 @@ namespace itk * * Extent of input in first dimension (alpha) should be only < 0, 2*pi ). * - * \author Jakub Bican, Department of Image Processing, Institute of Information Theory and Automation, Academy of Sciences of the Czech Republic. + * \author Jakub Bican, Department of Image Processing, Institute of Information Theory and Automation, Academy of + * Sciences of the Czech Republic. * * \ingroup Transforms * \ingroup PolarTransform */ -template < typename TParametersValueType=double, // Data type for scalars (float or double) - unsigned int NDimensions=3 > // Number of dimensions -class ITK_TEMPLATE_EXPORT PolarToCartesianTransform: - public Transform< TParametersValueType, NDimensions, NDimensions > +template // Number of dimensions +class ITK_TEMPLATE_EXPORT PolarToCartesianTransform : public Transform { public: ITK_DISALLOW_COPY_AND_ASSIGN(PolarToCartesianTransform); /** Standard class type alias. */ using Self = PolarToCartesianTransform; - using Superclass = Transform< TParametersValueType, NDimensions, NDimensions >; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Superclass = Transform; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; /** New macro for creation of through the object factory.*/ - itkNewMacro( Self ); + itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro( PolarToCartesianTransform, Transform ); + itkTypeMacro(PolarToCartesianTransform, Transform); /** Dimension of the domain space. */ static constexpr unsigned int SpaceDimension = NDimensions; @@ -103,61 +103,69 @@ class ITK_TEMPLATE_EXPORT PolarToCartesianTransform: * This method transforms first two dimensions of a point from polar * coordinates to cartesian coordinates. */ - OutputPointType TransformPoint(const InputPointType &point ) const override; + OutputPointType + TransformPoint(const InputPointType & point) const override; /** Method to transform a vector - not applicable for this type of transform. */ - OutputVectorType TransformVector(const InputVectorType &) const override - { + OutputVectorType + TransformVector(const InputVectorType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return OutputVectorType(); - } + } /** Method to transform a vnl_vector - not applicable for this type of transform. */ - OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override - { + OutputVnlVectorType + TransformVector(const InputVnlVectorType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return OutputVnlVectorType(); - } + } /** Method to transform a vector - not applicable for this type of transform. */ - typename Superclass::OutputVectorPixelType TransformVector( - const typename Superclass::InputVectorPixelType &, const InputPointType &) const override - { + typename Superclass::OutputVectorPixelType + TransformVector(const typename Superclass::InputVectorPixelType &, const InputPointType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return typename Superclass::OutputVectorPixelType(); - } + } using Superclass::TransformVector; /** Method to transform a CovariantVector - not applicable for this type of transform */ - OutputCovariantVectorType TransformCovariantVector( - const InputCovariantVectorType &) const override - { + OutputCovariantVectorType + TransformCovariantVector(const InputCovariantVectorType &) const override + { itkExceptionMacro(<< "Method not applicable for this type of transform."); return OutputCovariantVectorType(); - } + } using Superclass::TransformCovariantVector; - void ComputeJacobianWithRespectToParameters( const InputPointType &, JacobianType & ) const override - { + void + ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &) const override + { itkExceptionMacro(<< "Method not implemented yet."); - } + } - void SetParameters(const ParametersType &) override {} + void + SetParameters(const ParametersType &) override + {} - void SetFixedParameters(const ParametersType &) override {} + void + SetFixedParameters(const ParametersType &) override + {} /** Set the location of the center of the polar coordinate system. */ - itkSetMacro( Center, OutputPointType ); - itkGetConstReferenceMacro( Center, OutputPointType ); + itkSetMacro(Center, OutputPointType); + itkGetConstReferenceMacro(Center, OutputPointType); - /** Set an angular offset for the polar coordinate transform. + /** Set an angular offset for the polar coordinate transform. * * Defaults to 0.0 */ - itkSetMacro( AngleOffset, typename InputPointType::ValueType ); - itkGetConstReferenceMacro( AngleOffset, typename InputPointType::ValueType ); + itkSetMacro(AngleOffset, typename InputPointType::ValueType); + itkGetConstReferenceMacro(AngleOffset, typename InputPointType::ValueType); /** Enable/Disable to use constant arc increment instead of constant angular increment. * @@ -180,20 +188,21 @@ class ITK_TEMPLATE_EXPORT PolarToCartesianTransform: ~PolarToCartesianTransform() override; /** Print contents of an PolarToCartesianTransform. */ - void PrintSelf(std::ostream &os, Indent indent) const override; + void + PrintSelf(std::ostream & os, Indent indent) const override; private: - OutputPointType m_Center; + OutputPointType m_Center; typename InputPointType::ValueType m_AngleOffset = 0; - bool m_ConstArcIncr = false; - bool m_ReturnNaN = false; -}; //class PolarToCartesianTransform + bool m_ConstArcIncr = false; + bool m_ReturnNaN = false; +}; // class PolarToCartesianTransform -} // namespace itk +} // namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkPolarToCartesianTransform.hxx" +# include "itkPolarToCartesianTransform.hxx" #endif #endif diff --git a/include/itkPolarToCartesianTransform.hxx b/include/itkPolarToCartesianTransform.hxx index 48472de..d152f40 100644 --- a/include/itkPolarToCartesianTransform.hxx +++ b/include/itkPolarToCartesianTransform.hxx @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,62 +23,56 @@ namespace itk { -template< typename TParametersValueType, unsigned int NDimensions > -PolarToCartesianTransform -::PolarToCartesianTransform(): - Superclass(ParametersDimension) +template +PolarToCartesianTransform::PolarToCartesianTransform() + : Superclass(ParametersDimension) { - this->m_Center.Fill( 0.0 ); + this->m_Center.Fill(0.0); } -template -PolarToCartesianTransform -::~PolarToCartesianTransform() -{ -} +template +PolarToCartesianTransform::~PolarToCartesianTransform() = default; -template +template void -PolarToCartesianTransform -::PrintSelf(std::ostream &os, Indent indent) const +PolarToCartesianTransform::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf(os,indent); + Superclass::PrintSelf(os, indent); os << indent << "Center: " << m_Center << std::endl; } -template +template typename PolarToCartesianTransform::OutputPointType -PolarToCartesianTransform -::TransformPoint(const InputPointType & inputPoint) const +PolarToCartesianTransform::TransformPoint(const InputPointType & inputPoint) const { OutputPointType outputPoint(inputPoint); double alpha = inputPoint[0]; - if(m_ConstArcIncr) - { + if (m_ConstArcIncr) + { alpha /= inputPoint[1]; // alpha = arc/r - } + } - if(m_ReturnNaN && (alpha < -Math::pi || Math::pi < alpha)) - { + if (m_ReturnNaN && (alpha < -Math::pi || Math::pi < alpha)) + { using PointNumericTraits = NumericTraits; outputPoint[0] = PointNumericTraits::quiet_NaN(); outputPoint[1] = PointNumericTraits::quiet_NaN(); return outputPoint; - } - + } + alpha += m_AngleOffset; // add offset after NaN return to keep values within [-pi,pi] - - outputPoint[0] = inputPoint[1] * std::cos(alpha); //r*cos(alpha) - outputPoint[1] = inputPoint[1] * std::sin(alpha); //r*sin(alpha) - for( unsigned int ii = 0; ii < SpaceDimension; ++ii ) - { + outputPoint[0] = inputPoint[1] * std::cos(alpha); // r*cos(alpha) + outputPoint[1] = inputPoint[1] * std::sin(alpha); // r*sin(alpha) + + for (unsigned int ii = 0; ii < SpaceDimension; ++ii) + { outputPoint[ii] = this->m_Center[ii] + outputPoint[ii]; - } + } return outputPoint; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cd29c9d..65beaa1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,7 +10,9 @@ itk_add_test(NAME itkPolarTransformTest COMMAND PolarTransformTestDriver itkPolarTransformTest ) -itk_python_expression_add_test(NAME itkPolarToCartesianTransformPythonTest - EXPRESSION "instance = itk.PolarToCartesianTransform.New()") -itk_python_expression_add_test(NAME itkCartesianToPolarTransformPythonTest - EXPRESSION "instance = itk.CartesianToPolarTransform.New()") +if(ITK_WRAP_PYTHON) + itk_python_expression_add_test(NAME itkPolarToCartesianTransformPythonTest + EXPRESSION "instance = itk.PolarToCartesianTransform.New()") + itk_python_expression_add_test(NAME itkCartesianToPolarTransformPythonTest + EXPRESSION "instance = itk.CartesianToPolarTransform.New()") +endif() diff --git a/test/azure-pipelines.yml b/test/azure-pipelines.yml new file mode 100644 index 0000000..919162e --- /dev/null +++ b/test/azure-pipelines.yml @@ -0,0 +1,233 @@ +# The file template originates from: https://github.com/InsightSoftwareConsortium/ITKModuleTemplate +variables: + ITKGitTag: v5.1rc02 + ITKPythonGitTag: v5.1rc02 + CMakeBuildType: Release + +trigger: + batch: true + branches: + include: + - master + +jobs: + +- job: 'Test' + displayName: "Build and test" + timeoutInMinutes: 0 + cancelTimeoutInMinutes: 300 + + strategy: + matrix: + Linux1604: + imageName: 'ubuntu-16.04' + cCompiler: gcc + cxxCompiler: g++ + compilerInitialization: '' + Linux1804: + imageName: 'ubuntu-18.04' + cCompiler: gcc + cxxCompiler: g++ + compilerInitialization: '' + macOS1015: + imageName: 'macos-10.15' + cCompiler: clang + cxxCompiler: clang++ + compilerInitialization: '' + macOS1014: + imageName: 'macos-10.14' + cCompiler: clang + cxxCompiler: clang++ + compilerInitialization: '' + Windows2017: + imageName: 'vs2017-win2016' + cCompiler: cl.exe + cxxCompiler: cl.exe + compilerInitialization: 'call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"' + Windows2019: + imageName: 'windows-2019' + cCompiler: cl.exe + cxxCompiler: cl.exe + compilerInitialization: 'call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"' + + pool: + vmImage: $(imageName) + + steps: + - bash: | + set -x + if [ -n "$(System.PullRequest.SourceCommitId)" ]; then + git checkout $(System.PullRequest.SourceCommitId) + fi + displayName: 'Checkout pull request HEAD' + + - task: UsePythonVersion@0 + inputs: + versionSpec: '3.7' + architecture: 'x64' + + - script: | + python -m pip install --upgrade pip + python -m pip install --upgrade setuptools + python -m pip install scikit-ci-addons + python -m pip install ninja + displayName: 'Install build dependencies' + + - script: | + git clone --depth 5 --branch $(ITKGitTag) https://github.com/InsightSoftwareConsortium/ITK.git + workingDirectory: $(Agent.BuildDirectory) + displayName: 'Download ITK' + + - script: | + mkdir ITK-build + cd ITK-build + $(compilerInitialization) + cmake -DCMAKE_C_COMPILER:FILEPATH="$(cCompiler)" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="$(cxxCompiler)" -DCMAKE_BUILD_TYPE:STRING=$(CMakeBuildType) -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK + ninja + workingDirectory: $(Agent.BuildDirectory) + displayName: 'Build ITK' + + - script: | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O + displayName: 'Fetch CTest driver script' + + - bash: | + cat > dashboard.cmake << EOF + set(CTEST_SITE "Azure.\$ENV{AGENT_MACHINENAME}") + file(TO_CMAKE_PATH "\$ENV{AGENT_BUILDDIRECTORY}" CTEST_DASHBOARD_ROOT) + file(TO_CMAKE_PATH "\$ENV{BUILD_SOURCESDIRECTORY}" CTEST_SOURCE_DIRECTORY) + file(TO_CMAKE_PATH "\$ENV{AGENT_BUILDDIRECTORY}/build" CTEST_BINARY_DIRECTORY) + set(dashboard_source_name "$(Build.Repository.Name)") + if(DEFINED ENV{SYSTEM_PULLREQUEST_SOURCEBRANCH}) + set(branch "-\$ENV{SYSTEM_PULLREQUEST_SOURCEBRANCH}") + set(dashboard_model "Experimental") + elseif(ENV{BUILD_SOURCEBRANCHNAME} STREQUAL "master") + set(branch "-master") + set(dashboard_model "Continuous") + else() + set(branch "-\$ENV{BUILD_SOURCEBRANCHNAME}") + set(dashboard_model "Experimental") + endif() + if(DEFINED ENV{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}) + set(pr "-PR\$ENV{SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}") + else() + set(pr "") + endif() + set(CTEST_BUILD_NAME "$(Build.Repository.Name)-$(Agent.OS)-Build$(Build.BuildId)\${pr}\${branch}") + set(CTEST_UPDATE_VERSION_ONLY 1) + set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL}) + set(CTEST_BUILD_CONFIGURATION "Release") + set(CTEST_CMAKE_GENERATOR "Ninja") + set(CTEST_CUSTOM_WARNING_EXCEPTION + \${CTEST_CUSTOM_WARNING_EXCEPTION} + # macOS Azure Pipelines + "ld: warning: text-based stub file" + ) + set(dashboard_no_clean 1) + set(ENV{CC} $(cCompiler)) + set(ENV{CXX} $(cxxCompiler)) + set(dashboard_cache " + ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build + BUILD_TESTING:BOOL=ON + ") + string(TIMESTAMP build_date "%Y-%m-%d") + message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}") + message("CTEST_SITE = \${CTEST_SITE}") + include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake) + EOF + cat dashboard.cmake + displayName: 'Configure CTest script' + + - script: | + $(compilerInitialization) + ctest -j 2 -V -S dashboard.cmake + displayName: 'Build and test' + + - script: | + sudo pip3 install --upgrade pip + sudo pip3 install --upgrade setuptools + sudo pip3 install scikit-ci-addons + ci_addons ctest_junit_formatter $(Agent.BuildDirectory)/build > $(Agent.BuildDirectory)/JUnitTestResults.xml + condition: succeededOrFailed() + displayName: 'Format CTest output in JUnit format' + + - task: PublishTestResults@2 + inputs: + testResultsFiles: "$(Agent.BuildDirectory)/JUnitTestResults.xml" + testRunTitle: 'CTest $(Agent.OS)' + condition: succeededOrFailed() + displayName: 'Publish test results' + + +- job: 'PackageLinux' + timeoutInMinutes: 0 + cancelTimeoutInMinutes: 300 + displayName: "Build Linux Python packages" + pool: + vmImage: 'Ubuntu-16.04' + + steps: + - script: | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O + chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh + displayName: 'Fetch build script' + + - script: | + export ITK_PACKAGE_VERSION=$(ITKPythonGitTag) + ./dockcross-manylinux-download-cache-and-build-module-wheels.sh + displayName: 'Build Python packages' + + - task: PublishPipelineArtifact@0 + inputs: + artifactName: 'LinuxWheels' + targetPath: './dist' + + +- job: 'PackageMacOS' + displayName: "Build macOS Python packages" + timeoutInMinutes: 0 + cancelTimeoutInMinutes: 300 + pool: + vmImage: 'macos-10.13' + + steps: + - script: | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/macpython-download-cache-and-build-module-wheels.sh -O + chmod u+x macpython-download-cache-and-build-module-wheels.sh + displayName: 'Fetch build script' + + - script: | + export ITK_PACKAGE_VERSION=$(ITKPythonGitTag) + ./macpython-download-cache-and-build-module-wheels.sh + displayName: 'Build Python packages' + + - task: PublishPipelineArtifact@0 + inputs: + artifactName: 'MacOSWheels' + targetPath: './dist' + + +- job: 'PackageWindows' + displayName: "Build Windows Python packages" + timeoutInMinutes: 0 + cancelTimeoutInMinutes: 300 + pool: + vmImage: 'vs2017-win2016' + + steps: + - script: | + curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/windows-download-cache-and-build-module-wheels.ps1 -O + displayName: 'Fetch build script' + + - script: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat" + set ITK_PACKAGE_VERSION=$(ITKPythonGitTag) + set CC=cl.exe + set CXX=cl.exe + powershell.exe -file .\windows-download-cache-and-build-module-wheels.ps1 + displayName: 'Build Python packages' + + - task: PublishPipelineArtifact@0 + inputs: + artifactName: 'WindowsWheels' + targetPath: './dist' diff --git a/test/itkPolarTransformTest.cxx b/test/itkPolarTransformTest.cxx index 1ab0e96..16d6de7 100644 --- a/test/itkPolarTransformTest.cxx +++ b/test/itkPolarTransformTest.cxx @@ -1,6 +1,6 @@ /*========================================================================= * - * Copyright Insight Software Consortium + * Copyright NumFOCUS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,82 +19,83 @@ #include "itkCartesianToPolarTransform.h" #include "itkMath.h" -int itkPolarTransformTest( int, char *[] ) +int +itkPolarTransformTest(int, char *[]) { constexpr unsigned int Dimension = 4; - const double epsilon = 1e-10; + const double epsilon = 1e-10; /* Create 3D polar transforms and print them. */ - using P2CTransformType = itk::PolarToCartesianTransform; - using C2PTransformType = itk::CartesianToPolarTransform; + using P2CTransformType = itk::PolarToCartesianTransform; + using C2PTransformType = itk::CartesianToPolarTransform; P2CTransformType::Pointer p2c = P2CTransformType::New(); C2PTransformType::Pointer c2p = C2PTransformType::New(); P2CTransformType::InputPointType center; - center.Fill( 0.0 ); + center.Fill(0.0); center[0] = -1.0; - p2c->SetCenter( center ); - c2p->SetCenter( center ); + p2c->SetCenter(center); + c2p->SetCenter(center); - std::cout << "Polar to cartesian transform: "<< p2c << std::endl; - std::cout << "Cartesian to polar transform: "<< c2p << std::endl; + std::cout << "Polar to cartesian transform: " << p2c << std::endl; + std::cout << "Cartesian to polar transform: " << c2p << std::endl; /* Create testing points in cartesian and polar space. */ itk::Point c, p, tmp; c[0] = 0.0; c[1] = std::sqrt(3.0); - p[0] = itk::Math::pi/3.0; + p[0] = itk::Math::pi / 3.0; p[1] = 2.0; - for ( unsigned int i = 2; i < Dimension; ++i ) - { + for (unsigned int i = 2; i < Dimension; ++i) + { c[i] = 3.0; p[i] = c[i]; - } + } /* Transform point from polar to cartesian space. */ tmp = p2c->TransformPoint(p); - for( unsigned int i = 0; i < Dimension; ++i ) + for (unsigned int i = 0; i < Dimension; ++i) + { + if (std::abs(tmp[i] - c[i]) > epsilon) { - if( std::abs( tmp[i] - c[i] ) > epsilon ) - { return EXIT_FAILURE; - } } + } /* Transform point from cartesian to polar space. */ tmp = c2p->TransformPoint(c); - for( unsigned int i = 0; i < Dimension; ++i ) + for (unsigned int i = 0; i < Dimension; ++i) + { + if (std::abs(tmp[i] - p[i]) > epsilon) { - if( std::abs( tmp[i] - p[i] ) > epsilon ) - { std::cout << "Invalid cartesian to polar computed." << std::endl; return EXIT_FAILURE; - } } + } /* Transform point from polar to cartesian space and back. */ tmp = c2p->TransformPoint(p2c->TransformPoint(p)); - for( unsigned int i = 0; i < Dimension; ++i ) + for (unsigned int i = 0; i < Dimension; ++i) + { + if (std::abs(tmp[i] - p[i]) > epsilon) { - if( std::abs( tmp[i] - p[i] ) > epsilon ) - { std::cout << "Invalid polar to cartesian and back computed." << std::endl; return EXIT_FAILURE; - } } + } /* Transform point from cartesian to polar space and back. */ tmp = p2c->TransformPoint(c2p->TransformPoint(c)); - for( unsigned int i = 0; i < Dimension; ++i ) + for (unsigned int i = 0; i < Dimension; ++i) + { + if (std::abs(tmp[i] - c[i]) > epsilon) { - if ( std::abs( tmp[i] - c[i] ) > epsilon ) - { std::cout << "Invalid cartesian to polar and back computed." << std::endl; return EXIT_FAILURE; - } } + } return EXIT_SUCCESS; }