From d0200599c0dd50202bc60ddcbdaf714f1cc46c7b Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Mon, 18 Apr 2016 21:11:18 -0500 Subject: [PATCH] COMP: Address CPPCHECK warnings Several cppcheck warnings were addressed. Removed redundant typedefs and redundant shadow variables. Also added testing of previously unused functions. --- BRAINSCommonLib/BRAINSFitHelperTemplate.hxx | 1 - BRAINSCommonLib/ExtractSingleLargestRegion.cxx | 2 ++ BRAINSCommonLib/ExtractSingleLargestRegion.h | 2 ++ BRAINSCommonLib/TestSuite/PrettyPrintTableTest.cxx | 31 +++++++++------------- .../itkLargestForegroundFilledMaskImageFilter.h | 7 +---- .../itkLargestForegroundFilledMaskImageFilter.hxx | 6 +---- ImageCalculator/ImageGenerate.cxx | 10 +++---- 7 files changed, 24 insertions(+), 35 deletions(-) diff --git a/BRAINSCommonLib/BRAINSFitHelperTemplate.hxx b/BRAINSCommonLib/BRAINSFitHelperTemplate.hxx index be65d79a4..b98fa3351 100644 --- a/BRAINSCommonLib/BRAINSFitHelperTemplate.hxx +++ b/BRAINSCommonLib/BRAINSFitHelperTemplate.hxx @@ -317,7 +317,6 @@ DoCenteredInitialization( typename FixedImageType::Pointer & orientedFixedVolume bestEulerAngles3D->SetCenter(rotationCenter); bestEulerAngles3D->SetTranslation(translationVector); - typedef itk::Euler3DTransform EulerAngle3DTransformType; typename EulerAngle3DTransformType::Pointer currentEulerAngles3D = EulerAngle3DTransformType::New(); currentEulerAngles3D->SetCenter(rotationCenter); diff --git a/BRAINSCommonLib/ExtractSingleLargestRegion.cxx b/BRAINSCommonLib/ExtractSingleLargestRegion.cxx index 09c06af29..daa10b1fd 100644 --- a/BRAINSCommonLib/ExtractSingleLargestRegion.cxx +++ b/BRAINSCommonLib/ExtractSingleLargestRegion.cxx @@ -128,6 +128,7 @@ ExtractSingleLargestRegionFromMask(itk::Image::Pointer Mask, return myMult2->GetOutput(); } +#if 0 itk::Image::Pointer ExtractSingleLargestRegion(const unsigned char threshold_low, const unsigned char threshold_high, const int openingSize, const int closingSize, const int safetySize, @@ -146,3 +147,4 @@ ExtractSingleLargestRegion(const unsigned char threshold_low, const unsigned cha return ExtractSingleLargestRegionFromMask( threshold->GetOutput(), openingSize, closingSize, safetySize, inputLabelImage); } +#endif diff --git a/BRAINSCommonLib/ExtractSingleLargestRegion.h b/BRAINSCommonLib/ExtractSingleLargestRegion.h index e41b1d911..7c3c8219f 100644 --- a/BRAINSCommonLib/ExtractSingleLargestRegion.h +++ b/BRAINSCommonLib/ExtractSingleLargestRegion.h @@ -27,11 +27,13 @@ itk::Image::Pointer ExtractSingleLargestRegionFromMask(itk::Im const int safetySize, itk::Image::Pointer inputLabelImage); +#if 0 extern itk::Image::Pointer ExtractSingleLargestRegion(const unsigned char threshold_low, const unsigned char threshold_high, const int openingSize, const int closingSize, const int safetySize, itk::Image::Pointer inputLabelImage); +#endif #endif // ExtractSingleLargestRegion_h diff --git a/BRAINSCommonLib/TestSuite/PrettyPrintTableTest.cxx b/BRAINSCommonLib/TestSuite/PrettyPrintTableTest.cxx index 9f7e17172..773325d63 100644 --- a/BRAINSCommonLib/TestSuite/PrettyPrintTableTest.cxx +++ b/BRAINSCommonLib/TestSuite/PrettyPrintTableTest.cxx @@ -18,6 +18,7 @@ *=========================================================================*/ #include #include "PrettyPrintTable.h" +#include "BRAINSToolsVersion.h" int main(int, char * *) { @@ -25,40 +26,34 @@ int main(int, char * *) p.setTablePad(5); p.add(0, 0, "String"); - p.add(0, 1, "SecondColumn"); - p.add(0, 2, "4C"); - p.add(0, 3, "5C"); - p.add(1, 0, "Integers"); - p.add(1, 1, 1, "%d"); // Similar to %d - p.add(1, 2, 2, "%d"); - p.add(1, 3, 3, "%d"); - p.add(1, 0, "ZeroPadInt"); - p.add(1, 1, 1, "%02d"); // Similar to %02d in printf - p.add(1, 2, 2, "%02d"); - p.add(1, 3, 3, "%02d"); - p.add(2, 0, "FloatingPoint"); - p.add(2, 1, 1.0F, "%+5.2f"); // Similar to %5.2f in printf - p.add(2, 2, 2.0F, "%+5.2f"); - p.add(2, 3, 3.0F, "%+5.2f"); - p.Print(std::cout); - p.rightJustify(); - p.Print(std::cout); + + std::cout << "MajorVersion: " << BRAINSTools::Version::MajorVersion() << std::endl; + std::cout << "MinorVersion: " << BRAINSTools::Version::MinorVersion() << std::endl; + std::cout << "PatchVersion: " << BRAINSTools::Version::PatchVersion() << std::endl; + std::cout << "TweakVersion: " << BRAINSTools::Version::TweakVersion() << std::endl; + std::cout << "VersionString: " << BRAINSTools::Version::VersionString() << std::endl; + std::cout << "BuildDate: " << BRAINSTools::Version::BuildDate() << std::endl; + + std::cout << "ExtendedVersionString: " << BRAINSTools::Version::ExtendedVersionString() << std::endl; + std::cout << "ToString: " << BRAINSTools::Version::ToString() << std::endl; + + return EXIT_SUCCESS; } diff --git a/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.h b/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.h index 3fd086304..bd0cf8697 100644 --- a/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.h +++ b/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.h @@ -58,11 +58,6 @@ class LargestForegroundFilledMaskImageFilter : public ImageToImageFilter { public: - /** Extract dimension from input and output image. */ - itkStaticConstMacro(InputImageDimension, unsigned int, - TInputImage::ImageDimension); - itkStaticConstMacro(OutputImageDimension, unsigned int, - TOutputImage::ImageDimension); /** Convenient typedefs for simplifying declarations. */ typedef TInputImage InputImageType; @@ -138,7 +133,7 @@ class LargestForegroundFilledMaskImageFilter : * Low and High are set to the ?????? */ unsigned int SetLowHigh(InputPixelType & low, InputPixelType & high); - void ImageMinMax(InputPixelType & min, InputPixelType & max); + void ImageMinMax(InputPixelType & min, InputPixelType & max) const; // No longer used double m_OtsuPercentileThreshold; double m_OtsuPercentileLowerThreshold; diff --git a/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.hxx b/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.hxx index 4d812bf67..7c2fb72a1 100644 --- a/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.hxx +++ b/BRAINSCommonLib/itkLargestForegroundFilledMaskImageFilter.hxx @@ -55,10 +55,6 @@ LargestForegroundFilledMaskImageFilter m_InsideValue(NumericTraits::OneValue()), m_OutsideValue(NumericTraits::ZeroValue()) { - // this->m_InsideValue = - // NumericTraits::OneValue(); - // this->m_OutsideValue = - // NumericTraits::ZeroValue(); } template @@ -90,7 +86,7 @@ template void LargestForegroundFilledMaskImageFilter ::ImageMinMax(typename TInputImage::PixelType & imageMin, - typename TInputImage::PixelType & imageMax) + typename TInputImage::PixelType & imageMax) const { typename MinimumMaximumImageFilter::Pointer minmaxFilter = MinimumMaximumImageFilter::New(); diff --git a/ImageCalculator/ImageGenerate.cxx b/ImageCalculator/ImageGenerate.cxx index d81918349..b8b05b26e 100644 --- a/ImageCalculator/ImageGenerate.cxx +++ b/ImageCalculator/ImageGenerate.cxx @@ -194,11 +194,11 @@ ProcessArgs(int argc, char * *argv, template int MakeImage(const std::string & filename, - unsigned xdim, - unsigned ydim, - unsigned zdim, - unsigned tdim, - PixelType value) + const unsigned xdim, + const unsigned ydim, + const unsigned zdim, + const unsigned tdim, + const PixelType value) { typedef typename itk::Image ImageType; typedef typename ImageType::Pointer ImagePointerType;