diff --git a/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex b/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex index ace41c95..3e1da078 100644 --- a/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex +++ b/SoftwareGuide/Latex/Appendices/CodingStyleGuide.tex @@ -120,6 +120,18 @@ \section{System Overview \& Philosophy} Note as well that ITK follows American English spelling and norms. +\subsection{Clang Style} +\label{subsec:clangStyle} + +ITK has adopted a \code{.clang-format} coding style configuration file so +that a number of coding style rules are applied to all C++ code with the +\code{clang-format} binary. A consistent coding style is critical for +readability and collaborative development. + +ITK has a pre-commit hook to automatically reformat any changed C++ ITK code +to adhere to the style defined in the \code{.clang-format}. + + \subsection{Kitware Style} \label{subsec:KWStyle} @@ -180,10 +192,10 @@ \subsection{Constants} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} /** Set the marker image */ -void SetMaskImage(const MaskImageType *input) +void SetMaskImage(const MaskImageType * input) { // Process object is not const-correct so the const casting is required. - this->SetNthInput( 1, const_cast< TMaskImage * >( input ) ); + this->SetNthInput(1, const_cast(input)); } \end{minted} \normalsize @@ -401,13 +413,13 @@ \section{Citations} * \ingroup ITKDiffusionTensorImage */ -template< typename TReferenceImagePixelType, +template > -class ITK_TEMPLATE_EXPORT DiffusionTensor3DReconstructionImageFilter: -public ImageToImageFilter< Image< TReferenceImagePixelType, 3 >, -Image< DiffusionTensor3D< TTensorPixelType >, 3 > > +typename TMaskImageType = Image> +class ITK_TEMPLATE_EXPORT DiffusionTensor3DReconstructionImageFilter : +public ImageToImageFilter, +Image, 3>> { ... @@ -424,9 +436,9 @@ \section{Citations} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< unsigned int VDimension > -void Solver< VDimension > -::ApplyBC( int dimension, unsigned int matrix ) +template +void Solver +::ApplyBC(int dimension, unsigned int matrix) { ... // Store the appropriate value in bc correction vector (-K12*u2) @@ -591,7 +603,6 @@ \subsection{Naming Classes} \item \code{ScalarImageRegionIterator} \item \code{NeighborhoodIterator} \item \code{MapContainer} -\item \code{DefaultImageTraits} \item \code{BackwardDifferenceOperator} \end{itemize} @@ -628,7 +639,7 @@ \subsubsection{Naming Tests} name should generally be indicative of the class tested, e.g. \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkTobogganImageFilterTest( int argc, char *argv[] ) +int itkTobogganImageFilterTest(int argc, char * argv[]) \end{minted} \normalsize @@ -698,7 +709,7 @@ \subsubsection{Naming Tests} meaning behind the code, e.g. \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkSingleLevelSetWhitakerImage2DWithCurvatureTest( int argc, char* argv[] ) +int itkSingleLevelSetWhitakerImage2DWithCurvatureTest(int argc, char * argv[]) \end{minted} \normalsize @@ -785,7 +796,7 @@ \subsection{Naming Enumerations} class MathematicalMorphologyEnums { - public: +public: /**\class Algorithm * \brief Algorithm or implementation used in the dilation/erosion operations. * \ingroup ITKMathematicalMorphology @@ -890,8 +901,8 @@ \subsubsection{Temporary Variable Naming} \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} ... // Resize the schedules -ScheduleType schedule( m_NumberOfLevels, ImageDimension ); -schedule.Fill( 0 ); +ScheduleType schedule(m_NumberOfLevels, ImageDimension); +schedule.Fill(0); m_Schedule = schedule; ... \end{minted} @@ -904,12 +915,12 @@ \subsubsection{Temporary Variable Naming} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} ... -ValueType dimension = static_cast< ValueType >( ImageDimension ); +ValueType dimension = static_cast(ImageDimension); NormalVectorFilterType normalVectorFilter = NormalVectorFilterType::New(); ... -normalVectorFilter->SetIsoLevelLow( -m_CurvatureBandWidth - dimension ); -normalVectorFilter->SetIsoLevelHigh( m_CurvatureBandWidth + dimension ); +normalVectorFilter->SetIsoLevelLow(-m_CurvatureBandWidth - dimension); +normalVectorFilter->SetIsoLevelHigh(m_CurvatureBandWidth + dimension); ... // Move the pixel container and image information of the image we are working @@ -917,16 +928,16 @@ \subsubsection{Temporary Variable Naming} // avoids a complete copy of the image. typename OutputImageType::Pointer output = this->GetOutput(); auto tmp = OutputImageType::New(); -tmp->SetRequestedRegion( output->GetRequestedRegion() ); -tmp->SetBufferedRegion( output->GetBufferedRegion() ); -tmp->SetLargestPossibleRegion( output->GetLargestPossibleRegion() ); -tmp->SetPixelContainer( output->GetPixelContainer() ); -tmp->CopyInformation( output ); +tmp->SetRequestedRegion(output->GetRequestedRegion()); +tmp->SetBufferedRegion(output->GetBufferedRegion()); +tmp->SetLargestPossibleRegion(output->GetLargestPossibleRegion()); +tmp->SetPixelContainer(output->GetPixelContainer()); +tmp->CopyInformation(output); typename SparseImageType::Pointer sparseNormalImage = normalVectorFilter->GetOutput(); -this->ComputeCurvatureTarget( tmp, sparseNormalImage ); -m_LevelSetFunction->SetSparseTargetImage( sparseNormalImage ); +this->ComputeCurvatureTarget(tmp, sparseNormalImage); +m_LevelSetFunction->SetSparseTargetImage(sparseNormalImage); \end{minted} \normalsize @@ -941,30 +952,30 @@ \subsubsection{Variable Initialization} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage > +template double -WarpHarmonicEnergyCalculator< TInputImage > -::EvaluateAtNeighborhood( ConstNeighborhoodIteratorType & it ) const +WarpHarmonicEnergyCalculator +::EvaluateAtNeighborhood(ConstNeighborhoodIteratorType & it) const { - vnl_matrix_fixed< double, ImageDimension, VectorDimension > J; + vnl_matrix_fixed J; PixelType next, prev; double weight = 0; - for( unsigned int i = 0; i < ImageDimension; ++i ) - { + for (unsigned int i = 0; i < ImageDimension; ++i) + { next = it.GetNext(i); prev = it.GetPrevious(i); weight = 0.5 * m_DerivativeWeights[i]; - for( unsigned int j = 0; j < VectorDimension; ++j ) - { - J[i][j] = weight * ( static_cast< double >( next[j] ) - - static_cast< double >( prev[j] ) ); - } + for (unsigned int j = 0; j < VectorDimension; ++j) + { + J[i][j] = weight * (static_cast(next[j]) + - static_cast(prev[j])); } + } const double norm = J.fro_norm(); return norm * norm; @@ -985,25 +996,25 @@ \subsubsection{Variable Initialization} ... // Declare the type of the size -using SizeType = itk::Size< ImageDimension >; +using SizeType = itk::Size; SizeType size; size[0] = 100; size[1] = 100; // Declare the type of the index to access images -using IndexType = itk::Index< ImageDimension >; +using IndexType = itk::Index; IndexType start; start[0] = 0; start[1] = 0; // Declare the type of the Region -using RegionType = itk::ImageRegion< ImageDimension >; +using RegionType = itk::ImageRegion; RegionType region; -region.SetIndex( start ); -region.SetSize( size ); +region.SetIndex(start); +region.SetSize(size); \end{minted} \normalsize @@ -1031,15 +1042,15 @@ \subsubsection{Variable Scope} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} unsigned int i; -for ( i = 0; i < ImageDimension; ++i ) - { +for (i = 0; i < ImageDimension; ++i) +{ Something(); - } +} ... -for ( i = 0; i < ImageDimension; ++i ) - { +for (i = 0; i < ImageDimension; ++i) +{ SomethingElse(); - } +} \end{minted} \normalsize @@ -1049,15 +1060,15 @@ \subsubsection{Variable Scope} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} unsigned int i = 0; -for ( unsigned int i = 0; i < ImageDimension; ++i ) - { +for (unsigned int i = 0; i < ImageDimension; ++i) +{ Something(); - } +} ... -for ( unsigned int i = 0; i < ImageDimension; ++i ) - { +for (unsigned int i = 0; i < ImageDimension; ++i) +{ SomethingElse(); - } +} \end{minted} \normalsize @@ -1072,8 +1083,8 @@ \subsection{Naming Template Parameters} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TPixel, unsigned int VImageDimension = 2 > -class ITK_TEMPLATE_EXPORT Image:public ImageBase< VImageDimension > +template +class ITK_TEMPLATE_EXPORT Image : public ImageBase \end{minted} \normalsize @@ -1133,7 +1144,7 @@ \subsection{Naming Typedefs} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -using Superclass = ImageBase< VImageDimension >; +using Superclass = ImageBase; \end{minted} \normalsize @@ -1141,7 +1152,7 @@ \subsection{Naming Typedefs} \item \textbf{\code{Pointer}} as in a smart pointer to an object as in \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -using Pointer = SmartPointer< Self >; +using Pointer = SmartPointer; \end{minted} \normalsize @@ -1171,7 +1182,7 @@ \subsection{Using Operators to Pointers} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkTransformFileReaderTest( int argc, char *argv[] ) +int itkTransformFileReaderTest(int argc, char * argv[]) \end{minted} \normalsize @@ -1179,7 +1190,7 @@ \subsection{Using Operators to Pointers} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -const InputImageType *inputPtr = this->GetInput(); +const InputImageType * inputPtr = this->GetInput(); \end{minted} \normalsize @@ -1188,7 +1199,7 @@ \subsection{Using Operators to Pointers} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -const typename FixedImageType::RegionType &fixedRegion = +const typename FixedImageType::RegionType & fixedRegion = m_FixedImage->GetLargestPossibleRegion(); \end{minted} \normalsize @@ -1197,7 +1208,7 @@ \subsection{Using Operators to Pointers} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -::PrintSelf( std::ostream &os, Indent indent ) const +::PrintSelf(std::ostream &os, Indent indent) const \end{minted} \normalsize @@ -1208,7 +1219,7 @@ \subsection{Using Operators to Arrays} The subscript operator (\code{[]}) must be placed next to the variable, e.g. \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkGaborKernelFunctionTest( int argc, char *argv[] ) +int itkGaborKernelFunctionTest(int argc, char * argv[]) \end{minted} \normalsize @@ -1216,9 +1227,9 @@ \subsection{Using Operators to Arrays} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -unsigned int GetSplitInternal( unsigned int dim, +unsigned int GetSplitInternal(unsigned int dim, unsigned int i, unsigned int numberOfPieces, IndexValueType regionIndex[], - SizeValueType regionSize[] ) const override; + SizeValueType regionSize[]) const override; \end{minted} \normalsize @@ -1318,23 +1329,23 @@ \subsection{Const Correctness} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} /** Set the marker image. */ -void SetMaskImage( const MaskImageType *input ) - { +void SetMaskImage(const MaskImageType * input) +{ // Process object is not const-correct so the const casting is required. - this->SetNthInput( 1, const_cast< TMaskImage * >( input ) ); - } + this->SetNthInput(1, const_cast(input)); +} /** Set the input image. */ -void SetInput1( const InputImageType *input ) - { - this->SetInput( input ); - } +void SetInput1(const InputImageType * input) +{ + this->SetInput(input); +} /** Set the marker image. */ -void SetInput2( const MaskImageType *input ) - { - this->SetMaskImage( input ); - } +void SetInput2(const MaskImageType * input) +{ + this->SetMaskImage(input); +} \end{minted} \normalsize @@ -1343,9 +1354,9 @@ \subsection{Const Correctness} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} bool GetUseVectorBasedAlgorithm() const - { +{ return HistogramType::UseVectorBasedAlgorithm(); - } +} \end{minted} \normalsize @@ -1412,16 +1423,18 @@ \section{Aliasing Template Parameter Typenames} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TPixel, unsigned int VImageDimension = 2 > -class ITK_TEMPLATE_EXPORT Image : public ImageBase< VImageDimension > +template +class ITK_TEMPLATE_EXPORT Image : public ImageBase { public: + ITK_DISALLOW_COPY_AND_MOVE(Image); + /** Standard class type alias. */ using Self = Image; - using Superclass = ImageBase< VImageDimension >; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; - using ConstWeakPointer = WeakPointer< const Self >; + using Superclass = ImageBase; + using Pointer = SmartPointer; + using ConstPointer = SmartPointer; + using ConstWeakPointer = WeakPointer; ... @@ -1436,13 +1449,13 @@ \section{Aliasing Template Parameter Typenames} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TImage > -class ITK_TEMPLATE_EXPORT ImageRegionIterator : public ImageRegionConstIterator< TImage > +template +class ITK_TEMPLATE_EXPORT ImageRegionIterator : public ImageRegionConstIterator { public: /** Standard class type alias. */ using Self = ImageRegionIterator; - using Superclass = ImageRegionConstIterator< TImage >; + using Superclass = ImageRegionConstIterator; /** Types inherited from the Superclass */ using IndexType = typename Superclass::IndexType; @@ -1473,27 +1486,27 @@ \section{Pipelines} \end{minted} \normalsize -\item Do not assume \code{inputImage->SetRequestedRegion( smallRegion )} will +\item Do not assume \code{inputImage->SetRequestedRegion(smallRegion)} will make the filter faster! The filter might run on the entire input image regardless. To make it run on a smaller block, get a new \code{itk::RegionOfInterestImageFilter}, say \code{ROIfilter}, and do: \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -ROIfilter->SetInput( inputImage ); -ROIfilter->SetRegionOfInterest( smallRegion ); -CCfilter->SetInput( ROIfilter->GetOutput() ); +ROIfilter->SetInput(inputImage); +ROIfilter->SetRegionOfInterest(smallRegion); +CCfilter->SetInput(ROIfilter->GetOutput()); \end{minted} \normalsize \item On a newly-manually-created image, do initialize the pixel values if you expect them to be so! ITK does not initialize the image buffer when you call \code{Allocate()}. It is your responsibility to initialize the pixel values, -either by calling \code{Allocate( true )} or filling the image buffer as in: +either by calling \code{Allocate(true)} or filling the image buffer as in: \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -image->FillBuffer( 0 ); // Initialize it to all dark. +image->FillBuffer(0); // Initialize it to all dark. \end{minted} \normalsize @@ -1530,44 +1543,58 @@ \section{The auto Keyword} \section{Initialization and Assignment} \label{sec:IniitalizationAndAssignment} -All member variables must be initialized in the class constructor. For such -purpose, initialization lists are preferred +All member variables must be initialized when they are declared. For such +purpose, brace initializers, e.g. \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > -SpecializedFilter< TInputImage, TOutputImage > -::SpecializedFilter() : - m_ForegroundValue( NumericTraits::max() ), - m_BackgroundValue( NumericTraits::ZeroValue() ), - m_NumPixelComponents( 0 ), - m_NoiseSigmaIsSet( false ), - m_SearchSpaceList( ListAdaptorType::New() ) -{ - // By default, turn off automatic kernel bandwidth sigma estimation - this->KernelBandwidthEstimationOff(); -} +private: + double m_InnerRadius{ 1.0 }; + double m_Thickness{ 1.0 }; + bool m_Normalize{ false }; + bool m_BrightCenter{ false }; + PixelType m_InteriorValue{ NumericTraits::ZeroValue() }; + PixelType m_AnnulusValue{ NumericTraits::OneValue() }; + PixelType m_ExteriorValue{ NumericTraits::ZeroValue() }; + SpacingType m_Spacing{ 1.0 }; \end{minted} \normalsize -over assignment: +and brace list initialization, e.g. \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > -SpecializedFilter< TInputImage, TOutputImage > -::SpecializedFilter() +private: + IndexType m_Index = { { 0 } }; + SizeType m_Size = { { 0 } }; +\end{minted} +\normalsize + +are preferred over initialization lists in the method constructor, e.g. + +\small +\begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} +template +SpecializedFilter::SpecializedFilter() + : m_BackgroundValue(NumericTraits::ZeroValue()) + , m_ForegroundValue(NumericTraits::OneValue()) { - m_ForegroundValue = NumericTraits::max(); - m_BackgroundValue = NumericTraits::ZeroValue(); + ... +} +\end{minted} +\normalsize - m_NumPixelComponents = 0; - m_UseSmoothDiscPatchWeights = false; +or assignment: - m_SearchSpaceList = ListAdaptorType::New(); +\small +\begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} +template +SpecializedFilter::SpecializedFilter() +{ + m_BackgroundValue = NumericTraits::ZeroValue(); + m_ForegroundValue = NumericTraits::OneValue(); - // By default, turn off automatic kernel bandwidth sigma estimation - this->KernelBandwidthEstimationOff(); + ... } \end{minted} \normalsize @@ -1599,17 +1626,16 @@ \section{Accessing Members} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > +template void -ExpandImageFilter< TInputImage, TOutputImage > +ExpandImageFilter ::GenerateInputRequestedRegion() { // Call the superclass' implementation of this method Superclass::GenerateInputRequestedRegion(); // Get pointers to the input and output - InputImageType * inputPtr = - const_cast< InputImageType * >( this->GetInput() ); + InputImageType * inputPtr = const_cast(this->GetInput()); const OutputImageType * outputPtr = this->GetOutput(); ... @@ -1627,14 +1653,14 @@ \section{Accessing Members} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > +template void -BinaryContourImageFilter< TInputImage, TOutputImage > -::PrintSelf( std::ostream & os, Indent indent ) const +BinaryContourImageFilter +::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); - os << indent << "FullyConnected: " << m_FullyConnected << std::endl; + os << indent << "FullyConnected: " << m_FullyConnected << std::endl; ... } \end{minted} @@ -1644,14 +1670,14 @@ \section{Accessing Members} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > +template void -BinaryContourImageFilter< TInputImage, TOutputImage > -::PrintSelf( std::ostream & os, Indent indent ) const +BinaryContourImageFilter +::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); - os << indent << "FullyConnected: " << this->m_FullyConnected << std::endl; + os << indent << "FullyConnected: " << this->m_FullyConnected << std::endl; ... } \end{minted} @@ -1696,13 +1722,13 @@ \subsection{General Layout} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( condition ) - { +if (condition) +{ unsigned int numberOfIterations = 100; - filter->SetNumberOfIterations( numberOfIterations ); + filter->SetNumberOfIterations(numberOfIterations); filter->Update(); - filter->Print( std::cout ); - } + filter->Print(std::cout); +} \end{minted} \normalsize @@ -1757,10 +1783,16 @@ \subsection{Class Layout} #ifndef itkImage_h #define itkImage_h -#include "itkImageBase.h" -#include "itkPixelTraits.h" -#include "itkDefaultImageTraits.h" -#include "itkDefaultDataAccessor.h" +#include "itkImageRegion.h" +#include "itkImportImageContainer.h" +#include "itkDefaultPixelAccessor.h" +#include "itkDefaultPixelAccessorFunctor.h" +#include "itkPoint.h" +#include "itkFixedArray.h" +#include "itkWeakPointer.h" +#include "itkNeighborhoodAccessorFunctor.h" + +#include namespace itk { @@ -1771,9 +1803,8 @@ \subsection{Class Layout} * Detailed documentation... */ -template< typename TPixel, unsigned int VImageDimension=2, - typename TImageTraits=DefaultImageTraits< TPixel, VImageDimension > > -class Image: public ImageBase< VImageDimension > +template +class ITK_TEMPLATE_EXPORT Image : public ImageBase { public: ... @@ -1788,7 +1819,7 @@ \subsection{Class Layout} } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkImage.hxx" +# include "itkImage.hxx" #endif #endif // itkImage_h @@ -1854,33 +1885,25 @@ \subsection{Class Layout} namespace itk { -template< typename TPixel, unsigned int VImageDimension > -Image< TPixel, VImageDimension > +template +Image ::Image() { m_Buffer = PixelContainer::New(); } - -template< typename TPixel, unsigned int VImageDimension > -Image< TPixel, VImageDimension > -~::Image() -{ -} - - ... -template< typename TPixel, unsigned int VImageDimension > +template void -Image< TPixel, VImageDimension > -::PrintSelf( std::ostream &os, Indent indent ) const +Image +::PrintSelf(std::ostream &os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); os << indent << "PixelContainer: " << std::endl; - m_Buffer->Print( os, indent.GetNextIndent() ); + m_Buffer->Print(os, indent.GetNextIndent()); } } // end namespace itk @@ -1902,18 +1925,16 @@ \subsection{Method Definition} \begin{itemize} \item The first line is the template declaration. \item The second line is the method return type. -\item The third line is the class qualifier. -\item And the fourth line is the name of the method. +\item The third line is the class qualifier and the name of the method. \end{itemize} e.g. \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TPixel, unsigned int VImageDimension, typename TImageTraits > -const double * -Image< TPixel, VImageDimension, TImageTraits > -::GetSpacing() const +template +unsigned int +Image ::GetNumberOfComponentsPerPixel() const { ... } @@ -1925,14 +1946,19 @@ \subsection{Method Definition} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} void -Bruker2DSEQImageIO -::PrintSelf(std::ostream & os, Indent indent) const +Bruker2DSEQImageIO::PrintSelf(std::ostream & os, Indent indent) const { ... } \end{minted} \normalsize +If the line length exceed the threshold set by the automatic style +enforcement tool, they will be automatically be formatted. + +Due to different line length rules in this text book, the name of the method +may be split into a separate line. + \subsection{Use of Braces} \label{subsec:UseOfBraces} @@ -1946,10 +1972,10 @@ \subsubsection{Braces in Control Sequences} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int i = 0; i < ImageDimension; ++i ) - { +for (unsigned int i = 0; i < ImageDimension; ++i) +{ ... - } +} \end{minted} \normalsize @@ -1958,18 +1984,18 @@ \subsubsection{Braces in Control Sequences} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( condition ) - { +if (condition) +{ ... - } -else if( otherCondition ) - { +} +else if (otherCondition) +{ ... - } +} else - { +{ ... - } +} \end{minted} \normalsize @@ -1978,8 +2004,8 @@ \subsubsection{Braces in Control Sequences} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -switch( m_OperationQ.front() ) - { +switch (m_OperationQ.front()) +{ case Self::SET_PRIORITY_LEVEL: m_PriorityLevel = m_LevelQ.front(); m_LevelQ.pop(); @@ -1992,7 +2018,7 @@ \subsubsection{Braces in Control Sequences} ... default: break; - } +} \end{minted} \normalsize @@ -2002,11 +2028,11 @@ \subsubsection{Braces in Control Sequences} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} do - { +{ k += 1; p *= rand->GetVariate(); - } -while( p > L ); +} +while (p > L); \end{minted} \normalsize @@ -2036,21 +2062,21 @@ \subsection{Indentation and Tabs} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage = TInputImage > +template class ITK_TEMPLATE_EXPORT SpecializedFilter : - public ImageToImageFilter< TInputImage, TOutputImage > + public ImageToImageFilter { public: using Self = SpecializedFilter; - using Superclass = ImageToImageFilter< TInputImage, TOutputImage >; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Superclass = ImageToImageFilter; + 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( SpecializedFilter, ImageToImageFilter ); + itkTypeMacro(SpecializedFilter, ImageToImageFilter); ... }; @@ -2061,9 +2087,9 @@ \subsection{Indentation and Tabs} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > +template void -SpecializedFilter< TInputImage, TOutputImage > +SpecializedFilter ::GenerateData() const { // Allocate the outputs. @@ -2071,23 +2097,23 @@ \subsection{Indentation and Tabs} // Create a process accumulator for tracking the progress of this minipipeline. auto progress = ProgressAccumulator::New(); - progress->SetMiniPipelineFilter( this ); + progress->SetMiniPipelineFilter(this); ... } \end{minted} \normalsize -ITK uses the Whitesmiths indentation style, with the braces associated with -a control statement on the next line, indented. Thus, source code in the body of -the brackets must be aligned along with the brackets. +ITK uses the Allman indentation style, with the braces associated with a +control statement on the next line, indented to the same level as the control +statement. Thus, source code in the body of the brackets must be indented. \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -while( x == y ) - { +while (x == y) +{ Something(); - } +} \end{minted} \normalsize @@ -2134,10 +2160,10 @@ \subsection{White Spaces} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int i = 0; i < ImageDimension; ++i ) - { +for (unsigned int i = 0; i < ImageDimension; ++i) +{ ... - } +} \end{minted} \normalsize @@ -2145,7 +2171,7 @@ \subsection{White Spaces} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -this->SomeMethod( param, a+b ); +this->SomeMethod(param, a + b); \end{minted} \normalsize @@ -2155,21 +2181,21 @@ \subsection{White Spaces} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage = TInputImage > +template class ITK_TEMPLATE_EXPORT SpecializedFilter : - public ImageToImageFilter< TInputImage, TOutputImage > + public ImageToImageFilter { public: using Self = SpecializedFilter; - using Superclass = ImageToImageFilter< TInputImage, TOutputImage >; - using Pointer = SmartPointer< Self >; - using ConstPointer = SmartPointer< const Self >; + using Superclass = ImageToImageFilter; + 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( SpecializedFilter, ImageToImageFilter ); + itkTypeMacro(SpecializedFilter, ImageToImageFilter); ... }; @@ -2180,14 +2206,14 @@ \subsection{White Spaces} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > -SpecializedFilter< TInputImage, TOutputImage > +template +SpecializedFilter ::SpecializedFilter() : - m_ForegroundValue( NumericTraits::max() ), - m_BackgroundValue( NumericTraits::ZeroValue() ), - m_NumPixelComponents( 0 ), - m_NoiseSigmaIsSet( false ), - m_SearchSpaceList( ListAdaptorType::New() ) + m_ForegroundValue(NumericTraits::max()), + m_BackgroundValue(NumericTraits::ZeroValue()), + m_NumPixelComponents(0), + m_NoiseSigmaIsSet(false), + m_SearchSpaceList(ListAdaptorType::New()) { // By default, turn off automatic kernel bandwidth sigma estimation this->KernelBandwidthEstimationOff(); @@ -2222,14 +2248,14 @@ \subsubsection{Conditional Expressions} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( modelFile == "tri3-q.meta" && ( s == 2 || s == 1 ) ) - { +if (modelFile == "tri3-q.meta" && (s == 2 || s == 1)) +{ ... - } +} else - { +{ ... - } +} \end{minted} \normalsize @@ -2237,14 +2263,14 @@ \subsubsection{Conditional Expressions} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( ( modelFile == "tri3-q.meta" ) && ( ( s == 2 ) || ( s == 1 ) ) ) - { +if ((modelFile == "tri3-q.meta") && ((s == 2) || (s == 1))) +{ ... - } +} else - { +{ ... - } +} \end{minted} \normalsize @@ -2261,7 +2287,7 @@ \subsubsection{Assignments} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -sum[dim] += ( component * weight ); +sum[dim] += (component * weight); \end{minted} \normalsize @@ -2286,16 +2312,16 @@ \subsubsection{Return Statements} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} OutputType Evaluate(const PointType & point) const override - { +{ ContinuousIndexType index; - this->GetInputImage()->TransformPhysicalPointToContinuousIndex( point, + this->GetInputImage()->TransformPhysicalPointToContinuousIndex(point, index); // No thread info passed in, so call method that doesn't need thread // identifier. - return this->EvaluateDerivativeAtContinuousIndex( index ); - } + return this->EvaluateDerivativeAtContinuousIndex(index); +} \end{minted} \normalsize @@ -2305,9 +2331,9 @@ \subsubsection{Return Statements} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TPoint > +template double -SimpleSignedDistance( const TPoint & p ) +SimpleSignedDistance(const TPoint & p) { ... return accum - radius; @@ -2315,21 +2341,21 @@ \subsubsection{Return Statements} \end{minted} \normalsize -instead of writing \code{return ( accum - radius );}. +instead of writing \code{return (accum - radius);}. Or in: \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} bool -RealTimeStamp::operator>( const Self & other ) const +RealTimeStamp::operator>(const Self & other) const { - if( this->m_Seconds > other.m_Seconds ) + if (this->m_Seconds > other.m_Seconds) { return true; } - if( this->m_Seconds < other.m_Seconds ) + if (this->m_Seconds < other.m_Seconds) { return false; } @@ -2406,9 +2432,8 @@ \subsection{Alignment} * Detailed documentation... */ -template< typename TPixel, unsigned int VImageDimension=2, - typename TImageTraits=DefaultImageTraits< TPixel, VImageDimension > > -class Image: public ImageBase< VImageDimension > +template +class ITK_TEMPLATE_EXPORT Image : public ImageBase { public: ... @@ -2423,7 +2448,7 @@ \subsection{Alignment} } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkImage.hxx" +# include "itkImage.hxx" #endif #endif // itkImage_h @@ -2440,10 +2465,9 @@ \subsection{Alignment} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TPixel, unsigned int VImageDimension, typename TImageTraits > -const double * -Image< TPixel, VImageDimension, TImageTraits > -::GetSpacing() const +template +unsigned int +Image ::GetNumberOfComponentsPerPixel() const { ... } @@ -2454,13 +2478,12 @@ \subsection{Alignment} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -InputPixelType m_ForegroundValue; -OutputPixelType m_BackgroundValue; - -unsigned int m_MaximumIterations; +std::string m_FileName; +ConstTransformListType m_TransformList; +bool m_AppendMode{ false }; -std::vector< double > m_Sensitivity; -std::vector< float > m_Overlaps; +bool m_UseCompression{ false }; +typename TransformIOType::Pointer m_TransformIO; \end{minted} \normalsize @@ -2469,11 +2492,11 @@ \subsection{Alignment} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -normalVectorFilter->SetIsoLevelLow( -m_CurvatureBandWidth - dimension ); -normalVectorFilter->SetIsoLevelHigh( m_CurvatureBandWidth + dimension ); -normalVectorFilter->SetMaxIteration( m_MaxNormalIteration ); -normalVectorFilter->SetUnsharpMaskingFlag( m_NormalProcessUnsharpFlag ); -normalVectorFilter->SetUnsharpMaskingWeight( m_NormalProcessUnsharpWeight ); +normalVectorFilter->SetIsoLevelLow(-m_CurvatureBandWidth - dimension); +normalVectorFilter->SetIsoLevelHigh(m_CurvatureBandWidth + dimension); +normalVectorFilter->SetMaxIteration(m_MaxNormalIteration); +normalVectorFilter->SetUnsharpMaskingFlag(m_NormalProcessUnsharpFlag); +normalVectorFilter->SetUnsharpMaskingWeight(m_NormalProcessUnsharpWeight); \end{minted} \normalsize @@ -2481,11 +2504,11 @@ \subsection{Alignment} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -normalVectorFilter->SetIsoLevelLow ( -m_CurvatureBandWidth - dimension ); -normalVectorFilter->SetIsoLevelHigh ( m_CurvatureBandWidth + dimension ); -normalVectorFilter->SetMaxIteration ( m_MaxNormalIteration ); -normalVectorFilter->SetUnsharpMaskingFlag ( m_NormalProcessUnsharpFlag ); -normalVectorFilter->SetUnsharpMaskingWeight( m_NormalProcessUnsharpWeight ); +normalVectorFilter->SetIsoLevelLow (-m_CurvatureBandWidth - dimension); +normalVectorFilter->SetIsoLevelHigh (m_CurvatureBandWidth + dimension); +normalVectorFilter->SetMaxIteration (m_MaxNormalIteration); +normalVectorFilter->SetUnsharpMaskingFlag (m_NormalProcessUnsharpFlag); +normalVectorFilter->SetUnsharpMaskingWeight(m_NormalProcessUnsharpWeight); \end{minted} \normalsize @@ -2513,14 +2536,14 @@ \subsection{Alignment} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( coeff.size() > m_MaximumKernelWidth ) - { +if (coeff.size() > m_MaximumKernelWidth) +{ itkWarningMacro("Kernel size has exceeded the specified maximum width of " << m_MaximumKernelWidth << " and has been truncated to " - << static_cast< unsigned long >( coeff.size() ) << " elements. You can raise " + << static_cast(coeff.size()) << " elements. You can raise " "the maximum width using the SetMaximumKernelWidth method."); break; - } +} \end{minted} \normalsize @@ -2528,14 +2551,14 @@ \subsection{Alignment} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( coeff.size() > m_MaximumKernelWidth ) - { - itkWarningMacro( "Kernel size has exceeded the specified maximum width of " +if (coeff.size() > m_MaximumKernelWidth) +{ + itkWarningMacro("Kernel size has exceeded the specified maximum width of " << m_MaximumKernelWidth << " and has been truncated to " - << static_cast< unsigned long >( coeff.size() ) << " elements. You can raise " - "the maximum width using the SetMaximumKernelWidth method." ); + << static_cast(coeff.size()) << " elements. You can raise " + "the maximum width using the SetMaximumKernelWidth method."); break; - } +} \end{minted} \normalsize @@ -2543,9 +2566,9 @@ \subsection{Alignment} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -unsigned int GetSplitInternal( unsigned int dim, +unsigned int GetSplitInternal(unsigned int dim, unsigned int i, unsigned int numberOfPieces, IndexValueType regionIndex[], - SizeValueType regionSize[] ) const override; + SizeValueType regionSize[]) const override; \end{minted} \normalsize @@ -2575,7 +2598,7 @@ \subsection{Line Splitting Policy} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -const typename FixedImageType::RegionType &fixedRegion = +const typename FixedImageType::RegionType & fixedRegion = m_FixedImage->GetLargestPossibleRegion(); \end{minted} \normalsize @@ -2584,8 +2607,8 @@ \subsection{Line Splitting Policy} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -using FilterType = AddImageFilter< BiasFieldControlPointLatticeType, - BiasFieldControlPointLatticeType, BiasFieldControlPointLatticeType > +using FilterType = AddImageFilter \end{minted} \normalsize @@ -2594,8 +2617,8 @@ \subsection{Line Splitting Policy} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -while( m_ElapsedIterations++ < m_MaximumNumberOfIterations[m_CurrentLevel] - && m_CurrentConvergenceMeasurement > m_ConvergenceThreshold ) +while (m_ElapsedIterations++ < m_MaximumNumberOfIterations[m_CurrentLevel] + && m_CurrentConvergenceMeasurement > m_ConvergenceThreshold) \end{minted} \normalsize @@ -2604,8 +2627,8 @@ \subsection{Line Splitting Policy} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} centerFixedIndex[k] = - static_cast< ContinuousIndexValueType >( fixedIndex[k] ) - + static_cast< ContinuousIndexValueType >( fixedSize[k] - 1 ) / 2.0; + static_cast(fixedIndex[k]) + + static_cast(fixedSize[k] - 1) / 2.0; \end{minted} \normalsize @@ -2693,23 +2716,23 @@ \subsection{Empty Lines} * \ingroup ITKImageFilterBase */ -template< typename TInputImage, typename TOutputImage > -class ITK_TEMPLATE_EXPORT BoxImageFilter: - public ImageToImageFilter< TInputImage, TOutputImage > +template +class ITK_TEMPLATE_EXPORT BoxImageFilter : + public ImageToImageFilter { public: ITK_DISALLOW_COPY_AND_ASSIGN(BoxImageFilter); /** Standard class type alias. */ using Self = BoxImageFilter; - using Superclass = ImageToImageFilter< TInputImage, TOutputImage >; + using Superclass = ImageToImageFilter; ... protected: BoxImageFilter(); - ~BoxImageFilter() {} + ~BoxImageFilter() override = default; void GenerateInputRequestedRegion() override; @@ -2722,7 +2745,7 @@ \subsection{Empty Lines} } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION -#include "itkBoxImageFilter.hxx" +# include "itkBoxImageFilter.hxx" #endif #endif // itkBoxImageFilter_h @@ -2763,49 +2786,49 @@ \subsection{Empty Lines} * *=========================================================================*/ -#ifndef itkBoxImageFilter_hxx -#define itkBoxImageFilter_hxx +#ifndef itkSpecializedImageFilter_hxx +#define itkSpecializedImageFilter_hxx -#include "itkBoxImageFilter.h" +#include "itkSpecializedImageFilter.h" #include "itkProgressAccumulator.h" namespace itk { -template< typename TInputImage, typename TOutputImage > -BoxImageFilter< TInputImage, TOutputImage > -::BoxImageFilter() +template +SpecializedImageFilter +::SpecializedImageFilter() { - m_Radius.Fill( 1 ); // A good arbitrary starting point. + this->DynamicMultiThreadingOn(); } -template< typename TInputImage, typename TOutputImage > +template void -BoxImageFilter< TInputImage, TOutputImage > +SpecializedImageFilter ::SetRadius(const RadiusType & radius) { - if( m_Radius != radius ) - { + if (m_Radius != radius) + { m_Radius = radius; this->Modified(); - } + } } -template< typename TInputImage, typename TOutputImage > +template void -BoxImageFilter< TInputImage, TOutputImage > -::PrintSelf( std::ostream & os, Indent indent ) const +SpecializedImageFilter +::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); os << indent << "Radius: " << m_Radius << std::endl; } } // end namespace itk -#endif // itkBoxImageFilter_hxx +#endif // itkSpecializedImageFilter_hxx \end{minted} \normalsize @@ -2814,23 +2837,23 @@ \subsection{Empty Lines} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkHMinimaImageFilterTest( int argc, char *argv[] ) +int itkHMinimaImageFilterTest(int argc, char * argv[]) { ... - hMinimaFilter->SetInput( reader->GetOutput() ); + hMinimaFilter->SetInput(reader->GetOutput()); // Run the filter - ITK_TRY_EXPECT_NO_EXCEPTION( hMinimaFilter->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(hMinimaFilter->Update()); // Write the output - using WriterType = itk::ImageFileWriter< OutputImageType >; + using WriterType = itk::ImageFileWriter; auto writer = WriterType::New(); - writer->SetFileName( argv[2] ); - writer->SetInput( hMinimaFilter->GetOutput() ); + writer->SetFileName(argv[2]); + writer->SetInput(hMinimaFilter->GetOutput()); - ITK_TRY_EXPECT_NO_EXCEPTION( writer->Update() ); + ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); std::cout << "Test finished." << std::endl; @@ -2847,9 +2870,9 @@ \subsection{Empty Lines} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkHMinimaImageFilterTest( int argc, char * argv[] ) +int itkHMinimaImageFilterTest(int argc, char * argv[]) { - if( argc != 5 ) + if (argc != 5) { std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); @@ -2878,29 +2901,25 @@ \subsection{Empty Lines} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TMaskImage, typename TOutputImage > -typename -N4BiasFieldCorrectionImageFilter< TInputImage, TMaskImage, TOutputImage >::RealImagePointer -N4BiasFieldCorrectionImageFilter< TInputImage, TMaskImage, TOutputImage > -::SharpenImage( const RealImageType *unsharpenedImage ) const +template +void N4BiasFieldCorrectionImageFilter::SharpenImage( + const RealImageType * unsharpenedImage, RealImageType * sharpenedImage) const { - const MaskImageType *maskImage = this->GetMaskImage(); - const RealImageType *confidenceImage = this->GetConfidenceImage(); -#if !defined( ITK_FUTURE_LEGACY_REMOVE ) + const auto maskImageBufferRange = MakeImageBufferRange(this->GetMaskImage()); + const auto confidenceImageBufferRange = MakeImageBufferRange(this->GetConfidenceImage()); const MaskPixelType maskLabel = this->GetMaskLabel(); - const bool useMaskLabel = this->GetUseMaskLabel(); -#endif + const bool useMaskLabel = this->GetUseMaskLabel(); // Build the histogram for the uncorrected image. Store copy // in a vnl_vector to utilize vnl FFT routines. Note that variables // in real space are denoted by a single uppercase letter whereas their // frequency counterparts are indicated by a trailing lowercase 'f'. - RealType binMaximum = NumericTraits< RealType >::NonpositiveMin(); - RealType binMinimum = NumericTraits< RealType >::max(); + RealType binMaximum = NumericTraits::NonpositiveMin(); + RealType binMinimum = NumericTraits::max(); - ImageRegionConstIterator< RealImageType > itU( - unsharpenedImage, unsharpenedImage->GetLargestPossibleRegion() ); + ImageRegionConstIterator itU( + unsharpenedImage, unsharpenedImage->GetLargestPossibleRegion()); ... } @@ -2924,24 +2943,24 @@ \subsection{New Line Character} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage > +template void -MinimumMaximumImageCalculator< TInputImage > -::PrintSelf( std::ostream & os, Indent indent ) const +MinimumMaximumImageCalculator +::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); os << indent << "Minimum: " - << static_cast< typename NumericTraits< PixelType >::PrintType >( m_Minimum ) + << static_cast::PrintType>(m_Minimum) << std::endl; os << indent << "Maximum: " - << static_cast< typename NumericTraits< PixelType >::PrintType >( m_Maximum ) + << static_cast::PrintType>(m_Maximum) << std::endl; os << indent << "IndexOfMinimum: " << m_IndexOfMinimum << std::endl; os << indent << "IndexOfMaximum: " << m_IndexOfMaximum << std::endl; - itkPrintSelfObjectMacro( Image ); + itkPrintSelfObjectMacro(Image); os << indent << "Region: " << std::endl; - m_Region.Print( os, indent.GetNextIndent() ); + m_Region.Print(os, indent.GetNextIndent()); os << indent << "RegionSetByUser: " << m_RegionSetByUser << std::endl; } \end{minted} @@ -2964,10 +2983,10 @@ \section{Increment/decrement Operators} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int i = 0; i < ImageDimension; ++i ) - { +for (unsigned int i = 0; i < ImageDimension; ++i) +{ ... - } +} \end{minted} \normalsize @@ -2977,11 +2996,11 @@ \section{Increment/decrement Operators} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -while( it != m_Container.end() ) - { +while (it != m_Container.end()) +{ ... ++it; - } +} \end{minted} \normalsize @@ -3016,13 +3035,13 @@ \section{Ternary Operator} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int i = 0; i < m_NumOfThreads; ++i ) +for (unsigned int i = 0; i < m_NumOfThreads; ++i) +{ + for (unsigned int j = (i == 0 ? 0 : m_Boundary[i - 1] + 1); j <= m_Boundary[i]; ++j) { - for( unsigned int j = ( i == 0 ? 0 : m_Boundary[i - 1] + 1 ); j <= m_Boundary[i]; ++j ) - { m_GlobalZHistogram[j] = m_Data[i].m_ZHistogram[j]; - } } +} \end{minted} \normalsize @@ -3033,23 +3052,23 @@ \section{Ternary Operator} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int i = 0; i < m_NumOfThreads; ++i ) +for (unsigned int i = 0; i < m_NumOfThreads; ++i) +{ + if (i == 0) { - if( i == 0 ) + for (unsigned int j = 0; j <= m_Boundary[i]; ++j) { - for( unsigned int j = 0; j <= m_Boundary[i]; ++j ) - { m_GlobalZHistogram[j] = m_Data[i].m_ZHistogram[j]; - } } + } else + { + for (unsigned int j = m_Boundary[i - 1] + 1; j <= m_Boundary[i]; ++j) { - for( unsigned int j = m_Boundary[i - 1] + 1; j <= m_Boundary[i]; ++j ) - { m_GlobalZHistogram[j] = m_Data[i].m_ZHistogram[j]; - } } } +} \end{minted} \normalsize @@ -3057,17 +3076,17 @@ \section{Ternary Operator} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int j = 0; j <= m_Boundary[i]; ++j ) - { +for (unsigned int j = 0; j <= m_Boundary[i]; ++j) +{ m_GlobalZHistogram[j] = m_Data[0].m_ZHistogram[j]; - } -for( unsigned int i = 1; i < m_NumOfThreads; ++i ) +} +for (unsigned int i = 1; i < m_NumOfThreads; ++i) +{ + for (unsigned int j = m_Boundary[i - 1] + 1; j <= m_Boundary[i]; ++j) { - for( unsigned int j = m_Boundary[i - 1] + 1; j <= m_Boundary[i]; ++j ) - { m_GlobalZHistogram[j] = m_Data[i].m_ZHistogram[j]; - } } +} \end{minted} \normalsize @@ -3076,11 +3095,11 @@ \section{Ternary Operator} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int i = 0; j < ImageDimension; i++ ) - { +for (unsigned int i = 0; j < ImageDimension; ++i) +{ const elementSign = ( m_Step[i] > 0 ) ? 1.0 : -1.0; flipMatrix[i][i] = elementSign; - } +} \end{minted} \normalsize @@ -3089,18 +3108,18 @@ \section{Ternary Operator} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -for( unsigned int i = 0; j < ImageDimension; i++ ) +for (unsigned int i = 0; j < ImageDimension; ++i) +{ + if (m_Step[i] > 0) { - if( m_Step[i] > 0 ) - { elementSign = 1.0; - } + } else - { + { elementSign = -1.0; - } - flipMatrix[i][i] = elementSign; } + flipMatrix[i][i] = elementSign; +} \end{minted} \normalsize @@ -3194,10 +3213,10 @@ \section{Using Standard Macros} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} /** Method for creation through the object factory. */ -itkNewMacro( Self ); +itkNewMacro(Self); /** Run-time type information (and related methods). */ -itkTypeMacro( Image, ImageBase ); +itkTypeMacro(Image, ImageBase); \end{minted} \normalsize @@ -3211,7 +3230,7 @@ \section{Using Standard Macros} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -ITK_TRY_EXPECT_NO_EXCEPTION( writer->Update() ); +ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update()); \end{minted} \normalsize @@ -3235,7 +3254,7 @@ \section{Exception Handling} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} /** Initialize the components related to supporting multiple threads. */ -virtual void MultiThreadingInitialize(void) throw ( ExceptionObject ); +virtual void MultiThreadingInitialize(void) throw (ExceptionObject); \end{minted} \normalsize @@ -3255,17 +3274,17 @@ \section{Exception Handling} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} try - { +{ // Code liable to throw an exception - } -catch( const ExceptionObject & exc ) - { +} +catch (const ExceptionObject & exc) +{ std::cerr << exc << std::endl; - } -catch( const std::exception & exc ) - { +} +catch (const std::exception & exc) +{ std::cerr << exc.what() << std::endl; - } +} \end{minted} \normalsize @@ -3273,15 +3292,15 @@ \section{Exception Handling} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} - try - { +try +{ m_ExceptionMessage = ""; this->TestFileExistanceAndReadability(); - } -catch( const ExceptionObject & exc ) - { +} +catch (const ExceptionObject & exc) +{ m_ExceptionMessage = exc.GetDescription(); - } +} \end{minted} \normalsize @@ -3291,11 +3310,11 @@ \section{Exception Handling} \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} // Do the optimization try - { +{ m_Optimizer->StartOptimization(); - } -catch( const ExceptionObject & exc ) - { +} +catch (const ExceptionObject & exc) +{ // An error has occurred in the optimization. // Update the parameters. m_LastTransformParameters = m_Optimizer->GetCurrentPosition(); @@ -3319,10 +3338,10 @@ \section{Exception Handling} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( m_FileName == "" ) - { - throw MeshFileReaderException( __FILE__, __LINE__, "FileName must be specified", ITK_LOCATION ); - } +if (m_FileName == "") +{ + throw MeshFileReaderException(__FILE__, __LINE__, "FileName must be specified", ITK_LOCATION); +} \end{minted} \normalsize @@ -3345,21 +3364,20 @@ \subsection{Errors in Pipelines} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > +template void -BinShrinkImageFilter< TInputImage, TOutputImage > +BinShrinkImageFilter ::GenerateInputRequestedRegion() { // Call the superclass' implementation of this method. Superclass::GenerateInputRequestedRegion(); // Get pointers to the input and output. - InputImageType * inputPtr = - const_cast< InputImageType * >( this->GetInput() ); + InputImageType * inputPtr = const_cast(this->GetInput()); const OutputImageType * outputPtr = this->GetOutput(); - itkAssertInDebugAndIgnoreInReleaseMacro( inputPtr != nullptr ); - itkAssertInDebugAndIgnoreInReleaseMacro( outputPtr ); + itkAssertInDebugAndIgnoreInReleaseMacro(inputPtr != nullptr); + itkAssertInDebugAndIgnoreInReleaseMacro(outputPtr); ... } @@ -3370,13 +3388,13 @@ \subsection{Errors in Pipelines} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > +template void -PatchBasedDenoisingBaseImageFilter< TInputImage, TOutputImage > -::SetPatchWeights( const PatchWeightsType& weights ) +PatchBasedDenoisingBaseImageFilter +::SetPatchWeights(const PatchWeightsType & weights) { - itkAssertOrThrowMacro( this->GetPatchLengthInVoxels() == weights.GetSize(), - "Unexpected patch size encountered while setting patch weights" ); + itkAssertOrThrowMacro(this->GetPatchLengthInVoxels() == weights.GetSize(), + "Unexpected patch size encountered while setting patch weights"); ... } @@ -3404,7 +3422,7 @@ \subsection{Messages in Macros} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -itkDebugMacro( << "Computing Bayes Rule" ); +itkDebugMacro(<< "Computing Bayes Rule"); \end{minted} \normalsize @@ -3412,7 +3430,7 @@ \subsection{Messages in Macros} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -itkExceptionMacro( << "The size of the mask differs from the input image" ); +itkExceptionMacro(<< "The size of the mask differs from the input image"); \end{minted} \normalsize @@ -3449,13 +3467,13 @@ \subsection{Messages in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( argc != 3 ) - { +if (argc != 3) +{ std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); std::cerr << " inputImage outputImage" << std::endl; return EXIT_FAILURE; - } +} \end{minted} \normalsize @@ -3467,8 +3485,8 @@ \subsection{Messages in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( argc < 3 ) - { +if (argc < 3) +{ std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); std::cerr << " inputImage" @@ -3476,7 +3494,7 @@ \subsection{Messages in Tests} << " [foregroundValue] << " [backgroundValue]" << std::endl; return EXIT_FAILURE; - } +} \end{minted} \normalsize @@ -3486,15 +3504,15 @@ \subsection{Messages in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -bool tf = colors->SetColor( 0, 0, 0, 0, name ); -if( tf != true ) - { +bool tf = colors->SetColor(0, 0, 0, 0, name); +if (tf != true) +{ std::cerr << "Test failed!" << std::endl; std::cerr << "Error in itk::ColorTable::SetColor" << std::endl; std::cerr << "Expected: " << true << ", but got: " << tf << std::endl; return EXIT_FAILURE; - } +} \end{minted} \normalsize @@ -3506,22 +3524,22 @@ \subsection{Messages in Tests} \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} // Check the content of the result image const OutputImageType::PixelType expectedValue = - static_cast< OutputImageType::PixelType >( valueA * valueB ); + static_cast(valueA * valueB); const OutputImageType::PixelType epsilon = 1e-6; -while( !oIt.IsAtEnd() ) +while (!oIt.IsAtEnd()) +{ +if (!itk::Math::FloatAlmostEqual(oIt.Get(), expectedValue, 10, epsilon)) { - if( !itk::Math::FloatAlmostEqual( oIt.Get(), expectedValue, 10, epsilon ) ) - { - std::cerr.precision( static_cast< int >( itk::Math::abs( std::log10( epsilon ) ) ) ); + std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); std::cerr << "Test failed!" << std::endl; std::cerr << "Error in pixel value at index [" << oIt.GetIndex() << "]" << std::endl; std::cerr << "Expected value " << expectedValue << std::endl; std::cerr << " differs from " << oIt.Get(); std::cerr << " by more than " << epsilon << std::endl; return EXIT_FAILURE; - } - ++oIt; } + ++oIt; +} \end{minted} \normalsize @@ -3549,7 +3567,7 @@ \section{Printing Variables} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -Superclass::PrintSelf( os, indent ); +Superclass::PrintSelf(os, indent); os << indent << "" << << std::endl; \end{minted} @@ -3564,7 +3582,7 @@ \section{Printing Variables} \item Without harm to the previous convention, constructs such as images can be printed using the \code{Print} method. \item Objects that have been declared as a type alias must be casted -statically using the \code{NumericTraits< Type >::PrintType >} helper +statically using the \code{NumericTraits::PrintType} helper formatting. \item The order of the variables should be the same used in their declaration. \end{itemize} @@ -3573,24 +3591,24 @@ \section{Printing Variables} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage > +template void -MinimumMaximumImageCalculator< TInputImage > -::PrintSelf( std::ostream & os, Indent indent ) const +MinimumMaximumImageCalculator +::PrintSelf(std::ostream & os, Indent indent) const { - Superclass::PrintSelf( os, indent ); + Superclass::PrintSelf(os, indent); os << indent << "Minimum: " - << static_cast< typename NumericTraits< PixelType >::PrintType >( m_Minimum ) + << static_cast::PrintType>(m_Minimum) << std::endl; os << indent << "Maximum: " - << static_cast< typename NumericTraits< PixelType >::PrintType >( m_Maximum ) + << static_cast::PrintType>(m_Maximum) << std::endl; os << indent << "IndexOfMinimum: " << m_IndexOfMinimum << std::endl; os << indent << "IndexOfMaximum: " << m_IndexOfMaximum << std::endl; - itkPrintSelfObjectMacro( Image ); + itkPrintSelfObjectMacro(Image); os << indent << "Region: " << std::endl; - m_Region.Print( os, indent.GetNextIndent() ); + m_Region.Print(os, indent.GetNextIndent()); os << indent << "RegionSetByUser: " << m_RegionSetByUser << std::endl; } \end{minted} @@ -3655,7 +3673,7 @@ \subsection{Regressions in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkAbsImageFilterAndAdaptorTest( int, char* [] ) +int itkAbsImageFilterAndAdaptorTest(int, char *[]) { int testStatus = EXIT_SUCCESS; @@ -3665,27 +3683,27 @@ \subsection{Regressions in Tests} const OutputImageType::PixelType epsilon = 1e-6; ot.GoToBegin(); it.GoToBegin(); - while( !ot.IsAtEnd() ) - { - std::cout.precision( static_cast< int >( itk::Math::abs( std::log10( epsilon ) ) ) ); + while (!ot.IsAtEnd()) + { + std::cout.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); std::cout << ot.Get() << " = "; - std::cout << itk::Math::abs( it.Get() ) << std::endl; + std::cout << itk::Math::abs(it.Get()) << std::endl; const InputImageType::PixelType input = it.Get(); const OutputImageType::PixelType output = ot.Get(); const OutputImageType::PixelType absolute = itk::Math::abs(input); - if( !itk::Math::FloatAlmostEqual( absolute, output, 10, epsilon ) ) - { - std::cerr.precision( static_cast< int >( itk::Math::abs( std::log10( epsilon ) ) ) ); + if (!itk::Math::FloatAlmostEqual(absolute, output, 10, epsilon)) + { + std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); std::cerr << "Test failed!" << std::endl; std::cerr << "Error in pixel value at index [" << oIt.GetIndex() << "]" << std::endl; std::cerr << "Expected value " << abs(" << input << ") = " << absolute << std::endl; std::cerr << " differs from " << output(); std::cerr << " by more than " << epsilon << std::endl; testStatus = EXIT_FAILURE; - } + } ++ot; ++it; - } + } // // Test AbsImageAdaptor @@ -3698,16 +3716,16 @@ \subsection{Regressions in Tests} std::cout << "Verification of the output " << std::endl; // Create an iterator for going through the image output. - OutputIteratorType dt( diffImage, diffImage->GetRequestedRegion() ); + OutputIteratorType dt(diffImage, diffImage->GetRequestedRegion()); dt.GoToBegin(); - while( !dt.IsAtEnd() ) - { - std::cout.precision( static_cast< int >( itk::Math::abs( std::log10( epsilon ) ) ) ); + while (!dt.IsAtEnd()) + { + std::cout.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); const OutputImageType::PixelType diff = dt.Get(); - if( !itk::Math::FloatAlmostEqual( diff, ( OutputImageType::PixelType )0, 10, epsilon ) ) - { - std::cerr.precision( static_cast< int >( itk::Math::abs( std::log10( epsilon ) ) ) ); + if (!itk::Math::FloatAlmostEqual(diff, (OutputImageType::PixelType)0, 10, epsilon)) + { + std::cerr.precision(static_cast(itk::Math::abs(std::log10(epsilon)))); std::cerr << "Test failed!" << std::endl; std::cerr << "Error in pixel value at index [" << dt.GetIndex() << "]" << std::endl; std::cerr << "Expected difference " << diff << std::endl; @@ -3718,7 +3736,7 @@ \subsection{Regressions in Tests} ++dt; } - std::cout << "Test finished."; + std::cout << "Test finished." << std::endl; return testStatus; } \end{minted} @@ -3748,7 +3766,7 @@ \subsection{Arguments in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkVersionTest( int, char* [] ) +int itkVersionTest(int, char *[]) \end{minted} \normalsize @@ -3758,7 +3776,7 @@ \subsection{Arguments in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkGaborKernelFunctionTest( int itkNotUsed( argc ), char * itkNotUsed( argv )[] ) +int itkGaborKernelFunctionTest(int itkNotUsed(argc), char * itkNotUsed(argv)[]) \end{minted} \normalsize @@ -3768,13 +3786,13 @@ \subsection{Arguments in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( argc != 3 ) - { +if (argc != 3) +{ std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); std::cerr << " inputImage outputImage " << std::endl; return EXIT_FAILURE; - } +} \end{minted} \normalsize @@ -3783,8 +3801,8 @@ \subsection{Arguments in Tests} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -if( argc < 3 ) - { +if (argc < 3) +{ std::cerr << "Missing parameters." << std::endl; std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv); std::cerr << " inputImage" @@ -3792,7 +3810,7 @@ \subsection{Arguments in Tests} << " [foregroundValue] << " [backgroundValue]" << std::endl; return EXIT_FAILURE; - } +} \end{minted} \normalsize @@ -3826,7 +3844,7 @@ \subsection{Test Return Value} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkVersionTest( int, char* [] ) +int itkVersionTest(int, char *[]) \end{minted} \normalsize @@ -3835,7 +3853,7 @@ \subsection{Test Return Value} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -int itkAbsImageFilterAndAdaptorTest( int, char* [] ) +int itkAbsImageFilterAndAdaptorTest(int, char *[]) { int testStatus = EXIT_SUCCESS; @@ -3938,11 +3956,19 @@ \subsection{General Principles} \small \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} -template< typename TInputImage, typename TOutputImage > -BoxImageFilter< TInputImage, TOutputImage > -::BoxImageFilter() +template +void +SpecializedImageFilter +::SpecializedMethod() { - m_Radius.Fill( 1 ); // A good arbitrary starting point. + ... + + OutputVectorRealType lambda11 = -(x1 * v1) / ((x - x1) * v1); // upper left + OutputVectorRealType lambda12 = -(x1 * v2) / ((x - x1) * v2); // upper right + OutputVectorRealType lambda21 = -(x2 * v1) / ((x - x2) * v1); // lower left + OutputVectorRealType lambda22 = -(x2 * v2) / ((x - x2) * v2); // lower right + + ... } \end{minted} \normalsize @@ -4035,11 +4061,11 @@ \subsection{Documenting Methods} \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} // We wish to copy whole lines, otherwise just use the basic implementation. // Check that the number of internal components match. -if( inRegion.GetSize()[0] != outRegion.GetSize()[0] - || NumberOfInternalComponents != ImageAlgorithm::PixelSize::Get( outImage ) ) +if (inRegion.GetSize()[0] != outRegion.GetSize()[0] + || NumberOfInternalComponents != ImageAlgorithm::PixelSize::Get(outImage)) { -ImageAlgorithm::DispatchedCopy( inImage, outImage, inRegion, - outRegion ); +ImageAlgorithm::DispatchedCopy(inImage, outImage, inRegion, + outRegion); return; } \end{minted} @@ -4062,8 +4088,8 @@ \subsection{Documenting Data Members} public: /** Set/Get the standard deviation of the Gaussian used for smoothing. */ - itkSetMacro( Sigma, SigmaArrayType ); - itkGetConstMacro( Sigma, SigmaArrayType ); + itkSetMacro(Sigma, SigmaArrayType); + itkGetConstMacro(Sigma, SigmaArrayType); private: @@ -4083,9 +4109,9 @@ \subsection{Documenting Data Members} /** Set/Get direction along the gradient to search. * Set to true to use the direction that the gradient is pointing; * set to false for the opposite direction. Default is Off. */ -itkGetConstMacro( Polarity, bool ); -itkSetMacro( Polarity, bool ); -itkBooleanMacro( Polarity ); +itkGetConstMacro(Polarity, bool); +itkSetMacro(Polarity, bool); +itkBooleanMacro(Polarity); \end{minted} \normalsize @@ -4109,22 +4135,23 @@ \subsection{Documenting Macros} \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cpp} /** This macro is used to print debug (or other information). They are * also used to catch errors, etc. Example usage looks like: - * itkDebugMacro( << "this is debug info" << this->SomeVariable ); */ -#if defined( NDEBUG ) -#define itkDebugMacro(x) -#define itkDebugStatement(x) + * itkDebugMacro(<< "this is debug info" << this->SomeVariable); */ +#if defined(NDEBUG) +# define itkDebugMacro(x) +# define itkDebugStatement(x) #else -#define itkDebugMacro(x) \ - { \ - if ( this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay() ) \ - { \ - std::ostringstream itkmsg; \ - itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \ - << this->GetNameOfClass() << " (" << this << "): " x \ - << "\n\n"; \ - ::itk::OutputWindowDisplayDebugText( itkmsg.str().c_str() ); \ - } \ - } +# define itkDebugMacro(x) \ + do \ + { \ + if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \ + { \ + std::ostringstream itkmsg; \ + itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \ + << this->GetNameOfClass() << " (" << this << "): " x \ + << "\n\n"; \ + ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \ + } \ + } while (0) \end{minted} \normalsize @@ -4149,7 +4176,7 @@ \subsection{Documenting Tests} /* Test the SetMetricSamplingPercentage and SetMetricSamplingPercentagePerLevel. * We only need to explicitly run the SetMetricSamplingPercentage method because * it invokes the SetMetricSamplingPercentagePerLevel method. */ -int itkImageRegistrationSamplingTest( int, char *[] ) +int itkImageRegistrationSamplingTest(int, char *[]) \end{minted} \normalsize