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/include/itkSplitComponentsImageFilter.h b/include/itkSplitComponentsImageFilter.h index f39221f..633e261 100644 --- a/include/itkSplitComponentsImageFilter.h +++ b/include/itkSplitComponentsImageFilter.h @@ -44,9 +44,8 @@ namespace itk * \sa DiffusionTensor3D * \sa NthElementImageAdaptor */ -template< typename TInputImage, typename TOutputImage, unsigned int TComponents = TInputImage::ImageDimension > -class SplitComponentsImageFilter: - public ImageToImageFilter< TInputImage, TOutputImage > +template +class SplitComponentsImageFilter : public ImageToImageFilter { public: ITK_DISALLOW_COPY_AND_ASSIGN(SplitComponentsImageFilter); @@ -65,34 +64,37 @@ class SplitComponentsImageFilter: /** Standard class type alias. */ using Self = SplitComponentsImageFilter; - using Superclass = ImageToImageFilter< InputImageType, OutputImageType >; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Superclass = ImageToImageFilter; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; - using ComponentsMaskType = FixedArray< bool, TComponents >; + using ComponentsMaskType = FixedArray; /** Run-time type information (and related methods). */ - itkTypeMacro( SplitComponentsImageFilter, ImageToImageFilter ); + itkTypeMacro(SplitComponentsImageFilter, ImageToImageFilter); /** Method of creation through the object factory. */ - itkNewMacro( Self ); + itkNewMacro(Self); /** Set/Get the components mask. The mask is as long as the number of * components, and only values in the mask that evaluate are true will be * populated in the output. The default is all true. */ - itkSetMacro( ComponentsMask, ComponentsMaskType ); - itkGetConstReferenceMacro( ComponentsMask, ComponentsMaskType ); + itkSetMacro(ComponentsMask, ComponentsMaskType); + itkGetConstReferenceMacro(ComponentsMask, ComponentsMaskType); protected: SplitComponentsImageFilter(); ~SplitComponentsImageFilter() override {} /** Do not allocate outputs that we will not populate. */ - void AllocateOutputs() override; + void + AllocateOutputs() override; - void DynamicThreadedGenerateData( const OutputRegionType& outputRegion ) override; + void + DynamicThreadedGenerateData(const OutputRegionType & outputRegion) override; - void PrintSelf ( std::ostream& os, Indent indent ) const override; + void + PrintSelf(std::ostream & os, Indent indent) const override; private: ComponentsMaskType m_ComponentsMask; @@ -101,7 +103,7 @@ class SplitComponentsImageFilter: } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkSplitComponentsImageFilter.hxx" +# include "itkSplitComponentsImageFilter.hxx" #endif #endif diff --git a/include/itkSplitComponentsImageFilter.hxx b/include/itkSplitComponentsImageFilter.hxx index c7bef38..b76b920 100644 --- a/include/itkSplitComponentsImageFilter.hxx +++ b/include/itkSplitComponentsImageFilter.hxx @@ -26,100 +26,94 @@ namespace itk { -template< typename TInputImage, typename TOutputImage, unsigned int TComponents > -SplitComponentsImageFilter< TInputImage, TOutputImage, TComponents > -::SplitComponentsImageFilter() +template +SplitComponentsImageFilter::SplitComponentsImageFilter() { - this->m_ComponentsMask.Fill( true ); + this->m_ComponentsMask.Fill(true); - this->SetNumberOfIndexedOutputs( Components ); + this->SetNumberOfIndexedOutputs(Components); // ImageSource only does this for the first output. - for ( unsigned int i = 1; i < Components; i++ ) - { - this->SetNthOutput( i, this->MakeOutput( i ) ); - } + for (unsigned int i = 1; i < Components; i++) + { + this->SetNthOutput(i, this->MakeOutput(i)); + } this->DynamicMultiThreadingOn(); } -template< typename TInputImage, typename TOutputImage, unsigned int TComponents > +template void -SplitComponentsImageFilter< TInputImage, TOutputImage, TComponents > -::AllocateOutputs() +SplitComponentsImageFilter::AllocateOutputs() { - using ImageBaseType = ImageBase< TOutputImage::ImageDimension >; + using ImageBaseType = ImageBase; typename ImageBaseType::Pointer outputPtr; // Allocate the output memory as with ImageSource unsigned int ii = 0; - for ( OutputDataObjectIterator it(this); - !it.IsAtEnd(); - ++it, ++ii ) - { + for (OutputDataObjectIterator it(this); !it.IsAtEnd(); ++it, ++ii) + { // Check whether the output is an image of the appropriate // dimension (use ProcessObject's version of the GetInput() // method since it returns the input as a pointer to a // DataObject as opposed to the subclass version which // static_casts the input to an TInputImage). - outputPtr = dynamic_cast< ImageBaseType * >( it.GetOutput() ); + outputPtr = dynamic_cast(it.GetOutput()); - if ( outputPtr && this->m_ComponentsMask[ii] ) - { - outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() ); + if (outputPtr && this->m_ComponentsMask[ii]) + { + outputPtr->SetBufferedRegion(outputPtr->GetRequestedRegion()); outputPtr->Allocate(); - } } + } } -template< typename TInputImage, typename TOutputImage, unsigned int TComponents > +template void -SplitComponentsImageFilter< TInputImage, TOutputImage, TComponents > -::DynamicThreadedGenerateData( const OutputRegionType& outputRegion ) +SplitComponentsImageFilter::DynamicThreadedGenerateData( + const OutputRegionType & outputRegion) { typename InputImageType::ConstPointer input = this->GetInput(); ProcessObject::DataObjectPointerArray outputs = this->GetOutputs(); - const ComponentsMaskType componentsMask = this->m_ComponentsMask; - - using OutputIteratorType = ImageRegionIterator< OutputImageType >; - ImageRegionConstIterator< InputImageType > inIt( input, outputRegion ); - std::vector< OutputIteratorType > outIts( Components ); - for ( unsigned int ii = 0; ii < Components; ++ii ) + const ComponentsMaskType componentsMask = this->m_ComponentsMask; + + using OutputIteratorType = ImageRegionIterator; + ImageRegionConstIterator inIt(input, outputRegion); + std::vector outIts(Components); + for (unsigned int ii = 0; ii < Components; ++ii) + { + if (componentsMask[ii]) { - if( componentsMask[ii] ) - { - OutputIteratorType outIt( dynamic_cast< OutputImageType* > - ( outputs[ii].GetPointer() ), outputRegion ); + OutputIteratorType outIt(dynamic_cast(outputs[ii].GetPointer()), outputRegion); outIt.GoToBegin(); outIts[ii] = outIt; - } } + } InputPixelType inputPixel; - for ( inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt ) - { + for (inIt.GoToBegin(); !inIt.IsAtEnd(); ++inIt) + { inputPixel = inIt.Get(); - for ( unsigned int ii = 0; ii < Components; ++ii ) + for (unsigned int ii = 0; ii < Components; ++ii) + { + if (componentsMask[ii]) { - if( componentsMask[ii] ) - { - outIts[ii].Set( static_cast< OutputPixelType >( inputPixel[ii] ) ); + outIts[ii].Set(static_cast(inputPixel[ii])); ++(outIts[ii]); - } } } + } } -template< typename TInputImage, typename TOutputImage, unsigned int TComponents > +template void -SplitComponentsImageFilter< TInputImage, TOutputImage, TComponents > -::PrintSelf( std::ostream & os, Indent indent ) const +SplitComponentsImageFilter::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); - os << indent << "ComponentsMask: " - << static_cast< typename NumericTraits< ComponentsMaskType >::PrintType >( m_ComponentsMask ) - << std::endl; + os << indent + << "ComponentsMask: " << static_cast::PrintType>(m_ComponentsMask) + << std::endl; } } // end namespace itk diff --git a/include/itkStrainImageFilter.h b/include/itkStrainImageFilter.h index c0eea66..cd1c18f 100644 --- a/include/itkStrainImageFilter.h +++ b/include/itkStrainImageFilter.h @@ -59,11 +59,11 @@ namespace itk * \ingroup Strain * */ -template< typename TInputImage, typename TOperatorValueType=float, typename TOutputValueType=float > -class StrainImageFilter : public - ImageToImageFilter< TInputImage, - Image< SymmetricSecondRankTensor< TOutputValueType, TInputImage::ImageDimension >, - TInputImage::ImageDimension > > +template +class StrainImageFilter + : public ImageToImageFilter< + TInputImage, + Image, TInputImage::ImageDimension>> { public: ITK_DISALLOW_COPY_AND_ASSIGN(StrainImageFilter); @@ -72,66 +72,74 @@ class StrainImageFilter : public static constexpr unsigned int ImageDimension = TInputImage::ImageDimension; using InputImageType = TInputImage; - using OutputPixelType = SymmetricSecondRankTensor< TOutputValueType, ImageDimension >; - using OutputImageType = Image< OutputPixelType, ImageDimension >; - using OperatorImageType = Image< TOperatorValueType, ImageDimension >; + using OutputPixelType = SymmetricSecondRankTensor; + using OutputImageType = Image; + using OperatorImageType = Image; /** Standard class type alias. */ using Self = StrainImageFilter; - using Superclass = ImageToImageFilter< InputImageType, OutputImageType >; + using Superclass = ImageToImageFilter; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; /** Type of the filter used to calculate the gradients. */ - using GradientOutputPixelType = CovariantVector< TOperatorValueType, ImageDimension >; - using GradientOutputImageType = Image< GradientOutputPixelType, ImageDimension >; - using GradientFilterType = ImageToImageFilter< OperatorImageType, GradientOutputImageType >; + using GradientOutputPixelType = CovariantVector; + using GradientOutputImageType = Image; + using GradientFilterType = ImageToImageFilter; /** Alternate type of filter used to calculate the gradients. */ - using VectorGradientFilterType = ImageToImageFilter< InputImageType, GradientOutputImageType >; + using VectorGradientFilterType = ImageToImageFilter; /** Method for creation through the object factory. */ - itkNewMacro( Self ); + itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro( StrainImageFilter, ImageToImageFilter ); + itkTypeMacro(StrainImageFilter, ImageToImageFilter); /** Set the filter used to calculate the gradients internally. The default is * an itk::GradientImageFilter. */ - itkSetObjectMacro( GradientFilter, GradientFilterType ); - itkGetConstObjectMacro( GradientFilter, GradientFilterType ); + itkSetObjectMacro(GradientFilter, GradientFilterType); + itkGetConstObjectMacro(GradientFilter, GradientFilterType); /** Set the filter used to calculate the gradients internally. This filter * should take a Vector image as input and produce a CovariantVector gradient * image on each output corresponding to every Vector component. If this * filter is non-NULL, it is used instead of the GradientFilter. */ - itkSetObjectMacro( VectorGradientFilter, VectorGradientFilterType ); - itkGetConstObjectMacro( VectorGradientFilter, VectorGradientFilterType ); + itkSetObjectMacro(VectorGradientFilter, VectorGradientFilterType); + itkGetConstObjectMacro(VectorGradientFilter, VectorGradientFilterType); /** * Three different types of strains can be calculated, infinitesimal (default), aka * engineering strain, which is appropriate for small strains, Green-Lagrangian, * which uses a material reference system, and Eulerian-Almansi, which uses a * spatial reference system. This is set with SetStrainForm(). */ - enum StrainFormType {INFINITESIMAL = 0, GREENLAGRANGIAN = 1, EULERIANALMANSI = 2}; + enum StrainFormType + { + INFINITESIMAL = 0, + GREENLAGRANGIAN = 1, + EULERIANALMANSI = 2 + }; - itkSetMacro( StrainForm, StrainFormType ); - itkGetConstMacro( StrainForm, StrainFormType ); + itkSetMacro(StrainForm, StrainFormType); + itkGetConstMacro(StrainForm, StrainFormType); protected: using OutputRegionType = typename OutputImageType::RegionType; StrainImageFilter(); - void BeforeThreadedGenerateData() override; + void + BeforeThreadedGenerateData() override; - void DynamicThreadedGenerateData( const OutputRegionType& outputRegion ) override; + void + DynamicThreadedGenerateData(const OutputRegionType & outputRegion) override; - using InputComponentsImageFilterType = itk::SplitComponentsImageFilter< InputImageType, OperatorImageType >; + using InputComponentsImageFilterType = itk::SplitComponentsImageFilter; - void PrintSelf ( std::ostream& os, Indent indent ) const override; + void + PrintSelf(std::ostream & os, Indent indent) const override; private: typename InputComponentsImageFilterType::Pointer m_InputComponentsFilter; @@ -146,7 +154,7 @@ class StrainImageFilter : public } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkStrainImageFilter.hxx" +# include "itkStrainImageFilter.hxx" #endif #endif diff --git a/include/itkStrainImageFilter.hxx b/include/itkStrainImageFilter.hxx index 0c23f2f..21ef27a 100644 --- a/include/itkStrainImageFilter.hxx +++ b/include/itkStrainImageFilter.hxx @@ -27,187 +27,173 @@ namespace itk { -template< typename TInputImage, typename TOperatorValueType, typename TOutputValueType > -StrainImageFilter< TInputImage, TOperatorValueType, TOutputValueType > -::StrainImageFilter(): - m_InputComponentsFilter( InputComponentsImageFilterType::New() ), - m_StrainForm( INFINITESIMAL ) +template +StrainImageFilter::StrainImageFilter() + : m_InputComponentsFilter(InputComponentsImageFilterType::New()) + , m_StrainForm(INFINITESIMAL) { // The first output is only of interest to the user. The rest of the outputs // are GradientImageFilter outputs used internally, but put on the output so // memory management capabilities of the pipeline can be taken advantage of. - this->SetNumberOfIndexedOutputs( 1 + ImageDimension ); - for( unsigned int i = 1; i < ImageDimension + 1; i++ ) - { - this->SetNthOutput( i, GradientOutputImageType::New().GetPointer() ); - } + this->SetNumberOfIndexedOutputs(1 + ImageDimension); + for (unsigned int i = 1; i < ImageDimension + 1; i++) + { + this->SetNthOutput(i, GradientOutputImageType::New().GetPointer()); + } - using GradientImageFilterType = GradientImageFilter< OperatorImageType, TOperatorValueType, TOperatorValueType >; + using GradientImageFilterType = GradientImageFilter; this->m_GradientFilter = GradientImageFilterType::New().GetPointer(); this->DynamicMultiThreadingOn(); } -template< typename TInputImage, typename TOperatorValueType, typename TOutputValueType > +template void -StrainImageFilter< TInputImage, TOperatorValueType, TOutputValueType > -::BeforeThreadedGenerateData() +StrainImageFilter::BeforeThreadedGenerateData() { typename InputImageType::ConstPointer input = this->GetInput(); - if( this->m_VectorGradientFilter.GetPointer() != nullptr ) + if (this->m_VectorGradientFilter.GetPointer() != nullptr) + { + this->m_VectorGradientFilter->SetInput(input); + for (unsigned int i = 1; i < ImageDimension + 1; ++i) { - this->m_VectorGradientFilter->SetInput( input ); - for( unsigned int i = 1; i < ImageDimension + 1; ++i ) - { - this->m_VectorGradientFilter->GraftNthOutput( i - 1, dynamic_cast< GradientOutputImageType* >( - this->ProcessObject::GetOutput( i ) ) ); - } + this->m_VectorGradientFilter->GraftNthOutput( + i - 1, dynamic_cast(this->ProcessObject::GetOutput(i))); + } this->m_VectorGradientFilter->Update(); - for( unsigned int i = 1; i < ImageDimension + 1; ++i ) - { - this->GraftNthOutput( i, this->m_VectorGradientFilter->GetOutput( i - 1 ) ); - } + for (unsigned int i = 1; i < ImageDimension + 1; ++i) + { + this->GraftNthOutput(i, this->m_VectorGradientFilter->GetOutput(i - 1)); } + } else - { - this->m_InputComponentsFilter->SetInput( input ); + { + this->m_InputComponentsFilter->SetInput(input); - for( unsigned int i = 1; i < ImageDimension + 1; ++i ) - { - this->m_GradientFilter->SetInput( - this->m_InputComponentsFilter->GetOutput( i - 1 ) ); - this->m_GradientFilter->GraftOutput( dynamic_cast< GradientOutputImageType* >( - this->ProcessObject::GetOutput( i ) ) ); + for (unsigned int i = 1; i < ImageDimension + 1; ++i) + { + this->m_GradientFilter->SetInput(this->m_InputComponentsFilter->GetOutput(i - 1)); + this->m_GradientFilter->GraftOutput(dynamic_cast(this->ProcessObject::GetOutput(i))); this->m_GradientFilter->Update(); - this->GraftNthOutput( i, this->m_GradientFilter->GetOutput() ); - } + this->GraftNthOutput(i, this->m_GradientFilter->GetOutput()); } + } const StrainFormType strainForm = this->GetStrainForm(); - if( strainForm != INFINITESIMAL && strainForm != GREENLAGRANGIAN && strainForm != EULERIANALMANSI ) - { - itkExceptionMacro( "Invalid StrainForm!" ); - } + if (strainForm != INFINITESIMAL && strainForm != GREENLAGRANGIAN && strainForm != EULERIANALMANSI) + { + itkExceptionMacro("Invalid StrainForm!"); + } OutputImageType * output = this->GetOutput(); - output->FillBuffer( NumericTraits< OutputPixelType >::ZeroValue() ); + output->FillBuffer(NumericTraits::ZeroValue()); } -template< typename TInputImage, typename TOperatorValueType, typename TOutputValueType > +template void -StrainImageFilter< TInputImage, TOperatorValueType, TOutputValueType > -::DynamicThreadedGenerateData( const OutputRegionType& region ) +StrainImageFilter::DynamicThreadedGenerateData( + const OutputRegionType & region) { typename InputImageType::ConstPointer input = this->GetInput(); OutputImageType * output = this->GetOutput(); - ImageRegionIterator< OutputImageType > outputIt( output, region ); + ImageRegionIterator outputIt(output, region); // e_ij += 1/2( du_i/dx_j + du_j/dx_i ) - for( unsigned int i = 0; i < ImageDimension; ++i ) + for (unsigned int i = 0; i < ImageDimension; ++i) + { + ImageRegionConstIterator gradientIt( + reinterpret_cast( + dynamic_cast(this->ProcessObject::GetOutput(i + 1))), + region); + for (outputIt.GoToBegin(), gradientIt.GoToBegin(); !gradientIt.IsAtEnd(); ++outputIt, ++gradientIt) { - ImageRegionConstIterator< GradientOutputImageType > - gradientIt( reinterpret_cast< GradientOutputImageType* >( - dynamic_cast< GradientOutputImageType* >( - this->ProcessObject::GetOutput( i + 1 ) ) ) - , region ); - for( outputIt.GoToBegin(), gradientIt.GoToBegin(); - !gradientIt.IsAtEnd(); - ++outputIt, ++gradientIt ) - { typename OutputImageType::PixelType outputPixel = outputIt.Get(); - const GradientOutputPixelType gradientPixel = gradientIt.Get(); - for( unsigned int j = 0; j < i; ++j ) - { - outputPixel( i, j ) += gradientPixel[j] / static_cast< TOutputValueType >( 2 ); - } + const GradientOutputPixelType gradientPixel = gradientIt.Get(); + for (unsigned int j = 0; j < i; ++j) + { + outputPixel(i, j) += gradientPixel[j] / static_cast(2); + } // j == i - outputPixel( i, i ) += gradientPixel[i]; - for( unsigned int j = i + 1; j < ImageDimension; ++j ) - { - outputPixel( i, j ) += gradientPixel[j] / static_cast< TOutputValueType >( 2 ); - } - outputIt.Set( outputPixel ); + outputPixel(i, i) += gradientPixel[i]; + for (unsigned int j = i + 1; j < ImageDimension; ++j) + { + outputPixel(i, j) += gradientPixel[j] / static_cast(2); } + outputIt.Set(outputPixel); } - switch( m_StrainForm ) - { - case INFINITESIMAL: + } + switch (m_StrainForm) + { + case INFINITESIMAL: break; - // e_ij += 1/2 du_m/du_i du_m/du_j - case GREENLAGRANGIAN: - for( unsigned int i = 0; i < ImageDimension; ++i ) + // e_ij += 1/2 du_m/du_i du_m/du_j + case GREENLAGRANGIAN: + for (unsigned int i = 0; i < ImageDimension; ++i) { - ImageRegionConstIterator< GradientOutputImageType > - gradientIt( reinterpret_cast< GradientOutputImageType* >( - dynamic_cast< GradientOutputImageType* >( - this->ProcessObject::GetOutput( i + 1 ) ) ), region ); - for( outputIt.GoToBegin(), gradientIt.GoToBegin(); - !gradientIt.IsAtEnd(); - ++outputIt, ++gradientIt ) + ImageRegionConstIterator gradientIt( + reinterpret_cast( + dynamic_cast(this->ProcessObject::GetOutput(i + 1))), + region); + for (outputIt.GoToBegin(), gradientIt.GoToBegin(); !gradientIt.IsAtEnd(); ++outputIt, ++gradientIt) { - typename OutputImageType::PixelType outputPixel = outputIt.Get(); - const GradientOutputPixelType gradientPixel = gradientIt.Get(); - for( unsigned int j = 0; j < ImageDimension; ++j ) + typename OutputImageType::PixelType outputPixel = outputIt.Get(); + const GradientOutputPixelType gradientPixel = gradientIt.Get(); + for (unsigned int j = 0; j < ImageDimension; ++j) { - for( unsigned int k = 0; k <= j; ++k ) + for (unsigned int k = 0; k <= j; ++k) { - outputPixel( j, k ) += gradientPixel[j] * gradientPixel[k] / static_cast< TOutputValueType >( 2 ); + outputPixel(j, k) += gradientPixel[j] * gradientPixel[k] / static_cast(2); } } - outputIt.Set( outputPixel ); + outputIt.Set(outputPixel); } } break; - // e_ij -= 1/2 du_m/du_i du_m/du_j - case EULERIANALMANSI: - for( unsigned int i = 0; i < ImageDimension; ++i ) + // e_ij -= 1/2 du_m/du_i du_m/du_j + case EULERIANALMANSI: + for (unsigned int i = 0; i < ImageDimension; ++i) { - ImageRegionConstIterator< GradientOutputImageType > - gradientIt( reinterpret_cast< GradientOutputImageType* >( - dynamic_cast< GradientOutputImageType* >( - this->ProcessObject::GetOutput( i + 1 ) ) ) - , region ); - for( outputIt.GoToBegin(), gradientIt.GoToBegin(); - !gradientIt.IsAtEnd(); - ++outputIt, ++gradientIt ) + ImageRegionConstIterator gradientIt( + reinterpret_cast( + dynamic_cast(this->ProcessObject::GetOutput(i + 1))), + region); + for (outputIt.GoToBegin(), gradientIt.GoToBegin(); !gradientIt.IsAtEnd(); ++outputIt, ++gradientIt) { - typename OutputImageType::PixelType outputPixel = outputIt.Get(); - const GradientOutputPixelType gradientPixel = gradientIt.Get(); - for( unsigned int j = 0; j < ImageDimension; ++j ) + typename OutputImageType::PixelType outputPixel = outputIt.Get(); + const GradientOutputPixelType gradientPixel = gradientIt.Get(); + for (unsigned int j = 0; j < ImageDimension; ++j) { - for( unsigned int k = 0; k <= j; ++k ) + for (unsigned int k = 0; k <= j; ++k) { - outputPixel( j, k ) -= gradientPixel[j] * gradientPixel[k] / static_cast< TOutputValueType >( 2 ); + outputPixel(j, k) -= gradientPixel[j] * gradientPixel[k] / static_cast(2); } } - outputIt.Set( outputPixel ); + outputIt.Set(outputPixel); } } break; - default: - itkExceptionMacro( << "Unknown strain form." ); - } + default: + itkExceptionMacro(<< "Unknown strain form."); + } } -template< typename TInputImage, typename TOperatorValueType, typename TOutputValueType > +template void -StrainImageFilter< TInputImage, TOperatorValueType, TOutputValueType > -::PrintSelf( std::ostream & os, Indent indent ) const +StrainImageFilter::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); - itkPrintSelfObjectMacro( InputComponentsFilter ); + itkPrintSelfObjectMacro(InputComponentsFilter); - itkPrintSelfObjectMacro( GradientFilter ); + itkPrintSelfObjectMacro(GradientFilter); - itkPrintSelfObjectMacro( VectorGradientFilter ); + itkPrintSelfObjectMacro(VectorGradientFilter); - os << indent << "StrainForm: " - << static_cast< typename NumericTraits< StrainFormType >::PrintType >( m_StrainForm ) - << std::endl; + os << indent << "StrainForm: " << static_cast::PrintType>(m_StrainForm) + << std::endl; } } // end namespace itk diff --git a/include/itkTransformToStrainFilter.h b/include/itkTransformToStrainFilter.h index 7e979f0..9e304ef 100644 --- a/include/itkTransformToStrainFilter.h +++ b/include/itkTransformToStrainFilter.h @@ -50,10 +50,10 @@ namespace itk * \ingroup Strain * */ -template< typename TTransform, typename TOperatorValueType=float, typename TOutputValueType=float > -class TransformToStrainFilter : public - GenerateImageSource< Image< SymmetricSecondRankTensor< TOutputValueType, TTransform::InputSpaceDimension >, - TTransform::InputSpaceDimension > > +template +class TransformToStrainFilter + : public GenerateImageSource, + TTransform::InputSpaceDimension>> { public: ITK_DISALLOW_COPY_AND_ASSIGN(TransformToStrainFilter); @@ -62,22 +62,22 @@ class TransformToStrainFilter : public static constexpr unsigned int ImageDimension = TTransform::InputSpaceDimension; using TransformType = TTransform; - using TransformInputType = DataObjectDecorator< TransformType >; - using OutputPixelType = SymmetricSecondRankTensor< TOutputValueType, ImageDimension >; - using OutputImageType = Image< OutputPixelType, ImageDimension >; + using TransformInputType = DataObjectDecorator; + using OutputPixelType = SymmetricSecondRankTensor; + using OutputImageType = Image; /** Standard class type alias. */ using Self = TransformToStrainFilter; - using Superclass = GenerateImageSource< OutputImageType >; + using Superclass = GenerateImageSource; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; /** Method for creation through the object factory. */ - itkNewMacro( Self ); + itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro( TransformToStrainFilter, GenerateImageSource ); + itkTypeMacro(TransformToStrainFilter, GenerateImageSource); /** Get/Set the coordinate transformation. * Set the coordinate transform to use for resampling. Note that this must @@ -89,20 +89,28 @@ class TransformToStrainFilter : public * engineering strain, which is appropriate for small strains, Green-Lagrangian, * which uses a material reference system, and Eulerian-Almansi, which uses a * spatial reference system. This is set with SetStrainForm(). */ - enum StrainFormType {INFINITESIMAL = 0, GREENLAGRANGIAN = 1, EULERIANALMANSI = 2}; + enum StrainFormType + { + INFINITESIMAL = 0, + GREENLAGRANGIAN = 1, + EULERIANALMANSI = 2 + }; - itkSetMacro( StrainForm, StrainFormType ); - itkGetConstMacro( StrainForm, StrainFormType ); + itkSetMacro(StrainForm, StrainFormType); + itkGetConstMacro(StrainForm, StrainFormType); protected: using OutputRegionType = typename OutputImageType::RegionType; TransformToStrainFilter(); - void BeforeThreadedGenerateData() override; - void DynamicThreadedGenerateData( const OutputRegionType& outputRegion ) override; + void + BeforeThreadedGenerateData() override; + void + DynamicThreadedGenerateData(const OutputRegionType & outputRegion) override; - void PrintSelf ( std::ostream& os, Indent indent ) const override; + void + PrintSelf(std::ostream & os, Indent indent) const override; private: StrainFormType m_StrainForm; @@ -111,7 +119,7 @@ class TransformToStrainFilter : public } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkTransformToStrainFilter.hxx" +# include "itkTransformToStrainFilter.hxx" #endif #endif diff --git a/include/itkTransformToStrainFilter.hxx b/include/itkTransformToStrainFilter.hxx index 738fca2..d917c60 100644 --- a/include/itkTransformToStrainFilter.hxx +++ b/include/itkTransformToStrainFilter.hxx @@ -24,143 +24,135 @@ namespace itk { -template < typename TTransform, typename TOperatorValue, - typename TOutputValue > -TransformToStrainFilter< TTransform, TOperatorValue, TOutputValue > -::TransformToStrainFilter(): - m_StrainForm( INFINITESIMAL ) +template +TransformToStrainFilter::TransformToStrainFilter() + : m_StrainForm(INFINITESIMAL) { this->DynamicMultiThreadingOn(); } -template < typename TTransform, typename TOperatorValue, - typename TOutputValue > +template void -TransformToStrainFilter< TTransform, TOperatorValue, TOutputValue > -::BeforeThreadedGenerateData() +TransformToStrainFilter::BeforeThreadedGenerateData() { OutputImageType * output = this->GetOutput(); - output->FillBuffer( NumericTraits< OutputPixelType >::ZeroValue() ); + output->FillBuffer(NumericTraits::ZeroValue()); const TransformType * input = this->GetTransform(); - if( input == nullptr ) - { - itkExceptionMacro( "Input transform not available!" ); - } + if (input == nullptr) + { + itkExceptionMacro("Input transform not available!"); + } const StrainFormType strainForm = this->GetStrainForm(); - if( strainForm != INFINITESIMAL && strainForm != GREENLAGRANGIAN && strainForm != EULERIANALMANSI ) - { - itkExceptionMacro( "Invalid StrainForm!" ); - } + if (strainForm != INFINITESIMAL && strainForm != GREENLAGRANGIAN && strainForm != EULERIANALMANSI) + { + itkExceptionMacro("Invalid StrainForm!"); + } } -template < typename TTransform, typename TOperatorValue, - typename TOutputValue > +template void -TransformToStrainFilter< TTransform, TOperatorValue, TOutputValue > -::DynamicThreadedGenerateData( const OutputRegionType& region ) +TransformToStrainFilter::DynamicThreadedGenerateData( + const OutputRegionType & region) { const TransformType * input = this->GetTransform(); OutputImageType * output = this->GetOutput(); - using ImageIteratorType = ImageRegionIteratorWithIndex< OutputImageType >; - ImageIteratorType outputIt( output, region ); + using ImageIteratorType = ImageRegionIteratorWithIndex; + ImageIteratorType outputIt(output, region); typename TransformType::JacobianPositionType identity; identity.set_identity(); // e_ij += 1/2( du_i/dx_j + du_j/dx_i ) - for( outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt ) - { + for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt) + { const typename OutputImageType::IndexType index = outputIt.GetIndex(); - typename OutputImageType::PointType point; - output->TransformIndexToPhysicalPoint( index, point ); + typename OutputImageType::PointType point; + output->TransformIndexToPhysicalPoint(index, point); typename TransformType::JacobianPositionType jacobian; - input->ComputeJacobianWithRespectToPosition( point, jacobian ); + input->ComputeJacobianWithRespectToPosition(point, jacobian); typename OutputImageType::PixelType outputPixel = outputIt.Get(); - for( unsigned int i = 0; i < ImageDimension; ++i ) + for (unsigned int i = 0; i < ImageDimension; ++i) + { + for (unsigned int j = 0; j < i; ++j) { - for( unsigned int j = 0; j < i; ++j ) - { - outputPixel( i, j ) += jacobian( i, j ) / static_cast< TOutputValue >( 2 ); - } - for( unsigned int j = i + 1; j < ImageDimension; ++j ) - { - outputPixel( i, j ) += jacobian( i, j ) / static_cast< TOutputValue >( 2 ); - } - outputPixel( i, i ) = jacobian( i, i ) - static_cast< TOutputValue >( 1 ); + outputPixel(i, j) += jacobian(i, j) / static_cast(2); } - outputIt.Set( outputPixel ); + for (unsigned int j = i + 1; j < ImageDimension; ++j) + { + outputPixel(i, j) += jacobian(i, j) / static_cast(2); + } + outputPixel(i, i) = jacobian(i, i) - static_cast(1); } - switch( m_StrainForm ) - { - case INFINITESIMAL: + outputIt.Set(outputPixel); + } + switch (m_StrainForm) + { + case INFINITESIMAL: break; - // e_ij += 1/2 du_m/du_i du_m/du_j - case GREENLAGRANGIAN: - for( outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt ) + // e_ij += 1/2 du_m/du_i du_m/du_j + case GREENLAGRANGIAN: + for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt) { - const typename OutputImageType::IndexType index = outputIt.GetIndex(); - typename OutputImageType::PointType point; - output->TransformIndexToPhysicalPoint( index, point ); - typename TransformType::JacobianPositionType jacobian; - input->ComputeJacobianWithRespectToPosition( point, jacobian ); - jacobian -= identity; - typename OutputImageType::PixelType outputPixel = outputIt.Get(); - for( unsigned int i = 0; i < ImageDimension; ++i ) + const typename OutputImageType::IndexType index = outputIt.GetIndex(); + typename OutputImageType::PointType point; + output->TransformIndexToPhysicalPoint(index, point); + typename TransformType::JacobianPositionType jacobian; + input->ComputeJacobianWithRespectToPosition(point, jacobian); + jacobian -= identity; + typename OutputImageType::PixelType outputPixel = outputIt.Get(); + for (unsigned int i = 0; i < ImageDimension; ++i) { - for( unsigned int j = 0; j < ImageDimension; ++j ) + for (unsigned int j = 0; j < ImageDimension; ++j) { - for( unsigned int k = 0; k <= j; ++k ) + for (unsigned int k = 0; k <= j; ++k) { - outputPixel( j, k ) += jacobian( i, j ) * jacobian( i, k ) / static_cast< TOutputValue >( 2 ); + outputPixel(j, k) += jacobian(i, j) * jacobian(i, k) / static_cast(2); } } } - outputIt.Set( outputPixel ); + outputIt.Set(outputPixel); } break; - // e_ij -= 1/2 du_m/du_i du_m/du_j - case EULERIANALMANSI: - for( outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt ) + // e_ij -= 1/2 du_m/du_i du_m/du_j + case EULERIANALMANSI: + for (outputIt.GoToBegin(); !outputIt.IsAtEnd(); ++outputIt) { - const typename OutputImageType::IndexType index = outputIt.GetIndex(); - typename OutputImageType::PointType point; - output->TransformIndexToPhysicalPoint( index, point ); - typename TransformType::JacobianPositionType jacobian; - input->ComputeJacobianWithRespectToPosition( point, jacobian ); - jacobian -= identity; - typename OutputImageType::PixelType outputPixel = outputIt.Get(); - for( unsigned int i = 0; i < ImageDimension; ++i ) + const typename OutputImageType::IndexType index = outputIt.GetIndex(); + typename OutputImageType::PointType point; + output->TransformIndexToPhysicalPoint(index, point); + typename TransformType::JacobianPositionType jacobian; + input->ComputeJacobianWithRespectToPosition(point, jacobian); + jacobian -= identity; + typename OutputImageType::PixelType outputPixel = outputIt.Get(); + for (unsigned int i = 0; i < ImageDimension; ++i) { - for( unsigned int j = 0; j < ImageDimension; ++j ) + for (unsigned int j = 0; j < ImageDimension; ++j) { - for( unsigned int k = 0; k <= j; ++k ) + for (unsigned int k = 0; k <= j; ++k) { - outputPixel( j, k ) -= jacobian( i, j ) * jacobian( i, k ) / static_cast< TOutputValue >( 2 ); + outputPixel(j, k) -= jacobian(i, j) * jacobian(i, k) / static_cast(2); } } } - outputIt.Set( outputPixel ); + outputIt.Set(outputPixel); } break; - default: - itkExceptionMacro( << "Unknown strain form." ); - } + default: + itkExceptionMacro(<< "Unknown strain form."); + } } -template < typename TTransform, typename TOperatorValue, - typename TOutputValue > +template void -TransformToStrainFilter< TTransform, TOperatorValue, TOutputValue > -::PrintSelf( std::ostream & os, Indent indent ) const +TransformToStrainFilter::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); - os << indent << "StrainForm: " - << static_cast< typename NumericTraits< StrainFormType >::PrintType >( m_StrainForm ) - << std::endl; + os << indent << "StrainForm: " << static_cast::PrintType>(m_StrainForm) + << std::endl; } } // end namespace itk diff --git a/test/ReadInDisplacements.h b/test/ReadInDisplacements.h index ff10ddd..ab7f78f 100644 --- a/test/ReadInDisplacements.h +++ b/test/ReadInDisplacements.h @@ -21,25 +21,26 @@ #include "itkImageFileReader.h" -template< typename TDisplacementImageType > -int ReadInDisplacements( const char * inputFile, typename TDisplacementImageType::Pointer & inputImage ) +template +int +ReadInDisplacements(const char * inputFile, typename TDisplacementImageType::Pointer & inputImage) { using InputImageType = TDisplacementImageType; - using ReaderType = itk::ImageFileReader< InputImageType >; + using ReaderType = itk::ImageFileReader; typename ReaderType::Pointer reader = ReaderType::New(); - reader->SetFileName( inputFile ); + reader->SetFileName(inputFile); try - { + { reader->Update(); - } - catch (itk::ExceptionObject& ex) - { + } + catch (itk::ExceptionObject & ex) + { std::cerr << "Exception caught!" << std::endl; std::cerr << ex << std::endl; return EXIT_FAILURE; - } + } inputImage = reader->GetOutput(); diff --git a/test/WriteOutStrains.h b/test/WriteOutStrains.h index ee324c1..9babb70 100644 --- a/test/WriteOutStrains.h +++ b/test/WriteOutStrains.h @@ -25,67 +25,63 @@ #include "itkNthElementImageAdaptor.h" #include "itkVTKImageIO.h" -template< typename TPixel, unsigned int Dimension, typename TTensorImage > -int WriteOutStrains( const char * outputPrefix, TTensorImage * strainImage ) +template +int +WriteOutStrains(const char * outputPrefix, TTensorImage * strainImage) { using PixelType = TPixel; using TensorImageType = TTensorImage; - using ComponentImageType = itk::Image< PixelType, Dimension >; + using ComponentImageType = itk::Image; - using TensorWriterType = itk::ImageFileWriter< TensorImageType >; - using TensorComponentWriterType = itk::ImageFileWriter< ComponentImageType >; - using AdaptorType = itk::NthElementImageAdaptor< TensorImageType, PixelType >; + using TensorWriterType = itk::ImageFileWriter; + using TensorComponentWriterType = itk::ImageFileWriter; + using AdaptorType = itk::NthElementImageAdaptor; using IOType = itk::VTKImageIO; - typename TensorWriterType::Pointer tensorWriter = TensorWriterType::New(); + typename TensorWriterType::Pointer tensorWriter = TensorWriterType::New(); typename TensorComponentWriterType::Pointer tensorComponentWriter = TensorComponentWriterType::New(); - typename ComponentImageType::Pointer outImage = ComponentImageType::New(); - typename AdaptorType::Pointer adaptor = AdaptorType::New(); - IOType::Pointer io = IOType::New(); + typename ComponentImageType::Pointer outImage = ComponentImageType::New(); + typename AdaptorType::Pointer adaptor = AdaptorType::New(); + IOType::Pointer io = IOType::New(); - tensorWriter->SetFileName( std::string( outputPrefix ) + "Output.vtk" ); - tensorWriter->SetInput( strainImage ); + tensorWriter->SetFileName(std::string(outputPrefix) + "Output.vtk"); + tensorWriter->SetInput(strainImage); io->SetFileTypeToBinary(); - tensorWriter->SetImageIO( io ); + tensorWriter->SetImageIO(io); - outImage->SetRegions( strainImage->GetLargestPossibleRegion() ); + outImage->SetRegions(strainImage->GetLargestPossibleRegion()); outImage->Allocate(); - tensorComponentWriter->SetInput( outImage ); - adaptor->SetImage( strainImage ); + tensorComponentWriter->SetInput(outImage); + adaptor->SetImage(strainImage); std::ostringstream ostr; try - { + { tensorWriter->Update(); - for( unsigned int i = 0; i < 3; ++i ) - { - ostr.str( "" ); + for (unsigned int i = 0; i < 3; ++i) + { + ostr.str(""); ostr << outputPrefix << "Component" << i << ".mha"; - adaptor->SelectNthElement( i ); + adaptor->SelectNthElement(i); adaptor->Update(); - itk::ImageRegionConstIterator< AdaptorType > adaptorIt( adaptor, - adaptor->GetBufferedRegion() ); - itk::ImageRegionIterator< ComponentImageType > outputIt( outImage, - outImage->GetLargestPossibleRegion() ); - for( adaptorIt.GoToBegin(), outputIt.GoToBegin(); - !adaptorIt.IsAtEnd(); - ++adaptorIt, ++outputIt ) - { - outputIt.Set( adaptorIt.Get() ); - } - tensorComponentWriter->SetFileName( ostr.str() ); - tensorComponentWriter->Update(); + itk::ImageRegionConstIterator adaptorIt(adaptor, adaptor->GetBufferedRegion()); + itk::ImageRegionIterator outputIt(outImage, outImage->GetLargestPossibleRegion()); + for (adaptorIt.GoToBegin(), outputIt.GoToBegin(); !adaptorIt.IsAtEnd(); ++adaptorIt, ++outputIt) + { + outputIt.Set(adaptorIt.Get()); } + tensorComponentWriter->SetFileName(ostr.str()); + tensorComponentWriter->Update(); } - catch (itk::ExceptionObject& ex) - { + } + catch (itk::ExceptionObject & ex) + { std::cerr << "Exception caught!" << std::endl; std::cerr << ex << std::endl; return EXIT_FAILURE; - } + } return EXIT_SUCCESS; - } #endif diff --git a/test/itkStrainImageFilterDoGTest.cxx b/test/itkStrainImageFilterDoGTest.cxx index ecd14f2..094b8e5 100644 --- a/test/itkStrainImageFilterDoGTest.cxx +++ b/test/itkStrainImageFilterDoGTest.cxx @@ -23,16 +23,17 @@ #include "ReadInDisplacements.h" #include "WriteOutStrains.h" -int itkStrainImageFilterDoGTest( int argc, char* argv[] ) +int +itkStrainImageFilterDoGTest(int argc, char * argv[]) { - if( argc < 3 ) - { + if (argc < 3) + { std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << argv[0]; std::cerr << " inputDisplacementImage outputPrefix "; std::cerr << std::endl; return EXIT_FAILURE; - } + } const char * inputDisplacementImageFileName = argv[1]; @@ -40,45 +41,42 @@ int itkStrainImageFilterDoGTest( int argc, char* argv[] ) constexpr unsigned int Dimension = 2; using PixelType = float; - using DisplacementVectorType = itk::Vector< PixelType, Dimension >; - using InputImageType = itk::Image< DisplacementVectorType, Dimension >; + using DisplacementVectorType = itk::Vector; + using InputImageType = itk::Image; - using StrainFilterType = itk::StrainImageFilter< InputImageType, PixelType, PixelType >; + using StrainFilterType = itk::StrainImageFilter; using TensorImageType = StrainFilterType::OutputImageType; StrainFilterType::Pointer strainFilter = StrainFilterType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS( strainFilter, StrainImageFilter, - ImageToImageFilter ); + ITK_EXERCISE_BASIC_OBJECT_METHODS(strainFilter, StrainImageFilter, ImageToImageFilter); - using GradientFilterType = itk::DifferenceOfGaussiansGradientImageFilter< itk::Image< PixelType, Dimension >, PixelType >; + using GradientFilterType = itk::DifferenceOfGaussiansGradientImageFilter, PixelType>; GradientFilterType::Pointer gradientFilter = GradientFilterType::New(); - gradientFilter->SetWidth( 1.0 ); + gradientFilter->SetWidth(1.0); - strainFilter->SetGradientFilter( gradientFilter.GetPointer() ); - ITK_TEST_SET_GET_VALUE( gradientFilter.GetPointer(), - strainFilter->GetGradientFilter() ); + strainFilter->SetGradientFilter(gradientFilter.GetPointer()); + ITK_TEST_SET_GET_VALUE(gradientFilter.GetPointer(), strainFilter->GetGradientFilter()); InputImageType::Pointer inputDisplacements; - if( ReadInDisplacements< InputImageType >( - inputDisplacementImageFileName, inputDisplacements ) == EXIT_FAILURE ) - { + if (ReadInDisplacements(inputDisplacementImageFileName, inputDisplacements) == EXIT_FAILURE) + { std::cerr << "Test failed!" << std::endl; return EXIT_FAILURE; - } + } - strainFilter->SetInput( inputDisplacements ); + strainFilter->SetInput(inputDisplacements); - ITK_TRY_EXPECT_NO_EXCEPTION( strainFilter->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(strainFilter->Update()); - if( WriteOutStrains< PixelType, Dimension, TensorImageType >( - outputFileNamePrefix, strainFilter->GetOutput() ) == EXIT_FAILURE ) - { + if (WriteOutStrains(outputFileNamePrefix, strainFilter->GetOutput()) == + EXIT_FAILURE) + { std::cerr << "Test failed!" << std::endl; return EXIT_FAILURE; - } + } std::cout << "Test finished." << std::endl; diff --git a/test/itkStrainImageFilterRecursiveGaussianTest.cxx b/test/itkStrainImageFilterRecursiveGaussianTest.cxx index a882d10..6c9b34e 100644 --- a/test/itkStrainImageFilterRecursiveGaussianTest.cxx +++ b/test/itkStrainImageFilterRecursiveGaussianTest.cxx @@ -23,16 +23,17 @@ #include "ReadInDisplacements.h" #include "WriteOutStrains.h" -int itkStrainImageFilterRecursiveGaussianTest( int argc, char* argv[] ) +int +itkStrainImageFilterRecursiveGaussianTest(int argc, char * argv[]) { - if( argc < 3 ) - { + if (argc < 3) + { std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << argv[0]; std::cerr << " inputDisplacementImage outputPrefix "; std::cerr << std::endl; return EXIT_FAILURE; - } + } const char * inputDisplacementImageFileName = argv[1]; @@ -40,46 +41,44 @@ int itkStrainImageFilterRecursiveGaussianTest( int argc, char* argv[] ) constexpr unsigned int Dimension = 2; using PixelType = float; - using DisplacementVectorType = itk::Vector< PixelType, Dimension >; - using InputImageType = itk::Image< DisplacementVectorType, Dimension >; + using DisplacementVectorType = itk::Vector; + using InputImageType = itk::Image; - using StrainFilterType = itk::StrainImageFilter< InputImageType, PixelType, PixelType >; + using StrainFilterType = itk::StrainImageFilter; using TensorImageType = StrainFilterType::OutputImageType; using GradientOutputImageType = StrainFilterType::GradientOutputImageType; StrainFilterType::Pointer strainFilter = StrainFilterType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS( strainFilter, StrainImageFilter, - ImageToImageFilter ); + ITK_EXERCISE_BASIC_OBJECT_METHODS(strainFilter, StrainImageFilter, ImageToImageFilter); - using GradientFilterType = itk::GradientRecursiveGaussianImageFilter< itk::Image< PixelType, Dimension >, GradientOutputImageType >; + using GradientFilterType = + itk::GradientRecursiveGaussianImageFilter, GradientOutputImageType>; GradientFilterType::Pointer gradientFilter = GradientFilterType::New(); - gradientFilter->SetSigma( 1.0 ); + gradientFilter->SetSigma(1.0); - strainFilter->SetGradientFilter( gradientFilter.GetPointer() ); - ITK_TEST_SET_GET_VALUE( gradientFilter.GetPointer(), - strainFilter->GetGradientFilter() ); + strainFilter->SetGradientFilter(gradientFilter.GetPointer()); + ITK_TEST_SET_GET_VALUE(gradientFilter.GetPointer(), strainFilter->GetGradientFilter()); InputImageType::Pointer inputDisplacements; - if( ReadInDisplacements< InputImageType >( - inputDisplacementImageFileName, inputDisplacements ) == EXIT_FAILURE ) - { + if (ReadInDisplacements(inputDisplacementImageFileName, inputDisplacements) == EXIT_FAILURE) + { std::cerr << "Test failed!" << std::endl; return EXIT_FAILURE; - } + } - strainFilter->SetInput( inputDisplacements ); + strainFilter->SetInput(inputDisplacements); - ITK_TRY_EXPECT_NO_EXCEPTION( strainFilter->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(strainFilter->Update()); - if( WriteOutStrains< PixelType, Dimension, TensorImageType >( - outputFileNamePrefix, strainFilter->GetOutput() ) == EXIT_FAILURE ) - { + if (WriteOutStrains(outputFileNamePrefix, strainFilter->GetOutput()) == + EXIT_FAILURE) + { std::cerr << "Test failed!" << std::endl; return EXIT_FAILURE; - } + } std::cout << "Test finished." << std::endl; diff --git a/test/itkStrainImageFilterTest.cxx b/test/itkStrainImageFilterTest.cxx index be0fba8..8642e03 100644 --- a/test/itkStrainImageFilterTest.cxx +++ b/test/itkStrainImageFilterTest.cxx @@ -22,16 +22,17 @@ #include "ReadInDisplacements.h" #include "WriteOutStrains.h" -int itkStrainImageFilterTest( int argc, char* argv[] ) +int +itkStrainImageFilterTest(int argc, char * argv[]) { - if( argc < 4 ) - { + if (argc < 4) + { std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << argv[0]; std::cerr << " inputDisplacementImage outputPrefix strainForm"; std::cerr << std::endl; return EXIT_FAILURE; - } + } const char * inputDisplacementImageFileName = argv[1]; @@ -39,73 +40,67 @@ int itkStrainImageFilterTest( int argc, char* argv[] ) constexpr unsigned int Dimension = 2; using PixelType = float; - using DisplacementVectorType = itk::Vector< PixelType, Dimension >; - using InputImageType = itk::Image< DisplacementVectorType, Dimension >; + using DisplacementVectorType = itk::Vector; + using InputImageType = itk::Image; - using StrainFilterType = itk::StrainImageFilter< InputImageType, PixelType, PixelType >; + using StrainFilterType = itk::StrainImageFilter; using TensorImageType = StrainFilterType::OutputImageType; StrainFilterType::Pointer strainFilter = StrainFilterType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS( strainFilter, StrainImageFilter, - ImageToImageFilter ); + ITK_EXERCISE_BASIC_OBJECT_METHODS(strainFilter, StrainImageFilter, ImageToImageFilter); InputImageType::Pointer inputDisplacements; - if( ReadInDisplacements< InputImageType >( - inputDisplacementImageFileName, inputDisplacements ) == EXIT_FAILURE ) - { + if (ReadInDisplacements(inputDisplacementImageFileName, inputDisplacements) == EXIT_FAILURE) + { std::cerr << "Test failed!" << std::endl; return EXIT_FAILURE; - } + } - strainFilter->SetInput( inputDisplacements ); + strainFilter->SetInput(inputDisplacements); // Test the unknown strain form exception int strainForm = -1; - strainFilter->SetStrainForm( - static_cast< StrainFilterType::StrainFormType >( strainForm ) ); + strainFilter->SetStrainForm(static_cast(strainForm)); - ITK_TRY_EXPECT_EXCEPTION( strainFilter->Update() ); + ITK_TRY_EXPECT_EXCEPTION(strainFilter->Update()); // Get the input strain form - if( !strcmp( argv[3], "INFINITESIMAL" ) ) - { + if (!strcmp(argv[3], "INFINITESIMAL")) + { strainForm = 0; - } - else if( !strcmp( argv[3], "GREENLAGRANGIAN" ) ) - { + } + else if (!strcmp(argv[3], "GREENLAGRANGIAN")) + { strainForm = 1; - } - else if( !strcmp( argv[3], "EULERIANALMANSI" ) ) - { + } + else if (!strcmp(argv[3], "EULERIANALMANSI")) + { strainForm = 2; - } + } else - { + { std::cerr << "Test failed!" << std::endl; std::cerr << "Unknown strain form: " << argv[3] << std::endl; return EXIT_FAILURE; - } + } - strainFilter->SetStrainForm( - static_cast< StrainFilterType::StrainFormType >( strainForm ) ); - ITK_TEST_SET_GET_VALUE( - static_cast< StrainFilterType::StrainFormType >( strainForm ), - strainFilter->GetStrainForm() ); + strainFilter->SetStrainForm(static_cast(strainForm)); + ITK_TEST_SET_GET_VALUE(static_cast(strainForm), strainFilter->GetStrainForm()); - ITK_TRY_EXPECT_NO_EXCEPTION( strainFilter->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(strainFilter->Update()); - if( WriteOutStrains< PixelType, Dimension, TensorImageType >( - outputFileNamePrefix, strainFilter->GetOutput() ) == EXIT_FAILURE ) - { + if (WriteOutStrains(outputFileNamePrefix, strainFilter->GetOutput()) == + EXIT_FAILURE) + { std::cerr << "Test failed!" << std::endl; return EXIT_FAILURE; - } + } std::cout << "Test finished." << std::endl; diff --git a/test/itkTransformToStrainFilterTest.cxx b/test/itkTransformToStrainFilterTest.cxx index e7f56f7..f7dbf5e 100644 --- a/test/itkTransformToStrainFilterTest.cxx +++ b/test/itkTransformToStrainFilterTest.cxx @@ -24,21 +24,22 @@ #include "itkStrainImageFilter.h" #include "itkTestingMacros.h" -int itkTransformToStrainFilterTest( int argc, char * argv [] ) +int +itkTransformToStrainFilterTest(int argc, char * argv[]) { // Check command line arguments. - if( argc < 6 ) - { + if (argc < 6) + { std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << argv[0]; std::cerr << "strainForm" - << " transformName" - << " strainFieldFileName" - << " displacementField" - << " displacementFieldStrain" - << " [bSplineParametersFile]" << std::endl; + << " transformName" + << " strainFieldFileName" + << " displacementField" + << " displacementFieldStrain" + << " [bSplineParametersFile]" << std::endl; return EXIT_FAILURE; - } + } // Typedefs. @@ -47,238 +48,228 @@ int itkTransformToStrainFilterTest( int argc, char * argv [] ) using CoordRepresentationType = double; constexpr unsigned int SplineOrder = 3; - using TransformType = itk::Transform< CoordRepresentationType, Dimension, Dimension >; + using TransformType = itk::Transform; using ParametersType = TransformType::ParametersType; - using TransformToStrainFilterType = itk::TransformToStrainFilter< TransformType, ScalarPixelType, ScalarPixelType >; + using TransformToStrainFilterType = itk::TransformToStrainFilter; - TransformToStrainFilterType::Pointer transformToStrainFilter = - TransformToStrainFilterType::New(); + TransformToStrainFilterType::Pointer transformToStrainFilter = TransformToStrainFilterType::New(); - ITK_EXERCISE_BASIC_OBJECT_METHODS( transformToStrainFilter, - TransformToStrainFilter, GenerateImageSource ); + ITK_EXERCISE_BASIC_OBJECT_METHODS(transformToStrainFilter, TransformToStrainFilter, GenerateImageSource); // Test the unknown strain form exception int strainForm = -1; - transformToStrainFilter->SetStrainForm( - static_cast< TransformToStrainFilterType::StrainFormType >( strainForm ) ); + transformToStrainFilter->SetStrainForm(static_cast(strainForm)); - ITK_TRY_EXPECT_EXCEPTION( transformToStrainFilter->Update() ); + ITK_TRY_EXPECT_EXCEPTION(transformToStrainFilter->Update()); // Get the input strain form - if( !strcmp( argv[1], "INFINITESIMAL" ) ) - { + if (!strcmp(argv[1], "INFINITESIMAL")) + { strainForm = 0; - } - else if( !strcmp( argv[1], "GREENLAGRANGIAN" ) ) - { + } + else if (!strcmp(argv[1], "GREENLAGRANGIAN")) + { strainForm = 1; - } - else if( !strcmp( argv[1], "EULERIANALMANSI" ) ) - { + } + else if (!strcmp(argv[1], "EULERIANALMANSI")) + { strainForm = 2; - } + } else - { + { std::cerr << "Test failed!" << std::endl; std::cerr << "Unknown strain form: " << argv[1] << std::endl; return EXIT_FAILURE; - } + } const std::string transformName = argv[2]; const std::string strainFieldFileName = argv[3]; const std::string displacementFieldFileName = argv[4]; const std::string displacementFieldStrainFileName = argv[5]; - std::string bSplineParametersFile; - if( argc > 6 ) - { + std::string bSplineParametersFile; + if (argc > 6) + { bSplineParametersFile = argv[6]; - } + } - transformToStrainFilter->SetStrainForm( - static_cast< TransformToStrainFilterType::StrainFormType >( strainForm ) ); - ITK_TEST_SET_GET_VALUE( - static_cast< TransformToStrainFilterType::StrainFormType >( strainForm ), - transformToStrainFilter->GetStrainForm() ); + transformToStrainFilter->SetStrainForm(static_cast(strainForm)); + ITK_TEST_SET_GET_VALUE(static_cast(strainForm), + transformToStrainFilter->GetStrainForm()); // Create output information. using SizeType = TransformToStrainFilterType::SizeType; SizeType size; - size.Fill( 20 ); + size.Fill(20); using SpacingType = TransformToStrainFilterType::SpacingType; SpacingType spacing; - spacing.Fill( 0.7 ); + spacing.Fill(0.7); using OriginType = TransformToStrainFilterType::PointType; OriginType origin; - origin.Fill( -10.0 ); + origin.Fill(-10.0); // Create the equivalent strain field by first converting the transform to a // displacement field, then computing the strain from that displacement // field. - using DisplacementVectorType = itk::Vector< ScalarPixelType, Dimension >; - using DisplacementFieldType = itk::Image< DisplacementVectorType, Dimension >; + using DisplacementVectorType = itk::Vector; + using DisplacementFieldType = itk::Image; - using TransformToDisplacementFilterType = itk::TransformToDisplacementFieldFilter< DisplacementFieldType, CoordRepresentationType >; - TransformToDisplacementFilterType::Pointer transformToDisplacement = - TransformToDisplacementFilterType::New(); + using TransformToDisplacementFilterType = + itk::TransformToDisplacementFieldFilter; + TransformToDisplacementFilterType::Pointer transformToDisplacement = TransformToDisplacementFilterType::New(); // Create transforms. - using AffineTransformType = itk::AffineTransform< CoordRepresentationType, Dimension >; + using AffineTransformType = itk::AffineTransform; AffineTransformType::Pointer affineTransform = AffineTransformType::New(); - using BSplineTransformType = itk::BSplineTransform< CoordRepresentationType, Dimension, SplineOrder >; + using BSplineTransformType = itk::BSplineTransform; BSplineTransformType::Pointer bSplineTransform = BSplineTransformType::New(); - using SimilarityTransformType = itk::Similarity2DTransform< CoordRepresentationType >; - SimilarityTransformType::Pointer similarityTransform = - SimilarityTransformType::New(); + using SimilarityTransformType = itk::Similarity2DTransform; + SimilarityTransformType::Pointer similarityTransform = SimilarityTransformType::New(); - if( transformName == "Similarity" ) - { - transformToStrainFilter->SetTransform( similarityTransform.GetPointer() ); - ITK_TEST_SET_GET_VALUE( similarityTransform.GetPointer(), - transformToStrainFilter->GetTransform() ); + if (transformName == "Similarity") + { + transformToStrainFilter->SetTransform(similarityTransform.GetPointer()); + ITK_TEST_SET_GET_VALUE(similarityTransform.GetPointer(), transformToStrainFilter->GetTransform()); - transformToDisplacement->SetTransform( similarityTransform.GetPointer() ); + transformToDisplacement->SetTransform(similarityTransform.GetPointer()); SimilarityTransformType::OffsetType translation; translation[0] = -3.0; translation[1] = -4.0; - similarityTransform->Translate( translation ); + similarityTransform->Translate(translation); - similarityTransform->SetAngle( 0.2 ); - similarityTransform->SetScale( 1.025 ); - } - else if( transformName == "Affine" ) - { - transformToStrainFilter->SetTransform( affineTransform.GetPointer() ); - ITK_TEST_SET_GET_VALUE( affineTransform.GetPointer(), - transformToStrainFilter->GetTransform() ); + similarityTransform->SetAngle(0.2); + similarityTransform->SetScale(1.025); + } + else if (transformName == "Affine") + { + transformToStrainFilter->SetTransform(affineTransform.GetPointer()); + ITK_TEST_SET_GET_VALUE(affineTransform.GetPointer(), transformToStrainFilter->GetTransform()); - transformToDisplacement->SetTransform( affineTransform.GetPointer() ); + transformToDisplacement->SetTransform(affineTransform.GetPointer()); // Set the options. OriginType centerOfRotation; centerOfRotation[0] = -3.0; centerOfRotation[1] = -3.0; - affineTransform->SetCenter( centerOfRotation ); + affineTransform->SetCenter(centerOfRotation); // Create and set parameters. - ParametersType parameters( affineTransform->GetNumberOfParameters() ); - //parameters[ 0 ] = 1.1; - //parameters[ 1 ] = 0.1; - //parameters[ 2 ] = -0.2; - //parameters[ 3 ] = 0.9; - //parameters[ 4 ] = 10.3; - //parameters[ 5 ] = -33.8; + ParametersType parameters(affineTransform->GetNumberOfParameters()); + // parameters[ 0 ] = 1.1; + // parameters[ 1 ] = 0.1; + // parameters[ 2 ] = -0.2; + // parameters[ 3 ] = 0.9; + // parameters[ 4 ] = 10.3; + // parameters[ 5 ] = -33.8; parameters[0] = 1.1; parameters[1] = 0.3; parameters[2] = 0.3; parameters[3] = 1.2; parameters[4] = 0.0; parameters[5] = 0.0; - affineTransform->SetParameters( parameters ); - } - else if( transformName == "BSpline" ) - { - transformToStrainFilter->SetTransform( bSplineTransform ); - ITK_TEST_SET_GET_VALUE( bSplineTransform, transformToStrainFilter->GetTransform() ); + affineTransform->SetParameters(parameters); + } + else if (transformName == "BSpline") + { + transformToStrainFilter->SetTransform(bSplineTransform); + ITK_TEST_SET_GET_VALUE(bSplineTransform, transformToStrainFilter->GetTransform()); - transformToDisplacement->SetTransform( bSplineTransform ); + transformToDisplacement->SetTransform(bSplineTransform); // Set the options. BSplineTransformType::PhysicalDimensionsType dimensions; - for( unsigned int dd = 0; dd < Dimension; ++dd ) - { - dimensions[dd] = spacing[dd] * ( size[dd] - 1.0 ); - } - BSplineTransformType::MeshSizeType meshSize; + for (unsigned int dd = 0; dd < Dimension; ++dd) + { + dimensions[dd] = spacing[dd] * (size[dd] - 1.0); + } + BSplineTransformType::MeshSizeType meshSize; BSplineTransformType::DirectionType direction; direction.SetIdentity(); meshSize[0] = 7 - SplineOrder; meshSize[1] = 10 - SplineOrder; - bSplineTransform->SetTransformDomainOrigin( origin ); - bSplineTransform->SetTransformDomainPhysicalDimensions( dimensions ); - bSplineTransform->SetTransformDomainMeshSize( meshSize ); - bSplineTransform->SetTransformDomainDirection( direction ); + bSplineTransform->SetTransformDomainOrigin(origin); + bSplineTransform->SetTransformDomainPhysicalDimensions(dimensions); + bSplineTransform->SetTransformDomainMeshSize(meshSize); + bSplineTransform->SetTransformDomainDirection(direction); // Create and set parameters. - ParametersType parameters( bSplineTransform->GetNumberOfParameters() ); - std::ifstream input( bSplineParametersFile.c_str() ); - if ( input.is_open() ) + ParametersType parameters(bSplineTransform->GetNumberOfParameters()); + std::ifstream input(bSplineParametersFile.c_str()); + if (input.is_open()) + { + for (unsigned int i = 0; i < parameters.GetSize(); ++i) { - for ( unsigned int i = 0; i < parameters.GetSize(); ++i ) - { - input >> parameters[ i ]; - } - input.close(); + input >> parameters[i]; } + input.close(); + } else - { + { std::cerr << "Test failed!" << std::endl; std::cerr << "Error: B-Spline parameter file not found." << std::endl; return EXIT_FAILURE; - } - bSplineTransform->SetParametersByValue( parameters ); } + bSplineTransform->SetParametersByValue(parameters); + } else - { + { std::cerr << "Test failed!" << std::endl; - std::cerr << "Error: Not a valid transform name: " << transformName - << std::endl; + std::cerr << "Error: Not a valid transform name: " << transformName << std::endl; return EXIT_FAILURE; - } + } // Create and setup strain field generator. - transformToStrainFilter->SetSize( size ); - ITK_TEST_SET_GET_VALUE( size, transformToStrainFilter->GetSize() ); + transformToStrainFilter->SetSize(size); + ITK_TEST_SET_GET_VALUE(size, transformToStrainFilter->GetSize()); - transformToStrainFilter->SetSpacing( spacing ); - ITK_TEST_SET_GET_VALUE( spacing, transformToStrainFilter->GetSpacing() ); + transformToStrainFilter->SetSpacing(spacing); + ITK_TEST_SET_GET_VALUE(spacing, transformToStrainFilter->GetSpacing()); - transformToStrainFilter->SetOrigin( origin ); - ITK_TEST_SET_GET_VALUE( origin, transformToStrainFilter->GetOrigin() ); + transformToStrainFilter->SetOrigin(origin); + ITK_TEST_SET_GET_VALUE(origin, transformToStrainFilter->GetOrigin()); - transformToDisplacement->SetSize( size ); - transformToDisplacement->SetOutputSpacing( spacing ); - transformToDisplacement->SetOutputOrigin( origin ); + transformToDisplacement->SetSize(size); + transformToDisplacement->SetOutputSpacing(spacing); + transformToDisplacement->SetOutputOrigin(origin); // Write strain field to disk. - using WriterType = itk::ImageFileWriter< TransformToStrainFilterType::OutputImageType >; + using WriterType = itk::ImageFileWriter; WriterType::Pointer writer = WriterType::New(); - writer->SetInput( transformToStrainFilter->GetOutput() ); - writer->SetFileName( strainFieldFileName ); + writer->SetInput(transformToStrainFilter->GetOutput()); + writer->SetFileName(strainFieldFileName); - ITK_TRY_EXPECT_NO_EXCEPTION( writer->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); // Write strain computed from the displacement field. - using StrainImageFilterType = itk::StrainImageFilter< DisplacementFieldType, CoordRepresentationType >; + using StrainImageFilterType = itk::StrainImageFilter; StrainImageFilterType::Pointer strainImageFilter = StrainImageFilterType::New(); - strainImageFilter->SetInput( transformToDisplacement->GetOutput() ); - strainImageFilter->SetStrainForm( - static_cast< StrainImageFilterType::StrainFormType >( strainForm ) ); - writer->SetInput( strainImageFilter->GetOutput() ); - writer->SetFileName( displacementFieldStrainFileName ); + strainImageFilter->SetInput(transformToDisplacement->GetOutput()); + strainImageFilter->SetStrainForm(static_cast(strainForm)); + writer->SetInput(strainImageFilter->GetOutput()); + writer->SetFileName(displacementFieldStrainFileName); - ITK_TRY_EXPECT_NO_EXCEPTION( writer->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); - using DisplacementWriterType = itk::ImageFileWriter< DisplacementFieldType >; + using DisplacementWriterType = itk::ImageFileWriter; DisplacementWriterType::Pointer displacementWriter = DisplacementWriterType::New(); - displacementWriter->SetFileName( displacementFieldFileName ); - displacementWriter->SetInput( transformToDisplacement->GetOutput() ); + displacementWriter->SetFileName(displacementFieldFileName); + displacementWriter->SetInput(transformToDisplacement->GetOutput()); - ITK_TRY_EXPECT_NO_EXCEPTION( displacementWriter->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(displacementWriter->Update()); std::cout << "Test finished." << std::endl;